]> git.pld-linux.org Git - packages/kernel.git/blob - patch-2.6.0-test4-bk6
- obsolete
[packages/kernel.git] / patch-2.6.0-test4-bk6
1 diff -Nru a/CREDITS b/CREDITS
2 --- a/CREDITS   Wed Aug 20 04:45:18 2003
3 +++ b/CREDITS   Tue Sep  2 11:40:27 2003
4 @@ -281,6 +281,14 @@
5  S: Greenbelt, Maryland 20771
6  S: USA
7  
8 +N: Daniele Bellucci
9 +E: bellucda@tiscali.it
10 +D: Various Janitor work.
11 +W: http://web.tiscali.it/bellucda
12 +S: Via Delle Palme, 9
13 +S: Terni 05100
14 +S: Italy
15 +
16  N: Randolph Bentson
17  E: bentson@grieg.seaslug.org
18  W: http://www.aa.net/~bentson/
19 @@ -1279,14 +1287,13 @@
20  
21  N: Christoph Hellwig
22  E: hch@infradead.org
23 -E: hch@sgi.com
24  D: all kinds of driver, filesystem & core kernel hacking
25  D: freevxfs driver
26  D: sysvfs maintainer
27  D: chief codingstyle nitpicker
28 -S: Auweg 38
29 -S: 85748 Garching
30 -S: Germany
31 +S: Ampferstr. 50 / 4
32 +S: 6020 Innsbruck
33 +S: Austria
34  
35  N: Richard Henderson
36  E: rth@twiddle.net
37 diff -Nru a/Documentation/DocBook/kernel-locking.tmpl b/Documentation/DocBook/kernel-locking.tmpl
38 --- a/Documentation/DocBook/kernel-locking.tmpl Thu Dec  5 18:56:55 2002
39 +++ b/Documentation/DocBook/kernel-locking.tmpl Sun Aug 31 16:14:01 2003
40 @@ -463,7 +463,7 @@
41        <function>spin_lock_irqsave()</function> 
42        (<filename>include/linux/spinlock.h</filename>) is a variant
43        which saves whether interrupts were on or off in a flags word,
44 -      which is passed to <function>spin_lock_irqrestore()</function>.  This 
45 +      which is passed to <function>spin_unlock_irqrestore()</function>.  This
46        means that the same code can be used inside an hard irq handler (where
47        interrupts are already off) and in softirqs (where the irq
48        disabling is required).
49 diff -Nru a/Documentation/DocBook/writing_usb_driver.tmpl b/Documentation/DocBook/writing_usb_driver.tmpl
50 --- a/Documentation/DocBook/writing_usb_driver.tmpl     Tue Oct 29 09:47:57 2002
51 +++ b/Documentation/DocBook/writing_usb_driver.tmpl     Wed Aug 20 09:40:22 2003
52 @@ -111,12 +111,12 @@
53    </para>
54    <programlisting>
55  static struct usb_driver skel_driver = {
56 -        name:        "skeleton",
57 -        probe:       skel_probe,
58 -        disconnect:  skel_disconnect,
59 -        fops:        &amp;skel_fops,
60 -        minor:       USB_SKEL_MINOR_BASE,
61 -        id_table:    skel_table,
62 +        .name        = "skeleton",
63 +        .probe       = skel_probe,
64 +        .disconnect  = skel_disconnect,
65 +        .fops        = &amp;skel_fops,
66 +        .minor       = USB_SKEL_MINOR_BASE,
67 +        .id_table    = skel_table,
68  };
69    </programlisting>
70    <para>
71 @@ -202,41 +202,21 @@
72       are passed to the function:
73    </para>
74    <programlisting>
75 -static void * skel_probe(struct usb_device *dev,
76 -unsigned int ifnum, const struct usb_device_id *id)
77 +static int skel_probe(struct usb_interface *interface,
78 +    const struct usb_device_id *id)
79    </programlisting>
80    <para>
81       The driver now needs to verify that this device is actually one that it
82 -     can accept. If not, or if any error occurs during initialization, a NULL
83 -     value is returned from the probe function. Otherwise a pointer to a
84 -     private data structure containing the driver's state for this device is
85 -     returned. That pointer is stored in the usb_device structure, and all
86 -     callbacks to the driver pass that pointer.
87 +     can accept. If so, it returns 0.
88 +     If not, or if any error occurs during initialization, an errorcode
89 +     (such as <literal>-ENOMEM<literal> or <literal>-ENODEV<literal>)
90 +     is returned from the probe function.
91    </para>
92    <para>
93       In the skeleton driver, we determine what end points are marked as bulk-in
94       and bulk-out. We create buffers to hold the data that will be sent and
95       received from the device, and a USB urb to write data to the device is
96 -     initialized. Also, we register the device with the devfs subsystem,
97 -     allowing users of devfs to access our device. That registration looks like
98 -     the following:
99 -  </para>
100 -  <programlisting>
101 -/* initialize the devfs node for this device and register it */
102 -sprintf(name, &quot;skel%d&quot;, skel->minor);
103 -skel->devfs = devfs_register (usb_devfs_handle,
104 -                              name,
105 -                              DEVFS_FL_DEFAULT,
106 -                              USB_MAJOR,
107 -                              USB_SKEL_MINOR_BASE + skel->minor,
108 -                              S_IFCHR | S_IRUSR | S_IWUSR |
109 -                              S_IRGRP | S_IWGRP | S_IROTH,
110 -                              &amp;skel_fops,
111 -                              NULL);
112 -  </programlisting>
113 -  <para>
114 -     If the devfs_register function fails, we do not care, as the devfs
115 -     subsystem will report this to the user.
116 +     initialized.
117    </para>
118    <para>
119       Conversely, when the device is removed from the USB bus, the disconnect
120 @@ -254,23 +234,18 @@
121       the device, any of the functions in the file_operations structure that
122       were passed to the USB subsystem will be called from a user program trying
123       to talk to the device. The first function called will be open, as the
124 -     program tries to open the device for I/O. Within the skeleton driver's
125 -     open function we increment the driver's usage count if it is a module with
126 -     a call to MODULE_INC_USE_COUNT. With this macro call, if the driver is
127 -     compiled as a module, the driver cannot be unloaded until a corresponding
128 -     MODULE_DEC_USE_COUNT macro is called.  We also increment our private usage
129 +     program tries to open the device for I/O. We increment our private usage
130       count and save off a pointer to our internal structure in the file
131       structure. This is done so that future calls to file operations will
132 -     enable the driver to determine which device the user is addressing. All of
133 -     this is done with the following code:
134 +     enable the driver to determine which device the user is addressing.  All
135 +     of this is done with the following code:
136    </para>
137    <programlisting>
138  /* increment our usage count for the module */
139 -MOD_INC_USE_COUNT;
140  ++skel->open_count;
141  
142  /* save our object in the file's private structure */
143 -file->private_data = skel;
144 +file->private_data = dev;
145    </programlisting>
146    <para>
147       After the open function is called, the read and write functions are called
148 @@ -349,75 +324,47 @@
149    </para>
150    <para>
151       When the user program releases the file handle that it has been using to
152 -     talk to the device, the release function in the driver is called.  In this
153 -     function we decrement the module usage count with a call to
154 -     MOD_DEC_USE_COUNT (to match our previous call to MOD_INC_USE_COUNT).  We
155 -     also determine if there are any other programs that are currently talking
156 -     to the device (a device may be opened by more than one program at one
157 -     time). If this is the last user of the device, then we shut down any
158 -     possible pending writes that might be currently occurring.  This is all
159 -     done with:
160 -  </para>
161 +     talk to the device, the release function in the driver is called. In this
162 +     function we decrement our private usage count and wait for possible
163 +     pending writes:
164    <programlisting>
165  /* decrement our usage count for the device */
166  --skel->open_count;
167 -if (skel->open_count &lt;= 0) {
168 -        /* shutdown any bulk writes that might be going on */
169 -        usb_unlink_urb (skel->write_urb);
170 -        skel->open_count = 0;
171 -}
172 -/* decrement our usage count for the module */
173 -MOD_DEC_USE_COUNT;
174    </programlisting>
175    <para>
176       One of the more difficult problems that USB drivers must be able to handle
177       smoothly is the fact that the USB device may be removed from the system at
178       any point in time, even if a program is currently talking to it. It needs
179       to be able to shut down any current reads and writes and notify the
180 -     user-space programs that the device is no longer there.  The following
181 -     code is an example of how to do this: </para>
182 +     user-space programs that the device is no longer there. The following
183 +     code (function <function>skel_delete</function>)
184 +     is an example of how to do this: </para>
185    <programlisting>
186 -/* if the device is not opened, then we clean right now */
187 -if (skel->open_count) {
188 -        minor_table[skel->minor] = NULL;
189 -        if (skel->bulk_in_buffer != NULL)
190 -                kfree (skel->bulk_in_buffer);
191 -        if (skel->bulk_out_buffer != NULL)
192 -                kfree (skel->bulk_out_buffer);
193 -        if (skel->write_urb != NULL)
194 -                usb_free_urb (skel->write_urb);
195 -        kfree (skel);
196 -} else {
197 -        skel->dev = NULL;
198 -        up (&amp;skel->sem);
199 +static inline void skel_delete (struct usb_skel *dev)
200 +{
201 +    if (dev->bulk_in_buffer != NULL)
202 +        kfree (dev->bulk_in_buffer);
203 +    if (dev->bulk_out_buffer != NULL)
204 +        usb_buffer_free (dev->udev, dev->bulk_out_size,
205 +            dev->bulk_out_buffer,
206 +            dev->write_urb->transfer_dma);
207 +    if (dev->write_urb != NULL)
208 +        usb_free_urb (dev->write_urb);
209 +    kfree (dev);
210  }
211    </programlisting>
212    <para>
213 -     If a program currently has an open handle to the device, we only null the
214 -     usb_device structure in our local structure, as it has now gone away. For
215 +     If a program currently has an open handle to the device, we reset the flag
216 +     <literal>device_present</literal>. For
217       every read, write, release and other functions that expect a device to be
218 -     present, the driver first checks to see if this usb_device structure is
219 +     present, the driver first checks this flag to see if the device is
220       still present. If not, it releases that the device has disappeared, and a
221 -     -ENODEV error is returned to the user-space program.  When the release
222 -     function is eventually called, it determines if there is no usb_device
223 -     structure and if not, it does the cleanup that the skel_disconnect
224 +     -ENODEV error is returned to the user-space program. When the release
225 +     function is eventually called, it determines if there is no device
226 +     and if not, it does the cleanup that the skel_disconnect
227       function normally does if there are no open files on the device (see
228       Listing 5).
229    </para>
230 -  <programlisting>
231 -if (skel->dev == NULL) {
232 -        /* the device was unplugged before the file was released */
233 -        minor_table[skel->minor] = NULL;
234 -        if (skel->bulk_in_buffer != NULL)
235 -                kfree (skel->bulk_in_buffer);
236 -        if (skel->bulk_out_buffer != NULL)
237 -                kfree (skel->bulk_out_buffer);
238 -        if (skel->write_urb != NULL)
239 -                usb_free_urb (skel->write_urb);
240 -        kfree (skel);
241 -        goto exit;
242 -}
243 -  </programlisting>
244    </chapter>
245  
246    <chapter id="iso">
247 diff -Nru a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
248 --- a/Documentation/filesystems/proc.txt        Sun Jun  1 14:12:47 2003
249 +++ b/Documentation/filesystems/proc.txt        Sun Aug 31 16:15:48 2003
250 @@ -25,6 +25,7 @@
251    1.5  SCSI info
252    1.6  Parallel port info in /proc/parport
253    1.7  TTY info in /proc/tty
254 +  1.8  Miscellaneous kernel statistics in /proc/stat
255  
256    2    Modifying System Parameters
257    2.1  /proc/sys/fs - File system data
258 @@ -702,6 +703,58 @@
259    /dev/console         /dev/console    5       1 system:console 
260    /dev/tty             /dev/tty        5       0 system:/dev/tty 
261    unknown              /dev/tty        4    1-63 console 
262 +
263 +
264 +1.8 Miscellaneous kernel statistics in /proc/stat
265 +-------------------------------------------------
266 +
267 +Various pieces   of  information about  kernel activity  are  available in the
268 +/proc/stat file.  All  of  the numbers reported  in  this file are  aggregates
269 +since the system first booted.  For a quick look, simply cat the file:
270 +
271 +  > cat /proc/stat
272 +  cpu  2255 34 2290 22625563 6290 127 456
273 +  cpu0 1132 34 1441 11311718 3675 127 438
274 +  cpu1 1123 0 849 11313845 2614 0 18
275 +  intr 114930548 113199788 3 0 5 263 0 4 [... lots more numbers ...]
276 +  ctxt 1990473
277 +  btime 1062191376
278 +  processes 2915
279 +  procs_running 1
280 +  procs_blocked 0
281 +
282 +The very first  "cpu" line aggregates the  numbers in all  of the other "cpuN"
283 +lines.  These numbers identify the amount of time the CPU has spent performing
284 +different kinds of work.  Time units are in USER_HZ (typically hundredths of a
285 +second).  The meanings of the columns are as follows, from left to right:
286 +
287 +- user: normal processes executing in user mode
288 +- nice: niced processes executing in user mode
289 +- system: processes executing in kernel mode
290 +- idle: twiddling thumbs
291 +- iowait: waiting for I/O to complete
292 +- irq: servicing interrupts
293 +- softirq: servicing softirqs
294 +
295 +The "intr" line gives counts of interrupts  serviced since boot time, for each
296 +of the  possible system interrupts.   The first  column  is the  total of  all
297 +interrupts serviced; each  subsequent column is the  total for that particular
298 +interrupt.
299 +
300 +The "ctxt" line gives the total number of context switches across all CPUs.
301 +
302 +The "btime" line gives  the time at which the  system booted, in seconds since
303 +the Unix epoch.
304 +
305 +The "processes" line gives the number  of processes and threads created, which
306 +includes (but  is not limited  to) those  created by  calls to the  fork() and
307 +clone() system calls.
308 +
309 +The  "procs_running" line gives the  number of processes  currently running on
310 +CPUs.
311 +
312 +The   "procs_blocked" line gives  the  number of  processes currently blocked,
313 +waiting for I/O to complete.
314  
315  
316  ------------------------------------------------------------------------------
317 diff -Nru a/Documentation/ide.txt b/Documentation/ide.txt
318 --- a/Documentation/ide.txt     Mon May 26 17:48:43 2003
319 +++ b/Documentation/ide.txt     Sun Aug 31 16:13:57 2003
320 @@ -1,5 +1,5 @@
321  
322 -       Information regarding the Enhanced IDE drive in Linux 2.5
323 +       Information regarding the Enhanced IDE drive in Linux 2.6
324  
325  ==============================================================================
326  
327 @@ -242,8 +242,23 @@
328                           and quite likely to cause trouble with
329                           older/odd IDE drives.
330  
331 + "hdx=biostimings"     : driver will NOT attempt to tune interface speed
332 +                         (DMA/PIO) but always honour BIOS timings.
333 +
334   "hdx=slow"            : insert a huge pause after each access to the data
335                           port. Should be used only as a last resort.
336 +
337 + "hdx=swapdata"                : when the drive is a disk, byte swap all data
338 +
339 + "hdx=bswap"           : same as above..........
340 +
341 + "hdx=flash"           : allows for more than one ata_flash disk to be
342 +                         registered. In most cases, only one device
343 +                         will be present.
344 +
345 + "hdx=scsi"            : the return of the ide-scsi flag, this is useful for
346 +                         allowing ide-floppy, ide-tape, and ide-cdrom|writers
347 +                         to use ide-scsi emulation on a device specific option.
348                                 
349   "hdxlun=xx"           : set the drive last logical unit
350  
351 @@ -277,27 +292,41 @@
352   "idex=noautotune"     : driver will NOT attempt to tune interface speed 
353                           This is the default for most chipsets,
354                           except the cmd640.
355 +
356 + "idex=biostimings"    : driver will NOT attempt to tune interface speed
357 +                         (DMA/PIO) but always honour BIOS timings.
358                                 
359   "idex=serialize"      : do not overlap operations on idex. Please note
360                           that you will have to specify this option for
361                           both the respecitve primary and secondary channel
362                           to take effect.
363 +
364 + "idex=four"           : four drives on idex and ide(x^1) share same ports
365                         
366   "idex=reset"          : reset interface after probe
367   
368   "idex=dma"            : automatically configure/use DMA if possible.
369  
370 -The following are valid ONLY on ide0, which usually corresponds to the first
371 -ATA interface found on the particular host, and the defaults for the base,ctl
372 -ports must not be altered.
373 + "idex=ata66"          : informs the interface that it has an 80c cable
374 +                         for chipsets that are ATA-66 capable, but the
375 +                         ability to bit test for detection is currently
376 +                         unknown.
377 +
378 + "ide=reverse"         : formerly called to pci sub-system, but now local.
379 +
380 +The following are valid ONLY on ide0 (except dc4030), which usually corresponds
381 +to the first ATA interface found on the particular host, and the defaults for
382 +the base,ctl ports must not be altered.
383  
384   "ide0=dtc2278"                : probe/support DTC2278 interface
385   "ide0=ht6560b"                : probe/support HT6560B interface
386   "ide0=cmd640_vlb"     : *REQUIRED* for VLB cards with the CMD640 chip
387                           (not for PCI -- automatically detected)
388   "ide0=qd65xx"         : probe/support qd65xx interface
389 - "ide0=ali14xx"                : probe/support ali14xx chipsets (ALI M1439/M1445)
390 + "ide0=ali14xx"                : probe/support ali14xx chipsets (ALI M1439/M1443/M1445)
391   "ide0=umc8672"                : probe/support umc8672 chipsets
392 + "idex=dc4030"         : probe/support Promise DC4030VL interface
393 + "ide=doubler"         : probe/support IDE doublers on Amiga
394  
395  There may be more options than shown -- use the source, Luke!
396  
397 @@ -375,3 +404,6 @@
398  
399  Wed Apr 17 22:52:44 CEST 2002 edited by Marcin Dalecki, the current
400  maintainer.
401 +
402 +Wed Aug 20 22:31:29 CEST 2003 updated ide boot uptions to current ide.c
403 +comments at 2.6.0-test4 time. Maciej Soltysiak <solt@dns.toxicfilms.tv>
404 diff -Nru a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
405 --- a/Documentation/kernel-parameters.txt       Mon Aug 18 22:27:07 2003
406 +++ b/Documentation/kernel-parameters.txt       Sun Aug 31 16:14:50 2003
407 @@ -215,7 +215,10 @@
408                         when calculating gettimeofday(). If specicified timesource
409                         is not avalible, it defaults to PIT. 
410                         Format: { pit | tsc | cyclone | ... }
411 -                       
412 +
413 +       hpet=           [IA-32,HPET] option to disable HPET and use PIT.
414 +                       Format: disable
415 +
416         cm206=          [HW,CD]
417                         Format: { auto | [<io>,][<irq>] }
418  
419 diff -Nru a/Documentation/kmod.txt b/Documentation/kmod.txt
420 --- a/Documentation/kmod.txt    Tue Feb  5 09:40:37 2002
421 +++ /dev/null   Wed Dec 31 16:00:00 1969
422 @@ -1,68 +0,0 @@
423 -Kmod: The Kernel Module Loader
424 -Kirk Petersen
425 -
426 -Kmod is a simple replacement for kerneld.  It consists of a 
427 -request_module() replacement and a kernel thread called kmod.  When the
428 -kernel requests a module, the kmod wakes up and execve()s modprobe,
429 -passing it the name that was requested.
430 -
431 -If you have the /proc filesystem mounted, you can set the path of
432 -modprobe (where the kernel looks for it) by doing:
433 -
434 -       echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
435 -
436 -To periodically unload unused modules, put something like the following
437 -in root's crontab entry:
438 -
439 -       0-59/5 * * * * /sbin/rmmod -a
440 -
441 -Kmod only loads modules.  Kerneld could do more (although
442 -nothing in the standard kernel used its other features).  If you
443 -require features such as request_route, we suggest that you take
444 -a similar approach.  A simple request_route function could be called,
445 -and a kroute kernel thread could be sent off to do the work.  But
446 -we should probably keep this to a minimum.
447 -
448 -Kerneld also had a mechanism for storing device driver settings.  This
449 -can easily be done with modprobe.  When a module is unloaded, modprobe
450 -could look at a per-driver-configurable location (/proc/sys/drivers/blah)
451 -for device driver settings and save them to a file.  When a module
452 -is loaded, simply cat that file back to that location in the proc
453 -filesystem.  Or perhaps a script could be a setting in /etc/modules.conf.
454 -There are many user-land methods that will work (I prefer using /proc,
455 -myself).
456 -
457 -If kerneld worked, why replace it?
458 -
459 -- kerneld used SysV IPC, which can now be made into a module.  Besides,
460 -  SysV IPC is ugly and should therefore be avoided (well, certainly for
461 -  kernel level stuff)
462 -
463 -- both kmod and kerneld end up doing the same thing (calling modprobe),
464 -  so why not skip the middle man?
465 -
466 -- removing kerneld related stuff from ipc/msg.c made it 40% smaller
467 -
468 -- kmod reports errors through the normal kernel mechanisms, which avoids
469 -  the chicken and egg problem of kerneld and modular Unix domain sockets
470 -
471 -
472 -Keith Owens <kaos@ocs.com.au> December 1999
473 -
474 -The combination of kmod and modprobe can loop, especially if modprobe uses a
475 -system call that requires a module.  If modules.dep does not exist and modprobe
476 -was started with the -s option (kmod does this), modprobe tries to syslog() a
477 -message.  syslog() needs Unix sockets, if Unix sockets are modular then kmod
478 -runs "modprobe -s net-pf-1".  This runs a second copy of modprobe which
479 -complains that modules.dep does not exist, tries to use syslog() and starts yet
480 -another copy of modprobe.  This is not the only possible kmod/modprobe loop,
481 -just the most common.
482 -
483 -To detect loops caused by "modprobe needs a service which is in a module", kmod
484 -limits the number of concurrent kmod issued modprobes.  See MAX_KMOD_CONCURRENT
485 -in kernel/kmod.c.  When this limit is exceeded, the kernel issues message "kmod:
486 -runaway modprobe loop assumed and stopped".
487 -
488 -Note for users building a heavily modularised system.  It is a good idea to
489 -create modules.dep after installing the modules and before booting a kernel for
490 -the first time.  "depmod -ae m.n.p" where m.n.p is the new kernel version.
491 diff -Nru a/Documentation/kobject.txt b/Documentation/kobject.txt
492 --- a/Documentation/kobject.txt Tue Jun 17 15:59:07 2003
493 +++ b/Documentation/kobject.txt Sun Aug 31 16:14:13 2003
494 @@ -245,7 +245,9 @@
495    see the sysfs documentation for more information. 
496  
497  - default_attrs: Default attributes to be exported via sysfs when the
498 -  object is registered. 
499 +  object is registered.Note that the last attribute has to be
500 +  initialized to NULL ! You can find a complete implementation
501 +  in drivers/block/genhd.c
502  
503  
504  Instances of struct kobj_type are not registered; only referenced by
505 diff -Nru a/Documentation/sonypi.txt b/Documentation/sonypi.txt
506 --- a/Documentation/sonypi.txt  Tue Mar 11 10:20:18 2003
507 +++ b/Documentation/sonypi.txt  Tue Aug 26 09:02:05 2003
508 @@ -8,7 +8,9 @@
509         Copyright (C) 2000 Andrew Tridgell <tridge@samba.org>
510  
511  This driver enables access to the Sony Programmable I/O Control Device which
512 -can be found in many (all ?) Sony Vaio laptops.
513 +can be found in many Sony Vaio laptops. Some newer Sony laptops (seems to be
514 +limited to new FX series laptops, at least the FX501 and the FX702) lack a
515 +sonypi device and are not supported at all by this driver.
516  
517  It will give access (through a user space utility) to some events those laptops
518  generate, like:
519 @@ -96,6 +98,7 @@
520                                 SONYPI_THUMBPHRASE_MASK         0x0200
521                                 SONYPI_MEYE_MASK                0x0400
522                                 SONYPI_MEMORYSTICK_MASK         0x0800
523 +                               SONYPI_BATTERY_MASK             0x1000
524  
525         useinput:       if set (which is the default) jogdial events are
526                         forwarded to the input subsystem as mouse wheel
527 diff -Nru a/Documentation/sysctl/README b/Documentation/sysctl/README
528 --- a/Documentation/sysctl/README       Tue Feb  5 09:40:37 2002
529 +++ b/Documentation/sysctl/README       Sun Aug 31 16:14:14 2003
530 @@ -55,6 +55,7 @@
531  by piece basis, or just some 'thematic frobbing'.
532  
533  The subdirs are about:
534 +abi/           execution domains & personalities
535  debug/         <empty>
536  dev/           device specific information (eg dev/cdrom/info)
537  fs/            specific filesystems
538 diff -Nru a/Documentation/sysctl/abi.txt b/Documentation/sysctl/abi.txt
539 --- /dev/null   Wed Dec 31 16:00:00 1969
540 +++ b/Documentation/sysctl/abi.txt      Sun Aug 31 16:14:14 2003
541 @@ -0,0 +1,54 @@
542 +Documentation for /proc/sys/abi/* kernel version 2.6.0.test2
543 +       (c) 2003,  Fabian Frederick <ffrederick@users.sourceforge.net>
544 +
545 +For general info : README.
546 +
547 +==============================================================
548 +
549 +This path is binary emulation relevant aka personality types aka abi.
550 +When a process is executed, it's linked to an exec_domain whose
551 +personality is defined using values available from /proc/sys/abi.
552 +You can find further details about abi in include/linux/personality.h.
553 +
554 +Here are the files featuring in 2.6 kernel :
555 +
556 +- defhandler_coff
557 +- defhandler_elf
558 +- defhandler_lcall7
559 +- defhandler_libcso
560 +- fake_utsname
561 +- trace
562 +
563 +===========================================================
564 +defhandler_coff:
565 +defined value :
566 +PER_SCOSVR3
567 +0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE
568 +
569 +===========================================================
570 +defhandler_elf:
571 +defined value :
572 +PER_LINUX
573 +0
574 +
575 +===========================================================
576 +defhandler_lcall7:
577 +defined value :
578 +PER_SVR4
579 +0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
580 +
581 +===========================================================
582 +defhandler_libsco:
583 +defined value:
584 +PER_SVR4
585 +0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
586 +
587 +===========================================================
588 +fake_utsname:
589 +Unused
590 +
591 +===========================================================
592 +trace:
593 +Unused
594 +
595 +===========================================================
596 diff -Nru a/Documentation/usb/hotplug.txt b/Documentation/usb/hotplug.txt
597 --- a/Documentation/usb/hotplug.txt     Fri Dec 27 03:00:19 2002
598 +++ b/Documentation/usb/hotplug.txt     Wed Aug 20 09:40:22 2003
599 @@ -122,17 +122,17 @@
600  something like this:
601  
602      static struct usb_driver mydriver = {
603 -       name:           "mydriver",
604 -       id_table:       mydriver_id_table,
605 -       probe:          my_probe,
606 -       disconnect:     my_disconnect,
607 +       .name           = "mydriver",
608 +       .id_table       = mydriver_id_table,
609 +       .probe          = my_probe,
610 +       .disconnect     = my_disconnect,
611  
612         /*
613         if using the usb chardev framework:
614 -           minor:              MY_USB_MINOR_START,
615 -           fops:               my_file_ops,
616 +           .minor              = MY_USB_MINOR_START,
617 +           .fops               = my_file_ops,
618         if exposing any operations through usbdevfs:
619 -           ioctl:              my_ioctl,
620 +           .ioctl              = my_ioctl,
621         */
622      }
623  
624 diff -Nru a/Documentation/video4linux/meye.txt b/Documentation/video4linux/meye.txt
625 --- a/Documentation/video4linux/meye.txt        Tue Feb 18 03:32:29 2003
626 +++ b/Documentation/video4linux/meye.txt        Fri Aug  1 05:47:51 2003
627 @@ -16,6 +16,23 @@
628  
629  MJPEG hardware grabbing is supported via a private API (see below).
630  
631 +Hardware supported:
632 +-------------------
633 +
634 +This driver supports the 'second' version of the MotionEye camera :)
635 +
636 +The first version was connected directly on the video bus of the Neomagic
637 +video card and is unsupported.
638 +
639 +The second one, made by Kawasaki Steel is fully supported by this 
640 +driver (PCI vendor/device is 0x136b/0xff01)
641 +
642 +The third one, present in recent (more or less last year) Picturebooks
643 +(C1M* models), is not supported. The manufacturer has given the specs
644 +to the developers under a NDA (which allows the develoment of a GPL
645 +driver however), but things are not moving very fast (see
646 +http://r-engine.sourceforge.net/) (PCI vendor/device is 0x10cf/0x2011).
647 +
648  Driver options:
649  ---------------
650  
651 diff -Nru a/MAINTAINERS b/MAINTAINERS
652 --- a/MAINTAINERS       Thu Aug 21 09:09:26 2003
653 +++ b/MAINTAINERS       Wed Sep  3 23:39:56 2003
654 @@ -615,8 +615,6 @@
655  S:     Maintained
656  
657  DRM DRIVERS
658 -P:     Rik Faith
659 -M:     faith@redhat.com
660  L:     dri-devel@lists.sourceforge.net
661  S:     Supported
662  
663 @@ -1087,6 +1085,14 @@
664  L:     kbuild-devel@lists.sourceforge.net
665  W:     http://kbuild.sourceforge.net
666  S:     Maintained 
667 +
668 +KERNEL JANITORS
669 +P:     Several
670 +L:     kernel-janitors@osdl.org
671 +W:     http://www.kerneljanitors.org/
672 +W:     http://sf.net/projects/kernel-janitor/
673 +W:     http://developer.osdl.org/rddunlap/kj-patches/
674 +S:     Maintained
675  
676  KERNEL NFSD
677  P:     Neil Brown
678 diff -Nru a/Makefile b/Makefile
679 --- a/Makefile  Fri Aug 22 16:38:51 2003
680 +++ b/Makefile  Thu Sep  4 04:34:53 2003
681 @@ -268,8 +268,19 @@
682  # Detect when mixed targets is specified, and make a second invocation
683  # of make so .config is not included in this case either (for *config).
684  
685 +no-dot-config-targets := clean mrproper distclean \
686 +                        cscope TAGS tags help %docs check%
687 +
688  config-targets := 0
689  mixed-targets  := 0
690 +dot-config     := 1
691 +
692 +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
693 +       ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
694 +               dot-config := 0
695 +       endif
696 +endif
697 +
698  ifneq ($(filter config %config,$(MAKECMDGOALS)),)
699         config-targets := 1
700         ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
701 @@ -309,7 +320,26 @@
702  core-y         := usr/
703  SUBDIRS                :=
704  
705 --include .config
706 +ifeq ($(dot-config),1)
707 +# In this section, we need .config
708 +
709 +# Read in dependencies to all Kconfig* files, make sure to run
710 +# oldconfig if changes are detected.
711 +-include .config.cmd
712 +
713 +include .config
714 +
715 +# If .config needs to be updated, it will be done via the dependency
716 +# that autoconf has on .config.
717 +# To avoid any implicit rule to kick in, define an empty command
718 +.config: ;
719 +
720 +# If .config is newer than include/linux/autoconf.h, someone tinkered
721 +# with it and forgot to run make oldconfig
722 +include/linux/autoconf.h: scripts/fixdep .config
723 +       $(Q)$(MAKE) $(build)=scripts/kconfig silentoldconfig
724 +
725 +endif
726  
727  include arch/$(ARCH)/Makefile
728  
729 @@ -338,15 +368,7 @@
730  
731  # Here goes the main Makefile
732  # ---------------------------------------------------------------------------
733 -#
734 -# If the user gave a *config target, it'll be handled in another
735 -# section below, since in this case we cannot include .config
736 -# Same goes for other targets like clean/mrproper etc, which
737 -# don't need .config, either
738  
739 -#      In this section, we need .config
740 -
741 --include .config.cmd
742  
743  ifndef CONFIG_FRAME_POINTER
744  CFLAGS         += -fomit-frame-pointer
745 @@ -521,13 +543,6 @@
746         @scripts/split-include include/linux/autoconf.h include/config
747         @touch $@
748  
749 -#      if .config is newer than include/linux/autoconf.h, someone tinkered
750 -#      with it and forgot to run make oldconfig
751 -
752 -include/linux/autoconf.h: .config scripts/fixdep
753 -       $(Q)$(MAKE) $(build)=scripts/kconfig scripts/kconfig/conf
754 -       ./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
755 -
756  # Generate some files
757  # ---------------------------------------------------------------------------
758  
759 @@ -579,6 +594,11 @@
760  
761  .PHONY: _modinst_
762  _modinst_:
763 +       @if [ -z "`$(DEPMOD) -V | grep module-init-tools`" ]; then \
764 +               echo "Warning: you may need to install module-init-tools"; \
765 +               echo "See http://www.codemonkey.org.uk/post-halloween-2.5.txt";\
766 +               sleep 1; \
767 +       fi
768         @rm -rf $(MODLIB)/kernel
769         @rm -f $(MODLIB)/build
770         @mkdir -p $(MODLIB)/kernel
771 diff -Nru a/arch/alpha/Kconfig b/arch/alpha/Kconfig
772 --- a/arch/alpha/Kconfig        Sun Aug 17 01:06:24 2003
773 +++ b/arch/alpha/Kconfig        Sun Aug 31 16:14:22 2003
774 @@ -597,40 +597,6 @@
775  
776  source "drivers/pcmcia/Kconfig"
777  
778 -choice
779 -       prompt "Kernel core (/proc/kcore) format"
780 -       depends on PROC_FS
781 -       default KCORE_ELF
782 -
783 -config KCORE_ELF
784 -       bool "ELF"
785 -       ---help---
786 -         If you enabled support for /proc file system then the file
787 -         /proc/kcore will contain the kernel core image. This can be used
788 -         in gdb:
789 -
790 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
791 -
792 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
793 -         /proc/kcore appear in ELF core format as defined by the Executable
794 -         and Linking Format specification. Selecting A.OUT will choose the
795 -         old "a.out" format which may be necessary for some old versions
796 -         of binutils or on some architectures.
797 -
798 -         This is especially useful if you have compiled the kernel with the
799 -         "-g" option to preserve debugging information. It is mainly used
800 -         for examining kernel data structures on the live kernel so if you
801 -         don't understand what this means or are not a kernel hacker, just
802 -         leave it at its default value ELF.
803 -
804 -config KCORE_AOUT
805 -       bool "A.OUT"
806 -       help
807 -         Not necessary unless you're using a very out-of-date binutils
808 -         version.  You probably want KCORE_ELF.
809 -
810 -endchoice
811 -
812  config SRM_ENV
813         tristate "SRM environment through procfs"
814         depends on PROC_FS
815 diff -Nru a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c
816 --- a/arch/alpha/kernel/core_titan.c    Sun Aug 17 00:57:42 2003
817 +++ b/arch/alpha/kernel/core_titan.c    Sun Aug 31 16:14:08 2003
818 @@ -717,12 +717,12 @@
819  
820  struct alpha_agp_ops titan_agp_ops =
821  {
822 -       setup:          titan_agp_setup,
823 -       cleanup:        titan_agp_cleanup,
824 -       configure:      titan_agp_configure,
825 -       bind:           titan_agp_bind_memory,
826 -       unbind:         titan_agp_unbind_memory,
827 -       translate:      titan_agp_translate
828 +       .setup          = titan_agp_setup,
829 +       .cleanup        = titan_agp_cleanup,
830 +       .configure      = titan_agp_configure,
831 +       .bind           = titan_agp_bind_memory,
832 +       .unbind         = titan_agp_unbind_memory,
833 +       .translate      = titan_agp_translate
834  };
835  
836  alpha_agp_info *
837 diff -Nru a/arch/arm/Kconfig b/arch/arm/Kconfig
838 --- a/arch/arm/Kconfig  Tue Aug 19 11:44:53 2003
839 +++ b/arch/arm/Kconfig  Sun Aug 31 16:14:22 2003
840 @@ -654,39 +654,6 @@
841           If you do not feel you need a faster FP emulation you should better
842           choose NWFPE.
843  
844 -choice
845 -       prompt "Kernel core (/proc/kcore) format"
846 -       default KCORE_ELF
847 -
848 -config KCORE_ELF
849 -       bool "ELF"
850 -       ---help---
851 -         If you enabled support for /proc file system then the file
852 -         /proc/kcore will contain the kernel core image. This can be used
853 -         in gdb:
854 -
855 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
856 -
857 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
858 -         /proc/kcore appear in ELF core format as defined by the Executable
859 -         and Linking Format specification. Selecting A.OUT will choose the
860 -         old "a.out" format which may be necessary for some old versions
861 -         of binutils or on some architectures.
862 -
863 -         This is especially useful if you have compiled the kernel with the
864 -         "-g" option to preserve debugging information. It is mainly used
865 -         for examining kernel data structures on the live kernel so if you
866 -         don't understand what this means or are not a kernel hacker, just
867 -         leave it at its default value ELF.
868 -
869 -config KCORE_AOUT
870 -       bool "A.OUT"
871 -       help
872 -         Not necessary unless you're using a very out-of-date binutils
873 -         version.  You probably want KCORE_ELF.
874 -
875 -endchoice
876 -
877  source "fs/Kconfig.binfmt"
878  
879  source "drivers/base/Kconfig"
880 diff -Nru a/arch/arm/Makefile b/arch/arm/Makefile
881 --- a/arch/arm/Makefile Tue Aug 19 11:44:53 2003
882 +++ b/arch/arm/Makefile Wed Sep  3 10:17:53 2003
883 @@ -24,17 +24,12 @@
884  CFLAGS         += -mbig-endian
885  AS             += -EB
886  LD             += -EB
887 +AFLAGS         += -mbig-endian
888  endif
889  
890  check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
891  comma = ,
892  
893 -# Select CPU dependent flags.  Note that order of declaration is important;
894 -# the options further down the list override previous items.
895 -#
896 -apcs-$(CONFIG_CPU_32)          :=-mapcs-32
897 -apcs-$(CONFIG_CPU_26)          :=-mapcs-26 -mcpu=arm3
898 -
899  # This selects which instruction set is used.
900  # Note that GCC does not numerically define an architecture version
901  # macro, but instead defines a whole series of macros which makes
902 @@ -54,37 +49,21 @@
903  tune-$(CONFIG_CPU_SA1100)      :=-mtune=strongarm1100
904  tune-$(CONFIG_CPU_XSCALE)      :=$(call check_gcc,-mtune=xscale,-mtune=strongarm110)
905  
906 -# Force -mno-fpu to be passed to the assembler.  Some versions of gcc don't
907 -# do this with -msoft-float
908 -CFLAGS_BOOT    :=$(apcs-y) $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Wa,-mno-fpu -Uarm
909 -CFLAGS         +=$(apcs-y) $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Wa,-mno-fpu -Uarm
910 -AFLAGS         +=$(apcs-y) $(arch-y) $(tune-y) -msoft-float -Wa,-mno-fpu
911 +CFLAGS_BOOT    :=-mapcs-32 $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Wa,-mno-fpu -Uarm
912 +CFLAGS         +=-mapcs-32 $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Wa,-mno-fpu -Uarm
913 +AFLAGS         +=-mapcs-32 $(arch-y) $(tune-y) -msoft-float -Wa,-mno-fpu
914  
915  #Default value
916  DATAADDR       := .
917  
918 -ifeq ($(CONFIG_CPU_26),y)
919 -PROCESSOR      := armo
920 -head-y         := arch/arm/mach-arc/head.o arch/arm/kernel/init_task.o
921 -LDFLAGS_BLOB   += --oformat elf26-littlearm
922 -  ifeq ($(CONFIG_ROM_KERNEL),y)
923 -    DATAADDR    := 0x02080000
924 -    textaddr-y  := 0x03800000
925 -  else
926 -    textaddr-y  := 0x02080000
927 -  endif
928 -endif
929 -
930 -ifeq ($(CONFIG_CPU_32),y)
931  PROCESSOR      := armv
932  head-y         := arch/arm/kernel/head.o arch/arm/kernel/init_task.o
933 -  ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
934 -    LDFLAGS_BLOB       += --oformat elf32-bigarm
935 -  else
936 -    LDFLAGS_BLOB       += --oformat elf32-littlearm
937 -  endif
938 -textaddr-y     := 0xC0008000
939 +ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
940 +  LDFLAGS_BLOB += --oformat elf32-bigarm
941 +else
942 +  LDFLAGS_BLOB += --oformat elf32-littlearm
943  endif
944 +textaddr-y     := 0xC0008000
945  
946   machine-$(CONFIG_ARCH_ARCA5K)    := arc
947   machine-$(CONFIG_ARCH_RPC)       := rpc
948 @@ -159,16 +138,10 @@
949         @ln -sf arch-$(INCDIR) include/asm-arm/arch
950         @touch $@
951  
952 -include/asm-arm/.proc: $(wildcard include/config/cpu/32.h) $(wildcard include/config/cpu/26.h)
953 -       @echo '  Making asm-arm/proc -> asm-arm/proc-$(PROCESSOR) symlink'
954 -       @rm -f include/asm-arm/proc
955 -       @ln -sf proc-$(PROCESSOR) include/asm-arm/proc
956 -       @touch $@
957 -
958  prepare: maketools
959  
960  .PHONY: maketools FORCE
961 -maketools: include/asm-arm/.arch include/asm-arm/.proc \
962 +maketools: include/asm-arm/.arch \
963            include/asm-arm/constants.h include/linux/version.h FORCE
964         $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h
965  
966 @@ -184,7 +157,6 @@
967  
968  MRPROPER_FILES += \
969         include/asm-arm/arch include/asm-arm/.arch \
970 -       include/asm-arm/proc include/asm-arm/.proc \
971         include/asm-arm/constants.h* \
972         include/asm-arm/mach-types.h
973  
974 @@ -216,7 +188,7 @@
975         )
976  
977  arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
978 -                                  include/asm-arm/.arch include/asm-arm/.proc \
979 +                                  include/asm-arm/.arch \
980                                    include/config/MARKER
981  
982  include/asm-$(ARCH)/constants.h: arch/$(ARCH)/kernel/asm-offsets.s
983 diff -Nru a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
984 --- a/arch/arm/boot/Makefile    Tue Apr 15 08:12:47 2003
985 +++ b/arch/arm/boot/Makefile    Wed Aug 13 16:46:20 2003
986 @@ -42,11 +42,12 @@
987  ifeq ($(CONFIG_ARCH_SA1100),y)
988     zreladdr-$(CONFIG_SA1111)           := 0xc0208000
989  endif
990 -  zreladdr-$(CONFIG_ARCH_PXA)          := 0xa0008000
991 -  zreladdr-$(CONFIG_ARCH_ANAKIN)       := 0x20008000
992 -  zreladdr-$(CONFIG_ARCH_IQ80310)      := 0xa0008000
993 -  zreladdr-$(CONFIG_ARCH_IQ80321)      := 0xa0008000
994 -  zreladdr-$(CONFIG_ARCH_ADIFCC)       := 0xc0008000
995 +   zreladdr-$(CONFIG_ARCH_PXA)         := 0xa0008000
996 +   zreladdr-$(CONFIG_ARCH_ANAKIN)      := 0x20008000
997 +   zreladdr-$(CONFIG_ARCH_IOP3XX)      := 0xa0008000
998 +params-phys-$(CONFIG_ARCH_IOP3XX)      := 0xa0000100
999 +   zreladdr-$(CONFIG_ARCH_ADIFCC)      := 0xc0008000
1000 +params-phys-$(CONFIG_ARCH_ADIFCC)      := 0xc0000100
1001  
1002  ZRELADDR    := $(zreladdr-y)
1003  ZTEXTADDR   := $(ztextaddr-y)
1004 diff -Nru a/arch/arm/common/amba.c b/arch/arm/common/amba.c
1005 --- a/arch/arm/common/amba.c    Fri Aug 15 15:22:52 2003
1006 +++ b/arch/arm/common/amba.c    Sun Aug 24 07:16:13 2003
1007 @@ -41,13 +41,35 @@
1008         return amba_lookup(pcdrv->id_table, pcdev) != NULL;
1009  }
1010  
1011 +static int amba_suspend(struct device *dev, u32 state)
1012 +{
1013 +       struct amba_driver *drv = to_amba_driver(dev->driver);
1014 +       int ret = 0;
1015 +
1016 +       if (dev->driver && drv->suspend)
1017 +               ret = drv->suspend(to_amba_device(dev), state);
1018 +       return ret;
1019 +}
1020 +
1021 +static int amba_resume(struct device *dev)
1022 +{
1023 +       struct amba_driver *drv = to_amba_driver(dev->driver);
1024 +       int ret = 0;
1025 +
1026 +       if (dev->driver && drv->resume)
1027 +               ret = drv->resume(to_amba_device(dev));
1028 +       return ret;
1029 +}
1030 +
1031  /*
1032   * Primecells are part of the Advanced Microcontroller Bus Architecture,
1033   * so we call the bus "amba".
1034   */
1035 -struct bus_type amba_bustype = {
1036 -       .name   = "amba",
1037 -       .match  = amba_match,
1038 +static struct bus_type amba_bustype = {
1039 +       .name           = "amba",
1040 +       .match          = amba_match,
1041 +       .suspend        = amba_suspend,
1042 +       .resume         = amba_resume,
1043  };
1044  
1045  static int __init amba_init(void)
1046 @@ -84,18 +106,6 @@
1047         drv->shutdown(to_amba_device(dev));
1048  }
1049  
1050 -static int amba_suspend(struct device *dev, u32 state, u32 level)
1051 -{
1052 -       struct amba_driver *drv = to_amba_driver(dev->driver);
1053 -       return drv->suspend(to_amba_device(dev), state, level);
1054 -}
1055 -
1056 -static int amba_resume(struct device *dev, u32 level)
1057 -{
1058 -       struct amba_driver *drv = to_amba_driver(dev->driver);
1059 -       return drv->resume(to_amba_device(dev), level);
1060 -}
1061 -
1062  /**
1063   *     amba_driver_register - register an AMBA device driver
1064   *     @drv: amba device driver structure
1065 @@ -112,8 +122,6 @@
1066         SETFN(probe);
1067         SETFN(remove);
1068         SETFN(shutdown);
1069 -       SETFN(suspend);
1070 -       SETFN(resume);
1071  
1072         return driver_register(&drv->drv);
1073  }
1074 diff -Nru a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
1075 --- a/arch/arm/common/sa1111.c  Fri Aug 15 15:22:52 2003
1076 +++ b/arch/arm/common/sa1111.c  Sun Aug 24 07:45:04 2003
1077 @@ -790,10 +790,13 @@
1078         struct sa1111 *sachip = dev_get_drvdata(dev);
1079         struct sa1111_save_data *save;
1080         unsigned long flags;
1081 +       unsigned int val;
1082         char *base;
1083  
1084 -       if (!dev->saved_state && level == SUSPEND_NOTIFY)
1085 -               dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
1086 +       if (level != SUSPEND_DISABLE)
1087 +               return 0;
1088 +
1089 +       dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
1090         if (!dev->saved_state)
1091                 return -ENOMEM;
1092  
1093 @@ -804,36 +807,31 @@
1094         /*
1095          * Save state.
1096          */
1097 -       if (level == SUSPEND_SAVE_STATE) {
1098 -               base = sachip->base;
1099 -               save->skcr     = sa1111_readl(base + SA1111_SKCR);
1100 -               save->skpcr    = sa1111_readl(base + SA1111_SKPCR);
1101 -               save->skcdr    = sa1111_readl(base + SA1111_SKCDR);
1102 -               save->skaud    = sa1111_readl(base + SA1111_SKAUD);
1103 -               save->skpwm0   = sa1111_readl(base + SA1111_SKPWM0);
1104 -               save->skpwm1   = sa1111_readl(base + SA1111_SKPWM1);
1105 -
1106 -               base = sachip->base + SA1111_INTC;
1107 -               save->intpol0  = sa1111_readl(base + SA1111_INTPOL0);
1108 -               save->intpol1  = sa1111_readl(base + SA1111_INTPOL1);
1109 -               save->inten0   = sa1111_readl(base + SA1111_INTEN0);
1110 -               save->inten1   = sa1111_readl(base + SA1111_INTEN1);
1111 -               save->wakepol0 = sa1111_readl(base + SA1111_WAKEPOL0);
1112 -               save->wakepol1 = sa1111_readl(base + SA1111_WAKEPOL1);
1113 -               save->wakeen0  = sa1111_readl(base + SA1111_WAKEEN0);
1114 -               save->wakeen1  = sa1111_readl(base + SA1111_WAKEEN1);
1115 -       }
1116 +       base = sachip->base;
1117 +       save->skcr     = sa1111_readl(base + SA1111_SKCR);
1118 +       save->skpcr    = sa1111_readl(base + SA1111_SKPCR);
1119 +       save->skcdr    = sa1111_readl(base + SA1111_SKCDR);
1120 +       save->skaud    = sa1111_readl(base + SA1111_SKAUD);
1121 +       save->skpwm0   = sa1111_readl(base + SA1111_SKPWM0);
1122 +       save->skpwm1   = sa1111_readl(base + SA1111_SKPWM1);
1123 +
1124 +       base = sachip->base + SA1111_INTC;
1125 +       save->intpol0  = sa1111_readl(base + SA1111_INTPOL0);
1126 +       save->intpol1  = sa1111_readl(base + SA1111_INTPOL1);
1127 +       save->inten0   = sa1111_readl(base + SA1111_INTEN0);
1128 +       save->inten1   = sa1111_readl(base + SA1111_INTEN1);
1129 +       save->wakepol0 = sa1111_readl(base + SA1111_WAKEPOL0);
1130 +       save->wakepol1 = sa1111_readl(base + SA1111_WAKEPOL1);
1131 +       save->wakeen0  = sa1111_readl(base + SA1111_WAKEEN0);
1132 +       save->wakeen1  = sa1111_readl(base + SA1111_WAKEEN1);
1133  
1134         /*
1135          * Disable.
1136          */
1137 -       if (level == SUSPEND_POWER_DOWN && state == 4) {
1138 -               unsigned int val = sa1111_readl(sachip->base + SA1111_SKCR);
1139 -
1140 -               sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR);
1141 -               sa1111_writel(0, sachip->base + SA1111_SKPWM0);
1142 -               sa1111_writel(0, sachip->base + SA1111_SKPWM1);
1143 -       }
1144 +       val = sa1111_readl(sachip->base + SA1111_SKCR);
1145 +       sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR);
1146 +       sa1111_writel(0, sachip->base + SA1111_SKPWM0);
1147 +       sa1111_writel(0, sachip->base + SA1111_SKPWM1);
1148  
1149         spin_unlock_irqrestore(&sachip->lock, flags);
1150  
1151 @@ -857,6 +855,9 @@
1152         unsigned long flags, id;
1153         char *base;
1154  
1155 +       if (level != RESUME_ENABLE)
1156 +               return 0;
1157 +
1158         save = (struct sa1111_save_data *)dev->saved_state;
1159         if (!save)
1160                 return 0;
1161 @@ -878,39 +879,32 @@
1162         /*
1163          * First of all, wake up the chip.
1164          */
1165 -       if (level == RESUME_POWER_ON) {
1166 -               sa1111_wake(sachip);
1167 -
1168 -               sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0);
1169 -               sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1);
1170 -       }
1171 -
1172 -       if (level == RESUME_RESTORE_STATE) {
1173 -               base = sachip->base;
1174 -               sa1111_writel(save->skcr,     base + SA1111_SKCR);
1175 -               sa1111_writel(save->skpcr,    base + SA1111_SKPCR);
1176 -               sa1111_writel(save->skcdr,    base + SA1111_SKCDR);
1177 -               sa1111_writel(save->skaud,    base + SA1111_SKAUD);
1178 -               sa1111_writel(save->skpwm0,   base + SA1111_SKPWM0);
1179 -               sa1111_writel(save->skpwm1,   base + SA1111_SKPWM1);
1180 -
1181 -               base = sachip->base + SA1111_INTC;
1182 -               sa1111_writel(save->intpol0,  base + SA1111_INTPOL0);
1183 -               sa1111_writel(save->intpol1,  base + SA1111_INTPOL1);
1184 -               sa1111_writel(save->inten0,   base + SA1111_INTEN0);
1185 -               sa1111_writel(save->inten1,   base + SA1111_INTEN1);
1186 -               sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0);
1187 -               sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1);
1188 -               sa1111_writel(save->wakeen0,  base + SA1111_WAKEEN0);
1189 -               sa1111_writel(save->wakeen1,  base + SA1111_WAKEEN1);
1190 -       }
1191 +       sa1111_wake(sachip);
1192 +       sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0);
1193 +       sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1);
1194 +
1195 +       base = sachip->base;
1196 +       sa1111_writel(save->skcr,     base + SA1111_SKCR);
1197 +       sa1111_writel(save->skpcr,    base + SA1111_SKPCR);
1198 +       sa1111_writel(save->skcdr,    base + SA1111_SKCDR);
1199 +       sa1111_writel(save->skaud,    base + SA1111_SKAUD);
1200 +       sa1111_writel(save->skpwm0,   base + SA1111_SKPWM0);
1201 +       sa1111_writel(save->skpwm1,   base + SA1111_SKPWM1);
1202 +
1203 +       base = sachip->base + SA1111_INTC;
1204 +       sa1111_writel(save->intpol0,  base + SA1111_INTPOL0);
1205 +       sa1111_writel(save->intpol1,  base + SA1111_INTPOL1);
1206 +       sa1111_writel(save->inten0,   base + SA1111_INTEN0);
1207 +       sa1111_writel(save->inten1,   base + SA1111_INTEN1);
1208 +       sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0);
1209 +       sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1);
1210 +       sa1111_writel(save->wakeen0,  base + SA1111_WAKEEN0);
1211 +       sa1111_writel(save->wakeen1,  base + SA1111_WAKEEN1);
1212  
1213         spin_unlock_irqrestore(&sachip->lock, flags);
1214  
1215 -       if (level == RESUME_ENABLE) {
1216 -               dev->saved_state = NULL;
1217 -               kfree(save);
1218 -       }
1219 +       dev->saved_state = NULL;
1220 +       kfree(save);
1221  
1222         return 0;
1223  }
1224 @@ -1135,9 +1129,55 @@
1225         return dev->devid == drv->devid;
1226  }
1227  
1228 +static int sa1111_bus_suspend(struct device *dev, u32 state)
1229 +{
1230 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
1231 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1232 +       int ret = 0;
1233 +
1234 +       if (drv && drv->suspend)
1235 +               ret = drv->suspend(sadev, state);
1236 +       return ret;
1237 +}
1238 +
1239 +static int sa1111_bus_resume(struct device *dev)
1240 +{
1241 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
1242 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1243 +       int ret = 0;
1244 +
1245 +       if (drv && drv->resume)
1246 +               ret = drv->resume(sadev);
1247 +       return ret;
1248 +}
1249 +
1250 +static int sa1111_bus_probe(struct device *dev)
1251 +{
1252 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
1253 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1254 +       int ret = -ENODEV;
1255 +
1256 +       if (drv->probe)
1257 +               ret = drv->probe(sadev);
1258 +       return ret;
1259 +}
1260 +
1261 +static int sa1111_bus_remove(struct device *dev)
1262 +{
1263 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
1264 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1265 +       int ret = 0;
1266 +
1267 +       if (drv->remove)
1268 +               ret = drv->remove(sadev);
1269 +       return ret;
1270 +}
1271 +
1272  struct bus_type sa1111_bus_type = {
1273 -       .name   = "RAB",
1274 -       .match  = sa1111_match,
1275 +       .name           = "sa1111-rab",
1276 +       .match          = sa1111_match,
1277 +       .suspend        = sa1111_bus_suspend,
1278 +       .resume         = sa1111_bus_resume,
1279  };
1280  
1281  static int sa1111_rab_bus_init(void)
1282 @@ -1147,6 +1187,19 @@
1283  
1284  postcore_initcall(sa1111_rab_bus_init);
1285  
1286 +int sa1111_driver_register(struct sa1111_driver *driver)
1287 +{
1288 +       driver->drv.probe = sa1111_bus_probe;
1289 +       driver->drv.remove = sa1111_bus_remove;
1290 +       driver->drv.bus = &sa1111_bus_type;
1291 +       return driver_register(&driver->drv);
1292 +}
1293 +
1294 +void sa1111_driver_unregister(struct sa1111_driver *driver)
1295 +{
1296 +       driver_unregister(&driver->drv);
1297 +}
1298 +
1299  EXPORT_SYMBOL(sa1111_check_dma_bug);
1300  EXPORT_SYMBOL(sa1111_select_audio_mode);
1301  EXPORT_SYMBOL(sa1111_set_audio_rate);
1302 @@ -1155,3 +1208,5 @@
1303  EXPORT_SYMBOL(sa1111_disable_device);
1304  EXPORT_SYMBOL(sa1111_pll_clock);
1305  EXPORT_SYMBOL(sa1111_bus_type);
1306 +EXPORT_SYMBOL(sa1111_driver_register);
1307 +EXPORT_SYMBOL(sa1111_driver_unregister);
1308 diff -Nru a/arch/arm/def-configs/iq80310 b/arch/arm/def-configs/iq80310
1309 --- a/arch/arm/def-configs/iq80310      Tue Apr 15 07:34:41 2003
1310 +++ b/arch/arm/def-configs/iq80310      Wed Aug 13 16:46:20 2003
1311 @@ -19,6 +19,12 @@
1312  # CONFIG_BSD_PROCESS_ACCT is not set
1313  CONFIG_SYSCTL=y
1314  CONFIG_LOG_BUF_SHIFT=14
1315 +# CONFIG_EMBEDDED is not set
1316 +CONFIG_KALLSYMS=y
1317 +CONFIG_FUTEX=y
1318 +CONFIG_EPOLL=y
1319 +CONFIG_IOSCHED_AS=y
1320 +CONFIG_IOSCHED_DEADLINE=y
1321  
1322  #
1323  # Loadable module support
1324 @@ -34,7 +40,6 @@
1325  #
1326  # CONFIG_ARCH_ADIFCC is not set
1327  # CONFIG_ARCH_ANAKIN is not set
1328 -# CONFIG_ARCH_ARCA5K is not set
1329  # CONFIG_ARCH_CLPS7500 is not set
1330  # CONFIG_ARCH_CLPS711X is not set
1331  # CONFIG_ARCH_CO285 is not set
1332 @@ -50,14 +55,6 @@
1333  # CONFIG_ARCH_SHARK is not set
1334  
1335  #
1336 -# Archimedes/A5000 Implementations
1337 -#
1338 -
1339 -#
1340 -# Archimedes/A5000 Implementations (select only ONE)
1341 -#
1342 -
1343 -#
1344  # CLPS711X/EP721X Implementations
1345  #
1346  
1347 @@ -73,7 +70,9 @@
1348  # IOP3xx Implementation Options
1349  #
1350  CONFIG_ARCH_IQ80310=y
1351 +# CONFIG_ARCH_IQ80321 is not set
1352  CONFIG_ARCH_IOP310=y
1353 +# CONFIG_ARCH_IOP321 is not set
1354  
1355  #
1356  # IOP3xx Chipset Features
1357 @@ -84,6 +83,14 @@
1358  # CONFIG_IOP3XX_PMON is not set
1359  
1360  #
1361 +# ADIFCC Implementation Options
1362 +#
1363 +
1364 +#
1365 +# ADI Board Types
1366 +#
1367 +
1368 +#
1369  # Intel PXA250/210 Implementations
1370  #
1371  
1372 @@ -96,6 +103,7 @@
1373  #
1374  CONFIG_CPU_32=y
1375  CONFIG_CPU_XSCALE=y
1376 +CONFIG_XS80200=y
1377  CONFIG_CPU_32v5=y
1378  
1379  #
1380 @@ -116,9 +124,15 @@
1381  # CONFIG_HOTPLUG is not set
1382  
1383  #
1384 +# MMC/SD Card support
1385 +#
1386 +# CONFIG_MMC is not set
1387 +
1388 +#
1389  # At least one math emulation must be selected
1390  #
1391  CONFIG_FPE_NWFPE=y
1392 +# CONFIG_FPE_NWFPE_XP is not set
1393  # CONFIG_FPE_FASTFPE is not set
1394  CONFIG_KCORE_ELF=y
1395  # CONFIG_KCORE_AOUT is not set
1396 @@ -154,6 +168,7 @@
1397  CONFIG_MTD_BLOCK=y
1398  # CONFIG_FTL is not set
1399  # CONFIG_NFTL is not set
1400 +# CONFIG_INFTL is not set
1401  
1402  #
1403  # RAM/ROM/Flash chip drivers
1404 @@ -164,6 +179,7 @@
1405  # CONFIG_MTD_CFI_ADV_OPTIONS is not set
1406  CONFIG_MTD_CFI_INTELEXT=y
1407  # CONFIG_MTD_CFI_AMDSTD is not set
1408 +# CONFIG_MTD_CFI_STAA is not set
1409  # CONFIG_MTD_RAM is not set
1410  # CONFIG_MTD_ROM is not set
1411  # CONFIG_MTD_ABSENT is not set
1412 @@ -172,13 +188,11 @@
1413  #
1414  # Mapping drivers for chip access
1415  #
1416 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
1417  # CONFIG_MTD_PHYSMAP is not set
1418 -# CONFIG_MTD_NORA is not set
1419  # CONFIG_MTD_ARM_INTEGRATOR is not set
1420  CONFIG_MTD_IQ80310=y
1421  # CONFIG_MTD_EDB7312 is not set
1422 -# CONFIG_MTD_PCI is not set
1423 -# CONFIG_MTD_UCLINUX is not set
1424  
1425  #
1426  # Self-contained MTD device drivers
1427 @@ -191,9 +205,9 @@
1428  #
1429  # Disk-On-Chip Device Drivers
1430  #
1431 -# CONFIG_MTD_DOC1000 is not set
1432  # CONFIG_MTD_DOC2000 is not set
1433  # CONFIG_MTD_DOC2001 is not set
1434 +# CONFIG_MTD_DOC2001PLUS is not set
1435  
1436  #
1437  # NAND Flash Device Drivers
1438 @@ -236,7 +250,6 @@
1439  # CONFIG_NETLINK_DEV is not set
1440  CONFIG_NETFILTER=y
1441  # CONFIG_NETFILTER_DEBUG is not set
1442 -# CONFIG_FILTER is not set
1443  CONFIG_UNIX=y
1444  # CONFIG_NET_KEY is not set
1445  CONFIG_INET=y
1446 @@ -253,7 +266,7 @@
1447  # CONFIG_SYN_COOKIES is not set
1448  # CONFIG_INET_AH is not set
1449  # CONFIG_INET_ESP is not set
1450 -# CONFIG_XFRM_USER is not set
1451 +# CONFIG_INET_IPCOMP is not set
1452  
1453  #
1454  # IP: Netfilter Configuration
1455 @@ -264,7 +277,13 @@
1456  # CONFIG_IP_NF_ARPTABLES is not set
1457  # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
1458  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
1459 +
1460 +#
1461 +# IP: Virtual Server Configuration
1462 +#
1463 +# CONFIG_IP_VS is not set
1464  # CONFIG_IPV6 is not set
1465 +# CONFIG_XFRM_USER is not set
1466  
1467  #
1468  # SCTP Configuration (EXPERIMENTAL)
1469 @@ -310,6 +329,7 @@
1470  #
1471  CONFIG_NET_ETHERNET=y
1472  CONFIG_MII=y
1473 +# CONFIG_SMC91X is not set
1474  # CONFIG_HAPPYMEAL is not set
1475  # CONFIG_SUNGEM is not set
1476  # CONFIG_NET_VENDOR_3COM is not set
1477 @@ -351,6 +371,11 @@
1478  # CONFIG_R8169 is not set
1479  # CONFIG_SK98LIN is not set
1480  # CONFIG_TIGON3 is not set
1481 +
1482 +#
1483 +# Ethernet (10000 Mbit)
1484 +#
1485 +# CONFIG_IXGB is not set
1486  # CONFIG_FDDI is not set
1487  # CONFIG_HIPPI is not set
1488  # CONFIG_PPP is not set
1489 @@ -402,6 +427,7 @@
1490  CONFIG_BLK_DEV_IDECD=y
1491  # CONFIG_BLK_DEV_IDEFLOPPY is not set
1492  # CONFIG_IDE_TASK_IOCTL is not set
1493 +# CONFIG_IDE_TASKFILE_IO is not set
1494  
1495  #
1496  # IDE chipset support/bugfixes
1497 @@ -409,7 +435,7 @@
1498  # CONFIG_BLK_DEV_IDEPCI is not set
1499  
1500  #
1501 -# SCSI support
1502 +# SCSI device support
1503  #
1504  # CONFIG_SCSI is not set
1505  
1506 @@ -481,6 +507,7 @@
1507  #
1508  # I2C Hardware Sensors Chip support
1509  #
1510 +# CONFIG_I2C_SENSOR is not set
1511  
1512  #
1513  # L3 serial bus support
1514 @@ -534,6 +561,8 @@
1515  # CONFIG_VIDEO_PMS is not set
1516  # CONFIG_VIDEO_CPIA is not set
1517  # CONFIG_VIDEO_STRADIS is not set
1518 +# CONFIG_VIDEO_HEXIUM_ORION is not set
1519 +# CONFIG_VIDEO_HEXIUM_GEMINI is not set
1520  
1521  #
1522  # Radio Adapters
1523 @@ -551,18 +580,29 @@
1524  #
1525  # Supported Frontend Modules
1526  #
1527 -CONFIG_DVB_ALPS_BSRU6=y
1528 +# CONFIG_DVB_STV0299 is not set
1529  # CONFIG_DVB_ALPS_BSRV2 is not set
1530  # CONFIG_DVB_ALPS_TDLB7 is not set
1531  # CONFIG_DVB_ALPS_TDMB7 is not set
1532 +# CONFIG_DVB_ATMEL_AT76C651 is not set
1533 +# CONFIG_DVB_CX24110 is not set
1534  # CONFIG_DVB_GRUNDIG_29504_491 is not set
1535  # CONFIG_DVB_GRUNDIG_29504_401 is not set
1536 +# CONFIG_DVB_MT312 is not set
1537  # CONFIG_DVB_VES1820 is not set
1538 +# CONFIG_DVB_TDA1004X is not set
1539  
1540  #
1541 -# Supported DVB Adapters
1542 +# Supported SAA7146 based PCI Adapters
1543  #
1544  # CONFIG_DVB_AV7110 is not set
1545 +# CONFIG_DVB_BUDGET is not set
1546 +
1547 +#
1548 +# Supported FlexCopII (B2C2) Adapters
1549 +#
1550 +# CONFIG_DVB_B2C2_SKYSTAR is not set
1551 +# CONFIG_VIDEO_BTCX is not set
1552  
1553  #
1554  # File systems
1555 @@ -598,6 +638,7 @@
1556  CONFIG_PROC_FS=y
1557  # CONFIG_DEVFS_FS is not set
1558  CONFIG_DEVPTS_FS=y
1559 +# CONFIG_DEVPTS_FS_XATTR is not set
1560  CONFIG_TMPFS=y
1561  CONFIG_RAMFS=y
1562  
1563 @@ -631,13 +672,13 @@
1564  CONFIG_ROOT_NFS=y
1565  CONFIG_LOCKD=y
1566  # CONFIG_EXPORTFS is not set
1567 +CONFIG_SUNRPC=y
1568 +# CONFIG_SUNRPC_GSS is not set
1569  # CONFIG_SMB_FS is not set
1570  # CONFIG_CIFS is not set
1571  # CONFIG_NCP_FS is not set
1572  # CONFIG_CODA_FS is not set
1573  # CONFIG_INTERMEZZO_FS is not set
1574 -CONFIG_SUNRPC=y
1575 -# CONFIG_SUNRPC_GSS is not set
1576  # CONFIG_AFS_FS is not set
1577  
1578  #
1579 @@ -655,6 +696,7 @@
1580  # CONFIG_SOLARIS_X86_PARTITION is not set
1581  # CONFIG_UNIXWARE_DISKLABEL is not set
1582  # CONFIG_LDM_PARTITION is not set
1583 +# CONFIG_NEC98_PARTITION is not set
1584  # CONFIG_SGI_PARTITION is not set
1585  # CONFIG_ULTRIX_PARTITION is not set
1586  # CONFIG_SUN_PARTITION is not set
1587 @@ -666,13 +708,6 @@
1588  # CONFIG_FB is not set
1589  
1590  #
1591 -# Console display driver support
1592 -#
1593 -# CONFIG_VGA_CONSOLE is not set
1594 -# CONFIG_MDA_CONSOLE is not set
1595 -CONFIG_DUMMY_CONSOLE=y
1596 -
1597 -#
1598  # Sound
1599  #
1600  # CONFIG_SOUND is not set
1601 @@ -695,6 +730,7 @@
1602  # USB support
1603  #
1604  # CONFIG_USB is not set
1605 +# CONFIG_USB_GADGET is not set
1606  
1607  #
1608  # Bluetooth support
1609 @@ -714,7 +750,6 @@
1610  # CONFIG_DEBUG_WAITQ is not set
1611  CONFIG_DEBUG_BUGVERBOSE=y
1612  CONFIG_DEBUG_ERRORS=y
1613 -CONFIG_KALLSYMS=y
1614  CONFIG_DEBUG_LL=y
1615  
1616  #
1617 diff -Nru a/arch/arm/def-configs/iq80321 b/arch/arm/def-configs/iq80321
1618 --- a/arch/arm/def-configs/iq80321      Sat Aug  2 12:59:32 2003
1619 +++ b/arch/arm/def-configs/iq80321      Wed Aug 13 16:46:20 2003
1620 @@ -9,7 +9,7 @@
1621  #
1622  # Code maturity level options
1623  #
1624 -# CONFIG_EXPERIMENTAL is not set
1625 +CONFIG_EXPERIMENTAL=y
1626  
1627  #
1628  # General setup
1629 @@ -19,6 +19,12 @@
1630  # CONFIG_BSD_PROCESS_ACCT is not set
1631  CONFIG_SYSCTL=y
1632  CONFIG_LOG_BUF_SHIFT=14
1633 +# CONFIG_EMBEDDED is not set
1634 +CONFIG_KALLSYMS=y
1635 +CONFIG_FUTEX=y
1636 +CONFIG_EPOLL=y
1637 +CONFIG_IOSCHED_AS=y
1638 +CONFIG_IOSCHED_DEADLINE=y
1639  
1640  #
1641  # Loadable module support
1642 @@ -26,6 +32,7 @@
1643  CONFIG_MODULES=y
1644  # CONFIG_MODULE_UNLOAD is not set
1645  CONFIG_OBSOLETE_MODPARM=y
1646 +# CONFIG_MODVERSIONS is not set
1647  CONFIG_KMOD=y
1648  
1649  #
1650 @@ -33,7 +40,6 @@
1651  #
1652  # CONFIG_ARCH_ADIFCC is not set
1653  # CONFIG_ARCH_ANAKIN is not set
1654 -# CONFIG_ARCH_ARCA5K is not set
1655  # CONFIG_ARCH_CLPS7500 is not set
1656  # CONFIG_ARCH_CLPS711X is not set
1657  # CONFIG_ARCH_CO285 is not set
1658 @@ -49,14 +55,6 @@
1659  # CONFIG_ARCH_SHARK is not set
1660  
1661  #
1662 -# Archimedes/A5000 Implementations
1663 -#
1664 -
1665 -#
1666 -# Archimedes/A5000 Implementations (select only ONE)
1667 -#
1668 -
1669 -#
1670  # CLPS711X/EP721X Implementations
1671  #
1672  
1673 @@ -79,6 +77,18 @@
1674  #
1675  # IOP3xx Chipset Features
1676  #
1677 +# CONFIG_IOP3XX_AAU is not set
1678 +# CONFIG_IOP3XX_DMA is not set
1679 +# CONFIG_IOP3XX_MU is not set
1680 +# CONFIG_IOP3XX_PMON is not set
1681 +
1682 +#
1683 +# ADIFCC Implementation Options
1684 +#
1685 +
1686 +#
1687 +# ADI Board Types
1688 +#
1689  
1690  #
1691  # Intel PXA250/210 Implementations
1692 @@ -98,6 +108,7 @@
1693  #
1694  # Processor Features
1695  #
1696 +# CONFIG_ARM_THUMB is not set
1697  CONFIG_XSCALE_PMU=y
1698  
1699  #
1700 @@ -112,17 +123,25 @@
1701  # CONFIG_HOTPLUG is not set
1702  
1703  #
1704 +# MMC/SD Card support
1705 +#
1706 +# CONFIG_MMC is not set
1707 +
1708 +#
1709  # At least one math emulation must be selected
1710  #
1711  CONFIG_FPE_NWFPE=y
1712 +# CONFIG_FPE_NWFPE_XP is not set
1713 +# CONFIG_FPE_FASTFPE is not set
1714  CONFIG_KCORE_ELF=y
1715  # CONFIG_KCORE_AOUT is not set
1716  CONFIG_BINFMT_AOUT=y
1717  CONFIG_BINFMT_ELF=y
1718  # CONFIG_BINFMT_MISC is not set
1719  # CONFIG_PM is not set
1720 +# CONFIG_PREEMPT is not set
1721  # CONFIG_ARTHUR is not set
1722 -CONFIG_CMDLINE="ip=boot root=nfs console=ttyS0,115200"
1723 +CONFIG_CMDLINE="ip=boot root=nfs console=ttyS0,115200 mem=128M@0xa0000000"
1724  CONFIG_ALIGNMENT_TRAP=y
1725  
1726  #
1727 @@ -148,6 +167,7 @@
1728  CONFIG_MTD_BLOCK=y
1729  # CONFIG_FTL is not set
1730  # CONFIG_NFTL is not set
1731 +# CONFIG_INFTL is not set
1732  
1733  #
1734  # RAM/ROM/Flash chip drivers
1735 @@ -158,6 +178,7 @@
1736  # CONFIG_MTD_CFI_ADV_OPTIONS is not set
1737  CONFIG_MTD_CFI_INTELEXT=y
1738  # CONFIG_MTD_CFI_AMDSTD is not set
1739 +# CONFIG_MTD_CFI_STAA is not set
1740  # CONFIG_MTD_RAM is not set
1741  # CONFIG_MTD_ROM is not set
1742  # CONFIG_MTD_ABSENT is not set
1743 @@ -166,13 +187,10 @@
1744  #
1745  # Mapping drivers for chip access
1746  #
1747 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
1748  # CONFIG_MTD_PHYSMAP is not set
1749 -# CONFIG_MTD_NORA is not set
1750  # CONFIG_MTD_ARM_INTEGRATOR is not set
1751 -CONFIG_MTD_IQ80321=y
1752  # CONFIG_MTD_EDB7312 is not set
1753 -# CONFIG_MTD_PCI is not set
1754 -# CONFIG_MTD_UCLINUX is not set
1755  
1756  #
1757  # Self-contained MTD device drivers
1758 @@ -185,9 +203,9 @@
1759  #
1760  # Disk-On-Chip Device Drivers
1761  #
1762 -# CONFIG_MTD_DOC1000 is not set
1763  # CONFIG_MTD_DOC2000 is not set
1764  # CONFIG_MTD_DOC2001 is not set
1765 +# CONFIG_MTD_DOC2001PLUS is not set
1766  
1767  #
1768  # NAND Flash Device Drivers
1769 @@ -206,6 +224,7 @@
1770  # CONFIG_BLK_CPQ_DA is not set
1771  # CONFIG_BLK_CPQ_CISS_DA is not set
1772  # CONFIG_BLK_DEV_DAC960 is not set
1773 +# CONFIG_BLK_DEV_UMEM is not set
1774  # CONFIG_BLK_DEV_LOOP is not set
1775  # CONFIG_BLK_DEV_NBD is not set
1776  CONFIG_BLK_DEV_RAM=y
1777 @@ -229,7 +248,6 @@
1778  # CONFIG_NETLINK_DEV is not set
1779  CONFIG_NETFILTER=y
1780  # CONFIG_NETFILTER_DEBUG is not set
1781 -# CONFIG_FILTER is not set
1782  CONFIG_UNIX=y
1783  # CONFIG_NET_KEY is not set
1784  CONFIG_INET=y
1785 @@ -241,24 +259,47 @@
1786  # CONFIG_IP_PNP_RARP is not set
1787  # CONFIG_NET_IPIP is not set
1788  # CONFIG_NET_IPGRE is not set
1789 +# CONFIG_ARPD is not set
1790  # CONFIG_INET_ECN is not set
1791  # CONFIG_SYN_COOKIES is not set
1792  # CONFIG_INET_AH is not set
1793  # CONFIG_INET_ESP is not set
1794 -# CONFIG_XFRM_USER is not set
1795 +# CONFIG_INET_IPCOMP is not set
1796  
1797  #
1798  # IP: Netfilter Configuration
1799  #
1800  # CONFIG_IP_NF_CONNTRACK is not set
1801 +# CONFIG_IP_NF_QUEUE is not set
1802  # CONFIG_IP_NF_IPTABLES is not set
1803  # CONFIG_IP_NF_ARPTABLES is not set
1804  # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
1805  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
1806 +
1807 +#
1808 +# IP: Virtual Server Configuration
1809 +#
1810 +# CONFIG_IP_VS is not set
1811 +# CONFIG_IPV6 is not set
1812 +# CONFIG_XFRM_USER is not set
1813 +
1814 +#
1815 +# SCTP Configuration (EXPERIMENTAL)
1816 +#
1817 +CONFIG_IPV6_SCTP__=y
1818 +# CONFIG_IP_SCTP is not set
1819 +# CONFIG_ATM is not set
1820  # CONFIG_VLAN_8021Q is not set
1821  # CONFIG_LLC is not set
1822  # CONFIG_DECNET is not set
1823  # CONFIG_BRIDGE is not set
1824 +# CONFIG_X25 is not set
1825 +# CONFIG_LAPB is not set
1826 +# CONFIG_NET_DIVERT is not set
1827 +# CONFIG_ECONET is not set
1828 +# CONFIG_WAN_ROUTER is not set
1829 +# CONFIG_NET_FASTROUTE is not set
1830 +# CONFIG_NET_HW_FLOWCONTROL is not set
1831  
1832  #
1833  # QoS and/or fair queueing
1834 @@ -279,12 +320,14 @@
1835  # CONFIG_BONDING is not set
1836  # CONFIG_EQUALIZER is not set
1837  # CONFIG_TUN is not set
1838 +# CONFIG_ETHERTAP is not set
1839  
1840  #
1841  # Ethernet (10 or 100Mbit)
1842  #
1843  CONFIG_NET_ETHERNET=y
1844  # CONFIG_MII is not set
1845 +# CONFIG_SMC91X is not set
1846  # CONFIG_HAPPYMEAL is not set
1847  # CONFIG_SUNGEM is not set
1848  # CONFIG_NET_VENDOR_3COM is not set
1849 @@ -298,6 +341,7 @@
1850  # CONFIG_PCNET32 is not set
1851  # CONFIG_AMD8111_ETH is not set
1852  # CONFIG_ADAPTEC_STARFIRE is not set
1853 +# CONFIG_B44 is not set
1854  # CONFIG_DGRS is not set
1855  CONFIG_EEPRO100=y
1856  # CONFIG_EEPRO100_PIO is not set
1857 @@ -305,6 +349,7 @@
1858  # CONFIG_FEALNX is not set
1859  # CONFIG_NATSEMI is not set
1860  # CONFIG_NE2K_PCI is not set
1861 +# CONFIG_8139CP is not set
1862  # CONFIG_8139TOO is not set
1863  # CONFIG_SIS900 is not set
1864  # CONFIG_EPIC100 is not set
1865 @@ -317,13 +362,21 @@
1866  #
1867  # CONFIG_ACENIC is not set
1868  # CONFIG_DL2K is not set
1869 -# CONFIG_E1000 is not set
1870 +CONFIG_E1000=y
1871 +CONFIG_E1000_NAPI=y
1872  # CONFIG_NS83820 is not set
1873  # CONFIG_HAMACHI is not set
1874 +# CONFIG_YELLOWFIN is not set
1875  # CONFIG_R8169 is not set
1876  # CONFIG_SK98LIN is not set
1877  # CONFIG_TIGON3 is not set
1878 +
1879 +#
1880 +# Ethernet (10000 Mbit)
1881 +#
1882 +# CONFIG_IXGB is not set
1883  # CONFIG_FDDI is not set
1884 +# CONFIG_HIPPI is not set
1885  # CONFIG_PPP is not set
1886  # CONFIG_SLIP is not set
1887  
1888 @@ -335,6 +388,8 @@
1889  #
1890  # Token Ring devices (depends on LLC=y)
1891  #
1892 +# CONFIG_RCPCI is not set
1893 +# CONFIG_SHAPER is not set
1894  
1895  #
1896  # Wan interfaces
1897 @@ -371,6 +426,7 @@
1898  CONFIG_BLK_DEV_IDECD=y
1899  # CONFIG_BLK_DEV_IDEFLOPPY is not set
1900  # CONFIG_IDE_TASK_IOCTL is not set
1901 +# CONFIG_IDE_TASKFILE_IO is not set
1902  
1903  #
1904  # IDE chipset support/bugfixes
1905 @@ -379,11 +435,13 @@
1906  # CONFIG_BLK_DEV_GENERIC is not set
1907  # CONFIG_IDEPCI_SHARE_IRQ is not set
1908  CONFIG_BLK_DEV_IDEDMA_PCI=y
1909 +# CONFIG_BLK_DEV_IDE_TCQ is not set
1910  # CONFIG_BLK_DEV_OFFBOARD is not set
1911  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
1912  CONFIG_IDEDMA_PCI_AUTO=y
1913  # CONFIG_IDEDMA_ONLYDISK is not set
1914  CONFIG_BLK_DEV_IDEDMA=y
1915 +# CONFIG_IDEDMA_PCI_WIP is not set
1916  CONFIG_BLK_DEV_ADMA=y
1917  # CONFIG_BLK_DEV_AEC62XX is not set
1918  # CONFIG_BLK_DEV_ALI15X3 is not set
1919 @@ -391,11 +449,13 @@
1920  CONFIG_BLK_DEV_CMD64X=y
1921  # CONFIG_BLK_DEV_TRIFLEX is not set
1922  # CONFIG_BLK_DEV_CY82C693 is not set
1923 +# CONFIG_BLK_DEV_CS5520 is not set
1924  # CONFIG_BLK_DEV_HPT34X is not set
1925  # CONFIG_BLK_DEV_HPT366 is not set
1926  # CONFIG_BLK_DEV_SC1200 is not set
1927  # CONFIG_BLK_DEV_PIIX is not set
1928  # CONFIG_BLK_DEV_NS87415 is not set
1929 +# CONFIG_BLK_DEV_OPTI621 is not set
1930  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
1931  # CONFIG_BLK_DEV_PDC202XX_NEW is not set
1932  # CONFIG_BLK_DEV_SVWKS is not set
1933 @@ -408,11 +468,16 @@
1934  # CONFIG_IDEDMA_IVB is not set
1935  
1936  #
1937 -# SCSI support
1938 +# SCSI device support
1939  #
1940  # CONFIG_SCSI is not set
1941  
1942  #
1943 +# IEEE 1394 (FireWire) support (EXPERIMENTAL)
1944 +#
1945 +# CONFIG_IEEE1394 is not set
1946 +
1947 +#
1948  # I2O device support
1949  #
1950  # CONFIG_I2O is not set
1951 @@ -450,11 +515,16 @@
1952  #
1953  # Serial drivers
1954  #
1955 +CONFIG_SERIAL_8250=y
1956 +CONFIG_SERIAL_8250_CONSOLE=y
1957 +# CONFIG_SERIAL_8250_EXTENDED is not set
1958  
1959  #
1960  # Non-8250 serial port support
1961  #
1962  # CONFIG_SERIAL_DZ is not set
1963 +CONFIG_SERIAL_CORE=y
1964 +CONFIG_SERIAL_CORE_CONSOLE=y
1965  CONFIG_UNIX98_PTYS=y
1966  CONFIG_UNIX98_PTY_COUNT=256
1967  
1968 @@ -470,6 +540,7 @@
1969  #
1970  # I2C Hardware Sensors Chip support
1971  #
1972 +# CONFIG_I2C_SENSOR is not set
1973  
1974  #
1975  # L3 serial bus support
1976 @@ -522,6 +593,9 @@
1977  #
1978  # CONFIG_VIDEO_PMS is not set
1979  # CONFIG_VIDEO_CPIA is not set
1980 +# CONFIG_VIDEO_STRADIS is not set
1981 +# CONFIG_VIDEO_HEXIUM_ORION is not set
1982 +# CONFIG_VIDEO_HEXIUM_GEMINI is not set
1983  
1984  #
1985  # Radio Adapters
1986 @@ -534,6 +608,7 @@
1987  # Digital Video Broadcasting Devices
1988  #
1989  # CONFIG_DVB is not set
1990 +# CONFIG_VIDEO_BTCX is not set
1991  
1992  #
1993  # File systems
1994 @@ -567,16 +642,25 @@
1995  # Pseudo filesystems
1996  #
1997  CONFIG_PROC_FS=y
1998 +# CONFIG_DEVFS_FS is not set
1999  CONFIG_DEVPTS_FS=y
2000 +# CONFIG_DEVPTS_FS_XATTR is not set
2001  CONFIG_TMPFS=y
2002  CONFIG_RAMFS=y
2003  
2004  #
2005  # Miscellaneous filesystems
2006  #
2007 +# CONFIG_ADFS_FS is not set
2008 +# CONFIG_AFFS_FS is not set
2009 +# CONFIG_HFS_FS is not set
2010 +# CONFIG_BEFS_FS is not set
2011 +# CONFIG_BFS_FS is not set
2012 +# CONFIG_EFS_FS is not set
2013  # CONFIG_JFFS_FS is not set
2014  CONFIG_JFFS2_FS=y
2015  CONFIG_JFFS2_FS_DEBUG=0
2016 +# CONFIG_JFFS2_FS_NAND is not set
2017  # CONFIG_CRAMFS is not set
2018  # CONFIG_VXFS_FS is not set
2019  # CONFIG_HPFS_FS is not set
2020 @@ -589,15 +673,19 @@
2021  #
2022  CONFIG_NFS_FS=y
2023  # CONFIG_NFS_V3 is not set
2024 +# CONFIG_NFS_V4 is not set
2025  # CONFIG_NFSD is not set
2026  CONFIG_ROOT_NFS=y
2027  CONFIG_LOCKD=y
2028  # CONFIG_EXPORTFS is not set
2029 +CONFIG_SUNRPC=y
2030 +# CONFIG_SUNRPC_GSS is not set
2031  # CONFIG_SMB_FS is not set
2032  # CONFIG_CIFS is not set
2033  # CONFIG_NCP_FS is not set
2034  # CONFIG_CODA_FS is not set
2035 -CONFIG_SUNRPC=y
2036 +# CONFIG_INTERMEZZO_FS is not set
2037 +# CONFIG_AFS_FS is not set
2038  
2039  #
2040  # Partition Types
2041 @@ -614,6 +702,7 @@
2042  # CONFIG_SOLARIS_X86_PARTITION is not set
2043  # CONFIG_UNIXWARE_DISKLABEL is not set
2044  # CONFIG_LDM_PARTITION is not set
2045 +# CONFIG_NEC98_PARTITION is not set
2046  # CONFIG_SGI_PARTITION is not set
2047  # CONFIG_ULTRIX_PARTITION is not set
2048  # CONFIG_SUN_PARTITION is not set
2049 @@ -625,13 +714,6 @@
2050  # CONFIG_FB is not set
2051  
2052  #
2053 -# Console display driver support
2054 -#
2055 -# CONFIG_VGA_CONSOLE is not set
2056 -# CONFIG_MDA_CONSOLE is not set
2057 -CONFIG_DUMMY_CONSOLE=y
2058 -
2059 -#
2060  # Sound
2061  #
2062  # CONFIG_SOUND is not set
2063 @@ -654,6 +736,7 @@
2064  # USB support
2065  #
2066  # CONFIG_USB is not set
2067 +# CONFIG_USB_GADGET is not set
2068  
2069  #
2070  # Bluetooth support
2071 @@ -664,7 +747,7 @@
2072  # Kernel hacking
2073  #
2074  CONFIG_FRAME_POINTER=y
2075 -CONFIG_DEBUG_USER=y
2076 +# CONFIG_DEBUG_USER is not set
2077  # CONFIG_DEBUG_INFO is not set
2078  CONFIG_DEBUG_KERNEL=y
2079  # CONFIG_DEBUG_SLAB is not set
2080 @@ -673,7 +756,6 @@
2081  # CONFIG_DEBUG_WAITQ is not set
2082  CONFIG_DEBUG_BUGVERBOSE=y
2083  CONFIG_DEBUG_ERRORS=y
2084 -# CONFIG_KALLSYMS is not set
2085  CONFIG_DEBUG_LL=y
2086  
2087  #
2088 diff -Nru a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
2089 --- a/arch/arm/kernel/Makefile  Mon Aug  4 20:55:17 2003
2090 +++ b/arch/arm/kernel/Makefile  Wed Sep  3 01:25:59 2003
2091 @@ -2,13 +2,11 @@
2092  # Makefile for the linux kernel.
2093  #
2094  
2095 -ENTRY_OBJ = entry-$(PROCESSOR).o
2096 -
2097  AFLAGS_head.o := -DTEXTADDR=$(TEXTADDR)
2098  
2099  # Object file lists.
2100  
2101 -obj-y          := arch.o compat.o dma.o $(ENTRY_OBJ) entry-common.o irq.o   \
2102 +obj-y          := arch.o compat.o dma.o entry-armv.o entry-common.o irq.o   \
2103                    process.o ptrace.o semaphore.o setup.o signal.o sys_arm.o \
2104                    time.o traps.o
2105  
2106 @@ -34,6 +32,5 @@
2107  
2108  # Spell out some dependencies that `make dep' doesn't spot
2109  $(obj)/entry-armv.o:   $(obj)/entry-header.S include/asm-arm/constants.h
2110 -$(obj)/entry-armo.o:   $(obj)/entry-header.S include/asm-arm/constants.h
2111  $(obj)/entry-common.o:         $(obj)/entry-header.S include/asm-arm/constants.h \
2112                         $(obj)/calls.S
2113 diff -Nru a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
2114 --- a/arch/arm/kernel/apm.c     Wed Mar 26 05:00:46 2003
2115 +++ b/arch/arm/kernel/apm.c     Sun Aug 31 16:14:08 2003
2116 @@ -26,6 +26,7 @@
2117  #include <linux/init.h>
2118  #include <linux/completion.h>
2119  
2120 +#include <asm/apm.h> /* apm_power_info */
2121  #include <asm/system.h>
2122  
2123  /*
2124 @@ -93,18 +94,7 @@
2125  
2126  static const char driver_version[] = "1.13";   /* no spaces */
2127  
2128 -/*
2129 - * This structure gets filled in by the machine specific 'get_power_status'
2130 - * implementation.  Any fields which are not set default to a safe value.
2131 - */
2132 -struct apm_power_info {
2133 -       unsigned char   ac_line_status;
2134 -       unsigned char   battery_status;
2135 -       unsigned char   battery_flag;
2136 -       unsigned char   battery_life;
2137 -       int             time;
2138 -       int             units;
2139 -};
2140 +
2141  
2142  /*
2143   * Compatibility cruft until the IPAQ people move over to the new
2144 @@ -388,18 +378,18 @@
2145  }
2146  
2147  static struct file_operations apm_bios_fops = {
2148 -       owner:          THIS_MODULE,
2149 -       read:           apm_read,
2150 -       poll:           apm_poll,
2151 -       ioctl:          apm_ioctl,
2152 -       open:           apm_open,
2153 -       release:        apm_release,
2154 +       .owner          = THIS_MODULE,
2155 +       .read           = apm_read,
2156 +       .poll           = apm_poll,
2157 +       .ioctl          = apm_ioctl,
2158 +       .open           = apm_open,
2159 +       .release        = apm_release,
2160  };
2161  
2162  static struct miscdevice apm_device = {
2163 -       minor:          APM_MINOR_DEV,
2164 -       name:           "apm_bios",
2165 -       fops:           &apm_bios_fops
2166 +       .minor          = APM_MINOR_DEV,
2167 +       .name           = "apm_bios",
2168 +       .fops           = &apm_bios_fops
2169  };
2170  
2171  
2172 diff -Nru a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
2173 --- a/arch/arm/kernel/bios32.c  Thu Jul 31 16:47:19 2003
2174 +++ b/arch/arm/kernel/bios32.c  Sun Aug 24 06:12:42 2003
2175 @@ -263,7 +263,7 @@
2176  void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
2177  {
2178         if (debug_pci)
2179 -               printk("PCI: Assigning IRQ %02d to %s\n", irq, dev->dev.name);
2180 +               printk("PCI: Assigning IRQ %02d to %s\n", irq, pci_name(dev));
2181         pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
2182  }
2183  
2184 @@ -362,6 +362,19 @@
2185                         isa_bridge = dev;
2186                         break;
2187  #endif
2188 +               case PCI_CLASS_BRIDGE_PCI:
2189 +                       pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &status);
2190 +                       status |= PCI_BRIDGE_CTL_PARITY|PCI_BRIDGE_CTL_MASTER_ABORT;
2191 +                       status &= ~(PCI_BRIDGE_CTL_BUS_RESET|PCI_BRIDGE_CTL_FAST_BACK);
2192 +                       pci_write_config_word(dev, PCI_BRIDGE_CONTROL, status);
2193 +                       break;
2194 +
2195 +               case PCI_CLASS_BRIDGE_CARDBUS:
2196 +                       pci_read_config_word(dev, PCI_CB_BRIDGE_CONTROL, &status);
2197 +                       status |= PCI_CB_BRIDGE_CTL_PARITY|PCI_CB_BRIDGE_CTL_MASTER_ABORT;
2198 +                       pci_write_config_word(dev, PCI_CB_BRIDGE_CONTROL, status);
2199 +                       break;
2200 +               }
2201         }
2202  
2203         /*
2204 diff -Nru a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
2205 --- a/arch/arm/kernel/ecard.c   Fri Aug 15 15:22:53 2003
2206 +++ b/arch/arm/kernel/ecard.c   Sun Aug 24 05:44:40 2003
2207 @@ -896,7 +896,7 @@
2208  static ssize_t ecard_show_vendor(struct device *dev, char *buf)
2209  {
2210         struct expansion_card *ec = ECARD_DEV(dev);
2211 -       return sprintf(buf, "%u\n", ec->manufacturer);
2212 +       return sprintf(buf, "%u\n", ec->cid.manufacturer);
2213  }
2214  
2215  static DEVICE_ATTR(vendor, S_IRUGO, ecard_show_vendor, NULL);
2216 @@ -904,7 +904,7 @@
2217  static ssize_t ecard_show_device(struct device *dev, char *buf)
2218  {
2219         struct expansion_card *ec = ECARD_DEV(dev);
2220 -       return sprintf(buf, "%u\n", ec->product);
2221 +       return sprintf(buf, "%u\n", ec->cid.product);
2222  }
2223  
2224  static DEVICE_ATTR(device, S_IRUGO, ecard_show_device, NULL);
2225 diff -Nru a/arch/arm/kernel/entry-armo.S b/arch/arm/kernel/entry-armo.S
2226 --- a/arch/arm/kernel/entry-armo.S      Mon Feb 24 12:42:23 2003
2227 +++ /dev/null   Wed Dec 31 16:00:00 1969
2228 @@ -1,633 +0,0 @@
2229 -/*
2230 - *  linux/arch/arm/kernel/entry-armo.S
2231 - *
2232 - *  Copyright (C) 1995,1996,1997,1998 Russell King.
2233 - *
2234 - * This program is free software; you can redistribute it and/or modify
2235 - * it under the terms of the GNU General Public License version 2 as
2236 - * published by the Free Software Foundation.
2237 - *
2238 - *  Low-level vector interface routines
2239 - *
2240 - *  Design issues:
2241 - *   - We have several modes that each vector can be called from,
2242 - *     each with its own set of registers.  On entry to any vector,
2243 - *     we *must* save the registers used in *that* mode.
2244 - *
2245 - *   - This code must be as fast as possible.
2246 - *
2247 - *  There are a few restrictions on the vectors:
2248 - *   - the SWI vector cannot be called from *any* non-user mode
2249 - *
2250 - *   - the FP emulator is *never* called from *any* non-user mode undefined
2251 - *     instruction.
2252 - *
2253 - *  Ok, so this file may be a mess, but its as efficient as possible while
2254 - *  adhering to the above criteria.
2255 - */
2256 -#include <linux/config.h>
2257 -#include <linux/init.h>
2258 -#include "entry-header.S"
2259 -
2260 -               .text
2261 -
2262 -#ifdef IOC_BASE
2263 -/* IOC / IOMD based hardware */
2264 -               .equ    ioc_base_high, IOC_BASE & 0xff000000
2265 -               .equ    ioc_base_low, IOC_BASE & 0x00ff0000
2266 -               .macro  disable_fiq
2267 -               mov     r12, #ioc_base_high
2268 -               .if     ioc_base_low
2269 -               orr     r12, r12, #ioc_base_low
2270 -               .endif
2271 -               strb    r12, [r12, #0x38]       @ Disable FIQ register
2272 -               .endm
2273 -
2274 -               .macro  get_irqnr_and_base, irqnr, base
2275 -               mov     r4, #ioc_base_high              @ point at IOC
2276 -               .if     ioc_base_low
2277 -               orr     r4, r4, #ioc_base_low
2278 -               .endif
2279 -               ldrb    \irqnr, [r4, #0x24]             @ get high priority first
2280 -               adr     \base, irq_prio_h
2281 -               teq     \irqnr, #0
2282 -               ldreqb  \irqnr, [r4, #0x14]             @ get low priority
2283 -               adreq   \base, irq_prio_l
2284 -               .endm
2285 -
2286 -/*
2287 - * Interrupt table (incorporates priority)
2288 - */
2289 -               .macro  irq_prio_table
2290 -irq_prio_l:    .byte    0, 0, 1, 0, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
2291 -               .byte    4, 0, 1, 0, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
2292 -               .byte    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
2293 -               .byte    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
2294 -               .byte    6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3
2295 -               .byte    6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3
2296 -               .byte    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
2297 -               .byte    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
2298 -               .byte    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2299 -               .byte    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2300 -               .byte    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2301 -               .byte    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2302 -               .byte    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2303 -               .byte    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2304 -               .byte    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2305 -               .byte    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2306 -irq_prio_h:    .byte    0, 8, 9, 8,10,10,10,10,11,11,11,11,10,10,10,10
2307 -               .byte   12, 8, 9, 8,10,10,10,10,11,11,11,11,10,10,10,10
2308 -               .byte   13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
2309 -               .byte   13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
2310 -               .byte   14,14,14,14,10,10,10,10,11,11,11,11,10,10,10,10
2311 -               .byte   14,14,14,14,10,10,10,10,11,11,11,11,10,10,10,10
2312 -               .byte   13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
2313 -               .byte   13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
2314 -               .byte   15,15,15,15,10,10,10,10,11,11,11,11,10,10,10,10
2315 -               .byte   15,15,15,15,10,10,10,10,11,11,11,11,10,10,10,10
2316 -               .byte   13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
2317 -               .byte   13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
2318 -               .byte   15,15,15,15,10,10,10,10,11,11,11,11,10,10,10,10
2319 -               .byte   15,15,15,15,10,10,10,10,11,11,11,11,10,10,10,10
2320 -               .byte   13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
2321 -               .byte   13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
2322 -               .endm
2323 -#else
2324 -#error Unknown architecture
2325 -#endif
2326 -
2327 -/*=============================================================================
2328 - * For entry-common.S
2329 - */
2330 -
2331 -#if 0
2332 -/*
2333 - * Uncomment these if you wish to get more debugging into about data aborts.
2334 - */
2335 -#define FAULT_CODE_LDRSTRPOST  0x80
2336 -#define FAULT_CODE_LDRSTRPRE   0x40
2337 -#define FAULT_CODE_LDRSTRREG   0x20
2338 -#define FAULT_CODE_LDMSTM      0x10
2339 -#define FAULT_CODE_LDCSTC      0x08
2340 -#endif
2341 -#define FAULT_CODE_PREFETCH    0x04
2342 -#define FAULT_CODE_WRITE       0x02
2343 -#define FAULT_CODE_FORCECOW    0x01
2344 -
2345 -#define SVC_SAVE_ALL                           \
2346 -               str     sp, [sp, #-16]!         ;\
2347 -               str     lr, [sp, #8]            ;\
2348 -               str     lr, [sp, #4]            ;\
2349 -               stmfd   sp!, {r0 - r12}         ;\
2350 -               mov     r0, #-1                 ;\
2351 -               str     r0, [sp, #S_OLD_R0]     ;\
2352 -               zero_fp
2353 -
2354 -#define SVC_IRQ_SAVE_ALL                       \
2355 -               str     sp, [sp, #-16]!         ;\
2356 -               str     lr, [sp, #4]            ;\
2357 -               ldr     lr, .LCirq              ;\
2358 -               ldr     lr, [lr]                ;\
2359 -               str     lr, [sp, #8]            ;\
2360 -               stmfd   sp!, {r0 - r12}         ;\
2361 -               mov     r0, #-1                 ;\
2362 -               str     r0, [sp, #S_OLD_R0]     ;\
2363 -               zero_fp
2364 -
2365 -#define SVC_RESTORE_ALL                                \
2366 -               ldmfd   sp, {r0 - pc}^
2367 -               
2368 -/*=============================================================================
2369 - * Undefined FIQs
2370 - *-----------------------------------------------------------------------------
2371 - */
2372 -_unexp_fiq:    ldr     sp, .LCfiq
2373 -               mov     r12, #IOC_BASE
2374 -               strb    r12, [r12, #0x38]       @ Disable FIQ register
2375 -               teqp    pc, #0x0c000003
2376 -               mov     r0, r0
2377 -               stmfd   sp!, {r0 - r3, ip, lr}
2378 -               adr     r0, Lfiqmsg
2379 -               bl      printk
2380 -               ldmfd   sp!, {r0 - r3, ip, lr}
2381 -               teqp    pc, #0x0c000001
2382 -               mov     r0, r0
2383 -               movs    pc, lr
2384 -
2385 -Lfiqmsg:       .ascii  "*** Unexpected FIQ\n\0"
2386 -               .align
2387 -
2388 -.LCfiq:                .word   __temp_fiq
2389 -.LCirq:                .word   __temp_irq
2390 -
2391 -/*=============================================================================
2392 - * Undefined instruction handler
2393 - *-----------------------------------------------------------------------------
2394 - * Handles floating point instructions
2395 - */
2396 -vector_undefinstr:
2397 -               tst     lr,#3
2398 -               bne     __und_svc
2399 -               save_user_regs
2400 -               zero_fp
2401 -               teqp    pc, #PSR_I_BIT | MODE_SVC
2402 -.Lbug_undef:
2403 -               ldr     r4, .LC2
2404 -               ldr     pc, [r4]                        @ Call FP module USR entry point
2405 -
2406 -               .globl  fpundefinstr
2407 -fpundefinstr:                                          @ Called by FP module on undefined instr
2408 -               mov     r0, lr
2409 -               mov     r1, sp
2410 -               teqp    pc, #MODE_SVC
2411 -               bl      do_undefinstr
2412 -               b       ret_from_exception              @ Normal FP exit
2413 -
2414 -__und_svc:     SVC_SAVE_ALL                            @ Non-user mode
2415 -               mask_pc r0, lr
2416 -               and     r2, lr, #3
2417 -               sub     r0, r0, #4
2418 -               mov     r1, sp
2419 -               bl      do_undefinstr
2420 -               SVC_RESTORE_ALL
2421 -
2422 -#if defined CONFIG_FPE_NWFPE || defined CONFIG_FPE_FASTFPE
2423 -               /* The FPE is always present */
2424 -               .equ    fpe_not_present, 0
2425 -#else
2426 -/* We get here if an undefined instruction happens and the floating
2427 - * point emulator is not present.  If the offending instruction was
2428 - * a WFS, we just perform a normal return as if we had emulated the
2429 - * operation.  This is a hack to allow some basic userland binaries
2430 - * to run so that the emulator module proper can be loaded. --philb
2431 - */
2432 -fpe_not_present:
2433 -               adr     r10, wfs_mask_data
2434 -               ldmia   r10, {r4, r5, r6, r7, r8}
2435 -               ldr     r10, [sp, #S_PC]                @ Load PC
2436 -               sub     r10, r10, #4
2437 -               mask_pc r10, r10
2438 -               ldrt    r10, [r10]                      @ get instruction
2439 -               and     r5, r10, r5
2440 -               teq     r5, r4                          @ Is it WFS?
2441 -               beq     ret_from_exception
2442 -               and     r5, r10, r8
2443 -               teq     r5, r6                          @ Is it LDF/STF on sp or fp?
2444 -               teqne   r5, r7
2445 -               bne     fpundefinstr
2446 -               tst     r10, #0x00200000                @ Does it have WB
2447 -               beq     ret_from_exception
2448 -               and     r4, r10, #255                   @ get offset
2449 -               and     r6, r10, #0x000f0000
2450 -               tst     r10, #0x00800000                @ +/-
2451 -               ldr     r5, [sp, r6, lsr #14]           @ Load reg
2452 -               rsbeq   r4, r4, #0
2453 -               add     r5, r5, r4, lsl #2
2454 -               str     r5, [sp, r6, lsr #14]           @ Save reg
2455 -               b       ret_from_exception
2456 -
2457 -wfs_mask_data: .word   0x0e200110                      @ WFS/RFS
2458 -               .word   0x0fef0fff
2459 -               .word   0x0d0d0100                      @ LDF [sp]/STF [sp]
2460 -               .word   0x0d0b0100                      @ LDF [fp]/STF [fp]
2461 -               .word   0x0f0f0f00
2462 -#endif
2463 -
2464 -.LC2:          .word   fp_enter
2465 -
2466 -/*=============================================================================
2467 - * Prefetch abort handler
2468 - *-----------------------------------------------------------------------------
2469 - */
2470 -
2471 -vector_prefetch:
2472 -               sub     lr, lr, #4
2473 -               tst     lr, #3
2474 -               bne     __pabt_invalid
2475 -               save_user_regs
2476 -               teqp    pc, #0x00000003         @ NOT a problem - doesn't change mode
2477 -               mask_pc r0, lr                  @ Address of abort
2478 -               mov     r1, sp                  @ Tasks registers
2479 -               bl      do_PrefetchAbort
2480 -               teq     r0, #0                  @ If non-zero, we believe this abort..
2481 -               bne     ret_from_exception
2482 -#ifdef DEBUG_UNDEF
2483 -               adr     r0, t
2484 -               bl      printk
2485 -#endif
2486 -               ldr     lr, [sp,#S_PC]          @ program to test this on.  I think its
2487 -               b       .Lbug_undef             @ broken at the moment though!)
2488 -
2489 -__pabt_invalid:        SVC_SAVE_ALL
2490 -               mov     r0, sp                          @ Prefetch aborts are definitely *not*
2491 -               mov     r1, #BAD_PREFETCH               @ allowed in non-user modes.  We cant
2492 -               and     r2, lr, #3                      @ recover from this problem.
2493 -               b       bad_mode
2494 -
2495 -#ifdef DEBUG_UNDEF
2496 -t:             .ascii "*** undef ***\r\n\0"
2497 -               .align
2498 -#endif
2499 -
2500 -/*=============================================================================
2501 - * Address exception handler
2502 - *-----------------------------------------------------------------------------
2503 - * These aren't too critical.
2504 - * (they're not supposed to happen).
2505 - * In order to debug the reason for address exceptions in non-user modes,
2506 - * we have to obtain all the registers so that we can see what's going on.
2507 - */
2508 -
2509 -vector_addrexcptn:
2510 -               sub     lr, lr, #8
2511 -               tst     lr, #3
2512 -               bne     Laddrexcptn_not_user
2513 -               save_user_regs
2514 -               teq     pc, #0x00000003
2515 -               mask_pc r0, lr                  @ Point to instruction
2516 -               mov     r1, sp                  @ Point to registers
2517 -               mov     r2, #0x400
2518 -               mov     lr, pc
2519 -               bl      do_excpt
2520 -               b       ret_from_exception
2521 -
2522 -Laddrexcptn_not_user:
2523 -               SVC_SAVE_ALL
2524 -               and     r2, lr, #3
2525 -               teq     r2, #3
2526 -               bne     Laddrexcptn_illegal_mode
2527 -               teqp    pc, #0x00000003         @ NOT a problem - doesn't change mode
2528 -               mask_pc r0, lr
2529 -               mov     r1, sp
2530 -               orr     r2, r2, #0x400
2531 -               bl      do_excpt
2532 -               ldmia   sp, {r0 - lr}           @ I cant remember the reason I changed this...
2533 -               add     sp, sp, #15*4
2534 -               movs    pc, lr
2535 -
2536 -Laddrexcptn_illegal_mode:
2537 -               mov     r0, sp
2538 -               str     lr, [sp, #-4]!
2539 -               orr     r1, r2, #0x0c000000
2540 -               teqp    r1, #0                  @ change into mode (wont be user mode)
2541 -               mov     r0, r0
2542 -               mov     r1, r8                  @ Any register from r8 - r14 can be banked
2543 -               mov     r2, r9
2544 -               mov     r3, r10
2545 -               mov     r4, r11
2546 -               mov     r5, r12
2547 -               mov     r6, r13
2548 -               mov     r7, r14
2549 -               teqp    pc, #0x04000003         @ back to svc
2550 -               mov     r0, r0
2551 -               stmfd   sp!, {r1-r7}
2552 -               ldmia   r0, {r0-r7}
2553 -               stmfd   sp!, {r0-r7}
2554 -               mov     r0, sp
2555 -               mov     r1, #BAD_ADDREXCPTN
2556 -               b       bad_mode
2557 -
2558 -/*=============================================================================
2559 - * Interrupt (IRQ) handler
2560 - *-----------------------------------------------------------------------------
2561 - * Note: if in user mode, then *no* kernel routine is running, so do not have
2562 - *       to save svc lr
2563 - * (r13 points to irq temp save area)
2564 - */
2565 -
2566 -vector_IRQ:    ldr     r13, .LCirq                     @ I will leave this one in just in case...
2567 -               sub     lr, lr, #4
2568 -               str     lr, [r13]
2569 -               tst     lr, #3
2570 -               bne     __irq_svc
2571 -               teqp    pc, #0x08000003
2572 -               mov     r0, r0
2573 -               ldr     lr, .LCirq
2574 -               ldr     lr, [lr]
2575 -               save_user_regs
2576 -
2577 -1:             get_irqnr_and_base r6, r5
2578 -               teq     r6, #0
2579 -               ldrneb  r0, [r5, r6]                    @ get IRQ number
2580 -               movne   r1, sp
2581 -               @
2582 -               @ routine called with r0 = irq number, r1 = struct pt_regs *
2583 -               @
2584 -               adr     lr, 1b
2585 -               orr     lr, lr, #0x08000003             @ Force SVC
2586 -               bne     asm_do_IRQ
2587 -
2588 -               mov     why, #0
2589 -               get_current_task r5
2590 -               b       ret_to_user
2591 -
2592 -               irq_prio_table
2593 -
2594 -__irq_svc:     teqp    pc, #0x08000003
2595 -               mov     r0, r0
2596 -               SVC_IRQ_SAVE_ALL
2597 -                and    r2, lr, #3
2598 -               teq     r2, #3
2599 -               bne     __irq_invalid
2600 -1:             get_irqnr_and_base r6, r5
2601 -               teq     r6, #0
2602 -               ldrneb  r0, [r5, r6]                    @ get IRQ number
2603 -               movne   r1, sp
2604 -               @
2605 -               @ routine called with r0 = irq number, r1 = struct pt_regs *
2606 -               @
2607 -               adr     lr, 1b
2608 -               orr     lr, lr, #0x08000003             @ Force SVC
2609 -               bne     asm_do_IRQ                      @ Returns to 1b
2610 -               SVC_RESTORE_ALL
2611 -
2612 -__irq_invalid: mov     r0, sp
2613 -               mov     r1, #BAD_IRQ
2614 -               b       bad_mode
2615 -
2616 -/*=============================================================================
2617 - * Data abort handler code
2618 - *-----------------------------------------------------------------------------
2619 - *
2620 - * This handles both exceptions from user and SVC modes, computes the address
2621 - *  range of the problem, and does any correction that is required.  It then
2622 - *  calls the kernel data abort routine.
2623 - *
2624 - * This is where I wish that the ARM would tell you which address aborted.
2625 - */
2626 -
2627 -vector_data:   sub     lr, lr, #8              @ Correct lr
2628 -               tst     lr, #3
2629 -               bne     Ldata_not_user
2630 -               save_user_regs
2631 -               teqp    pc, #0x00000003         @ NOT a problem - doesn't change mode
2632 -               mask_pc r0, lr
2633 -               bl      Ldata_do
2634 -               b       ret_from_exception
2635 -
2636 -Ldata_not_user:
2637 -               SVC_SAVE_ALL
2638 -               and     r2, lr, #3
2639 -               teq     r2, #3
2640 -               bne     Ldata_illegal_mode
2641 -               tst     lr, #0x08000000
2642 -               teqeqp  pc, #0x00000003         @ NOT a problem - doesn't change mode
2643 -               mask_pc r0, lr
2644 -               bl      Ldata_do
2645 -               SVC_RESTORE_ALL
2646 -
2647 -Ldata_illegal_mode:
2648 -               mov     r0, sp
2649 -               mov     r1, #BAD_DATA
2650 -               b       bad_mode
2651 -
2652 -Ldata_do:      mov     r3, sp
2653 -               ldr     r4, [r0]                @ Get instruction
2654 -               mov     r2, #0
2655 -               tst     r4, #1 << 20            @ Check to see if it is a write instruction
2656 -               orreq   r2, r2, #FAULT_CODE_WRITE @ Indicate write instruction
2657 -               mov     r1, r4, lsr #22         @ Now branch to the relevant processing routine
2658 -               and     r1, r1, #15 << 2
2659 -               add     pc, pc, r1
2660 -               movs    pc, lr
2661 -               b       Ldata_unknown
2662 -               b       Ldata_unknown
2663 -               b       Ldata_unknown
2664 -               b       Ldata_unknown
2665 -               b       Ldata_ldrstr_post       @ ldr   rd, [rn], #m
2666 -               b       Ldata_ldrstr_numindex   @ ldr   rd, [rn, #m]    @ RegVal
2667 -               b       Ldata_ldrstr_post       @ ldr   rd, [rn], rm
2668 -               b       Ldata_ldrstr_regindex   @ ldr   rd, [rn, rm]
2669 -               b       Ldata_ldmstm            @ ldm*a rn, <rlist>
2670 -               b       Ldata_ldmstm            @ ldm*b rn, <rlist>
2671 -               b       Ldata_unknown
2672 -               b       Ldata_unknown
2673 -               b       Ldata_ldrstr_post       @ ldc   rd, [rn], #m    @ Same as ldr   rd, [rn], #m
2674 -               b       Ldata_ldcstc_pre        @ ldc   rd, [rn, #m]
2675 -               b       Ldata_unknown
2676 -Ldata_unknown: @ Part of jumptable
2677 -               mov     r0, r1
2678 -               mov     r1, r4
2679 -               mov     r2, r3
2680 -               b       baddataabort
2681 -
2682 -Ldata_ldrstr_post:
2683 -               mov     r0, r4, lsr #14         @ Get Rn
2684 -               and     r0, r0, #15 << 2        @ Mask out reg.
2685 -               teq     r0, #15 << 2
2686 -               ldr     r0, [r3, r0]            @ Get register
2687 -               biceq   r0, r0, #PCMASK
2688 -               mov     r1, r0
2689 -#ifdef FAULT_CODE_LDRSTRPOST
2690 -               orr     r2, r2, #FAULT_CODE_LDRSTRPOST
2691 -#endif
2692 -               b       do_DataAbort
2693 -
2694 -Ldata_ldrstr_numindex:
2695 -               mov     r0, r4, lsr #14         @ Get Rn
2696 -               and     r0, r0, #15 << 2        @ Mask out reg.
2697 -               teq     r0, #15 << 2
2698 -               ldr     r0, [r3, r0]            @ Get register
2699 -               mov     r1, r4, lsl #20
2700 -               biceq   r0, r0, #PCMASK
2701 -               tst     r4, #1 << 23
2702 -               addne   r0, r0, r1, lsr #20
2703 -               subeq   r0, r0, r1, lsr #20
2704 -               mov     r1, r0
2705 -#ifdef FAULT_CODE_LDRSTRPRE
2706 -               orr     r2, r2, #FAULT_CODE_LDRSTRPRE
2707 -#endif
2708 -               b       do_DataAbort
2709 -
2710 -Ldata_ldrstr_regindex:
2711 -               mov     r0, r4, lsr #14         @ Get Rn
2712 -               and     r0, r0, #15 << 2        @ Mask out reg.
2713 -               teq     r0, #15 << 2
2714 -               ldr     r0, [r3, r0]            @ Get register
2715 -               and     r7, r4, #15
2716 -               biceq   r0, r0, #PCMASK
2717 -               teq     r7, #15                 @ Check for PC
2718 -               ldr     r7, [r3, r7, lsl #2]    @ Get Rm
2719 -               and     r8, r4, #0x60           @ Get shift types
2720 -               biceq   r7, r7, #PCMASK
2721 -               mov     r9, r4, lsr #7          @ Get shift amount
2722 -               and     r9, r9, #31
2723 -               teq     r8, #0
2724 -               moveq   r7, r7, lsl r9
2725 -               teq     r8, #0x20               @ LSR shift
2726 -               moveq   r7, r7, lsr r9
2727 -               teq     r8, #0x40               @ ASR shift
2728 -               moveq   r7, r7, asr r9
2729 -               teq     r8, #0x60               @ ROR shift
2730 -               moveq   r7, r7, ror r9
2731 -               tst     r4, #1 << 23
2732 -               addne   r0, r0, r7
2733 -               subeq   r0, r0, r7              @ Apply correction
2734 -               mov     r1, r0
2735 -#ifdef FAULT_CODE_LDRSTRREG
2736 -               orr     r2, r2, #FAULT_CODE_LDRSTRREG
2737 -#endif
2738 -               b       do_DataAbort
2739 -
2740 -Ldata_ldmstm:
2741 -               mov     r7, #0x11
2742 -               orr     r7, r7, r7, lsl #8
2743 -               and     r0, r4, r7
2744 -               and     r1, r4, r7, lsl #1
2745 -               add     r0, r0, r1, lsr #1
2746 -               and     r1, r4, r7, lsl #2
2747 -               add     r0, r0, r1, lsr #2
2748 -               and     r1, r4, r7, lsl #3
2749 -               add     r0, r0, r1, lsr #3
2750 -               add     r0, r0, r0, lsr #8
2751 -               add     r0, r0, r0, lsr #4
2752 -               and     r7, r0, #15             @ r7 = no. of registers to transfer.
2753 -               mov     r5, r4, lsr #14         @ Get Rn
2754 -               and     r5, r5, #15 << 2
2755 -               ldr     r0, [r3, r5]            @ Get reg
2756 -               eor     r6, r4, r4, lsl #2
2757 -               tst     r6, #1 << 23            @ Check inc/dec ^ writeback
2758 -               rsbeq   r7, r7, #0
2759 -               add     r7, r0, r7, lsl #2      @ Do correction (signed)
2760 -               subne   r1, r7, #1
2761 -               subeq   r1, r0, #1
2762 -               moveq   r0, r7
2763 -               tst     r4, #1 << 21            @ Check writeback
2764 -               strne   r7, [r3, r5]
2765 -               eor     r6, r4, r4, lsl #1
2766 -               tst     r6, #1 << 24            @ Check Pre/Post ^ inc/dec
2767 -               addeq   r0, r0, #4
2768 -               addeq   r1, r1, #4
2769 -               teq     r5, #15*4               @ CHECK FOR PC
2770 -               biceq   r1, r1, #PCMASK
2771 -               biceq   r0, r0, #PCMASK
2772 -#ifdef FAULT_CODE_LDMSTM
2773 -               orr     r2, r2, #FAULT_CODE_LDMSTM
2774 -#endif
2775 -               b       do_DataAbort
2776 -
2777 -Ldata_ldcstc_pre:
2778 -               mov     r0, r4, lsr #14         @ Get Rn
2779 -               and     r0, r0, #15 << 2        @ Mask out reg.
2780 -               teq     r0, #15 << 2
2781 -               ldr     r0, [r3, r0]            @ Get register
2782 -               mov     r1, r4, lsl #24         @ Get offset
2783 -               biceq   r0, r0, #PCMASK
2784 -               tst     r4, #1 << 23
2785 -               addne   r0, r0, r1, lsr #24
2786 -               subeq   r0, r0, r1, lsr #24
2787 -               mov     r1, r0
2788 -#ifdef FAULT_CODE_LDCSTC
2789 -               orr     r2, r2, #FAULT_CODE_LDCSTC
2790 -#endif
2791 -               b       do_DataAbort
2792 -
2793 -
2794 -/*
2795 - * This is the return code to user mode for abort handlers
2796 - */
2797 -ENTRY(ret_from_exception)
2798 -               get_current_task tsk
2799 -               mov     why, #0
2800 -               b       ret_to_user
2801 -
2802 -               .data
2803 -ENTRY(fp_enter)
2804 -               .word   fpe_not_present
2805 -               .text
2806 -/*
2807 - * Register switch for older 26-bit only ARMs
2808 - */
2809 -ENTRY(__switch_to)
2810 -               stmfd   sp!, {r4 - sl, fp, lr}          @ Store most regs on stack
2811 -               str     sp, [r0, #TSS_SAVE]             @ Save sp_SVC
2812 -               ldr     sp, [r1, #TSS_SAVE]             @ Get saved sp_SVC
2813 -               ldmfd   sp!, {r4 - sl, fp, pc}^         @ Load all regs saved previously
2814 -
2815 -/*
2816 - *=============================================================================
2817 - *             Low-level interface code
2818 - *-----------------------------------------------------------------------------
2819 - *             Trap initialisation
2820 - *-----------------------------------------------------------------------------
2821 - *
2822 - * Note - FIQ code has changed.  The default is a couple of words in 0x1c, 0x20
2823 - * that call _unexp_fiq.  Nowever, we now copy the FIQ routine to 0x1c (removes
2824 - * some excess cycles).
2825 - *
2826 - * What we need to put into 0-0x1c are branches to branch to the kernel.
2827 - */
2828 -
2829 -               __INIT
2830 -
2831 -.Ljump_addresses:
2832 -               swi     SYS_ERROR0
2833 -               .word   vector_undefinstr       - 12
2834 -               .word   vector_swi              - 16
2835 -               .word   vector_prefetch         - 20
2836 -               .word   vector_data             - 24
2837 -               .word   vector_addrexcptn       - 28
2838 -               .word   vector_IRQ              - 32
2839 -               .word   _unexp_fiq              - 36
2840 -               b       . + 8
2841 -/*
2842 - * initialise the trap system
2843 - */
2844 -ENTRY(__trap_init)
2845 -               stmfd   sp!, {r4 - r7, lr}
2846 -               adr     r1, .Ljump_addresses
2847 -               ldmia   r1, {r1 - r7, ip, lr}
2848 -               orr     r2, lr, r2, lsr #2
2849 -               orr     r3, lr, r3, lsr #2
2850 -               orr     r4, lr, r4, lsr #2
2851 -               orr     r5, lr, r5, lsr #2
2852 -               orr     r6, lr, r6, lsr #2
2853 -               orr     r7, lr, r7, lsr #2
2854 -               orr     ip, lr, ip, lsr #2
2855 -               mov     r0, #0
2856 -               stmia   r0, {r1 - r7, ip}
2857 -               ldmfd   sp!, {r4 - r7, pc}^
2858 -
2859 -               .bss
2860 -__temp_irq:    .space  4                               @ saved lr_irq
2861 -__temp_fiq:    .space  128
2862 diff -Nru a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2863 --- a/arch/arm/kernel/entry-armv.S      Tue Apr 22 05:39:46 2003
2864 +++ b/arch/arm/kernel/entry-armv.S      Wed Sep  3 10:17:53 2003
2865 @@ -15,10 +15,12 @@
2866   */
2867  #include <linux/config.h>
2868  #include <linux/init.h>
2869 -#include "entry-header.S"
2870 +
2871  #include <asm/thread_info.h>
2872  #include <asm/glue.h>
2873 +#include <asm/ptrace.h>
2874  
2875 +#include "entry-header.S"
2876  
2877  #ifdef IOC_BASE
2878  /* IOC / IOMD based hardware */
2879 diff -Nru a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2880 --- a/arch/arm/kernel/entry-common.S    Wed Mar 26 05:13:45 2003
2881 +++ b/arch/arm/kernel/entry-common.S    Wed Sep  3 10:17:54 2003
2882 @@ -8,8 +8,11 @@
2883   * published by the Free Software Foundation.
2884   */
2885  #include <linux/config.h>
2886 -#include "entry-header.S"
2887 +
2888  #include <asm/thread_info.h>
2889 +#include <asm/ptrace.h>
2890 +
2891 +#include "entry-header.S"
2892  
2893  /* 
2894   * We rely on the fact that R0 is at the bottom of the stack (due to
2895 diff -Nru a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2896 --- a/arch/arm/kernel/entry-header.S    Tue Mar  4 16:47:50 2003
2897 +++ b/arch/arm/kernel/entry-header.S    Sun Aug 24 06:17:52 2003
2898 @@ -63,13 +63,7 @@
2899  #define S_OFF          8
2900  
2901         .macro  set_cpsr_c, reg, mode
2902 -#if 1
2903 -       /* broken binutils */
2904 -       mov     \reg, \mode
2905 -       msr     cpsr_c, \reg
2906 -#else
2907         msr     cpsr_c, \mode
2908 -#endif
2909         .endm
2910  
2911         .macro  disable_irq, temp
2912 diff -Nru a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2913 --- a/arch/arm/kernel/head.S    Tue Apr  8 01:29:38 2003
2914 +++ b/arch/arm/kernel/head.S    Wed Sep  3 10:17:54 2003
2915 @@ -16,6 +16,7 @@
2916  #include <asm/assembler.h>
2917  #include <asm/mach-types.h>
2918  #include <asm/procinfo.h>
2919 +#include <asm/ptrace.h>
2920  #include <asm/mach/arch.h>
2921  
2922  /*
2923 diff -Nru a/arch/arm/kernel/pm.c b/arch/arm/kernel/pm.c
2924 --- a/arch/arm/kernel/pm.c      Sat Jun 21 03:42:03 2003
2925 +++ b/arch/arm/kernel/pm.c      Sun Aug 24 05:40:01 2003
2926 @@ -36,23 +36,7 @@
2927         if (ret != 0)
2928                 goto out;
2929  
2930 -       /*
2931 -        * Tell LDM devices we're going to suspend.
2932 -        */
2933 -       ret = device_suspend(4, SUSPEND_NOTIFY);
2934 -       if (ret != 0)
2935 -               goto resume_legacy;
2936 -
2937 -       /*
2938 -        * Disable, devices, and save state.
2939 -        */
2940 -       device_suspend(4, SUSPEND_DISABLE);
2941 -       device_suspend(4, SUSPEND_SAVE_STATE);
2942 -
2943 -       /*
2944 -        * Tell devices that they're going to be powered off.
2945 -        */
2946 -       device_suspend(4, SUSPEND_POWER_DOWN);
2947 +       device_suspend(3);
2948  
2949         local_irq_disable();
2950         leds_event(led_stop);
2951 @@ -62,21 +46,8 @@
2952         leds_event(led_start);
2953         local_irq_enable();
2954  
2955 -       /*
2956 -        * Tell devices that they now have power.
2957 -        */
2958 -       device_resume(RESUME_POWER_ON);
2959 -
2960 -       /*
2961 -        * Resume LDM devices.
2962 -        */
2963 -       device_resume(RESUME_RESTORE_STATE);
2964 -       device_resume(RESUME_ENABLE);
2965 +       device_resume();
2966  
2967 - resume_legacy:
2968 -       /*
2969 -        * Resume "legacy" devices.
2970 -        */
2971         pm_send_all(PM_RESUME, (void *)0);
2972  
2973   out:
2974 diff -Nru a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
2975 --- a/arch/arm/kernel/vmlinux.lds.S     Mon Aug  4 20:39:42 2003
2976 +++ b/arch/arm/kernel/vmlinux.lds.S     Sun Aug 24 04:26:29 2003
2977 @@ -1,21 +1,134 @@
2978 -#include <linux/config.h>
2979 -
2980 -#ifdef CONFIG_CPU_26
2981 -
2982 -#ifdef CONFIG_ROM_KERNEL
2983 -
2984 -#include "vmlinux-armo-rom.lds.in"
2985 -
2986 +/* ld script to make ARM Linux kernel
2987 + * taken from the i386 version by Russell King
2988 + * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
2989 + */
2990 +
2991 +#include <asm-generic/vmlinux.lds.h>
2992 +       
2993 +OUTPUT_ARCH(arm)
2994 +ENTRY(stext)
2995 +#ifndef __ARMEB__
2996 +jiffies = jiffies_64;
2997  #else
2998 -
2999 -#include "vmlinux-armo.lds.in"
3000 -
3001 -#endif
3002 -
3003 -#endif
3004 -
3005 -#ifdef CONFIG_CPU_32
3006 -
3007 -#include "vmlinux-armv.lds.in"
3008 -
3009 +jiffies = jiffies_64 + 4;
3010  #endif
3011 +SECTIONS
3012 +{
3013 +       . = TEXTADDR;
3014 +       .init : {                       /* Init code and data           */
3015 +               _stext = .;
3016 +               __init_begin = .;
3017 +                       _sinittext = .;
3018 +                       *(.init.text)
3019 +                       _einittext = .;
3020 +               __proc_info_begin = .;
3021 +                       *(.proc.info)
3022 +               __proc_info_end = .;
3023 +               __arch_info_begin = .;
3024 +                       *(.arch.info)
3025 +               __arch_info_end = .;
3026 +               __tagtable_begin = .;
3027 +                       *(.taglist)
3028 +               __tagtable_end = .;
3029 +                       *(.init.data)
3030 +               . = ALIGN(16);
3031 +               __setup_start = .;
3032 +                       *(.init.setup)
3033 +               __setup_end = .;
3034 +               __early_begin = .;
3035 +                       *(__early_param)
3036 +               __early_end = .;
3037 +               __start___param = .;
3038 +                       *(__param)
3039 +               __stop___param = .;
3040 +               __initcall_start = .;
3041 +                       *(.initcall1.init)
3042 +                       *(.initcall2.init)
3043 +                       *(.initcall3.init)
3044 +                       *(.initcall4.init)
3045 +                       *(.initcall5.init)
3046 +                       *(.initcall6.init)
3047 +                       *(.initcall7.init)
3048 +               __initcall_end = .;
3049 +               __con_initcall_start = .;
3050 +                       *(.con_initcall.init)
3051 +               __con_initcall_end = .;
3052 +               __security_initcall_start = .;
3053 +                       *(.security_initcall.init)
3054 +               __security_initcall_end = .;
3055 +               . = ALIGN(32);
3056 +               __initramfs_start = .;
3057 +                       usr/built-in.o(.init.ramfs)
3058 +               __initramfs_end = .;
3059 +               . = ALIGN(4096);
3060 +               __init_end = .;
3061 +       }
3062 +
3063 +       /DISCARD/ : {                   /* Exit code and data           */
3064 +               *(.exit.text)
3065 +               *(.exit.data)
3066 +               *(.exitcall.exit)
3067 +       }
3068 +
3069 +       .text : {                       /* Real text segment            */
3070 +               _text = .;              /* Text and read-only data      */
3071 +                       *(.text)
3072 +                       *(.fixup)
3073 +                       *(.gnu.warning)
3074 +                       *(.rodata)
3075 +                       *(.rodata.*)
3076 +                       *(.glue_7)
3077 +                       *(.glue_7t)
3078 +               *(.got)                 /* Global offset table          */
3079 +
3080 +               _etext = .;             /* End of text section          */
3081 +       }
3082 +
3083 +       . = ALIGN(16);
3084 +       __ex_table : {                  /* Exception table              */
3085 +               __start___ex_table = .;
3086 +                       *(__ex_table)
3087 +               __stop___ex_table = .;
3088 +       }
3089 +
3090 +       RODATA
3091 +
3092 +       . = ALIGN(8192);
3093 +
3094 +       .data : {
3095 +               /*
3096 +                * first, the init task union, aligned
3097 +                * to an 8192 byte boundary.
3098 +                */
3099 +               *(.init.task)
3100 +
3101 +               /*
3102 +                * then the cacheline aligned data
3103 +                */
3104 +               . = ALIGN(32);
3105 +               *(.data.cacheline_aligned)
3106 +
3107 +               /*
3108 +                * and the usual data section
3109 +                */
3110 +               *(.data)
3111 +               CONSTRUCTORS
3112 +
3113 +               _edata = .;
3114 +       }
3115 +
3116 +       .bss : {
3117 +               __bss_start = .;        /* BSS                          */
3118 +               *(.bss)
3119 +               *(COMMON)
3120 +               _end = . ;
3121 +       }
3122 +                                       /* Stabs debugging sections.    */
3123 +       .stab 0 : { *(.stab) }
3124 +       .stabstr 0 : { *(.stabstr) }
3125 +       .stab.excl 0 : { *(.stab.excl) }
3126 +       .stab.exclstr 0 : { *(.stab.exclstr) }
3127 +       .stab.index 0 : { *(.stab.index) }
3128 +       .stab.indexstr 0 : { *(.stab.indexstr) }
3129 +       .comment 0 : { *(.comment) }
3130 +}
3131 diff -Nru a/arch/arm/mach-footbridge/netwinder-pci.c b/arch/arm/mach-footbridge/netwinder-pci.c
3132 --- a/arch/arm/mach-footbridge/netwinder-pci.c  Thu Jul 31 16:47:19 2003
3133 +++ b/arch/arm/mach-footbridge/netwinder-pci.c  Sun Aug 24 04:37:15 2003
3134 @@ -36,8 +36,8 @@
3135                 return IRQ_NETWINDER_ETHER10;
3136  
3137         default:
3138 -               printk(KERN_ERR "PCI: unknown device in slot %s: %s\n",
3139 -                       pci_name(dev), dev->dev.name);
3140 +               printk(KERN_ERR "PCI: unknown device in slot %s\n",
3141 +                       pci_name(dev));
3142                 return 0;
3143         }
3144  }
3145 diff -Nru a/arch/arm/mach-iop3xx/iop321-time.c b/arch/arm/mach-iop3xx/iop321-time.c
3146 --- a/arch/arm/mach-iop3xx/iop321-time.c        Tue Apr 15 08:12:47 2003
3147 +++ b/arch/arm/mach-iop3xx/iop321-time.c        Wed Aug 13 16:46:20 2003
3148 @@ -51,7 +51,8 @@
3149         return usec;
3150  }
3151  
3152 -static void iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3153 +static irqreturn_t
3154 +iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3155  {
3156         u32 tisr;
3157  
3158 @@ -62,6 +63,8 @@
3159         asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr));
3160  
3161         do_timer(regs);
3162 +
3163 +       return IRQ_HANDLED;
3164  }
3165  
3166  extern unsigned long (*gettimeoffset)(void);
3167 diff -Nru a/arch/arm/mach-iop3xx/iq80310-time.c b/arch/arm/mach-iop3xx/iq80310-time.c
3168 --- a/arch/arm/mach-iop3xx/iq80310-time.c       Mon Apr 21 15:43:40 2003
3169 +++ b/arch/arm/mach-iop3xx/iq80310-time.c       Wed Aug 13 16:46:20 2003
3170 @@ -88,7 +88,8 @@
3171  }
3172  
3173  
3174 -static void iq80310_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3175 +static irqreturn_t
3176 +iq80310_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3177  {
3178         volatile u_char *timer_en = (volatile u_char *)IQ80310_TIMER_EN;
3179  
3180 @@ -96,21 +97,9 @@
3181         *timer_en &= ~2;
3182         *timer_en |= 2;
3183  
3184 -       /*
3185 -        * AHEM..HACK
3186 -        *
3187 -        * Since the timer interrupt is cascaded through the CPLD and
3188 -        * the 80312 and the demux code calls do_IRQ, the irq count is
3189 -        * going to be at least 2 when we get here and this will cause the
3190 -        * kernel to increment the system tick counter even if we're
3191 -        * idle. This causes it to look like there's always 100% system
3192 -        * time, which is not the case.  To get around it, we just decrement
3193 -        * the IRQ count before calling do_timer. We increment it again
3194 -        * b/c otherwise it will go negative and than bad things happen.
3195 -        *
3196 -        * -DS
3197 -        */
3198         do_timer(regs);
3199 +
3200 +       return IRQ_HANDLED;
3201  }
3202  
3203  extern unsigned long (*gettimeoffset)(void);
3204 @@ -126,7 +115,9 @@
3205         volatile u_char *timer_en = (volatile u_char *)IQ80310_TIMER_EN;
3206  
3207         gettimeoffset = iq80310_gettimeoffset;
3208 +
3209         setup_irq(IRQ_IQ80310_TIMER, &timer_irq);
3210 +
3211         *timer_en = 0;
3212         iq80310_write_timer(LATCH);
3213         *timer_en |= 2;
3214 diff -Nru a/arch/arm/mach-l7200/core.c b/arch/arm/mach-l7200/core.c
3215 --- a/arch/arm/mach-l7200/core.c        Tue Jun  4 16:19:02 2002
3216 +++ b/arch/arm/mach-l7200/core.c        Wed Sep  3 10:17:54 2003
3217 @@ -11,7 +11,6 @@
3218  
3219  #include <asm/hardware.h>
3220  #include <asm/page.h>
3221 -#include <asm/proc/domain.h>
3222  
3223  #include <asm/mach/map.h>
3224  #include <asm/arch/hardware.h>
3225 diff -Nru a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
3226 --- a/arch/arm/mach-rpc/riscpc.c        Sun Sep 29 09:11:41 2002
3227 +++ b/arch/arm/mach-rpc/riscpc.c        Wed Sep  3 10:17:54 2003
3228 @@ -21,7 +21,7 @@
3229  #include <asm/mach-types.h>
3230  #include <asm/hardware.h>
3231  #include <asm/page.h>
3232 -#include <asm/proc/domain.h>
3233 +#include <asm/domain.h>
3234  #include <asm/setup.h>
3235  
3236  #include <asm/mach/map.h>
3237 diff -Nru a/arch/arm/mach-sa1100/leds-simpad.c b/arch/arm/mach-sa1100/leds-simpad.c
3238 --- a/arch/arm/mach-sa1100/leds-simpad.c        Mon Feb  4 23:53:46 2002
3239 +++ b/arch/arm/mach-sa1100/leds-simpad.c        Thu Aug  7 11:40:46 2003
3240 @@ -9,6 +9,7 @@
3241  #include <asm/hardware.h>
3242  #include <asm/leds.h>
3243  #include <asm/system.h>
3244 +#include <asm/arch/simpad.h>
3245  
3246  #include "leds.h"
3247  
3248 diff -Nru a/arch/arm/mach-sa1100/leds.c b/arch/arm/mach-sa1100/leds.c
3249 --- a/arch/arm/mach-sa1100/leds.c       Wed Dec 11 06:27:36 2002
3250 +++ b/arch/arm/mach-sa1100/leds.c       Thu Aug  7 11:40:46 2003
3251 @@ -41,6 +41,8 @@
3252                 leds_event = adsbitsy_leds_event;
3253         if (machine_is_pt_system3())
3254                 leds_event = system3_leds_event;
3255 +       if (machine_is_simpad())
3256 +               leds_event = simpad_leds_event; /* what about machine registry? including led, apm... -zecke */
3257  
3258         leds_event(led_start);
3259         return 0;
3260 diff -Nru a/arch/arm/mach-sa1100/leds.h b/arch/arm/mach-sa1100/leds.h
3261 --- a/arch/arm/mach-sa1100/leds.h       Wed Dec 11 06:27:36 2002
3262 +++ b/arch/arm/mach-sa1100/leds.h       Thu Aug  7 11:40:46 2003
3263 @@ -11,3 +11,4 @@
3264  extern void graphicsmaster_leds_event(led_event_t evt);
3265  extern void adsbitsy_leds_event(led_event_t evt);
3266  extern void system3_leds_event(led_event_t evt);
3267 +extern void simpad_leds_event(led_event_t evt);
3268 diff -Nru a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
3269 --- a/arch/arm/mm/Makefile      Sun Apr 27 16:46:31 2003
3270 +++ b/arch/arm/mm/Makefile      Wed Sep  3 01:25:59 2003
3271 @@ -4,20 +4,12 @@
3272  
3273  # Object file lists.
3274  
3275 -obj-y          := init.o extable.o fault-common.o
3276 -obj-m          :=
3277 -obj-n          :=
3278 -obj-           :=
3279 -ifeq ($(CONFIG_CPU_32),y)
3280 -obj-y          += consistent.o fault-armv.o ioremap.o mm-armv.o
3281 +obj-y          := consistent.o extable.o fault-armv.o fault-common.o \
3282 +                  init.o ioremap.o mm-armv.o
3283  obj-$(CONFIG_MODULES) += proc-syms.o
3284 -endif
3285  
3286  obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o
3287  obj-$(CONFIG_DISCONTIGMEM) += discontig.o
3288 -
3289 -# Select the processor-specific files
3290 -p-$(CONFIG_CPU_26)     += proc-arm2_3.o
3291  
3292  # ARMv3
3293  p-$(CONFIG_CPU_ARM610) += proc-arm6_7.o  tlb-v3.o    cache-v3.o    copypage-v3.o
3294 diff -Nru a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
3295 --- a/arch/arm/mm/mm-armv.c     Thu Aug 14 07:58:33 2003
3296 +++ b/arch/arm/mm/mm-armv.c     Wed Sep  3 10:17:54 2003
3297 @@ -34,8 +34,8 @@
3298  };
3299  
3300  static struct cachepolicy cache_policies[] __initdata = {
3301 -       { "uncached",           CR1_W|CR1_C,    PMD_SECT_UNCACHED },
3302 -       { "buffered",           CR1_C,          PMD_SECT_BUFFERED },
3303 +       { "uncached",           CR_W|CR_C,      PMD_SECT_UNCACHED },
3304 +       { "buffered",           CR_C,           PMD_SECT_BUFFERED },
3305         { "writethrough",       0,              PMD_SECT_WT       },
3306  #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
3307         { "writeback",          0,              PMD_SECT_WB       },
3308 @@ -102,8 +102,8 @@
3309  
3310  static int __init noalign_setup(char *__unused)
3311  {
3312 -       cr_alignment &= ~CR1_A;
3313 -       cr_no_alignment &= ~CR1_A;
3314 +       cr_alignment &= ~CR_A;
3315 +       cr_no_alignment &= ~CR_A;
3316         set_cr(cr_alignment);
3317         return 1;
3318  }
3319 diff -Nru a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
3320 --- a/arch/arm/mm/proc-arm1020.S        Sun Apr 27 17:16:24 2003
3321 +++ b/arch/arm/mm/proc-arm1020.S        Wed Sep  3 10:17:54 2003
3322 @@ -30,6 +30,7 @@
3323  #include <asm/assembler.h>
3324  #include <asm/constants.h>
3325  #include <asm/procinfo.h>
3326 +#include <asm/ptrace.h>
3327  #include <asm/hardware.h>
3328  
3329  /*
3330 diff -Nru a/arch/arm/mm/proc-arm2_3.S b/arch/arm/mm/proc-arm2_3.S
3331 --- a/arch/arm/mm/proc-arm2_3.S Mon Apr 28 14:55:34 2003
3332 +++ /dev/null   Wed Dec 31 16:00:00 1969
3333 @@ -1,360 +0,0 @@
3334 -/*
3335 - *  linux/arch/arm/mm/proc-arm2,3.S
3336 - *
3337 - *  Copyright (C) 1997-1999 Russell King
3338 - *
3339 - * This program is free software; you can redistribute it and/or modify
3340 - * it under the terms of the GNU General Public License version 2 as
3341 - * published by the Free Software Foundation.
3342 - *
3343 - *  MMU functions for ARM2,3
3344 - *
3345 - *  These are the low level assembler for performing cache
3346 - *  and memory functions on ARM2, ARM250 and ARM3 processors.
3347 - */
3348 -#include <linux/linkage.h>
3349 -#include <linux/init.h>
3350 -#include <asm/assembler.h>
3351 -#include <asm/constants.h>
3352 -#include <asm/procinfo.h>
3353 -
3354 -/*
3355 - * MEMC workhorse code.  It's both a horse which things it's a pig.
3356 - */
3357 -/*
3358 - * Function: cpu_memc_update_entry(pgd_t *pgd, unsigned long phys_pte, unsigned long addr)
3359 - * Params  : pgd       Page tables/MEMC mapping
3360 - *         : phys_pte  physical address, or PTE
3361 - *         : addr      virtual address
3362 - */
3363 -ENTRY(cpu_memc_update_entry)
3364 -               tst     r1, #PAGE_PRESENT               @ is the page present
3365 -               orreq   r1, r1, #PAGE_OLD | PAGE_CLEAN
3366 -               moveq   r2, #0x01f00000
3367 -               mov     r3, r1, lsr #13                 @ convert to physical page nr
3368 -               and     r3, r3, #0x3fc
3369 -               adr     ip, memc_phys_table_32
3370 -               ldr     r3, [ip, r3]
3371 -               tst     r1, #PAGE_OLD | PAGE_NOT_USER
3372 -               biceq   r3, r3, #0x200
3373 -               tsteq   r1, #PAGE_READONLY | PAGE_CLEAN
3374 -               biceq   r3, r3, #0x300
3375 -               mov     r2, r2, lsr #15                 @ virtual -> nr
3376 -               orr     r3, r3, r2, lsl #15
3377 -               and     r2, r2, #0x300
3378 -               orr     r3, r3, r2, lsl #2
3379 -               and     r2, r3, #255
3380 -               sub     r0, r0, #256 * 4
3381 -               str     r3, [r0, r2, lsl #2]
3382 -               strb    r3, [r3]
3383 -               movs    pc, lr
3384 -/*
3385 - * Params  : r0 = preserved
3386 - *         : r1 = memc table base (preserved)
3387 - *         : r2 = page table entry
3388 - *         : r3 = preserved
3389 - *         : r4 = unused
3390 - *         : r5 = memc physical address translation table
3391 - *         : ip = virtual address (preserved)
3392 - */
3393 -update_pte:
3394 -               mov     r4, r2, lsr #13
3395 -               and     r4, r4, #0x3fc
3396 -               ldr     r4, [r5, r4]                    @ covert to MEMC page
3397 -
3398 -               tst     r2, #PAGE_OLD | PAGE_NOT_USER   @ check for MEMC read
3399 -               biceq   r4, r4, #0x200
3400 -               tsteq   r2, #PAGE_READONLY | PAGE_CLEAN @ check for MEMC write
3401 -               biceq   r4, r4, #0x300
3402 -
3403 -               orr     r4, r4, ip
3404 -               and     r2, ip, #0x01800000
3405 -               orr     r4, r4, r2, lsr #13
3406 -
3407 -               and     r2, r4, #255
3408 -               str     r4, [r1, r2, lsl #2]
3409 -               movs    pc, lr
3410 -
3411 -/*
3412 - * Params  : r0 = preserved
3413 - *         : r1 = memc table base (preserved)
3414 - *         : r2 = page table base
3415 - *         : r3 = preserved
3416 - *         : r4 = unused
3417 - *         : r5 = memc physical address translation table
3418 - *         : ip = virtual address (updated)
3419 - */
3420 -update_pte_table:
3421 -               stmfd   sp!, {r0, lr}
3422 -               bic     r0, r2, #3
3423 -1:             ldr     r2, [r0], #4                    @ get entry
3424 -               tst     r2, #PAGE_PRESENT               @ page present
3425 -               blne    update_pte                      @ process pte
3426 -               add     ip, ip, #32768                  @ increment virt addr
3427 -               ldr     r2, [r0], #4                    @ get entry
3428 -               tst     r2, #PAGE_PRESENT               @ page present
3429 -               blne    update_pte                      @ process pte
3430 -               add     ip, ip, #32768                  @ increment virt addr
3431 -               ldr     r2, [r0], #4                    @ get entry
3432 -               tst     r2, #PAGE_PRESENT               @ page present
3433 -               blne    update_pte                      @ process pte
3434 -               add     ip, ip, #32768                  @ increment virt addr
3435 -               ldr     r2, [r0], #4                    @ get entry
3436 -               tst     r2, #PAGE_PRESENT               @ page present
3437 -               blne    update_pte                      @ process pte
3438 -               add     ip, ip, #32768                  @ increment virt addr
3439 -               tst     ip, #32768 * 31                 @ finished?
3440 -               bne     1b
3441 -               ldmfd   sp!, {r0, pc}^
3442 -
3443 -/*
3444 - * Function: cpu_memc_update_all(pgd_t *pgd)
3445 - * Params  : pgd       Page tables/MEMC mapping
3446 - * Notes   : this is optimised for 32k pages
3447 - */
3448 -ENTRY(cpu_memc_update_all)
3449 -               stmfd   sp!, {r4, r5, lr}
3450 -               bl      clear_tables
3451 -               sub     r1, r0, #256 * 4                @ start of MEMC tables
3452 -               adr     r5, memc_phys_table_32          @ Convert to logical page number
3453 -               mov     ip, #0                          @ virtual address
3454 -1:             ldmia   r0!, {r2, r3}
3455 -               tst     r2, #PAGE_PRESENT
3456 -               addeq   ip, ip, #1048576
3457 -               blne    update_pte_table
3458 -               mov     r2, r3
3459 -               tst     r2, #PAGE_PRESENT
3460 -               addeq   ip, ip, #1048576
3461 -               blne    update_pte_table
3462 -               teq     ip, #32 * 1048576
3463 -               bne     1b
3464 -               ldmfd   sp!, {r4, r5, pc}^
3465 -
3466 -/*
3467 - * Build the table to map from physical page number to memc page number
3468 - */
3469 -               .type   memc_phys_table_32, #object
3470 -memc_phys_table_32:
3471 -               .irp    b7, 0x00, 0x80
3472 -               .irp    b6, 0x00, 0x02
3473 -               .irp    b5, 0x00, 0x04
3474 -               .irp    b4, 0x00, 0x01
3475 -
3476 -               .irp    b3, 0x00, 0x40
3477 -               .irp    b2, 0x00, 0x20
3478 -               .irp    b1, 0x00, 0x10
3479 -               .irp    b0, 0x00, 0x08
3480 -               .long   0x03800300 + \b7 + \b6 + \b5 + \b4 + \b3 + \b2 + \b1 + \b0
3481 -               .endr
3482 -               .endr
3483 -               .endr
3484 -               .endr
3485 -
3486 -               .endr
3487 -               .endr
3488 -               .endr
3489 -               .endr
3490 -               .size   memc_phys_table_32, . - memc_phys_table_32
3491 -
3492 -/*
3493 - * helper for cpu_memc_update_all, this clears out all
3494 - * mappings, setting them close to the top of memory,
3495 - * and inaccessible (0x01f00000).
3496 - * Params  : r0 = page table pointer
3497 - */
3498 -clear_tables:  ldr     r1, _arm3_switch_mm - 4
3499 -               ldr     r2, [r1]
3500 -               sub     r1, r0, #256 * 4                @ start of MEMC tables
3501 -               add     r2, r1, r2, lsl #2              @ end of tables
3502 -               mov     r3, #0x03f00000                 @ Default mapping (null mapping)
3503 -               orr     r3, r3, #0x00000f00
3504 -               orr     r4, r3, #1
3505 -               orr     r5, r3, #2
3506 -               orr     ip, r3, #3
3507 -1:             stmia   r1!, {r3, r4, r5, ip}
3508 -               add     r3, r3, #4
3509 -               add     r4, r4, #4
3510 -               add     r5, r5, #4
3511 -               add     ip, ip, #4
3512 -               stmia   r1!, {r3, r4, r5, ip}
3513 -               add     r3, r3, #4
3514 -               add     r4, r4, #4
3515 -               add     r5, r5, #4
3516 -               add     ip, ip, #4
3517 -               teq     r1, r2
3518 -               bne     1b
3519 -               mov     pc, lr
3520 -
3521 -/*
3522 - * Function: *_switch_mm(pgd_t *pgd)
3523 - * Params  : pgd       New page tables/MEMC mapping
3524 - * Purpose : update MEMC hardware with new mapping
3525 - */
3526 -               .word   page_nr
3527 -_arm3_switch_mm:
3528 -               mcr     p15, 0, r1, c1, c0, 0           @ flush cache
3529 -_arm2_switch_mm:
3530 -               stmfd   sp!, {lr}
3531 -               ldr     r1, _arm3_switch_mm - 4
3532 -               ldr     r2, [r1]
3533 -               sub     r0, r0, #256 * 4                @ start of MEMC tables
3534 -               add     r1, r0, r2, lsl #2              @ end of tables
3535 -1:             ldmia   r0!, {r2, r3, ip, lr}
3536 -               strb    r2, [r2]
3537 -               strb    r3, [r3]
3538 -               strb    ip, [ip]
3539 -               strb    lr, [lr]
3540 -               ldmia   r0!, {r2, r3, ip, lr}
3541 -               strb    r2, [r2]
3542 -               strb    r3, [r3]
3543 -               strb    ip, [ip]
3544 -               strb    lr, [lr]
3545 -               teq     r0, r1
3546 -               bne     1b
3547 -               ldmfd   sp!, {pc}^
3548 -
3549 -/*
3550 - * Function: *_proc_init (void)
3551 - * Purpose : Initialise the cache control registers
3552 - */
3553 -_arm3_proc_init:
3554 -               mov     r0, #0x001f0000
3555 -               orr     r0, r0, #0x0000ff00
3556 -               orr     r0, r0, #0x000000ff
3557 -               mcr     p15, 0, r0, c3, c0              @ ARM3 Cacheable
3558 -               mcr     p15, 0, r0, c4, c0              @ ARM3 Updateable
3559 -               mov     r0, #0
3560 -               mcr     p15, 0, r0, c5, c0              @ ARM3 Disruptive
3561 -               mcr     p15, 0, r0, c1, c0              @ ARM3 Flush
3562 -               mov     r0, #3
3563 -               mcr     p15, 0, r0, c2, c0              @ ARM3 Control
3564 -_arm2_proc_init:
3565 -               movs    pc, lr
3566 -
3567 -/*
3568 - * Function: *_proc_fin (void)
3569 - * Purpose : Finalise processor (disable caches)
3570 - */
3571 -_arm3_proc_fin:        mov     r0, #2
3572 -               mcr     p15, 0, r0, c2, c0
3573 -_arm2_proc_fin:        orrs    pc, lr, #PSR_I_BIT|PSR_F_BIT
3574 -
3575 -/*
3576 - * Function: *_xchg_1 (int new, volatile void *ptr)
3577 - * Params  : new       New value to store at...
3578 - *        : ptr        pointer to byte-wide location
3579 - * Purpose : Performs an exchange operation
3580 - * Returns : Original byte data at 'ptr'
3581 - */
3582 -_arm2_xchg_1:  mov     r2, pc
3583 -               orr     r2, r2, #PSR_I_BIT
3584 -               teqp    r2, #0
3585 -               ldrb    r2, [r1]
3586 -               strb    r0, [r1]
3587 -               mov     r0, r2
3588 -               movs    pc, lr
3589 -
3590 -_arm3_xchg_1:  swpb    r0, r0, [r1]
3591 -               movs    pc, lr
3592 -
3593 -/*
3594 - * Function: *_xchg_4 (int new, volatile void *ptr)
3595 - * Params  : new       New value to store at...
3596 - *        : ptr        pointer to word-wide location
3597 - * Purpose : Performs an exchange operation
3598 - * Returns : Original word data at 'ptr'
3599 - */
3600 -_arm2_xchg_4:  mov     r2, pc
3601 -               orr     r2, r2, #PSR_I_BIT
3602 -               teqp    r2, #0
3603 -               ldr     r2, [r1]
3604 -               str     r0, [r1]
3605 -               mov     r0, r2
3606 -               movs    pc, lr
3607 -
3608 -_arm3_xchg_4:  swp     r0, r0, [r1]
3609 -               movs    pc, lr
3610 -
3611 -cpu_arm2_name:
3612 -               .asciz  "ARM 2"
3613 -cpu_arm250_name:
3614 -               .asciz  "ARM 250"
3615 -cpu_arm3_name:
3616 -               .asciz  "ARM 3"
3617 -
3618 -               __INIT
3619 -/*
3620 - * Purpose : Function pointers used to access above functions - all calls
3621 - *          come through these
3622 - */
3623 -               .globl  arm2_processor_functions
3624 -arm2_processor_functions:
3625 -               .word   _arm2_proc_init
3626 -               .word   _arm2_proc_fin
3627 -               .word   _arm2_switch_mm
3628 -               .word   _arm2_xchg_1
3629 -               .word   _arm2_xchg_4
3630 -
3631 -               .globl  arm250_processor_functions
3632 -arm250_processor_functions:
3633 -               .word   _arm2_proc_init
3634 -               .word   _arm2_proc_fin
3635 -               .word   _arm2_switch_mm
3636 -               .word   _arm3_xchg_1
3637 -               .word   _arm3_xchg_4
3638 -
3639 -               .globl  arm3_processor_functions
3640 -arm3_processor_functions:
3641 -               .word   _arm3_proc_init
3642 -               .word   _arm3_proc_fin
3643 -               .word   _arm3_switch_mm
3644 -               .word   _arm3_xchg_1
3645 -               .word   _arm3_xchg_4
3646 -
3647 -arm2_arch_name:        .asciz  "armv1"
3648 -arm3_arch_name:        .asciz  "armv2"
3649 -arm2_elf_name: .asciz  "v1"
3650 -arm3_elf_name: .asciz  "v2"
3651 -               .align
3652 -
3653 -               .section ".proc.info", #alloc, #execinstr
3654 -
3655 -               .long   0x41560200
3656 -               .long   0xfffffff0
3657 -               .long   0
3658 -               mov     pc, lr
3659 -               .long   arm2_arch_name
3660 -               .long   arm2_elf_name
3661 -               .long   0
3662 -               .long   cpu_arm2_name
3663 -               .long   arm2_processor_functions
3664 -               .long   0
3665 -               .long   0
3666 -               .long   0
3667 -
3668 -               .long   0x41560250
3669 -               .long   0xfffffff0
3670 -               .long   0
3671 -               mov     pc, lr
3672 -               .long   arm3_arch_name
3673 -               .long   arm3_elf_name
3674 -               .long   0
3675 -               .long   cpu_arm250_name
3676 -               .long   arm250_processor_functions
3677 -               .long   0
3678 -               .long   0
3679 -               .long   0
3680 -
3681 -               .long   0x41560300
3682 -               .long   0xfffffff0
3683 -               .long   0
3684 -               mov     pc, lr
3685 -               .long   arm3_arch_name
3686 -               .long   arm3_elf_name
3687 -               .long   0
3688 -               .long   cpu_arm3_name
3689 -               .long   arm3_processor_functions
3690 -               .long   0
3691 -               .long   0
3692 -               .long   0
3693 -
3694 diff -Nru a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S
3695 --- a/arch/arm/mm/proc-arm6_7.S Mon Apr 28 14:55:34 2003
3696 +++ b/arch/arm/mm/proc-arm6_7.S Wed Sep  3 10:17:55 2003
3697 @@ -15,6 +15,7 @@
3698  #include <asm/assembler.h>
3699  #include <asm/constants.h>
3700  #include <asm/procinfo.h>
3701 +#include <asm/ptrace.h>
3702  
3703  ENTRY(cpu_arm6_dcache_clean_area)
3704  ENTRY(cpu_arm7_dcache_clean_area)
3705 diff -Nru a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
3706 --- a/arch/arm/mm/proc-arm720.S Sun Apr 27 17:16:25 2003
3707 +++ b/arch/arm/mm/proc-arm720.S Wed Sep  3 10:17:55 2003
3708 @@ -35,6 +35,7 @@
3709  #include <asm/assembler.h>
3710  #include <asm/constants.h>
3711  #include <asm/procinfo.h>
3712 +#include <asm/ptrace.h>
3713  #include <asm/hardware.h>
3714  
3715  /*
3716 diff -Nru a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
3717 --- a/arch/arm/mm/proc-arm920.S Sun Apr 27 17:16:25 2003
3718 +++ b/arch/arm/mm/proc-arm920.S Wed Sep  3 10:17:55 2003
3719 @@ -31,6 +31,7 @@
3720  #include <asm/procinfo.h>
3721  #include <asm/hardware.h>
3722  #include <asm/page.h>
3723 +#include <asm/ptrace.h>
3724  #include "proc-macros.S"
3725  
3726  /*
3727 diff -Nru a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
3728 --- a/arch/arm/mm/proc-arm922.S Sun Apr 27 17:16:25 2003
3729 +++ b/arch/arm/mm/proc-arm922.S Wed Sep  3 10:17:55 2003
3730 @@ -32,6 +32,7 @@
3731  #include <asm/procinfo.h>
3732  #include <asm/hardware.h>
3733  #include <asm/page.h>
3734 +#include <asm/ptrace.h>
3735  #include "proc-macros.S"
3736  
3737  /*
3738 diff -Nru a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
3739 --- a/arch/arm/mm/proc-arm926.S Sun Apr 27 17:16:25 2003
3740 +++ b/arch/arm/mm/proc-arm926.S Wed Sep  3 10:17:55 2003
3741 @@ -31,6 +31,7 @@
3742  #include <asm/procinfo.h>
3743  #include <asm/hardware.h>
3744  #include <asm/page.h>
3745 +#include <asm/ptrace.h>
3746  #include "proc-macros.S"
3747  
3748  /*
3749 diff -Nru a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
3750 --- a/arch/arm/mm/proc-sa110.S  Sun Apr 27 17:16:25 2003
3751 +++ b/arch/arm/mm/proc-sa110.S  Wed Sep  3 10:17:55 2003
3752 @@ -18,7 +18,8 @@
3753  #include <asm/constants.h>
3754  #include <asm/procinfo.h>
3755  #include <asm/hardware.h>
3756 -#include <asm/proc/pgtable.h>
3757 +#include <asm/pgtable.h>
3758 +#include <asm/ptrace.h>
3759  
3760  /*
3761   * the cache line size of the I and D cache
3762 diff -Nru a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
3763 --- a/arch/arm/mm/proc-sa1100.S Sun Apr 27 17:16:25 2003
3764 +++ b/arch/arm/mm/proc-sa1100.S Wed Sep  3 10:17:56 2003
3765 @@ -23,7 +23,8 @@
3766  #include <asm/constants.h>
3767  #include <asm/procinfo.h>
3768  #include <asm/hardware.h>
3769 -#include <asm/proc/pgtable.h>
3770 +#include <asm/pgtable.h>
3771 +#include <asm/ptrace.h>
3772  
3773  /*
3774   * the cache line size of the I and D cache
3775 diff -Nru a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
3776 --- a/arch/arm/mm/proc-xscale.S Sun Apr 27 17:16:26 2003
3777 +++ b/arch/arm/mm/proc-xscale.S Wed Sep  3 10:17:56 2003
3778 @@ -25,8 +25,9 @@
3779  #include <asm/assembler.h>
3780  #include <asm/procinfo.h>
3781  #include <asm/hardware.h>
3782 -#include <asm/proc/pgtable.h>
3783 +#include <asm/pgtable.h>
3784  #include <asm/page.h>
3785 +#include <asm/ptrace.h>
3786  #include "proc-macros.S"
3787  
3788  /*
3789 diff -Nru a/arch/arm/vmlinux-armo.lds.in b/arch/arm/vmlinux-armo.lds.in
3790 --- a/arch/arm/vmlinux-armo.lds.in      Wed Jun 11 17:40:04 2003
3791 +++ /dev/null   Wed Dec 31 16:00:00 1969
3792 @@ -1,114 +0,0 @@
3793 -/* ld script to make ARM Linux kernel
3794 - * taken from the i386 version by Russell King
3795 - * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
3796 - */
3797 -
3798 -#include <asm-generic/vmlinux.lds.h>
3799 -       
3800 -OUTPUT_ARCH(arm)
3801 -ENTRY(stext)
3802 -jiffies = jiffies_64;
3803 -SECTIONS
3804 -{
3805 -       . = TEXTADDR;
3806 -       .init : {                       /* Init code and data           */
3807 -               _stext = .;
3808 -               __init_begin = .;
3809 -                       _sinittext = .;
3810 -                       *(.init.text)
3811 -                       _einittext = .;
3812 -               __proc_info_begin = .;
3813 -                       *(.proc.info)
3814 -               __proc_info_end = .;
3815 -               __arch_info_begin = .;
3816 -                       *(.arch.info)
3817 -               __arch_info_end = .;
3818 -               __tagtable_begin = .;
3819 -                       *(.taglist)
3820 -               __tagtable_end = .;
3821 -                       *(.init.data)
3822 -               . = ALIGN(16);
3823 -               __setup_start = .;
3824 -                       *(.init.setup)
3825 -               __setup_end = .;
3826 -               __initcall_start = .;
3827 -                       *(.initcall1.init)
3828 -                       *(.initcall2.init)
3829 -                       *(.initcall3.init)
3830 -                       *(.initcall4.init)
3831 -                       *(.initcall5.init)
3832 -                       *(.initcall6.init)
3833 -                       *(.initcall7.init)
3834 -               __initcall_end = .;
3835 -               __con_initcall_start = .;
3836 -                       *(.con_initcall.init)
3837 -               __con_initcall_end = .;
3838 -               SECURITY_INIT
3839 -               . = ALIGN(32768);
3840 -               __init_end = .;
3841 -       }
3842 -
3843 -       .init.task : {
3844 -               *(.init.task)
3845 -       }
3846 -
3847 -       /DISCARD/ : {                   /* Exit code and data           */
3848 -               *(.exit.text)
3849 -               *(.exit.data)
3850 -               *(.exitcall.exit)
3851 -       }
3852 -
3853 -       .text : {                       /* Real text segment            */
3854 -               _text = .;              /* Text and read-only data      */
3855 -                       *(.text)
3856 -                       *(.fixup)
3857 -                       *(.gnu.warning)
3858 -                       *(.rodata)
3859 -                       *(.rodata.*)
3860 -                       *(.glue_7)
3861 -                       *(.glue_7t)
3862 -               *(.got)                 /* Global offset table          */
3863 -
3864 -               _etext = .;             /* End of text section          */
3865 -       }
3866 -
3867 -       . = ALIGN(16);
3868 -       __ex_table : {                  /* Exception table              */
3869 -               __start___ex_table = .;
3870 -                       *(__ex_table)
3871 -               __stop___ex_table = .;
3872 -       }
3873 -
3874 -       RODATA
3875 -
3876 -       .data : {
3877 -               /*
3878 -                * The cacheline aligned data
3879 -                */
3880 -               . = ALIGN(32);
3881 -               *(.data.cacheline_aligned)
3882 -
3883 -               /*
3884 -                * and the usual data section
3885 -                */
3886 -               *(.data)
3887 -               CONSTRUCTORS
3888 -
3889 -               _edata = .;
3890 -       }
3891 -
3892 -       .bss : {
3893 -               __bss_start = .;        /* BSS                          */
3894 -               *(.bss)
3895 -               *(COMMON)
3896 -               _end = . ;
3897 -       }
3898 -                                       /* Stabs debugging sections.    */
3899 -       .stab 0 : { *(.stab) }
3900 -       .stabstr 0 : { *(.stabstr) }
3901 -       .stab.excl 0 : { *(.stab.excl) }
3902 -       .stab.exclstr 0 : { *(.stab.exclstr) }
3903 -       .stab.index 0 : { *(.stab.index) }
3904 -       .stab.indexstr 0 : { *(.stab.indexstr) }
3905 -       .comment 0 : { *(.comment) }
3906 -}
3907 diff -Nru a/arch/arm/vmlinux-armv.lds.in b/arch/arm/vmlinux-armv.lds.in
3908 --- a/arch/arm/vmlinux-armv.lds.in      Wed Jun 18 16:33:31 2003
3909 +++ /dev/null   Wed Dec 31 16:00:00 1969
3910 @@ -1,134 +0,0 @@
3911 -/* ld script to make ARM Linux kernel
3912 - * taken from the i386 version by Russell King
3913 - * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
3914 - */
3915 -
3916 -#include <asm-generic/vmlinux.lds.h>
3917 -       
3918 -OUTPUT_ARCH(arm)
3919 -ENTRY(stext)
3920 -#ifndef __ARMEB__
3921 -jiffies = jiffies_64;
3922 -#else
3923 -jiffies = jiffies_64 + 4;
3924 -#endif
3925 -SECTIONS
3926 -{
3927 -       . = TEXTADDR;
3928 -       .init : {                       /* Init code and data           */
3929 -               _stext = .;
3930 -               __init_begin = .;
3931 -                       _sinittext = .;
3932 -                       *(.init.text)
3933 -                       _einittext = .;
3934 -               __proc_info_begin = .;
3935 -                       *(.proc.info)
3936 -               __proc_info_end = .;
3937 -               __arch_info_begin = .;
3938 -                       *(.arch.info)
3939 -               __arch_info_end = .;
3940 -               __tagtable_begin = .;
3941 -                       *(.taglist)
3942 -               __tagtable_end = .;
3943 -                       *(.init.data)
3944 -               . = ALIGN(16);
3945 -               __setup_start = .;
3946 -                       *(.init.setup)
3947 -               __setup_end = .;
3948 -               __early_begin = .;
3949 -                       *(__early_param)
3950 -               __early_end = .;
3951 -               __start___param = .;
3952 -                       *(__param)
3953 -               __stop___param = .;
3954 -               __initcall_start = .;
3955 -                       *(.initcall1.init)
3956 -                       *(.initcall2.init)
3957 -                       *(.initcall3.init)
3958 -                       *(.initcall4.init)
3959 -                       *(.initcall5.init)
3960 -                       *(.initcall6.init)
3961 -                       *(.initcall7.init)
3962 -               __initcall_end = .;
3963 -               __con_initcall_start = .;
3964 -                       *(.con_initcall.init)
3965 -               __con_initcall_end = .;
3966 -               __security_initcall_start = .;
3967 -                       *(.security_initcall.init)
3968 -               __security_initcall_end = .;
3969 -               . = ALIGN(32);
3970 -               __initramfs_start = .;
3971 -                       usr/built-in.o(.init.ramfs)
3972 -               __initramfs_end = .;
3973 -               . = ALIGN(4096);
3974 -               __init_end = .;
3975 -       }
3976 -
3977 -       /DISCARD/ : {                   /* Exit code and data           */
3978 -               *(.exit.text)
3979 -               *(.exit.data)
3980 -               *(.exitcall.exit)
3981 -       }
3982 -
3983 -       .text : {                       /* Real text segment            */
3984 -               _text = .;              /* Text and read-only data      */
3985 -                       *(.text)
3986 -                       *(.fixup)
3987 -                       *(.gnu.warning)
3988 -                       *(.rodata)
3989 -                       *(.rodata.*)
3990 -                       *(.glue_7)
3991 -                       *(.glue_7t)
3992 -               *(.got)                 /* Global offset table          */
3993 -
3994 -               _etext = .;             /* End of text section          */
3995 -       }
3996 -
3997 -       . = ALIGN(16);
3998 -       __ex_table : {                  /* Exception table              */
3999 -               __start___ex_table = .;
4000 -                       *(__ex_table)
4001 -               __stop___ex_table = .;
4002 -       }
4003 -
4004 -       RODATA
4005 -
4006 -       . = ALIGN(8192);
4007 -
4008 -       .data : {
4009 -               /*
4010 -                * first, the init task union, aligned
4011 -                * to an 8192 byte boundary.
4012 -                */
4013 -               *(.init.task)
4014 -
4015 -               /*
4016 -                * then the cacheline aligned data
4017 -                */
4018 -               . = ALIGN(32);
4019 -               *(.data.cacheline_aligned)
4020 -
4021 -               /*
4022 -                * and the usual data section
4023 -                */
4024 -               *(.data)
4025 -               CONSTRUCTORS
4026 -
4027 -               _edata = .;
4028 -       }
4029 -
4030 -       .bss : {
4031 -               __bss_start = .;        /* BSS                          */
4032 -               *(.bss)
4033 -               *(COMMON)
4034 -               _end = . ;
4035 -       }
4036 -                                       /* Stabs debugging sections.    */
4037 -       .stab 0 : { *(.stab) }
4038 -       .stabstr 0 : { *(.stabstr) }
4039 -       .stab.excl 0 : { *(.stab.excl) }
4040 -       .stab.exclstr 0 : { *(.stab.exclstr) }
4041 -       .stab.index 0 : { *(.stab.index) }
4042 -       .stab.indexstr 0 : { *(.stab.indexstr) }
4043 -       .comment 0 : { *(.comment) }
4044 -}
4045 diff -Nru a/arch/arm26/Kconfig b/arch/arm26/Kconfig
4046 --- a/arch/arm26/Kconfig        Sat Aug  2 14:26:16 2003
4047 +++ b/arch/arm26/Kconfig        Sun Aug 31 16:14:22 2003
4048 @@ -146,39 +146,6 @@
4049           You may say N here if you are going to load the Acorn FPEmulator
4050           early in the bootup.
4051  
4052 -choice
4053 -       prompt "Kernel core (/proc/kcore) format"
4054 -       default KCORE_ELF
4055 -
4056 -config KCORE_ELF
4057 -       bool "ELF"
4058 -       ---help---
4059 -         If you enabled support for /proc file system then the file
4060 -         /proc/kcore will contain the kernel core image. This can be used
4061 -         in gdb:
4062 -
4063 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
4064 -
4065 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
4066 -         /proc/kcore appear in ELF core format as defined by the Executable
4067 -         and Linking Format specification. Selecting A.OUT will choose the
4068 -         old "a.out" format which may be necessary for some old versions
4069 -         of binutils or on some architectures.
4070 -
4071 -         This is especially useful if you have compiled the kernel with the
4072 -         "-g" option to preserve debugging information. It is mainly used
4073 -         for examining kernel data structures on the live kernel so if you
4074 -         don't understand what this means or are not a kernel hacker, just
4075 -         leave it at its default value ELF.
4076 -
4077 -config KCORE_AOUT
4078 -       bool "A.OUT"
4079 -       help
4080 -         Not necessary unless you're using a very out-of-date binutils
4081 -         version.  You probably want KCORE_ELF.
4082 -
4083 -endchoice
4084 -
4085  source "fs/Kconfig.binfmt"
4086  
4087  config PREEMPT
4088 diff -Nru a/arch/arm26/kernel/setup.c b/arch/arm26/kernel/setup.c
4089 --- a/arch/arm26/kernel/setup.c Thu Jul  3 15:03:57 2003
4090 +++ b/arch/arm26/kernel/setup.c Sun Aug 31 16:14:08 2003
4091 @@ -304,12 +304,12 @@
4092  
4093  #if defined(CONFIG_DUMMY_CONSOLE)
4094  struct screen_info screen_info = {
4095 - orig_video_lines:     30,
4096 - orig_video_cols:      80,
4097 - orig_video_mode:      0,
4098 - orig_video_ega_bx:    0,
4099 - orig_video_isVGA:     1,
4100 - orig_video_points:    8
4101 + .orig_video_lines     = 30,
4102 + .orig_video_cols      = 80,
4103 + .orig_video_mode      = 0,
4104 + .orig_video_ega_bx    = 0,
4105 + .orig_video_isVGA     = 1,
4106 + .orig_video_points    = 8
4107  };
4108  
4109  static int __init parse_tag_videotext(const struct tag *tag)
4110 diff -Nru a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c
4111 --- a/arch/cris/arch-v10/drivers/eeprom.c       Fri Jul  4 03:27:37 2003
4112 +++ b/arch/cris/arch-v10/drivers/eeprom.c       Tue Aug 26 09:25:41 2003
4113 @@ -441,9 +441,9 @@
4114  static int eeprom_open(struct inode * inode, struct file * file)
4115  {
4116  
4117 -  if(minor(inode->i_rdev) != EEPROM_MINOR_NR)
4118 +  if(iminor(inode) != EEPROM_MINOR_NR)
4119       return -ENXIO;
4120 -  if(major(inode->i_rdev) != EEPROM_MAJOR_NR)
4121 +  if(imajor(inode) != EEPROM_MAJOR_NR)
4122       return -ENXIO;
4123  
4124    if( eeprom.size > 0 )
4125 diff -Nru a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
4126 --- a/arch/cris/arch-v10/drivers/gpio.c Fri Jul  4 03:27:37 2003
4127 +++ b/arch/cris/arch-v10/drivers/gpio.c Tue Aug 26 09:25:40 2003
4128 @@ -386,7 +386,7 @@
4129  gpio_open(struct inode *inode, struct file *filp)
4130  {
4131         struct gpio_private *priv;
4132 -       int p = minor(inode->i_rdev);
4133 +       int p = iminor(inode);
4134  
4135         if (p > GPIO_MINOR_LAST)
4136                 return -EINVAL;
4137 diff -Nru a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
4138 --- a/arch/cris/arch-v10/drivers/pcf8563.c      Wed Jul 23 07:38:45 2003
4139 +++ b/arch/cris/arch-v10/drivers/pcf8563.c      Sun Aug 31 16:14:08 2003
4140 @@ -57,10 +57,10 @@
4141  int pcf8563_release(struct inode *, struct file *);
4142  
4143  static struct file_operations pcf8563_fops = {
4144 -       owner: THIS_MODULE,
4145 -       ioctl: pcf8563_ioctl,
4146 -       open: pcf8563_open,
4147 -       release: pcf8563_release,
4148 +       .owner = THIS_MODULE,
4149 +       .ioctl = pcf8563_ioctl,
4150 +       .open = pcf8563_open,
4151 +       .release = pcf8563_release,
4152  };
4153  
4154  unsigned char
4155 diff -Nru a/arch/h8300/Kconfig b/arch/h8300/Kconfig
4156 --- a/arch/h8300/Kconfig        Thu Aug 21 08:42:22 2003
4157 +++ b/arch/h8300/Kconfig        Sun Aug 31 16:14:22 2003
4158 @@ -177,13 +177,6 @@
4159  
4160  menu "Executable file formats"
4161  
4162 -config KCORE_AOUT
4163 -       bool
4164 -       default y
4165 -
4166 -config KCORE_ELF
4167 -       default y
4168 -
4169  source "fs/Kconfig.binfmt"
4170  
4171  endmenu
4172 diff -Nru a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
4173 --- a/arch/h8300/kernel/setup.c Sun Jul 27 20:40:08 2003
4174 +++ b/arch/h8300/kernel/setup.c Sun Aug 31 16:14:08 2003
4175 @@ -91,12 +91,12 @@
4176  }
4177  
4178  static const struct console gdb_console = {
4179 -       name:           "gdb_con",
4180 -       write:          gdb_console_output,
4181 -       device:         NULL,
4182 -       setup:          gdb_console_setup,
4183 -       flags:          CON_PRINTBUFFER,
4184 -       index:          -1,
4185 +       .name           = "gdb_con",
4186 +       .write          = gdb_console_output,
4187 +       .device         = NULL,
4188 +       .setup          = gdb_console_setup,
4189 +       .flags          = CON_PRINTBUFFER,
4190 +       .index          = -1,
4191  };
4192  #endif
4193  
4194 @@ -260,8 +260,8 @@
4195  }
4196  
4197  struct seq_operations cpuinfo_op = {
4198 -       start:  c_start,
4199 -       next:   c_next,
4200 -       stop:   c_stop,
4201 -       show:   show_cpuinfo,
4202 +       .start  = c_start,
4203 +       .next   = c_next,
4204 +       .stop   = c_stop,
4205 +       .show   = show_cpuinfo,
4206  };
4207 diff -Nru a/arch/h8300/platform/h8300h/ints.c b/arch/h8300/platform/h8300h/ints.c
4208 --- a/arch/h8300/platform/h8300h/ints.c Thu Aug 21 08:42:22 2003
4209 +++ b/arch/h8300/platform/h8300h/ints.c Wed Aug 27 08:10:22 2003
4210 @@ -32,15 +32,6 @@
4211  #include <asm/regs306x.h>
4212  #include <asm/errno.h>
4213  
4214 -#define EXT_IRQ0 12
4215 -#define EXT_IRQ1 13
4216 -#define EXT_IRQ2 14
4217 -#define EXT_IRQ3 15
4218 -#define EXT_IRQ4 16
4219 -#define EXT_IRQ5 17
4220 -#define EXT_IRQ6 18
4221 -#define EXT_IRQ7 19
4222 -
4223  /*
4224   * This structure has only 4 elements for speed reasons
4225   */
4226 @@ -57,17 +48,20 @@
4227  
4228  extern unsigned long *interrupt_redirect_table;
4229  
4230 +#define CPU_VECTOR ((unsigned long *)0x000000)
4231 +#define ADDR_MASK (0xffffff)
4232 +
4233  static inline unsigned long *get_vector_address(void)
4234  {
4235 -       unsigned long *rom_vector = (unsigned long *)0x000000;
4236 +       unsigned long *rom_vector = CPU_VECTOR;
4237         unsigned long base,tmp;
4238         int vec_no;
4239  
4240 -       base = rom_vector[EXT_IRQ0];
4241 +       base = rom_vector[EXT_IRQ0] & ADDR_MASK;
4242         
4243         /* check romvector format */
4244         for (vec_no = EXT_IRQ1; vec_no <= EXT_IRQ5; vec_no++) {
4245 -               if ((base+(vec_no - EXT_IRQ0)*4) != rom_vector[vec_no])
4246 +               if ((base+(vec_no - EXT_IRQ0)*4) != (rom_vector[vec_no] & ADDR_MASK))
4247                         return NULL;
4248         }
4249  
4250 @@ -171,7 +165,7 @@
4251                        irq, irq_list[irq]->devname);
4252         if (irq >= EXT_IRQ0 && irq <= EXT_IRQ5)
4253                 *(volatile unsigned char *)IER &= ~(1 << (irq - EXT_IRQ0));
4254 -       if ((irq_list[irq] & 0x80000000) == 0) {
4255 +       if (((unsigned long)irq_list[irq] & 0x80000000) == 0) {
4256                 kfree(irq_list[irq]);
4257                 irq_list[irq] = NULL;
4258         }
4259 @@ -241,8 +235,9 @@
4260  {
4261  }
4262  
4263 -static void __init enable_kmalloc(void)
4264 +static int __init enable_kmalloc(void)
4265  {
4266         use_kmalloc = 1;
4267 +       return 0;
4268  }
4269 -__initcall(enable_kmalloc);
4270 +core_initcall(enable_kmalloc);
4271 diff -Nru a/arch/h8300/platform/h8s/ints.c b/arch/h8300/platform/h8s/ints.c
4272 --- a/arch/h8300/platform/h8s/ints.c    Thu Aug 21 08:42:22 2003
4273 +++ b/arch/h8300/platform/h8s/ints.c    Wed Aug 27 08:10:22 2003
4274 @@ -33,23 +33,6 @@
4275  #include <asm/regs267x.h>
4276  #include <asm/errno.h>
4277  
4278 -#define EXT_IRQ0 16
4279 -#define EXT_IRQ1 17
4280 -#define EXT_IRQ2 18
4281 -#define EXT_IRQ3 19
4282 -#define EXT_IRQ4 20
4283 -#define EXT_IRQ5 21
4284 -#define EXT_IRQ6 22
4285 -#define EXT_IRQ7 23
4286 -#define EXT_IRQ8 24
4287 -#define EXT_IRQ9 25
4288 -#define EXT_IRQ10 26
4289 -#define EXT_IRQ11 27
4290 -#define EXT_IRQ12 28
4291 -#define EXT_IRQ13 29
4292 -#define EXT_IRQ14 30
4293 -#define EXT_IRQ15 31
4294 -
4295  /*
4296   * This structure has only 4 elements for speed reasons
4297   */
4298 @@ -95,17 +78,20 @@
4299  
4300  extern unsigned long *interrupt_redirect_table;
4301  
4302 +#define CPU_VECTOR ((unsigned long *)0x000000)
4303 +#define ADDR_MASK (0xffffff)
4304 +
4305  static inline unsigned long *get_vector_address(void)
4306  {
4307 -       volatile unsigned long *rom_vector = (unsigned long *)0x000000;
4308 +       volatile unsigned long *rom_vector = CPU_VECTOR;
4309         unsigned long base,tmp;
4310         int vec_no;
4311  
4312 -       base = rom_vector[EXT_IRQ0];
4313 +       base = rom_vector[EXT_IRQ0] & ADDR_MASK;
4314         
4315         /* check romvector format */
4316         for (vec_no = EXT_IRQ1; vec_no <= EXT_IRQ15; vec_no++) {
4317 -               if ((base+(vec_no - EXT_IRQ0)*4) != rom_vector[vec_no])
4318 +               if ((base+(vec_no - EXT_IRQ0)*4) != (rom_vector[vec_no] & ADDR_MASK))
4319                         return NULL;
4320         }
4321  
4322 @@ -307,4 +293,4 @@
4323         use_kmalloc = 1;
4324         return 0;
4325  }
4326 -__initcall(enable_kmalloc);
4327 +core_initcall(enable_kmalloc);
4328 diff -Nru a/arch/i386/Kconfig b/arch/i386/Kconfig
4329 --- a/arch/i386/Kconfig Wed Aug 20 12:16:36 2003
4330 +++ b/arch/i386/Kconfig Wed Sep  3 23:40:07 2003
4331 @@ -408,6 +408,20 @@
4332  
4333           Otherwise, say N.
4334  
4335 +config HPET_TIMER
4336 +       bool "HPET Timer Support"
4337 +       help
4338 +         This enables the use of the HPET for the kernel's internal timer.
4339 +         HPET is the next generation timer replacing legacy 8254s.
4340 +         You can safely choose Y here.  However, HPET will only be
4341 +         activated if the platform and the BIOS support this feature.
4342 +         Otherwise the 8254 will be used for timing services.
4343 +
4344 +         Choose N to continue using the legacy 8254 timer.
4345 +
4346 +config HPET_EMULATE_RTC
4347 +       def_bool HPET_TIMER && RTC=y
4348 +
4349  config SMP
4350         bool "Symmetric multi-processing support"
4351         ---help---
4352 @@ -1155,40 +1169,6 @@
4353  
4354  
4355  menu "Executable file formats"
4356 -
4357 -choice
4358 -       prompt "Kernel core (/proc/kcore) format"
4359 -       depends on PROC_FS
4360 -       default KCORE_ELF
4361 -
4362 -config KCORE_ELF
4363 -       bool "ELF"
4364 -       ---help---
4365 -         If you enabled support for /proc file system then the file
4366 -         /proc/kcore will contain the kernel core image. This can be used
4367 -         in gdb:
4368 -
4369 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
4370 -
4371 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
4372 -         /proc/kcore appear in ELF core format as defined by the Executable
4373 -         and Linking Format specification. Selecting A.OUT will choose the
4374 -         old "a.out" format which may be necessary for some old versions
4375 -         of binutils or on some architectures.
4376 -
4377 -         This is especially useful if you have compiled the kernel with the
4378 -         "-g" option to preserve debugging information. It is mainly used
4379 -         for examining kernel data structures on the live kernel so if you
4380 -         don't understand what this means or are not a kernel hacker, just
4381 -         leave it at its default value ELF.
4382 -
4383 -config KCORE_AOUT
4384 -       bool "A.OUT"
4385 -       help
4386 -         Not necessary unless you're using a very out-of-date binutils
4387 -         version.  You probably want KCORE_ELF.
4388 -
4389 -endchoice
4390  
4391  source "fs/Kconfig.binfmt"
4392  
4393 diff -Nru a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
4394 --- a/arch/i386/kernel/Makefile Mon Aug 18 11:16:59 2003
4395 +++ b/arch/i386/kernel/Makefile Sun Aug 31 16:14:50 2003
4396 @@ -31,6 +31,7 @@
4397  obj-$(CONFIG_MODULES)          += module.o
4398  obj-y                          += sysenter.o vsyscall.o
4399  obj-$(CONFIG_ACPI_SRAT)        += srat.o
4400 +obj-$(CONFIG_HPET_TIMER)       += time_hpet.o
4401  
4402  EXTRA_AFLAGS   := -traditional
4403  
4404 diff -Nru a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
4405 --- a/arch/i386/kernel/acpi/boot.c      Thu Aug 21 11:08:59 2003
4406 +++ b/arch/i386/kernel/acpi/boot.c      Sun Aug 31 16:14:49 2003
4407 @@ -41,6 +41,7 @@
4408  #define PREFIX                 "ACPI: "
4409  
4410  extern int acpi_disabled;
4411 +extern int acpi_irq;
4412  extern int acpi_ht;
4413  
4414  int acpi_lapic = 0;
4415 @@ -269,6 +270,27 @@
4416         return 0;
4417  }
4418  
4419 +#ifdef CONFIG_HPET_TIMER
4420 +extern unsigned long hpet_address;
4421 +
4422 +static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
4423 +{
4424 +       struct acpi_table_hpet *hpet_tbl;
4425 +
4426 +       hpet_tbl = __va(phys);
4427 +
4428 +       if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
4429 +               printk(KERN_WARNING PREFIX "HPET timers must be located in "
4430 +                      "memory.\n");
4431 +               return -1;
4432 +       }
4433 +
4434 +       hpet_address = hpet_tbl->addr.addrl;
4435 +       printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", hpet_tbl->id,
4436 +              hpet_address);
4437 +       return 0;
4438 +}
4439 +#endif
4440  
4441  unsigned long __init
4442  acpi_find_rsdp (void)
4443 @@ -407,7 +429,7 @@
4444          * If MPS is present, it will handle them,
4445          * otherwise the system will stay in PIC mode
4446          */
4447 -       if (acpi_disabled) {
4448 +       if (acpi_disabled || !acpi_irq) {
4449                 return 1;
4450          }
4451  
4452 @@ -457,6 +479,9 @@
4453                 smp_found_config = 1;
4454                 clustered_apic_check();
4455         }
4456 +#endif
4457 +#ifdef CONFIG_HPET_TIMER
4458 +       acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
4459  #endif
4460  
4461         return 0;
4462 diff -Nru a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
4463 --- a/arch/i386/kernel/apic.c   Mon Aug 18 22:27:07 2003
4464 +++ b/arch/i386/kernel/apic.c   Fri Aug 29 03:51:17 2003
4465 @@ -34,6 +34,7 @@
4466  #include <asm/pgalloc.h>
4467  #include <asm/desc.h>
4468  #include <asm/arch_hooks.h>
4469 +#include <asm/hpet.h>
4470  
4471  #include <mach_apic.h>
4472  
4473 @@ -779,7 +780,8 @@
4474         return count;
4475  }
4476  
4477 -void __init wait_8254_wraparound(void)
4478 +/* next tick in 8254 can be caught by catching timer wraparound */
4479 +static void __init wait_8254_wraparound(void)
4480  {
4481         unsigned int curr_count, prev_count=~0;
4482         int delta;
4483 @@ -801,6 +803,12 @@
4484  }
4485  
4486  /*
4487 + * Default initialization for 8254 timers. If we use other timers like HPET,
4488 + * we override this later
4489 + */
4490 +void (*wait_timer_tick)(void) = wait_8254_wraparound;
4491 +
4492 +/*
4493   * This function sets up the local APIC timer, with a timeout of
4494   * 'clocks' APIC bus clock. During calibration we actually call
4495   * this function twice on the boot CPU, once with a bogus timeout
4496 @@ -841,7 +849,7 @@
4497         /*
4498          * Wait for IRQ0's slice:
4499          */
4500 -       wait_8254_wraparound();
4501 +       wait_timer_tick();
4502  
4503         __setup_APIC_LVTT(clocks);
4504  
4505 @@ -884,7 +892,7 @@
4506          * (the current tick might have been already half done)
4507          */
4508  
4509 -       wait_8254_wraparound();
4510 +       wait_timer_tick();
4511  
4512         /*
4513          * We wrapped around just now. Let's start:
4514 @@ -897,7 +905,7 @@
4515          * Let's wait LOOPS wraprounds:
4516          */
4517         for (i = 0; i < LOOPS; i++)
4518 -               wait_8254_wraparound();
4519 +               wait_timer_tick();
4520  
4521         tt2 = apic_read(APIC_TMCCT);
4522         if (cpu_has_tsc)
4523 diff -Nru a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
4524 --- a/arch/i386/kernel/apm.c    Thu Aug 21 14:15:08 2003
4525 +++ b/arch/i386/kernel/apm.c    Wed Sep  3 23:40:14 2003
4526 @@ -2080,4 +2080,4 @@
4527  MODULE_PARM(smp, "i");
4528  MODULE_PARM_DESC(smp,
4529         "Set this to enable APM use on an SMP platform. Use with caution on older systems");
4530 -
4531 +MODULE_ALIAS_MISCDEV(APM_MINOR_DEV);
4532 diff -Nru a/arch/i386/kernel/cpu/mcheck/non-fatal.c b/arch/i386/kernel/cpu/mcheck/non-fatal.c
4533 --- a/arch/i386/kernel/cpu/mcheck/non-fatal.c   Mon Apr 14 12:08:32 2003
4534 +++ b/arch/i386/kernel/cpu/mcheck/non-fatal.c   Wed Sep  3 23:39:56 2003
4535 @@ -1,5 +1,5 @@
4536  /*
4537 - * P4 specific Machine Check Exception Reporting
4538 + * Non Fatal Machine Check Exception Reporting
4539   */
4540  
4541  #include <linux/init.h>
4542 diff -Nru a/arch/i386/kernel/cpu/mtrr/if.c b/arch/i386/kernel/cpu/mtrr/if.c
4543 --- a/arch/i386/kernel/cpu/mtrr/if.c    Wed May 14 23:43:54 2003
4544 +++ b/arch/i386/kernel/cpu/mtrr/if.c    Sun Aug 31 16:14:43 2003
4545 @@ -17,6 +17,22 @@
4546  
4547  #define FILE_FCOUNT(f) (((struct seq_file *)((f)->private_data))->private)
4548  
4549 +static char *mtrr_strings[MTRR_NUM_TYPES] =
4550 +{
4551 +    "uncachable",               /* 0 */
4552 +    "write-combining",          /* 1 */
4553 +    "?",                        /* 2 */
4554 +    "?",                        /* 3 */
4555 +    "write-through",            /* 4 */
4556 +    "write-protect",            /* 5 */
4557 +    "write-back",               /* 6 */
4558 +};
4559 +
4560 +char *mtrr_attrib_to_str(int x)
4561 +{
4562 +       return (x <= 6) ? mtrr_strings[x] : "?";
4563 +}
4564 +
4565  static int
4566  mtrr_file_add(unsigned long base, unsigned long size,
4567               unsigned int type, char increment, struct file *file, int page)
4568 @@ -300,11 +316,6 @@
4569  
4570  #  endif                       /*  CONFIG_PROC_FS  */
4571  
4572 -char * attrib_to_str(int x)
4573 -{
4574 -       return (x <= 6) ? mtrr_strings[x] : "?";
4575 -}
4576 -
4577  static int mtrr_seq_show(struct seq_file *seq, void *offset)
4578  {
4579         char factor;
4580 @@ -332,7 +343,7 @@
4581                         len += seq_printf(seq, 
4582                                    "reg%02i: base=0x%05lx000 (%4liMB), size=%4i%cB: %s, count=%d\n",
4583                              i, base, base >> (20 - PAGE_SHIFT), size, factor,
4584 -                            attrib_to_str(type), usage_table[i]);
4585 +                            mtrr_attrib_to_str(type), usage_table[i]);
4586                 }
4587         }
4588         return 0;
4589 diff -Nru a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
4590 --- a/arch/i386/kernel/cpu/mtrr/main.c  Thu Aug 21 11:48:14 2003
4591 +++ b/arch/i386/kernel/cpu/mtrr/main.c  Sun Aug 31 16:14:43 2003
4592 @@ -111,11 +111,6 @@
4593         num_var_ranges = config & 0xff;
4594  }
4595  
4596 -static char * attrib_to_str(int x)
4597 -{
4598 -       return (x <= 6) ? mtrr_strings[x] : "?";
4599 -}
4600 -
4601  static void init_table(void)
4602  {
4603         int i, max;
4604 @@ -362,8 +357,8 @@
4605                         if (type == MTRR_TYPE_UNCACHABLE)
4606                                 continue;
4607                         printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
4608 -                            base, size, attrib_to_str(ltype),
4609 -                            attrib_to_str(type));
4610 +                            base, size, mtrr_attrib_to_str(ltype),
4611 +                            mtrr_attrib_to_str(type));
4612                         goto out;
4613                 }
4614                 if (increment)
4615 @@ -703,16 +698,4 @@
4616         return -ENXIO;
4617  }
4618  
4619 -char *mtrr_strings[MTRR_NUM_TYPES] =
4620 -{
4621 -    "uncachable",               /* 0 */
4622 -    "write-combining",          /* 1 */
4623 -    "?",                        /* 2 */
4624 -    "?",                        /* 3 */
4625 -    "write-through",            /* 4 */
4626 -    "write-protect",            /* 5 */
4627 -    "write-back",               /* 6 */
4628 -};
4629 -
4630  subsys_initcall(mtrr_init);
4631 -
4632 diff -Nru a/arch/i386/kernel/cpu/mtrr/mtrr.h b/arch/i386/kernel/cpu/mtrr/mtrr.h
4633 --- a/arch/i386/kernel/cpu/mtrr/mtrr.h  Wed Nov 27 22:37:22 2002
4634 +++ b/arch/i386/kernel/cpu/mtrr/mtrr.h  Sun Aug 31 16:14:43 2003
4635 @@ -95,5 +95,6 @@
4636  
4637  void finalize_mtrr_state(void);
4638  void mtrr_state_warn(void);
4639 +char *mtrr_attrib_to_str(int x);
4640  
4641  extern char * mtrr_if_name[];
4642 diff -Nru a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
4643 --- a/arch/i386/kernel/cpuid.c  Mon Aug 18 19:46:23 2003
4644 +++ b/arch/i386/kernel/cpuid.c  Tue Aug 26 09:25:40 2003
4645 @@ -115,7 +115,7 @@
4646    u32 data[4];
4647    size_t rv;
4648    u32 reg = *ppos;
4649 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
4650 +  int cpu = iminor(file->f_dentry->d_inode);
4651    
4652    if ( count % 16 )
4653      return -EINVAL; /* Invalid chunk size */
4654 @@ -133,7 +133,7 @@
4655  
4656  static int cpuid_open(struct inode *inode, struct file *file)
4657  {
4658 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
4659 +  int cpu = iminor(file->f_dentry->d_inode);
4660    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
4661  
4662    if (!cpu_online(cpu))
4663 diff -Nru a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
4664 --- a/arch/i386/kernel/mpparse.c        Tue Aug 19 21:21:36 2003
4665 +++ b/arch/i386/kernel/mpparse.c        Sun Aug 31 16:14:25 2003
4666 @@ -850,7 +850,7 @@
4667                         return i;
4668         }
4669  
4670 -       printk(KERN_ERR "ERROR: Unable to locate IOAPIC for IRQ %d/n", irq);
4671 +       printk(KERN_ERR "ERROR: Unable to locate IOAPIC for IRQ %d\n", irq);
4672  
4673         return -1;
4674  }
4675 diff -Nru a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
4676 --- a/arch/i386/kernel/msr.c    Mon Aug 18 19:46:23 2003
4677 +++ b/arch/i386/kernel/msr.c    Tue Aug 26 09:25:40 2003
4678 @@ -194,7 +194,7 @@
4679    u32 data[2];
4680    size_t rv;
4681    u32 reg = *ppos;
4682 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
4683 +  int cpu = iminor(file->f_dentry->d_inode);
4684    int err;
4685  
4686    if ( count % 8 )
4687 @@ -219,7 +219,7 @@
4688    u32 data[2];
4689    size_t rv;
4690    u32 reg = *ppos;
4691 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
4692 +  int cpu = iminor(file->f_dentry->d_inode);
4693    int err;
4694  
4695    if ( count % 8 )
4696 @@ -239,7 +239,7 @@
4697  
4698  static int msr_open(struct inode *inode, struct file *file)
4699  {
4700 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
4701 +  int cpu = iminor(file->f_dentry->d_inode);
4702    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
4703    
4704    if (!cpu_online(cpu))
4705 diff -Nru a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
4706 --- a/arch/i386/kernel/process.c        Wed Aug 20 10:43:52 2003
4707 +++ b/arch/i386/kernel/process.c        Tue Sep  2 00:37:21 2003
4708 @@ -452,7 +452,7 @@
4709  
4710         /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
4711  
4712 -       unlazy_fpu(prev_p);
4713 +       __unlazy_fpu(prev_p);
4714  
4715         /*
4716          * Reload esp0, LDT and the page table pointer:
4717 diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
4718 --- a/arch/i386/kernel/setup.c  Thu Aug 21 11:08:59 2003
4719 +++ b/arch/i386/kernel/setup.c  Sun Aug 31 16:14:11 2003
4720 @@ -71,6 +71,7 @@
4721  EXPORT_SYMBOL(acpi_disabled);
4722  
4723  #ifdef CONFIG_ACPI_BOOT
4724 +       int acpi_irq __initdata = 1;    /* enable IRQ */
4725         int acpi_ht __initdata = 1;     /* enable HT */
4726  #endif
4727  
4728 @@ -542,6 +543,11 @@
4729                 else if (!memcmp(from, "acpi=ht", 7)) {
4730                         acpi_ht = 1;
4731                         if (!acpi_force) acpi_disabled = 1;
4732 +               }
4733 +
4734 +               /* "pci=noacpi" disables ACPI interrupt routing */
4735 +               else if (!memcmp(from, "pci=noacpi", 10)) {
4736 +                       acpi_irq = 0;
4737                 }
4738  
4739  #ifdef CONFIG_X86_LOCAL_APIC
4740 diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
4741 --- a/arch/i386/kernel/time.c   Thu Jul 10 22:22:57 2003
4742 +++ b/arch/i386/kernel/time.c   Fri Aug 29 03:51:17 2003
4743 @@ -60,6 +60,8 @@
4744  #include <linux/timex.h>
4745  #include <linux/config.h>
4746  
4747 +#include <asm/hpet.h>
4748 +
4749  #include <asm/arch_hooks.h>
4750  
4751  #include "io_ports.h"
4752 @@ -291,8 +293,38 @@
4753  
4754  device_initcall(time_init_device);
4755  
4756 +#ifdef CONFIG_HPET_TIMER
4757 +extern void (*late_time_init)(void);
4758 +/* Duplicate of time_init() below, with hpet_enable part added */
4759 +void __init hpet_time_init(void)
4760 +{
4761 +       xtime.tv_sec = get_cmos_time();
4762 +       wall_to_monotonic.tv_sec = -xtime.tv_sec;
4763 +       xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
4764 +       wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
4765 +
4766 +       if (hpet_enable() >= 0) {
4767 +               printk("Using HPET for base-timer\n");
4768 +       }
4769 +
4770 +       cur_timer = select_timer();
4771 +       time_init_hook();
4772 +}
4773 +#endif
4774 +
4775  void __init time_init(void)
4776  {
4777 +#ifdef CONFIG_HPET_TIMER
4778 +       if (is_hpet_capable()) {
4779 +               /*
4780 +                * HPET initialization needs to do memory-mapped io. So, let
4781 +                * us do a late initialization after mem_init().
4782 +                */
4783 +               late_time_init = hpet_time_init;
4784 +               return;
4785 +       }
4786 +#endif
4787 +
4788         xtime.tv_sec = get_cmos_time();
4789         wall_to_monotonic.tv_sec = -xtime.tv_sec;
4790         xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
4791 diff -Nru a/arch/i386/kernel/time_hpet.c b/arch/i386/kernel/time_hpet.c
4792 --- /dev/null   Wed Dec 31 16:00:00 1969
4793 +++ b/arch/i386/kernel/time_hpet.c      Wed Sep  3 23:40:07 2003
4794 @@ -0,0 +1,391 @@
4795 +/*
4796 + *  linux/arch/i386/kernel/time_hpet.c
4797 + *  This code largely copied from arch/x86_64/kernel/time.c
4798 + *  See that file for credits.
4799 + *
4800 + *  2003-06-30    Venkatesh Pallipadi - Additional changes for HPET support
4801 + */
4802 +
4803 +#include <linux/errno.h>
4804 +#include <linux/kernel.h>
4805 +#include <linux/param.h>
4806 +#include <linux/string.h>
4807 +#include <linux/init.h>
4808 +#include <linux/smp.h>
4809 +
4810 +#include <asm/timer.h>
4811 +#include <asm/fixmap.h>
4812 +#include <asm/apic.h>
4813 +
4814 +#include <linux/timex.h>
4815 +#include <linux/config.h>
4816 +
4817 +#include <asm/hpet.h>
4818 +
4819 +unsigned long hpet_period;     /* fsecs / HPET clock */
4820 +unsigned long hpet_tick;       /* hpet clks count per tick */
4821 +unsigned long hpet_address;    /* hpet memory map physical address */
4822 +
4823 +static int use_hpet;           /* can be used for runtime check of hpet */
4824 +static int boot_hpet_disable;  /* boottime override for HPET timer */
4825 +static unsigned long hpet_virt_address;        /* hpet kernel virtual address */
4826 +
4827 +#define FSEC_TO_USEC (1000000000UL)
4828 +
4829 +int hpet_readl(unsigned long a)
4830 +{
4831 +       return readl(hpet_virt_address + a);
4832 +}
4833 +
4834 +void hpet_writel(unsigned long d, unsigned long a)
4835 +{
4836 +       writel(d, hpet_virt_address + a);
4837 +}
4838 +
4839 +#ifdef CONFIG_X86_LOCAL_APIC
4840 +/*
4841 + * HPET counters dont wrap around on every tick. They just change the
4842 + * comparator value and continue. Next tick can be caught by checking
4843 + * for a change in the comparator value. Used in apic.c.
4844 + */
4845 +void __init wait_hpet_tick(void)
4846 +{
4847 +       unsigned int start_cmp_val, end_cmp_val;
4848 +
4849 +       start_cmp_val = hpet_readl(HPET_T0_CMP);
4850 +       do {
4851 +               end_cmp_val = hpet_readl(HPET_T0_CMP);
4852 +       } while (start_cmp_val == end_cmp_val);
4853 +}
4854 +#endif
4855 +
4856 +/*
4857 + * Check whether HPET was found by ACPI boot parse. If yes setup HPET
4858 + * counter 0 for kernel base timer.
4859 + */
4860 +int __init hpet_enable(void)
4861 +{
4862 +       unsigned int cfg, id;
4863 +       unsigned long tick_fsec_low, tick_fsec_high; /* tick in femto sec */
4864 +       unsigned long hpet_tick_rem;
4865 +
4866 +       if (boot_hpet_disable)
4867 +               return -1;
4868 +
4869 +       if (!hpet_address) {
4870 +               return -1;
4871 +       }
4872 +       hpet_virt_address = (unsigned long) ioremap_nocache(hpet_address,
4873 +                                                           HPET_MMAP_SIZE);
4874 +       /*
4875 +        * Read the period, compute tick and quotient.
4876 +        */
4877 +       id = hpet_readl(HPET_ID);
4878 +
4879 +       /*
4880 +        * We are checking for value '1' or more in number field.
4881 +        * So, we are OK with HPET_EMULATE_RTC part too, where we need
4882 +        * to have atleast 2 timers.
4883 +        */
4884 +       if (!(id & HPET_ID_NUMBER) ||
4885 +           !(id & HPET_ID_LEGSUP))
4886 +               return -1;
4887 +
4888 +       if (((id & HPET_ID_VENDOR) >> HPET_ID_VENDOR_SHIFT) !=
4889 +                               HPET_ID_VENDOR_8086)
4890 +               return -1;
4891 +
4892 +       hpet_period = hpet_readl(HPET_PERIOD);
4893 +       if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD))
4894 +               return -1;
4895 +
4896 +       /*
4897 +        * 64 bit math
4898 +        * First changing tick into fsec
4899 +        * Then 64 bit div to find number of hpet clk per tick
4900 +        */
4901 +       ASM_MUL64_REG(tick_fsec_low, tick_fsec_high,
4902 +                       KERNEL_TICK_USEC, FSEC_TO_USEC);
4903 +       ASM_DIV64_REG(hpet_tick, hpet_tick_rem,
4904 +                       hpet_period, tick_fsec_low, tick_fsec_high);
4905 +
4906 +       if (hpet_tick_rem > (hpet_period >> 1))
4907 +               hpet_tick++; /* rounding the result */
4908 +
4909 +       /*
4910 +        * Stop the timers and reset the main counter.
4911 +        */
4912 +       cfg = hpet_readl(HPET_CFG);
4913 +       cfg &= ~HPET_CFG_ENABLE;
4914 +       hpet_writel(cfg, HPET_CFG);
4915 +       hpet_writel(0, HPET_COUNTER);
4916 +       hpet_writel(0, HPET_COUNTER + 4);
4917 +
4918 +       /*
4919 +        * Set up timer 0, as periodic with first interrupt to happen at
4920 +        * hpet_tick, and period also hpet_tick.
4921 +        */
4922 +       cfg = hpet_readl(HPET_T0_CFG);
4923 +       cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
4924 +              HPET_TN_SETVAL | HPET_TN_32BIT;
4925 +       hpet_writel(cfg, HPET_T0_CFG);
4926 +       hpet_writel(hpet_tick, HPET_T0_CMP);
4927 +
4928 +       /*
4929 +        * Go!
4930 +        */
4931 +       cfg = hpet_readl(HPET_CFG);
4932 +       cfg |= HPET_CFG_ENABLE | HPET_CFG_LEGACY;
4933 +       hpet_writel(cfg, HPET_CFG);
4934 +
4935 +       use_hpet = 1;
4936 +#ifdef CONFIG_X86_LOCAL_APIC
4937 +       wait_timer_tick = wait_hpet_tick;
4938 +#endif
4939 +       return 0;
4940 +}
4941 +
4942 +int is_hpet_enabled(void)
4943 +{
4944 +       return use_hpet;
4945 +}
4946 +
4947 +int is_hpet_capable(void)
4948 +{
4949 +       if (!boot_hpet_disable && hpet_address)
4950 +               return 1;
4951 +       return 0;
4952 +}
4953 +
4954 +static int __init hpet_setup(char* str)
4955 +{
4956 +       if (str) {
4957 +               if (!strncmp("disable", str, 7))
4958 +                       boot_hpet_disable = 1;
4959 +       }
4960 +       return 1;
4961 +}
4962 +
4963 +__setup("hpet=", hpet_setup);
4964 +
4965 +#ifdef CONFIG_HPET_EMULATE_RTC
4966 +/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
4967 + * is enabled, we support RTC interrupt functionality in software.
4968 + * RTC has 3 kinds of interrupts:
4969 + * 1) Update Interrupt - generate an interrupt, every sec, when RTC clock
4970 + *    is updated
4971 + * 2) Alarm Interrupt - generate an interrupt at a specific time of day
4972 + * 3) Periodic Interrupt - generate periodic interrupt, with frequencies
4973 + *    2Hz-8192Hz (2Hz-64Hz for non-root user) (all freqs in powers of 2)
4974 + * (1) and (2) above are implemented using polling at a frequency of
4975 + * 64 Hz. The exact frequency is a tradeoff between accuracy and interrupt
4976 + * overhead. (DEFAULT_RTC_INT_FREQ)
4977 + * For (3), we use interrupts at 64Hz or user specified periodic
4978 + * frequency, whichever is higher.
4979 + */
4980 +#include <linux/mc146818rtc.h>
4981 +#include <linux/rtc.h>
4982 +
4983 +extern irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
4984 +
4985 +#define DEFAULT_RTC_INT_FREQ   64
4986 +#define RTC_NUM_INTS           1
4987 +
4988 +static unsigned long UIE_on;
4989 +static unsigned long prev_update_sec;
4990 +
4991 +static unsigned long AIE_on;
4992 +static struct rtc_time alarm_time;
4993 +
4994 +static unsigned long PIE_on;
4995 +static unsigned long PIE_freq = DEFAULT_RTC_INT_FREQ;
4996 +static unsigned long PIE_count;
4997 +
4998 +static unsigned long hpet_rtc_int_freq; /* RTC interrupt frequency */
4999 +
5000 +/*
5001 + * Timer 1 for RTC, we do not use periodic interrupt feature,
5002 + * even if HPET supports periodic interrupts on Timer 1.
5003 + * The reason being, to set up a periodic interrupt in HPET, we need to
5004 + * stop the main counter. And if we do that everytime someone diables/enables
5005 + * RTC, we will have adverse effect on main kernel timer running on Timer 0.
5006 + * So, for the time being, simulate the periodic interrupt in software.
5007 + *
5008 + * hpet_rtc_timer_init() is called for the first time and during subsequent
5009 + * interuppts reinit happens through hpet_rtc_timer_reinit().
5010 + */
5011 +int hpet_rtc_timer_init(void)
5012 +{
5013 +       unsigned int cfg, cnt;
5014 +       unsigned long flags;
5015 +
5016 +       if (!is_hpet_enabled())
5017 +               return 0;
5018 +       /*
5019 +        * Set the counter 1 and enable the interrupts.
5020 +        */
5021 +       if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
5022 +               hpet_rtc_int_freq = PIE_freq;
5023 +       else
5024 +               hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
5025 +
5026 +       local_irq_save(flags);
5027 +       cnt = hpet_readl(HPET_COUNTER);
5028 +       cnt += ((hpet_tick*HZ)/hpet_rtc_int_freq);
5029 +       hpet_writel(cnt, HPET_T1_CMP);
5030 +       local_irq_restore(flags);
5031 +
5032 +       cfg = hpet_readl(HPET_T1_CFG);
5033 +       cfg |= HPET_TN_ENABLE | HPET_TN_SETVAL | HPET_TN_32BIT;
5034 +       hpet_writel(cfg, HPET_T1_CFG);
5035 +
5036 +       return 1;
5037 +}
5038 +
5039 +static void hpet_rtc_timer_reinit(void)
5040 +{
5041 +       unsigned int cfg, cnt;
5042 +
5043 +       if (!(PIE_on | AIE_on | UIE_on))
5044 +               return;
5045 +
5046 +       if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
5047 +               hpet_rtc_int_freq = PIE_freq;
5048 +       else
5049 +               hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
5050 +
5051 +       /* It is more accurate to use the comparator value than current count.*/
5052 +       cnt = hpet_readl(HPET_T1_CMP);
5053 +       cnt += hpet_tick*HZ/hpet_rtc_int_freq;
5054 +       hpet_writel(cnt, HPET_T1_CMP);
5055 +
5056 +       cfg = hpet_readl(HPET_T1_CFG);
5057 +       cfg |= HPET_TN_ENABLE | HPET_TN_SETVAL | HPET_TN_32BIT;
5058 +       hpet_writel(cfg, HPET_T1_CFG);
5059 +
5060 +       return;
5061 +}
5062 +
5063 +/*
5064 + * The functions below are called from rtc driver.
5065 + * Return 0 if HPET is not being used.
5066 + * Otherwise do the necessary changes and return 1.
5067 + */
5068 +int hpet_mask_rtc_irq_bit(unsigned long bit_mask)
5069 +{
5070 +       if (!is_hpet_enabled())
5071 +               return 0;
5072 +
5073 +       if (bit_mask & RTC_UIE)
5074 +               UIE_on = 0;
5075 +       if (bit_mask & RTC_PIE)
5076 +               PIE_on = 0;
5077 +       if (bit_mask & RTC_AIE)
5078 +               AIE_on = 0;
5079 +
5080 +       return 1;
5081 +}
5082 +
5083 +int hpet_set_rtc_irq_bit(unsigned long bit_mask)
5084 +{
5085 +       int timer_init_reqd = 0;
5086 +
5087 +       if (!is_hpet_enabled())
5088 +               return 0;
5089 +
5090 +       if (!(PIE_on | AIE_on | UIE_on))
5091 +               timer_init_reqd = 1;
5092 +
5093 +       if (bit_mask & RTC_UIE) {
5094 +               UIE_on = 1;
5095 +       }
5096 +       if (bit_mask & RTC_PIE) {
5097 +               PIE_on = 1;
5098 +               PIE_count = 0;
5099 +       }
5100 +       if (bit_mask & RTC_AIE) {
5101 +               AIE_on = 1;
5102 +       }
5103 +
5104 +       if (timer_init_reqd)
5105 +               hpet_rtc_timer_init();
5106 +
5107 +       return 1;
5108 +}
5109 +
5110 +int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec)
5111 +{
5112 +       if (!is_hpet_enabled())
5113 +               return 0;
5114 +
5115 +       alarm_time.tm_hour = hrs;
5116 +       alarm_time.tm_min = min;
5117 +       alarm_time.tm_sec = sec;
5118 +
5119 +       return 1;
5120 +}
5121 +
5122 +int hpet_set_periodic_freq(unsigned long freq)
5123 +{
5124 +       if (!is_hpet_enabled())
5125 +               return 0;
5126 +
5127 +       PIE_freq = freq;
5128 +       PIE_count = 0;
5129 +
5130 +       return 1;
5131 +}
5132 +
5133 +int hpet_rtc_dropped_irq(void)
5134 +{
5135 +       if (!is_hpet_enabled())
5136 +               return 0;
5137 +
5138 +       return 1;
5139 +}
5140 +
5141 +irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
5142 +{
5143 +       struct rtc_time curr_time;
5144 +       unsigned long rtc_int_flag = 0;
5145 +       int call_rtc_interrupt = 0;
5146 +
5147 +       hpet_rtc_timer_reinit();
5148 +
5149 +       if (UIE_on | AIE_on) {
5150 +               rtc_get_rtc_time(&curr_time);
5151 +       }
5152 +       if (UIE_on) {
5153 +               if (curr_time.tm_sec != prev_update_sec) {
5154 +                       /* Set update int info, call real rtc int routine */
5155 +                       call_rtc_interrupt = 1;
5156 +                       rtc_int_flag = RTC_UF;
5157 +                       prev_update_sec = curr_time.tm_sec;
5158 +               }
5159 +       }
5160 +       if (PIE_on) {
5161 +               PIE_count++;
5162 +               if (PIE_count >= hpet_rtc_int_freq/PIE_freq) {
5163 +                       /* Set periodic int info, call real rtc int routine */
5164 +                       call_rtc_interrupt = 1;
5165 +                       rtc_int_flag |= RTC_PF;
5166 +                       PIE_count = 0;
5167 +               }
5168 +       }
5169 +       if (AIE_on) {
5170 +               if ((curr_time.tm_sec == alarm_time.tm_sec) &&
5171 +                   (curr_time.tm_min == alarm_time.tm_min) &&
5172 +                   (curr_time.tm_hour == alarm_time.tm_hour)) {
5173 +                       /* Set alarm int info, call real rtc int routine */
5174 +                       call_rtc_interrupt = 1;
5175 +                       rtc_int_flag |= RTC_AF;
5176 +               }
5177 +       }
5178 +       if (call_rtc_interrupt) {
5179 +               rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8));
5180 +               rtc_interrupt(rtc_int_flag, dev_id, regs);
5181 +       }
5182 +       return IRQ_HANDLED;
5183 +}
5184 +#endif
5185 +
5186 diff -Nru a/arch/i386/kernel/timers/Makefile b/arch/i386/kernel/timers/Makefile
5187 --- a/arch/i386/kernel/timers/Makefile  Sun May  4 23:38:34 2003
5188 +++ b/arch/i386/kernel/timers/Makefile  Sun Aug 31 16:14:50 2003
5189 @@ -5,3 +5,4 @@
5190  obj-y := timer.o timer_none.o timer_tsc.o timer_pit.o
5191  
5192  obj-$(CONFIG_X86_CYCLONE_TIMER)        += timer_cyclone.o
5193 +obj-$(CONFIG_HPET_TIMER)       += timer_hpet.o
5194 diff -Nru a/arch/i386/kernel/timers/timer.c b/arch/i386/kernel/timers/timer.c
5195 --- a/arch/i386/kernel/timers/timer.c   Wed Jul  2 21:21:34 2003
5196 +++ b/arch/i386/kernel/timers/timer.c   Sun Aug 31 16:15:21 2003
5197 @@ -3,10 +3,21 @@
5198  #include <linux/string.h>
5199  #include <asm/timer.h>
5200  
5201 +#ifdef CONFIG_HPET_TIMER
5202 +/*
5203 + * HPET memory read is slower than tsc reads, but is more dependable as it
5204 + * always runs at constant frequency and reduces complexity due to
5205 + * cpufreq. So, we prefer HPET timer to tsc based one. Also, we cannot use
5206 + * timer_pit when HPET is active. So, we default to timer_tsc.
5207 + */
5208 +#endif
5209  /* list of timers, ordered by preference, NULL terminated */
5210  static struct timer_opts* timers[] = {
5211  #ifdef CONFIG_X86_CYCLONE_TIMER
5212         &timer_cyclone,
5213 +#endif
5214 +#ifdef CONFIG_HPET_TIMER
5215 +       &timer_hpet,
5216  #endif
5217         &timer_tsc,
5218         &timer_pit,
5219 diff -Nru a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c
5220 --- /dev/null   Wed Dec 31 16:00:00 1969
5221 +++ b/arch/i386/kernel/timers/timer_hpet.c      Sun Aug 31 16:15:29 2003
5222 @@ -0,0 +1,241 @@
5223 +/*
5224 + * This code largely moved from arch/i386/kernel/time.c.
5225 + * See comments there for proper credits.
5226 + */
5227 +
5228 +#include <linux/spinlock.h>
5229 +#include <linux/init.h>
5230 +#include <linux/timex.h>
5231 +#include <linux/errno.h>
5232 +#include <linux/string.h>
5233 +#include <linux/jiffies.h>
5234 +
5235 +#include <asm/timer.h>
5236 +#include <asm/io.h>
5237 +#include <asm/processor.h>
5238 +
5239 +#include "io_ports.h"
5240 +#include "mach_timer.h"
5241 +#include <asm/hpet.h>
5242 +
5243 +static unsigned long hpet_usec_quotient;       /* convert hpet clks to usec */
5244 +static unsigned long tsc_hpet_quotient;                /* convert tsc to hpet clks */
5245 +static unsigned long hpet_last;        /* hpet counter value at last tick*/
5246 +static unsigned long last_tsc_low;     /* lsb 32 bits of Time Stamp Counter */
5247 +static unsigned long last_tsc_high;    /* msb 32 bits of Time Stamp Counter */
5248 +static unsigned long long monotonic_base;
5249 +static rwlock_t monotonic_lock = RW_LOCK_UNLOCKED;
5250 +
5251 +/* convert from cycles(64bits) => nanoseconds (64bits)
5252 + *  basic equation:
5253 + *             ns = cycles / (freq / ns_per_sec)
5254 + *             ns = cycles * (ns_per_sec / freq)
5255 + *             ns = cycles * (10^9 / (cpu_mhz * 10^6))
5256 + *             ns = cycles * (10^3 / cpu_mhz)
5257 + *
5258 + *     Then we use scaling math (suggested by george@mvista.com) to get:
5259 + *             ns = cycles * (10^3 * SC / cpu_mhz) / SC
5260 + *             ns = cycles * cyc2ns_scale / SC
5261 + *
5262 + *     And since SC is a constant power of two, we can convert the div
5263 + *  into a shift.
5264 + *                     -johnstul@us.ibm.com "math is hard, lets go shopping!"
5265 + */
5266 +static unsigned long cyc2ns_scale;
5267 +#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
5268 +
5269 +static inline void set_cyc2ns_scale(unsigned long cpu_mhz)
5270 +{
5271 +       cyc2ns_scale = (1000 << CYC2NS_SCALE_FACTOR)/cpu_mhz;
5272 +}
5273 +
5274 +static inline unsigned long long cycles_2_ns(unsigned long long cyc)
5275 +{
5276 +       return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
5277 +}
5278 +
5279 +static unsigned long long monotonic_clock_hpet(void)
5280 +{
5281 +       unsigned long long last_offset, this_offset, base;
5282 +
5283 +       /* atomically read monotonic base & last_offset */
5284 +       read_lock_irq(&monotonic_lock);
5285 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
5286 +       base = monotonic_base;
5287 +       read_unlock_irq(&monotonic_lock);
5288 +
5289 +       /* Read the Time Stamp Counter */
5290 +       rdtscll(this_offset);
5291 +
5292 +       /* return the value in ns */
5293 +       return base + cycles_2_ns(this_offset - last_offset);
5294 +}
5295 +
5296 +static unsigned long get_offset_hpet(void)
5297 +{
5298 +       register unsigned long eax, edx;
5299 +
5300 +       eax = hpet_readl(HPET_COUNTER);
5301 +       eax -= hpet_last;       /* hpet delta */
5302 +
5303 +       /*
5304 +         * Time offset = (hpet delta) * ( usecs per HPET clock )
5305 +        *             = (hpet delta) * ( usecs per tick / HPET clocks per tick)
5306 +        *             = (hpet delta) * ( hpet_usec_quotient ) / (2^32)
5307 +        *
5308 +        * Where,
5309 +        * hpet_usec_quotient = (2^32 * usecs per tick)/HPET clocks per tick
5310 +        *
5311 +        * Using a mull instead of a divl saves some cycles in critical path.
5312 +         */
5313 +       ASM_MUL64_REG(eax, edx, hpet_usec_quotient, eax);
5314 +
5315 +       /* our adjusted time offset in microseconds */
5316 +       return edx;
5317 +}
5318 +
5319 +static void mark_offset_hpet(void)
5320 +{
5321 +       unsigned long long this_offset, last_offset;
5322 +       unsigned long offset;
5323 +
5324 +       write_lock(&monotonic_lock);
5325 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
5326 +       rdtsc(last_tsc_low, last_tsc_high);
5327 +
5328 +       offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
5329 +       if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
5330 +               int lost_ticks = (offset - hpet_last) / hpet_tick;
5331 +               jiffies += lost_ticks;
5332 +       }
5333 +       hpet_last = offset;
5334 +
5335 +       /* update the monotonic base value */
5336 +       this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
5337 +       monotonic_base += cycles_2_ns(this_offset - last_offset);
5338 +       write_unlock(&monotonic_lock);
5339 +}
5340 +
5341 +void delay_hpet(unsigned long loops)
5342 +{
5343 +       unsigned long hpet_start, hpet_end;
5344 +       unsigned long eax;
5345 +
5346 +       /* loops is the number of cpu cycles. Convert it to hpet clocks */
5347 +       ASM_MUL64_REG(eax, loops, tsc_hpet_quotient, loops);
5348 +
5349 +       hpet_start = hpet_readl(HPET_COUNTER);
5350 +       do {
5351 +               rep_nop();
5352 +               hpet_end = hpet_readl(HPET_COUNTER);
5353 +       } while ((hpet_end - hpet_start) < (loops));
5354 +}
5355 +
5356 +/* ------ Calibrate the TSC -------
5357 + * Return 2^32 * (1 / (TSC clocks per usec)) for getting the CPU freq.
5358 + * Set 2^32 * (1 / (tsc per HPET clk)) for delay_hpet().
5359 + * calibrate_tsc() calibrates the processor TSC by comparing
5360 + * it to the HPET timer of known frequency.
5361 + * Too much 64-bit arithmetic here to do this cleanly in C
5362 + */
5363 +#define CALIBRATE_CNT_HPET     (5 * hpet_tick)
5364 +#define CALIBRATE_TIME_HPET    (5 * KERNEL_TICK_USEC)
5365 +
5366 +static unsigned long __init calibrate_tsc(void)
5367 +{
5368 +       unsigned long tsc_startlow, tsc_starthigh;
5369 +       unsigned long tsc_endlow, tsc_endhigh;
5370 +       unsigned long hpet_start, hpet_end;
5371 +       unsigned long result, remain;
5372 +
5373 +       hpet_start = hpet_readl(HPET_COUNTER);
5374 +       rdtsc(tsc_startlow, tsc_starthigh);
5375 +       do {
5376 +               hpet_end = hpet_readl(HPET_COUNTER);
5377 +       } while ((hpet_end - hpet_start) < CALIBRATE_CNT_HPET);
5378 +       rdtsc(tsc_endlow, tsc_endhigh);
5379 +
5380 +       /* 64-bit subtract - gcc just messes up with long longs */
5381 +       __asm__("subl %2,%0\n\t"
5382 +               "sbbl %3,%1"
5383 +               :"=a" (tsc_endlow), "=d" (tsc_endhigh)
5384 +               :"g" (tsc_startlow), "g" (tsc_starthigh),
5385 +                "0" (tsc_endlow), "1" (tsc_endhigh));
5386 +
5387 +       /* Error: ECPUTOOFAST */
5388 +       if (tsc_endhigh)
5389 +               goto bad_calibration;
5390 +
5391 +       /* Error: ECPUTOOSLOW */
5392 +       if (tsc_endlow <= CALIBRATE_TIME_HPET)
5393 +               goto bad_calibration;
5394 +
5395 +       ASM_DIV64_REG(result, remain, tsc_endlow, 0, CALIBRATE_TIME_HPET);
5396 +       if (remain > (tsc_endlow >> 1))
5397 +               result++; /* rounding the result */
5398 +
5399 +       ASM_DIV64_REG(tsc_hpet_quotient, remain, tsc_endlow, 0,
5400 +                       CALIBRATE_CNT_HPET);
5401 +       if (remain > (tsc_endlow >> 1))
5402 +               tsc_hpet_quotient++; /* rounding the result */
5403 +
5404 +       return result;
5405 +bad_calibration:
5406 +       /*
5407 +        * the CPU was so fast/slow that the quotient wouldn't fit in
5408 +        * 32 bits..
5409 +        */
5410 +       return 0;
5411 +}
5412 +
5413 +static int __init init_hpet(char* override)
5414 +{
5415 +       unsigned long result, remain;
5416 +
5417 +       /* check clock override */
5418 +       if (override[0] && strncmp(override,"hpet",4))
5419 +               return -ENODEV;
5420 +
5421 +       if (!is_hpet_enabled())
5422 +               return -ENODEV;
5423 +
5424 +       printk("Using HPET for gettimeofday\n");
5425 +       if (cpu_has_tsc) {
5426 +               unsigned long tsc_quotient = calibrate_tsc();
5427 +               if (tsc_quotient) {
5428 +                       /* report CPU clock rate in Hz.
5429 +                        * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
5430 +                        * clock/second. Our precision is about 100 ppm.
5431 +                        */
5432 +                       {       unsigned long eax=0, edx=1000;
5433 +                               ASM_DIV64_REG(cpu_khz, edx, tsc_quotient,
5434 +                                               eax, edx);
5435 +                               printk("Detected %lu.%03lu MHz processor.\n",
5436 +                                       cpu_khz / 1000, cpu_khz % 1000);
5437 +                       }
5438 +                       set_cyc2ns_scale(cpu_khz/1000);
5439 +               }
5440 +       }
5441 +
5442 +       /*
5443 +        * Math to calculate hpet to usec multiplier
5444 +        * Look for the comments at get_offset_hpet()
5445 +        */
5446 +       ASM_DIV64_REG(result, remain, hpet_tick, 0, KERNEL_TICK_USEC);
5447 +       if (remain > (hpet_tick >> 1))
5448 +               result++; /* rounding the result */
5449 +       hpet_usec_quotient = result;
5450 +
5451 +       return 0;
5452 +}
5453 +
5454 +/************************************************************/
5455 +
5456 +/* tsc timer_opts struct */
5457 +struct timer_opts timer_hpet = {
5458 +       .init =                 init_hpet,
5459 +       .mark_offset =          mark_offset_hpet,
5460 +       .get_offset =           get_offset_hpet,
5461 +       .monotonic_clock =      monotonic_clock_hpet,
5462 +       .delay =                delay_hpet,
5463 +};
5464 diff -Nru a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
5465 --- a/arch/i386/kernel/timers/timer_tsc.c       Mon Aug 18 06:40:02 2003
5466 +++ b/arch/i386/kernel/timers/timer_tsc.c       Sun Aug 31 16:15:21 2003
5467 @@ -19,9 +19,18 @@
5468  #include "io_ports.h"
5469  #include "mach_timer.h"
5470  
5471 +#include <asm/hpet.h>
5472 +
5473 +#ifdef CONFIG_HPET_TIMER
5474 +static unsigned long hpet_usec_quotient;
5475 +static unsigned long hpet_last;
5476 +struct timer_opts timer_tsc;
5477 +#endif
5478 +
5479  int tsc_disable __initdata = 0;
5480  
5481  extern spinlock_t i8253_lock;
5482 +extern volatile unsigned long jiffies;
5483  
5484  static int use_tsc;
5485  /* Number of usecs that the last interrupt was delayed */
5486 @@ -232,7 +241,7 @@
5487  
5488  #define CALIBRATE_TIME (5 * 1000020/HZ)
5489  
5490 -unsigned long __init calibrate_tsc(void)
5491 +static unsigned long __init calibrate_tsc(void)
5492  {
5493         mach_prepare_counter();
5494  
5495 @@ -282,6 +291,107 @@
5496         return 0;
5497  }
5498  
5499 +#ifdef CONFIG_HPET_TIMER
5500 +static void mark_offset_tsc_hpet(void)
5501 +{
5502 +       unsigned long long this_offset, last_offset;
5503 +       unsigned long offset, temp, hpet_current;
5504 +
5505 +       write_lock(&monotonic_lock);
5506 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
5507 +       /*
5508 +        * It is important that these two operations happen almost at
5509 +        * the same time. We do the RDTSC stuff first, since it's
5510 +        * faster. To avoid any inconsistencies, we need interrupts
5511 +        * disabled locally.
5512 +        */
5513 +       /*
5514 +        * Interrupts are just disabled locally since the timer irq
5515 +        * has the SA_INTERRUPT flag set. -arca
5516 +        */
5517 +       /* read Pentium cycle counter */
5518 +
5519 +       hpet_current = hpet_readl(HPET_COUNTER);
5520 +       rdtsc(last_tsc_low, last_tsc_high);
5521 +
5522 +       /* lost tick compensation */
5523 +       offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
5524 +       if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
5525 +               int lost_ticks = (offset - hpet_last) / hpet_tick;
5526 +               jiffies += lost_ticks;
5527 +       }
5528 +       hpet_last = hpet_current;
5529 +
5530 +       /* update the monotonic base value */
5531 +       this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
5532 +       monotonic_base += cycles_2_ns(this_offset - last_offset);
5533 +       write_unlock(&monotonic_lock);
5534 +
5535 +       /* calculate delay_at_last_interrupt */
5536 +       /*
5537 +        * Time offset = (hpet delta) * ( usecs per HPET clock )
5538 +        *             = (hpet delta) * ( usecs per tick / HPET clocks per tick)
5539 +        *             = (hpet delta) * ( hpet_usec_quotient ) / (2^32)
5540 +        * Where,
5541 +        * hpet_usec_quotient = (2^32 * usecs per tick)/HPET clocks per tick
5542 +        */
5543 +       delay_at_last_interrupt = hpet_current - offset;
5544 +       ASM_MUL64_REG(temp, delay_at_last_interrupt,
5545 +                       hpet_usec_quotient, delay_at_last_interrupt);
5546 +}
5547 +
5548 +/* ------ Calibrate the TSC based on HPET timer -------
5549 + * Return 2^32 * (1 / (TSC clocks per usec)) for do_fast_gettimeoffset().
5550 + * calibrate_tsc() calibrates the processor TSC by comparing
5551 + * it to the HPET timer of known frequency.
5552 + * Too much 64-bit arithmetic here to do this cleanly in C
5553 + */
5554 +
5555 +#define CALIBRATE_CNT_HPET     (5 * hpet_tick)
5556 +#define CALIBRATE_TIME_HPET    (5 * KERNEL_TICK_USEC)
5557 +
5558 +unsigned long __init calibrate_tsc_hpet(void)
5559 +{
5560 +       unsigned long tsc_startlow, tsc_starthigh;
5561 +       unsigned long tsc_endlow, tsc_endhigh;
5562 +       unsigned long hpet_start, hpet_end;
5563 +       unsigned long result, remain;
5564 +
5565 +       hpet_start = hpet_readl(HPET_COUNTER);
5566 +       rdtsc(tsc_startlow, tsc_starthigh);
5567 +       do {
5568 +               hpet_end = hpet_readl(HPET_COUNTER);
5569 +       } while ((hpet_end - hpet_start) < CALIBRATE_CNT_HPET);
5570 +       rdtsc(tsc_endlow, tsc_endhigh);
5571 +
5572 +       /* 64-bit subtract - gcc just messes up with long longs */
5573 +       __asm__("subl %2,%0\n\t"
5574 +               "sbbl %3,%1"
5575 +               :"=a" (tsc_endlow), "=d" (tsc_endhigh)
5576 +               :"g" (tsc_startlow), "g" (tsc_starthigh),
5577 +                "0" (tsc_endlow), "1" (tsc_endhigh));
5578 +
5579 +       /* Error: ECPUTOOFAST */
5580 +       if (tsc_endhigh)
5581 +               goto bad_calibration;
5582 +
5583 +       /* Error: ECPUTOOSLOW */
5584 +       if (tsc_endlow <= CALIBRATE_TIME_HPET)
5585 +               goto bad_calibration;
5586 +
5587 +       ASM_DIV64_REG(result, remain, tsc_endlow, 0, CALIBRATE_TIME_HPET);
5588 +       if (remain > (tsc_endlow >> 1))
5589 +               result++; /* rounding the result */
5590 +
5591 +       return result;
5592 +bad_calibration:
5593 +       /*
5594 +        * the CPU was so fast/slow that the quotient wouldn't fit in
5595 +        * 32 bits..
5596 +        */
5597 +       return 0;
5598 +}
5599 +#endif
5600  
5601  #ifdef CONFIG_CPU_FREQ
5602  static unsigned int  ref_freq = 0;
5603 @@ -333,8 +443,16 @@
5604  {
5605  
5606         /* check clock override */
5607 -       if (override[0] && strncmp(override,"tsc",3))
5608 +       if (override[0] && strncmp(override,"tsc",3)) {
5609 +#ifdef CONFIG_HPET_TIMER
5610 +               if (is_hpet_enabled()) {
5611 +                       printk(KERN_ERR "Warning: clock= override failed. Defaulting to tsc\n");
5612 +               } else
5613 +#endif
5614 +               {
5615                         return -ENODEV;
5616 +               }
5617 +       }
5618  
5619         /*
5620          * If we have APM enabled or the CPU clock speed is variable
5621 @@ -368,7 +486,29 @@
5622         count2 = LATCH; /* initialize counter for mark_offset_tsc() */
5623  
5624         if (cpu_has_tsc) {
5625 -               unsigned long tsc_quotient = calibrate_tsc();
5626 +               unsigned long tsc_quotient;
5627 +#ifdef CONFIG_HPET_TIMER
5628 +               if (is_hpet_enabled()){
5629 +                       unsigned long result, remain;
5630 +                       printk("Using TSC for gettimeofday\n");
5631 +                       tsc_quotient = calibrate_tsc_hpet();
5632 +                       timer_tsc.mark_offset = &mark_offset_tsc_hpet;
5633 +                       /*
5634 +                        * Math to calculate hpet to usec multiplier
5635 +                        * Look for the comments at get_offset_tsc_hpet()
5636 +                        */
5637 +                       ASM_DIV64_REG(result, remain, hpet_tick,
5638 +                                       0, KERNEL_TICK_USEC);
5639 +                       if (remain > (hpet_tick >> 1))
5640 +                               result++; /* rounding the result */
5641 +
5642 +                       hpet_usec_quotient = result;
5643 +               } else
5644 +#endif
5645 +               {
5646 +                       tsc_quotient = calibrate_tsc();
5647 +               }
5648 +
5649                 if (tsc_quotient) {
5650                         fast_gettimeoffset_quotient = tsc_quotient;
5651                         use_tsc = 1;
5652 diff -Nru a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
5653 --- a/arch/i386/kernel/traps.c  Thu Jun 26 12:11:29 2003
5654 +++ b/arch/i386/kernel/traps.c  Tue Sep  2 00:37:21 2003
5655 @@ -745,7 +745,8 @@
5656   * Careful.. There are problems with IBM-designed IRQ13 behaviour.
5657   * Don't touch unless you *really* know how it works.
5658   *
5659 - * Must be called with kernel preemption disabled.
5660 + * Must be called with kernel preemption disabled (in this case,
5661 + * local interrupts are disabled at the call-site in entry.S).
5662   */
5663  asmlinkage void math_state_restore(struct pt_regs regs)
5664  {
5665 diff -Nru a/arch/i386/mach-visws/mpparse.c b/arch/i386/mach-visws/mpparse.c
5666 --- a/arch/i386/mach-visws/mpparse.c    Mon Aug 18 19:46:23 2003
5667 +++ b/arch/i386/mach-visws/mpparse.c    Sun Aug 31 16:14:17 2003
5668 @@ -38,7 +38,7 @@
5669  void __init MP_processor_info (struct mpc_config_processor *m)
5670  {
5671         int ver, logical_apicid;
5672 -       cpumask_t apic_cpus;
5673 +       physid_mask_t apic_cpus;
5674         
5675         if (!(m->mpc_cpuflag & CPU_ENABLED))
5676                 return;
5677 diff -Nru a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
5678 --- a/arch/i386/mach-voyager/voyager_smp.c      Mon Aug 18 19:46:23 2003
5679 +++ b/arch/i386/mach-voyager/voyager_smp.c      Sun Aug 31 16:14:42 2003
5680 @@ -130,7 +130,7 @@
5681  {
5682         int cpu;
5683  
5684 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
5685 +       for_each_cpu(cpu, cpu_online_map) {
5686                 if(cpuset & (1<<cpu)) {
5687  #ifdef VOYAGER_DEBUG
5688                         if(!cpu_isset(cpu, cpu_online_map))
5689 @@ -874,10 +874,10 @@
5690  asmlinkage void 
5691  smp_invalidate_interrupt(void)
5692  {
5693 -       __u8 cpu = get_cpu();
5694 +       __u8 cpu = smp_processor_id();
5695  
5696 -       if (!(smp_invalidate_needed & (1UL << cpu)))
5697 -               goto out;
5698 +       if (!test_bit(cpu, &smp_invalidate_needed))
5699 +               return;
5700         /* This will flood messages.  Don't uncomment unless you see
5701          * Problems with cross cpu invalidation
5702         VDEBUG(("VOYAGER SMP: CPU%d received INVALIDATE_CPI\n",
5703 @@ -893,9 +893,9 @@
5704                 } else
5705                         leave_mm(cpu);
5706         }
5707 -       smp_invalidate_needed |= 1UL << cpu;
5708 - out:
5709 -       put_cpu_no_resched();
5710 +       smp_mb__before_clear_bit();
5711 +       clear_bit(cpu, &smp_invalidate_needed);
5712 +       smp_mb__after_clear_bit();
5713  }
5714  
5715  /* All the new flush operations for 2.4 */
5716 @@ -929,6 +929,7 @@
5717         send_CPI(cpumask, VIC_INVALIDATE_CPI);
5718  
5719         while (smp_invalidate_needed) {
5720 +               mb();
5721                 if(--stuck == 0) {
5722                         printk("***WARNING*** Stuck doing invalidate CPI (CPU%d)\n", smp_processor_id());
5723                         break;
5724 @@ -1464,7 +1465,7 @@
5725         cpuset &= 0xff;         /* only first 8 CPUs vaild for VIC CPI */
5726         if(cpuset == 0)
5727                 return;
5728 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
5729 +       for_each_cpu(cpu, cpu_online_map) {
5730                 if(cpuset & (1<<cpu))
5731                         set_bit(cpi, &vic_cpi_mailbox[cpu]);
5732         }
5733 @@ -1578,7 +1579,7 @@
5734         VDEBUG(("VOYAGER: enable_vic_irq(%d) CPU%d affinity 0x%lx\n",
5735                 irq, cpu, cpu_irq_affinity[cpu]));
5736         spin_lock_irqsave(&vic_irq_lock, flags);
5737 -       for_each_cpu(real_cpu, mk_cpumask_const(cpu_online_map)) {
5738 +       for_each_cpu(real_cpu, cpu_online_map) {
5739                 if(!(voyager_extended_vic_processors & (1<<real_cpu)))
5740                         continue;
5741                 if(!(cpu_irq_affinity[real_cpu] & mask)) {
5742 @@ -1723,7 +1724,7 @@
5743  
5744                         printk("VOYAGER SMP: CPU%d lost interrupt %d\n",
5745                                cpu, irq);
5746 -                       for_each_cpu(real_cpu, mk_cpumask_const(mask)) {
5747 +                       for_each_cpu(real_cpu, mask) {
5748  
5749                                 outb(VIC_CPU_MASQUERADE_ENABLE | real_cpu,
5750                                      VIC_PROCESSOR_ID);
5751 @@ -1808,7 +1809,7 @@
5752                  * bus) */
5753                 return;
5754  
5755 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
5756 +       for_each_cpu(cpu, cpu_online_map) {
5757                 unsigned long cpu_mask = 1 << cpu;
5758                 
5759                 if(cpu_mask & real_mask) {
5760 @@ -1874,7 +1875,7 @@
5761         int old_cpu = smp_processor_id(), cpu;
5762  
5763         /* dump the interrupt masks of each processor */
5764 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
5765 +       for_each_cpu(cpu, cpu_online_map) {
5766                 __u16 imr, isr, irr;
5767                 unsigned long flags;
5768  
5769 diff -Nru a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
5770 --- a/arch/i386/oprofile/nmi_int.c      Thu Jul 17 17:21:06 2003
5771 +++ b/arch/i386/oprofile/nmi_int.c      Fri Aug 29 09:02:20 2003
5772 @@ -364,10 +364,21 @@
5773         switch (vendor) {
5774                 case X86_VENDOR_AMD:
5775                         /* Needs to be at least an Athlon (or hammer in 32bit mode) */
5776 -                       if (family < 6)
5777 +
5778 +                       switch (family) {
5779 +                       default:
5780                                 return -ENODEV;
5781 -                       model = &op_athlon_spec;
5782 -                       nmi_ops.cpu_type = "i386/athlon";
5783 +                       case 6:
5784 +                               model = &op_athlon_spec;
5785 +                               nmi_ops.cpu_type = "i386/athlon";
5786 +                               break;
5787 +#if defined(CONFIG_X86_64)
5788 +                       case 0xf:
5789 +                               model = &op_athlon_spec;
5790 +                               nmi_ops.cpu_type = "x86-64/hammer";
5791 +                               break;
5792 +#endif /* CONFIG_X86_64 */
5793 +                       }
5794                         break;
5795   
5796  #if !defined(CONFIG_X86_64)
5797 diff -Nru a/arch/i386/pci/common.c b/arch/i386/pci/common.c
5798 --- a/arch/i386/pci/common.c    Mon Jun 23 12:31:05 2003
5799 +++ b/arch/i386/pci/common.c    Mon Sep  1 17:58:12 2003
5800 @@ -152,7 +152,7 @@
5801         pci_cache_line_size = 32 >> 2;
5802         if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD)
5803                 pci_cache_line_size = 64 >> 2;  /* K7 & K8 */
5804 -       else if (c->x86 > 6)
5805 +       else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL)
5806                 pci_cache_line_size = 128 >> 2; /* P4 */
5807  
5808         pcibios_resource_survey();
5809 diff -Nru a/arch/ia64/Kconfig b/arch/ia64/Kconfig
5810 --- a/arch/ia64/Kconfig Fri Aug  8 10:02:34 2003
5811 +++ b/arch/ia64/Kconfig Sun Aug 31 16:14:22 2003
5812 @@ -234,8 +234,8 @@
5813  endchoice
5814  
5815  config DISCONTIGMEM
5816 -       bool "Discontiguous memory support" if (IA64_DIG && NUMA)
5817 -       default y if IA64_SGI_SN2 || IA64_GENERIC
5818 +       bool "Discontiguous memory support" if (IA64_DIG || IA64_SGI_SN2 || IA64_GENERIC) && NUMA
5819 +       default y if (IA64_SGI_SN2 || IA64_GENERIC) && NUMA
5820         help
5821           Say Y to support efficient handling of discontiguous physical memory,
5822           for architectures which are either NUMA (Non-Uniform Memory Access)
5823 @@ -296,29 +296,6 @@
5824         help
5825           If you are compiling a kernel that will run under SGI's IA-64
5826           simulator (Medusa) then say Y, otherwise say N.
5827 -
5828 -# On IA-64, we always want an ELF /proc/kcore.
5829 -config KCORE_ELF
5830 -       bool
5831 -       default y
5832 -       ---help---
5833 -         If you enabled support for /proc file system then the file
5834 -         /proc/kcore will contain the kernel core image. This can be used
5835 -         in gdb:
5836 -
5837 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
5838 -
5839 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
5840 -         /proc/kcore appear in ELF core format as defined by the Executable
5841 -         and Linking Format specification. Selecting A.OUT will choose the
5842 -         old "a.out" format which may be necessary for some old versions
5843 -         of binutils or on some architectures.
5844 -
5845 -         This is especially useful if you have compiled the kernel with the
5846 -         "-g" option to preserve debugging information. It is mainly used
5847 -         for examining kernel data structures on the live kernel so if you
5848 -         don't understand what this means or are not a kernel hacker, just
5849 -         leave it at its default value ELF.
5850  
5851  config FORCE_MAX_ZONEORDER
5852         int
5853 diff -Nru a/arch/ia64/Makefile b/arch/ia64/Makefile
5854 --- a/arch/ia64/Makefile        Tue Aug 19 23:13:39 2003
5855 +++ b/arch/ia64/Makefile        Sat Aug 23 10:28:23 2003
5856 @@ -70,6 +70,8 @@
5857  
5858  .PHONY: boot compressed check
5859  
5860 +all: compressed
5861 +
5862  compressed: vmlinux.gz
5863  
5864  vmlinux.gz: vmlinux
5865 @@ -100,6 +102,6 @@
5866  
5867  
5868  define archhelp
5869 -  echo '  compressed   - Build compressed kernel image'
5870 +  echo '* compressed   - Build compressed kernel image'
5871    echo '  boot         - Build vmlinux and bootloader for Ski simulator'
5872  endef
5873 diff -Nru a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
5874 --- a/arch/ia64/hp/common/sba_iommu.c   Sun Jul 27 12:01:33 2003
5875 +++ b/arch/ia64/hp/common/sba_iommu.c   Sun Aug 31 16:14:08 2003
5876 @@ -1935,10 +1935,10 @@
5877  }
5878  
5879  static struct acpi_driver acpi_sba_ioc_driver = {
5880 -       name:           "IOC IOMMU Driver",
5881 -       ids:            "HWP0001,HWP0004",
5882 -       ops: {
5883 -               add:    acpi_sba_ioc_add,
5884 +       .name           = "IOC IOMMU Driver",
5885 +       .ids            = "HWP0001,HWP0004",
5886 +       .ops            = {
5887 +               .add    = acpi_sba_ioc_add,
5888         },
5889  };
5890  
5891 diff -Nru a/arch/ia64/ia32/ia32_ioctl.c b/arch/ia64/ia32/ia32_ioctl.c
5892 --- a/arch/ia64/ia32/ia32_ioctl.c       Thu Aug  7 17:00:00 2003
5893 +++ b/arch/ia64/ia32/ia32_ioctl.c       Sun Aug 31 16:14:44 2003
5894 @@ -70,7 +70,7 @@
5895  #define IOCTL_TABLE_START \
5896         struct ioctl_trans ioctl_start[] = {
5897  #define IOCTL_TABLE_END \
5898 -       }; struct ioctl_trans ioctl_end[0];
5899 +       };
5900  
5901  IOCTL_TABLE_START
5902  HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
5903 @@ -79,3 +79,5 @@
5904  #include "compat_ioctl.c"
5905  #include <linux/compat_ioctl.h>
5906  IOCTL_TABLE_END
5907 +
5908 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
5909 diff -Nru a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
5910 --- a/arch/ia64/ia32/sys_ia32.c Tue Aug 19 23:13:39 2003
5911 +++ b/arch/ia64/ia32/sys_ia32.c Mon Aug 25 14:45:43 2003
5912 @@ -76,7 +76,6 @@
5913  
5914  #define OFFSET4K(a)            ((a) & 0xfff)
5915  #define PAGE_START(addr)       ((addr) & PAGE_MASK)
5916 -#define PAGE_OFF(addr)         ((addr) & ~PAGE_MASK)
5917  
5918  #define high2lowuid(uid) ((uid) > 65535 ? 65534 : (uid))
5919  #define high2lowgid(gid) ((gid) > 65535 ? 65534 : (gid))
5920 @@ -170,9 +169,9 @@
5921                 current->thread.map_base  = old_map_base;
5922                 current->thread.task_size = old_task_size;
5923                 set_fs(USER_DS);        /* establish new task-size as the address-limit */
5924 -         out:
5925 -               kfree(av);
5926         }
5927 +  out:
5928 +       kfree(av);
5929         return r;
5930  }
5931  
5932 @@ -271,11 +270,11 @@
5933  
5934         if (old_prot) {
5935                 /* copy back the old page contents.  */
5936 -               if (PAGE_OFF(start))
5937 -                       copy_to_user((void *) PAGE_START(start), page, PAGE_OFF(start));
5938 -               if (PAGE_OFF(end))
5939 -                       copy_to_user((void *) end, page + PAGE_OFF(end),
5940 -                                    PAGE_SIZE - PAGE_OFF(end));
5941 +               if (offset_in_page(start))
5942 +                       copy_to_user((void *) PAGE_START(start), page, offset_in_page(start));
5943 +               if (offset_in_page(end))
5944 +                       copy_to_user((void *) end, page + offset_in_page(end),
5945 +                                    PAGE_SIZE - offset_in_page(end));
5946         }
5947  
5948         if (!(flags & MAP_ANONYMOUS)) {
5949 @@ -330,7 +329,7 @@
5950                                        "%s(%d): emulate_mmap() can't share tail (end=0x%lx)\n",
5951                                        current->comm, current->pid, end);
5952                         ret = mmap_subpage(file, max(start, PAGE_START(end)), end, prot, flags,
5953 -                                          (off + len) - PAGE_OFF(end));
5954 +                                          (off + len) - offset_in_page(end));
5955                         if (IS_ERR((void *) ret))
5956                                 return ret;
5957                         pend -= PAGE_SIZE;
5958 @@ -347,14 +346,14 @@
5959                 tmp = arch_get_unmapped_area(file, pstart - fudge, pend - pstart, 0, flags);
5960                 if (tmp != pstart) {
5961                         pstart = tmp;
5962 -                       start = pstart + PAGE_OFF(off); /* make start congruent with off */
5963 +                       start = pstart + offset_in_page(off);   /* make start congruent with off */
5964                         end = start + len;
5965                         pend = PAGE_ALIGN(end);
5966                 }
5967         }
5968  
5969         poff = off + (pstart - start);  /* note: (pstart - start) may be negative */
5970 -       is_congruent = (flags & MAP_ANONYMOUS) || (PAGE_OFF(poff) == 0);
5971 +       is_congruent = (flags & MAP_ANONYMOUS) || (offset_in_page(poff) == 0);
5972  
5973         if ((flags & MAP_SHARED) && !is_congruent)
5974                 printk(KERN_INFO "%s(%d): emulate_mmap() can't share contents of incongruent mmap "
5975 @@ -588,7 +587,7 @@
5976  
5977         down(&ia32_mmap_sem);
5978         {
5979 -               if (PAGE_OFF(start)) {
5980 +               if (offset_in_page(start)) {
5981                         /* start address is 4KB aligned but not page aligned. */
5982                         retval = mprotect_subpage(PAGE_START(start), prot);
5983                         if (retval < 0)
5984 @@ -599,7 +598,7 @@
5985                                 goto out;       /* retval is already zero... */
5986                 }
5987  
5988 -               if (PAGE_OFF(end)) {
5989 +               if (offset_in_page(end)) {
5990                         /* end address is 4KB aligned but not page aligned. */
5991                         retval = mprotect_subpage(PAGE_START(end), prot);
5992                         if (retval < 0)
5993 diff -Nru a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
5994 --- a/arch/ia64/kernel/acpi.c   Wed Aug  6 12:37:03 2003
5995 +++ b/arch/ia64/kernel/acpi.c   Tue Aug 26 15:09:18 2003
5996 @@ -130,7 +130,7 @@
5997         int vector = -1;
5998  
5999         if (int_type < ACPI_MAX_PLATFORM_INTERRUPTS) {
6000 -               /* correctable platform error interrupt */
6001 +               /* corrected platform error interrupt */
6002                 vector = platform_intr_list[int_type];
6003         } else
6004                 printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n");
6005 diff -Nru a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
6006 --- a/arch/ia64/kernel/entry.S  Sat Aug 16 17:16:48 2003
6007 +++ b/arch/ia64/kernel/entry.S  Mon Aug 25 14:47:33 2003
6008 @@ -1473,7 +1473,7 @@
6009         data8 sys_clock_nanosleep
6010         data8 sys_fstatfs64
6011         data8 sys_statfs64
6012 -       data8 ia64_ni_syscall
6013 +       data8 sys_fadvise64_64
6014         data8 ia64_ni_syscall                   // 1260
6015         data8 ia64_ni_syscall
6016         data8 ia64_ni_syscall
6017 diff -Nru a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S
6018 --- a/arch/ia64/kernel/fsys.S   Thu Jul 10 18:16:32 2003
6019 +++ b/arch/ia64/kernel/fsys.S   Mon Aug 25 14:47:33 2003
6020 @@ -678,9 +678,9 @@
6021         data8 0                         // clock_gettime
6022         data8 0                         // clock_getres         // 1255
6023         data8 0                         // clock_nanosleep
6024 -       data8 0
6025 -       data8 0
6026 -       data8 0
6027 +       data8 0                         // fstatfs64
6028 +       data8 0                         // statfs64
6029 +       data8 0                         // fadvise64_64
6030         data8 0                                                 // 1260
6031         data8 0
6032         data8 0
6033 diff -Nru a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
6034 --- a/arch/ia64/kernel/mca.c    Tue Aug 19 23:13:39 2003
6035 +++ b/arch/ia64/kernel/mca.c    Tue Aug 26 13:42:37 2003
6036 @@ -1145,7 +1145,7 @@
6037  
6038         ia64_mca_cmc_int_handler(cpe_irq, arg, ptregs);
6039  
6040 -       for (++cpuid ; !cpu_online(cpuid) && cpuid < NR_CPUS ; cpuid++);
6041 +       for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++);
6042  
6043         if (cpuid < NR_CPUS) {
6044                 platform_send_ipi(cpuid, IA64_CMCP_VECTOR, IA64_IPI_DM_INT, 0);
6045 @@ -1225,7 +1225,7 @@
6046  
6047         ia64_mca_cpe_int_handler(cpe_irq, arg, ptregs);
6048  
6049 -       for (++cpuid ; !cpu_online(cpuid) && cpuid < NR_CPUS ; cpuid++);
6050 +       for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++);
6051  
6052         if (cpuid < NR_CPUS) {
6053                 platform_send_ipi(cpuid, IA64_CPEP_VECTOR, IA64_IPI_DM_INT, 0);
6054 diff -Nru a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
6055 --- a/arch/ia64/kernel/perfmon.c        Thu Aug 21 15:45:04 2003
6056 +++ b/arch/ia64/kernel/perfmon.c        Sun Aug 31 16:14:08 2003
6057 @@ -2109,7 +2109,7 @@
6058         return 1;
6059  }
6060  static struct dentry_operations pfmfs_dentry_operations = {
6061 -       d_delete:       pfmfs_delete_dentry,
6062 +       .d_delete       = pfmfs_delete_dentry,
6063  };
6064  
6065  
6066 diff -Nru a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
6067 --- a/arch/ia64/kernel/smpboot.c        Mon Aug 18 19:46:23 2003
6068 +++ b/arch/ia64/kernel/smpboot.c        Fri Aug 22 15:20:52 2003
6069 @@ -560,7 +560,7 @@
6070                 if (cpu_online(cpu))
6071                         bogosum += cpu_data(cpu)->loops_per_jiffy;
6072  
6073 -       printk(KERN_INFO "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
6074 +       printk(KERN_INFO "Total of %lu processors activated (%lu.%02lu BogoMIPS).\n",
6075                num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100);
6076  }
6077  
6078 diff -Nru a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
6079 --- a/arch/ia64/kernel/sys_ia64.c       Wed Jul  9 09:56:58 2003
6080 +++ b/arch/ia64/kernel/sys_ia64.c       Mon Aug 25 14:45:43 2003
6081 @@ -242,7 +242,7 @@
6082  asmlinkage unsigned long
6083  sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, long off)
6084  {
6085 -       if ((off & ~PAGE_MASK) != 0)
6086 +       if (offset_in_page(off) != 0)
6087                 return -EINVAL;
6088  
6089         addr = do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
6090 diff -Nru a/arch/ia64/lib/Makefile b/arch/ia64/lib/Makefile
6091 --- a/arch/ia64/lib/Makefile    Fri Jun 20 12:48:24 2003
6092 +++ b/arch/ia64/lib/Makefile    Mon Aug 25 09:56:27 2003
6093 @@ -14,9 +14,6 @@
6094  lib-$(CONFIG_PERFMON)  += carta_random.o
6095  lib-$(CONFIG_MD_RAID5) += xor.o
6096  
6097 -IGNORE_FLAGS_OBJS =    __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \
6098 -                       __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o
6099 -
6100  AFLAGS___divdi3.o      =
6101  AFLAGS___udivdi3.o     = -DUNSIGNED
6102  AFLAGS___moddi3.o      =            -DMODULO
6103 @@ -27,26 +24,26 @@
6104  AFLAGS___modsi3.o      =            -DMODULO
6105  AFLAGS___umodsi3.o     = -DUNSIGNED -DMODULO
6106  
6107 -$(obj)/__divdi3.o: $(src)/idiv64.S
6108 -       $(cmd_as_o_S)
6109 +$(obj)/__divdi3.o: $(src)/idiv64.S FORCE
6110 +       $(call if_changed_dep,as_o_S)
6111  
6112 -$(obj)/__udivdi3.o: $(src)/idiv64.S
6113 -       $(cmd_as_o_S)
6114 +$(obj)/__udivdi3.o: $(src)/idiv64.S FORCE
6115 +       $(call if_changed_dep,as_o_S)
6116  
6117 -$(obj)/__moddi3.o: $(src)/idiv64.S
6118 -       $(cmd_as_o_S)
6119 +$(obj)/__moddi3.o: $(src)/idiv64.S FORCE
6120 +       $(call if_changed_dep,as_o_S)
6121  
6122 -$(obj)/__umoddi3.o: $(src)/idiv64.S
6123 -       $(cmd_as_o_S)
6124 +$(obj)/__umoddi3.o: $(src)/idiv64.S FORCE
6125 +       $(call if_changed_dep,as_o_S)
6126  
6127 -$(obj)/__divsi3.o: $(src)/idiv32.S
6128 -       $(cmd_as_o_S)
6129 +$(obj)/__divsi3.o: $(src)/idiv32.S FORCE
6130 +       $(call if_changed_dep,as_o_S)
6131  
6132 -$(obj)/__udivsi3.o: $(src)/idiv32.S
6133 -       $(cmd_as_o_S)
6134 +$(obj)/__udivsi3.o: $(src)/idiv32.S FORCE
6135 +       $(call if_changed_dep,as_o_S)
6136  
6137 -$(obj)/__modsi3.o: $(src)/idiv32.S
6138 -       $(cmd_as_o_S)
6139 +$(obj)/__modsi3.o: $(src)/idiv32.S FORCE
6140 +       $(call if_changed_dep,as_o_S)
6141  
6142 -$(obj)/__umodsi3.o: $(src)/idiv32.S
6143 -       $(cmd_as_o_S)
6144 +$(obj)/__umodsi3.o: $(src)/idiv32.S FORCE
6145 +       $(call if_changed_dep,as_o_S)
6146 diff -Nru a/arch/ia64/mm/numa.c b/arch/ia64/mm/numa.c
6147 --- a/arch/ia64/mm/numa.c       Mon Sep 30 06:38:28 2002
6148 +++ b/arch/ia64/mm/numa.c       Thu Aug 21 05:02:28 2003
6149 @@ -42,5 +42,5 @@
6150                     paddr < node_memblk[i].start_paddr + node_memblk[i].size)
6151                         break;
6152  
6153 -       return (i < num_memblks) ? node_memblk[i].nid : -1;
6154 +       return (i < num_memblks) ? node_memblk[i].nid : (num_memblks ? -1 : 0);
6155  }
6156 diff -Nru a/arch/ia64/sn/io/drivers/ioconfig_bus.c b/arch/ia64/sn/io/drivers/ioconfig_bus.c
6157 --- a/arch/ia64/sn/io/drivers/ioconfig_bus.c    Mon May 19 05:42:35 2003
6158 +++ b/arch/ia64/sn/io/drivers/ioconfig_bus.c    Sun Aug 31 16:14:08 2003
6159 @@ -346,9 +346,9 @@
6160  }
6161  
6162  struct file_operations ioconfig_bus_fops = {
6163 -       ioctl:ioconfig_bus_ioctl,
6164 -       open:ioconfig_bus_open,         /* open */
6165 -       release:ioconfig_bus_close      /* release */
6166 +       .ioctl = ioconfig_bus_ioctl,
6167 +       .open = ioconfig_bus_open,              /* open */
6168 +       .release = ioconfig_bus_close   /* release */
6169  };
6170  
6171  
6172 diff -Nru a/arch/ia64/sn/io/sn2/shub.c b/arch/ia64/sn/io/sn2/shub.c
6173 --- a/arch/ia64/sn/io/sn2/shub.c        Mon Aug  4 10:02:37 2003
6174 +++ b/arch/ia64/sn/io/sn2/shub.c        Sun Aug 31 16:14:08 2003
6175 @@ -243,7 +243,7 @@
6176  }
6177  
6178  struct file_operations shub_mon_fops = {
6179 -               ioctl:          shubstats_ioctl,
6180 +               .ioctl          = shubstats_ioctl,
6181  };
6182  
6183  /*
6184 diff -Nru a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
6185 --- a/arch/ia64/sn/kernel/setup.c       Sat Aug 16 16:26:35 2003
6186 +++ b/arch/ia64/sn/kernel/setup.c       Sun Aug 31 16:14:08 2003
6187 @@ -117,14 +117,14 @@
6188   * VGA color display.
6189   */
6190  struct screen_info sn_screen_info = {
6191 -       orig_x:                  0,
6192 -       orig_y:                  0,
6193 -       orig_video_mode:         3,
6194 -       orig_video_cols:        80,
6195 -       orig_video_ega_bx:       3,
6196 -       orig_video_lines:       25,
6197 -       orig_video_isVGA:        1,
6198 -       orig_video_points:      16
6199 +       .orig_x                 = 0,
6200 +       .orig_y                 = 0,
6201 +       .orig_video_mode        = 3,
6202 +       .orig_video_cols        = 80,
6203 +       .orig_video_ega_bx      = 3,
6204 +       .orig_video_lines       = 25,
6205 +       .orig_video_isVGA       = 1,
6206 +       .orig_video_points      = 16
6207  };
6208  
6209  /*
6210 diff -Nru a/arch/m68k/Kconfig b/arch/m68k/Kconfig
6211 --- a/arch/m68k/Kconfig Sat Aug  2 14:26:16 2003
6212 +++ b/arch/m68k/Kconfig Sun Aug 31 16:14:22 2003
6213 @@ -342,40 +342,6 @@
6214  
6215  menu "General setup"
6216  
6217 -choice
6218 -       prompt "Kernel core (/proc/kcore) format"
6219 -       depends on PROC_FS
6220 -       default KCORE_ELF
6221 -
6222 -config KCORE_ELF
6223 -       bool "ELF"
6224 -       ---help---
6225 -         If you enabled support for /proc file system then the file
6226 -         /proc/kcore will contain the kernel core image. This can be used
6227 -         in gdb:
6228 -
6229 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
6230 -
6231 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
6232 -         /proc/kcore appear in ELF core format as defined by the Executable
6233 -         and Linking Format specification. Selecting A.OUT will choose the
6234 -         old "a.out" format which may be necessary for some old versions
6235 -         of binutils or on some architectures.
6236 -
6237 -         This is especially useful if you have compiled the kernel with the
6238 -         "-g" option to preserve debugging information. It is mainly used
6239 -         for examining kernel data structures on the live kernel so if you
6240 -         don't understand what this means or are not a kernel hacker, just
6241 -         leave it at its default value ELF.
6242 -
6243 -config KCORE_AOUT
6244 -       bool "A.OUT"
6245 -       help
6246 -         Not necessary unless you're using a very out-of-date binutils
6247 -         version.  You probably want KCORE_ELF.
6248 -
6249 -endchoice
6250 -
6251  source "fs/Kconfig.binfmt"
6252  
6253  config ZORRO
6254 diff -Nru a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
6255 --- /dev/null   Wed Dec 31 16:00:00 1969
6256 +++ b/arch/m68k/kernel/vmlinux-std.lds  Sun Jun 15 03:46:43 2003
6257 @@ -0,0 +1,97 @@
6258 +/* ld script to make m68k Linux kernel */
6259 +
6260 +#include <asm-generic/vmlinux.lds.h>
6261 +
6262 +OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
6263 +OUTPUT_ARCH(m68k)
6264 +ENTRY(_start)
6265 +jiffies = jiffies_64 + 4;
6266 +SECTIONS
6267 +{
6268 +  . = 0x1000;
6269 +  _text = .;                   /* Text and read-only data */
6270 +  .text : {
6271 +       *(.text)
6272 +       *(.fixup)
6273 +       *(.gnu.warning)
6274 +       } = 0x4e75
6275 +
6276 +  . = ALIGN(16);               /* Exception table */
6277 +  __start___ex_table = .;
6278 +  __ex_table : { *(__ex_table) }
6279 +  __stop___ex_table = .;
6280 +
6281 +  RODATA
6282 +
6283 +  _etext = .;                  /* End of text section */
6284 +
6285 +  .data : {                    /* Data */
6286 +       *(.data)
6287 +       CONSTRUCTORS
6288 +       }
6289 +
6290 +  .bss : { *(.bss) }           /* BSS */
6291 +
6292 +  . = ALIGN(16);
6293 +  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
6294 +
6295 +  _edata = .;                  /* End of data section */
6296 +
6297 +  /* will be freed after init */
6298 +  . = ALIGN(4096);             /* Init code and data */
6299 +  __init_begin = .;
6300 +  .init.text : { 
6301 +       _sinittext = .;
6302 +       *(.init.text)
6303 +       _einittext = .;
6304 +  }
6305 +  .init.data : { *(.init.data) }
6306 +  . = ALIGN(16);
6307 +  __setup_start = .;
6308 +  .init.setup : { *(.init.setup) }
6309 +  __setup_end = .;
6310 +  __start___param = .;
6311 +  __param : { *(__param) }
6312 +  __stop___param = .;
6313 +  __initcall_start = .;
6314 +  .initcall.init : {
6315 +       *(.initcall1.init) 
6316 +       *(.initcall2.init) 
6317 +       *(.initcall3.init) 
6318 +       *(.initcall4.init) 
6319 +       *(.initcall5.init) 
6320 +       *(.initcall6.init) 
6321 +       *(.initcall7.init)
6322 +  }
6323 +  __initcall_end = .;
6324 +  __con_initcall_start = .;
6325 +  .con_initcall.init : { *(.con_initcall.init) }
6326 +  __con_initcall_end = .;
6327 +  SECURITY_INIT
6328 +  . = ALIGN(8192);
6329 +  __initramfs_start = .;
6330 +  .init.ramfs : { *(.init.ramfs) }
6331 +  __initramfs_end = .;
6332 +  . = ALIGN(8192);
6333 +  __init_end = .;
6334 +
6335 +  .data.init_task : { *(.data.init_task) }     /* The initial task and kernel stack */
6336 +
6337 +  _end = . ;
6338 +
6339 +  /* Sections to be discarded */
6340 +  /DISCARD/ : {
6341 +       *(.exit.text)
6342 +       *(.exit.data)
6343 +       *(.exitcall.exit)
6344 +       }
6345 +
6346 +  /* Stabs debugging sections.  */
6347 +  .stab 0 : { *(.stab) }
6348 +  .stabstr 0 : { *(.stabstr) }
6349 +  .stab.excl 0 : { *(.stab.excl) }
6350 +  .stab.exclstr 0 : { *(.stab.exclstr) }
6351 +  .stab.index 0 : { *(.stab.index) }
6352 +  .stab.indexstr 0 : { *(.stab.indexstr) }
6353 +  .comment 0 : { *(.comment) }
6354 +}
6355 diff -Nru a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
6356 --- /dev/null   Wed Dec 31 16:00:00 1969
6357 +++ b/arch/m68k/kernel/vmlinux-sun3.lds Sun Jun 15 03:46:43 2003
6358 @@ -0,0 +1,97 @@
6359 +/* ld script to make m68k Linux kernel */
6360 +
6361 +#include <asm-generic/vmlinux.lds.h>
6362 +
6363 +OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
6364 +OUTPUT_ARCH(m68k)
6365 +ENTRY(_start)
6366 +jiffies = jiffies_64 + 4;
6367 +SECTIONS
6368 +{
6369 +  . = 0xE004000;
6370 +  _text = .;                   /* Text and read-only data */
6371 +  .text : {
6372 +       *(.head)
6373 +       *(.text)
6374 +       *(.fixup)
6375 +       *(.gnu.warning)
6376 +       } = 0x4e75
6377 +       RODATA
6378 +
6379 +  _etext = .;                  /* End of text section */
6380 +
6381 +  .data : {                    /* Data */
6382 +       *(.data)
6383 +       CONSTRUCTORS
6384 +       . = ALIGN(16);          /* Exception table */
6385 +       __start___ex_table = .;
6386 +       *(__ex_table) 
6387 +       __stop___ex_table = .;
6388 +       }
6389 +  /* End of data goes *here* so that freeing init code works properly. */
6390 +  _edata = .;
6391 +
6392 +  /* will be freed after init */
6393 +  . = ALIGN(8192);     /* Init code and data */
6394 +__init_begin = .;
6395 +       .init.text : { 
6396 +               _sinittext = .;
6397 +               *(.init.text)
6398 +               _einittext = .;
6399 +       }
6400 +       .init.data : { *(.init.data) }
6401 +       . = ALIGN(16);
6402 +       __setup_start = .;
6403 +       .init.setup : { *(.init.setup) }
6404 +       __setup_end = .;
6405 +       __start___param = .;
6406 +       __param : { *(__param) }
6407 +       __stop___param = .;
6408 +       __initcall_start = .;
6409 +       .initcall.init : {
6410 +               *(.initcall1.init) 
6411 +               *(.initcall2.init) 
6412 +               *(.initcall3.init) 
6413 +               *(.initcall4.init) 
6414 +               *(.initcall5.init) 
6415 +               *(.initcall6.init) 
6416 +               *(.initcall7.init)
6417 +       }
6418 +       __initcall_end = .;
6419 +       __con_initcall_start = .;
6420 +       .con_initcall.init : { *(.con_initcall.init) }
6421 +       __con_initcall_end = .;
6422 +       SECURITY_INIT
6423 +       . = ALIGN(8192);
6424 +       __initramfs_start = .;
6425 +       .init.ramfs : { *(.init.ramfs) }
6426 +       __initramfs_end = .;
6427 +       . = ALIGN(8192);
6428 +       __init_end = .;
6429 +       .init.task : { *(init_task) }
6430 +       
6431 +
6432 +  .bss : { *(.bss) }           /* BSS */
6433 +
6434 +  _end = . ;
6435 +
6436 +  /* Sections to be discarded */
6437 +  /DISCARD/ : {
6438 +       *(.exit.text)
6439 +       *(.exit.data)
6440 +       *(.exitcall.exit)
6441 +       }
6442 +
6443 +  .crap : {
6444 +       /* Stabs debugging sections.  */
6445 +       *(.stab)
6446 +       *(.stabstr)
6447 +       *(.stab.excl)
6448 +       *(.stab.exclstr)
6449 +       *(.stab.index)
6450 +       *(.stab.indexstr)
6451 +       *(.comment)
6452 +       *(.note)
6453 +  }
6454 +
6455 +}
6456 diff -Nru a/arch/m68k/vmlinux-std.lds b/arch/m68k/vmlinux-std.lds
6457 --- a/arch/m68k/vmlinux-std.lds Wed Jun 11 17:40:05 2003
6458 +++ /dev/null   Wed Dec 31 16:00:00 1969
6459 @@ -1,97 +0,0 @@
6460 -/* ld script to make m68k Linux kernel */
6461 -
6462 -#include <asm-generic/vmlinux.lds.h>
6463 -
6464 -OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
6465 -OUTPUT_ARCH(m68k)
6466 -ENTRY(_start)
6467 -jiffies = jiffies_64 + 4;
6468 -SECTIONS
6469 -{
6470 -  . = 0x1000;
6471 -  _text = .;                   /* Text and read-only data */
6472 -  .text : {
6473 -       *(.text)
6474 -       *(.fixup)
6475 -       *(.gnu.warning)
6476 -       } = 0x4e75
6477 -
6478 -  . = ALIGN(16);               /* Exception table */
6479 -  __start___ex_table = .;
6480 -  __ex_table : { *(__ex_table) }
6481 -  __stop___ex_table = .;
6482 -
6483 -  RODATA
6484 -
6485 -  _etext = .;                  /* End of text section */
6486 -
6487 -  .data : {                    /* Data */
6488 -       *(.data)
6489 -       CONSTRUCTORS
6490 -       }
6491 -
6492 -  .bss : { *(.bss) }           /* BSS */
6493 -
6494 -  . = ALIGN(16);
6495 -  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
6496 -
6497 -  _edata = .;                  /* End of data section */
6498 -
6499 -  /* will be freed after init */
6500 -  . = ALIGN(4096);             /* Init code and data */
6501 -  __init_begin = .;
6502 -  .init.text : { 
6503 -       _sinittext = .;
6504 -       *(.init.text)
6505 -       _einittext = .;
6506 -  }
6507 -  .init.data : { *(.init.data) }
6508 -  . = ALIGN(16);
6509 -  __setup_start = .;
6510 -  .init.setup : { *(.init.setup) }
6511 -  __setup_end = .;
6512 -  __start___param = .;
6513 -  __param : { *(__param) }
6514 -  __stop___param = .;
6515 -  __initcall_start = .;
6516 -  .initcall.init : {
6517 -       *(.initcall1.init) 
6518 -       *(.initcall2.init) 
6519 -       *(.initcall3.init) 
6520 -       *(.initcall4.init) 
6521 -       *(.initcall5.init) 
6522 -       *(.initcall6.init) 
6523 -       *(.initcall7.init)
6524 -  }
6525 -  __initcall_end = .;
6526 -  __con_initcall_start = .;
6527 -  .con_initcall.init : { *(.con_initcall.init) }
6528 -  __con_initcall_end = .;
6529 -  SECURITY_INIT
6530 -  . = ALIGN(8192);
6531 -  __initramfs_start = .;
6532 -  .init.ramfs : { *(.init.ramfs) }
6533 -  __initramfs_end = .;
6534 -  . = ALIGN(8192);
6535 -  __init_end = .;
6536 -
6537 -  .data.init_task : { *(.data.init_task) }     /* The initial task and kernel stack */
6538 -
6539 -  _end = . ;
6540 -
6541 -  /* Sections to be discarded */
6542 -  /DISCARD/ : {
6543 -       *(.exit.text)
6544 -       *(.exit.data)
6545 -       *(.exitcall.exit)
6546 -       }
6547 -
6548 -  /* Stabs debugging sections.  */
6549 -  .stab 0 : { *(.stab) }
6550 -  .stabstr 0 : { *(.stabstr) }
6551 -  .stab.excl 0 : { *(.stab.excl) }
6552 -  .stab.exclstr 0 : { *(.stab.exclstr) }
6553 -  .stab.index 0 : { *(.stab.index) }
6554 -  .stab.indexstr 0 : { *(.stab.indexstr) }
6555 -  .comment 0 : { *(.comment) }
6556 -}
6557 diff -Nru a/arch/m68k/vmlinux-sun3.lds b/arch/m68k/vmlinux-sun3.lds
6558 --- a/arch/m68k/vmlinux-sun3.lds        Wed Jun 11 17:40:05 2003
6559 +++ /dev/null   Wed Dec 31 16:00:00 1969
6560 @@ -1,97 +0,0 @@
6561 -/* ld script to make m68k Linux kernel */
6562 -
6563 -#include <asm-generic/vmlinux.lds.h>
6564 -
6565 -OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
6566 -OUTPUT_ARCH(m68k)
6567 -ENTRY(_start)
6568 -jiffies = jiffies_64 + 4;
6569 -SECTIONS
6570 -{
6571 -  . = 0xE004000;
6572 -  _text = .;                   /* Text and read-only data */
6573 -  .text : {
6574 -       *(.head)
6575 -       *(.text)
6576 -       *(.fixup)
6577 -       *(.gnu.warning)
6578 -       } = 0x4e75
6579 -       RODATA
6580 -
6581 -  _etext = .;                  /* End of text section */
6582 -
6583 -  .data : {                    /* Data */
6584 -       *(.data)
6585 -       CONSTRUCTORS
6586 -       . = ALIGN(16);          /* Exception table */
6587 -       __start___ex_table = .;
6588 -       *(__ex_table) 
6589 -       __stop___ex_table = .;
6590 -       }
6591 -  /* End of data goes *here* so that freeing init code works properly. */
6592 -  _edata = .;
6593 -
6594 -  /* will be freed after init */
6595 -  . = ALIGN(8192);     /* Init code and data */
6596 -__init_begin = .;
6597 -       .init.text : { 
6598 -               _sinittext = .;
6599 -               *(.init.text)
6600 -               _einittext = .;
6601 -       }
6602 -       .init.data : { *(.init.data) }
6603 -       . = ALIGN(16);
6604 -       __setup_start = .;
6605 -       .init.setup : { *(.init.setup) }
6606 -       __setup_end = .;
6607 -       __start___param = .;
6608 -       __param : { *(__param) }
6609 -       __stop___param = .;
6610 -       __initcall_start = .;
6611 -       .initcall.init : {
6612 -               *(.initcall1.init) 
6613 -               *(.initcall2.init) 
6614 -               *(.initcall3.init) 
6615 -               *(.initcall4.init) 
6616 -               *(.initcall5.init) 
6617 -               *(.initcall6.init) 
6618 -               *(.initcall7.init)
6619 -       }
6620 -       __initcall_end = .;
6621 -       __con_initcall_start = .;
6622 -       .con_initcall.init : { *(.con_initcall.init) }
6623 -       __con_initcall_end = .;
6624 -       SECURITY_INIT
6625 -       . = ALIGN(8192);
6626 -       __initramfs_start = .;
6627 -       .init.ramfs : { *(.init.ramfs) }
6628 -       __initramfs_end = .;
6629 -       . = ALIGN(8192);
6630 -       __init_end = .;
6631 -       .init.task : { *(init_task) }
6632 -       
6633 -
6634 -  .bss : { *(.bss) }           /* BSS */
6635 -
6636 -  _end = . ;
6637 -
6638 -  /* Sections to be discarded */
6639 -  /DISCARD/ : {
6640 -       *(.exit.text)
6641 -       *(.exit.data)
6642 -       *(.exitcall.exit)
6643 -       }
6644 -
6645 -  .crap : {
6646 -       /* Stabs debugging sections.  */
6647 -       *(.stab)
6648 -       *(.stabstr)
6649 -       *(.stab.excl)
6650 -       *(.stab.exclstr)
6651 -       *(.stab.index)
6652 -       *(.stab.indexstr)
6653 -       *(.comment)
6654 -       *(.note)
6655 -  }
6656 -
6657 -}
6658 diff -Nru a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
6659 --- a/arch/m68knommu/Kconfig    Sat Aug  2 14:26:16 2003
6660 +++ b/arch/m68knommu/Kconfig    Sun Aug 31 16:14:22 2003
6661 @@ -490,14 +490,6 @@
6662  
6663  menu "Executable file formats"
6664  
6665 -config KCORE_AOUT
6666 -       bool
6667 -       default y
6668 -
6669 -config KCORE_ELF
6670 -       bool
6671 -       default y
6672 -
6673  source "fs/Kconfig.binfmt"
6674  
6675  endmenu
6676 diff -Nru a/arch/m68knommu/platform/5206/config.c b/arch/m68knommu/platform/5206/config.c
6677 --- a/arch/m68knommu/platform/5206/config.c     Tue May 27 20:13:12 2003
6678 +++ b/arch/m68knommu/platform/5206/config.c     Sat Aug 23 06:07:40 2003
6679 @@ -14,6 +14,7 @@
6680  #include <linux/sched.h>
6681  #include <linux/param.h>
6682  #include <linux/init.h>
6683 +#include <linux/interrupt.h>
6684  #include <asm/irq.h>
6685  #include <asm/dma.h>
6686  #include <asm/traps.h>
6687 @@ -26,7 +27,7 @@
6688  /***************************************************************************/
6689  
6690  void coldfire_tick(void);
6691 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
6692 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
6693  unsigned long coldfire_timer_offset(void);
6694  void coldfire_trap_init(void);
6695  void coldfire_reset(void);
6696 diff -Nru a/arch/m68knommu/platform/5206e/config.c b/arch/m68knommu/platform/5206e/config.c
6697 --- a/arch/m68knommu/platform/5206e/config.c    Tue May 27 20:13:12 2003
6698 +++ b/arch/m68knommu/platform/5206e/config.c    Sat Aug 23 06:07:40 2003
6699 @@ -12,6 +12,7 @@
6700  #include <linux/kernel.h>
6701  #include <linux/sched.h>
6702  #include <linux/param.h>
6703 +#include <linux/interrupt.h>
6704  #include <asm/irq.h>
6705  #include <asm/dma.h>
6706  #include <asm/traps.h>
6707 @@ -26,7 +27,7 @@
6708  /***************************************************************************/
6709  
6710  void coldfire_tick(void);
6711 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
6712 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
6713  unsigned long coldfire_timer_offset(void);
6714  void coldfire_trap_init(void);
6715  void coldfire_reset(void);
6716 diff -Nru a/arch/m68knommu/platform/5249/config.c b/arch/m68knommu/platform/5249/config.c
6717 --- a/arch/m68knommu/platform/5249/config.c     Tue Jun 17 06:35:38 2003
6718 +++ b/arch/m68knommu/platform/5249/config.c     Sat Aug 23 06:07:40 2003
6719 @@ -26,7 +26,7 @@
6720  /***************************************************************************/
6721  
6722  void coldfire_tick(void);
6723 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
6724 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
6725  unsigned long coldfire_timer_offset(void);
6726  void coldfire_trap_init(void);
6727  void coldfire_reset(void);
6728 diff -Nru a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c
6729 --- a/arch/m68knommu/platform/5272/config.c     Tue Jun 17 06:35:38 2003
6730 +++ b/arch/m68knommu/platform/5272/config.c     Sat Aug 23 06:07:40 2003
6731 @@ -14,6 +14,7 @@
6732  #include <linux/sched.h>
6733  #include <linux/param.h>
6734  #include <linux/init.h>
6735 +#include <linux/interrupt.h>
6736  #include <asm/irq.h>
6737  #include <asm/dma.h>
6738  #include <asm/traps.h>
6739 @@ -27,7 +28,7 @@
6740  /***************************************************************************/
6741  
6742  void coldfire_tick(void);
6743 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
6744 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
6745  unsigned long coldfire_timer_offset(void);
6746  void coldfire_trap_init(void);
6747  void coldfire_reset(void);
6748 diff -Nru a/arch/mips/Kconfig b/arch/mips/Kconfig
6749 --- a/arch/mips/Kconfig Mon Jul 28 04:57:50 2003
6750 +++ b/arch/mips/Kconfig Sun Aug 31 16:14:22 2003
6751 @@ -1126,31 +1126,6 @@
6752  
6753  menu "Executable file formats"
6754  
6755 -config KCORE_ELF
6756 -       bool
6757 -       default y
6758 -       ---help---
6759 -         If you enabled support for /proc file system then the file
6760 -         /proc/kcore will contain the kernel core image. This can be used
6761 -         in gdb:
6762 -
6763 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
6764 -
6765 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
6766 -         /proc/kcore appear in ELF core format as defined by the Executable
6767 -         and Linking Format specification. Selecting A.OUT will choose the
6768 -         old "a.out" format which may be necessary for some old versions
6769 -         of binutils or on some architectures.
6770 -
6771 -         This is especially useful if you have compiled the kernel with the
6772 -         "-g" option to preserve debugging information. It is mainly used
6773 -         for examining kernel data structures on the live kernel so if you
6774 -         don't understand what this means or are not a kernel hacker, just
6775 -         leave it at its default value ELF.
6776 -
6777 -config KCORE_AOUT
6778 -       bool
6779 -
6780  source "fs/Kconfig.binfmt"
6781  
6782  config TRAD_SIGNALS
6783 diff -Nru a/arch/mips/au1000/common/dma.c b/arch/mips/au1000/common/dma.c
6784 --- a/arch/mips/au1000/common/dma.c     Mon Jun 23 12:12:26 2003
6785 +++ b/arch/mips/au1000/common/dma.c     Sun Aug 31 16:14:08 2003
6786 @@ -62,14 +62,14 @@
6787  spinlock_t au1000_dma_spin_lock = SPIN_LOCK_UNLOCKED;
6788  
6789  struct dma_chan au1000_dma_table[NUM_AU1000_DMA_CHANNELS] = {
6790 -      {dev_id:-1,},
6791 -      {dev_id:-1,},
6792 -      {dev_id:-1,},
6793 -      {dev_id:-1,},
6794 -      {dev_id:-1,},
6795 -      {dev_id:-1,},
6796 -      {dev_id:-1,},
6797 -      {dev_id:-1,}
6798 +      {.dev_id = -1,},
6799 +      {.dev_id = -1,},
6800 +      {.dev_id = -1,},
6801 +      {.dev_id = -1,},
6802 +      {.dev_id = -1,},
6803 +      {.dev_id = -1,},
6804 +      {.dev_id = -1,},
6805 +      {.dev_id = -1,}
6806  };
6807  
6808  // Device FIFO addresses and default DMA modes
6809 diff -Nru a/arch/mips/kernel/ioctl32.c b/arch/mips/kernel/ioctl32.c
6810 --- a/arch/mips/kernel/ioctl32.c        Mon Jul 28 04:57:50 2003
6811 +++ b/arch/mips/kernel/ioctl32.c        Sun Aug 31 16:14:44 2003
6812 @@ -810,8 +810,7 @@
6813  #define IOCTL_TABLE_START \
6814         struct ioctl_trans ioctl_start[] = {
6815  #define IOCTL_TABLE_END \
6816 -       }; struct ioctl_trans ioctl_end[0];
6817 -
6818 +       };
6819  
6820  IOCTL_TABLE_START
6821  #include <linux/compat_ioctl.h>
6822 @@ -1205,6 +1204,8 @@
6823  COMPATIBLE_IOCTL(RTC_WKALM_SET)
6824  COMPATIBLE_IOCTL(RTC_WKALM_RD)
6825  IOCTL_TABLE_END
6826 +
6827 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
6828  
6829  #define NR_IOCTL_TRANS         (sizeof(ioctl_translations) /   \
6830                                  sizeof(ioctl_translations[0]))
6831 diff -Nru a/arch/mips/sibyte/cfe/console.c b/arch/mips/sibyte/cfe/console.c
6832 --- a/arch/mips/sibyte/cfe/console.c    Mon Jul 28 04:57:50 2003
6833 +++ b/arch/mips/sibyte/cfe/console.c    Sun Aug 31 16:14:08 2003
6834 @@ -9,7 +9,6 @@
6835  #include "cfe_error.h"
6836  
6837  extern int cfe_cons_handle;
6838 -static kdev_t cfe_consdev;
6839  
6840  static void cfe_console_write(struct console *cons, const char *str,
6841                        unsigned int count)
6842 @@ -57,15 +56,12 @@
6843  #ifdef CONFIG_SIBYTE_SB1250_DUART
6844                 if (!strcmp(consdev, "uart0")) {
6845                         setleds("u0cn");
6846 -//                     cfe_consdev = MKDEV(TTY_MAJOR, SB1250_DUART_MINOR_BASE + 0);
6847                 } else if (!strcmp(consdev, "uart1")) {
6848                         setleds("u1cn");
6849 -//                     cfe_consdev = MKDEV(TTY_MAJOR, SB1250_DUART_MINOR_BASE + 1);
6850  #endif
6851  #ifdef CONFIG_VGA_CONSOLE
6852                 } else if (!strcmp(consdev, "pcconsole0")) {
6853                         setleds("pccn");
6854 -//                     cfe_consdev = MKDEV(TTY_MAJOR, 0);
6855  #endif
6856                 } else
6857                         return -ENODEV;
6858 @@ -74,12 +70,12 @@
6859  }
6860  
6861  static struct console sb1250_cfe_cons = {
6862 -       name:           "cfe",
6863 -       write:          cfe_console_write,
6864 -       device:         cfe_console_device,
6865 -       setup:          cfe_console_setup,
6866 -       flags:          CON_PRINTBUFFER,
6867 -       index:          -1,
6868 +       .name           = "cfe",
6869 +       .write          = cfe_console_write,
6870 +       .device         = cfe_console_device,
6871 +       .setup          = cfe_console_setup,
6872 +       .flags          = CON_PRINTBUFFER,
6873 +       .index          = -1,
6874  };
6875  
6876  static int __init sb1250_cfe_console_init(void)
6877 diff -Nru a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c
6878 --- a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c  Mon Jul 28 04:57:50 2003
6879 +++ b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c  Tue Aug 26 09:25:40 2003
6880 @@ -253,7 +253,7 @@
6881  {
6882         int minor;
6883  
6884 -       minor = minor(inode->i_rdev);
6885 +       minor = iminor(inode);
6886         if (minor != 0) {
6887                 return -ENODEV;
6888         }
6889 @@ -278,7 +278,7 @@
6890  {
6891         int minor;
6892  
6893 -       minor = minor(inode->i_rdev);
6894 +       minor = iminor(inode);
6895         if (minor != 0 || !sbp.open) {
6896                 return -ENODEV;
6897         }
6898 diff -Nru a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
6899 --- a/arch/mips/tx4927/common/tx4927_irq.c      Mon Apr 14 20:10:10 2003
6900 +++ b/arch/mips/tx4927/common/tx4927_irq.c      Sun Aug 31 16:14:08 2003
6901 @@ -149,26 +149,26 @@
6902  
6903  #define TX4927_CP0_NAME "TX4927-CP0"
6904  static struct hw_interrupt_type tx4927_irq_cp0_type = {
6905 -       typename:       TX4927_CP0_NAME,
6906 -       startup:        tx4927_irq_cp0_startup,
6907 -       shutdown:       tx4927_irq_cp0_shutdown,
6908 -       enable:         tx4927_irq_cp0_enable,
6909 -       disable:        tx4927_irq_cp0_disable,
6910 -       ack:            tx4927_irq_cp0_mask_and_ack,
6911 -       end:            tx4927_irq_cp0_end,
6912 -       set_affinity:   NULL
6913 +       .typename       = TX4927_CP0_NAME,
6914 +       .startup        = tx4927_irq_cp0_startup,
6915 +       .shutdown       = tx4927_irq_cp0_shutdown,
6916 +       .enable         = tx4927_irq_cp0_enable,
6917 +       .disable        = tx4927_irq_cp0_disable,
6918 +       .ack            = tx4927_irq_cp0_mask_and_ack,
6919 +       .end            = tx4927_irq_cp0_end,
6920 +       .set_affinity   = NULL
6921  };
6922  
6923  #define TX4927_PIC_NAME "TX4927-PIC"
6924  static struct hw_interrupt_type tx4927_irq_pic_type = {
6925 -       typename:       TX4927_PIC_NAME,
6926 -       startup:        tx4927_irq_pic_startup,
6927 -       shutdown:       tx4927_irq_pic_shutdown,
6928 -       enable:         tx4927_irq_pic_enable,
6929 -       disable:        tx4927_irq_pic_disable,
6930 -       ack:            tx4927_irq_pic_mask_and_ack,
6931 -       end:            tx4927_irq_pic_end,
6932 -       set_affinity:   NULL
6933 +       .typename       = TX4927_PIC_NAME,
6934 +       .startup        = tx4927_irq_pic_startup,
6935 +       .shutdown       = tx4927_irq_pic_shutdown,
6936 +       .enable         = tx4927_irq_pic_enable,
6937 +       .disable        = tx4927_irq_pic_disable,
6938 +       .ack            = tx4927_irq_pic_mask_and_ack,
6939 +       .end            = tx4927_irq_pic_end,
6940 +       .set_affinity   = NULL
6941  };
6942  
6943  #define TX4927_PIC_ACTION(s) { no_action, 0, 0, s, NULL, NULL }
6944 diff -Nru a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
6945 --- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c  Thu Jul  3 15:17:43 2003
6946 +++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c  Sun Aug 31 16:14:08 2003
6947 @@ -255,14 +255,14 @@
6948  
6949  #define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC"
6950  static struct hw_interrupt_type toshiba_rbtx4927_irq_ioc_type = {
6951 -       typename:TOSHIBA_RBTX4927_IOC_NAME,
6952 -       startup:toshiba_rbtx4927_irq_ioc_startup,
6953 -       shutdown:toshiba_rbtx4927_irq_ioc_shutdown,
6954 -       enable:toshiba_rbtx4927_irq_ioc_enable,
6955 -       disable:toshiba_rbtx4927_irq_ioc_disable,
6956 -       ack:toshiba_rbtx4927_irq_ioc_mask_and_ack,
6957 -       end:toshiba_rbtx4927_irq_ioc_end,
6958 -       set_affinity:NULL
6959 +       .typename = TOSHIBA_RBTX4927_IOC_NAME,
6960 +       .startup = toshiba_rbtx4927_irq_ioc_startup,
6961 +       .shutdown = toshiba_rbtx4927_irq_ioc_shutdown,
6962 +       .enable = toshiba_rbtx4927_irq_ioc_enable,
6963 +       .disable = toshiba_rbtx4927_irq_ioc_disable,
6964 +       .ack = toshiba_rbtx4927_irq_ioc_mask_and_ack,
6965 +       .end = toshiba_rbtx4927_irq_ioc_end,
6966 +       .set_affinity = NULL
6967  };
6968  #define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000
6969  #define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006
6970 @@ -271,14 +271,14 @@
6971  #ifdef CONFIG_TOSHIBA_FPCIB0
6972  #define TOSHIBA_RBTX4927_ISA_NAME "RBTX4927-ISA"
6973  static struct hw_interrupt_type toshiba_rbtx4927_irq_isa_type = {
6974 -       typename:TOSHIBA_RBTX4927_ISA_NAME,
6975 -       startup:toshiba_rbtx4927_irq_isa_startup,
6976 -       shutdown:toshiba_rbtx4927_irq_isa_shutdown,
6977 -       enable:toshiba_rbtx4927_irq_isa_enable,
6978 -       disable:toshiba_rbtx4927_irq_isa_disable,
6979 -       ack:toshiba_rbtx4927_irq_isa_mask_and_ack,
6980 -       end:toshiba_rbtx4927_irq_isa_end,
6981 -       set_affinity:NULL
6982 +       .typename = TOSHIBA_RBTX4927_ISA_NAME,
6983 +       .startup = toshiba_rbtx4927_irq_isa_startup,
6984 +       .shutdown = toshiba_rbtx4927_irq_isa_shutdown,
6985 +       .enable = toshiba_rbtx4927_irq_isa_enable,
6986 +       .disable = toshiba_rbtx4927_irq_isa_disable,
6987 +       .ack = toshiba_rbtx4927_irq_isa_mask_and_ack,
6988 +       .end = toshiba_rbtx4927_irq_isa_end,
6989 +       .set_affinity = NULL
6990  };
6991  #endif
6992  
6993 diff -Nru a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c
6994 --- a/arch/mips/vr41xx/common/vrc4173.c Thu Jul 31 08:59:17 2003
6995 +++ b/arch/mips/vr41xx/common/vrc4173.c Sun Aug 31 16:14:08 2003
6996 @@ -250,10 +250,10 @@
6997  }
6998  
6999  static struct pci_driver vrc4173_driver = {
7000 -       name:           "NEC VRC4173",
7001 -       probe:          vrc4173_probe,
7002 -       remove:         NULL,
7003 -       id_table:       vrc4173_table,
7004 +       .name           = "NEC VRC4173",
7005 +       .probe          = vrc4173_probe,
7006 +       .remove         = NULL,
7007 +       .id_table       = vrc4173_table,
7008  };
7009  
7010  static int __devinit vrc4173_init(void)
7011 diff -Nru a/arch/parisc/Kconfig b/arch/parisc/Kconfig
7012 --- a/arch/parisc/Kconfig       Sat Aug  2 14:26:16 2003
7013 +++ b/arch/parisc/Kconfig       Sun Aug 31 16:14:22 2003
7014 @@ -161,11 +161,6 @@
7015  
7016  menu "Executable file formats"
7017  
7018 -config KCORE_ELF
7019 -       bool
7020 -       depends on PROC_FS
7021 -       default y
7022 -
7023  source "fs/Kconfig.binfmt"
7024  
7025  endmenu
7026 diff -Nru a/arch/parisc/kernel/ioctl32.c b/arch/parisc/kernel/ioctl32.c
7027 --- a/arch/parisc/kernel/ioctl32.c      Fri May  2 10:22:56 2003
7028 +++ b/arch/parisc/kernel/ioctl32.c      Sun Aug 31 16:14:44 2003
7029 @@ -1426,7 +1426,7 @@
7030                 return -EINVAL;
7031                         
7032         tty = (struct tty_struct *)file->private_data;
7033 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
7034 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
7035                 return -EINVAL;
7036                                                         
7037         if (tty->driver->ioctl != vt_ioctl)
7038 @@ -2458,7 +2458,7 @@
7039  #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd, sys_ioctl) 
7040  
7041  #define IOCTL_TABLE_START  struct ioctl_trans ioctl_start[] = {
7042 -#define IOCTL_TABLE_END    }; struct ioctl_trans ioctl_end[0];
7043 +#define IOCTL_TABLE_END    };
7044  
7045  IOCTL_TABLE_START
7046  #include <linux/compat_ioctl.h>
7047 @@ -2631,3 +2631,4 @@
7048  #endif /* DRM */
7049  IOCTL_TABLE_END
7050  
7051 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
7052 diff -Nru a/arch/ppc/8260_io/uart.c b/arch/ppc/8260_io/uart.c
7053 --- a/arch/ppc/8260_io/uart.c   Wed Jun 11 12:32:53 2003
7054 +++ b/arch/ppc/8260_io/uart.c   Tue Aug 26 09:25:39 2003
7055 @@ -50,6 +50,10 @@
7056  #include <asm/cpm_8260.h>
7057  #include <asm/irq.h>
7058  
7059 +#ifdef CONFIG_MAGIC_SYSRQ
7060 +#include <linux/sysrq.h>
7061 +#endif
7062 +
7063  #ifdef CONFIG_SERIAL_CONSOLE
7064  #include <linux/console.h>
7065  
7066 @@ -77,6 +81,14 @@
7067  static struct tty_driver *serial_driver;
7068  static int serial_console_setup(struct console *co, char *options);
7069  
7070 +static void serial_console_write(struct console *c, const char *s,
7071 +                                               unsigned count);
7072 +static kdev_t serial_console_device(struct console *c);
7073 +
7074 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
7075 +static unsigned long break_pressed; /* break, really ... */
7076 +#endif
7077 +
7078  /*
7079   * Serial driver configuration section.  Here are the various options:
7080   */
7081 @@ -208,6 +220,15 @@
7082         cbd_t                   *tx_cur;
7083  } ser_info_t;
7084  
7085 +static struct console sercons = {
7086 +       .name =         "ttyS",
7087 +       .write =        serial_console_write,
7088 +       .device =       serial_console_device,
7089 +       .setup =        serial_console_setup,
7090 +       .flags =        CON_PRINTBUFFER,
7091 +       .index =        CONFIG_SERIAL_CONSOLE_PORT,
7092 +};
7093 +
7094  static void change_speed(ser_info_t *info);
7095  static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout);
7096  
7097 @@ -328,7 +349,7 @@
7098         schedule_work(&info->tqueue);
7099  }
7100  
7101 -static _INLINE_ void receive_chars(ser_info_t *info)
7102 +static _INLINE_ void receive_chars(ser_info_t *info, struct pt_regs *regs)
7103  {
7104         struct tty_struct *tty = info->tty;
7105         unsigned char ch, *cp;
7106 @@ -450,6 +471,19 @@
7107                                         }
7108                                 }
7109                         }
7110 +
7111 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
7112 +                       if (break_pressed && info->line == sercons.index) {
7113 +                               if (ch != 0 && time_before(jiffies,
7114 +                                                       break_pressed + HZ*5)) {
7115 +                                       handle_sysrq(ch, regs, NULL, NULL);
7116 +                                       break_pressed = 0;
7117 +                                       goto ignore_char;
7118 +                               } else
7119 +                                       break_pressed = 0;
7120 +                       }
7121 +#endif
7122 +                       
7123                         if (tty->flip.count >= TTY_FLIPBUF_SIZE)
7124                                 break;
7125  
7126 @@ -458,6 +492,10 @@
7127                         tty->flip.count++;
7128                 }
7129  
7130 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
7131 +       ignore_char:
7132 +#endif
7133 +
7134                 /* This BD is ready to be used again.  Clear status.
7135                  * Get next BD.
7136                  */
7137 @@ -475,7 +513,36 @@
7138         schedule_delayed_work(&tty->flip.work, 1);
7139  }
7140  
7141 -static _INLINE_ void transmit_chars(ser_info_t *info)
7142 +static _INLINE_ void receive_break(ser_info_t *info, struct pt_regs *regs)
7143 +{
7144 +       struct tty_struct *tty = info->tty;
7145 +
7146 +       info->state->icount.brk++;
7147 +
7148 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
7149 +       if (info->line == sercons.index) {
7150 +               if (!break_pressed) {
7151 +                       break_pressed = jiffies;
7152 +                       return;
7153 +               } else
7154 +                       break_pressed = 0;
7155 +       }
7156 +#endif
7157 +
7158 +       /* Check to see if there is room in the tty buffer for
7159 +        * the break.  If not, we exit now, losing the break.  FIXME
7160 +        */
7161 +       if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE)
7162 +               return;
7163 +       *(tty->flip.flag_buf_ptr++) = TTY_BREAK;
7164 +       *(tty->flip.char_buf_ptr++) = 0;
7165 +       tty->flip.count++;
7166 +
7167 +       queue_task(&tty->flip.tqueue, &tq_timer);
7168 +}
7169 +
7170 +
7171 +static _INLINE_ void transmit_chars(ser_info_t *info, struct pt_regs *regs)
7172  {
7173         
7174         if (info->flags & TX_WAKEUP) {
7175 @@ -575,19 +642,23 @@
7176         if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
7177                 smcp = &immr->im_smc[idx];
7178                 events = smcp->smc_smce;
7179 +               if (events & SMCM_BRKE)
7180 +                       receive_break(info, regs);
7181                 if (events & SMCM_RX)
7182 -                       receive_chars(info);
7183 +                       receive_chars(info, regs);
7184                 if (events & SMCM_TX)
7185 -                       transmit_chars(info);
7186 +                       transmit_chars(info, regs);
7187                 smcp->smc_smce = events;
7188         }
7189         else {
7190                 sccp = &immr->im_scc[idx - SCC_IDX_BASE];
7191                 events = sccp->scc_scce;
7192 +               if (events & SMCM_BRKE)
7193 +                       receive_break(info, regs);
7194                 if (events & SCCM_RX)
7195 -                       receive_chars(info);
7196 +                       receive_chars(info, regs);
7197                 if (events & SCCM_TX)
7198 -                       transmit_chars(info);
7199 +                       transmit_chars(info, regs);
7200                 sccp->scc_scce = events;
7201         }
7202         
7203 @@ -2207,7 +2278,7 @@
7204  static void serial_console_write(struct console *c, const char *s,
7205                                 unsigned count)
7206  {
7207 -#if defined(CONFIG_KGDB) && !defined(CONFIG_USE_SERIAL2_KGDB)
7208 +#if defined(CONFIG_KGDB_CONSOLE) && !defined(CONFIG_USE_SERIAL2_KGDB)
7209         /* Try to let stub handle output. Returns true if it did. */ 
7210         if (kgdb_output_string(s, count))
7211                 return;
7212 @@ -2391,21 +2462,11 @@
7213  }
7214  #endif
7215  
7216 -static kdev_t serial_console_device(struct console *c)
7217 +static struct tty_driver *serial_console_device(struct console *c, int *index)
7218  {
7219         *index = c->index;
7220         return serial_driver;
7221  }
7222 -
7223 -
7224 -static struct console sercons = {
7225 -       .name =         "ttyS",
7226 -       .write =        serial_console_write,
7227 -       .device =       serial_console_device,
7228 -       .setup =        serial_console_setup,
7229 -       .flags =        CON_PRINTBUFFER,
7230 -       .index =        CONFIG_SERIAL_CONSOLE_PORT,
7231 -};
7232  
7233  /*
7234   *     Register console.
7235 diff -Nru a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
7236 --- a/arch/ppc/8xx_io/cs4218_tdm.c      Tue Jul 15 10:01:29 2003
7237 +++ b/arch/ppc/8xx_io/cs4218_tdm.c      Tue Aug 26 09:25:40 2003
7238 @@ -2106,11 +2106,11 @@
7239          */
7240         cs4218_ctl_write(cs4218_control);
7241  
7242 -       sound.minDev = MINOR(inode->i_rdev) & 0x0f;
7243 +       sound.minDev = iminor(inode) & 0x0f;
7244         sound.soft = sound.dsp;
7245         sound.hard = sound.dsp;
7246         sound_init();
7247 -       if ((MINOR(inode->i_rdev) & 0x0f) == SND_DEV_AUDIO) {
7248 +       if ((iminor(inode) & 0x0f) == SND_DEV_AUDIO) {
7249                 sound_set_speed(8000);
7250                 sound_set_stereo(0);
7251                 sound_set_format(AFMT_MU_LAW);
7252 diff -Nru a/arch/ppc/8xx_io/uart.c b/arch/ppc/8xx_io/uart.c
7253 --- a/arch/ppc/8xx_io/uart.c    Wed Jun 11 12:32:54 2003
7254 +++ b/arch/ppc/8xx_io/uart.c    Thu Aug 21 15:10:37 2003
7255 @@ -1068,7 +1068,7 @@
7256         volatile cbd_t *bdp;
7257         unsigned char   *cp;
7258  
7259 -#ifdef CONFIG_KGDB
7260 +#ifdef CONFIG_KGDB_CONSOLE
7261          /* Try to let stub handle output. Returns true if it did. */ 
7262          if (kgdb_output_string(buf, count))
7263              return ret;
7264 @@ -2271,7 +2271,7 @@
7265  static void serial_console_write(struct console *c, const char *s,
7266                                 unsigned count)
7267  {
7268 -#ifdef CONFIG_KGDB
7269 +#ifdef CONFIG_KGDB_CONSOLE
7270         /* Try to let stub handle output. Returns true if it did. */ 
7271         if (kgdb_output_string(s, count))
7272                 return;
7273 diff -Nru a/arch/ppc/Kconfig b/arch/ppc/Kconfig
7274 --- a/arch/ppc/Kconfig  Mon Aug  4 16:10:57 2003
7275 +++ b/arch/ppc/Kconfig  Wed Sep  3 05:16:34 2003
7276 @@ -66,6 +66,9 @@
7277  config 40x
7278         bool "40x"
7279  
7280 +config 44x
7281 +       bool "44x"
7282 +
7283  config POWER3
7284         bool "POWER3"
7285  
7286 @@ -74,6 +77,11 @@
7287  
7288  endchoice
7289  
7290 +config PTE_64BIT
7291 +       bool
7292 +       depends on 44x
7293 +       default y
7294 +
7295  source arch/ppc/platforms/4xx/Kconfig
7296  
7297  config 8260
7298 @@ -766,8 +774,8 @@
7299           RS/6000 machines are currently not supported by Linux.
7300  
7301  config PCI
7302 -       bool "PCI support" if 4xx || 8260
7303 -       default y if !4xx && !8260 && !8xx && !APUS
7304 +       bool "PCI support" if 40x || 8260
7305 +       default y if !40x && !8260 && !8xx && !APUS
7306         default PCI_PERMEDIA if !4xx && !8260 && !8xx && APUS
7307         default PCI_QSPAN if !4xx && !8260 && 8xx
7308         help
7309 @@ -795,22 +803,6 @@
7310         bool "PCI for Permedia2"
7311         depends on !4xx && !8xx && APUS
7312  
7313 -# only elf supported, a.out is not -- Cort
7314 -config KCORE_ELF
7315 -       bool
7316 -       depends on PROC_FS
7317 -       default y
7318 -       help
7319 -         If you enabled support for /proc file system then the file
7320 -         /proc/kcore will contain the kernel core image in ELF format. This
7321 -         can be used in gdb:
7322 -
7323 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
7324 -
7325 -         This is especially useful if you have compiled the kernel with the
7326 -         "-g" option to preserve debugging information. It is mainly used
7327 -         for examining kernel data structures on the live kernel.
7328 -
7329  config KERNEL_ELF
7330         bool
7331         default y
7332 @@ -1159,6 +1151,7 @@
7333  config BOOT_LOAD
7334         hex "Link/load address for booting" if BOOT_LOAD_BOOL
7335         default "0x00400000" if 40x || 8xx || 8260
7336 +       default "0x01000000" if 44x
7337         default "0x00800000"
7338  
7339  config PIN_TLB
7340 @@ -1277,16 +1270,11 @@
7341           floppy controller, say Y here. Most commonly found in PowerMacs.
7342  
7343  config MAC_SERIAL
7344 -       tristate "Support for PowerMac serial ports"
7345 +       tristate "Support for PowerMac serial ports (OBSOLETE DRIVER)"
7346         depends on PPC_PMAC
7347         help
7348 -         If you have Macintosh style serial ports (8 pin mini-DIN), say Y
7349 -         here. If you also have regular serial ports and enable the driver
7350 -         for them, you can't currently use the serial console feature.
7351 -
7352 -config SERIAL_CONSOLE
7353 -       bool "Support for console on serial port"
7354 -       depends on PPC_PMAC && MAC_SERIAL=y
7355 +         This driver is obsolete. Use CONFIG_SERIAL_PMACZILOG in
7356 +         "Character devices --> Serial drivers --> PowerMac z85c30" option.
7357  
7358  config ADB
7359         bool "Apple Desktop Bus (ADB) support"
7360 @@ -1426,20 +1414,12 @@
7361  config KGDB
7362         bool "Include kgdb kernel debugger"
7363         depends on DEBUG_KERNEL
7364 +       select DEBUG_INFO
7365         help
7366           Include in-kernel hooks for kgdb, the Linux kernel source level
7367           debugger.  See <http://kgdb.sourceforge.net/> for more information.
7368           Unless you are intending to debug the kernel, say N here.
7369  
7370 -config DEBUG_INFO
7371 -       bool "Compile the kernel with debug info"
7372 -       depends on DEBUG_KERNEL
7373 -       help
7374 -          If you say Y here the resulting kernel image will include
7375 -         debugging info resulting in a larger kernel image.
7376 -         Say Y here only if you plan to use gdb to debug the kernel.
7377 -         If you don't debug the kernel, you can say N.
7378 -         
7379  choice
7380         prompt "Serial Port"
7381         depends on KGDB
7382 @@ -1459,6 +1439,14 @@
7383  
7384  endchoice
7385  
7386 +config KGDB_CONSOLE
7387 +       bool "Enable serial console thru kgdb port"
7388 +       depends on KGDB && 8xx || 8260
7389 +       help
7390 +         If you enable this, all serial console messages will be sent
7391 +         over the gdb stub.
7392 +         If unsure, say N.
7393 +
7394  config XMON
7395         bool "Include xmon kernel debugger"
7396         depends on DEBUG_KERNEL
7397 @@ -1474,18 +1462,16 @@
7398           Unless you are intending to debug the kernel with one of these
7399           machines, say N here.
7400  
7401 -config MORE_COMPILE_OPTIONS
7402 -       bool "Add any additional compile options"
7403 -       depends on DEBUG_KERNEL && (KGDB || XMON || BDI_SWITCH)
7404 -       help
7405 -         If you want to add additional CFLAGS to the kernel build, such as -g
7406 -         for KGDB or the BDI2000, enable this option and then enter what you
7407 -         would like to add in the next question.
7408 -
7409 -config COMPILE_OPTIONS
7410 -       string "Additional compile arguments"
7411 -       depends on MORE_COMPILE_OPTIONS
7412 -       default "-g -ggdb"
7413 +config DEBUG_INFO
7414 +       bool "Compile the kernel with debug info"
7415 +       depends on DEBUG_KERNEL
7416 +       default y if BDI_SWITCH || XMON
7417 +       help
7418 +          If you say Y here the resulting kernel image will include
7419 +         debugging info resulting in a larger kernel image.
7420 +         Say Y here only if you plan to use some sort of debugger to
7421 +         debug the kernel.
7422 +         If you don't debug the kernel, you can say N.
7423  
7424  config BOOTX_TEXT
7425         bool "Support for early boot text console (BootX or OpenFirmware only)"
7426 diff -Nru a/arch/ppc/Makefile b/arch/ppc/Makefile
7427 --- a/arch/ppc/Makefile Sun Jul 27 15:52:30 2003
7428 +++ b/arch/ppc/Makefile Wed Sep  3 05:16:34 2003
7429 @@ -22,9 +22,6 @@
7430  
7431  cflags-$(CONFIG_4xx)           += -Wa,-m405
7432  cflags-$(CONFIG_PPC64BRIDGE)   += -Wa,-mppc64bridge
7433 -# Use sed to remove the quotes.
7434 -cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \
7435 -       $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
7436  
7437  CFLAGS += $(cflags-y)
7438  
7439 @@ -32,7 +29,7 @@
7440  head-y                         := arch/ppc/kernel/head.o
7441  head-$(CONFIG_8xx)             := arch/ppc/kernel/head_8xx.o
7442  head-$(CONFIG_4xx)             := arch/ppc/kernel/head_4xx.o
7443 -head-$(CONFIG_440)             := arch/ppc/kernel/head_44x.o
7444 +head-$(CONFIG_44x)             := arch/ppc/kernel/head_44x.o
7445  
7446  head-$(CONFIG_6xx)             += arch/ppc/kernel/idle_6xx.o
7447  
7448 diff -Nru a/arch/ppc/boot/common/ns16550.c b/arch/ppc/boot/common/ns16550.c
7449 --- a/arch/ppc/boot/common/ns16550.c    Sat Jun 28 11:06:53 2003
7450 +++ b/arch/ppc/boot/common/ns16550.c    Wed Aug 20 10:24:16 2003
7451 @@ -60,7 +60,7 @@
7452         else {
7453                 /* Input clock. */
7454                 outb(com_port + (UART_DLL << shift),
7455 -                    (BASE_BAUD / SERIAL_BAUD));
7456 +                    (BASE_BAUD / SERIAL_BAUD) & 0xFF);
7457                 outb(com_port + (UART_DLM << shift),
7458                      (BASE_BAUD / SERIAL_BAUD) >> 8);
7459                 /* 8 data, 1 stop, no parity */
7460 diff -Nru a/arch/ppc/boot/common/util.S b/arch/ppc/boot/common/util.S
7461 --- a/arch/ppc/boot/common/util.S       Tue Feb 25 11:37:43 2003
7462 +++ b/arch/ppc/boot/common/util.S       Thu Aug 21 10:17:00 2003
7463 @@ -160,9 +160,22 @@
7464         blr
7465  
7466  
7467 +/* udelay (on non-601 processors) needs to know the period of the
7468 + * timebase in nanoseconds.  This used to be hardcoded to be 60ns
7469 + * (period of 66MHz/4).  Now a variable is used that is initialized to
7470 + * 60 for backward compatibility, but it can be overridden as necessary
7471 + * with code something like this:
7472 + *    extern unsigned long timebase_period_ns;
7473 + *    timebase_period_ns = 1000000000 / bd->bi_tbfreq;
7474 + */
7475 +       .data
7476 +       .globl timebase_period_ns
7477 +timebase_period_ns:
7478 +       .long   60
7479 +
7480 +       .text
7481  /*
7482   * Delay for a number of microseconds
7483 - * -- Use the BUS timer (assumes 66MHz)
7484   */
7485         .globl  udelay
7486  udelay:
7487 @@ -180,8 +193,13 @@
7488  
7489  .udelay_not_601:
7490         mulli   r4,r3,1000      /* nanoseconds */
7491 -       addi    r4,r4,59
7492 -       li      r5,60
7493 +       /*  Change r4 to be the number of ticks using:  
7494 +        *      (nanoseconds + (timebase_period_ns - 1 )) / timebase_period_ns
7495 +        *  timebase_period_ns defaults to 60 (16.6MHz) */
7496 +       lis     r5,timebase_period_ns@h
7497 +       lwz     r5,timebase_period_ns@l(r5)
7498 +       addi    r4,r4,r5
7499 +       addi    r4,r4,-1
7500         divw    r4,r4,r5        /* BUS ticks */
7501  1:     mftbu   r5
7502         mftb    r6
7503 diff -Nru a/arch/ppc/boot/include/of1275.h b/arch/ppc/boot/include/of1275.h
7504 --- a/arch/ppc/boot/include/of1275.h    Mon Sep 16 21:58:06 2002
7505 +++ b/arch/ppc/boot/include/of1275.h    Mon Aug 25 05:13:38 2003
7506 @@ -20,6 +20,7 @@
7507  /* function declarations */
7508  
7509  void * claim(unsigned int virt, unsigned int size, unsigned int align);
7510 +int    map(unsigned int phys, unsigned int virt, unsigned int size);
7511  void   enter(void);
7512  void   exit(void);
7513  phandle        finddevice(const char *name);
7514 diff -Nru a/arch/ppc/boot/ld.script b/arch/ppc/boot/ld.script
7515 --- a/arch/ppc/boot/ld.script   Thu May 29 04:06:53 2003
7516 +++ b/arch/ppc/boot/ld.script   Mon Aug 25 05:13:38 2003
7517 @@ -66,7 +66,7 @@
7518    _edata  =  .;
7519    PROVIDE (edata = .);
7520  
7521 -  . = ALIGN(8);
7522 +  . = ALIGN(4096);
7523    __bss_start = .;
7524    .bss       :
7525    {
7526 diff -Nru a/arch/ppc/boot/of1275/Makefile b/arch/ppc/boot/of1275/Makefile
7527 --- a/arch/ppc/boot/of1275/Makefile     Sun Jun  8 01:12:49 2003
7528 +++ b/arch/ppc/boot/of1275/Makefile     Mon Aug 25 09:36:40 2003
7529 @@ -3,4 +3,4 @@
7530  #
7531  
7532  lib-y := claim.o enter.o exit.o finddevice.o getprop.o ofinit.o        \
7533 -        ofstdio.o read.o release.o write.o
7534 +        ofstdio.o read.o release.o write.o map.o
7535 diff -Nru a/arch/ppc/boot/of1275/map.c b/arch/ppc/boot/of1275/map.c
7536 --- /dev/null   Wed Dec 31 16:00:00 1969
7537 +++ b/arch/ppc/boot/of1275/map.c        Mon Aug 25 09:36:40 2003
7538 @@ -0,0 +1,50 @@
7539
7540 +/*
7541 + * Copyright (C) Paul Mackerras 1997.
7542 + * Copyright (C) Leigh Brown 2002.
7543 + *
7544 + * This program is free software; you can redistribute it and/or
7545 + * modify it under the terms of the GNU General Public License
7546 + * as published by the Free Software Foundation; either version
7547 + * 2 of the License, or (at your option) any later version.
7548 + */
7549 +
7550 +#include "of1275.h"
7551 +#include "nonstdio.h"
7552 +
7553 +extern ihandle of_prom_mmu;
7554 +
7555 +int
7556 +map(unsigned int phys, unsigned int virt, unsigned int size)
7557 +{
7558 +    struct prom_args {
7559 +       char *service;
7560 +       int nargs;
7561 +       int nret;
7562 +       char *method;
7563 +       ihandle mmu_ihandle;    
7564 +       int misc;
7565 +       unsigned int phys;
7566 +       unsigned int virt;
7567 +       unsigned int size;
7568 +       int ret0;
7569 +       int ret1;
7570 +    } args;
7571 +
7572 +    if (of_prom_mmu == 0) {
7573 +       printf("map() called, no MMU found\n");
7574 +       return -1;
7575 +    }
7576 +    args.service = "call-method";
7577 +    args.nargs = 6;
7578 +    args.nret = 2;
7579 +    args.method = "map";
7580 +    args.mmu_ihandle = of_prom_mmu;
7581 +    args.misc = -1;
7582 +    args.phys = phys;
7583 +    args.virt = virt;
7584 +    args.size = size;
7585 +    (*of_prom_entry)(&args);
7586 +
7587 +    return (int)args.ret0;
7588 +}
7589 diff -Nru a/arch/ppc/boot/of1275/ofinit.c b/arch/ppc/boot/of1275/ofinit.c
7590 --- a/arch/ppc/boot/of1275/ofinit.c     Mon Sep 16 22:18:13 2002
7591 +++ b/arch/ppc/boot/of1275/ofinit.c     Mon Aug 25 05:13:38 2003
7592 @@ -11,9 +11,17 @@
7593  #include "of1275.h"
7594  
7595  prom_entry of_prom_entry;
7596 +ihandle of_prom_mmu;
7597  
7598  void
7599  ofinit(prom_entry prom_ptr)
7600  {
7601 +    phandle chosen;
7602 +
7603      of_prom_entry = prom_ptr;
7604 +   
7605 +    if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE)
7606 +       return;
7607 +    if (getprop(chosen, "mmu", &of_prom_mmu, sizeof(ihandle)) != 4)
7608 +       return;
7609  }
7610 diff -Nru a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile
7611 --- a/arch/ppc/boot/openfirmware/Makefile       Wed Jul 23 08:39:58 2003
7612 +++ b/arch/ppc/boot/openfirmware/Makefile       Mon Aug 25 05:13:38 2003
7613 @@ -22,7 +22,7 @@
7614  images := $(boot)/images
7615  
7616  OBJCOPY_ARGS   := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
7617 -COFF_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00700000 -Bstatic
7618 +COFF_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00500000 -Bstatic
7619  CHRP_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00800000
7620  NEWWORLD_LD_ARGS:= -T $(boot)/ld.script -e _start -Ttext 0x01000000
7621  
7622 diff -Nru a/arch/ppc/boot/openfirmware/coffmain.c b/arch/ppc/boot/openfirmware/coffmain.c
7623 --- a/arch/ppc/boot/openfirmware/coffmain.c     Thu Nov  7 03:31:11 2002
7624 +++ b/arch/ppc/boot/openfirmware/coffmain.c     Mon Aug 25 05:13:38 2003
7625 @@ -32,16 +32,16 @@
7626  char *begin_avail, *end_avail;
7627  char *avail_high;
7628  
7629 -#define RAM_START      0
7630 -#define RAM_END                (RAM_START + 0x800000)  /* only 8M mapped with BATs */
7631 -
7632 -#define PROG_START     RAM_START
7633 -#define PROG_SIZE      0x00700000
7634 -
7635  #define SCRATCH_SIZE   (128 << 10)
7636  
7637  static char heap[SCRATCH_SIZE];
7638  
7639 +static unsigned long ram_start = 0;
7640 +static unsigned long ram_end = 0x1000000;
7641 +static unsigned long prog_start = 0x800000;
7642 +static unsigned long prog_size = 0x800000;
7643 +
7644 +
7645  typedef void (*kernel_start_t)(int, int, void *);
7646  
7647  void boot(int a1, int a2, void *prom)
7648 @@ -52,32 +52,34 @@
7649      unsigned initrd_start, initrd_size;
7650      
7651      printf("coffboot starting: loaded at 0x%p\n", &_start);
7652 -    setup_bats(RAM_START);
7653 +    setup_bats(ram_start);
7654  
7655      initrd_size = (char *)(&__ramdisk_end) - (char *)(&__ramdisk_begin);
7656      if (initrd_size) {
7657 -       initrd_start = (RAM_END - initrd_size) & ~0xFFF;
7658 +       initrd_start = (ram_end - initrd_size) & ~0xFFF;
7659         a1 = initrd_start;
7660         a2 = initrd_size;
7661 -       claim(initrd_start, RAM_END - initrd_start, 0);
7662 +       claim(initrd_start, ram_end - initrd_start, 0);
7663         printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r",
7664                initrd_start, (char *)(&__ramdisk_begin), initrd_size);
7665         memcpy((char *)initrd_start, (char *)(&__ramdisk_begin), initrd_size);
7666 +       prog_size = initrd_start - prog_start;
7667      } else
7668         a2 = 0xdeadbeef;
7669  
7670      im = (char *)(&__image_begin);
7671      len = (char *)(&__image_end) - (char *)(&__image_begin);
7672 -    /* claim 4MB starting at 0 */
7673 -    claim(0, PROG_SIZE, 0);
7674 -    dst = (void *) RAM_START;
7675 +    /* claim 4MB starting at PROG_START */
7676 +    claim(prog_start, prog_size, 0);
7677 +    map(prog_start, prog_start, prog_size);
7678 +    dst = (void *) prog_start;
7679      if (im[0] == 0x1f && im[1] == 0x8b) {
7680         /* set up scratch space */
7681         begin_avail = avail_high = avail_ram = heap;
7682         end_avail = heap + sizeof(heap);
7683         printf("heap at 0x%p\n", avail_ram);
7684         printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
7685 -       gunzip(dst, PROG_SIZE, im, &len);
7686 +       gunzip(dst, prog_size, im, &len);
7687         printf("done %u bytes\n", len);
7688         printf("%u bytes of heap consumed, max in use %u\n",
7689                avail_high - begin_avail, heap_max);
7690 @@ -87,9 +89,9 @@
7691  
7692      flush_cache(dst, len);
7693      make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac,
7694 -                   (PROG_START + PROG_SIZE));
7695 +                   (prog_start + prog_size));
7696  
7697 -    sa = (unsigned long)PROG_START;
7698 +    sa = (unsigned long)prog_start;
7699      printf("start address = 0x%x\n", sa);
7700  
7701      (*(kernel_start_t)sa)(a1, a2, prom);
7702 diff -Nru a/arch/ppc/boot/openfirmware/misc.S b/arch/ppc/boot/openfirmware/misc.S
7703 --- a/arch/ppc/boot/openfirmware/misc.S Mon Sep 16 21:54:12 2002
7704 +++ b/arch/ppc/boot/openfirmware/misc.S Mon Aug 25 05:13:38 2003
7705 @@ -9,7 +9,7 @@
7706         .text
7707  
7708  /*
7709 - * Use the BAT3 registers to map the 1st 8MB of RAM to
7710 + * Use the BAT2 & 3 registers to map the 1st 16MB of RAM to
7711   * the address given as the 1st argument.
7712   */
7713         .globl  setup_bats
7714 @@ -22,6 +22,10 @@
7715         mtibatl 3,0                     /* invalidate BAT first */
7716         ori     3,3,4                   /* set up BAT registers for 601 */
7717         li      4,0x7f
7718 +       mtibatu 2,3
7719 +       mtibatl 2,4
7720 +       oris    3,3,0x80
7721 +       oris    4,4,0x80
7722         mtibatu 3,3
7723         mtibatl 3,4
7724         b       5f
7725 @@ -29,6 +33,12 @@
7726         mtibatu 3,0
7727         ori     3,3,0xff                /* set up BAT registers for 604 */
7728         li      4,2
7729 +       mtdbatl 2,4
7730 +       mtdbatu 2,3
7731 +       mtibatl 2,4
7732 +       mtibatu 2,3
7733 +       oris    3,3,0x80
7734 +       oris    4,4,0x80
7735         mtdbatl 3,4
7736         mtdbatu 3,3
7737         mtibatl 3,4
7738 diff -Nru a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
7739 --- a/arch/ppc/boot/simple/Makefile     Tue Jul  1 17:01:18 2003
7740 +++ b/arch/ppc/boot/simple/Makefile     Wed Sep  3 05:16:34 2003
7741 @@ -22,7 +22,6 @@
7742  # get_mem_size(), which is memory controller dependent.  Add in the correct
7743  # XXX_memory.o file for this to work, as well as editing the $(MISC) file.
7744  
7745 -boot: zImage
7746  
7747  boot                           := arch/ppc/boot
7748  common                         := $(boot)/common
7749 @@ -32,86 +31,95 @@
7750  
7751  # Normally, we use the 'misc.c' file for decompress_kernel and
7752  # whatnot.  Sometimes we need to override this however.
7753 -MISC                           := misc.o
7754 -ifeq ($(CONFIG_IBM_OPENBIOS),y)
7755 -ZIMAGE                         := zImage-TREE
7756 -ZIMAGEINITRD                   := zImage.initrd-TREE
7757 -END                            := treeboot
7758 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
7759 -MISC                           := misc-embedded.o
7760 -endif
7761 -ifeq ($(CONFIG_EMBEDDEDBOOT),y)
7762 -TFTPIMAGE                      := /tftpboot/zImage.embedded
7763 -MISC                           := misc-embedded.o
7764 -endif
7765 -ifeq ($(CONFIG_EBONY),y)
7766 -ZIMAGE                         := zImage-TREE
7767 -ZIMAGEINITRD                   := zImage.initrd-TREE
7768 -END                            := ebony
7769 -ENTRYPOINT                     := 0x01000000
7770 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
7771 -endif
7772 -ifeq ($(CONFIG_EV64260),y)
7773 -EXTRA                          := misc-ev64260.o
7774 -TFTPIMAGE                      := /tftpboot/zImage.ev64260
7775 -endif
7776 -ifeq ($(CONFIG_GEMINI),y)
7777 -ZIMAGE                         := zImage-STRIPELF
7778 -ZIMAGEINITRD                   := zImage.initrd-STRIPELF
7779 -END                            := gemini
7780 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
7781 -endif
7782 -ifeq ($(CONFIG_K2),y)
7783 -EXTRA                          := legacy.o
7784 -TFTPIMAGE                      := /tftpboot/zImage.k2
7785 -endif
7786 -# kbuild-2.4 'feature', only one of these will ever by 'y' at a time.
7787 +misc-y := misc.o
7788 +
7789 +#
7790 +# See arch/ppc/kconfig and arch/ppc/platforms/Kconfig
7791 +# for definition of what platform each config option refer to.
7792 +#----------------------------------------------------------------------------
7793 +      zimage-$(CONFIG_IBM_OPENBIOS)    := zImage-TREE
7794 +zimageinitrd-$(CONFIG_IBM_OPENBIOS)    := zImage.initrd-TREE
7795 +         end-$(CONFIG_IBM_OPENBIOS)    := treeboot
7796 +   tftpimage-$(CONFIG_IBM_OPENBIOS)    := /tftpboot/zImage.$(end-y)
7797 +        misc-$(CONFIG_IBM_OPENBIOS)    := misc-embedded.o
7798 +
7799 +   tftpimage-$(CONFIG_EMBEDDEDBOOT)    :=  /tftpboot/zImage.embedded
7800 +        misc-$(CONFIG_EMBEDDEDBOOT)    := misc-embedded.o
7801 +
7802 +      zimage-$(CONFIG_EBONY)           := zImage-TREE
7803 +zimageinitrd-$(CONFIG_EBONY)           := zImage.initrd-TREE
7804 +         end-$(CONFIG_EBONY)           := ebony
7805 +  entrypoint-$(CONFIG_EBONY)           := 0x01000000
7806 +   tftpimage-$(CONFIG_EBONY)           := /tftpboot/zImage.$(end-y)
7807 +
7808 +      zimage-$(CONFIG_OCOTEA)          := zImage-TREE
7809 +zimageinitrd-$(CONFIG_OCOTEA)          := zImage.initrd-TREE
7810 +         end-$(CONFIG_OCOTEA)          := ocotea
7811 +  entrypoint-$(CONFIG_OCOTEA)          := 0x01000000
7812 +   tftpimage-$(CONFIG_OCOTEA)          := /tftpboot/zImage.$(end-y)
7813 +
7814 +     extra.o-$(CONFIG_EV64260)         := direct.o misc-ev64260.o
7815 +   tftpimage-$(CONFIG_EV64260)         := /tftpboot/zImage.ev64260
7816 +
7817 +      zimage-$(CONFIG_GEMINI)          := zImage-STRIPELF
7818 +zimageinitrd-$(CONFIG_GEMINI)          := zImage.initrd-STRIPELF
7819 +         end-$(CONFIG_GEMINI)          := gemini
7820 +   tftpimage-$(CONFIG_GEMINI)          := /tftpboot/zImage.$(end-y)
7821 +
7822 +     extra.o-$(CONFIG_K2)              := legacy.o
7823 +   tftpimage-$(CONFIG_K2)              := /tftpboot/zImage.k2
7824 +
7825 +# kconfig 'feature', only one of these will ever by 'y' at a time.
7826  # The rest will be unset.
7827 -ifeq ($(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750)$(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS),y)
7828 -ZIMAGE                         := zImage-PPLUS
7829 -ZIMAGEINITRD                   := zImage.initrd-PPLUS
7830 -TFTPIMAGE                      := /tftpboot/zImage.pplus
7831 -ZNETBOOT                       := zImage.pplus
7832 -ZNETBOOTRD                     := zImage.initrd.pplus
7833 -endif
7834 -ifeq ($(CONFIG_PPLUS),y)
7835 -EXTRA                          := legacy.o
7836 -endif
7837 -ifeq ($(CONFIG_PCORE)$(CONFIG_POWERPMC250),y)
7838 -ZIMAGE                         := zImage-STRIPELF
7839 -ZIMAGEINITRD                   := zImage.initrd-STRIPELF
7840 -EXTRA                          := chrpmap.o
7841 -END                            := pcore
7842 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
7843 -endif
7844 -ifeq ($(CONFIG_SANDPOINT),y)
7845 -TFTPIMAGE                      := /tftpboot/zImage.sandpoint
7846 -endif
7847 -ifeq ($(CONFIG_SPRUCE),y)
7848 -ZIMAGE                         := zImage-TREE
7849 -ZIMAGEINITRD                   := zImage.initrd-TREE
7850 -END                            := spruce
7851 -ENTRYPOINT                     := 0x00800000
7852 -MISC                           := misc-spruce.o
7853 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
7854 -endif
7855 -ifeq ($(CONFIG_SMP),y)
7856 -TFTPIMAGE                      += .smp
7857 -endif
7858 -ifeq ($(CONFIG_REDWOOD_4),y)
7859 +multi := $(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750) \
7860 +$(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS)
7861 +      zimage-$(multi)                  := zImage-PPLUS
7862 +zimageinitrd-$(multi)                  := zImage.initrd-PPLUS
7863 +   tftpimage-$(multi)                  := /tftpboot/zImage.pplus
7864 +    znetboot-$(multi)                  := zImage.pplus
7865 +  znetbootrd-$(multi)                  := zImage.initrd.pplus
7866 +
7867 +# Overrides previous assingment
7868 +     extra.o-$(CONFIG_PPLUS)           := legacy.o
7869 +
7870 +      zimage-$(CONFIG_PCORE)           := zImage-STRIPELF
7871 +zimageinitrd-$(CONFIG_PCORE)           := zImage.initrd-STRIPELF
7872 +     extra.o-$(CONFIG_PCORE)           := chrpmap.o
7873 +         end-$(CONFIG_PCORE)           := pcore
7874 +   tftpimage-$(CONFIG_PCORE)           := /tftpboot/zImage.$(end-y)
7875 +
7876 +      zimage-$(CONFIG_POWERPMC250)     := zImage-STRIPELF
7877 +zimageinitrd-$(CONFIG_POWERPMC250)     := zImage.initrd-STRIPELF
7878 +     extra.o-$(CONFIG_POWERPMC250)     := chrpmap.o
7879 +         end-$(CONFIG_POWERPMC250)     := pcore
7880 +   tftpimage-$(CONFIG_POWERPMC250)     := /tftpboot/zImage.$(end-y)
7881 +
7882 +   tftpimage-$(CONFIG_SANDPOINT)       := /tftpboot/zImage.sandpoint
7883 +
7884 +      zimage-$(CONFIG_SPRUCE)          := zImage-TREE
7885 +zimageinitrd-$(CONFIG_SPRUCE)          := zImage.initrd-TREE
7886 +         end-$(CONFIG_SPRUCE)          := spruce
7887 +  entrypoint-$(CONFIG_SPRUCE)          := 0x00800000
7888 +        misc-$(CONFIG_SPRUCE)          := misc-spruce.o
7889 +   tftpimage-$(CONFIG_SPRUCE)          := /tftpboot/zImage.$(end-y)
7890 +
7891 +
7892 +# tftp image is prefixed with .smp if compiled for SMP
7893 +tftpimage-$(CONFIG_SMP)        += .smp
7894 +
7895  # This is a treeboot that needs init functions until the
7896  # boot rom is sorted out (i.e. this is short lived)
7897 -EXTRA_AFLAGS                   := -Wa,-m405
7898 -EXTRA                          := rw4/rw4_init.o rw4/rw4_init_brd.o
7899 -endif
7900 +extra-aflags-$(CONFIG_REDWOOD_4)       := -Wa,-m405
7901 +extra.o-$(CONFIG_REDWOOD_4)            := rw4/rw4_init.o rw4/rw4_init_brd.o
7902 +EXTRA_AFLAGS := $(extra-aflags-y)
7903  
7904  # Linker args.  This specifies where the image will be run at.
7905 -LD_ARGS                                = -T $(boot)/ld.script \
7906 -                                       -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
7907 +LD_ARGS                                := -T $(boot)/ld.script \
7908 +                                  -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
7909  OBJCOPY_ARGS                   := -O elf32-powerpc
7910  
7911  # head.o and relocate.o must be at the start.
7912 -boot-y                         := head.o relocate.o $(EXTRA) $(MISC) 
7913 +boot-y                         := head.o relocate.o $(extra.o-y) $(misc-y) 
7914  boot-$(CONFIG_40x)             += embed_config.o
7915  boot-$(CONFIG_8xx)             += embed_config.o
7916  boot-$(CONFIG_8260)            += embed_config.o
7917 @@ -160,40 +168,40 @@
7918                 -R .stabstr -R .sysmap
7919  
7920  # Sort-of dummy rules, that let us format the image we want.
7921 -zImage: $(images)/$(ZIMAGE) $(obj)/zvmlinux
7922 +zImage: $(images)/$(zimage-y) $(obj)/zvmlinux
7923         cp -f $(obj)/zvmlinux $(images)/zImage.elf
7924         rm -f $(obj)/zvmlinux
7925  
7926 -zImage.initrd: $(images)/$(ZIMAGEINITRD) $(obj)/zvmlinux.initrd
7927 +zImage.initrd: $(images)/$(zimageinitrd-y) $(obj)/zvmlinux.initrd
7928         cp -f $(obj)/zvmlinux.initrd $(images)/zImage.initrd.elf
7929         rm -f $(obj)/zvmlinux.initrd
7930  
7931  znetboot: zImage
7932  ifneq ($(ZNETBOOT),)
7933 -       cp $(images)/$(ZNETBOOT) $(TFTPIMAGE)
7934 +       cp $(images)/$(ZNETBOOT) $(tftpimage-y)
7935  else
7936 -       cp $(images)/zImage.* $(TFTPIMAGE)
7937 +       cp $(images)/zImage.* $(tftpimage-y)
7938  endif
7939  
7940  znetboot.initrd: zImage.initrd
7941 -ifneq ($(ZNETBOOTRD),)
7942 -       cp $(images)/$(ZNETBOOTRD) $(TFTPIMAGE)
7943 +ifneq ($(znetbootrd-y),)
7944 +       cp $(images)/$(znetbootrd-y) $(tftpimage-y)
7945  else
7946 -       cp $(images)/zImage.* $(TFTPIMAGE)
7947 +       cp $(images)/zImage.* $(tftpimage-y)
7948  endif
7949  
7950  $(images)/zImage-STRIPELF: $(obj)/zvmlinux
7951 -       dd if=$(obj)/zvmlinux of=$(images)/zImage.$(END) skip=64 bs=1k
7952 +       dd if=$(obj)/zvmlinux of=$(images)/zImage.$(end-y) skip=64 bs=1k
7953  
7954  $(images)/zImage.initrd-STRIPELF: $(obj)/zvmlinux.initrd
7955 -       dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(END) \
7956 +       dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(end-y) \
7957                 skip=64 bs=1k
7958  
7959  $(images)/zImage-TREE: $(obj)/zvmlinux $(MKTREE)
7960 -       $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(END) $(ENTRYPOINT)
7961 +       $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(end-y) $(ENTRYPOINT)
7962  
7963  $(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE)
7964 -       $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(END) \
7965 +       $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \
7966                 $(ENTRYPOINT)
7967  
7968  $(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT)
7969 diff -Nru a/arch/ppc/boot/simple/embed_config.c b/arch/ppc/boot/simple/embed_config.c
7970 --- a/arch/ppc/boot/simple/embed_config.c       Sat Mar 22 17:18:48 2003
7971 +++ b/arch/ppc/boot/simple/embed_config.c       Thu Aug 21 10:17:00 2003
7972 @@ -20,6 +20,7 @@
7973  #ifdef CONFIG_40x
7974  #include <asm/io.h>
7975  #endif
7976 +extern unsigned long timebase_period_ns;
7977  
7978  /* For those boards that don't provide one.
7979  */
7980 @@ -768,6 +769,7 @@
7981  #if defined(CONFIG_REDWOOD_5) || defined (CONFIG_REDWOOD_6)
7982         bd->bi_tbfreq = 27 * 1000 * 1000;
7983  #endif
7984 +       timebase_period_ns = 1000000000 / bd->bi_tbfreq;
7985  }
7986  #endif /* CONFIG_BEECH */
7987  #endif /* CONFIG_IBM_OPENBIOS */
7988 diff -Nru a/arch/ppc/boot/simple/misc-embedded.c b/arch/ppc/boot/simple/misc-embedded.c
7989 --- a/arch/ppc/boot/simple/misc-embedded.c      Thu Jun  5 18:06:12 2003
7990 +++ b/arch/ppc/boot/simple/misc-embedded.c      Wed Aug 20 15:44:31 2003
7991 @@ -75,7 +75,7 @@
7992  extern void embed_config(bd_t **bp);
7993  
7994  unsigned long
7995 -decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *bp)
7996 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *bp)
7997  {
7998         char *cp, ch;
7999         int timer = 0, zimage_size;
8000 diff -Nru a/arch/ppc/boot/simple/misc-spruce.c b/arch/ppc/boot/simple/misc-spruce.c
8001 --- a/arch/ppc/boot/simple/misc-spruce.c        Tue Feb 11 15:48:52 2003
8002 +++ b/arch/ppc/boot/simple/misc-spruce.c        Wed Aug 20 15:44:31 2003
8003 @@ -147,7 +147,7 @@
8004  #define MEM_B2EA       0x60
8005  
8006  unsigned long
8007 -decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
8008 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
8009  {
8010         int timer = 0;
8011         char *cp, ch;
8012 diff -Nru a/arch/ppc/boot/simple/misc.c b/arch/ppc/boot/simple/misc.c
8013 --- a/arch/ppc/boot/simple/misc.c       Tue Feb 11 15:48:52 2003
8014 +++ b/arch/ppc/boot/simple/misc.c       Wed Sep  3 05:16:34 2003
8015 @@ -25,6 +25,9 @@
8016  #include <asm/processor.h>
8017  #include <asm/mmu.h>
8018  #include <asm/bootinfo.h>
8019 +#ifdef CONFIG_44x
8020 +#include <asm/ibm4xx.h>
8021 +#endif
8022  
8023  #include "nonstdio.h"
8024  #include "zlib.h"
8025 @@ -80,6 +83,16 @@
8026         serial_fixups();
8027         com_port = serial_init(0, NULL);
8028  
8029 +#ifdef CONFIG_44x
8030 +       /* Reset MAL */
8031 +       mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR);
8032 +       /* Wait for reset */
8033 +       while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {};
8034 +       /* Reset EMAC */
8035 +       *(volatile unsigned long *)PPC44x_EMAC0_MR0 = 0x20000000;
8036 +       __asm__ __volatile__("eieio");
8037 +#endif
8038 +
8039  #if defined(CONFIG_LOPEC) || defined(CONFIG_PAL4)
8040         /*
8041          * Call get_mem_size(), which is memory controller dependent,
8042 @@ -251,4 +264,11 @@
8043         serial_close(com_port);
8044  
8045         return (struct bi_record *)rec_loc;
8046 +}
8047 +
8048 +/* Allow decompress_kernel to be hooked into.  This is the default. */
8049 +void * __attribute__ ((weak))
8050 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
8051 +{
8052 +               return decompress_kernel(load_addr, num_words, cksum);
8053  }
8054 diff -Nru a/arch/ppc/boot/simple/relocate.S b/arch/ppc/boot/simple/relocate.S
8055 --- a/arch/ppc/boot/simple/relocate.S   Tue Feb 11 15:48:52 2003
8056 +++ b/arch/ppc/boot/simple/relocate.S   Wed Aug 20 15:44:31 2003
8057 @@ -183,7 +183,7 @@
8058         mr      r4,r7           /* Program length */
8059         mr      r5,r6           /* Checksum */
8060         mr      r6,r11          /* Residual data */
8061 -       bl      decompress_kernel
8062 +       bl      load_kernel
8063  
8064         /*
8065          * Make sure the kernel knows we don't have things set in
8066 diff -Nru a/arch/ppc/boot/utils/mktree.c b/arch/ppc/boot/utils/mktree.c
8067 --- a/arch/ppc/boot/utils/mktree.c      Sun Sep 15 21:51:58 2002
8068 +++ b/arch/ppc/boot/utils/mktree.c      Thu Aug 21 15:00:42 2003
8069 @@ -86,7 +86,7 @@
8070         }
8071  
8072         cksum = 0;
8073 -       cp = (uint *)&bt;
8074 +       cp = (void *)&bt;
8075         for (i=0; i<sizeof(bt)/sizeof(uint); i++)
8076                 cksum += *cp++;
8077         
8078 diff -Nru a/arch/ppc/configs/common_defconfig b/arch/ppc/configs/common_defconfig
8079 --- a/arch/ppc/configs/common_defconfig Sat Aug  2 13:06:57 2003
8080 +++ b/arch/ppc/configs/common_defconfig Sat Aug 23 02:33:38 2003
8081 @@ -9,6 +9,7 @@
8082  # Code maturity level options
8083  #
8084  CONFIG_EXPERIMENTAL=y
8085 +# CONFIG_BROKEN is not set
8086  
8087  #
8088  # General setup
8089 @@ -18,9 +19,15 @@
8090  # CONFIG_BSD_PROCESS_ACCT is not set
8091  CONFIG_SYSCTL=y
8092  CONFIG_LOG_BUF_SHIFT=14
8093 +CONFIG_IKCONFIG=y
8094 +CONFIG_IKCONFIG_PROC=y
8095  # CONFIG_EMBEDDED is not set
8096 +CONFIG_KALLSYMS=y
8097  CONFIG_FUTEX=y
8098  CONFIG_EPOLL=y
8099 +CONFIG_IOSCHED_NOOP=y
8100 +CONFIG_IOSCHED_AS=y
8101 +CONFIG_IOSCHED_DEADLINE=y
8102  
8103  #
8104  # Loadable module support
8105 @@ -86,8 +93,8 @@
8106  CONFIG_PCI=y
8107  CONFIG_PCI_DOMAINS=y
8108  CONFIG_KCORE_ELF=y
8109 -CONFIG_BINFMT_ELF=y
8110  CONFIG_KERNEL_ELF=y
8111 +CONFIG_BINFMT_ELF=y
8112  CONFIG_BINFMT_MISC=m
8113  CONFIG_PCI_LEGACY_PROC=y
8114  CONFIG_PCI_NAMES=y
8115 @@ -126,6 +133,11 @@
8116  CONFIG_BOOT_LOAD=0x00800000
8117  
8118  #
8119 +# Generic Driver Options
8120 +#
8121 +# CONFIG_FW_LOADER is not set
8122 +
8123 +#
8124  # Memory Technology Devices (MTD)
8125  #
8126  # CONFIG_MTD is not set
8127 @@ -144,10 +156,12 @@
8128  # CONFIG_BLK_DEV_DAC960 is not set
8129  # CONFIG_BLK_DEV_UMEM is not set
8130  CONFIG_BLK_DEV_LOOP=y
8131 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
8132  # CONFIG_BLK_DEV_NBD is not set
8133  CONFIG_BLK_DEV_RAM=y
8134  CONFIG_BLK_DEV_RAM_SIZE=4096
8135  CONFIG_BLK_DEV_INITRD=y
8136 +CONFIG_LBD=y
8137  
8138  #
8139  # Multi-device support (RAID and LVM)
8140 @@ -155,40 +169,38 @@
8141  # CONFIG_MD is not set
8142  
8143  #
8144 -# ATA/IDE/MFM/RLL support
8145 +# ATA/ATAPI/MFM/RLL support
8146  #
8147  CONFIG_IDE=y
8148 -
8149 -#
8150 -# IDE, ATA and ATAPI Block devices
8151 -#
8152  CONFIG_BLK_DEV_IDE=y
8153  
8154  #
8155  # Please see Documentation/ide.txt for help/info on IDE drives
8156  #
8157 -# CONFIG_BLK_DEV_HD is not set
8158  CONFIG_BLK_DEV_IDEDISK=y
8159  # CONFIG_IDEDISK_MULTI_MODE is not set
8160  # CONFIG_IDEDISK_STROKE is not set
8161  CONFIG_BLK_DEV_IDECD=y
8162 +# CONFIG_BLK_DEV_IDETAPE is not set
8163  CONFIG_BLK_DEV_IDEFLOPPY=y
8164  CONFIG_BLK_DEV_IDESCSI=y
8165  # CONFIG_IDE_TASK_IOCTL is not set
8166 +# CONFIG_IDE_TASKFILE_IO is not set
8167  
8168  #
8169  # IDE chipset support/bugfixes
8170  #
8171  CONFIG_BLK_DEV_IDEPCI=y
8172 -CONFIG_BLK_DEV_GENERIC=y
8173  CONFIG_IDEPCI_SHARE_IRQ=y
8174 +# CONFIG_BLK_DEV_OFFBOARD is not set
8175 +CONFIG_BLK_DEV_GENERIC=y
8176 +# CONFIG_BLK_DEV_OPTI621 is not set
8177 +CONFIG_BLK_DEV_SL82C105=y
8178  CONFIG_BLK_DEV_IDEDMA_PCI=y
8179  # CONFIG_BLK_DEV_IDE_TCQ is not set
8180 -# CONFIG_BLK_DEV_OFFBOARD is not set
8181  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
8182  CONFIG_IDEDMA_PCI_AUTO=y
8183  # CONFIG_IDEDMA_ONLYDISK is not set
8184 -CONFIG_BLK_DEV_IDEDMA=y
8185  # CONFIG_IDEDMA_PCI_WIP is not set
8186  CONFIG_BLK_DEV_ADMA=y
8187  # CONFIG_BLK_DEV_AEC62XX is not set
8188 @@ -198,12 +210,12 @@
8189  # CONFIG_BLK_DEV_TRIFLEX is not set
8190  # CONFIG_BLK_DEV_CY82C693 is not set
8191  # CONFIG_BLK_DEV_CS5520 is not set
8192 +# CONFIG_BLK_DEV_CS5530 is not set
8193  # CONFIG_BLK_DEV_HPT34X is not set
8194  # CONFIG_BLK_DEV_HPT366 is not set
8195  # CONFIG_BLK_DEV_SC1200 is not set
8196  # CONFIG_BLK_DEV_PIIX is not set
8197  # CONFIG_BLK_DEV_NS87415 is not set
8198 -# CONFIG_BLK_DEV_OPTI621 is not set
8199  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
8200  CONFIG_BLK_DEV_PDC202XX_NEW=y
8201  # CONFIG_PDC202XX_FORCE is not set
8202 @@ -212,15 +224,17 @@
8203  # CONFIG_BLK_DEV_SLC90E66 is not set
8204  # CONFIG_BLK_DEV_TRM290 is not set
8205  # CONFIG_BLK_DEV_VIA82CXXX is not set
8206 -CONFIG_BLK_DEV_SL82C105=y
8207  CONFIG_BLK_DEV_IDE_PMAC=y
8208  CONFIG_BLK_DEV_IDEDMA_PMAC=y
8209  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
8210 -CONFIG_IDEDMA_AUTO=y
8211 +CONFIG_BLK_DEV_IDEDMA=y
8212  # CONFIG_IDEDMA_IVB is not set
8213 +CONFIG_IDEDMA_AUTO=y
8214 +# CONFIG_DMA_NONPCI is not set
8215 +# CONFIG_BLK_DEV_HD is not set
8216  
8217  #
8218 -# SCSI support
8219 +# SCSI device support
8220  #
8221  CONFIG_SCSI=y
8222  
8223 @@ -260,8 +274,6 @@
8224  # CONFIG_SCSI_AIC79XX is not set
8225  # CONFIG_SCSI_DPT_I2O is not set
8226  CONFIG_SCSI_ADVANSYS=m
8227 -# CONFIG_SCSI_IN2000 is not set
8228 -# CONFIG_SCSI_AM53C974 is not set
8229  # CONFIG_SCSI_MEGARAID is not set
8230  # CONFIG_SCSI_BUSLOGIC is not set
8231  # CONFIG_SCSI_CPQFCTS is not set
8232 @@ -270,11 +282,8 @@
8233  # CONFIG_SCSI_EATA_PIO is not set
8234  # CONFIG_SCSI_FUTURE_DOMAIN is not set
8235  # CONFIG_SCSI_GDTH is not set
8236 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
8237 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
8238  # CONFIG_SCSI_INITIO is not set
8239  # CONFIG_SCSI_INIA100 is not set
8240 -# CONFIG_SCSI_NCR53C7xx is not set
8241  CONFIG_SCSI_SYM53C8XX_2=y
8242  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
8243  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
8244 @@ -287,7 +296,6 @@
8245  # CONFIG_SCSI_QLOGIC_1280 is not set
8246  # CONFIG_SCSI_DC395x is not set
8247  # CONFIG_SCSI_DC390T is not set
8248 -# CONFIG_SCSI_U14_34F is not set
8249  # CONFIG_SCSI_NSP32 is not set
8250  # CONFIG_SCSI_DEBUG is not set
8251  CONFIG_SCSI_MESH=y
8252 @@ -321,8 +329,6 @@
8253  CONFIG_PACKET=y
8254  # CONFIG_PACKET_MMAP is not set
8255  # CONFIG_NETLINK_DEV is not set
8256 -CONFIG_NETFILTER=y
8257 -# CONFIG_NETFILTER_DEBUG is not set
8258  CONFIG_UNIX=y
8259  # CONFIG_NET_KEY is not set
8260  CONFIG_INET=y
8261 @@ -340,6 +346,16 @@
8262  # CONFIG_INET_IPCOMP is not set
8263  
8264  #
8265 +# IP: Virtual Server Configuration
8266 +#
8267 +# CONFIG_IP_VS is not set
8268 +# CONFIG_IPV6 is not set
8269 +# CONFIG_DECNET is not set
8270 +# CONFIG_BRIDGE is not set
8271 +CONFIG_NETFILTER=y
8272 +# CONFIG_NETFILTER_DEBUG is not set
8273 +
8274 +#
8275  # IP: Netfilter Configuration
8276  #
8277  CONFIG_IP_NF_CONNTRACK=m
8278 @@ -355,6 +371,7 @@
8279  CONFIG_IP_NF_MATCH_MARK=m
8280  CONFIG_IP_NF_MATCH_MULTIPORT=m
8281  CONFIG_IP_NF_MATCH_TOS=m
8282 +CONFIG_IP_NF_MATCH_RECENT=m
8283  CONFIG_IP_NF_MATCH_ECN=m
8284  CONFIG_IP_NF_MATCH_DSCP=m
8285  CONFIG_IP_NF_MATCH_AH_ESP=m
8286 @@ -386,8 +403,6 @@
8287  # CONFIG_IP_NF_ARPTABLES is not set
8288  CONFIG_IP_NF_COMPAT_IPCHAINS=m
8289  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
8290 -# CONFIG_IPV6 is not set
8291 -# CONFIG_XFRM_USER is not set
8292  
8293  #
8294  # SCTP Configuration (EXPERIMENTAL)
8295 @@ -397,8 +412,6 @@
8296  # CONFIG_ATM is not set
8297  # CONFIG_VLAN_8021Q is not set
8298  # CONFIG_LLC is not set
8299 -# CONFIG_DECNET is not set
8300 -# CONFIG_BRIDGE is not set
8301  # CONFIG_X25 is not set
8302  # CONFIG_LAPB is not set
8303  # CONFIG_NET_DIVERT is not set
8304 @@ -482,6 +495,7 @@
8305  # CONFIG_HAMACHI is not set
8306  # CONFIG_YELLOWFIN is not set
8307  # CONFIG_R8169 is not set
8308 +# CONFIG_SIS190 is not set
8309  # CONFIG_SK98LIN is not set
8310  # CONFIG_TIGON3 is not set
8311  
8312 @@ -553,7 +567,7 @@
8313  # Graphics support
8314  #
8315  CONFIG_FB=y
8316 -CONFIG_FB_CIRRUS=y
8317 +# CONFIG_FB_CIRRUS is not set
8318  # CONFIG_FB_PM2 is not set
8319  # CONFIG_FB_CYBER2000 is not set
8320  CONFIG_FB_OF=y
8321 @@ -606,11 +620,6 @@
8322  CONFIG_LOGO_LINUX_CLUT224=y
8323  
8324  #
8325 -# Old CD-ROM drivers (not SCSI, not IDE)
8326 -#
8327 -# CONFIG_CD_NO_IDESCSI is not set
8328 -
8329 -#
8330  # Input device support
8331  #
8332  CONFIG_INPUT=y
8333 @@ -636,6 +645,7 @@
8334  CONFIG_SERIO_I8042=y
8335  # CONFIG_SERIO_SERPORT is not set
8336  # CONFIG_SERIO_CT82C710 is not set
8337 +# CONFIG_SERIO_PCIPS2 is not set
8338  
8339  #
8340  # Input Device Drivers
8341 @@ -703,10 +713,12 @@
8342  #
8343  # I2C Hardware Sensors Mainboard support
8344  #
8345 +# CONFIG_I2C_ALI1535 is not set
8346  # CONFIG_I2C_ALI15X3 is not set
8347  # CONFIG_I2C_AMD756 is not set
8348  # CONFIG_I2C_AMD8111 is not set
8349  # CONFIG_I2C_I801 is not set
8350 +# CONFIG_I2C_NFORCE2 is not set
8351  # CONFIG_I2C_PIIX4 is not set
8352  # CONFIG_I2C_SIS96X is not set
8353  # CONFIG_I2C_VIAPRO is not set
8354 @@ -718,6 +730,7 @@
8355  # CONFIG_SENSORS_IT87 is not set
8356  # CONFIG_SENSORS_LM75 is not set
8357  # CONFIG_SENSORS_LM85 is not set
8358 +# CONFIG_SENSORS_LM78 is not set
8359  # CONFIG_SENSORS_VIA686A is not set
8360  # CONFIG_SENSORS_W83781D is not set
8361  # CONFIG_I2C_SENSOR is not set
8362 @@ -913,13 +926,70 @@
8363  # Sound
8364  #
8365  CONFIG_SOUND=m
8366 -CONFIG_DMASOUND_AWACS=m
8367 -CONFIG_DMASOUND=m
8368 +# CONFIG_DMASOUND_AWACS is not set
8369  
8370  #
8371  # Advanced Linux Sound Architecture
8372  #
8373 -# CONFIG_SND is not set
8374 +CONFIG_SND=m
8375 +CONFIG_SND_SEQUENCER=m
8376 +# CONFIG_SND_SEQ_DUMMY is not set
8377 +CONFIG_SND_OSSEMUL=y
8378 +CONFIG_SND_MIXER_OSS=m
8379 +CONFIG_SND_PCM_OSS=m
8380 +CONFIG_SND_SEQUENCER_OSS=y
8381 +# CONFIG_SND_VERBOSE_PRINTK is not set
8382 +# CONFIG_SND_DEBUG is not set
8383 +
8384 +#
8385 +# Generic devices
8386 +#
8387 +# CONFIG_SND_DUMMY is not set
8388 +# CONFIG_SND_VIRMIDI is not set
8389 +# CONFIG_SND_MTPAV is not set
8390 +# CONFIG_SND_SERIAL_U16550 is not set
8391 +# CONFIG_SND_MPU401 is not set
8392 +
8393 +#
8394 +# PCI devices
8395 +#
8396 +# CONFIG_SND_ALI5451 is not set
8397 +# CONFIG_SND_AZT3328 is not set
8398 +# CONFIG_SND_CS46XX is not set
8399 +# CONFIG_SND_CS4281 is not set
8400 +# CONFIG_SND_EMU10K1 is not set
8401 +# CONFIG_SND_KORG1212 is not set
8402 +# CONFIG_SND_NM256 is not set
8403 +# CONFIG_SND_RME32 is not set
8404 +# CONFIG_SND_RME96 is not set
8405 +# CONFIG_SND_RME9652 is not set
8406 +# CONFIG_SND_HDSP is not set
8407 +# CONFIG_SND_TRIDENT is not set
8408 +# CONFIG_SND_YMFPCI is not set
8409 +# CONFIG_SND_ALS4000 is not set
8410 +# CONFIG_SND_CMIPCI is not set
8411 +# CONFIG_SND_ENS1370 is not set
8412 +# CONFIG_SND_ENS1371 is not set
8413 +# CONFIG_SND_ES1938 is not set
8414 +# CONFIG_SND_ES1968 is not set
8415 +# CONFIG_SND_MAESTRO3 is not set
8416 +# CONFIG_SND_FM801 is not set
8417 +# CONFIG_SND_ICE1712 is not set
8418 +# CONFIG_SND_ICE1724 is not set
8419 +# CONFIG_SND_INTEL8X0 is not set
8420 +# CONFIG_SND_SONICVIBES is not set
8421 +# CONFIG_SND_VIA82XX is not set
8422 +# CONFIG_SND_VX222 is not set
8423 +
8424 +#
8425 +# ALSA PowerMac devices
8426 +#
8427 +CONFIG_SND_POWERMAC=m
8428 +
8429 +#
8430 +# ALSA USB devices
8431 +#
8432 +CONFIG_SND_USB_AUDIO=m
8433  
8434  #
8435  # Open Sound System
8436 @@ -998,6 +1068,7 @@
8437  #
8438  # USB Network adaptors
8439  #
8440 +# CONFIG_USB_AX8817X is not set
8441  # CONFIG_USB_CATC is not set
8442  # CONFIG_USB_KAWETH is not set
8443  # CONFIG_USB_PEGASUS is not set
8444 @@ -1074,7 +1145,6 @@
8445  # Kernel hacking
8446  #
8447  # CONFIG_DEBUG_KERNEL is not set
8448 -CONFIG_KALLSYMS=y
8449  CONFIG_BOOTX_TEXT=y
8450  
8451  #
8452 diff -Nru a/arch/ppc/configs/ebony_defconfig b/arch/ppc/configs/ebony_defconfig
8453 --- /dev/null   Wed Dec 31 16:00:00 1969
8454 +++ b/arch/ppc/configs/ebony_defconfig  Wed Sep  3 05:16:34 2003
8455 @@ -0,0 +1,560 @@
8456 +#
8457 +# Automatically generated make config: don't edit
8458 +#
8459 +CONFIG_MMU=y
8460 +CONFIG_RWSEM_XCHGADD_ALGORITHM=y
8461 +CONFIG_HAVE_DEC_LOCK=y
8462 +
8463 +#
8464 +# Code maturity level options
8465 +#
8466 +CONFIG_EXPERIMENTAL=y
8467 +CONFIG_CLEAN_COMPILE=y
8468 +CONFIG_BROKEN_ON_SMP=y
8469 +
8470 +#
8471 +# General setup
8472 +#
8473 +CONFIG_SWAP=y
8474 +CONFIG_SYSVIPC=y
8475 +# CONFIG_BSD_PROCESS_ACCT is not set
8476 +CONFIG_SYSCTL=y
8477 +CONFIG_LOG_BUF_SHIFT=14
8478 +# CONFIG_IKCONFIG is not set
8479 +# CONFIG_EMBEDDED is not set
8480 +CONFIG_KALLSYMS=y
8481 +CONFIG_FUTEX=y
8482 +CONFIG_EPOLL=y
8483 +CONFIG_IOSCHED_NOOP=y
8484 +CONFIG_IOSCHED_AS=y
8485 +CONFIG_IOSCHED_DEADLINE=y
8486 +
8487 +#
8488 +# Loadable module support
8489 +#
8490 +CONFIG_MODULES=y
8491 +# CONFIG_MODULE_UNLOAD is not set
8492 +CONFIG_OBSOLETE_MODPARM=y
8493 +# CONFIG_MODVERSIONS is not set
8494 +CONFIG_KMOD=y
8495 +
8496 +#
8497 +# Platform support
8498 +#
8499 +CONFIG_PPC=y
8500 +CONFIG_PPC32=y
8501 +# CONFIG_6xx is not set
8502 +# CONFIG_40x is not set
8503 +CONFIG_44x=y
8504 +# CONFIG_POWER3 is not set
8505 +# CONFIG_8xx is not set
8506 +CONFIG_PTE_64BIT=y
8507 +CONFIG_4xx=y
8508 +
8509 +#
8510 +# IBM 4xx options
8511 +#
8512 +CONFIG_EBONY=y
8513 +# CONFIG_OCOTEA is not set
8514 +CONFIG_440GP=y
8515 +CONFIG_440=y
8516 +CONFIG_PIN_TLB=y
8517 +CONFIG_BOOKE=y
8518 +CONFIG_IBM_OCP=y
8519 +# CONFIG_PM is not set
8520 +CONFIG_NOT_COHERENT_CACHE=y
8521 +# CONFIG_SMP is not set
8522 +# CONFIG_PREEMPT is not set
8523 +# CONFIG_MATH_EMULATION is not set
8524 +# CONFIG_CPU_FREQ is not set
8525 +
8526 +#
8527 +# General setup
8528 +#
8529 +# CONFIG_HIGHMEM is not set
8530 +CONFIG_PCI=y
8531 +CONFIG_PCI_DOMAINS=y
8532 +# CONFIG_PC_KEYBOARD is not set
8533 +CONFIG_KERNEL_ELF=y
8534 +CONFIG_BINFMT_ELF=y
8535 +# CONFIG_BINFMT_MISC is not set
8536 +# CONFIG_PCI_LEGACY_PROC is not set
8537 +# CONFIG_PCI_NAMES is not set
8538 +# CONFIG_HOTPLUG is not set
8539 +
8540 +#
8541 +# Parallel port support
8542 +#
8543 +# CONFIG_PARPORT is not set
8544 +CONFIG_CMDLINE_BOOL=y
8545 +CONFIG_CMDLINE="ip=on"
8546 +
8547 +#
8548 +# Advanced setup
8549 +#
8550 +# CONFIG_ADVANCED_OPTIONS is not set
8551 +
8552 +#
8553 +# Default settings for advanced configuration options are used
8554 +#
8555 +CONFIG_HIGHMEM_START=0xfe000000
8556 +CONFIG_LOWMEM_SIZE=0x30000000
8557 +CONFIG_KERNEL_START=0xc0000000
8558 +CONFIG_TASK_SIZE=0x80000000
8559 +CONFIG_BOOT_LOAD=0x01000000
8560 +
8561 +#
8562 +# Generic Driver Options
8563 +#
8564 +
8565 +#
8566 +# Memory Technology Devices (MTD)
8567 +#
8568 +# CONFIG_MTD is not set
8569 +
8570 +#
8571 +# Plug and Play support
8572 +#
8573 +# CONFIG_PNP is not set
8574 +
8575 +#
8576 +# Block devices
8577 +#
8578 +# CONFIG_BLK_DEV_FD is not set
8579 +# CONFIG_BLK_CPQ_DA is not set
8580 +# CONFIG_BLK_CPQ_CISS_DA is not set
8581 +# CONFIG_BLK_DEV_DAC960 is not set
8582 +# CONFIG_BLK_DEV_UMEM is not set
8583 +# CONFIG_BLK_DEV_LOOP is not set
8584 +# CONFIG_BLK_DEV_NBD is not set
8585 +# CONFIG_BLK_DEV_RAM is not set
8586 +# CONFIG_BLK_DEV_INITRD is not set
8587 +CONFIG_LBD=y
8588 +
8589 +#
8590 +# Multi-device support (RAID and LVM)
8591 +#
8592 +# CONFIG_MD is not set
8593 +
8594 +#
8595 +# ATA/ATAPI/MFM/RLL support
8596 +#
8597 +# CONFIG_IDE is not set
8598 +
8599 +#
8600 +# SCSI device support
8601 +#
8602 +# CONFIG_SCSI is not set
8603 +
8604 +#
8605 +# Fusion MPT device support
8606 +#
8607 +
8608 +#
8609 +# IEEE 1394 (FireWire) support (EXPERIMENTAL)
8610 +#
8611 +# CONFIG_IEEE1394 is not set
8612 +
8613 +#
8614 +# I2O device support
8615 +#
8616 +# CONFIG_I2O is not set
8617 +
8618 +#
8619 +# Networking support
8620 +#
8621 +CONFIG_NET=y
8622 +
8623 +#
8624 +# Networking options
8625 +#
8626 +CONFIG_PACKET=y
8627 +# CONFIG_PACKET_MMAP is not set
8628 +# CONFIG_NETLINK_DEV is not set
8629 +CONFIG_UNIX=y
8630 +# CONFIG_NET_KEY is not set
8631 +CONFIG_INET=y
8632 +# CONFIG_IP_MULTICAST is not set
8633 +# CONFIG_IP_ADVANCED_ROUTER is not set
8634 +CONFIG_IP_PNP=y
8635 +# CONFIG_IP_PNP_DHCP is not set
8636 +CONFIG_IP_PNP_BOOTP=y
8637 +# CONFIG_IP_PNP_RARP is not set
8638 +# CONFIG_NET_IPIP is not set
8639 +# CONFIG_NET_IPGRE is not set
8640 +# CONFIG_ARPD is not set
8641 +# CONFIG_INET_ECN is not set
8642 +# CONFIG_SYN_COOKIES is not set
8643 +# CONFIG_INET_AH is not set
8644 +# CONFIG_INET_ESP is not set
8645 +# CONFIG_INET_IPCOMP is not set
8646 +
8647 +#
8648 +# IP: Virtual Server Configuration
8649 +#
8650 +# CONFIG_IP_VS is not set
8651 +# CONFIG_IPV6 is not set
8652 +# CONFIG_DECNET is not set
8653 +# CONFIG_BRIDGE is not set
8654 +CONFIG_NETFILTER=y
8655 +# CONFIG_NETFILTER_DEBUG is not set
8656 +
8657 +#
8658 +# IP: Netfilter Configuration
8659 +#
8660 +# CONFIG_IP_NF_CONNTRACK is not set
8661 +# CONFIG_IP_NF_QUEUE is not set
8662 +# CONFIG_IP_NF_IPTABLES is not set
8663 +# CONFIG_IP_NF_ARPTABLES is not set
8664 +# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
8665 +# CONFIG_IP_NF_COMPAT_IPFWADM is not set
8666 +
8667 +#
8668 +# SCTP Configuration (EXPERIMENTAL)
8669 +#
8670 +CONFIG_IPV6_SCTP__=y
8671 +# CONFIG_IP_SCTP is not set
8672 +# CONFIG_ATM is not set
8673 +# CONFIG_VLAN_8021Q is not set
8674 +# CONFIG_LLC is not set
8675 +# CONFIG_X25 is not set
8676 +# CONFIG_LAPB is not set
8677 +# CONFIG_NET_DIVERT is not set
8678 +# CONFIG_ECONET is not set
8679 +# CONFIG_WAN_ROUTER is not set
8680 +# CONFIG_NET_FASTROUTE is not set
8681 +# CONFIG_NET_HW_FLOWCONTROL is not set
8682 +
8683 +#
8684 +# QoS and/or fair queueing
8685 +#
8686 +# CONFIG_NET_SCHED is not set
8687 +
8688 +#
8689 +# Network testing
8690 +#
8691 +# CONFIG_NET_PKTGEN is not set
8692 +CONFIG_NETDEVICES=y
8693 +
8694 +#
8695 +# ARCnet devices
8696 +#
8697 +# CONFIG_ARCNET is not set
8698 +# CONFIG_DUMMY is not set
8699 +# CONFIG_BONDING is not set
8700 +# CONFIG_EQUALIZER is not set
8701 +# CONFIG_TUN is not set
8702 +
8703 +#
8704 +# Ethernet (10 or 100Mbit)
8705 +#
8706 +# CONFIG_NET_ETHERNET is not set
8707 +
8708 +#
8709 +# Ethernet (1000 Mbit)
8710 +#
8711 +# CONFIG_ACENIC is not set
8712 +# CONFIG_DL2K is not set
8713 +# CONFIG_E1000 is not set
8714 +# CONFIG_NS83820 is not set
8715 +# CONFIG_HAMACHI is not set
8716 +# CONFIG_YELLOWFIN is not set
8717 +# CONFIG_R8169 is not set
8718 +# CONFIG_SIS190 is not set
8719 +# CONFIG_SK98LIN is not set
8720 +# CONFIG_TIGON3 is not set
8721 +
8722 +#
8723 +# Ethernet (10000 Mbit)
8724 +#
8725 +# CONFIG_IXGB is not set
8726 +# CONFIG_FDDI is not set
8727 +# CONFIG_HIPPI is not set
8728 +# CONFIG_PPP is not set
8729 +# CONFIG_SLIP is not set
8730 +
8731 +#
8732 +# Wireless LAN (non-hamradio)
8733 +#
8734 +# CONFIG_NET_RADIO is not set
8735 +
8736 +#
8737 +# Token Ring devices (depends on LLC=y)
8738 +#
8739 +# CONFIG_RCPCI is not set
8740 +# CONFIG_SHAPER is not set
8741 +
8742 +#
8743 +# Wan interfaces
8744 +#
8745 +# CONFIG_WAN is not set
8746 +
8747 +#
8748 +# Amateur Radio support
8749 +#
8750 +# CONFIG_HAMRADIO is not set
8751 +
8752 +#
8753 +# IrDA (infrared) support
8754 +#
8755 +# CONFIG_IRDA is not set
8756 +
8757 +#
8758 +# ISDN subsystem
8759 +#
8760 +# CONFIG_ISDN_BOOL is not set
8761 +
8762 +#
8763 +# Graphics support
8764 +#
8765 +# CONFIG_FB is not set
8766 +
8767 +#
8768 +# Console display driver support
8769 +#
8770 +# CONFIG_VGA_CONSOLE is not set
8771 +# CONFIG_MDA_CONSOLE is not set
8772 +CONFIG_DUMMY_CONSOLE=y
8773 +
8774 +#
8775 +# Input device support
8776 +#
8777 +CONFIG_INPUT=y
8778 +
8779 +#
8780 +# Userland interfaces
8781 +#
8782 +CONFIG_INPUT_MOUSEDEV=y
8783 +CONFIG_INPUT_MOUSEDEV_PSAUX=y
8784 +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
8785 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
8786 +# CONFIG_INPUT_JOYDEV is not set
8787 +# CONFIG_INPUT_TSDEV is not set
8788 +# CONFIG_INPUT_EVDEV is not set
8789 +# CONFIG_INPUT_EVBUG is not set
8790 +
8791 +#
8792 +# Input I/O drivers
8793 +#
8794 +# CONFIG_GAMEPORT is not set
8795 +CONFIG_SOUND_GAMEPORT=y
8796 +# CONFIG_SERIO is not set
8797 +
8798 +#
8799 +# Input Device Drivers
8800 +#
8801 +# CONFIG_INPUT_KEYBOARD is not set
8802 +# CONFIG_INPUT_MOUSE is not set
8803 +# CONFIG_INPUT_JOYSTICK is not set
8804 +# CONFIG_INPUT_TOUCHSCREEN is not set
8805 +# CONFIG_INPUT_MISC is not set
8806 +
8807 +#
8808 +# Macintosh device drivers
8809 +#
8810 +
8811 +#
8812 +# Character devices
8813 +#
8814 +CONFIG_VT=y
8815 +CONFIG_VT_CONSOLE=y
8816 +CONFIG_HW_CONSOLE=y
8817 +# CONFIG_SERIAL_NONSTANDARD is not set
8818 +
8819 +#
8820 +# Serial drivers
8821 +#
8822 +CONFIG_SERIAL_8250=y
8823 +CONFIG_SERIAL_8250_CONSOLE=y
8824 +CONFIG_SERIAL_8250_EXTENDED=y
8825 +CONFIG_SERIAL_8250_MANY_PORTS=y
8826 +CONFIG_SERIAL_8250_SHARE_IRQ=y
8827 +# CONFIG_SERIAL_8250_DETECT_IRQ is not set
8828 +# CONFIG_SERIAL_8250_MULTIPORT is not set
8829 +# CONFIG_SERIAL_8250_RSA is not set
8830 +
8831 +#
8832 +# Non-8250 serial port support
8833 +#
8834 +CONFIG_SERIAL_CORE=y
8835 +CONFIG_SERIAL_CORE_CONSOLE=y
8836 +CONFIG_UNIX98_PTYS=y
8837 +CONFIG_UNIX98_PTY_COUNT=256
8838 +
8839 +#
8840 +# I2C support
8841 +#
8842 +# CONFIG_I2C is not set
8843 +
8844 +#
8845 +# I2C Hardware Sensors Mainboard support
8846 +#
8847 +
8848 +#
8849 +# I2C Hardware Sensors Chip support
8850 +#
8851 +# CONFIG_I2C_SENSOR is not set
8852 +
8853 +#
8854 +# Mice
8855 +#
8856 +# CONFIG_BUSMOUSE is not set
8857 +# CONFIG_QIC02_TAPE is not set
8858 +
8859 +#
8860 +# IPMI
8861 +#
8862 +# CONFIG_IPMI_HANDLER is not set
8863 +
8864 +#
8865 +# Watchdog Cards
8866 +#
8867 +# CONFIG_WATCHDOG is not set
8868 +# CONFIG_NVRAM is not set
8869 +# CONFIG_GEN_RTC is not set
8870 +# CONFIG_DTLK is not set
8871 +# CONFIG_R3964 is not set
8872 +# CONFIG_APPLICOM is not set
8873 +
8874 +#
8875 +# Ftape, the floppy tape device driver
8876 +#
8877 +# CONFIG_FTAPE is not set
8878 +# CONFIG_AGP is not set
8879 +# CONFIG_DRM is not set
8880 +# CONFIG_RAW_DRIVER is not set
8881 +# CONFIG_HANGCHECK_TIMER is not set
8882 +
8883 +#
8884 +# Multimedia devices
8885 +#
8886 +# CONFIG_VIDEO_DEV is not set
8887 +
8888 +#
8889 +# Digital Video Broadcasting Devices
8890 +#
8891 +# CONFIG_DVB is not set
8892 +
8893 +#
8894 +# File systems
8895 +#
8896 +# CONFIG_EXT2_FS is not set
8897 +# CONFIG_EXT3_FS is not set
8898 +# CONFIG_JBD is not set
8899 +# CONFIG_REISERFS_FS is not set
8900 +# CONFIG_JFS_FS is not set
8901 +# CONFIG_XFS_FS is not set
8902 +# CONFIG_MINIX_FS is not set
8903 +# CONFIG_ROMFS_FS is not set
8904 +# CONFIG_QUOTA is not set
8905 +# CONFIG_AUTOFS_FS is not set
8906 +# CONFIG_AUTOFS4_FS is not set
8907 +
8908 +#
8909 +# CD-ROM/DVD Filesystems
8910 +#
8911 +# CONFIG_ISO9660_FS is not set
8912 +# CONFIG_UDF_FS is not set
8913 +
8914 +#
8915 +# DOS/FAT/NT Filesystems
8916 +#
8917 +# CONFIG_FAT_FS is not set
8918 +# CONFIG_NTFS_FS is not set
8919 +
8920 +#
8921 +# Pseudo filesystems
8922 +#
8923 +CONFIG_PROC_FS=y
8924 +# CONFIG_DEVFS_FS is not set
8925 +CONFIG_DEVPTS_FS=y
8926 +# CONFIG_DEVPTS_FS_XATTR is not set
8927 +# CONFIG_TMPFS is not set
8928 +CONFIG_RAMFS=y
8929 +
8930 +#
8931 +# Miscellaneous filesystems
8932 +#
8933 +# CONFIG_ADFS_FS is not set
8934 +# CONFIG_AFFS_FS is not set
8935 +# CONFIG_HFS_FS is not set
8936 +# CONFIG_BEFS_FS is not set
8937 +# CONFIG_BFS_FS is not set
8938 +# CONFIG_EFS_FS is not set
8939 +# CONFIG_CRAMFS is not set
8940 +# CONFIG_VXFS_FS is not set
8941 +# CONFIG_HPFS_FS is not set
8942 +# CONFIG_QNX4FS_FS is not set
8943 +# CONFIG_SYSV_FS is not set
8944 +# CONFIG_UFS_FS is not set
8945 +
8946 +#
8947 +# Network File Systems
8948 +#
8949 +CONFIG_NFS_FS=y
8950 +# CONFIG_NFS_V3 is not set
8951 +# CONFIG_NFS_V4 is not set
8952 +# CONFIG_NFSD is not set
8953 +CONFIG_ROOT_NFS=y
8954 +CONFIG_LOCKD=y
8955 +# CONFIG_EXPORTFS is not set
8956 +CONFIG_SUNRPC=y
8957 +# CONFIG_SUNRPC_GSS is not set
8958 +# CONFIG_SMB_FS is not set
8959 +# CONFIG_CIFS is not set
8960 +# CONFIG_NCP_FS is not set
8961 +# CONFIG_CODA_FS is not set
8962 +# CONFIG_INTERMEZZO_FS is not set
8963 +# CONFIG_AFS_FS is not set
8964 +
8965 +#
8966 +# Partition Types
8967 +#
8968 +# CONFIG_PARTITION_ADVANCED is not set
8969 +CONFIG_MSDOS_PARTITION=y
8970 +
8971 +#
8972 +# Sound
8973 +#
8974 +# CONFIG_SOUND is not set
8975 +
8976 +#
8977 +# USB support
8978 +#
8979 +# CONFIG_USB is not set
8980 +# CONFIG_USB_GADGET is not set
8981 +
8982 +#
8983 +# Bluetooth support
8984 +#
8985 +# CONFIG_BT is not set
8986 +
8987 +#
8988 +# Library routines
8989 +#
8990 +CONFIG_CRC32=y
8991 +
8992 +#
8993 +# Kernel hacking
8994 +#
8995 +CONFIG_DEBUG_KERNEL=y
8996 +# CONFIG_DEBUG_SLAB is not set
8997 +# CONFIG_MAGIC_SYSRQ is not set
8998 +# CONFIG_DEBUG_SPINLOCK is not set
8999 +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
9000 +# CONFIG_KGDB is not set
9001 +# CONFIG_XMON is not set
9002 +CONFIG_BDI_SWITCH=y
9003 +# CONFIG_DEBUG_INFO is not set
9004 +# CONFIG_SERIAL_TEXT_DEBUG is not set
9005 +CONFIG_OCP=y
9006 +
9007 +#
9008 +# Security options
9009 +#
9010 +# CONFIG_SECURITY is not set
9011 +
9012 +#
9013 +# Cryptographic options
9014 +#
9015 +# CONFIG_CRYPTO is not set
9016 diff -Nru a/arch/ppc/configs/ibmchrp_defconfig b/arch/ppc/configs/ibmchrp_defconfig
9017 --- a/arch/ppc/configs/ibmchrp_defconfig        Tue Jul  1 17:01:18 2003
9018 +++ b/arch/ppc/configs/ibmchrp_defconfig        Sat Aug 23 02:33:38 2003
9019 @@ -9,6 +9,7 @@
9020  # Code maturity level options
9021  #
9022  CONFIG_EXPERIMENTAL=y
9023 +# CONFIG_BROKEN is not set
9024  
9025  #
9026  # General setup
9027 @@ -18,9 +19,15 @@
9028  # CONFIG_BSD_PROCESS_ACCT is not set
9029  CONFIG_SYSCTL=y
9030  CONFIG_LOG_BUF_SHIFT=14
9031 +CONFIG_IKCONFIG=y
9032 +CONFIG_IKCONFIG_PROC=y
9033  # CONFIG_EMBEDDED is not set
9034 +CONFIG_KALLSYMS=y
9035  CONFIG_FUTEX=y
9036  CONFIG_EPOLL=y
9037 +CONFIG_IOSCHED_NOOP=y
9038 +CONFIG_IOSCHED_AS=y
9039 +CONFIG_IOSCHED_DEADLINE=y
9040  
9041  #
9042  # Loadable module support
9043 @@ -83,8 +90,8 @@
9044  CONFIG_PCI=y
9045  CONFIG_PCI_DOMAINS=y
9046  CONFIG_KCORE_ELF=y
9047 -CONFIG_BINFMT_ELF=y
9048  CONFIG_KERNEL_ELF=y
9049 +CONFIG_BINFMT_ELF=y
9050  CONFIG_BINFMT_MISC=y
9051  CONFIG_PCI_LEGACY_PROC=y
9052  CONFIG_PCI_NAMES=y
9053 @@ -116,6 +123,10 @@
9054  CONFIG_BOOT_LOAD=0x00800000
9055  
9056  #
9057 +# Generic Driver Options
9058 +#
9059 +
9060 +#
9061  # Memory Technology Devices (MTD)
9062  #
9063  # CONFIG_MTD is not set
9064 @@ -134,10 +145,12 @@
9065  # CONFIG_BLK_DEV_DAC960 is not set
9066  # CONFIG_BLK_DEV_UMEM is not set
9067  CONFIG_BLK_DEV_LOOP=y
9068 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
9069  # CONFIG_BLK_DEV_NBD is not set
9070  CONFIG_BLK_DEV_RAM=y
9071  CONFIG_BLK_DEV_RAM_SIZE=4096
9072  CONFIG_BLK_DEV_INITRD=y
9073 +CONFIG_LBD=y
9074  
9075  #
9076  # Multi-device support (RAID and LVM)
9077 @@ -145,12 +158,12 @@
9078  # CONFIG_MD is not set
9079  
9080  #
9081 -# ATA/IDE/MFM/RLL support
9082 +# ATA/ATAPI/MFM/RLL support
9083  #
9084  # CONFIG_IDE is not set
9085  
9086  #
9087 -# SCSI support
9088 +# SCSI device support
9089  #
9090  CONFIG_SCSI=y
9091  
9092 @@ -183,8 +196,6 @@
9093  # CONFIG_SCSI_AIC79XX is not set
9094  # CONFIG_SCSI_DPT_I2O is not set
9095  # CONFIG_SCSI_ADVANSYS is not set
9096 -# CONFIG_SCSI_IN2000 is not set
9097 -# CONFIG_SCSI_AM53C974 is not set
9098  # CONFIG_SCSI_MEGARAID is not set
9099  # CONFIG_SCSI_BUSLOGIC is not set
9100  # CONFIG_SCSI_CPQFCTS is not set
9101 @@ -193,11 +204,8 @@
9102  # CONFIG_SCSI_EATA_PIO is not set
9103  # CONFIG_SCSI_FUTURE_DOMAIN is not set
9104  # CONFIG_SCSI_GDTH is not set
9105 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
9106 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
9107  # CONFIG_SCSI_INITIO is not set
9108  # CONFIG_SCSI_INIA100 is not set
9109 -# CONFIG_SCSI_NCR53C7xx is not set
9110  CONFIG_SCSI_SYM53C8XX_2=y
9111  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
9112  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
9113 @@ -210,7 +218,6 @@
9114  # CONFIG_SCSI_QLOGIC_1280 is not set
9115  # CONFIG_SCSI_DC395x is not set
9116  # CONFIG_SCSI_DC390T is not set
9117 -# CONFIG_SCSI_U14_34F is not set
9118  # CONFIG_SCSI_NSP32 is not set
9119  # CONFIG_SCSI_DEBUG is not set
9120  # CONFIG_SCSI_MESH is not set
9121 @@ -242,8 +249,6 @@
9122  CONFIG_PACKET=y
9123  # CONFIG_PACKET_MMAP is not set
9124  # CONFIG_NETLINK_DEV is not set
9125 -CONFIG_NETFILTER=y
9126 -# CONFIG_NETFILTER_DEBUG is not set
9127  CONFIG_UNIX=y
9128  # CONFIG_NET_KEY is not set
9129  CONFIG_INET=y
9130 @@ -261,6 +266,16 @@
9131  # CONFIG_INET_IPCOMP is not set
9132  
9133  #
9134 +# IP: Virtual Server Configuration
9135 +#
9136 +# CONFIG_IP_VS is not set
9137 +# CONFIG_IPV6 is not set
9138 +# CONFIG_DECNET is not set
9139 +# CONFIG_BRIDGE is not set
9140 +CONFIG_NETFILTER=y
9141 +# CONFIG_NETFILTER_DEBUG is not set
9142 +
9143 +#
9144  # IP: Netfilter Configuration
9145  #
9146  CONFIG_IP_NF_CONNTRACK=m
9147 @@ -276,6 +291,7 @@
9148  CONFIG_IP_NF_MATCH_MARK=m
9149  CONFIG_IP_NF_MATCH_MULTIPORT=m
9150  CONFIG_IP_NF_MATCH_TOS=m
9151 +CONFIG_IP_NF_MATCH_RECENT=m
9152  CONFIG_IP_NF_MATCH_ECN=m
9153  CONFIG_IP_NF_MATCH_DSCP=m
9154  CONFIG_IP_NF_MATCH_AH_ESP=m
9155 @@ -306,10 +322,9 @@
9156  CONFIG_IP_NF_TARGET_TCPMSS=m
9157  CONFIG_IP_NF_ARPTABLES=m
9158  CONFIG_IP_NF_ARPFILTER=m
9159 +CONFIG_IP_NF_ARP_MANGLE=m
9160  CONFIG_IP_NF_COMPAT_IPCHAINS=m
9161  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
9162 -# CONFIG_IPV6 is not set
9163 -# CONFIG_XFRM_USER is not set
9164  
9165  #
9166  # SCTP Configuration (EXPERIMENTAL)
9167 @@ -319,8 +334,6 @@
9168  # CONFIG_ATM is not set
9169  # CONFIG_VLAN_8021Q is not set
9170  # CONFIG_LLC is not set
9171 -# CONFIG_DECNET is not set
9172 -# CONFIG_BRIDGE is not set
9173  # CONFIG_X25 is not set
9174  # CONFIG_LAPB is not set
9175  # CONFIG_NET_DIVERT is not set
9176 @@ -396,6 +409,7 @@
9177  # CONFIG_HAMACHI is not set
9178  # CONFIG_YELLOWFIN is not set
9179  # CONFIG_R8169 is not set
9180 +# CONFIG_SIS190 is not set
9181  # CONFIG_SK98LIN is not set
9182  # CONFIG_TIGON3 is not set
9183  
9184 @@ -495,11 +509,6 @@
9185  CONFIG_LOGO_LINUX_CLUT224=y
9186  
9187  #
9188 -# Old CD-ROM drivers (not SCSI, not IDE)
9189 -#
9190 -# CONFIG_CD_NO_IDESCSI is not set
9191 -
9192 -#
9193  # Input device support
9194  #
9195  CONFIG_INPUT=y
9196 @@ -525,6 +534,7 @@
9197  CONFIG_SERIO_I8042=y
9198  CONFIG_SERIO_SERPORT=y
9199  # CONFIG_SERIO_CT82C710 is not set
9200 +# CONFIG_SERIO_PCIPS2 is not set
9201  
9202  #
9203  # Input Device Drivers
9204 @@ -791,7 +801,6 @@
9205  # Kernel hacking
9206  #
9207  # CONFIG_DEBUG_KERNEL is not set
9208 -CONFIG_KALLSYMS=y
9209  # CONFIG_BOOTX_TEXT is not set
9210  
9211  #
9212 diff -Nru a/arch/ppc/configs/mcpn765_defconfig b/arch/ppc/configs/mcpn765_defconfig
9213 --- a/arch/ppc/configs/mcpn765_defconfig        Tue Jul  1 17:01:18 2003
9214 +++ b/arch/ppc/configs/mcpn765_defconfig        Mon Jul 21 09:05:22 2003
9215 @@ -19,6 +19,7 @@
9216  CONFIG_SYSCTL=y
9217  CONFIG_LOG_BUF_SHIFT=14
9218  # CONFIG_EMBEDDED is not set
9219 +CONFIG_KALLSYMS=y
9220  CONFIG_FUTEX=y
9221  CONFIG_EPOLL=y
9222  
9223 @@ -74,8 +75,8 @@
9224  CONFIG_PCI=y
9225  CONFIG_PCI_DOMAINS=y
9226  CONFIG_KCORE_ELF=y
9227 -CONFIG_BINFMT_ELF=y
9228  CONFIG_KERNEL_ELF=y
9229 +CONFIG_BINFMT_ELF=y
9230  # CONFIG_BINFMT_MISC is not set
9231  # CONFIG_PCI_LEGACY_PROC is not set
9232  # CONFIG_PCI_NAMES is not set
9233 @@ -104,6 +105,11 @@
9234  CONFIG_BOOT_LOAD=0x00800000
9235  
9236  #
9237 +# Generic Driver Options
9238 +#
9239 +# CONFIG_FW_LOADER is not set
9240 +
9241 +#
9242  # Memory Technology Devices (MTD)
9243  #
9244  # CONFIG_MTD is not set
9245 @@ -122,10 +128,12 @@
9246  # CONFIG_BLK_DEV_DAC960 is not set
9247  # CONFIG_BLK_DEV_UMEM is not set
9248  CONFIG_BLK_DEV_LOOP=y
9249 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
9250  # CONFIG_BLK_DEV_NBD is not set
9251  CONFIG_BLK_DEV_RAM=y
9252  CONFIG_BLK_DEV_RAM_SIZE=4096
9253  CONFIG_BLK_DEV_INITRD=y
9254 +# CONFIG_LBD is not set
9255  
9256  #
9257  # Multi-device support (RAID and LVM)
9258 @@ -133,12 +141,12 @@
9259  # CONFIG_MD is not set
9260  
9261  #
9262 -# ATA/IDE/MFM/RLL support
9263 +# ATA/ATAPI/MFM/RLL support
9264  #
9265  # CONFIG_IDE is not set
9266  
9267  #
9268 -# SCSI support
9269 +# SCSI device support
9270  #
9271  # CONFIG_SCSI is not set
9272  
9273 @@ -320,11 +328,6 @@
9274  # CONFIG_FB is not set
9275  
9276  #
9277 -# Old CD-ROM drivers (not SCSI, not IDE)
9278 -#
9279 -# CONFIG_CD_NO_IDESCSI is not set
9280 -
9281 -#
9282  # Input device support
9283  #
9284  # CONFIG_INPUT is not set
9285 @@ -526,7 +529,6 @@
9286  # Kernel hacking
9287  #
9288  # CONFIG_DEBUG_KERNEL is not set
9289 -# CONFIG_KALLSYMS is not set
9290  # CONFIG_SERIAL_TEXT_DEBUG is not set
9291  
9292  #
9293 diff -Nru a/arch/ppc/configs/ocotea_defconfig b/arch/ppc/configs/ocotea_defconfig
9294 --- /dev/null   Wed Dec 31 16:00:00 1969
9295 +++ b/arch/ppc/configs/ocotea_defconfig Wed Sep  3 05:16:34 2003
9296 @@ -0,0 +1,574 @@
9297 +#
9298 +# Automatically generated make config: don't edit
9299 +#
9300 +CONFIG_MMU=y
9301 +CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9302 +CONFIG_HAVE_DEC_LOCK=y
9303 +
9304 +#
9305 +# Code maturity level options
9306 +#
9307 +CONFIG_EXPERIMENTAL=y
9308 +CONFIG_CLEAN_COMPILE=y
9309 +CONFIG_BROKEN_ON_SMP=y
9310 +
9311 +#
9312 +# General setup
9313 +#
9314 +CONFIG_SWAP=y
9315 +CONFIG_SYSVIPC=y
9316 +# CONFIG_BSD_PROCESS_ACCT is not set
9317 +CONFIG_SYSCTL=y
9318 +CONFIG_LOG_BUF_SHIFT=14
9319 +# CONFIG_IKCONFIG is not set
9320 +# CONFIG_EMBEDDED is not set
9321 +CONFIG_KALLSYMS=y
9322 +CONFIG_FUTEX=y
9323 +CONFIG_EPOLL=y
9324 +CONFIG_IOSCHED_NOOP=y
9325 +CONFIG_IOSCHED_AS=y
9326 +CONFIG_IOSCHED_DEADLINE=y
9327 +
9328 +#
9329 +# Loadable module support
9330 +#
9331 +CONFIG_MODULES=y
9332 +CONFIG_MODULE_UNLOAD=y
9333 +# CONFIG_MODULE_FORCE_UNLOAD is not set
9334 +CONFIG_OBSOLETE_MODPARM=y
9335 +# CONFIG_MODVERSIONS is not set
9336 +CONFIG_KMOD=y
9337 +
9338 +#
9339 +# Platform support
9340 +#
9341 +CONFIG_PPC=y
9342 +CONFIG_PPC32=y
9343 +# CONFIG_6xx is not set
9344 +# CONFIG_40x is not set
9345 +CONFIG_44x=y
9346 +# CONFIG_POWER3 is not set
9347 +# CONFIG_8xx is not set
9348 +CONFIG_PTE_64BIT=y
9349 +CONFIG_4xx=y
9350 +
9351 +#
9352 +# IBM 4xx options
9353 +#
9354 +# CONFIG_EBONY is not set
9355 +CONFIG_OCOTEA=y
9356 +CONFIG_440GX=y
9357 +CONFIG_440A=y
9358 +CONFIG_PIN_TLB=y
9359 +CONFIG_BOOKE=y
9360 +CONFIG_IBM_OCP=y
9361 +CONFIG_IBM_EMAC4=y
9362 +# CONFIG_PM is not set
9363 +CONFIG_NOT_COHERENT_CACHE=y
9364 +# CONFIG_SMP is not set
9365 +# CONFIG_PREEMPT is not set
9366 +# CONFIG_MATH_EMULATION is not set
9367 +# CONFIG_CPU_FREQ is not set
9368 +
9369 +#
9370 +# General setup
9371 +#
9372 +# CONFIG_HIGHMEM is not set
9373 +CONFIG_PCI=y
9374 +CONFIG_PCI_DOMAINS=y
9375 +# CONFIG_PC_KEYBOARD is not set
9376 +CONFIG_KERNEL_ELF=y
9377 +CONFIG_BINFMT_ELF=y
9378 +# CONFIG_BINFMT_MISC is not set
9379 +# CONFIG_PCI_LEGACY_PROC is not set
9380 +# CONFIG_PCI_NAMES is not set
9381 +# CONFIG_HOTPLUG is not set
9382 +
9383 +#
9384 +# Parallel port support
9385 +#
9386 +# CONFIG_PARPORT is not set
9387 +CONFIG_CMDLINE_BOOL=y
9388 +CONFIG_CMDLINE="ip=on console=ttyS0,115200"
9389 +
9390 +#
9391 +# Advanced setup
9392 +#
9393 +# CONFIG_ADVANCED_OPTIONS is not set
9394 +
9395 +#
9396 +# Default settings for advanced configuration options are used
9397 +#
9398 +CONFIG_HIGHMEM_START=0xfe000000
9399 +CONFIG_LOWMEM_SIZE=0x30000000
9400 +CONFIG_KERNEL_START=0xc0000000
9401 +CONFIG_TASK_SIZE=0x80000000
9402 +CONFIG_BOOT_LOAD=0x01000000
9403 +
9404 +#
9405 +# Generic Driver Options
9406 +#
9407 +
9408 +#
9409 +# Memory Technology Devices (MTD)
9410 +#
9411 +# CONFIG_MTD is not set
9412 +
9413 +#
9414 +# Plug and Play support
9415 +#
9416 +# CONFIG_PNP is not set
9417 +
9418 +#
9419 +# Block devices
9420 +#
9421 +# CONFIG_BLK_DEV_FD is not set
9422 +# CONFIG_BLK_CPQ_DA is not set
9423 +# CONFIG_BLK_CPQ_CISS_DA is not set
9424 +# CONFIG_BLK_DEV_DAC960 is not set
9425 +# CONFIG_BLK_DEV_UMEM is not set
9426 +# CONFIG_BLK_DEV_LOOP is not set
9427 +# CONFIG_BLK_DEV_NBD is not set
9428 +# CONFIG_BLK_DEV_RAM is not set
9429 +# CONFIG_BLK_DEV_INITRD is not set
9430 +# CONFIG_LBD is not set
9431 +
9432 +#
9433 +# Multi-device support (RAID and LVM)
9434 +#
9435 +# CONFIG_MD is not set
9436 +
9437 +#
9438 +# ATA/ATAPI/MFM/RLL support
9439 +#
9440 +# CONFIG_IDE is not set
9441 +
9442 +#
9443 +# SCSI device support
9444 +#
9445 +# CONFIG_SCSI is not set
9446 +
9447 +#
9448 +# Fusion MPT device support
9449 +#
9450 +
9451 +#
9452 +# IEEE 1394 (FireWire) support (EXPERIMENTAL)
9453 +#
9454 +# CONFIG_IEEE1394 is not set
9455 +
9456 +#
9457 +# I2O device support
9458 +#
9459 +# CONFIG_I2O is not set
9460 +
9461 +#
9462 +# Networking support
9463 +#
9464 +CONFIG_NET=y
9465 +
9466 +#
9467 +# Networking options
9468 +#
9469 +CONFIG_PACKET=y
9470 +# CONFIG_PACKET_MMAP is not set
9471 +# CONFIG_NETLINK_DEV is not set
9472 +CONFIG_UNIX=y
9473 +# CONFIG_NET_KEY is not set
9474 +CONFIG_INET=y
9475 +# CONFIG_IP_MULTICAST is not set
9476 +# CONFIG_IP_ADVANCED_ROUTER is not set
9477 +CONFIG_IP_PNP=y
9478 +# CONFIG_IP_PNP_DHCP is not set
9479 +CONFIG_IP_PNP_BOOTP=y
9480 +# CONFIG_IP_PNP_RARP is not set
9481 +# CONFIG_NET_IPIP is not set
9482 +# CONFIG_NET_IPGRE is not set
9483 +# CONFIG_ARPD is not set
9484 +# CONFIG_INET_ECN is not set
9485 +# CONFIG_SYN_COOKIES is not set
9486 +# CONFIG_INET_AH is not set
9487 +# CONFIG_INET_ESP is not set
9488 +# CONFIG_INET_IPCOMP is not set
9489 +
9490 +#
9491 +# IP: Virtual Server Configuration
9492 +#
9493 +# CONFIG_IP_VS is not set
9494 +# CONFIG_IPV6 is not set
9495 +# CONFIG_DECNET is not set
9496 +# CONFIG_BRIDGE is not set
9497 +CONFIG_NETFILTER=y
9498 +# CONFIG_NETFILTER_DEBUG is not set
9499 +
9500 +#
9501 +# IP: Netfilter Configuration
9502 +#
9503 +# CONFIG_IP_NF_CONNTRACK is not set
9504 +# CONFIG_IP_NF_QUEUE is not set
9505 +# CONFIG_IP_NF_IPTABLES is not set
9506 +# CONFIG_IP_NF_ARPTABLES is not set
9507 +# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
9508 +# CONFIG_IP_NF_COMPAT_IPFWADM is not set
9509 +
9510 +#
9511 +# SCTP Configuration (EXPERIMENTAL)
9512 +#
9513 +CONFIG_IPV6_SCTP__=y
9514 +# CONFIG_IP_SCTP is not set
9515 +# CONFIG_ATM is not set
9516 +# CONFIG_VLAN_8021Q is not set
9517 +# CONFIG_LLC is not set
9518 +# CONFIG_X25 is not set
9519 +# CONFIG_LAPB is not set
9520 +# CONFIG_NET_DIVERT is not set
9521 +# CONFIG_ECONET is not set
9522 +# CONFIG_WAN_ROUTER is not set
9523 +# CONFIG_NET_FASTROUTE is not set
9524 +# CONFIG_NET_HW_FLOWCONTROL is not set
9525 +
9526 +#
9527 +# QoS and/or fair queueing
9528 +#
9529 +# CONFIG_NET_SCHED is not set
9530 +
9531 +#
9532 +# Network testing
9533 +#
9534 +# CONFIG_NET_PKTGEN is not set
9535 +CONFIG_NETDEVICES=y
9536 +
9537 +#
9538 +# ARCnet devices
9539 +#
9540 +# CONFIG_ARCNET is not set
9541 +# CONFIG_DUMMY is not set
9542 +# CONFIG_BONDING is not set
9543 +# CONFIG_EQUALIZER is not set
9544 +# CONFIG_TUN is not set
9545 +
9546 +#
9547 +# Ethernet (10 or 100Mbit)
9548 +#
9549 +CONFIG_NET_ETHERNET=y
9550 +# CONFIG_MII is not set
9551 +# CONFIG_OAKNET is not set
9552 +# CONFIG_HAPPYMEAL is not set
9553 +# CONFIG_SUNGEM is not set
9554 +# CONFIG_NET_VENDOR_3COM is not set
9555 +
9556 +#
9557 +# Tulip family network device support
9558 +#
9559 +# CONFIG_NET_TULIP is not set
9560 +# CONFIG_HP100 is not set
9561 +# CONFIG_NET_PCI is not set
9562 +
9563 +#
9564 +# Ethernet (1000 Mbit)
9565 +#
9566 +# CONFIG_ACENIC is not set
9567 +# CONFIG_DL2K is not set
9568 +# CONFIG_E1000 is not set
9569 +# CONFIG_NS83820 is not set
9570 +# CONFIG_HAMACHI is not set
9571 +# CONFIG_YELLOWFIN is not set
9572 +# CONFIG_R8169 is not set
9573 +# CONFIG_SIS190 is not set
9574 +# CONFIG_SK98LIN is not set
9575 +# CONFIG_TIGON3 is not set
9576 +
9577 +#
9578 +# Ethernet (10000 Mbit)
9579 +#
9580 +# CONFIG_IXGB is not set
9581 +# CONFIG_FDDI is not set
9582 +# CONFIG_HIPPI is not set
9583 +# CONFIG_PPP is not set
9584 +# CONFIG_SLIP is not set
9585 +
9586 +#
9587 +# Wireless LAN (non-hamradio)
9588 +#
9589 +# CONFIG_NET_RADIO is not set
9590 +
9591 +#
9592 +# Token Ring devices (depends on LLC=y)
9593 +#
9594 +# CONFIG_RCPCI is not set
9595 +# CONFIG_SHAPER is not set
9596 +
9597 +#
9598 +# Wan interfaces
9599 +#
9600 +# CONFIG_WAN is not set
9601 +
9602 +#
9603 +# Amateur Radio support
9604 +#
9605 +# CONFIG_HAMRADIO is not set
9606 +
9607 +#
9608 +# IrDA (infrared) support
9609 +#
9610 +# CONFIG_IRDA is not set
9611 +
9612 +#
9613 +# ISDN subsystem
9614 +#
9615 +# CONFIG_ISDN_BOOL is not set
9616 +
9617 +#
9618 +# Graphics support
9619 +#
9620 +# CONFIG_FB is not set
9621 +
9622 +#
9623 +# Console display driver support
9624 +#
9625 +CONFIG_VGA_CONSOLE=y
9626 +# CONFIG_MDA_CONSOLE is not set
9627 +CONFIG_DUMMY_CONSOLE=y
9628 +
9629 +#
9630 +# Input device support
9631 +#
9632 +CONFIG_INPUT=y
9633 +
9634 +#
9635 +# Userland interfaces
9636 +#
9637 +CONFIG_INPUT_MOUSEDEV=y
9638 +CONFIG_INPUT_MOUSEDEV_PSAUX=y
9639 +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
9640 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
9641 +# CONFIG_INPUT_JOYDEV is not set
9642 +# CONFIG_INPUT_TSDEV is not set
9643 +# CONFIG_INPUT_EVDEV is not set
9644 +# CONFIG_INPUT_EVBUG is not set
9645 +
9646 +#
9647 +# Input I/O drivers
9648 +#
9649 +# CONFIG_GAMEPORT is not set
9650 +CONFIG_SOUND_GAMEPORT=y
9651 +# CONFIG_SERIO is not set
9652 +
9653 +#
9654 +# Input Device Drivers
9655 +#
9656 +# CONFIG_INPUT_KEYBOARD is not set
9657 +# CONFIG_INPUT_MOUSE is not set
9658 +# CONFIG_INPUT_JOYSTICK is not set
9659 +# CONFIG_INPUT_TOUCHSCREEN is not set
9660 +# CONFIG_INPUT_MISC is not set
9661 +
9662 +#
9663 +# Macintosh device drivers
9664 +#
9665 +
9666 +#
9667 +# Character devices
9668 +#
9669 +CONFIG_VT=y
9670 +CONFIG_VT_CONSOLE=y
9671 +CONFIG_HW_CONSOLE=y
9672 +# CONFIG_SERIAL_NONSTANDARD is not set
9673 +
9674 +#
9675 +# Serial drivers
9676 +#
9677 +CONFIG_SERIAL_8250=y
9678 +CONFIG_SERIAL_8250_CONSOLE=y
9679 +CONFIG_SERIAL_8250_EXTENDED=y
9680 +CONFIG_SERIAL_8250_MANY_PORTS=y
9681 +CONFIG_SERIAL_8250_SHARE_IRQ=y
9682 +# CONFIG_SERIAL_8250_DETECT_IRQ is not set
9683 +# CONFIG_SERIAL_8250_MULTIPORT is not set
9684 +# CONFIG_SERIAL_8250_RSA is not set
9685 +
9686 +#
9687 +# Non-8250 serial port support
9688 +#
9689 +CONFIG_SERIAL_CORE=y
9690 +CONFIG_SERIAL_CORE_CONSOLE=y
9691 +CONFIG_UNIX98_PTYS=y
9692 +CONFIG_UNIX98_PTY_COUNT=256
9693 +
9694 +#
9695 +# I2C support
9696 +#
9697 +# CONFIG_I2C is not set
9698 +
9699 +#
9700 +# I2C Hardware Sensors Mainboard support
9701 +#
9702 +
9703 +#
9704 +# I2C Hardware Sensors Chip support
9705 +#
9706 +# CONFIG_I2C_SENSOR is not set
9707 +
9708 +#
9709 +# Mice
9710 +#
9711 +# CONFIG_BUSMOUSE is not set
9712 +# CONFIG_QIC02_TAPE is not set
9713 +
9714 +#
9715 +# IPMI
9716 +#
9717 +# CONFIG_IPMI_HANDLER is not set
9718 +
9719 +#
9720 +# Watchdog Cards
9721 +#
9722 +# CONFIG_WATCHDOG is not set
9723 +# CONFIG_NVRAM is not set
9724 +# CONFIG_GEN_RTC is not set
9725 +# CONFIG_DTLK is not set
9726 +# CONFIG_R3964 is not set
9727 +# CONFIG_APPLICOM is not set
9728 +
9729 +#
9730 +# Ftape, the floppy tape device driver
9731 +#
9732 +# CONFIG_FTAPE is not set
9733 +# CONFIG_AGP is not set
9734 +# CONFIG_DRM is not set
9735 +# CONFIG_RAW_DRIVER is not set
9736 +# CONFIG_HANGCHECK_TIMER is not set
9737 +
9738 +#
9739 +# Multimedia devices
9740 +#
9741 +# CONFIG_VIDEO_DEV is not set
9742 +
9743 +#
9744 +# Digital Video Broadcasting Devices
9745 +#
9746 +# CONFIG_DVB is not set
9747 +
9748 +#
9749 +# File systems
9750 +#
9751 +# CONFIG_EXT2_FS is not set
9752 +# CONFIG_EXT3_FS is not set
9753 +# CONFIG_JBD is not set
9754 +# CONFIG_REISERFS_FS is not set
9755 +# CONFIG_JFS_FS is not set
9756 +# CONFIG_XFS_FS is not set
9757 +# CONFIG_MINIX_FS is not set
9758 +# CONFIG_ROMFS_FS is not set
9759 +# CONFIG_QUOTA is not set
9760 +# CONFIG_AUTOFS_FS is not set
9761 +# CONFIG_AUTOFS4_FS is not set
9762 +
9763 +#
9764 +# CD-ROM/DVD Filesystems
9765 +#
9766 +# CONFIG_ISO9660_FS is not set
9767 +# CONFIG_UDF_FS is not set
9768 +
9769 +#
9770 +# DOS/FAT/NT Filesystems
9771 +#
9772 +# CONFIG_FAT_FS is not set
9773 +# CONFIG_NTFS_FS is not set
9774 +
9775 +#
9776 +# Pseudo filesystems
9777 +#
9778 +CONFIG_PROC_FS=y
9779 +# CONFIG_DEVFS_FS is not set
9780 +CONFIG_DEVPTS_FS=y
9781 +# CONFIG_DEVPTS_FS_XATTR is not set
9782 +# CONFIG_TMPFS is not set
9783 +CONFIG_RAMFS=y
9784 +
9785 +#
9786 +# Miscellaneous filesystems
9787 +#
9788 +# CONFIG_ADFS_FS is not set
9789 +# CONFIG_AFFS_FS is not set
9790 +# CONFIG_HFS_FS is not set
9791 +# CONFIG_BEFS_FS is not set
9792 +# CONFIG_BFS_FS is not set
9793 +# CONFIG_EFS_FS is not set
9794 +# CONFIG_CRAMFS is not set
9795 +# CONFIG_VXFS_FS is not set
9796 +# CONFIG_HPFS_FS is not set
9797 +# CONFIG_QNX4FS_FS is not set
9798 +# CONFIG_SYSV_FS is not set
9799 +# CONFIG_UFS_FS is not set
9800 +
9801 +#
9802 +# Network File Systems
9803 +#
9804 +CONFIG_NFS_FS=y
9805 +# CONFIG_NFS_V3 is not set
9806 +# CONFIG_NFS_V4 is not set
9807 +# CONFIG_NFSD is not set
9808 +CONFIG_ROOT_NFS=y
9809 +CONFIG_LOCKD=y
9810 +# CONFIG_EXPORTFS is not set
9811 +CONFIG_SUNRPC=y
9812 +# CONFIG_SUNRPC_GSS is not set
9813 +# CONFIG_SMB_FS is not set
9814 +# CONFIG_CIFS is not set
9815 +# CONFIG_NCP_FS is not set
9816 +# CONFIG_CODA_FS is not set
9817 +# CONFIG_INTERMEZZO_FS is not set
9818 +# CONFIG_AFS_FS is not set
9819 +
9820 +#
9821 +# Partition Types
9822 +#
9823 +# CONFIG_PARTITION_ADVANCED is not set
9824 +CONFIG_MSDOS_PARTITION=y
9825 +
9826 +#
9827 +# Sound
9828 +#
9829 +# CONFIG_SOUND is not set
9830 +
9831 +#
9832 +# USB support
9833 +#
9834 +# CONFIG_USB is not set
9835 +# CONFIG_USB_GADGET is not set
9836 +
9837 +#
9838 +# Bluetooth support
9839 +#
9840 +# CONFIG_BT is not set
9841 +
9842 +#
9843 +# Library routines
9844 +#
9845 +CONFIG_CRC32=y
9846 +
9847 +#
9848 +# Kernel hacking
9849 +#
9850 +CONFIG_DEBUG_KERNEL=y
9851 +# CONFIG_DEBUG_SLAB is not set
9852 +# CONFIG_MAGIC_SYSRQ is not set
9853 +# CONFIG_DEBUG_SPINLOCK is not set
9854 +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
9855 +# CONFIG_KGDB is not set
9856 +# CONFIG_XMON is not set
9857 +CONFIG_BDI_SWITCH=y
9858 +CONFIG_DEBUG_INFO=y
9859 +# CONFIG_SERIAL_TEXT_DEBUG is not set
9860 +CONFIG_OCP=y
9861 +
9862 +#
9863 +# Security options
9864 +#
9865 +# CONFIG_SECURITY is not set
9866 +
9867 +#
9868 +# Cryptographic options
9869 +#
9870 +# CONFIG_CRYPTO is not set
9871 diff -Nru a/arch/ppc/configs/pmac_defconfig b/arch/ppc/configs/pmac_defconfig
9872 --- a/arch/ppc/configs/pmac_defconfig   Sat Aug  2 13:06:57 2003
9873 +++ b/arch/ppc/configs/pmac_defconfig   Sat Aug 23 02:33:38 2003
9874 @@ -9,6 +9,7 @@
9875  # Code maturity level options
9876  #
9877  CONFIG_EXPERIMENTAL=y
9878 +# CONFIG_BROKEN is not set
9879  
9880  #
9881  # General setup
9882 @@ -18,9 +19,15 @@
9883  # CONFIG_BSD_PROCESS_ACCT is not set
9884  CONFIG_SYSCTL=y
9885  CONFIG_LOG_BUF_SHIFT=14
9886 +CONFIG_IKCONFIG=y
9887 +CONFIG_IKCONFIG_PROC=y
9888  # CONFIG_EMBEDDED is not set
9889 +CONFIG_KALLSYMS=y
9890  CONFIG_FUTEX=y
9891  CONFIG_EPOLL=y
9892 +CONFIG_IOSCHED_NOOP=y
9893 +CONFIG_IOSCHED_AS=y
9894 +CONFIG_IOSCHED_DEADLINE=y
9895  
9896  #
9897  # Loadable module support
9898 @@ -79,6 +86,7 @@
9899  # CONFIG_TAU_INT is not set
9900  # CONFIG_TAU_AVERAGE is not set
9901  CONFIG_CPU_FREQ=y
9902 +CONFIG_CPU_FREQ_TABLE=y
9903  CONFIG_CPU_FREQ_PROC_INTF=y
9904  CONFIG_CPU_FREQ_24_API=y
9905  CONFIG_CPU_FREQ_PMAC=y
9906 @@ -90,8 +98,8 @@
9907  CONFIG_PCI=y
9908  CONFIG_PCI_DOMAINS=y
9909  CONFIG_KCORE_ELF=y
9910 -CONFIG_BINFMT_ELF=y
9911  CONFIG_KERNEL_ELF=y
9912 +CONFIG_BINFMT_ELF=y
9913  CONFIG_BINFMT_MISC=m
9914  CONFIG_PCI_LEGACY_PROC=y
9915  CONFIG_PCI_NAMES=y
9916 @@ -101,9 +109,9 @@
9917  # PCMCIA/CardBus support
9918  #
9919  CONFIG_PCMCIA=m
9920 +CONFIG_YENTA=m
9921  CONFIG_CARDBUS=y
9922  CONFIG_I82092=m
9923 -CONFIG_I82365=m
9924  CONFIG_TCIC=m
9925  
9926  #
9927 @@ -131,6 +139,11 @@
9928  CONFIG_BOOT_LOAD=0x00800000
9929  
9930  #
9931 +# Generic Driver Options
9932 +#
9933 +# CONFIG_FW_LOADER is not set
9934 +
9935 +#
9936  # Memory Technology Devices (MTD)
9937  #
9938  # CONFIG_MTD is not set
9939 @@ -149,10 +162,12 @@
9940  # CONFIG_BLK_DEV_DAC960 is not set
9941  # CONFIG_BLK_DEV_UMEM is not set
9942  CONFIG_BLK_DEV_LOOP=y
9943 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
9944  # CONFIG_BLK_DEV_NBD is not set
9945  CONFIG_BLK_DEV_RAM=y
9946  CONFIG_BLK_DEV_RAM_SIZE=4096
9947  CONFIG_BLK_DEV_INITRD=y
9948 +CONFIG_LBD=y
9949  
9950  #
9951  # Multi-device support (RAID and LVM)
9952 @@ -160,41 +175,39 @@
9953  # CONFIG_MD is not set
9954  
9955  #
9956 -# ATA/IDE/MFM/RLL support
9957 +# ATA/ATAPI/MFM/RLL support
9958  #
9959  CONFIG_IDE=y
9960 -
9961 -#
9962 -# IDE, ATA and ATAPI Block devices
9963 -#
9964  CONFIG_BLK_DEV_IDE=y
9965  
9966  #
9967  # Please see Documentation/ide.txt for help/info on IDE drives
9968  #
9969 -# CONFIG_BLK_DEV_HD is not set
9970  CONFIG_BLK_DEV_IDEDISK=y
9971  # CONFIG_IDEDISK_MULTI_MODE is not set
9972  # CONFIG_IDEDISK_STROKE is not set
9973  CONFIG_BLK_DEV_IDECS=m
9974  CONFIG_BLK_DEV_IDECD=y
9975 +# CONFIG_BLK_DEV_IDETAPE is not set
9976  CONFIG_BLK_DEV_IDEFLOPPY=y
9977  CONFIG_BLK_DEV_IDESCSI=y
9978  # CONFIG_IDE_TASK_IOCTL is not set
9979 +# CONFIG_IDE_TASKFILE_IO is not set
9980  
9981  #
9982  # IDE chipset support/bugfixes
9983  #
9984  CONFIG_BLK_DEV_IDEPCI=y
9985 -CONFIG_BLK_DEV_GENERIC=y
9986  CONFIG_IDEPCI_SHARE_IRQ=y
9987 +# CONFIG_BLK_DEV_OFFBOARD is not set
9988 +CONFIG_BLK_DEV_GENERIC=y
9989 +# CONFIG_BLK_DEV_OPTI621 is not set
9990 +CONFIG_BLK_DEV_SL82C105=y
9991  CONFIG_BLK_DEV_IDEDMA_PCI=y
9992  # CONFIG_BLK_DEV_IDE_TCQ is not set
9993 -# CONFIG_BLK_DEV_OFFBOARD is not set
9994  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
9995  CONFIG_IDEDMA_PCI_AUTO=y
9996  # CONFIG_IDEDMA_ONLYDISK is not set
9997 -CONFIG_BLK_DEV_IDEDMA=y
9998  # CONFIG_IDEDMA_PCI_WIP is not set
9999  CONFIG_BLK_DEV_ADMA=y
10000  # CONFIG_BLK_DEV_AEC62XX is not set
10001 @@ -204,12 +217,12 @@
10002  # CONFIG_BLK_DEV_TRIFLEX is not set
10003  # CONFIG_BLK_DEV_CY82C693 is not set
10004  # CONFIG_BLK_DEV_CS5520 is not set
10005 +# CONFIG_BLK_DEV_CS5530 is not set
10006  # CONFIG_BLK_DEV_HPT34X is not set
10007  # CONFIG_BLK_DEV_HPT366 is not set
10008  # CONFIG_BLK_DEV_SC1200 is not set
10009  # CONFIG_BLK_DEV_PIIX is not set
10010  # CONFIG_BLK_DEV_NS87415 is not set
10011 -# CONFIG_BLK_DEV_OPTI621 is not set
10012  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
10013  CONFIG_BLK_DEV_PDC202XX_NEW=y
10014  # CONFIG_PDC202XX_FORCE is not set
10015 @@ -218,15 +231,17 @@
10016  # CONFIG_BLK_DEV_SLC90E66 is not set
10017  # CONFIG_BLK_DEV_TRM290 is not set
10018  # CONFIG_BLK_DEV_VIA82CXXX is not set
10019 -CONFIG_BLK_DEV_SL82C105=y
10020  CONFIG_BLK_DEV_IDE_PMAC=y
10021  CONFIG_BLK_DEV_IDEDMA_PMAC=y
10022  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
10023 -CONFIG_IDEDMA_AUTO=y
10024 +CONFIG_BLK_DEV_IDEDMA=y
10025  # CONFIG_IDEDMA_IVB is not set
10026 +CONFIG_IDEDMA_AUTO=y
10027 +# CONFIG_DMA_NONPCI is not set
10028 +# CONFIG_BLK_DEV_HD is not set
10029  
10030  #
10031 -# SCSI support
10032 +# SCSI device support
10033  #
10034  CONFIG_SCSI=y
10035  
10036 @@ -266,8 +281,6 @@
10037  # CONFIG_SCSI_AIC79XX is not set
10038  # CONFIG_SCSI_DPT_I2O is not set
10039  CONFIG_SCSI_ADVANSYS=m
10040 -# CONFIG_SCSI_IN2000 is not set
10041 -# CONFIG_SCSI_AM53C974 is not set
10042  # CONFIG_SCSI_MEGARAID is not set
10043  # CONFIG_SCSI_BUSLOGIC is not set
10044  # CONFIG_SCSI_CPQFCTS is not set
10045 @@ -276,11 +289,8 @@
10046  # CONFIG_SCSI_EATA_PIO is not set
10047  # CONFIG_SCSI_FUTURE_DOMAIN is not set
10048  # CONFIG_SCSI_GDTH is not set
10049 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
10050 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
10051  # CONFIG_SCSI_INITIO is not set
10052  # CONFIG_SCSI_INIA100 is not set
10053 -# CONFIG_SCSI_NCR53C7xx is not set
10054  CONFIG_SCSI_SYM53C8XX_2=y
10055  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
10056  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
10057 @@ -293,7 +303,6 @@
10058  # CONFIG_SCSI_QLOGIC_1280 is not set
10059  # CONFIG_SCSI_DC395x is not set
10060  # CONFIG_SCSI_DC390T is not set
10061 -# CONFIG_SCSI_U14_34F is not set
10062  # CONFIG_SCSI_NSP32 is not set
10063  # CONFIG_SCSI_DEBUG is not set
10064  CONFIG_SCSI_MESH=y
10065 @@ -361,8 +370,6 @@
10066  CONFIG_PACKET=y
10067  # CONFIG_PACKET_MMAP is not set
10068  # CONFIG_NETLINK_DEV is not set
10069 -CONFIG_NETFILTER=y
10070 -# CONFIG_NETFILTER_DEBUG is not set
10071  CONFIG_UNIX=y
10072  # CONFIG_NET_KEY is not set
10073  CONFIG_INET=y
10074 @@ -380,6 +387,16 @@
10075  # CONFIG_INET_IPCOMP is not set
10076  
10077  #
10078 +# IP: Virtual Server Configuration
10079 +#
10080 +# CONFIG_IP_VS is not set
10081 +# CONFIG_IPV6 is not set
10082 +# CONFIG_DECNET is not set
10083 +# CONFIG_BRIDGE is not set
10084 +CONFIG_NETFILTER=y
10085 +# CONFIG_NETFILTER_DEBUG is not set
10086 +
10087 +#
10088  # IP: Netfilter Configuration
10089  #
10090  CONFIG_IP_NF_CONNTRACK=m
10091 @@ -395,6 +412,7 @@
10092  CONFIG_IP_NF_MATCH_MARK=m
10093  CONFIG_IP_NF_MATCH_MULTIPORT=m
10094  CONFIG_IP_NF_MATCH_TOS=m
10095 +CONFIG_IP_NF_MATCH_RECENT=m
10096  CONFIG_IP_NF_MATCH_ECN=m
10097  CONFIG_IP_NF_MATCH_DSCP=m
10098  CONFIG_IP_NF_MATCH_AH_ESP=m
10099 @@ -425,10 +443,9 @@
10100  CONFIG_IP_NF_TARGET_TCPMSS=m
10101  CONFIG_IP_NF_ARPTABLES=m
10102  CONFIG_IP_NF_ARPFILTER=m
10103 +CONFIG_IP_NF_ARP_MANGLE=m
10104  CONFIG_IP_NF_COMPAT_IPCHAINS=m
10105  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
10106 -# CONFIG_IPV6 is not set
10107 -# CONFIG_XFRM_USER is not set
10108  
10109  #
10110  # SCTP Configuration (EXPERIMENTAL)
10111 @@ -438,8 +455,6 @@
10112  # CONFIG_ATM is not set
10113  # CONFIG_VLAN_8021Q is not set
10114  # CONFIG_LLC is not set
10115 -# CONFIG_DECNET is not set
10116 -# CONFIG_BRIDGE is not set
10117  # CONFIG_X25 is not set
10118  # CONFIG_LAPB is not set
10119  # CONFIG_NET_DIVERT is not set
10120 @@ -516,6 +531,7 @@
10121  # CONFIG_HAMACHI is not set
10122  # CONFIG_YELLOWFIN is not set
10123  # CONFIG_R8169 is not set
10124 +# CONFIG_SIS190 is not set
10125  # CONFIG_SK98LIN is not set
10126  # CONFIG_TIGON3 is not set
10127  
10128 @@ -568,6 +584,7 @@
10129  CONFIG_PCMCIA_HERMES=m
10130  # CONFIG_AIRO_CS is not set
10131  # CONFIG_PCMCIA_ATMEL is not set
10132 +# CONFIG_PCMCIA_WL3501 is not set
10133  CONFIG_NET_WIRELESS=y
10134  
10135  #
10136 @@ -637,25 +654,18 @@
10137  #
10138  # Old SIR device drivers
10139  #
10140 -# CONFIG_IRTTY_OLD is not set
10141  # CONFIG_IRPORT_SIR is not set
10142  
10143  #
10144  # Old Serial dongle support
10145  #
10146 -# CONFIG_DONGLE_OLD is not set
10147  
10148  #
10149  # FIR device drivers
10150  #
10151  # CONFIG_USB_IRDA is not set
10152 -# CONFIG_NSC_FIR is not set
10153 -# CONFIG_WINBOND_FIR is not set
10154  # CONFIG_TOSHIBA_OLD is not set
10155  # CONFIG_TOSHIBA_FIR is not set
10156 -# CONFIG_SMC_IRCC_OLD is not set
10157 -# CONFIG_SMC_IRCC_FIR is not set
10158 -# CONFIG_ALI_FIR is not set
10159  # CONFIG_VLSI_FIR is not set
10160  
10161  #
10162 @@ -721,11 +731,6 @@
10163  CONFIG_LOGO_LINUX_CLUT224=y
10164  
10165  #
10166 -# Old CD-ROM drivers (not SCSI, not IDE)
10167 -#
10168 -# CONFIG_CD_NO_IDESCSI is not set
10169 -
10170 -#
10171  # Input device support
10172  #
10173  CONFIG_INPUT=y
10174 @@ -766,7 +771,7 @@
10175  CONFIG_PMAC_PBOOK=y
10176  CONFIG_PMAC_APM_EMU=y
10177  CONFIG_PMAC_BACKLIGHT=y
10178 -CONFIG_MAC_FLOPPY=y
10179 +# CONFIG_MAC_FLOPPY is not set
10180  CONFIG_MAC_SERIAL=y
10181  CONFIG_ADB=y
10182  CONFIG_ADB_MACIO=y
10183 @@ -808,10 +813,12 @@
10184  #
10185  # I2C Hardware Sensors Mainboard support
10186  #
10187 +# CONFIG_I2C_ALI1535 is not set
10188  # CONFIG_I2C_ALI15X3 is not set
10189  # CONFIG_I2C_AMD756 is not set
10190  # CONFIG_I2C_AMD8111 is not set
10191  # CONFIG_I2C_I801 is not set
10192 +# CONFIG_I2C_NFORCE2 is not set
10193  # CONFIG_I2C_PIIX4 is not set
10194  # CONFIG_I2C_SIS96X is not set
10195  # CONFIG_I2C_VIAPRO is not set
10196 @@ -823,6 +830,7 @@
10197  # CONFIG_SENSORS_IT87 is not set
10198  # CONFIG_SENSORS_LM75 is not set
10199  # CONFIG_SENSORS_LM85 is not set
10200 +# CONFIG_SENSORS_LM78 is not set
10201  # CONFIG_SENSORS_VIA686A is not set
10202  # CONFIG_SENSORS_W83781D is not set
10203  # CONFIG_I2C_SENSOR is not set
10204 @@ -1028,8 +1036,7 @@
10205  # Sound
10206  #
10207  CONFIG_SOUND=m
10208 -CONFIG_DMASOUND_AWACS=m
10209 -CONFIG_DMASOUND=m
10210 +# CONFIG_DMASOUND_AWACS is not set
10211  
10212  #
10213  # Advanced Linux Sound Architecture
10214 @@ -1168,6 +1175,7 @@
10215  #
10216  # USB Network adaptors
10217  #
10218 +# CONFIG_USB_AX8817X is not set
10219  # CONFIG_USB_CATC is not set
10220  # CONFIG_USB_KAWETH is not set
10221  # CONFIG_USB_PEGASUS is not set
10222 @@ -1231,7 +1239,6 @@
10223  # Kernel hacking
10224  #
10225  # CONFIG_DEBUG_KERNEL is not set
10226 -CONFIG_KALLSYMS=y
10227  CONFIG_BOOTX_TEXT=y
10228  
10229  #
10230 diff -Nru a/arch/ppc/configs/power3_defconfig b/arch/ppc/configs/power3_defconfig
10231 --- a/arch/ppc/configs/power3_defconfig Tue Jul  1 17:01:18 2003
10232 +++ b/arch/ppc/configs/power3_defconfig Sat Aug 23 02:33:38 2003
10233 @@ -9,6 +9,7 @@
10234  # Code maturity level options
10235  #
10236  CONFIG_EXPERIMENTAL=y
10237 +# CONFIG_BROKEN is not set
10238  
10239  #
10240  # General setup
10241 @@ -18,9 +19,15 @@
10242  # CONFIG_BSD_PROCESS_ACCT is not set
10243  CONFIG_SYSCTL=y
10244  CONFIG_LOG_BUF_SHIFT=15
10245 +CONFIG_IKCONFIG=y
10246 +CONFIG_IKCONFIG_PROC=y
10247  # CONFIG_EMBEDDED is not set
10248 +CONFIG_KALLSYMS=y
10249  CONFIG_FUTEX=y
10250  CONFIG_EPOLL=y
10251 +CONFIG_IOSCHED_NOOP=y
10252 +CONFIG_IOSCHED_AS=y
10253 +CONFIG_IOSCHED_DEADLINE=y
10254  
10255  #
10256  # Loadable module support
10257 @@ -82,8 +89,8 @@
10258  CONFIG_PCI=y
10259  CONFIG_PCI_DOMAINS=y
10260  CONFIG_KCORE_ELF=y
10261 -CONFIG_BINFMT_ELF=y
10262  CONFIG_KERNEL_ELF=y
10263 +CONFIG_BINFMT_ELF=y
10264  CONFIG_BINFMT_MISC=y
10265  CONFIG_PCI_LEGACY_PROC=y
10266  CONFIG_PCI_NAMES=y
10267 @@ -121,6 +128,10 @@
10268  CONFIG_BOOT_LOAD=0x00800000
10269  
10270  #
10271 +# Generic Driver Options
10272 +#
10273 +
10274 +#
10275  # Memory Technology Devices (MTD)
10276  #
10277  # CONFIG_MTD is not set
10278 @@ -140,10 +151,12 @@
10279  # CONFIG_BLK_DEV_DAC960 is not set
10280  # CONFIG_BLK_DEV_UMEM is not set
10281  CONFIG_BLK_DEV_LOOP=y
10282 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
10283  # CONFIG_BLK_DEV_NBD is not set
10284  CONFIG_BLK_DEV_RAM=y
10285  CONFIG_BLK_DEV_RAM_SIZE=4096
10286  CONFIG_BLK_DEV_INITRD=y
10287 +CONFIG_LBD=y
10288  
10289  #
10290  # Multi-device support (RAID and LVM)
10291 @@ -156,14 +169,15 @@
10292  CONFIG_MD_RAID5=y
10293  # CONFIG_MD_MULTIPATH is not set
10294  CONFIG_BLK_DEV_DM=y
10295 +CONFIG_DM_IOCTL_V4=y
10296  
10297  #
10298 -# ATA/IDE/MFM/RLL support
10299 +# ATA/ATAPI/MFM/RLL support
10300  #
10301  # CONFIG_IDE is not set
10302  
10303  #
10304 -# SCSI support
10305 +# SCSI device support
10306  #
10307  CONFIG_SCSI=y
10308  
10309 @@ -196,8 +210,6 @@
10310  # CONFIG_SCSI_AIC79XX is not set
10311  # CONFIG_SCSI_DPT_I2O is not set
10312  # CONFIG_SCSI_ADVANSYS is not set
10313 -# CONFIG_SCSI_IN2000 is not set
10314 -# CONFIG_SCSI_AM53C974 is not set
10315  # CONFIG_SCSI_MEGARAID is not set
10316  # CONFIG_SCSI_BUSLOGIC is not set
10317  # CONFIG_SCSI_CPQFCTS is not set
10318 @@ -206,13 +218,10 @@
10319  # CONFIG_SCSI_EATA_PIO is not set
10320  # CONFIG_SCSI_FUTURE_DOMAIN is not set
10321  # CONFIG_SCSI_GDTH is not set
10322 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
10323 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
10324  # CONFIG_SCSI_INITIO is not set
10325  # CONFIG_SCSI_INIA100 is not set
10326  # CONFIG_SCSI_PPA is not set
10327  # CONFIG_SCSI_IMM is not set
10328 -# CONFIG_SCSI_NCR53C7xx is not set
10329  CONFIG_SCSI_SYM53C8XX_2=y
10330  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
10331  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
10332 @@ -225,7 +234,6 @@
10333  # CONFIG_SCSI_QLOGIC_1280 is not set
10334  # CONFIG_SCSI_DC395x is not set
10335  # CONFIG_SCSI_DC390T is not set
10336 -# CONFIG_SCSI_U14_34F is not set
10337  # CONFIG_SCSI_NSP32 is not set
10338  # CONFIG_SCSI_DEBUG is not set
10339  # CONFIG_SCSI_MESH is not set
10340 @@ -257,7 +265,6 @@
10341  CONFIG_PACKET=y
10342  # CONFIG_PACKET_MMAP is not set
10343  # CONFIG_NETLINK_DEV is not set
10344 -# CONFIG_NETFILTER is not set
10345  CONFIG_UNIX=y
10346  # CONFIG_NET_KEY is not set
10347  CONFIG_INET=y
10348 @@ -274,7 +281,9 @@
10349  # CONFIG_INET_ESP is not set
10350  # CONFIG_INET_IPCOMP is not set
10351  # CONFIG_IPV6 is not set
10352 -# CONFIG_XFRM_USER is not set
10353 +# CONFIG_DECNET is not set
10354 +# CONFIG_BRIDGE is not set
10355 +# CONFIG_NETFILTER is not set
10356  
10357  #
10358  # SCTP Configuration (EXPERIMENTAL)
10359 @@ -284,8 +293,6 @@
10360  # CONFIG_ATM is not set
10361  # CONFIG_VLAN_8021Q is not set
10362  # CONFIG_LLC is not set
10363 -# CONFIG_DECNET is not set
10364 -# CONFIG_BRIDGE is not set
10365  # CONFIG_X25 is not set
10366  # CONFIG_LAPB is not set
10367  # CONFIG_NET_DIVERT is not set
10368 @@ -362,6 +369,7 @@
10369  # CONFIG_HAMACHI is not set
10370  # CONFIG_YELLOWFIN is not set
10371  # CONFIG_R8169 is not set
10372 +# CONFIG_SIS190 is not set
10373  # CONFIG_SK98LIN is not set
10374  # CONFIG_TIGON3 is not set
10375  
10376 @@ -464,11 +472,6 @@
10377  CONFIG_LOGO_LINUX_CLUT224=y
10378  
10379  #
10380 -# Old CD-ROM drivers (not SCSI, not IDE)
10381 -#
10382 -# CONFIG_CD_NO_IDESCSI is not set
10383 -
10384 -#
10385  # Input device support
10386  #
10387  CONFIG_INPUT=y
10388 @@ -495,6 +498,7 @@
10389  CONFIG_SERIO_SERPORT=y
10390  # CONFIG_SERIO_CT82C710 is not set
10391  # CONFIG_SERIO_PARKBD is not set
10392 +# CONFIG_SERIO_PCIPS2 is not set
10393  
10394  #
10395  # Input Device Drivers
10396 @@ -554,9 +558,8 @@
10397  #
10398  CONFIG_I2C=y
10399  CONFIG_I2C_ALGOBIT=y
10400 +# CONFIG_I2C_PROSAVAGE is not set
10401  # CONFIG_I2C_PHILIPSPAR is not set
10402 -# CONFIG_I2C_ELV is not set
10403 -# CONFIG_I2C_VELLEMAN is not set
10404  # CONFIG_SCx200_ACB is not set
10405  CONFIG_I2C_ALGOPCF=y
10406  # CONFIG_I2C_ELEKTOR is not set
10407 @@ -566,10 +569,12 @@
10408  #
10409  # I2C Hardware Sensors Mainboard support
10410  #
10411 +# CONFIG_I2C_ALI1535 is not set
10412  # CONFIG_I2C_ALI15X3 is not set
10413  # CONFIG_I2C_AMD756 is not set
10414  # CONFIG_I2C_AMD8111 is not set
10415  # CONFIG_I2C_I801 is not set
10416 +# CONFIG_I2C_NFORCE2 is not set
10417  # CONFIG_I2C_PIIX4 is not set
10418  # CONFIG_I2C_SIS96X is not set
10419  # CONFIG_I2C_VIAPRO is not set
10420 @@ -581,6 +586,7 @@
10421  # CONFIG_SENSORS_IT87 is not set
10422  # CONFIG_SENSORS_LM75 is not set
10423  # CONFIG_SENSORS_LM85 is not set
10424 +# CONFIG_SENSORS_LM78 is not set
10425  # CONFIG_SENSORS_VIA686A is not set
10426  # CONFIG_SENSORS_W83781D is not set
10427  # CONFIG_I2C_SENSOR is not set
10428 @@ -843,7 +849,6 @@
10429  # Kernel hacking
10430  #
10431  # CONFIG_DEBUG_KERNEL is not set
10432 -CONFIG_KALLSYMS=y
10433  CONFIG_BOOTX_TEXT=y
10434  
10435  #
10436 diff -Nru a/arch/ppc/defconfig b/arch/ppc/defconfig
10437 --- a/arch/ppc/defconfig        Sat Aug  2 12:59:32 2003
10438 +++ b/arch/ppc/defconfig        Sat Aug 23 02:33:38 2003
10439 @@ -9,6 +9,7 @@
10440  # Code maturity level options
10441  #
10442  CONFIG_EXPERIMENTAL=y
10443 +# CONFIG_BROKEN is not set
10444  
10445  #
10446  # General setup
10447 @@ -18,9 +19,15 @@
10448  # CONFIG_BSD_PROCESS_ACCT is not set
10449  CONFIG_SYSCTL=y
10450  CONFIG_LOG_BUF_SHIFT=14
10451 +CONFIG_IKCONFIG=y
10452 +CONFIG_IKCONFIG_PROC=y
10453  # CONFIG_EMBEDDED is not set
10454 +CONFIG_KALLSYMS=y
10455  CONFIG_FUTEX=y
10456  CONFIG_EPOLL=y
10457 +CONFIG_IOSCHED_NOOP=y
10458 +CONFIG_IOSCHED_AS=y
10459 +CONFIG_IOSCHED_DEADLINE=y
10460  
10461  #
10462  # Loadable module support
10463 @@ -78,6 +85,7 @@
10464  # CONFIG_TAU_INT is not set
10465  # CONFIG_TAU_AVERAGE is not set
10466  CONFIG_CPU_FREQ=y
10467 +CONFIG_CPU_FREQ_TABLE=y
10468  CONFIG_CPU_FREQ_PROC_INTF=y
10469  CONFIG_CPU_FREQ_24_API=y
10470  CONFIG_CPU_FREQ_PMAC=y
10471 @@ -89,8 +97,8 @@
10472  CONFIG_PCI=y
10473  CONFIG_PCI_DOMAINS=y
10474  CONFIG_KCORE_ELF=y
10475 -CONFIG_BINFMT_ELF=y
10476  CONFIG_KERNEL_ELF=y
10477 +CONFIG_BINFMT_ELF=y
10478  CONFIG_BINFMT_MISC=m
10479  CONFIG_PCI_LEGACY_PROC=y
10480  CONFIG_PCI_NAMES=y
10481 @@ -128,6 +136,11 @@
10482  CONFIG_BOOT_LOAD=0x00800000
10483  
10484  #
10485 +# Generic Driver Options
10486 +#
10487 +# CONFIG_FW_LOADER is not set
10488 +
10489 +#
10490  # Memory Technology Devices (MTD)
10491  #
10492  # CONFIG_MTD is not set
10493 @@ -146,10 +159,12 @@
10494  # CONFIG_BLK_DEV_DAC960 is not set
10495  # CONFIG_BLK_DEV_UMEM is not set
10496  CONFIG_BLK_DEV_LOOP=y
10497 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
10498  # CONFIG_BLK_DEV_NBD is not set
10499  CONFIG_BLK_DEV_RAM=y
10500  CONFIG_BLK_DEV_RAM_SIZE=4096
10501  CONFIG_BLK_DEV_INITRD=y
10502 +CONFIG_LBD=y
10503  
10504  #
10505  # Multi-device support (RAID and LVM)
10506 @@ -157,40 +172,38 @@
10507  # CONFIG_MD is not set
10508  
10509  #
10510 -# ATA/IDE/MFM/RLL support
10511 +# ATA/ATAPI/MFM/RLL support
10512  #
10513  CONFIG_IDE=y
10514 -
10515 -#
10516 -# IDE, ATA and ATAPI Block devices
10517 -#
10518  CONFIG_BLK_DEV_IDE=y
10519  
10520  #
10521  # Please see Documentation/ide.txt for help/info on IDE drives
10522  #
10523 -# CONFIG_BLK_DEV_HD is not set
10524  CONFIG_BLK_DEV_IDEDISK=y
10525  # CONFIG_IDEDISK_MULTI_MODE is not set
10526  # CONFIG_IDEDISK_STROKE is not set
10527  CONFIG_BLK_DEV_IDECD=y
10528 +# CONFIG_BLK_DEV_IDETAPE is not set
10529  CONFIG_BLK_DEV_IDEFLOPPY=y
10530  CONFIG_BLK_DEV_IDESCSI=y
10531  # CONFIG_IDE_TASK_IOCTL is not set
10532 +# CONFIG_IDE_TASKFILE_IO is not set
10533  
10534  #
10535  # IDE chipset support/bugfixes
10536  #
10537  CONFIG_BLK_DEV_IDEPCI=y
10538 -CONFIG_BLK_DEV_GENERIC=y
10539  CONFIG_IDEPCI_SHARE_IRQ=y
10540 +# CONFIG_BLK_DEV_OFFBOARD is not set
10541 +CONFIG_BLK_DEV_GENERIC=y
10542 +# CONFIG_BLK_DEV_OPTI621 is not set
10543 +CONFIG_BLK_DEV_SL82C105=y
10544  CONFIG_BLK_DEV_IDEDMA_PCI=y
10545  # CONFIG_BLK_DEV_IDE_TCQ is not set
10546 -# CONFIG_BLK_DEV_OFFBOARD is not set
10547  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
10548  CONFIG_IDEDMA_PCI_AUTO=y
10549  # CONFIG_IDEDMA_ONLYDISK is not set
10550 -CONFIG_BLK_DEV_IDEDMA=y
10551  # CONFIG_IDEDMA_PCI_WIP is not set
10552  CONFIG_BLK_DEV_ADMA=y
10553  # CONFIG_BLK_DEV_AEC62XX is not set
10554 @@ -200,12 +213,12 @@
10555  # CONFIG_BLK_DEV_TRIFLEX is not set
10556  # CONFIG_BLK_DEV_CY82C693 is not set
10557  # CONFIG_BLK_DEV_CS5520 is not set
10558 +# CONFIG_BLK_DEV_CS5530 is not set
10559  # CONFIG_BLK_DEV_HPT34X is not set
10560  # CONFIG_BLK_DEV_HPT366 is not set
10561  # CONFIG_BLK_DEV_SC1200 is not set
10562  # CONFIG_BLK_DEV_PIIX is not set
10563  # CONFIG_BLK_DEV_NS87415 is not set
10564 -# CONFIG_BLK_DEV_OPTI621 is not set
10565  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
10566  # CONFIG_BLK_DEV_PDC202XX_NEW is not set
10567  # CONFIG_BLK_DEV_SVWKS is not set
10568 @@ -213,15 +226,17 @@
10569  # CONFIG_BLK_DEV_SLC90E66 is not set
10570  # CONFIG_BLK_DEV_TRM290 is not set
10571  # CONFIG_BLK_DEV_VIA82CXXX is not set
10572 -CONFIG_BLK_DEV_SL82C105=y
10573  CONFIG_BLK_DEV_IDE_PMAC=y
10574  CONFIG_BLK_DEV_IDEDMA_PMAC=y
10575  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
10576 -CONFIG_IDEDMA_AUTO=y
10577 +CONFIG_BLK_DEV_IDEDMA=y
10578  # CONFIG_IDEDMA_IVB is not set
10579 +CONFIG_IDEDMA_AUTO=y
10580 +# CONFIG_DMA_NONPCI is not set
10581 +# CONFIG_BLK_DEV_HD is not set
10582  
10583  #
10584 -# SCSI support
10585 +# SCSI device support
10586  #
10587  CONFIG_SCSI=y
10588  
10589 @@ -261,8 +276,6 @@
10590  # CONFIG_SCSI_AIC79XX is not set
10591  # CONFIG_SCSI_DPT_I2O is not set
10592  CONFIG_SCSI_ADVANSYS=m
10593 -# CONFIG_SCSI_IN2000 is not set
10594 -# CONFIG_SCSI_AM53C974 is not set
10595  # CONFIG_SCSI_MEGARAID is not set
10596  # CONFIG_SCSI_BUSLOGIC is not set
10597  # CONFIG_SCSI_CPQFCTS is not set
10598 @@ -271,11 +284,8 @@
10599  # CONFIG_SCSI_EATA_PIO is not set
10600  # CONFIG_SCSI_FUTURE_DOMAIN is not set
10601  # CONFIG_SCSI_GDTH is not set
10602 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
10603 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
10604  # CONFIG_SCSI_INITIO is not set
10605  # CONFIG_SCSI_INIA100 is not set
10606 -# CONFIG_SCSI_NCR53C7xx is not set
10607  CONFIG_SCSI_SYM53C8XX_2=y
10608  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
10609  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
10610 @@ -288,7 +298,6 @@
10611  # CONFIG_SCSI_QLOGIC_1280 is not set
10612  # CONFIG_SCSI_DC395x is not set
10613  # CONFIG_SCSI_DC390T is not set
10614 -# CONFIG_SCSI_U14_34F is not set
10615  # CONFIG_SCSI_NSP32 is not set
10616  # CONFIG_SCSI_DEBUG is not set
10617  CONFIG_SCSI_MESH=y
10618 @@ -322,8 +331,6 @@
10619  CONFIG_PACKET=y
10620  # CONFIG_PACKET_MMAP is not set
10621  # CONFIG_NETLINK_DEV is not set
10622 -CONFIG_NETFILTER=y
10623 -# CONFIG_NETFILTER_DEBUG is not set
10624  CONFIG_UNIX=y
10625  # CONFIG_NET_KEY is not set
10626  CONFIG_INET=y
10627 @@ -341,6 +348,16 @@
10628  # CONFIG_INET_IPCOMP is not set
10629  
10630  #
10631 +# IP: Virtual Server Configuration
10632 +#
10633 +# CONFIG_IP_VS is not set
10634 +# CONFIG_IPV6 is not set
10635 +# CONFIG_DECNET is not set
10636 +# CONFIG_BRIDGE is not set
10637 +CONFIG_NETFILTER=y
10638 +# CONFIG_NETFILTER_DEBUG is not set
10639 +
10640 +#
10641  # IP: Netfilter Configuration
10642  #
10643  CONFIG_IP_NF_CONNTRACK=m
10644 @@ -356,6 +373,7 @@
10645  CONFIG_IP_NF_MATCH_MARK=m
10646  CONFIG_IP_NF_MATCH_MULTIPORT=m
10647  CONFIG_IP_NF_MATCH_TOS=m
10648 +CONFIG_IP_NF_MATCH_RECENT=m
10649  CONFIG_IP_NF_MATCH_ECN=m
10650  CONFIG_IP_NF_MATCH_DSCP=m
10651  CONFIG_IP_NF_MATCH_AH_ESP=m
10652 @@ -386,10 +404,9 @@
10653  CONFIG_IP_NF_TARGET_TCPMSS=m
10654  CONFIG_IP_NF_ARPTABLES=m
10655  CONFIG_IP_NF_ARPFILTER=m
10656 +CONFIG_IP_NF_ARP_MANGLE=m
10657  CONFIG_IP_NF_COMPAT_IPCHAINS=m
10658  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
10659 -# CONFIG_IPV6 is not set
10660 -# CONFIG_XFRM_USER is not set
10661  
10662  #
10663  # SCTP Configuration (EXPERIMENTAL)
10664 @@ -399,8 +416,6 @@
10665  # CONFIG_ATM is not set
10666  # CONFIG_VLAN_8021Q is not set
10667  # CONFIG_LLC is not set
10668 -# CONFIG_DECNET is not set
10669 -# CONFIG_BRIDGE is not set
10670  # CONFIG_X25 is not set
10671  # CONFIG_LAPB is not set
10672  # CONFIG_NET_DIVERT is not set
10673 @@ -477,6 +492,7 @@
10674  # CONFIG_HAMACHI is not set
10675  # CONFIG_YELLOWFIN is not set
10676  # CONFIG_R8169 is not set
10677 +# CONFIG_SIS190 is not set
10678  # CONFIG_SK98LIN is not set
10679  # CONFIG_TIGON3 is not set
10680  
10681 @@ -548,7 +564,7 @@
10682  # Graphics support
10683  #
10684  CONFIG_FB=y
10685 -CONFIG_FB_CIRRUS=y
10686 +# CONFIG_FB_CIRRUS is not set
10687  # CONFIG_FB_PM2 is not set
10688  # CONFIG_FB_CYBER2000 is not set
10689  CONFIG_FB_OF=y
10690 @@ -602,11 +618,6 @@
10691  CONFIG_LOGO_LINUX_CLUT224=y
10692  
10693  #
10694 -# Old CD-ROM drivers (not SCSI, not IDE)
10695 -#
10696 -# CONFIG_CD_NO_IDESCSI is not set
10697 -
10698 -#
10699  # Input device support
10700  #
10701  CONFIG_INPUT=y
10702 @@ -632,6 +643,7 @@
10703  CONFIG_SERIO_I8042=y
10704  CONFIG_SERIO_SERPORT=y
10705  # CONFIG_SERIO_CT82C710 is not set
10706 +# CONFIG_SERIO_PCIPS2 is not set
10707  
10708  #
10709  # Input Device Drivers
10710 @@ -698,10 +710,12 @@
10711  #
10712  # I2C Hardware Sensors Mainboard support
10713  #
10714 +# CONFIG_I2C_ALI1535 is not set
10715  # CONFIG_I2C_ALI15X3 is not set
10716  # CONFIG_I2C_AMD756 is not set
10717  # CONFIG_I2C_AMD8111 is not set
10718  # CONFIG_I2C_I801 is not set
10719 +# CONFIG_I2C_NFORCE2 is not set
10720  # CONFIG_I2C_PIIX4 is not set
10721  # CONFIG_I2C_SIS96X is not set
10722  # CONFIG_I2C_VIAPRO is not set
10723 @@ -713,6 +727,7 @@
10724  # CONFIG_SENSORS_IT87 is not set
10725  # CONFIG_SENSORS_LM75 is not set
10726  # CONFIG_SENSORS_LM85 is not set
10727 +# CONFIG_SENSORS_LM78 is not set
10728  # CONFIG_SENSORS_VIA686A is not set
10729  # CONFIG_SENSORS_W83781D is not set
10730  # CONFIG_I2C_SENSOR is not set
10731 @@ -1047,6 +1062,7 @@
10732  #
10733  # USB Network adaptors
10734  #
10735 +# CONFIG_USB_AX8817X is not set
10736  # CONFIG_USB_CATC is not set
10737  # CONFIG_USB_KAWETH is not set
10738  # CONFIG_USB_PEGASUS is not set
10739 @@ -1123,7 +1139,6 @@
10740  # Kernel hacking
10741  #
10742  # CONFIG_DEBUG_KERNEL is not set
10743 -CONFIG_KALLSYMS=y
10744  CONFIG_BOOTX_TEXT=y
10745  
10746  #
10747 diff -Nru a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
10748 --- a/arch/ppc/kernel/Makefile  Mon Aug  4 20:55:20 2003
10749 +++ b/arch/ppc/kernel/Makefile  Wed Sep  3 05:16:34 2003
10750 @@ -12,6 +12,7 @@
10751  # Start off with 'head.o', change as needed.
10752  extra-y                                := head.o
10753  extra-$(CONFIG_40x)            := head_4xx.o
10754 +extra-$(CONFIG_44x)            := head_44x.o
10755  extra-$(CONFIG_8xx)            := head_8xx.o
10756  extra-$(CONFIG_6xx)            += idle_6xx.o
10757  extra-y                                += vmlinux.lds.s
10758 diff -Nru a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c
10759 --- a/arch/ppc/kernel/cputable.c        Sun Apr 27 05:41:48 2003
10760 +++ b/arch/ppc/kernel/cputable.c        Wed Sep  3 05:16:34 2003
10761 @@ -154,6 +154,15 @@
10762         32, 32,
10763         __setup_cpu_750cx
10764      },
10765 +    {  /* 750FX rev 1.x */
10766 +       0xffffff00, 0x70000100, "750FX",
10767 +       CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
10768 +       CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_CAN_NAP |
10769 +       CPU_FTR_DUAL_PLL_750FX | CPU_FTR_NO_DPM,
10770 +       COMMON_PPC,
10771 +       32, 32,
10772 +       __setup_cpu_750
10773 +    },
10774      {  /* 750FX rev 2.0 must disable HID0[DPM] */
10775         0xffffffff, 0x70000200, "750FX",
10776         CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
10777 @@ -424,7 +433,7 @@
10778       },
10779  
10780  #endif /* CONFIG_40x */
10781 -#ifdef CONFIG_440
10782 +#ifdef CONFIG_44x
10783      { /* 440GP Rev. B */
10784          0xf0000fff, 0x40000440, "440GP Rev. B",
10785          CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
10786 @@ -439,7 +448,14 @@
10787          32, 32,
10788          0, /*__setup_cpu_440 */
10789      },
10790 -#endif /* CONFIG_440 */
10791 +    { /* 440GX Rev. A */
10792 +        0xf0000fff, 0x50000850, "440GX Rev. A",
10793 +        CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
10794 +        PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU,
10795 +        32, 32,
10796 +        0, /*__setup_cpu_440 */
10797 +    },
10798 +#endif /* CONFIG_44x */
10799  #if !CLASSIC_PPC
10800      {  /* default match */
10801         0x00000000, 0x00000000, "(generic PPC)",
10802 diff -Nru a/arch/ppc/kernel/head.S b/arch/ppc/kernel/head.S
10803 --- a/arch/ppc/kernel/head.S    Wed Jun  4 20:07:15 2003
10804 +++ b/arch/ppc/kernel/head.S    Tue Aug 26 06:38:51 2003
10805 @@ -355,11 +355,6 @@
10806   *     -- paulus.
10807   */
10808         . = 0x200
10809 -MachineCheck:
10810 -BEGIN_FTR_SECTION
10811 -       dssall
10812 -       sync
10813 -END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
10814         mtspr   SPRG0,r10
10815         mtspr   SPRG1,r11
10816         mfcr    r10
10817 diff -Nru a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S
10818 --- /dev/null   Wed Dec 31 16:00:00 1969
10819 +++ b/arch/ppc/kernel/head_44x.S        Wed Sep  3 02:08:48 2003
10820 @@ -0,0 +1,1056 @@
10821 +/*
10822 + * arch/ppc/kernel/head_44x.S
10823 + *
10824 + * Kernel execution entry point code.
10825 + *
10826 + * Matt Porter <mporter@mvista.com>
10827 + *
10828 + * Copyright 2002-2003 MontaVista Software, Inc.
10829 + *
10830 + * This program is free software; you can redistribute  it and/or modify it
10831 + * under  the terms of  the GNU General  Public License as published by the
10832 + * Free Software Foundation;  either version 2 of the  License, or (at your
10833 + * option) any later version.
10834 + */
10835 +
10836 +#include <linux/config.h>
10837 +#include <asm/processor.h>
10838 +#include <asm/page.h>
10839 +#include <asm/mmu.h>
10840 +#include <asm/pgtable.h>
10841 +#include <asm/ibm4xx.h>
10842 +#include <asm/ibm44x.h>
10843 +#include <asm/cputable.h>
10844 +#include <asm/thread_info.h>
10845 +#include <asm/ppc_asm.h>
10846 +#include <asm/offsets.h>
10847 +
10848 +/*
10849 + * Macros
10850 + */
10851 +
10852 +#define SET_IVOR(vector_number, vector_label)          \
10853 +               li      r26,vector_label@l;             \
10854 +               mtspr   SPRN_IVOR##vector_number,r26;   \
10855 +               sync
10856 +                                       
10857 +/* As with the other PowerPC ports, it is expected that when code
10858 + * execution begins here, the following registers contain valid, yet
10859 + * optional, information:
10860 + *
10861 + *   r3 - Board info structure pointer (DRAM, frequency, MAC address, etc.)
10862 + *   r4 - Starting address of the init RAM disk
10863 + *   r5 - Ending address of the init RAM disk
10864 + *   r6 - Start of kernel command line string (e.g. "mem=128")
10865 + *   r7 - End of kernel command line string
10866 + *
10867 + */ 
10868 +       .text
10869 +_GLOBAL(_stext)
10870 +_GLOBAL(_start)
10871 +       /*
10872 +        * Reserve a word at a fixed location to store the address
10873 +        * of abatron_pteptrs
10874 +        */
10875 +       nop
10876 +/*
10877 + * Save parameters we are passed
10878 + */
10879 +       mr      r31,r3
10880 +       mr      r30,r4
10881 +       mr      r29,r5
10882 +       mr      r28,r6
10883 +       mr      r27,r7
10884 +       li      r24,0           /* CPU number */
10885 +
10886 +/*
10887 + * Set up the initial MMU state
10888 + *
10889 + * We are still executing code at the virtual address
10890 + * mappings set by the firmware for the base of RAM.
10891 + *
10892 + * We first invalidate all TLB entries but the one
10893 + * we are running from.  We then load the KERNELBASE
10894 + * mappings so we can begin to use kernel addresses
10895 + * natively and so the interrupt vector locations are
10896 + * permanently pinned (necessary since Book E
10897 + * implementations always have translation enabled).
10898 + *
10899 + * TODO: Use the known TLB entry we are running from to
10900 + *      determine which physical region we are located
10901 + *      in.  This can be used to determine where in RAM
10902 + *      (on a shared CPU system) or PCI memory space
10903 + *      (on a DRAMless system) we are located.
10904 + *       For now, we assume a perfect world which means
10905 + *      we are located at the base of DRAM (physical 0).
10906 + */
10907 +
10908 +/*
10909 + * Search TLB for entry that we are currently using.
10910 + * Invalidate all entries but the one we are using.
10911 + */
10912 +       /* Load our current PID->MMUCR TID and MSR IS->MMUCR STS */
10913 +       mfspr   r3,SPRN_MMUCR                   /* Get MMUCR */
10914 +       lis     r4,PPC44x_MMUCR_STS@h
10915 +       ori     r4,r4,PPC44x_MMUCR_TID@l        /* Create mask */
10916 +       andc    r3,r3,r4                        /* Clear out TID/STS bits */
10917 +       mfspr   r4,SPRN_PID                     /* Get PID */
10918 +       or      r3,r3,r4                        /* Set TID bits */
10919 +       mfmsr   r5                              /* Get MSR */
10920 +       andi.   r5,r5,MSR_IS@l                  /* TS=1? */
10921 +       beq     wmmucr                          /* If not, leave STS=0 */
10922 +       oris    r3,r3,PPC44x_MMUCR_STS@h        /* Set STS=1 */
10923 +wmmucr:        mtspr   SPRN_MMUCR,r3                   /* Put MMUCR */
10924 +       sync
10925 +       
10926 +       bl      invstr                          /* Find our address */
10927 +invstr:        mflr    r5                              /* Make it accessible */
10928 +       tlbsx   r23,0,r5                        /* Find entry we are in */
10929 +       li      r4,0                            /* Start at TLB entry 0 */
10930 +       li      r3,0                            /* Set PAGEID inval value */
10931 +1:     cmpw    r23,r4                          /* Is this our entry? */
10932 +       beq     skpinv                          /* If so, skip the inval */
10933 +       tlbwe   r3,r4,PPC44x_TLB_PAGEID         /* If not, inval the entry */
10934 +skpinv:        addi    r4,r4,1                         /* Increment */
10935 +       cmpwi   r4,64                           /* Are we done? */
10936 +       bne     1b                              /* If not, repeat */
10937 +       isync                                   /* If so, context change */
10938 +
10939 +/*
10940 + * Configure and load pinned entries into TLB slots 62 and 63.
10941 + */
10942 +
10943 +       lis     r3,KERNELBASE@h         /* Load the kernel virtual address */
10944 +       ori     r3,r3,KERNELBASE@l
10945 +
10946 +       /* Kernel is at the base of RAM */
10947 +       li r4, 0                        /* Load the kernel physical address */
10948 +
10949 +       /* Load the kernel PID = 0 */
10950 +       li      r0,0
10951 +       mtspr   SPRN_PID,r0
10952 +       sync
10953 +
10954 +       /* Load the kernel TID  = 0 */
10955 +       mfspr   r5,SPRN_MMUCR
10956 +       lis     r6, PPC44x_MMUCR_TID@h
10957 +       ori     r6,r6,PPC44x_MMUCR_TID@l
10958 +       andc    r5,r5,r6
10959 +       mtspr   SPRN_MMUCR,r5
10960 +       sync
10961 +
10962 +       /* pageid fields */
10963 +       clrrwi  r3,r3,10                /* Mask off the effective page number */
10964 +       ori     r3,r3,(PPC44x_TLB_VALID | PPC44x_TLB_PAGESZ(PPC44x_PAGESZ_256M))
10965 +
10966 +       /* xlat fields */
10967 +       clrrwi  r4,r4,10                /* Mask off the real page number */
10968 +                                       /* ERPN is 0 for first 4GB page */
10969 +
10970 +       /* attrib fields */
10971 +       /* Added guarded bit to protect against speculative loads/stores */
10972 +       li      r5,0
10973 +       ori     r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G)
10974 +
10975 +        li      r0,62                    /* TLB slot 62 */
10976 +
10977 +       tlbwe   r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */
10978 +       tlbwe   r4,r0,PPC44x_TLB_XLAT   /* Load the translation fields */
10979 +       tlbwe   r5,r0,PPC44x_TLB_ATTRIB /* Load the attrib/access fields */
10980 +
10981 +       /* Force context change */
10982 +       mfmsr   r0
10983 +       mtspr   SRR1, r0
10984 +       lis     r0,3f@h
10985 +       ori     r0,r0,3f@l
10986 +       mtspr   SRR0,r0
10987 +       sync
10988 +       rfi
10989 +
10990 +       /* If necessary, invalidate original entry we used */
10991 +3:     cmpwi   r23,62
10992 +       beq     4f
10993 +       li      r6,0
10994 +       tlbwe   r6,r23,PPC44x_TLB_PAGEID
10995 +       sync
10996 +
10997 +4:     ori     r3,r3,PPC44x_TLB_TS     /* TS = 1 */
10998 +
10999 +        li      r0,63                   /* TLB slot 63 */
11000 +
11001 +       tlbwe   r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */
11002 +       tlbwe   r4,r0,PPC44x_TLB_XLAT   /* Load the translation fields */
11003 +       tlbwe   r5,r0,PPC44x_TLB_ATTRIB /* Load the attrib/access fields */
11004 +
11005 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
11006 +       /*
11007 +        * Add temporary UART mapping for early debug.  This
11008 +        * mapping must be identical to that used by the early
11009 +        * bootloader code since the same asm/serial.h parameters
11010 +        * are used for polled operation.
11011 +        */
11012 +       /* pageid fields */
11013 +       lis     r3,0xe000               
11014 +       ori     r3,r3,(PPC44x_TLB_VALID | PPC44x_TLB_PAGESZ(PPC44x_PAGESZ_256M))
11015 +
11016 +       /* xlat fields */
11017 +       lis     r4,0x4000               /* RPN is 0x40000000 */
11018 +       ori     r4,r4,0x0001            /* ERPN is 1 for second 4GB page */
11019 +
11020 +       /* attrib fields */
11021 +       li      r5,0
11022 +       ori     r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_I | PPC44x_TLB_G)
11023 +
11024 +        li      r0,60                    /* TLB slot 60 */
11025 +
11026 +       tlbwe   r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */
11027 +       tlbwe   r4,r0,PPC44x_TLB_XLAT   /* Load the translation fields */
11028 +       tlbwe   r5,r0,PPC44x_TLB_ATTRIB /* Load the attrib/access fields */
11029 +
11030 +       ori     r3,r3,PPC44x_TLB_TS     /* Translation state 1 */
11031 +
11032 +        li      r0,61                  /* TLB slot 61 */
11033 +
11034 +       tlbwe   r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */
11035 +       tlbwe   r4,r0,PPC44x_TLB_XLAT   /* Load the translation fields */
11036 +       tlbwe   r5,r0,PPC44x_TLB_ATTRIB /* Load the attrib/access fields */
11037 +#endif /* CONFIG_SERIAL_TEXT_DEBUG */
11038 +
11039 +       /* Force context change */
11040 +       isync
11041 +
11042 +       /* Establish the interrupt vector offsets */
11043 +       SET_IVOR(0,  CriticalInput);
11044 +       SET_IVOR(1,  MachineCheck);
11045 +       SET_IVOR(2,  DataStorage);
11046 +       SET_IVOR(3,  InstructionStorage);
11047 +       SET_IVOR(4,  ExternalInput);
11048 +       SET_IVOR(5,  Alignment);
11049 +       SET_IVOR(6,  Program);
11050 +       SET_IVOR(7,  FloatingPointUnavailable);
11051 +       SET_IVOR(8,  SystemCall);
11052 +       SET_IVOR(9,  AuxillaryProcessorUnavailable);
11053 +       SET_IVOR(10, Decrementer);
11054 +       SET_IVOR(11, FixedIntervalTimer);
11055 +       SET_IVOR(12, WatchdogTimer);
11056 +       SET_IVOR(13, DataTLBError);
11057 +       SET_IVOR(14, InstructionTLBError);
11058 +       SET_IVOR(15, Debug);
11059 +
11060 +       /* Establish the interrupt vector base */
11061 +       lis     r4,interrupt_base@h     /* IVPR only uses the high 16-bits */
11062 +       mtspr   SPRN_IVPR,r4
11063 +
11064 +       /*
11065 +        * This is where the main kernel code starts.
11066 +        */ 
11067 +
11068 +       /* ptr to current */
11069 +       lis     r2,init_task@h
11070 +       ori     r2,r2,init_task@l
11071 +
11072 +       /* ptr to current thread */
11073 +       addi    r4,r2,THREAD    /* init task's THREAD */
11074 +       mtspr   SPRG3,r4
11075 +
11076 +       /* stack */
11077 +       lis     r1,init_thread_union@h
11078 +       ori     r1,r1,init_thread_union@l
11079 +       li      r0,0
11080 +       stwu    r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)
11081 +
11082 +       bl      early_init
11083 +
11084 +/*
11085 + * Decide what sort of machine this is and initialize the MMU.
11086 + */
11087 +       mr      r3,r31
11088 +       mr      r4,r30
11089 +       mr      r5,r29
11090 +       mr      r6,r28
11091 +       mr      r7,r27
11092 +       bl      machine_init
11093 +       bl      MMU_init
11094 +
11095 +       /* Setup PTE pointers for the Abatron bdiGDB */
11096 +       lis     r6, swapper_pg_dir@h
11097 +       ori     r6, r6, swapper_pg_dir@l
11098 +       lis     r5, abatron_pteptrs@h
11099 +       ori     r5, r5, abatron_pteptrs@l
11100 +       lis     r4, KERNELBASE@h
11101 +       ori     r4, r4, KERNELBASE@l
11102 +       stw     r5, 0(r4)       /* Save abatron_pteptrs at a fixed location */
11103 +       stw     r6, 0(r5)
11104 +
11105 +       /* Let's move on */
11106 +       lis     r4,start_kernel@h
11107 +       ori     r4,r4,start_kernel@l
11108 +       lis     r3,MSR_KERNEL@h
11109 +       ori     r3,r3,MSR_KERNEL@l
11110 +       mtspr   SRR0,r4
11111 +       mtspr   SRR1,r3
11112 +       rfi                     /* change context and jump to start_kernel */
11113 +
11114 +/*
11115 + * Interrupt vector entry code
11116 + *
11117 + * The Book E MMUs are always on so we don't need to handle
11118 + * interrupts in real mode as with previous PPC processors. In
11119 + * this case we handle interrupts in the kernel virtual address
11120 + * space.
11121 + *
11122 + * Interrupt vectors are dynamically placed relative to the 
11123 + * interrupt prefix as determined by the address of interrupt_base.
11124 + * The interrupt vectors offsets are programmed using the labels
11125 + * for each interrupt vector entry.
11126 + *
11127 + * Interrupt vectors must be aligned on a 16 byte boundary.
11128 + * We align on a 32 byte cache line boundary for good measure.
11129 + */
11130 +
11131 +#define NORMAL_EXCEPTION_PROLOG                                                     \
11132 +       mtspr   SPRN_SPRG0,r10;         /* save two registers to work with */\
11133 +       mtspr   SPRN_SPRG1,r11;                                              \
11134 +       mtspr   SPRN_SPRG2,r1;                                               \
11135 +       mfcr    r10;                    /* save CR in r10 for now          */\
11136 +       mfspr   r11,SPRN_SRR1;          /* check whether user or kernel    */\
11137 +       andi.   r11,r11,MSR_PR;                                              \
11138 +       beq     1f;                                                          \
11139 +       mfspr   r1,SPRG3;               /* if from user, start at top of   */\
11140 +       lwz     r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack   */\
11141 +       addi    r1,r1,THREAD_SIZE;                                           \
11142 +1:     subi    r1,r1,INT_FRAME_SIZE;   /* Allocate an exception frame     */\
11143 +       tophys(r11,r1);                                                      \
11144 +       stw     r10,_CCR(r11);          /* save various registers          */\
11145 +       stw     r12,GPR12(r11);                                              \
11146 +       stw     r9,GPR9(r11);                                                \
11147 +       mfspr   r10,SPRG0;                                                   \
11148 +       stw     r10,GPR10(r11);                                              \
11149 +       mfspr   r12,SPRG1;                                                   \
11150 +       stw     r12,GPR11(r11);                                              \
11151 +       mflr    r10;                                                         \
11152 +       stw     r10,_LINK(r11);                                              \
11153 +       mfspr   r10,SPRG2;                                                   \
11154 +       mfspr   r12,SRR0;                                                    \
11155 +       stw     r10,GPR1(r11);                                               \
11156 +       mfspr   r9,SRR1;                                                     \
11157 +       stw     r10,0(r11);                                                  \
11158 +       rlwinm  r9,r9,0,14,12;          /* clear MSR_WE (necessary?)       */\
11159 +       stw     r0,GPR0(r11);                                                \
11160 +       SAVE_4GPRS(3, r11);                                                  \
11161 +       SAVE_2GPRS(7, r11)
11162 +
11163 +/*
11164 + * Exception prolog for critical exceptions.  This is a little different
11165 + * from the normal exception prolog above since a critical exception
11166 + * can potentially occur at any point during normal exception processing.
11167 + * Thus we cannot use the same SPRG registers as the normal prolog above.
11168 + * Instead we use a couple of words of memory at low physical addresses.
11169 + * This is OK since we don't support SMP on these processors.
11170 + */
11171 +/* XXX but we don't have RAM mapped at 0 in space 0  -- paulus. */
11172 +#define CRITICAL_EXCEPTION_PROLOG                                           \
11173 +       stw     r10,crit_r10@l(0);      /* save two registers to work with */\
11174 +       stw     r11,crit_r11@l(0);                                           \
11175 +       mfspr   r10,SPRG0;                                                   \
11176 +       stw     r10,crit_sprg0@l(0);                                         \
11177 +       mfspr   r10,SPRG1;                                                   \
11178 +       stw     r10,crit_sprg1@l(0);                                         \
11179 +       mfspr   r10,SPRG4R;                                                  \
11180 +       stw     r10,crit_sprg4@l(0);                                         \
11181 +       mfspr   r10,SPRG5R;                                                  \
11182 +       stw     r10,crit_sprg5@l(0);                                         \
11183 +       mfspr   r10,SPRG6R;                                                  \
11184 +       stw     r10,crit_sprg6@l(0);                                         \
11185 +       mfspr   r10,SPRG7R;                                                  \
11186 +       stw     r10,crit_sprg7@l(0);                                         \
11187 +       mfspr   r10,SPRN_PID;                                                \
11188 +       stw     r10,crit_pid@l(0);                                           \
11189 +       mfspr   r10,SRR0;                                                    \
11190 +       stw     r10,crit_srr0@l(0);                                          \
11191 +       mfspr   r10,SRR1;                                                    \
11192 +       stw     r10,crit_srr1@l(0);                                          \
11193 +       mfcr    r10;                    /* save CR in r10 for now          */\
11194 +       mfspr   r11,SPRN_CSRR1;         /* check whether user or kernel    */\
11195 +       andi.   r11,r11,MSR_PR;                                              \
11196 +       lis     r11,critical_stack_top@h;                                    \
11197 +       ori     r11,r11,critical_stack_top@l;                                \
11198 +       beq     1f;                                                          \
11199 +       /* COMING FROM USER MODE */                                          \
11200 +       mfspr   r11,SPRG3;              /* if from user, start at top of   */\
11201 +       lwz     r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
11202 +       addi    r11,r11,THREAD_SIZE;                                         \
11203 +1:     subi    r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame     */\
11204 +       tophys(r11,r11);                                                     \
11205 +       stw     r10,_CCR(r11);          /* save various registers          */\
11206 +       stw     r12,GPR12(r11);                                              \
11207 +       stw     r9,GPR9(r11);                                                \
11208 +       mflr    r10;                                                         \
11209 +       stw     r10,_LINK(r11);                                              \
11210 +       mfspr   r12,SPRN_DEAR;          /* save DEAR and ESR in the frame  */\
11211 +       stw     r12,_DEAR(r11);         /* since they may have had stuff   */\
11212 +       mfspr   r9,SPRN_ESR;            /* in them at the point where the  */\
11213 +       stw     r9,_ESR(r11);           /* exception was taken             */\
11214 +       mfspr   r12,CSRR0;                                                   \
11215 +       stw     r1,GPR1(r11);                                                \
11216 +       mfspr   r9,CSRR1;                                                    \
11217 +       stw     r1,0(r11);                                                   \
11218 +       tovirt(r1,r11);                                                      \
11219 +       rlwinm  r9,r9,0,14,12;          /* clear MSR_WE (necessary?)       */\
11220 +       stw     r0,GPR0(r11);                                                \
11221 +       SAVE_4GPRS(3, r11);                                                  \
11222 +       SAVE_2GPRS(7, r11)
11223 +
11224 +/*
11225 + * Exception vectors.
11226 + */
11227 +#define        START_EXCEPTION(label)                                               \
11228 +        .align 5;                                                                   \
11229 +label:
11230 +
11231 +#define FINISH_EXCEPTION(func)                                 \
11232 +       bl      transfer_to_handler_full;                       \
11233 +       .long   func;                                           \
11234 +       .long   ret_from_except_full
11235 +
11236 +#define EXCEPTION(n, label, hdlr, xfer)                                \
11237 +       START_EXCEPTION(label);                                 \
11238 +       NORMAL_EXCEPTION_PROLOG;                                \
11239 +       addi    r3,r1,STACK_FRAME_OVERHEAD;                     \
11240 +       xfer(n, hdlr)
11241 +
11242 +#define CRITICAL_EXCEPTION(n, label, hdlr)                     \
11243 +       START_EXCEPTION(label);                                 \
11244 +       CRITICAL_EXCEPTION_PROLOG;                              \
11245 +       addi    r3,r1,STACK_FRAME_OVERHEAD;                     \
11246 +       EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
11247 +                         NOCOPY, transfer_to_handler_full, \
11248 +                         ret_from_except_full)
11249 +
11250 +#define EXC_XFER_TEMPLATE(hdlr, trap, msr, copyee, tfer, ret)  \
11251 +       li      r10,trap;                                       \
11252 +       stw     r10,TRAP(r11);                                  \
11253 +       lis     r10,msr@h;                                      \
11254 +       ori     r10,r10,msr@l;                                  \
11255 +       copyee(r10, r9);                                        \
11256 +       bl      tfer;                                           \
11257 +       .long   hdlr;                                           \
11258 +       .long   ret
11259 +
11260 +#define COPY_EE(d, s)          rlwimi d,s,0,16,16
11261 +#define NOCOPY(d, s)
11262 +
11263 +#define EXC_XFER_STD(n, hdlr)          \
11264 +       EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, NOCOPY, transfer_to_handler_full, \
11265 +                         ret_from_except_full)
11266 +
11267 +#define EXC_XFER_LITE(n, hdlr)         \
11268 +       EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, NOCOPY, transfer_to_handler, \
11269 +                         ret_from_except)
11270 +
11271 +#define EXC_XFER_EE(n, hdlr)           \
11272 +       EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, COPY_EE, transfer_to_handler_full, \
11273 +                         ret_from_except_full)
11274 +
11275 +#define EXC_XFER_EE_LITE(n, hdlr)      \
11276 +       EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, COPY_EE, transfer_to_handler, \
11277 +                         ret_from_except)
11278 +
11279 +interrupt_base:
11280 +       /* Critical Input Interrupt */
11281 +       CRITICAL_EXCEPTION(0x0100, CriticalInput, UnknownException)
11282 +
11283 +       /* Machine Check Interrupt */
11284 +       CRITICAL_EXCEPTION(0x0200, MachineCheck, MachineCheckException)
11285 +
11286 +       /* Data Storage Interrupt */
11287 +       START_EXCEPTION(DataStorage)
11288 +       mtspr   SPRG0, r10              /* Save some working registers */
11289 +       mtspr   SPRG1, r11
11290 +       mtspr   SPRG4W, r12
11291 +       mtspr   SPRG5W, r13
11292 +       mtspr   SPRG6W, r14
11293 +       mfcr    r11
11294 +       mtspr   SPRG7W, r11
11295 +
11296 +       /*
11297 +        * Check if it was a store fault, if not then bail
11298 +        * because a user tried to access a kernel or
11299 +        * read-protected page.  Otherwise, get the
11300 +        * offending address and handle it.
11301 +        */
11302 +       mfspr   r10, SPRN_ESR
11303 +       andis.  r10, r10, ESR_ST@h
11304 +       beq     2f
11305 +
11306 +       mfspr   r10, SPRN_DEAR          /* Get faulting address */
11307 +
11308 +       /* If we are faulting a kernel address, we have to use the
11309 +        * kernel page tables.
11310 +        */
11311 +       andis.  r11, r10, 0x8000
11312 +       beq     3f
11313 +       lis     r11, swapper_pg_dir@h
11314 +       ori     r11, r11, swapper_pg_dir@l
11315 +
11316 +       mfspr   r12,SPRN_MMUCR          /* Set TID to 0 */
11317 +       li      r13,PPC44x_MMUCR_TID@l
11318 +       andc    r12,r12,r13
11319 +       mtspr   SPRN_MMUCR,r12
11320 +
11321 +       b       4f
11322 +
11323 +       /* Get the PGD for the current thread */
11324 +3:
11325 +       mfspr   r11,SPRG3
11326 +       lwz     r11,PGDIR(r11)
11327 +
11328 +       /* Load MMUCR with our PID and STS=<current TS> */
11329 +       mfspr   r12,SPRN_MMUCR                  /* Get MMUCR */
11330 +       lis     r13,PPC44x_MMUCR_STS@h
11331 +       ori     r13,r13,PPC44x_MMUCR_TID@l      /* Create mask */
11332 +       andc    r12,r12,r13                     /* Clear out TID/STS bits */
11333 +       mfspr   r13,SPRN_PID                    /* Get PID */
11334 +       or      r12,r12,r13                     /* Set TID bits */
11335 +       mfspr   r14,SPRN_SRR1                   /* Get SRR1 */
11336 +       andi.   r14,r14,MSR_IS@l                /* TS=1? */
11337 +       beq     4f                              /* If not, leave STS=0 */
11338 +       oris    r12,r12,PPC44x_MMUCR_STS@h      /* Set STS=1 */
11339 +       mtspr   SPRN_MMUCR,r12
11340 +4:
11341 +       rlwinm  r12, r10, 13, 19, 29    /* Compute pgdir/pmd offset */
11342 +       lwzx    r11, r12, r11           /* Get pgd/pmd entry */
11343 +       rlwinm. r12, r11, 0, 0, 20      /* Extract pt base address */
11344 +       beq     2f                      /* Bail if no table */
11345 +
11346 +       rlwimi  r12, r10, 23, 20, 28    /* Compute pte address */
11347 +       lwz     r11, 4(r12)             /* Get pte entry */
11348 +       
11349 +       andi.   r13, r11, _PAGE_RW      /* Is it writeable? */
11350 +       beq     2f                      /* Bail if not */
11351 +
11352 +       /* Update 'changed'.
11353 +       */
11354 +       ori     r11, r11, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
11355 +       stw     r11, 4(r12)             /* Update Linux page table */
11356 +
11357 +       /* FIXME: Staticly setting some permissions */
11358 +       li      r13, 0x003f             /* Set UX,UW,UR,SX,SW,SR */
11359 +       andi.   r11,r11,0xffff          /* Clear MS 16 bits */
11360 +       /* FIXME: Force attributes */
11361 +       ori     r11,r11, 0x0100         /* Set G */
11362 +       /* FIXME: Already set in PTE */
11363 +       rlwimi  r11,r13,0,26,31         /* Insert static perms */
11364 +
11365 +       lis     r13,0xffff
11366 +       ori     r13,r13,0x0fff                  /* Set U0-U3 mask */
11367 +       and     r11,r11,r13                     /* Clear U0-U3 */
11368 +
11369 +       /* find the TLB index that caused the fault.  It has to be here. */
11370 +       tlbsx   r14, 0, r10
11371 +
11372 +       tlbwe   r11, r14, PPC44x_TLB_ATTRIB             /* Write ATTRIB */
11373 +
11374 +       /* Done...restore registers and get out of here.
11375 +       */
11376 +       mfspr   r11, SPRG7R
11377 +       mtcr    r11
11378 +       mfspr   r14, SPRG6R
11379 +       mfspr   r13, SPRG5R
11380 +       mfspr   r12, SPRG4R
11381 +
11382 +       mfspr   r11, SPRG1
11383 +       mfspr   r10, SPRG0
11384 +       rfi                     /* Force context change */
11385 +
11386 +2:
11387 +       /*
11388 +        * The bailout.  Restore registers to pre-exception conditions
11389 +        * and call the heavyweights to help us out.
11390 +        */
11391 +       mfspr   r11, SPRG7R
11392 +       mtcr    r11
11393 +       mfspr   r14, SPRG6R
11394 +       mfspr   r13, SPRG5R
11395 +       mfspr   r12, SPRG4R
11396 +
11397 +       mfspr   r11, SPRG1
11398 +       mfspr   r10, SPRG0
11399 +       b       data_access
11400 +
11401 +       /* Instruction Storage Interrupt */
11402 +       START_EXCEPTION(InstructionStorage)
11403 +       NORMAL_EXCEPTION_PROLOG
11404 +       mr      r4,r12                  /* Pass SRR0 as arg2 */
11405 +       li      r5,0                    /* Pass zero as arg3 */
11406 +       addi    r3,r1,STACK_FRAME_OVERHEAD
11407 +       EXC_XFER_EE_LITE(0x0400, do_page_fault)
11408 +
11409 +       /* External Input Interrupt */
11410 +       EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)
11411 +
11412 +       /* Alignment Interrupt */
11413 +       START_EXCEPTION(Alignment)
11414 +       NORMAL_EXCEPTION_PROLOG
11415 +       mfspr   r4,SPRN_DEAR            /* Grab the DEAR and save it */
11416 +       stw     r4,_DEAR(r11)
11417 +       addi    r3,r1,STACK_FRAME_OVERHEAD
11418 +       EXC_XFER_EE(0x0600, AlignmentException)
11419 +
11420 +       /* Program Interrupt */
11421 +       START_EXCEPTION(Program)
11422 +       NORMAL_EXCEPTION_PROLOG
11423 +       mfspr   r4,SPRN_ESR             /* Grab the ESR and save it */
11424 +       stw     r4,_ESR(r11)
11425 +       addi    r3,r1,STACK_FRAME_OVERHEAD
11426 +       EXC_XFER_EE(0x700, ProgramCheckException)
11427 +
11428 +       /* Floating Point Unavailable Interrupt */
11429 +       EXCEPTION(0x2010, FloatingPointUnavailable, UnknownException, EXC_XFER_EE)
11430 +
11431 +       /* System Call Interrupt */
11432 +       START_EXCEPTION(SystemCall)
11433 +       NORMAL_EXCEPTION_PROLOG
11434 +       EXC_XFER_EE_LITE(0x0c00, DoSyscall)
11435 +
11436 +       /* Auxillary Processor Unavailable Interrupt */
11437 +       EXCEPTION(0x2020, AuxillaryProcessorUnavailable, UnknownException, EXC_XFER_EE)
11438 +
11439 +       /* Decrementer Interrupt */
11440 +       START_EXCEPTION(Decrementer)
11441 +       NORMAL_EXCEPTION_PROLOG
11442 +       lis     r0,TSR_DIS@h            /* Setup the DEC interrupt mask */
11443 +       mtspr   SPRN_TSR,r0             /* Clear the DEC interrupt */
11444 +       addi    r3,r1,STACK_FRAME_OVERHEAD
11445 +       EXC_XFER_LITE(0x1000, timer_interrupt)
11446 +
11447 +       /* Fixed Internal Timer Interrupt */
11448 +       /* TODO: Add FIT support */
11449 +       EXCEPTION(0x1010, FixedIntervalTimer, UnknownException, EXC_XFER_EE)
11450 +
11451 +       /* Watchdog Timer Interrupt */
11452 +       /* TODO: Add watchdog support */
11453 +       CRITICAL_EXCEPTION(0x1020, WatchdogTimer, UnknownException)
11454 +
11455 +       /* Data TLB Error Interrupt */
11456 +       START_EXCEPTION(DataTLBError)
11457 +       mtspr   SPRG0, r10              /* Save some working registers */
11458 +       mtspr   SPRG1, r11
11459 +       mtspr   SPRG4W, r12
11460 +       mtspr   SPRG5W, r13
11461 +       mtspr   SPRG6W, r14
11462 +       mfcr    r11
11463 +       mtspr   SPRG7W, r11
11464 +       mfspr   r10, SPRN_DEAR          /* Get faulting address */
11465 +
11466 +       /* If we are faulting a kernel address, we have to use the
11467 +        * kernel page tables.
11468 +        */
11469 +       andis.  r11, r10, 0x8000
11470 +       beq     3f
11471 +       lis     r11, swapper_pg_dir@h
11472 +       ori     r11, r11, swapper_pg_dir@l
11473 +
11474 +       mfspr   r12,SPRN_MMUCR          /* Set TID to 0 */
11475 +       li      r13,PPC44x_MMUCR_TID@l
11476 +       andc    r12,r12,r13
11477 +       mtspr   SPRN_MMUCR,r12
11478 +
11479 +       b       4f
11480 +
11481 +       /* Get the PGD for the current thread */
11482 +3:
11483 +       mfspr   r11,SPRG3
11484 +       lwz     r11,PGDIR(r11)
11485 +
11486 +       /* Load PID into MMUCR TID */
11487 +       li      r13,PPC44x_MMUCR_TID@l           /* Create mask */
11488 +       andc    r12,r12,r13                      /* Clear out TID/STS bits */
11489 +       mfspr   r13,SPRN_PID                     /* Get PID */
11490 +       or      r12,r12,r13
11491 +       mtspr   SPRN_MMUCR,r12
11492 +4:
11493 +       rlwinm  r12, r10, 13, 19, 29    /* Compute pgdir/pmd offset */
11494 +       lwzx    r11, r12, r11           /* Get pgd/pmd entry */
11495 +       rlwinm. r12, r11, 0, 0, 20      /* Extract pt base address */
11496 +       beq     2f                      /* Bail if no table */
11497 +
11498 +       rlwimi  r12, r10, 23, 20, 28    /* Compute pte address */
11499 +       lwz     r11, 4(r12)             /* Get pte entry */
11500 +       andi.   r13, r11, _PAGE_PRESENT /* Is the page present? */
11501 +       beq     2f                      /* Bail if not present */
11502 +
11503 +       ori     r11, r11, _PAGE_ACCESSED
11504 +       stw     r11, 4(r12)
11505 +
11506 +        /* Jump to common tlb load */
11507 +       b       finish_tlb_load
11508 +
11509 +2:
11510 +       /* The bailout.  Restore registers to pre-exception conditions
11511 +        * and call the heavyweights to help us out.
11512 +        */
11513 +       mfspr   r11, SPRG7R
11514 +       mtcr    r11
11515 +       mfspr   r14, SPRG6R
11516 +       mfspr   r13, SPRG5R
11517 +       mfspr   r12, SPRG4R
11518 +       mfspr   r11, SPRG1
11519 +       mfspr   r10, SPRG0
11520 +       b       data_access
11521 +
11522 +       /* Instruction TLB Error Interrupt */
11523 +       /*
11524 +        * Nearly the same as above, except we get our
11525 +        * information from different registers and bailout
11526 +        * to a different point.
11527 +        */
11528 +       START_EXCEPTION(InstructionTLBError)
11529 +       mtspr   SPRG0, r10              /* Save some working registers */
11530 +       mtspr   SPRG1, r11
11531 +       mtspr   SPRG4W, r12
11532 +       mtspr   SPRG5W, r13
11533 +       mtspr   SPRG6W, r14
11534 +       mfcr    r11
11535 +       mtspr   SPRG7W, r11
11536 +       mfspr   r10, SRR0               /* Get faulting address */
11537 +
11538 +       /* If we are faulting a kernel address, we have to use the
11539 +        * kernel page tables.
11540 +        */
11541 +       andis.  r11, r10, 0x8000
11542 +       beq     3f
11543 +       lis     r11, swapper_pg_dir@h
11544 +       ori     r11, r11, swapper_pg_dir@l
11545 +
11546 +       mfspr   r12,SPRN_MMUCR          /* Set TID to 0 */
11547 +       li      r13,PPC44x_MMUCR_TID@l
11548 +       andc    r12,r12,r13
11549 +       mtspr   SPRN_MMUCR,r12
11550 +
11551 +       b       4f
11552 +
11553 +       /* Get the PGD for the current thread */
11554 +3:
11555 +       mfspr   r11,SPRG3
11556 +       lwz     r11,PGDIR(r11)
11557 +
11558 +       /* Load PID into MMUCR TID */
11559 +       li      r13,PPC44x_MMUCR_TID@l           /* Create mask */
11560 +       andc    r12,r13,r13                      /* Clear out TID/STS bits */
11561 +       mfspr   r13,SPRN_PID                     /* Get PID */
11562 +       or      r12,r12,r13
11563 +       mtspr   SPRN_MMUCR,r12
11564 +
11565 +4:
11566 +       rlwinm  r12, r10, 13, 19, 29    /* Compute pgdir/pmd offset */
11567 +       lwzx    r11, r12, r11           /* Get pgd/pmd entry */
11568 +       rlwinm. r12, r11, 0, 0, 20      /* Extract pt base address */
11569 +       beq     2f                      /* Bail if no table */
11570 +
11571 +       rlwimi  r12, r10, 23, 20, 28    /* Compute pte address */
11572 +       lwz     r11, 4(r12)             /* Get pte entry */
11573 +       andi.   r13, r11, _PAGE_PRESENT /* Is the page present? */
11574 +       beq     2f                      /* Bail if not present */
11575 +
11576 +       ori     r11, r11, _PAGE_ACCESSED
11577 +       stw     r11, 4(r12)
11578 +
11579 +       /* Jump to common TLB load point */
11580 +       b       finish_tlb_load
11581 +
11582 +2:
11583 +       /* The bailout.  Restore registers to pre-exception conditions
11584 +        * and call the heavyweights to help us out.
11585 +        */
11586 +       mfspr   r11, SPRG7R
11587 +       mtcr    r11
11588 +       mfspr   r14, SPRG6R
11589 +       mfspr   r13, SPRG5R
11590 +       mfspr   r12, SPRG4R
11591 +       mfspr   r11, SPRG1
11592 +       mfspr   r10, SPRG0
11593 +       b       InstructionStorage
11594 +
11595 +/* Check for a single step debug exception while in an exception
11596 + * handler before state has been saved.  This is to catch the case
11597 + * where an instruction that we are trying to single step causes
11598 + * an exception (eg ITLB/DTLB miss) and thus the first instruction of
11599 + * the exception handler generates a single step debug exception.
11600 + *
11601 + * If we get a debug trap on the first instruction of an exception handler,
11602 + * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
11603 + * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
11604 + * The exception handler was handling a non-critical interrupt, so it will
11605 + * save (and later restore) the MSR via SPRN_SRR1, which will still have
11606 + * the MSR_DE bit set.
11607 + */
11608 +       /* Debug Interrupt */
11609 +       CRITICAL_EXCEPTION(0x2000, Debug, DebugException)
11610 +#if 0
11611 +       START_EXCEPTION(Debug)
11612 +       /* This first instruction was already executed by the exception
11613 +        * handler and must be the first instruction of every exception
11614 +        * handler.
11615 +        */
11616 +       mtspr   SPRN_SPRG0,r10          /* Save some working registers... */
11617 +       mtspr   SPRN_SPRG1,r11
11618 +       mtspr   SPRN_SPRG4W,r12
11619 +       mfcr    r10                     /* ..and the cr because we change it */
11620 +
11621 +       mfspr   r11,SPRN_CSRR1          /* MSR at the time of fault */
11622 +       andi.   r11,r11,MSR_PR
11623 +       bne+    2f                      /* trapped from problem state */
11624 +
11625 +       mfspr   r11,SPRN_CSRR0          /* Faulting instruction address */
11626 +       lis     r12, KERNELBASE@h
11627 +       ori     r12, r12, KERNELBASE@l
11628 +       cmplw   r11,r12
11629 +       blt+    2f                      /* addr below exception vectors */
11630 +
11631 +       lis     r12, Debug@h
11632 +       ori     r12, r12, Debug@l
11633 +       cmplw   r11,r12
11634 +       bgt+    2f                      /* addr above TLB exception vectors */
11635 +
11636 +       lis     r11,DBSR_IC@h           /* Remove the trap status */
11637 +       mtspr   SPRN_DBSR,r11
11638 +
11639 +       mfspr   r11,SPRN_CSRR1
11640 +       rlwinm  r11,r11,0,23,21         /* clear MSR_DE */
11641 +       mtspr   SPRN_CSRR1, r11         /* restore MSR at rcfi without DE */
11642 +
11643 +       mtcrf   0xff,r10                /* restore registers */
11644 +       mfspr   r12,SPRN_SPRG4R
11645 +       mfspr   r11,SPRN_SPRG1
11646 +       mfspr   r10,SPRN_SPRG0
11647 +
11648 +       sync
11649 +       rfci                            /* return to the exception handler  */
11650 +       b       .                       /* prevent prefetch past rfci */
11651 +
11652 +2:
11653 +       mtcrf   0xff,r10                /* restore registers */
11654 +       mfspr   r12,SPRN_SPRG4R
11655 +       mfspr   r11,SPRN_SPRG1
11656 +       mfspr   r10,SPRN_SPRG0
11657 +
11658 +       CRIT_EXCEPTION_PROLOG
11659 +       addi    r3,r1,STACK_FRAME_OVERHEAD
11660 +       li      r7,CRIT_EXC;
11661 +        li      r9,MSR_KERNEL
11662 +       FINISH_EXCEPTION(DebugException)
11663 +#endif
11664 +
11665 +/*
11666 + * Local functions
11667 + */
11668 +       /*
11669 +        * Data TLB exceptions will bail out to this point
11670 +        * if they can't resolve the lightweight TLB fault.
11671 +        */
11672 +data_access:
11673 +       NORMAL_EXCEPTION_PROLOG
11674 +       mfspr   r5,SPRN_ESR             /* Grab the ESR, save it, pass arg3 */
11675 +       stw     r5,_ESR(r11)
11676 +       mfspr   r4,SPRN_DEAR            /* Grab the DEAR, save it, pass arg2 */
11677 +       stw     r4,_DEAR(r11)
11678 +       addi    r3,r1,STACK_FRAME_OVERHEAD
11679 +       EXC_XFER_EE_LITE(0x0300, do_page_fault)
11680 +
11681 +/*
11682 +
11683 + * Both the instruction and data TLB miss get to this
11684 + * point to load the TLB.
11685 + *     r10 - EA of fault
11686 + *     r11 - available to use
11687 + *     r12 - Pointer to the 64-bit PTE
11688 + *     r13 - available to use
11689 + *     r14 - available to use
11690 + *     MMUCR - loaded with proper value when we get here
11691 + *     Upon exit, we reload everything and RFI.
11692 + */
11693 +finish_tlb_load:
11694 +       /*
11695 +        * We set execute, because we don't have the granularity to
11696 +        * properly set this at the page level (Linux problem).
11697 +        * If shared is set, we cause a zero PID->TID load.
11698 +        * Many of these bits are software only.  Bits we don't set
11699 +        * here we (properly should) assume have the appropriate value.
11700 +        */
11701 +
11702 +       /* Load the next available TLB index */
11703 +       lis     r13, tlb_44x_index@h
11704 +       ori     r13, r13, tlb_44x_index@l
11705 +       lwz     r14, 0(r13)
11706 +       /* Load the TLB high watermark */
11707 +       lis     r13, tlb_44x_hwater@h
11708 +       ori     r13, r13, tlb_44x_hwater@l
11709 +       lwz     r11, 0(r13)
11710 +
11711 +       
11712 +       /* Increment, rollover, and store TLB index */
11713 +       addi    r14, r14, 1
11714 +       cmpw    0, r14, r11             /* reserve entries 62-63 for kernel */
11715 +       ble     7f
11716 +       li      r14, 0
11717 +7:
11718 +       /* Load the next available TLB index */
11719 +       lis     r13, tlb_44x_index@h
11720 +       ori     r13, r13, tlb_44x_index@l
11721 +       stw     r14, 0(r13)
11722 +
11723 +6:
11724 +       lwz     r13, 0(r12)                     /* Get MS word of PTE */
11725 +       lwz     r11, 4(r12)                     /* Get LS word of PTE */
11726 +       rlwimi  r13, r11, 0, 0 , 19             /* Insert RPN */
11727 +       tlbwe   r13, r14, PPC44x_TLB_XLAT       /* Write XLAT */
11728 +
11729 +       /*
11730 +        * Create PAGEID. This is the faulting address plus
11731 +        * a set of static bits. The static bits are page
11732 +        * size and valid. Bits 20  and 21 should be zero
11733 +        * for a page size of 4KB.
11734 +        */
11735 +       li      r12, 0x0210                     /* Set size and valid */
11736 +       mfspr   r13, SPRN_SRR1                  /* Get SRR1 */
11737 +       andi.   r13, r13, MSR_IS@l
11738 +       beq     7f
11739 +       ori     r12, r12, PPC44x_TLB_TS@l       /* Set TS=1 */
11740 +7:     rlwimi  r10, r12, 0, 20, 31             /* Insert statics */
11741 +       tlbwe   r10, r14, PPC44x_TLB_PAGEID     /* Write PAGEID */
11742 +
11743 +       /* FIXME: Staticly setting some permissions */
11744 +       li      r13, 0x002d                     /* Set UX,UR,SX,SR */
11745 +       andi.   r11, r11, 0xffff                /* Clear MS 16 bits */
11746 +       andi.   r12, r11, 0x0002                /* _PAGE_HWWRITE? */
11747 +       beq     8f
11748 +       ori     r13, r13, 0x0002                /* Set SW */
11749 +       /* FIXME: Force attributes */
11750 +8:     ori     r11, r11, 0x0100                /* Set G */
11751 +       /* FIXME: Already set in PTE */
11752 +       rlwimi  r11, r13, 0, 26, 31             /* Insert static perms */
11753 +
11754 +       lis     r13,0xffff
11755 +       ori     r13,r13,0x0fff                  /* Set U0-U3 mask */
11756 +       and     r11,r11,r13                     /* Clear U0-U3 */
11757 +       tlbwe   r11, r14, PPC44x_TLB_ATTRIB     /* Write ATTRIB */
11758 +
11759 +       /* Done...restore registers and get out of here.
11760 +       */
11761 +       mfspr   r11, SPRG7R
11762 +       mtcr    r11
11763 +       mfspr   r14, SPRG6R
11764 +       mfspr   r13, SPRG5R
11765 +       mfspr   r12, SPRG4R
11766 +       mfspr   r11, SPRG1
11767 +       mfspr   r10, SPRG0
11768 +       rfi                                     /* Force context change */
11769 +
11770 +/*
11771 + * Global functions
11772 + */
11773 +
11774 +/*
11775 + * extern void giveup_altivec(struct task_struct *prev)
11776 + *
11777 + * The 44x core does not have an AltiVec unit.
11778 + */
11779 +_GLOBAL(giveup_altivec)
11780 +       blr
11781 +
11782 +/*
11783 + * extern void giveup_fpu(struct task_struct *prev)
11784 + *
11785 + * The 44x core does not have an FPU.
11786 + */
11787 +_GLOBAL(giveup_fpu)
11788 +       blr
11789 +
11790 +/*
11791 + * extern void abort(void)
11792 + *
11793 + * At present, this routine just applies a system reset.
11794 + */ 
11795 +_GLOBAL(abort)
11796 +        mfspr   r13,SPRN_DBCR0
11797 +        oris    r13,r13,DBCR_RST(DBCR_RST_SYSTEM)@h
11798 +        mtspr   SPRN_DBCR0,r13
11799 +
11800 +_GLOBAL(set_context)
11801 +
11802 +#ifdef CONFIG_BDI_SWITCH
11803 +       /* Context switch the PTE pointer for the Abatron BDI2000.
11804 +        * The PGDIR is the second parameter.
11805 +        */
11806 +       lis     r5, abatron_pteptrs@h
11807 +       ori     r5, r5, abatron_pteptrs@l
11808 +       stw     r4, 0x4(r5)
11809 +#endif
11810 +       mtspr   SPRN_PID,r3
11811 +       isync                   /* Force context change */
11812 +       blr
11813 +
11814 +/*
11815 + * We put a few things here that have to be page-aligned. This stuff
11816 + * goes at the beginning of the data segment, which is page-aligned.
11817 + */
11818 +       .data
11819 +_GLOBAL(sdata)
11820 +_GLOBAL(empty_zero_page)
11821 +       .space  4096
11822 +
11823 +/*
11824 + * To support >32-bit physical addresses, we use an 8KB pgdir.
11825 + */
11826 +_GLOBAL(swapper_pg_dir)
11827 +       .space  8192
11828 +
11829 +/* Stack for handling critical exceptions from kernel mode */
11830 +       .section .bss
11831 +critical_stack_bottom:
11832 +       .space 4096
11833 +critical_stack_top:
11834 +       .previous
11835 +
11836 +/*
11837 + * This space gets a copy of optional info passed to us by the bootstrap
11838 + * which is used to pass parameters into the kernel like root=/dev/sda1, etc.
11839 + */
11840 +_GLOBAL(cmd_line)
11841 +       .space  512
11842 +
11843 +/*
11844 + * Room for two PTE pointers, usually the kernel and current user pointers
11845 + * to their respective root page table.
11846 + */
11847 +abatron_pteptrs:
11848 +       .space  8
11849 +
11850 +/*
11851 + * This area is used for temporarily saving registers during the
11852 + * critical exception prolog.
11853 + */
11854 +crit_save:
11855 +_GLOBAL(crit_r10)
11856 +       .space  4
11857 +_GLOBAL(crit_r11)
11858 +       .space  4
11859 +_GLOBAL(crit_sprg0)
11860 +       .space  4
11861 +_GLOBAL(crit_sprg1)
11862 +       .space  4
11863 +_GLOBAL(crit_sprg4)
11864 +       .space  4
11865 +_GLOBAL(crit_sprg5)
11866 +       .space  4
11867 +_GLOBAL(crit_sprg6)
11868 +       .space  4
11869 +_GLOBAL(crit_sprg7)
11870 +       .space  4
11871 +_GLOBAL(crit_pid)
11872 +       .space  4
11873 +_GLOBAL(crit_srr0)
11874 +       .space  4
11875 +_GLOBAL(crit_srr1)
11876 +       .space  4
11877 diff -Nru a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S
11878 --- a/arch/ppc/kernel/misc.S    Tue Jul 15 04:47:19 2003
11879 +++ b/arch/ppc/kernel/misc.S    Wed Sep  3 05:16:34 2003
11880 @@ -405,16 +405,20 @@
11881         sync                    /* Flush to memory before changing mapping */
11882         tlbia
11883         isync                   /* Flush shadow TLB */
11884 -#elif defined(CONFIG_440)
11885 +#elif defined(CONFIG_44x)
11886         lis     r3,0
11887         sync
11888  1:
11889 -       tlbwe   r3,r3,PPC440_TLB_PAGEID
11890 +       tlbwe   r3,r3,PPC44x_TLB_PAGEID
11891         addi    r3,r3,1
11892 -       cmpwi   0,r3,61
11893 +       /* Load high watermark */
11894 +       lis     r4,tlb_44x_hwater@h
11895 +       ori     r4,r4,tlb_44x_hwater@l
11896 +       lwz     r5,0(r4)
11897 +       cmpw    0,r3,r5
11898         ble     1b
11899         isync
11900 -#else /* !(CONFIG_40x || CONFIG_440) */
11901 +#else /* !(CONFIG_40x || CONFIG_44x) */
11902  #if defined(CONFIG_SMP)
11903         rlwinm  r8,r1,0,0,18
11904         lwz     r8,TI_CPU(r8)
11905 @@ -465,17 +469,17 @@
11906         tlbwe   r3, r3, TLB_TAG
11907         isync
11908  10:
11909 -#elif defined(CONFIG_440)
11910 +#elif defined(CONFIG_44x)
11911         mfspr   r4,SPRN_MMUCR                   /* Get MMUCR */
11912 -       lis     r5,PPC440_MMUCR_STS@h
11913 -       ori     r5,r5,PPC440_MMUCR_TID@l        /* Create mask */
11914 +       lis     r5,PPC44x_MMUCR_STS@h
11915 +       ori     r5,r5,PPC44x_MMUCR_TID@l        /* Create mask */
11916         andc    r4,r4,r5                        /* Clear out TID/STS bits */
11917         mfspr   r5,SPRN_PID                     /* Get PID */
11918         or      r4,r4,r5                        /* Set TID bits */
11919         mfmsr   r6                              /* Get MSR */
11920         andi.   r6,r6,MSR_IS@l                  /* TS=1? */
11921         beq     11f                             /* If not, leave STS=0 */
11922 -       oris    r4,r4,PPC440_MMUCR_STS@h        /* Set STS=1 */
11923 +       oris    r4,r4,PPC44x_MMUCR_STS@h        /* Set STS=1 */
11924  11:    mtspr   SPRN_MMUCR, r4                  /* Put MMUCR */
11925  
11926         tlbsx.  r3, 0, r3
11927 @@ -486,10 +490,10 @@
11928          * the V bit in the TLB_PAGEID, loading this
11929          * value will invalidate the TLB entry.
11930          */
11931 -       tlbwe   r3, r3, PPC440_TLB_PAGEID
11932 +       tlbwe   r3, r3, PPC44x_TLB_PAGEID
11933         isync
11934  10:
11935 -#else /* !(CONFIG_40x || CONFIG_440) */
11936 +#else /* !(CONFIG_40x || CONFIG_44x) */
11937  #if defined(CONFIG_SMP)
11938         rlwinm  r8,r1,0,0,18
11939         lwz     r8,TI_CPU(r8)
11940 @@ -658,9 +662,9 @@
11941  #ifdef CONFIG_NOT_COHERENT_CACHE
11942  /*
11943   * 40x cores have 8K or 16K dcache and 32 byte line size.
11944 - * 440 has a 32K dcache and 32 byte line size.
11945 + * 44x has a 32K dcache and 32 byte line size.
11946   * 8xx has 1, 2, 4, 8K variants.
11947 - * For now, cover the worst case of the 440.
11948 + * For now, cover the worst case of the 44x.
11949   * Must be called with external interrupts disabled.
11950   */
11951  #define CACHE_NWAYS    64
11952 @@ -1380,3 +1384,4 @@
11953         .long sys_utimes
11954         .long sys_statfs64
11955         .long sys_fstatfs64
11956 +       .long ppc_fadvise64_64
11957 diff -Nru a/arch/ppc/kernel/ppc-stub.c b/arch/ppc/kernel/ppc-stub.c
11958 --- a/arch/ppc/kernel/ppc-stub.c        Mon Jun 30 10:10:33 2003
11959 +++ b/arch/ppc/kernel/ppc-stub.c        Mon Aug 25 11:39:55 2003
11960 @@ -106,6 +106,7 @@
11961  #include <linux/smp.h>
11962  #include <linux/smp_lock.h>
11963  
11964 +#include <asm/cacheflush.h>
11965  #include <asm/system.h>
11966  #include <asm/signal.h>
11967  #include <asm/kgdb.h>
11968 @@ -136,7 +137,7 @@
11969  /* typedef void (*trapfunc_t)(void); */
11970  
11971  static void kgdb_fault_handler(struct pt_regs *regs);
11972 -static void handle_exception (struct pt_regs *regs);
11973 +static int handle_exception (struct pt_regs *regs);
11974  
11975  #if 0
11976  /* Install an exception handler for kgdb */
11977 @@ -186,7 +187,7 @@
11978   * return 0.
11979   */
11980  static unsigned char *
11981 -mem2hex(char *mem, char *buf, int count)
11982 +mem2hex(const char *mem, char *buf, int count)
11983  {
11984         unsigned char ch;
11985         unsigned short tmp_s;
11986 @@ -460,14 +461,12 @@
11987  
11988  int kgdb_bpt(struct pt_regs *regs)
11989  {
11990 -       handle_exception(regs);
11991 -       return 1;
11992 +       return handle_exception(regs);
11993  }
11994  
11995  int kgdb_sstep(struct pt_regs *regs)
11996  {
11997 -       handle_exception(regs);
11998 -       return 1;
11999 +       return handle_exception(regs);
12000  }
12001  
12002  void kgdb(struct pt_regs *regs)
12003 @@ -477,16 +476,14 @@
12004  
12005  int kgdb_iabr_match(struct pt_regs *regs)
12006  {
12007 -       printk("kgdb doesn't support iabr, what?!?\n");
12008 -       handle_exception(regs);
12009 -       return 1;
12010 +       printk(KERN_ERR "kgdb doesn't support iabr, what?!?\n");
12011 +       return handle_exception(regs);
12012  }
12013  
12014  int kgdb_dabr_match(struct pt_regs *regs)
12015  {
12016 -       printk("kgdb doesn't support dabr, what?!?\n");
12017 -       handle_exception(regs);
12018 -       return 1;
12019 +       printk(KERN_ERR "kgdb doesn't support dabr, what?!?\n");
12020 +       return handle_exception(regs);
12021  }
12022  
12023  /* Convert the hardware trap type code to a unix signal number. */
12024 @@ -559,7 +556,7 @@
12025  /*
12026   * This function does all command processing for interfacing to gdb.
12027   */
12028 -static void
12029 +static int
12030  handle_exception (struct pt_regs *regs)
12031  {
12032         int sigval;
12033 @@ -568,14 +565,19 @@
12034         char *ptr;
12035         unsigned int msr;
12036  
12037 +       /* We don't handle user-mode breakpoints. */
12038 +       if (user_mode(regs))
12039 +               return 0;
12040 +
12041         if (debugger_fault_handler) {
12042                 debugger_fault_handler(regs);
12043                 panic("kgdb longjump failed!\n");
12044         }
12045         if (kgdb_active) {
12046 -               printk("interrupt while in kgdb, returning\n");
12047 -               return;
12048 +               printk(KERN_ERR "interrupt while in kgdb, returning\n");
12049 +               return 0;
12050         }
12051 +
12052         kgdb_active = 1;
12053         kgdb_started = 1;
12054  
12055 @@ -783,7 +785,7 @@
12056                                 printk("remcomInBuffer: %s\n", remcomInBuffer);
12057                                 printk("remcomOutBuffer: %s\n", remcomOutBuffer);
12058                         }
12059 -                       return;
12060 +                       return 1;
12061  
12062                 case 's':
12063                         kgdb_flush_cache_all();
12064 @@ -800,7 +802,7 @@
12065                                 printk("remcomInBuffer: %s\n", remcomInBuffer);
12066                                 printk("remcomOutBuffer: %s\n", remcomOutBuffer);
12067                         }
12068 -                       return;
12069 +                       return 1;
12070  
12071                 case 'r':               /* Reset (if user process..exit ???)*/
12072                         panic("kgdb reset.");
12073 @@ -828,11 +830,11 @@
12074                 return;
12075         }
12076  
12077 -       asm("   .globl breakinst
12078 -            breakinst: .long 0x7d821008
12079 -           ");
12080 +       asm("   .globl breakinst        \n\
12081 +            breakinst: .long 0x7d821008");
12082  }
12083  
12084 +#ifdef CONFIG_KGDB_CONSOLE
12085  /* Output string in GDB O-packet format if GDB has connected. If nothing
12086     output, returns 0 (caller must then handle output). */
12087  int
12088 @@ -852,3 +854,4 @@
12089  
12090         return 1;
12091  }
12092 +#endif
12093 diff -Nru a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
12094 --- a/arch/ppc/kernel/ppc_ksyms.c       Tue Jul  1 10:57:22 2003
12095 +++ b/arch/ppc/kernel/ppc_ksyms.c       Wed Sep  3 05:16:34 2003
12096 @@ -155,6 +155,9 @@
12097  EXPORT_SYMBOL(iopa);
12098  EXPORT_SYMBOL(mm_ptov);
12099  EXPORT_SYMBOL(ioremap);
12100 +#ifdef CONFIG_44x
12101 +EXPORT_SYMBOL(ioremap64);
12102 +#endif
12103  EXPORT_SYMBOL(__ioremap);
12104  EXPORT_SYMBOL(iounmap);
12105  EXPORT_SYMBOL(ioremap_bot);    /* aka VMALLOC_END */
12106 @@ -200,6 +203,7 @@
12107  EXPORT_SYMBOL(flush_icache_user_range);
12108  EXPORT_SYMBOL(flush_dcache_page);
12109  EXPORT_SYMBOL(flush_tlb_kernel_range);
12110 +EXPORT_SYMBOL(flush_tlb_page);
12111  #ifdef CONFIG_ALTIVEC
12112  EXPORT_SYMBOL(last_task_used_altivec);
12113  EXPORT_SYMBOL(giveup_altivec);
12114 @@ -259,6 +263,15 @@
12115  EXPORT_SYMBOL(pci_busdev_to_OF_node);
12116  EXPORT_SYMBOL(pci_device_to_OF_node);
12117  EXPORT_SYMBOL(pci_device_from_OF_node);
12118 +EXPORT_SYMBOL(of_find_node_by_name);
12119 +EXPORT_SYMBOL(of_find_node_by_type);
12120 +EXPORT_SYMBOL(of_find_compatible_node);
12121 +EXPORT_SYMBOL(of_find_node_by_path);
12122 +EXPORT_SYMBOL(of_find_all_nodes);
12123 +EXPORT_SYMBOL(of_get_parent);
12124 +EXPORT_SYMBOL(of_get_next_child);
12125 +EXPORT_SYMBOL(of_node_get);
12126 +EXPORT_SYMBOL(of_node_put);
12127  #endif /* CONFIG_PPC_OF */
12128  #if defined(CONFIG_BOOTX_TEXT)
12129  EXPORT_SYMBOL(btext_update_display);
12130 @@ -343,7 +356,7 @@
12131  EXPORT_SYMBOL(cpm_install_handler);
12132  EXPORT_SYMBOL(cpm_free_handler);
12133  #endif /* CONFIG_8xx */
12134 -#if defined(CONFIG_8xx) || defined(CONFIG_40x)
12135 +#if defined(CONFIG_8xx) || defined(CONFIG_4xx)
12136  EXPORT_SYMBOL(__res);
12137  #endif
12138  #if defined(CONFIG_8xx)
12139 diff -Nru a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
12140 --- a/arch/ppc/kernel/setup.c   Mon Aug 18 19:46:23 2003
12141 +++ b/arch/ppc/kernel/setup.c   Mon Aug 25 11:11:43 2003
12142 @@ -624,12 +624,10 @@
12143  #if defined(CONFIG_KGDB)
12144         kgdb_map_scc();
12145         set_debug_traps();
12146 -       if (strstr(cmd_line, "nokgdb"))
12147 -               printk("kgdb default breakpoint deactivated on command line\n");
12148 -       else {
12149 +       if (strstr(cmd_line, "gdb")) {
12150                 if (ppc_md.progress)
12151                         ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
12152 -               printk("kgdb default breakpoint activated\n");
12153 +               printk("kgdb breakpoint activated\n");
12154                 breakpoint();
12155         }
12156  #endif
12157 diff -Nru a/arch/ppc/kernel/smp.c b/arch/ppc/kernel/smp.c
12158 --- a/arch/ppc/kernel/smp.c     Mon Aug 18 19:46:23 2003
12159 +++ b/arch/ppc/kernel/smp.c     Fri Aug 22 19:58:08 2003
12160 @@ -47,8 +47,8 @@
12161  DEFINE_PER_CPU(unsigned int, prof_multiplier);
12162  DEFINE_PER_CPU(unsigned int, prof_counter);
12163  unsigned long cache_decay_ticks = HZ/100;
12164 -unsigned long cpu_online_map = cpumask_of_cpu(0);
12165 -unsigned long cpu_possible_map = 1UL;
12166 +cpumask_t cpu_online_map;
12167 +cpumask_t cpu_possible_map;
12168  int smp_hw_index[NR_CPUS];
12169  struct thread_info *secondary_ti;
12170  
12171 @@ -336,7 +336,7 @@
12172  
12173  void __init smp_prepare_cpus(unsigned int max_cpus)
12174  {
12175 -       int num_cpus;
12176 +       int num_cpus, i;
12177  
12178         /* Fixup boot cpu */
12179          smp_store_cpu_info(smp_processor_id());
12180 @@ -350,7 +350,8 @@
12181  
12182         /* Probe platform for CPUs: always linear. */
12183         num_cpus = smp_ops->probe();
12184 -       cpu_possible_map = (1 << num_cpus)-1;
12185 +       for (i = 0; i < num_cpus; ++i)
12186 +               cpu_set(i, cpu_possible_map);
12187  
12188         /* Backup CPU 0 state */
12189         __save_cpu_setup();
12190 diff -Nru a/arch/ppc/kernel/syscalls.c b/arch/ppc/kernel/syscalls.c
12191 --- a/arch/ppc/kernel/syscalls.c        Tue Jul 15 04:49:49 2003
12192 +++ b/arch/ppc/kernel/syscalls.c        Fri Aug 22 19:15:18 2003
12193 @@ -262,4 +262,14 @@
12194         return error;
12195  }
12196  
12197 +/*
12198 + * We put the arguments in a different order so we only use 6
12199 + * registers for arguments, rather than 7 as sys_fadvise64_64 needs
12200 + * (because `offset' goes in r5/r6).
12201 + */
12202 +long ppc_fadvise64_64(int fd, int advice, loff_t offset, loff_t len)
12203 +{
12204 +       return sys_fadvise64_64(fd, offset, len, advice);
12205 +}
12206 +
12207  cond_syscall(sys_pciconfig_iobase);
12208 diff -Nru a/arch/ppc/mm/44x_mmu.c b/arch/ppc/mm/44x_mmu.c
12209 --- /dev/null   Wed Dec 31 16:00:00 1969
12210 +++ b/arch/ppc/mm/44x_mmu.c     Wed Sep  3 02:10:22 2003
12211 @@ -0,0 +1,162 @@
12212 +/*
12213 + * Modifications by Matt Porter (mporter@mvista.com) to support
12214 + * PPC44x Book E processors.
12215 + *
12216 + * This file contains the routines for initializing the MMU
12217 + * on the 4xx series of chips.
12218 + *  -- paulus
12219 + * 
12220 + *  Derived from arch/ppc/mm/init.c:
12221 + *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
12222 + *
12223 + *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
12224 + *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
12225 + *    Copyright (C) 1996 Paul Mackerras
12226 + *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
12227 + *
12228 + *  Derived from "arch/i386/mm/init.c"
12229 + *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
12230 + *
12231 + *  This program is free software; you can redistribute it and/or
12232 + *  modify it under the terms of the GNU General Public License
12233 + *  as published by the Free Software Foundation; either version
12234 + *  2 of the License, or (at your option) any later version.
12235 + *
12236 + */
12237 +
12238 +#include <linux/config.h>
12239 +#include <linux/signal.h>
12240 +#include <linux/sched.h>
12241 +#include <linux/kernel.h>
12242 +#include <linux/errno.h>
12243 +#include <linux/string.h>
12244 +#include <linux/types.h>
12245 +#include <linux/ptrace.h>
12246 +#include <linux/mman.h>
12247 +#include <linux/mm.h>
12248 +#include <linux/swap.h>
12249 +#include <linux/stddef.h>
12250 +#include <linux/vmalloc.h>
12251 +#include <linux/init.h>
12252 +#include <linux/delay.h>
12253 +#include <linux/bootmem.h>
12254 +#include <linux/highmem.h>
12255 +
12256 +#include <asm/pgalloc.h>
12257 +#include <asm/prom.h>
12258 +#include <asm/io.h>
12259 +#include <asm/mmu_context.h>
12260 +#include <asm/pgtable.h>
12261 +#include <asm/mmu.h>
12262 +#include <asm/uaccess.h>
12263 +#include <asm/smp.h>
12264 +#include <asm/bootx.h>
12265 +#include <asm/machdep.h>
12266 +#include <asm/setup.h>
12267 +
12268 +#include "mmu_decl.h"
12269 +#include "mem_pieces.h"
12270 +
12271 +extern char etext[], _stext[];
12272 +extern struct mem_pieces phys_avail;
12273 +
12274 +/* Used by the 44x TLB replacement exception handler.
12275 + * Just needed it declared someplace.
12276 + */
12277 +unsigned int tlb_44x_index = 0;
12278 +unsigned int tlb_44x_hwater = 61;
12279 +
12280 +/*
12281 + * "Pins" a 256MB TLB entry in AS0 for kernel lowmem
12282 + */
12283 +static void __init
12284 +ppc44x_pin_tlb(int slot, unsigned int virt, unsigned int phys)
12285 +{
12286 +       unsigned long attrib;
12287 +
12288 +       __asm__ __volatile__("\
12289 +       clrrwi  %2,%2,10\n\
12290 +       ori     %2,%2,%4\n\
12291 +       clrrwi  %1,%1,10\n\
12292 +       li      %0,0\n\
12293 +       ori     %0,%0,%5\n\
12294 +       tlbwe   %2,%3,%6\n\
12295 +       tlbwe   %1,%3,%7\n\
12296 +       tlbwe   %0,%3,%8"
12297 +       :
12298 +       : "r" (attrib), "r" (phys), "r" (virt), "r" (slot),
12299 +         "i" (PPC44x_TLB_VALID | PPC44x_TLB_PAGESZ(PPC44x_PAGESZ_256M)),
12300 +         "i" (PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G),
12301 +         "i" (PPC44x_TLB_PAGEID),
12302 +         "i" (PPC44x_TLB_XLAT),
12303 +         "i" (PPC44x_TLB_ATTRIB));
12304 +}
12305 +
12306 +/*
12307 + * Configure PPC44x TLB for AS0 exception processing.
12308 + */
12309 +static void __init
12310 +ppc44x_tlb_config(void)
12311 +{
12312 +       unsigned int pinned_tlbs = 1;
12313 +       int i;
12314 +
12315 +       /*
12316 +        * If lowmem is not on a pin tlb entry size boundary,
12317 +        * then reserve the last page of system memory. This
12318 +        * eliminates the possibility of a speculative dcache
12319 +        * fetch past the end of system memory that would
12320 +        * result in a machine check exception.
12321 +        */
12322 +       if (total_lowmem | (PPC44x_PIN_SIZE - 1))
12323 +               mem_pieces_remove(&phys_avail, total_lowmem - PAGE_SIZE, PAGE_SIZE, 1);
12324 +
12325 +       /* Determine number of entries necessary to cover lowmem */
12326 +       pinned_tlbs = (unsigned int)
12327 +               (_ALIGN(total_lowmem, PPC44x_PIN_SIZE) >> PPC44x_PIN_SHIFT);
12328 +
12329 +       /* Write upper watermark to save location */
12330 +       tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs;
12331 +
12332 +       /* If necessary, set additional pinned TLBs */
12333 +       if (pinned_tlbs > 1)
12334 +               for (i = (PPC44x_LOW_SLOT-(pinned_tlbs-1)); i < PPC44x_LOW_SLOT; i++) {
12335 +                       unsigned int phys_addr = (PPC44x_LOW_SLOT-i) * PPC44x_PIN_SIZE;
12336 +                       ppc44x_pin_tlb(i, phys_addr+PAGE_OFFSET, phys_addr);
12337 +               }
12338 +}
12339 +
12340 +/*
12341 + * MMU_init_hw does the chip-specific initialization of the MMU hardware.
12342 + */
12343 +void __init MMU_init_hw(void)
12344 +{
12345 +       flush_instruction_cache();
12346 +
12347 +       ppc44x_tlb_config();
12348 +}
12349 +
12350 +/* TODO: Add large page lowmem mapping support */
12351 +unsigned long __init mmu_mapin_ram(void)
12352 +{
12353 +       unsigned long v, s, f = _PAGE_GUARDED;
12354 +       phys_addr_t p;
12355 +
12356 +       v = KERNELBASE;
12357 +       p = PPC_MEMSTART;
12358 +
12359 +       for (s = 0; s < total_lowmem; s += PAGE_SIZE) {
12360 +               if ((char *) v >= _stext && (char *) v < etext)
12361 +                       f |= _PAGE_RAM_TEXT;
12362 +               else
12363 +                       f |= _PAGE_RAM;
12364 +               map_page(v, p, f);
12365 +               v += PAGE_SIZE;
12366 +               p += PAGE_SIZE;
12367 +       }
12368 +
12369 +       if (ppc_md.progress)
12370 +               ppc_md.progress("MMU:mmu_mapin_ram done", 0x401);
12371 +
12372 +       return s;
12373 +}
12374 diff -Nru a/arch/ppc/mm/Makefile b/arch/ppc/mm/Makefile
12375 --- a/arch/ppc/mm/Makefile      Sat Jan  4 00:44:11 2003
12376 +++ b/arch/ppc/mm/Makefile      Wed Sep  3 05:16:34 2003
12377 @@ -11,4 +11,5 @@
12378  
12379  obj-$(CONFIG_PPC_STD_MMU)      += hashtable.o ppc_mmu.o tlb.o
12380  obj-$(CONFIG_40x)              += 4xx_mmu.o
12381 +obj-$(CONFIG_44x)              += 44x_mmu.o
12382  obj-$(CONFIG_NOT_COHERENT_CACHE)       += cachemap.o
12383 diff -Nru a/arch/ppc/mm/cachemap.c b/arch/ppc/mm/cachemap.c
12384 --- a/arch/ppc/mm/cachemap.c    Tue May 20 22:22:44 2003
12385 +++ b/arch/ppc/mm/cachemap.c    Wed Sep  3 05:16:34 2003
12386 @@ -48,7 +48,7 @@
12387  #include <asm/smp.h>
12388  #include <asm/machdep.h>
12389  
12390 -int map_page(unsigned long va, unsigned long pa, int flags);
12391 +int map_page(unsigned long va, phys_addr_t pa, int flags);
12392  
12393  /* This function will allocate the requested contiguous pages and
12394   * map them into the kernel's vmalloc() space.  This is done so we
12395 @@ -61,7 +61,8 @@
12396  {
12397         int order, err;
12398         struct page *page, *free, *end;
12399 -       unsigned long pa, flags, offset;
12400 +       phys_addr_t pa;
12401 +       unsigned long flags, offset;
12402         struct vm_struct *area = NULL;
12403         unsigned long va = 0;
12404  
12405 diff -Nru a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
12406 --- a/arch/ppc/mm/init.c        Wed Jun  4 20:48:59 2003
12407 +++ b/arch/ppc/mm/init.c        Wed Sep  3 05:16:34 2003
12408 @@ -6,6 +6,7 @@
12409   *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
12410   *    Copyright (C) 1996 Paul Mackerras
12411   *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
12412 + *  PPC44x/36-bit changes by Matt Porter (mporter@mvista.com)
12413   *
12414   *  Derived from "arch/i386/mm/init.c"
12415   *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
12416 diff -Nru a/arch/ppc/mm/mmu_decl.h b/arch/ppc/mm/mmu_decl.h
12417 --- a/arch/ppc/mm/mmu_decl.h    Sat Jan  4 03:05:41 2003
12418 +++ b/arch/ppc/mm/mmu_decl.h    Wed Sep  3 05:16:34 2003
12419 @@ -20,9 +20,10 @@
12420   *
12421   */
12422  #include <asm/tlbflush.h>
12423 +#include <asm/mmu.h>
12424  
12425  extern void mapin_ram(void);
12426 -extern int map_page(unsigned long va, unsigned long pa, int flags);
12427 +extern int map_page(unsigned long va, phys_addr_t pa, int flags);
12428  extern void setbat(int index, unsigned long virt, unsigned long phys,
12429                    unsigned int size, int flags);
12430  extern void reserve_phys_mem(unsigned long start, unsigned long size);
12431 diff -Nru a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
12432 --- a/arch/ppc/mm/pgtable.c     Thu Jun  5 18:11:52 2003
12433 +++ b/arch/ppc/mm/pgtable.c     Wed Sep  3 05:16:34 2003
12434 @@ -55,11 +55,18 @@
12435  #define p_mapped_by_bats(x)    (0UL)
12436  #endif /* HAVE_BATS */
12437  
12438 +#ifdef CONFIG_44x
12439 +/* 44x uses an 8kB pgdir because it has 8-byte Linux PTEs. */
12440 +#define PGDIR_ORDER    1
12441 +#else
12442 +#define PGDIR_ORDER    0
12443 +#endif
12444 +
12445  pgd_t *pgd_alloc(struct mm_struct *mm)
12446  {
12447         pgd_t *ret;
12448  
12449 -       if ((ret = (pgd_t *)__get_free_page(GFP_KERNEL)) != NULL)
12450 +       if ((ret = (pgd_t *)__get_free_pages(GFP_KERNEL, PGDIR_ORDER)) != NULL)
12451                 clear_page(ret);
12452         return ret;
12453  }
12454 @@ -110,16 +117,33 @@
12455         __free_page(pte);
12456  }
12457  
12458 +#ifndef CONFIG_44x
12459 +void *
12460 +ioremap(phys_addr_t addr, unsigned long size)
12461 +{
12462 +       return __ioremap(addr, size, _PAGE_NO_CACHE);
12463 +}
12464 +#else /* CONFIG_44x */
12465  void *
12466 -ioremap(unsigned long addr, unsigned long size)
12467 +ioremap64(unsigned long long addr, unsigned long size)
12468  {
12469         return __ioremap(addr, size, _PAGE_NO_CACHE);
12470  }
12471  
12472  void *
12473 -__ioremap(unsigned long addr, unsigned long size, unsigned long flags)
12474 +ioremap(phys_addr_t addr, unsigned long size)
12475 +{
12476 +       phys_addr_t addr64 = fixup_bigphys_addr(addr, size);;
12477 +
12478 +       return ioremap64(addr64, size);
12479 +}
12480 +#endif /* CONFIG_44x */
12481 +
12482 +void *
12483 +__ioremap(phys_addr_t addr, unsigned long size, unsigned long flags)
12484  {
12485 -       unsigned long p, v, i;
12486 +       unsigned long v, i;
12487 +       phys_addr_t p;
12488         int err;
12489  
12490         /*
12491 @@ -144,7 +168,7 @@
12492          */
12493         if ( mem_init_done && (p < virt_to_phys(high_memory)) )
12494         {
12495 -               printk("__ioremap(): phys addr %0lx is RAM lr %p\n", p,
12496 +               printk("__ioremap(): phys addr "PTE_FMT" is RAM lr %p\n", p,
12497                        __builtin_return_address(0));
12498                 return NULL;
12499         }
12500 @@ -195,7 +219,7 @@
12501         }
12502  
12503  out:
12504 -       return (void *) (v + (addr & ~PAGE_MASK));
12505 +       return (void *) (v + ((unsigned long)addr & ~PAGE_MASK));
12506  }
12507  
12508  void iounmap(void *addr)
12509 @@ -211,7 +235,7 @@
12510  }
12511  
12512  int
12513 -map_page(unsigned long va, unsigned long pa, int flags)
12514 +map_page(unsigned long va, phys_addr_t pa, int flags)
12515  {
12516         pmd_t *pd;
12517         pte_t *pg;
12518 @@ -261,7 +285,7 @@
12519   * virt, phys, size must all be page-aligned.
12520   * This should only be called before ioremap is called.
12521   */
12522 -void __init io_block_mapping(unsigned long virt, unsigned long phys,
12523 +void __init io_block_mapping(unsigned long virt, phys_addr_t phys,
12524                              unsigned int size, int flags)
12525  {
12526         int i;
12527 diff -Nru a/arch/ppc/ocp/ocp-probe.c b/arch/ppc/ocp/ocp-probe.c
12528 --- a/arch/ppc/ocp/ocp-probe.c  Wed Jan 15 19:45:18 2003
12529 +++ b/arch/ppc/ocp/ocp-probe.c  Wed Sep  3 05:40:20 2003
12530 @@ -62,7 +62,6 @@
12531             (unsigned long) dev->paddr, dev->irq, dev->pm);
12532  
12533         /* now put in global tree */
12534 -       strcpy(dev->dev.name, dev->name);
12535         sprintf(dev->dev.bus_id, "%d", index);
12536         dev->dev.parent = ocp_bus;
12537         dev->dev.bus = &ocp_bus_type;
12538 @@ -80,7 +79,7 @@
12539                 return NULL;
12540         memset(b, 0, sizeof(struct device));
12541         strcpy(b->bus_id, "ocp");
12542 -       strcpy(b->name, "Host/OCP Bridge");
12543 +
12544         device_register(b);
12545  
12546         return b;
12547 diff -Nru a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
12548 --- a/arch/ppc/platforms/4xx/Kconfig    Tue Aug 12 14:57:51 2003
12549 +++ b/arch/ppc/platforms/4xx/Kconfig    Wed Sep  3 05:16:34 2003
12550 @@ -1,6 +1,6 @@
12551  config 4xx
12552         bool
12553 -       depends on 40x
12554 +       depends on 40x || 44x
12555         default y
12556  
12557  menu "IBM 4xx options"
12558 @@ -57,6 +57,23 @@
12559  
12560  endchoice
12561  
12562 +choice
12563 +       prompt "Machine Type"
12564 +       depends on 44x
12565 +       default EBONY
12566 +
12567 +config EBONY
12568 +       bool "Ebony"
12569 +       help
12570 +         This option enables support for the IBM PPC440GP evaluation board.
12571 +
12572 +config OCOTEA
12573 +       bool "Ocotea"
12574 +       help
12575 +         This option enables support for the IBM PPC440GX evaluation board.
12576 +
12577 +endchoice
12578 +
12579  config EP405PC
12580         bool "EP405PC Support"
12581         depends on EP405
12582 @@ -70,6 +87,26 @@
12583         depends on ASH
12584         default y
12585  
12586 +config 440GP
12587 +       bool
12588 +       depends on EBONY
12589 +       default y
12590 +
12591 +config 440GX
12592 +       bool
12593 +       depends on OCOTEA
12594 +       default y
12595 +
12596 +config 440
12597 +       bool
12598 +       depends on 440GP
12599 +       default y
12600 +
12601 +config 440A
12602 +       bool
12603 +       depends on 440GX
12604 +       default y
12605 +
12606  # All 405-based cores up until the 405GPR and 405EP have this errata.
12607  config IBM405_ERR77
12608         bool
12609 @@ -82,9 +119,25 @@
12610         depends on 40x && !405GPR
12611         default y
12612  
12613 +
12614 +config PIN_TLB
12615 +       bool
12616 +       depends on 44x
12617 +       default y
12618 +
12619 +config BOOKE
12620 +       bool
12621 +       depends on 44x
12622 +       default y
12623 +
12624  config IBM_OCP
12625         bool
12626 -       depends on ASH || BEECH || CEDAR || CPCI405 || EP405 || REDWOOD_4 || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
12627 +       depends on ASH || BEECH || CEDAR || CPCI405 || EBONY || EP405 || OCOTEA || REDWOOD_4 || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
12628 +       default y
12629 +
12630 +config IBM_EMAC4
12631 +       bool
12632 +       depends on 440GX
12633         default y
12634  
12635  config NP405L
12636 diff -Nru a/arch/ppc/platforms/4xx/Makefile b/arch/ppc/platforms/4xx/Makefile
12637 --- a/arch/ppc/platforms/4xx/Makefile   Mon Feb  3 14:19:36 2003
12638 +++ b/arch/ppc/platforms/4xx/Makefile   Wed Sep  3 05:16:34 2003
12639 @@ -5,8 +5,10 @@
12640  obj-$(CONFIG_BEECH)            += beech.o 
12641  obj-$(CONFIG_CEDAR)            += cedar.o
12642  obj-$(CONFIG_CPCI405)          += cpci405.o
12643 +obj-$(CONFIG_EBONY)            += ebony.o 
12644  obj-$(CONFIG_EP405)            += ep405.o
12645  obj-$(CONFIG_OAK)              += oak.o
12646 +obj-$(CONFIG_OCOTEA)           += ocotea.o
12647  obj-$(CONFIG_REDWOOD_4)                += redwood.o
12648  obj-$(CONFIG_REDWOOD_5)                += redwood5.o
12649  obj-$(CONFIG_REDWOOD_6)                += redwood6.o 
12650 @@ -21,4 +23,6 @@
12651  obj-$(CONFIG_REDWOOD_6)                += ibmstbx25.o
12652  obj-$(CONFIG_NP4GS3)           += ibmnp4gs.o
12653  obj-$(CONFIG_405LP)            += ibm405lp.o
12654 +obj-$(CONFIG_EBONY)            += ibm440gp.o
12655 +obj-$(CONFIG_OCOTEA)           += ibm440gx.o
12656  obj-$(CONFIG_405GPR)           += ibm405gpr.o
12657 diff -Nru a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c
12658 --- /dev/null   Wed Dec 31 16:00:00 1969
12659 +++ b/arch/ppc/platforms/4xx/ebony.c    Wed Sep  3 02:14:10 2003
12660 @@ -0,0 +1,536 @@
12661 +/*
12662 + * arch/ppc/platforms/ebony.c
12663 + *
12664 + * Ebony board specific routines
12665 + *
12666 + * Matt Porter <mporter@mvista.com>
12667 + *
12668 + * Copyright 2002 MontaVista Software Inc.
12669 + *
12670 + * This program is free software; you can redistribute  it and/or modify it
12671 + * under  the terms of  the GNU General  Public License as published by the
12672 + * Free Software Foundation;  either version 2 of the  License, or (at your
12673 + * option) any later version.
12674 + */
12675 +
12676 +#include <linux/config.h>
12677 +#include <linux/stddef.h>
12678 +#include <linux/kernel.h>
12679 +#include <linux/init.h>
12680 +#include <linux/errno.h>
12681 +#include <linux/reboot.h>
12682 +#include <linux/pci.h>
12683 +#include <linux/kdev_t.h>
12684 +#include <linux/types.h>
12685 +#include <linux/major.h>
12686 +#include <linux/blkdev.h>
12687 +#include <linux/console.h>
12688 +#include <linux/delay.h>
12689 +#include <linux/ide.h>
12690 +#include <linux/initrd.h>
12691 +#include <linux/irq.h>
12692 +#include <linux/seq_file.h>
12693 +#include <linux/root_dev.h>
12694 +#include <linux/tty.h>
12695 +#include <linux/serial.h>
12696 +#include <linux/serial_core.h>
12697 +
12698 +#include <asm/system.h>
12699 +#include <asm/pgtable.h>
12700 +#include <asm/page.h>
12701 +#include <asm/dma.h>
12702 +#include <asm/io.h>
12703 +#include <asm/machdep.h>
12704 +#include <asm/pci-bridge.h>
12705 +#include <asm/time.h>
12706 +#include <asm/todc.h>
12707 +#include <asm/bootinfo.h>
12708 +#include <asm/ppc4xx_pic.h>
12709 +
12710 +/*
12711 + * Ebony IRQ triggering/polarity settings
12712 + */
12713 +static u_char ebony_IRQ_initsenses[] __initdata = {
12714 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 0: UART 0 */
12715 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 1: UART 1 */
12716 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 2: IIC 0 */
12717 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 3: IIC 1 */
12718 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 4: PCI Inb Mess */
12719 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 5: PCI Cmd Wrt */
12720 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 6: PCI PM */
12721 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 7: PCI MSI 0 */
12722 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 8: PCI MSI 1 */
12723 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 9: PCI MSI 2 */
12724 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 10: MAL TX EOB */
12725 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 11: MAL RX EOB */
12726 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 12: DMA Chan 0 */
12727 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 13: DMA Chan 1 */
12728 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 14: DMA Chan 2 */
12729 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 15: DMA Chan 3 */
12730 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 16: Reserved */
12731 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 17: Reserved */
12732 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 18: GPT Timer 0 */
12733 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 19: GPT Timer 1 */
12734 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 20: GPT Timer 2 */
12735 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 21: GPT Timer 3 */
12736 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 22: GPT Timer 4 */
12737 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 23: Ext Int 0 */
12738 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 24: Ext Int 1 */
12739 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 25: Ext Int 2 */
12740 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 26: Ext Int 3 */
12741 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 27: Ext Int 4 */
12742 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_NEGATIVE),      /* 28: Ext Int 5 */
12743 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 29: Ext Int 6 */
12744 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 30: UIC1 NC Int */
12745 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 31: UIC1 Crit Int */
12746 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 32: MAL SERR */
12747 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 33: MAL TXDE */
12748 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 34: MAL RXDE */
12749 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 35: ECC Unc Err */
12750 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 36: ECC Corr Err */
12751 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 37: Ext Bus Ctrl */
12752 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 38: Ext Bus Mstr */
12753 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 39: OPB->PLB */
12754 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 40: PCI MSI 3 */
12755 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 41: PCI MSI 4 */
12756 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 42: PCI MSI 5 */
12757 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 43: PCI MSI 6 */
12758 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 44: PCI MSI 7 */
12759 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 45: PCI MSI 8 */
12760 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 46: PCI MSI 9 */
12761 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 47: PCI MSI 10 */
12762 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),      /* 48: PCI MSI 11 */
12763 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 49: PLB Perf Mon */
12764 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 50: Ext Int 7 */
12765 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 51: Ext Int 8 */
12766 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 52: Ext Int 9 */
12767 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 53: Ext Int 10 */
12768 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 54: Ext Int 11 */
12769 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* 55: Ext Int 12 */
12770 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 56: Ser ROM Err */
12771 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 57: Reserved */
12772 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 58: Reserved */
12773 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 59: PCI Async Err */
12774 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 60: EMAC 0 */
12775 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 61: EMAC 0 WOL */
12776 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 62: EMAC 1 */
12777 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE),      /* 63: EMAC 1 WOL */
12778 +};
12779 +
12780 +extern void abort(void);
12781 +
12782 +/* Global Variables */
12783 +bd_t __res;
12784 +
12785 +static void __init
12786 +ebony_calibrate_decr(void)
12787 +{
12788 +       unsigned int freq;
12789 +
12790 +       /*
12791 +        * Determine system clock speed
12792 +        *
12793 +        * If we are on Rev. B silicon, then use
12794 +        * default external system clock.  If we are
12795 +        * on Rev. C silicon then errata forces us to
12796 +        * use the internal clock.
12797 +        */
12798 +       switch (PVR_REV(mfspr(PVR))) {
12799 +               case PVR_REV(PVR_440GP_RB):
12800 +                       freq = EBONY_440GP_RB_SYSCLK;
12801 +                       break;
12802 +               case PVR_REV(PVR_440GP_RC1):
12803 +               default:
12804 +                       freq = EBONY_440GP_RC_SYSCLK;
12805 +                       break;
12806 +       }
12807 +       
12808 +       tb_ticks_per_jiffy = freq / HZ;
12809 +       tb_to_us = mulhwu_scale_factor(freq, 1000000);
12810 +
12811 +       /* Set the time base to zero */
12812 +       mtspr(SPRN_TBWL, 0);
12813 +       mtspr(SPRN_TBWU, 0);
12814 +
12815 +       /* Clear any pending timer interrupts */
12816 +       mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
12817 +
12818 +       /* Enable decrementer interrupt */
12819 +       mtspr(SPRN_TCR, TCR_DIE);
12820 +}
12821 +
12822 +static int
12823 +ebony_show_cpuinfo(struct seq_file *m)
12824 +{
12825 +       seq_printf(m, "vendor\t\t: IBM\n");
12826 +       seq_printf(m, "machine\t\t: Ebony\n");
12827 +
12828 +       return 0;
12829 +}
12830 +
12831 +static inline int
12832 +ebony_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
12833 +{
12834 +       static char pci_irq_table[][4] =
12835 +       /*
12836 +        *      PCI IDSEL/INTPIN->INTLINE 
12837 +        *         A   B   C   D
12838 +        */
12839 +       {
12840 +               { 23, 23, 23, 23 },     /* IDSEL 1 - PCI Slot 0 */
12841 +               { 24, 24, 24, 24 },     /* IDSEL 2 - PCI Slot 1 */
12842 +               { 25, 25, 25, 25 },     /* IDSEL 3 - PCI Slot 2 */
12843 +               { 26, 26, 26, 26 },     /* IDSEL 4 - PCI Slot 3 */
12844 +       };
12845 +
12846 +       const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
12847 +       return PCI_IRQ_TABLE_LOOKUP;
12848 +}
12849 +
12850 +#define PCIX_WRITEL(value, offset) \
12851 +       (writel(value, (u32)pcix_reg_base+offset))
12852 +
12853 +/*
12854 + * FIXME: This is only here to "make it work".  This will move
12855 + * to a ibm_pcix.c which will contain a generic IBM PCIX bridge
12856 + * configuration library. -Matt
12857 + */
12858 +static void __init
12859 +ebony_setup_pcix(void)
12860 +{
12861 +       void *pcix_reg_base;
12862 +
12863 +       pcix_reg_base = ioremap64(PCIX0_REG_BASE, PCIX0_REG_SIZE);
12864 +
12865 +       /* Disable all windows */
12866 +       PCIX_WRITEL(0, PCIX0_POM0SA);
12867 +       PCIX_WRITEL(0, PCIX0_POM1SA);
12868 +       PCIX_WRITEL(0, PCIX0_POM2SA);
12869 +       PCIX_WRITEL(0, PCIX0_PIM0SA);
12870 +       PCIX_WRITEL(0, PCIX0_PIM1SA);
12871 +       PCIX_WRITEL(0, PCIX0_PIM2SA);
12872 +       
12873 +       /* Setup 2GB PLB->PCI outbound mem window (3_8000_0000->0_8000_0000) */
12874 +       PCIX_WRITEL(0x00000003, PCIX0_POM0LAH);
12875 +       PCIX_WRITEL(0x80000000, PCIX0_POM0LAL);
12876 +       PCIX_WRITEL(0x00000000, PCIX0_POM0PCIAH);
12877 +       PCIX_WRITEL(0x80000000, PCIX0_POM0PCIAL);
12878 +       PCIX_WRITEL(0x80000001, PCIX0_POM0SA);
12879 +
12880 +       /* Setup 2GB PCI->PLB inbound memory window at 0, enable MSIs */
12881 +       PCIX_WRITEL(0x00000000, PCIX0_PIM0LAH);
12882 +       PCIX_WRITEL(0x00000000, PCIX0_PIM0LAL);
12883 +       PCIX_WRITEL(0x80000007, PCIX0_PIM0SA);
12884 +
12885 +       eieio();
12886 +}
12887 +
12888 +static void __init
12889 +ebony_setup_hose(void)
12890 +{
12891 +       struct pci_controller *hose;
12892 +
12893 +       /* Configure windows on the PCI-X host bridge */
12894 +       ebony_setup_pcix();
12895 +
12896 +       hose = pcibios_alloc_controller();
12897 +
12898 +       if (!hose)
12899 +               return;
12900 +
12901 +       hose->first_busno = 0;
12902 +       hose->last_busno = 0xff;
12903 +
12904 +       hose->pci_mem_offset = EBONY_PCI_MEM_OFFSET;
12905 +
12906 +       pci_init_resource(&hose->io_resource,
12907 +                       EBONY_PCI_LOWER_IO,
12908 +                       EBONY_PCI_UPPER_IO,
12909 +                       IORESOURCE_IO,
12910 +                       "PCI host bridge");
12911 +
12912 +       pci_init_resource(&hose->mem_resources[0],
12913 +                       EBONY_PCI_LOWER_MEM,
12914 +                       EBONY_PCI_UPPER_MEM,
12915 +                       IORESOURCE_MEM,
12916 +                       "PCI host bridge");
12917 +
12918 +       hose->io_space.start = EBONY_PCI_LOWER_IO;
12919 +       hose->io_space.end = EBONY_PCI_UPPER_IO;
12920 +       hose->mem_space.start = EBONY_PCI_LOWER_MEM;
12921 +       hose->mem_space.end = EBONY_PCI_UPPER_MEM;
12922 +       isa_io_base =
12923 +               (unsigned long)ioremap64(EBONY_PCI_IO_BASE, EBONY_PCI_IO_SIZE);
12924 +       hose->io_base_virt = (void *)isa_io_base;
12925 +
12926 +       setup_indirect_pci(hose,
12927 +                       EBONY_PCI_CFGA_PLB32,
12928 +                       EBONY_PCI_CFGD_PLB32);
12929 +       hose->set_cfg_type = 1;
12930 +
12931 +       hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
12932 +
12933 +       ppc_md.pci_swizzle = common_swizzle;
12934 +       ppc_md.pci_map_irq = ebony_map_irq;
12935 +}
12936 +
12937 +TODC_ALLOC();
12938 +
12939 +static void __init
12940 +ebony_early_serial_map(void)
12941 +{
12942 +       struct uart_port port;
12943 +
12944 +       /* Setup ioremapped serial port access */
12945 +       memset(&port, 0, sizeof(port));
12946 +       port.membase = ioremap64(PPC440GP_UART0_ADDR, 8);
12947 +       port.irq = 0;
12948 +       port.uartclk = BASE_BAUD * 16;
12949 +       port.regshift = 0;
12950 +       port.iotype = SERIAL_IO_MEM;
12951 +       port.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
12952 +       port.line = 0;
12953 +
12954 +       if (early_serial_setup(&port) != 0) {
12955 +               printk("Early serial init of port 0 failed\n");
12956 +       }
12957 +
12958 +       port.membase = ioremap64(PPC440GP_UART1_ADDR, 8);
12959 +       port.irq = 1;
12960 +       port.line = 1;
12961 +
12962 +       if (early_serial_setup(&port) != 0) {
12963 +               printk("Early serial init of port 1 failed\n");
12964 +       }
12965 +}
12966 +
12967 +static void __init
12968 +ebony_setup_arch(void)
12969 +{
12970 +       unsigned char * vpd_base;
12971 +       struct ibm440gp_clocks clocks;
12972 +
12973 +#if !defined(CONFIG_BDI_SWITCH)
12974 +       /*
12975 +        * The Abatron BDI JTAG debugger does not tolerate others
12976 +        * mucking with the debug registers.
12977 +        */
12978 +        mtspr(SPRN_DBCR0, (DBCR0_TDE | DBCR0_IDM));
12979 +#endif
12980 +
12981 +       /* Retrieve MAC addresses */
12982 +       vpd_base = ioremap64(EBONY_VPD_BASE, EBONY_VPD_SIZE);
12983 +       memcpy(__res.bi_enetaddr[0],EBONY_NA0_ADDR(vpd_base),6);
12984 +       memcpy(__res.bi_enetaddr[1],EBONY_NA1_ADDR(vpd_base),6);
12985 +
12986 +       /*
12987 +        * Determine various clocks.
12988 +        * To be completely correct we should get SysClk
12989 +        * from FPGA, because it can be changed by on-board switches
12990 +        * --ebs
12991 +        */
12992 +       ibm440gp_get_clocks(&clocks, 33333333, 6 * 1843200);
12993 +       __res.bi_opb_busfreq = clocks.opb;
12994 +       
12995 +       /* Use IIC in standard (100 kHz) mode */
12996 +       __res.bi_iic_fast[0] = __res.bi_iic_fast[1] = 0;
12997 +
12998 +       /* Setup TODC access */
12999 +       TODC_INIT(TODC_TYPE_DS1743,
13000 +                       0,
13001 +                       0,
13002 +                       ioremap64(EBONY_RTC_ADDR, EBONY_RTC_SIZE),
13003 +                       8);
13004 +
13005 +       /* init to some ~sane value until calibrate_delay() runs */
13006 +        loops_per_jiffy = 50000000/HZ;
13007 +
13008 +       /* Setup PCI host bridge */
13009 +       ebony_setup_hose();
13010 +
13011 +#ifdef CONFIG_BLK_DEV_INITRD
13012 +       if (initrd_start)
13013 +               ROOT_DEV = Root_RAM0;
13014 +       else
13015 +#endif
13016 +#ifdef CONFIG_ROOT_NFS
13017 +               ROOT_DEV = Root_NFS;
13018 +#else
13019 +               ROOT_DEV = Root_HDA1;
13020 +#endif
13021 +
13022 +#ifdef CONFIG_VT
13023 +       conswitchp = &dummy_con;
13024 +#endif
13025 +
13026 +       ebony_early_serial_map();
13027 +
13028 +       ibm4xxPIC_InitSenses = ebony_IRQ_initsenses;
13029 +       ibm4xxPIC_NumInitSenses = sizeof(ebony_IRQ_initsenses);
13030 +
13031 +       /* Identify the system */
13032 +       printk("IBM Ebony port (MontaVista Software, Inc. (source@mvista.com))\n");
13033 +}
13034 +
13035 +static void
13036 +ebony_restart(char *cmd)
13037 +{
13038 +       local_irq_disable();
13039 +       abort();
13040 +}
13041 +
13042 +static void
13043 +ebony_power_off(void)
13044 +{
13045 +       local_irq_disable();
13046 +       for(;;);
13047 +}
13048 +
13049 +static void
13050 +ebony_halt(void)
13051 +{
13052 +       local_irq_disable();
13053 +       for(;;);
13054 +}
13055 +
13056 +/*
13057 + * Read the 440GP memory controller to get size of system memory.
13058 + */
13059 +static unsigned long __init
13060 +ebony_find_end_of_memory(void)
13061 +{
13062 +       u32 i, bank_config;
13063 +       u32 mem_size = 0;
13064 +
13065 +       for (i=0; i<4; i++)
13066 +       {
13067 +               switch (i)
13068 +               {
13069 +                       case 0:
13070 +                               mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B0CR);
13071 +                               break;
13072 +                       case 1:
13073 +                               mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B1CR);
13074 +                               break;
13075 +                       case 2:
13076 +                               mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B2CR);
13077 +                               break;
13078 +                       case 3:
13079 +                               mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B3CR);
13080 +                               break;
13081 +               }
13082 +
13083 +               bank_config = mfdcr(DCRN_SDRAM0_CFGDATA);
13084 +
13085 +               if (!(bank_config & SDRAM_CONFIG_BANK_ENABLE))
13086 +                       continue;
13087 +               switch (SDRAM_CONFIG_BANK_SIZE(bank_config))
13088 +               {
13089 +                       case SDRAM_CONFIG_SIZE_8M:
13090 +                               mem_size += PPC44x_MEM_SIZE_8M;
13091 +                               break;
13092 +                       case SDRAM_CONFIG_SIZE_16M:
13093 +                               mem_size += PPC44x_MEM_SIZE_16M;
13094 +                               break;
13095 +                       case SDRAM_CONFIG_SIZE_32M:
13096 +                               mem_size += PPC44x_MEM_SIZE_32M;
13097 +                               break;
13098 +                       case SDRAM_CONFIG_SIZE_64M:
13099 +                               mem_size += PPC44x_MEM_SIZE_64M;
13100 +                               break;
13101 +                       case SDRAM_CONFIG_SIZE_128M:
13102 +                               mem_size += PPC44x_MEM_SIZE_128M;
13103 +                               break;
13104 +                       case SDRAM_CONFIG_SIZE_256M:
13105 +                               mem_size += PPC44x_MEM_SIZE_256M;
13106 +                               break;
13107 +                       case SDRAM_CONFIG_SIZE_512M:
13108 +                               mem_size += PPC44x_MEM_SIZE_512M;
13109 +                               break;
13110 +               }
13111 +       }
13112 +       return mem_size;
13113 +}
13114 +
13115 +static void __init
13116 +ebony_init_irq(void)
13117 +{
13118 +       int i;
13119 +
13120 +       ppc4xx_pic_init();
13121 +
13122 +       for (i = 0; i < NR_IRQS; i++)
13123 +               irq_desc[i].handler = ppc4xx_pic;
13124 +}
13125 +
13126 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
13127 +#include <linux/serialP.h>
13128 +#include <linux/serial_reg.h>
13129 +#include <asm/serial.h>
13130 +
13131 +static struct serial_state rs_table[RS_TABLE_SIZE] = {
13132 +       SERIAL_PORT_DFNS        /* Defined in <asm/serial.h> */
13133 +};
13134 +
13135 +static void
13136 +ebony_progress(char *s, unsigned short hex)
13137 +{
13138 +       volatile char c;
13139 +       volatile unsigned long com_port;
13140 +       u16 shift;
13141 +
13142 +       com_port = (unsigned long)rs_table[0].iomem_base;
13143 +       shift = rs_table[0].iomem_reg_shift;
13144 +
13145 +       while ((c = *s++) != 0) {
13146 +               while ((*((volatile unsigned char *)com_port +
13147 +                               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
13148 +                       ;
13149 +               *(volatile unsigned char *)com_port = c;
13150 +
13151 +       }
13152 +
13153 +       /* Send LF/CR to pretty up output */
13154 +       while ((*((volatile unsigned char *)com_port +
13155 +               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
13156 +               ;
13157 +       *(volatile unsigned char *)com_port = '\r';
13158 +       while ((*((volatile unsigned char *)com_port +
13159 +               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
13160 +               ;
13161 +       *(volatile unsigned char *)com_port = '\n';
13162 +}
13163 +#endif /* CONFIG_SERIAL_TEXT_DEBUG */
13164 +
13165 +void __init platform_init(unsigned long r3, unsigned long r4,
13166 +               unsigned long r5, unsigned long r6, unsigned long r7)
13167 +{
13168 +       parse_bootinfo((struct bi_record *) (r3 + KERNELBASE));
13169 +
13170 +       ppc_md.setup_arch = ebony_setup_arch;
13171 +       ppc_md.show_cpuinfo = ebony_show_cpuinfo;
13172 +       ppc_md.init_IRQ = ebony_init_irq;
13173 +       ppc_md.get_irq = NULL;          /* Set in ppc4xx_pic_init() */
13174 +
13175 +       ppc_md.find_end_of_memory = ebony_find_end_of_memory;
13176 +
13177 +       ppc_md.restart = ebony_restart;
13178 +       ppc_md.power_off = ebony_power_off;
13179 +       ppc_md.halt = ebony_halt;
13180 +
13181 +       ppc_md.calibrate_decr = ebony_calibrate_decr;
13182 +       ppc_md.time_init = todc_time_init;
13183 +       ppc_md.set_rtc_time = todc_set_rtc_time;
13184 +       ppc_md.get_rtc_time = todc_get_rtc_time;
13185 +
13186 +       ppc_md.nvram_read_val = todc_direct_read_val;
13187 +       ppc_md.nvram_write_val = todc_direct_write_val;
13188 +
13189 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
13190 +       ppc_md.progress = ebony_progress;
13191 +#endif /* CONFIG_SERIAL_TEXT_DEBUG */
13192 +#ifdef CONFIG_KGDB
13193 +       ppc_md.early_serial_map = ebony_early_serial_map;
13194 +#endif
13195 +}
13196 +
13197 diff -Nru a/arch/ppc/platforms/4xx/ebony.h b/arch/ppc/platforms/4xx/ebony.h
13198 --- /dev/null   Wed Dec 31 16:00:00 1969
13199 +++ b/arch/ppc/platforms/4xx/ebony.h    Wed Sep  3 02:14:11 2003
13200 @@ -0,0 +1,96 @@
13201 +/*
13202 + * arch/ppc/platforms/ebony.h
13203 + *
13204 + * Ebony board definitions
13205 + *
13206 + * Matt Porter <mporter@mvista.com>
13207 + *
13208 + * Copyright 2002 MontaVista Software Inc.
13209 + *
13210 + * This program is free software; you can redistribute  it and/or modify it
13211 + * under  the terms of  the GNU General  Public License as published by the
13212 + * Free Software Foundation;  either version 2 of the  License, or (at your
13213 + * option) any later version.
13214 + */
13215 +
13216 +#ifdef __KERNEL__
13217 +#ifndef __ASM_EBONY_H__
13218 +#define __ASM_EBONY_H__
13219 +
13220 +#include <linux/config.h>
13221 +#include <platforms/4xx/ibm440gp.h>
13222 +
13223 +/* F/W TLB mapping used in bootloader glue to reset EMAC */
13224 +#define PPC44x_EMAC0_MR0       0xE0000800
13225 +
13226 +/* Macros to get at Ebony VPD info */
13227 +#define EBONY_VPD_BASE         0x00000001fffffe00ULL
13228 +#define EBONY_VPD_SIZE         0x24
13229 +#define EBONY_NA0_OFFSET       0x0c
13230 +#define EBONY_NA1_OFFSET       0x18
13231 +#define EBONY_NA0_ADDR(base)   (base + EBONY_NA0_OFFSET)
13232 +#define EBONY_NA1_ADDR(base)   (base + EBONY_NA1_OFFSET)
13233 +
13234 +/* Default clock rates for Rev. B and Rev. C silicon */
13235 +#define EBONY_440GP_RB_SYSCLK  33000000
13236 +#define EBONY_440GP_RC_SYSCLK  400000000
13237 +
13238 +/* RTC/NVRAM location */
13239 +#define EBONY_RTC_ADDR         0x0000000148000000ULL
13240 +#define EBONY_RTC_SIZE         0x2000
13241 +
13242 +/* Flash */
13243 +#define EBONY_FPGA_ADDR                0x0000000148300000
13244 +#define EBONY_BOOT_SMALL_FLASH(x)      (x & 0x20)
13245 +#define EBONY_ONBRD_FLASH_EN(x)                (x & 0x02)
13246 +#define EBONY_FLASH_SEL(x)             (x & 0x01)
13247 +#define EBONY_SMALL_FLASH_LOW1 0x00000001ff800000
13248 +#define EBONY_SMALL_FLASH_LOW2 0x00000001ff880000
13249 +#define EBONY_SMALL_FLASH_HIGH1        0x00000001fff00000
13250 +#define EBONY_SMALL_FLASH_HIGH2        0x00000001fff80000
13251 +#define EBONY_SMALL_FLASH_SIZE 0x80000
13252 +#define EBONY_LARGE_FLASH_LOW  0x00000001ff800000
13253 +#define EBONY_LARGE_FLASH_HIGH 0x00000001ffc00000
13254 +#define EBONY_LARGE_FLASH_SIZE 0x400000
13255 +
13256 +#define EBONY_SMALL_FLASH_BASE 0x00000001fff80000
13257 +#define EBONY_LARGE_FLASH_BASE 0x00000001ff800000
13258 +
13259 +/*
13260 + * Serial port defines
13261 + */
13262 +
13263 +/* OpenBIOS defined UART mappings, used before early_serial_setup */
13264 +#define UART0_IO_BASE  (u8 *) 0xE0000200
13265 +#define UART1_IO_BASE  (u8 *) 0xE0000300
13266 +
13267 +#define BASE_BAUD      33000000/3/16
13268 +#define UART0_INT      0
13269 +#define UART1_INT      1
13270 +
13271 +#define STD_UART_OP(num)                                       \
13272 +       { 0, BASE_BAUD, 0, UART##num##_INT,                     \
13273 +               (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST),        \
13274 +               iomem_base: UART##num##_IO_BASE,                \
13275 +               io_type: SERIAL_IO_MEM},
13276 +
13277 +#define SERIAL_PORT_DFNS       \
13278 +       STD_UART_OP(0)          \
13279 +       STD_UART_OP(1)
13280 +
13281 +/* PCI support */
13282 +#define EBONY_PCI_LOWER_IO     0x00000000
13283 +#define EBONY_PCI_UPPER_IO     0x0000ffff
13284 +#define EBONY_PCI_LOWER_MEM    0x80002000
13285 +#define EBONY_PCI_UPPER_MEM    0xffffefff
13286 +
13287 +#define EBONY_PCI_CFGREGS_BASE 0x000000020ec00000
13288 +#define EBONY_PCI_CFGA_PLB32   0x0ec00000
13289 +#define EBONY_PCI_CFGD_PLB32   0x0ec00004
13290 +
13291 +#define EBONY_PCI_IO_BASE      0x0000000208000000ULL
13292 +#define EBONY_PCI_IO_SIZE      0x00010000
13293 +#define EBONY_PCI_MEM_OFFSET   0x00000000
13294 +
13295 +#endif                         /* __ASM_EBONY_H__ */
13296 +#endif                         /* __KERNEL__ */
13297 diff -Nru a/arch/ppc/platforms/4xx/ibm440gp.c b/arch/ppc/platforms/4xx/ibm440gp.c
13298 --- /dev/null   Wed Dec 31 16:00:00 1969
13299 +++ b/arch/ppc/platforms/4xx/ibm440gp.c Wed Sep  3 02:14:28 2003
13300 @@ -0,0 +1,31 @@
13301 +/*
13302 + * arch/ppc/platforms/4xx/ibm440gp.c
13303 + *
13304 + * PPC440GP I/O descriptions
13305 + *
13306 + * Matt Porter <mporter@mvista.com>
13307 + *
13308 + * Copyright 2002 MontaVista Software Inc.
13309 + *
13310 + * This program is free software; you can redistribute  it and/or modify it
13311 + * under  the terms of  the GNU General  Public License as published by the
13312 + * Free Software Foundation;  either version 2 of the  License, or (at your
13313 + * option) any later version.
13314 + *
13315 + */
13316 +#include <platforms/4xx/ibm440gp.h>
13317 +#include <asm/ocp.h>
13318 +#include <linux/init.h>
13319 +
13320 +struct ocp_def core_ocp[] __initdata = {
13321 +       {OCP_VENDOR_IBM, OCP_FUNC_OPB, PPC440GP_OPB_BASE_START, OCP_IRQ_NA, OCP_CPM_NA},
13322 +       {OCP_VENDOR_IBM, OCP_FUNC_16550, PPC440GP_UART0_ADDR, UART0_INT, IBM_CPM_UART0},
13323 +       {OCP_VENDOR_IBM, OCP_FUNC_16550, PPC440GP_UART1_ADDR, UART1_INT, IBM_CPM_UART1},
13324 +       {OCP_VENDOR_IBM, OCP_FUNC_IIC, PPC440GP_IIC0_ADDR, IIC0_IRQ, IBM_CPM_IIC0},
13325 +       {OCP_VENDOR_IBM, OCP_FUNC_IIC, PPC440GP_IIC1_ADDR, IIC1_IRQ, IBM_CPM_IIC1},
13326 +       {OCP_VENDOR_IBM, OCP_FUNC_GPIO, PPC440GP_GPIO0_ADDR, OCP_IRQ_NA, IBM_CPM_GPIO0},
13327 +       {OCP_VENDOR_IBM, OCP_FUNC_EMAC, PPC440GP_EMAC0_ADDR, BL_MAC_ETH0, OCP_CPM_NA},
13328 +       {OCP_VENDOR_IBM, OCP_FUNC_EMAC, PPC440GP_EMAC1_ADDR, BL_MAC_ETH1, OCP_CPM_NA},
13329 +       {OCP_VENDOR_IBM, OCP_FUNC_ZMII, PPC440GP_ZMII_ADDR, OCP_IRQ_NA, OCP_CPM_NA},
13330 +       {OCP_VENDOR_INVALID, OCP_FUNC_INVALID, 0x0, OCP_IRQ_NA, OCP_CPM_NA},
13331 +};
13332 diff -Nru a/arch/ppc/platforms/4xx/ibm440gp.h b/arch/ppc/platforms/4xx/ibm440gp.h
13333 --- /dev/null   Wed Dec 31 16:00:00 1969
13334 +++ b/arch/ppc/platforms/4xx/ibm440gp.h Wed Sep  3 02:14:29 2003
13335 @@ -0,0 +1,102 @@
13336 +/*
13337 + * arch/ppc/platforms/4xx/ibm440gp.h
13338 + *
13339 + * PPC440GP definitions
13340 + *
13341 + * Roland Dreier <roland@digitalvampire.org>
13342 + *
13343 + * Copyright 2002 Roland Dreier
13344 + *
13345 + * This program is free software; you can redistribute  it and/or modify it
13346 + * under  the terms of  the GNU General  Public License as published by the
13347 + * Free Software Foundation;  either version 2 of the  License, or (at your
13348 + * option) any later version.
13349 + *
13350 + * This file contains code that was originally in the files ibm44x.h
13351 + * and ebony.h, which were written by Matt Porter of MontaVista Software Inc.
13352 + */
13353 +
13354 +#ifdef __KERNEL__
13355 +#ifndef __PPC_PLATFORMS_IBM440GP_H
13356 +#define __PPC_PLATFORMS_IBM440GP_H
13357 +
13358 +#include <linux/config.h>
13359 +
13360 +#define EMAC_NUMS              2
13361 +#define UART_NUMS              2
13362 +#define ZMII_NUMS              1
13363 +#define IIC_NUMS               2
13364 +#define IIC0_IRQ               2
13365 +#define IIC1_IRQ               3
13366 +#define GPIO_NUMS              1
13367 +
13368 +/* UART location */
13369 +#define PPC440GP_UART0_ADDR    0x0000000140000200ULL
13370 +#define PPC440GP_UART1_ADDR    0x0000000140000300ULL
13371 +
13372 +/* EMAC location */
13373 +#define PPC440GP_EMAC0_ADDR    0x0000000140000800ULL
13374 +#define PPC440GP_EMAC1_ADDR    0x0000000140000900ULL
13375 +#define PPC440GP_EMAC_SIZE     0x70
13376 +
13377 +/* EMAC IRQ's */
13378 +#define BL_MAC_WOL     61      /* WOL */
13379 +#define BL_MAC_WOL1    63      /* WOL */
13380 +#define BL_MAL_SERR    32      /* MAL SERR */
13381 +#define BL_MAL_TXDE    33      /* MAL TXDE */
13382 +#define BL_MAL_RXDE    34      /* MAL RXDE */
13383 +#define BL_MAL_TXEOB   10      /* MAL TX EOB */
13384 +#define BL_MAL_RXEOB   11      /* MAL RX EOB */
13385 +#define BL_MAC_ETH0    60      /* MAC */
13386 +#define BL_MAC_ETH1    62      /* MAC */
13387 +
13388 +/* ZMII location */
13389 +#define PPC440GP_ZMII_ADDR     0x0000000140000780ULL
13390 +#define PPC440GP_ZMII_SIZE     0x0c
13391 +
13392 +/* I2C location */
13393 +#define PPC440GP_IIC0_ADDR     0x40000400
13394 +#define PPC440GP_IIC1_ADDR     0x40000500
13395 +
13396 +/* GPIO location */
13397 +#define PPC440GP_GPIO0_ADDR    0x0000000140000700ULL
13398 +
13399 +/* Clock and Power Management */
13400 +#define IBM_CPM_IIC0           0x80000000      /* IIC interface */
13401 +#define IBM_CPM_IIC1           0x40000000      /* IIC interface */
13402 +#define IBM_CPM_PCI            0x20000000      /* PCI bridge */
13403 +#define IBM_CPM_CPU            0x02000000      /* processor core */
13404 +#define IBM_CPM_DMA            0x01000000      /* DMA controller */
13405 +#define IBM_CPM_BGO            0x00800000      /* PLB to OPB bus arbiter */
13406 +#define IBM_CPM_BGI            0x00400000      /* OPB to PLB bridge */
13407 +#define IBM_CPM_EBC            0x00200000      /* External Bux Controller */
13408 +#define IBM_CPM_EBM            0x00100000      /* Ext Bus Master Interface */
13409 +#define IBM_CPM_DMC            0x00080000      /* SDRAM peripheral controller */
13410 +#define IBM_CPM_PLB            0x00040000      /* PLB bus arbiter */
13411 +#define IBM_CPM_SRAM           0x00020000      /* SRAM memory controller */
13412 +#define IBM_CPM_PPM            0x00002000      /* PLB Performance Monitor */
13413 +#define IBM_CPM_UIC1           0x00001000      /* Universal Interrupt Controller */
13414 +#define IBM_CPM_GPIO0          0x00000800      /* General Purpose IO (??) */
13415 +#define IBM_CPM_GPT            0x00000400      /* General Purpose Timers  */
13416 +#define IBM_CPM_UART0          0x00000200      /* serial port 0 */
13417 +#define IBM_CPM_UART1          0x00000100      /* serial port 1 */
13418 +#define IBM_CPM_UIC0           0x00000080      /* Universal Interrupt Controller */
13419 +#define IBM_CPM_TMRCLK         0x00000040      /* CPU timers */
13420 +
13421 +#define DFLT_IBM4xx_PM         ~(IBM_CPM_UIC | IBM_CPM_UIC1 | IBM_CPM_CPU \
13422 +                               | IBM_CPM_EBC | IBM_CPM_SRAM | IBM_CPM_BGO \
13423 +                               | IBM_CPM_EBM | IBM_CPM_PLB | IBM_CPM_OPB \
13424 +                               | IBM_CPM_TMRCLK | IBM_CPM_DMA | IBM_CPM_PCI)
13425 +
13426 +#define PPC440GP_OPB_BASE_START        0x0000000140000000ULL
13427 +
13428 +/*
13429 + * Serial port defines
13430 + */
13431 +#define RS_TABLE_SIZE  2
13432 +
13433 +#include <asm/ibm44x.h>
13434 +#include <syslib/ibm440gp_common.h>
13435 +
13436 +#endif /* __PPC_PLATFORMS_IBM440GP_H */
13437 +#endif /* __KERNEL__ */
13438 diff -Nru a/arch/ppc/platforms/4xx/ibm440gx.c b/arch/ppc/platforms/4xx/ibm440gx.c
13439 --- /dev/null   Wed Dec 31 16:00:00 1969
13440 +++ b/arch/ppc/platforms/4xx/ibm440gx.c Wed Sep  3 02:14:29 2003
13441 @@ -0,0 +1,37 @@
13442 +/*
13443 + * arch/ppc/platforms/ibm440gx.c
13444 + *
13445 + * PPC440GX I/O descriptions
13446 + *
13447 + * Matt Porter <mporter@mvista.com>
13448 + *
13449 + * Copyright 2002-2003 MontaVista Software Inc.
13450 + *
13451 + * This program is free software; you can redistribute  it and/or modify it
13452 + * under  the terms of  the GNU General  Public License as published by the
13453 + * Free Software Foundation;  either version 2 of the  License, or (at your
13454 + * option) any later version.
13455 + *
13456 + */
13457 +
13458 +#include <linux/config.h>
13459 +#include <linux/init.h>
13460 +#include <linux/smp.h>
13461 +#include <linux/threads.h>
13462 +#include <linux/param.h>
13463 +#include <linux/string.h>
13464 +#include <asm/ocp.h>
13465 +#include <platforms/4xx/ibm440gx.h>
13466 +
13467 +struct ocp_def core_ocp[] __initdata = {
13468 +       {OCP_VENDOR_IBM, OCP_FUNC_OPB, PPC440GX_OPB_BASE_START, OCP_IRQ_NA, OCP_CPM_NA},
13469 +       {OCP_VENDOR_IBM, OCP_FUNC_16550, PPC440GX_UART0_ADDR, UART0_IRQ, IBM_CPM_UART0},
13470 +       {OCP_VENDOR_IBM, OCP_FUNC_16550, PPC440GX_UART1_ADDR, UART1_IRQ, IBM_CPM_UART1},
13471 +       {OCP_VENDOR_IBM, OCP_FUNC_IIC, PPC440GX_IIC0_ADDR, IIC0_IRQ, IBM_CPM_IIC0},
13472 +       {OCP_VENDOR_IBM, OCP_FUNC_IIC, PPC440GX_IIC1_ADDR, IIC1_IRQ, IBM_CPM_IIC1},
13473 +       {OCP_VENDOR_IBM, OCP_FUNC_GPIO, PPC440GX_GPIO0_ADDR, OCP_IRQ_NA, IBM_CPM_GPIO0},
13474 +       {OCP_VENDOR_IBM, OCP_FUNC_EMAC, PPC440GX_EMAC0_ADDR, BL_MAC_ETH0, OCP_CPM_NA},
13475 +       {OCP_VENDOR_IBM, OCP_FUNC_EMAC, PPC440GX_EMAC1_ADDR, BL_MAC_ETH1, OCP_CPM_NA},
13476 +       {OCP_VENDOR_IBM, OCP_FUNC_ZMII, PPC440GX_ZMII_ADDR, OCP_IRQ_NA, OCP_CPM_NA},
13477 +       {OCP_VENDOR_INVALID, OCP_FUNC_INVALID, 0x0, OCP_IRQ_NA, OCP_CPM_NA},
13478 +};
13479 diff -Nru a/arch/ppc/platforms/4xx/ibm440gx.h b/arch/ppc/platforms/4xx/ibm440gx.h
13480 --- /dev/null   Wed Dec 31 16:00:00 1969
13481 +++ b/arch/ppc/platforms/4xx/ibm440gx.h Wed Sep  3 05:16:34 2003
13482 @@ -0,0 +1,123 @@
13483 +/*
13484 + * arch/ppc/platforms/ibm440gx.h
13485 + *
13486 + * PPC440GX definitions
13487 + *
13488 + * Matt Porter <mporter@mvista.com>
13489 + *
13490 + * Copyright 2002 Roland Dreier
13491 + * Copyright 2003 MontaVista Software, Inc.
13492 + *
13493 + * This program is free software; you can redistribute  it and/or modify it
13494 + * under  the terms of  the GNU General  Public License as published by the
13495 + * Free Software Foundation;  either version 2 of the  License, or (at your
13496 + * option) any later version.
13497 + * 
13498 + */
13499 +
13500 +#ifdef __KERNEL__
13501 +#ifndef __PPC_PLATFORMS_IBM440GX_H
13502 +#define __PPC_PLATFORMS_IBM440GX_H
13503 +
13504 +#include <linux/config.h>
13505 +
13506 +#include <asm/ibm44x.h>
13507 +
13508 +/* UART */
13509 +#define PPC440GX_UART0_ADDR    0x0000000140000200ULL
13510 +#define PPC440GX_UART1_ADDR    0x0000000140000300ULL
13511 +#define UART0_IRQ              0
13512 +#define UART1_IRQ              1
13513 +
13514 +/* EMAC */
13515 +#define PPC440GX_EMAC0_ADDR    0x0000000140000800ULL
13516 +#define PPC440GX_EMAC1_ADDR    0x0000000140000900ULL
13517 +#define PPC440GX_EMAC2_ADDR    0x0000000140000C00ULL
13518 +#define PPC440GX_EMAC3_ADDR    0x0000000140000E00ULL
13519 +#define PPC440GX_EMAC_SIZE     0xFC
13520 +#define EMAC_NUMS               2
13521 +#define BL_MAC_WOL     61      /* WOL */
13522 +#define BL_MAC_WOL1    63      /* WOL */
13523 +#define BL_MAC_WOL2    65      /* WOL */
13524 +#define BL_MAC_WOL3    67      /* WOL */
13525 +#define BL_MAL_SERR    32      /* MAL SERR */
13526 +#define BL_MAL_TXDE    33      /* MAL TXDE */
13527 +#define BL_MAL_RXDE    34      /* MAL RXDE */
13528 +#define BL_MAL_TXEOB   10      /* MAL TX EOB */
13529 +#define BL_MAL_RXEOB   11      /* MAL RX EOB */
13530 +#define BL_MAC_ETH0    60      /* MAC */
13531 +#define BL_MAC_ETH1    62      /* MAC */
13532 +#define BL_MAC_ETH2    64      /* MAC */
13533 +#define BL_MAC_ETH3    66      /* MAC */
13534 +#define BL_TAH0                68      /* TAH 0 */
13535 +#define BL_TAH1                69      /* TAH 1 */
13536 +
13537 +/* TAH */
13538 +#define PPC440GX_TAH0_ADDR     0x0000000140000B00ULL
13539 +#define PPC440GX_TAH1_ADDR     0x0000000140000D00ULL
13540 +#define PPC440GX_TAH_SIZE      0xFC
13541 +
13542 +/* ZMII */
13543 +#define PPC440GX_ZMII_ADDR     0x0000000140000780ULL
13544 +#define PPC440GX_ZMII_SIZE     0x0c
13545 +
13546 +/* RGMII */
13547 +#define PPC440GX_RGMII_ADDR    0x0000000140000790ULL
13548 +#define PPC440GX_RGMII_SIZE    0x0c
13549 +
13550 +/* IIC  */
13551 +#define PPC440GX_IIC0_ADDR     0x40000400
13552 +#define PPC440GX_IIC1_ADDR     0x40000500
13553 +#define IIC0_IRQ               2
13554 +#define IIC1_IRQ               3
13555 +
13556 +/* GPIO */
13557 +#define PPC440GX_GPIO0_ADDR    0x0000000140000700ULL
13558 +
13559 +/* Clock and Power Management */
13560 +#define IBM_CPM_IIC0           0x80000000      /* IIC interface */
13561 +#define IBM_CPM_IIC1           0x40000000      /* IIC interface */
13562 +#define IBM_CPM_PCI            0x20000000      /* PCI bridge */
13563 +#define IBM_CPM_RGMII          0x10000000      /* RGMII */
13564 +#define IBM_CPM_TAHOE0         0x08000000      /* TAHOE 0 */
13565 +#define IBM_CPM_TAHOE1         0x04000000      /* TAHOE 1 */
13566 +#define IBM_CPM_CPU                0x02000000  /* processor core */
13567 +#define IBM_CPM_DMA                0x01000000  /* DMA controller */
13568 +#define IBM_CPM_BGO                0x00800000  /* PLB to OPB bus arbiter */
13569 +#define IBM_CPM_BGI                0x00400000  /* OPB to PLB bridge */
13570 +#define IBM_CPM_EBC                0x00200000  /* External Bux Controller */
13571 +#define IBM_CPM_EBM                0x00100000  /* Ext Bus Master Interface */
13572 +#define IBM_CPM_DMC                0x00080000  /* SDRAM peripheral controller */
13573 +#define IBM_CPM_PLB                0x00040000  /* PLB bus arbiter */
13574 +#define IBM_CPM_SRAM           0x00020000      /* SRAM memory controller */
13575 +#define IBM_CPM_PPM                0x00002000  /* PLB Performance Monitor */
13576 +#define IBM_CPM_UIC1           0x00001000      /* Universal Interrupt Controller */
13577 +#define IBM_CPM_GPIO0          0x00000800      /* General Purpose IO (??) */
13578 +#define IBM_CPM_GPT                0x00000400  /* General Purpose Timers  */
13579 +#define IBM_CPM_UART0          0x00000200      /* serial port 0 */
13580 +#define IBM_CPM_UART1          0x00000100      /* serial port 1 */
13581 +#define IBM_CPM_UIC0           0x00000080      /* Universal Interrupt Controller */
13582 +#define IBM_CPM_TMRCLK         0x00000040      /* CPU timers */
13583 +#define IBM_CPM_EMAC0                  0x00000020      /* EMAC 0     */
13584 +#define IBM_CPM_EMAC1                  0x00000010      /* EMAC 1     */
13585 +#define IBM_CPM_EMAC2                  0x00000008      /* EMAC 2     */
13586 +#define IBM_CPM_EMAC3                  0x00000004      /* EMAC 3     */
13587 +
13588 +#define DFLT_IBM4xx_PM         ~(IBM_CPM_UIC | IBM_CPM_UIC1 | IBM_CPM_CPU \
13589 +                               | IBM_CPM_EBC | IBM_CPM_SRAM | IBM_CPM_BGO \
13590 +                               | IBM_CPM_EBM | IBM_CPM_PLB | IBM_CPM_OPB \
13591 +                               | IBM_CPM_TMRCLK | IBM_CPM_DMA | IBM_CPM_PCI \
13592 +                               | IBM_CPM_TAHOE0 | IBM_CPM_TAHOE1 \
13593 +                               | IBM_CPM_EMAC0 | IBM_CPM_EMAC1 \
13594 +                               | IBM_CPM_EMAC2 | IBM_CPM_EMAC3 )       
13595 +
13596 +/* OPB */
13597 +#define PPC440GX_OPB_BASE_START        0x0000000140000000ULL
13598 +
13599 +/*
13600 + * Serial port defines
13601 + */
13602 +#define RS_TABLE_SIZE  2
13603 +
13604 +#endif /* __PPC_PLATFORMS_IBM440GX_H */
13605 +#endif /* __KERNEL__ */
13606 diff -Nru a/arch/ppc/platforms/4xx/ocotea.c b/arch/ppc/platforms/4xx/ocotea.c
13607 --- /dev/null   Wed Dec 31 16:00:00 1969
13608 +++ b/arch/ppc/platforms/4xx/ocotea.c   Wed Sep  3 02:14:47 2003
13609 @@ -0,0 +1,459 @@
13610 +/*
13611 + * arch/ppc/platforms/ocotea.c
13612 + *
13613 + * Ocotea board specific routines
13614 + *
13615 + * Matt Porter <mporter@mvista.com>
13616 + *
13617 + * Copyright 2003 MontaVista Software Inc.
13618 + *
13619 + * This program is free software; you can redistribute  it and/or modify it
13620 + * under  the terms of  the GNU General  Public License as published by the
13621 + * Free Software Foundation;  either version 2 of the  License, or (at your
13622 + * option) any later version.
13623 + */
13624 +
13625 +#include <linux/config.h>
13626 +#include <linux/stddef.h>
13627 +#include <linux/kernel.h>
13628 +#include <linux/init.h>
13629 +#include <linux/errno.h>
13630 +#include <linux/reboot.h>
13631 +#include <linux/pci.h>
13632 +#include <linux/kdev_t.h>
13633 +#include <linux/types.h>
13634 +#include <linux/major.h>
13635 +#include <linux/blkdev.h>
13636 +#include <linux/console.h>
13637 +#include <linux/delay.h>
13638 +#include <linux/ide.h>
13639 +#include <linux/initrd.h>
13640 +#include <linux/irq.h>
13641 +#include <linux/seq_file.h>
13642 +#include <linux/root_dev.h>
13643 +#include <linux/tty.h>
13644 +#include <linux/serial.h>
13645 +#include <linux/serial_core.h>
13646 +
13647 +#include <asm/system.h>
13648 +#include <asm/pgtable.h>
13649 +#include <asm/page.h>
13650 +#include <asm/dma.h>
13651 +#include <asm/io.h>
13652 +#include <asm/machdep.h>
13653 +#include <asm/pci-bridge.h>
13654 +#include <asm/time.h>
13655 +#include <asm/todc.h>
13656 +#include <asm/bootinfo.h>
13657 +#include <asm/ppc4xx_pic.h>
13658 +
13659 +extern void abort(void);
13660 +
13661 +/* Global Variables */
13662 +bd_t __res;
13663 +
13664 +static void __init
13665 +ocotea_calibrate_decr(void)
13666 +{
13667 +       unsigned int freq;
13668 +
13669 +       freq = OCOTEA_SYSCLK;
13670 +       
13671 +       tb_ticks_per_jiffy = freq / HZ;
13672 +       tb_to_us = mulhwu_scale_factor(freq, 1000000);
13673 +
13674 +       /* Set the time base to zero */
13675 +       mtspr(SPRN_TBWL, 0);
13676 +       mtspr(SPRN_TBWU, 0);
13677 +
13678 +       /* Clear any pending timer interrupts */
13679 +       mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
13680 +
13681 +       /* Enable decrementer interrupt */
13682 +       mtspr(SPRN_TCR, TCR_DIE);
13683 +}
13684 +
13685 +static int
13686 +ocotea_show_cpuinfo(struct seq_file *m)
13687 +{
13688 +       seq_printf(m, "vendor\t\t: IBM\n");
13689 +       seq_printf(m, "machine\t\t: PPC440GX EVB (Ocotea)\n");
13690 +
13691 +       return 0;
13692 +}
13693 +static inline int
13694 +ocotea_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
13695 +{
13696 +       static char pci_irq_table[][4] =
13697 +       /*
13698 +        *      PCI IDSEL/INTPIN->INTLINE 
13699 +        *         A   B   C   D
13700 +        */
13701 +       {
13702 +               { 23, 23, 23, 23 },     /* IDSEL 1 - PCI Slot 0 */
13703 +               { 24, 24, 24, 24 },     /* IDSEL 2 - PCI Slot 1 */
13704 +               { 25, 25, 25, 25 },     /* IDSEL 3 - PCI Slot 2 */
13705 +               { 26, 26, 26, 26 },     /* IDSEL 4 - PCI Slot 3 */
13706 +       };
13707 +
13708 +       const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
13709 +       return PCI_IRQ_TABLE_LOOKUP;
13710 +}
13711 +
13712 +#define PCIX_READW(offset) \
13713 +       (readw((u32)pcix_reg_base+offset))
13714 +
13715 +#define PCIX_WRITEW(value, offset) \
13716 +       (writew(value, (u32)pcix_reg_base+offset))
13717 +
13718 +#define PCIX_WRITEL(value, offset) \
13719 +       (writel(value, (u32)pcix_reg_base+offset))
13720 +
13721 +/*
13722 + * FIXME: This is only here to "make it work".  This will move
13723 + * to a ibm_pcix.c which will contain a generic IBM PCIX bridge
13724 + * configuration library. -Matt
13725 + */
13726 +static void __init
13727 +ocotea_setup_pcix(void)
13728 +{
13729 +       void *pcix_reg_base;
13730 +
13731 +       pcix_reg_base = ioremap64(PCIX0_REG_BASE, PCIX0_REG_SIZE);
13732 +
13733 +       /* Enable PCIX0 I/O, Mem, and Busmaster cycles */
13734 +       PCIX_WRITEW(PCIX_READW(PCIX0_COMMAND) | PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER, PCIX0_COMMAND);
13735 +
13736 +       /* Disable all windows */
13737 +       PCIX_WRITEL(0, PCIX0_POM0SA);
13738 +       PCIX_WRITEL(0, PCIX0_POM1SA);
13739 +       PCIX_WRITEL(0, PCIX0_POM2SA);
13740 +       PCIX_WRITEL(0, PCIX0_PIM0SA);
13741 +       PCIX_WRITEL(0, PCIX0_PIM0SAH);
13742 +       PCIX_WRITEL(0, PCIX0_PIM1SA);
13743 +       PCIX_WRITEL(0, PCIX0_PIM2SA);
13744 +       PCIX_WRITEL(0, PCIX0_PIM2SAH);
13745 +       
13746 +       /* Setup 2GB PLB->PCI outbound mem window (3_8000_0000->0_8000_0000) */
13747 +       PCIX_WRITEL(0x00000003, PCIX0_POM0LAH);
13748 +       PCIX_WRITEL(0x80000000, PCIX0_POM0LAL);
13749 +       PCIX_WRITEL(0x00000000, PCIX0_POM0PCIAH);
13750 +       PCIX_WRITEL(0x80000000, PCIX0_POM0PCIAL);
13751 +       PCIX_WRITEL(0x80000001, PCIX0_POM0SA);
13752 +
13753 +       /* Setup 2GB PCI->PLB inbound memory window at 0, enable MSIs */
13754 +       PCIX_WRITEL(0x00000000, PCIX0_PIM0LAH);
13755 +       PCIX_WRITEL(0x00000000, PCIX0_PIM0LAL);
13756 +       PCIX_WRITEL(0xe0000007, PCIX0_PIM0SA);
13757 +
13758 +       eieio();
13759 +}
13760 +
13761 +static void __init
13762 +ocotea_setup_hose(void)
13763 +{
13764 +       struct pci_controller *hose;
13765 +
13766 +       /* Configure windows on the PCI-X host bridge */
13767 +       ocotea_setup_pcix();
13768 +
13769 +       hose = pcibios_alloc_controller();
13770 +
13771 +       if (!hose)
13772 +               return;
13773 +
13774 +       hose->first_busno = 0;
13775 +       hose->last_busno = 0xff;
13776 +
13777 +       hose->pci_mem_offset = OCOTEA_PCI_MEM_OFFSET;
13778 +
13779 +       pci_init_resource(&hose->io_resource,
13780 +                       OCOTEA_PCI_LOWER_IO,
13781 +                       OCOTEA_PCI_UPPER_IO,
13782 +                       IORESOURCE_IO,
13783 +                       "PCI host bridge");
13784 +
13785 +       pci_init_resource(&hose->mem_resources[0],
13786 +                       OCOTEA_PCI_LOWER_MEM,
13787 +                       OCOTEA_PCI_UPPER_MEM,
13788 +                       IORESOURCE_MEM,
13789 +                       "PCI host bridge");
13790 +
13791 +       hose->io_space.start = OCOTEA_PCI_LOWER_IO;
13792 +       hose->io_space.end = OCOTEA_PCI_UPPER_IO;
13793 +       hose->mem_space.start = OCOTEA_PCI_LOWER_MEM;
13794 +       hose->mem_space.end = OCOTEA_PCI_UPPER_MEM;
13795 +       isa_io_base =
13796 +               (unsigned long)ioremap64(OCOTEA_PCI_IO_BASE, OCOTEA_PCI_IO_SIZE);
13797 +       hose->io_base_virt = (void *)isa_io_base;
13798 +
13799 +       setup_indirect_pci(hose,
13800 +                       OCOTEA_PCI_CFGA_PLB32,
13801 +                       OCOTEA_PCI_CFGD_PLB32);
13802 +       hose->set_cfg_type = 1;
13803 +
13804 +       hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
13805 +
13806 +       ppc_md.pci_swizzle = common_swizzle;
13807 +       ppc_md.pci_map_irq = ocotea_map_irq;
13808 +}
13809 +
13810 +
13811 +TODC_ALLOC();
13812 +
13813 +static void __init
13814 +ocotea_early_serial_map(void)
13815 +{
13816 +       struct uart_port port;
13817 +
13818 +       /* Setup ioremapped serial port access */
13819 +       memset(&port, 0, sizeof(port));
13820 +       port.membase = ioremap64(PPC440GX_UART0_ADDR, 8);
13821 +       port.irq = 0;
13822 +       port.uartclk = BASE_BAUD * 16;
13823 +       port.regshift = 0;
13824 +       port.iotype = SERIAL_IO_MEM;
13825 +       port.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
13826 +       port.line = 0;
13827 +
13828 +       if (early_serial_setup(&port) != 0) {
13829 +               printk("Early serial init of port 0 failed\n");
13830 +       }
13831 +
13832 +       port.membase = ioremap64(PPC440GX_UART1_ADDR, 8);
13833 +       port.irq = 1;
13834 +       port.line = 1;
13835 +
13836 +       if (early_serial_setup(&port) != 0) {
13837 +               printk("Early serial init of port 1 failed\n");
13838 +       }
13839 +}
13840 +
13841 +static void __init
13842 +ocotea_setup_arch(void)
13843 +{
13844 +       unsigned char *addr;
13845 +       unsigned long long mac64;
13846 +
13847 +       /* Retrieve MAC addresses from flash */
13848 +       addr = ioremap64(OCOTEA_MAC_BASE, OCOTEA_MAC_SIZE);
13849 +       mac64 = simple_strtoull(addr, 0, 16);
13850 +       memcpy(__res.bi_enetaddr[0], (char *)&mac64+2, 6);
13851 +       mac64 = simple_strtoull(addr+OCOTEA_MAC1_OFFSET, 0, 16);
13852 +       memcpy(__res.bi_enetaddr[1], (char *)&mac64+2, 6);
13853 +       iounmap(addr);
13854 +
13855 +#if !defined(CONFIG_BDI_SWITCH)
13856 +       /*
13857 +        * The Abatron BDI JTAG debugger does not tolerate others
13858 +        * mucking with the debug registers.
13859 +        */
13860 +        mtspr(SPRN_DBCR0, (DBCR0_TDE | DBCR0_IDM));
13861 +#endif
13862 +
13863 +       /* Setup TODC access */
13864 +       TODC_INIT(TODC_TYPE_DS1743,
13865 +                       0,
13866 +                       0,
13867 +                       ioremap64(OCOTEA_RTC_ADDR, OCOTEA_RTC_SIZE),
13868 +                       8);
13869 +
13870 +       /* init to some ~sane value until calibrate_delay() runs */
13871 +        loops_per_jiffy = 50000000/HZ;
13872 +
13873 +       /* Setup PCI host bridge */
13874 +       ocotea_setup_hose();
13875 +       
13876 +#ifdef CONFIG_BLK_DEV_INITRD
13877 +       if (initrd_start)
13878 +               ROOT_DEV = Root_RAM0;
13879 +       else
13880 +#endif
13881 +#ifdef CONFIG_ROOT_NFS
13882 +               ROOT_DEV = Root_NFS;
13883 +#else
13884 +               ROOT_DEV = Root_HDA1;
13885 +#endif
13886 +
13887 +#ifdef CONFIG_DUMMY_CONSOLE
13888 +       conswitchp = &dummy_con;
13889 +#endif
13890 +
13891 +       ocotea_early_serial_map();
13892 +
13893 +       /* Identify the system */
13894 +       printk("IBM Ocotea port (MontaVista Software, Inc. <source@mvista.com>)\n");
13895 +}
13896 +
13897 +static void
13898 +ocotea_restart(char *cmd)
13899 +{
13900 +       local_irq_disable();
13901 +       abort();
13902 +}
13903 +
13904 +static void
13905 +ocotea_power_off(void)
13906 +{
13907 +       local_irq_disable();
13908 +       for(;;);
13909 +}
13910 +
13911 +static void
13912 +ocotea_halt(void)
13913 +{
13914 +       local_irq_disable();
13915 +       for(;;);
13916 +}
13917 +
13918 +/*
13919 + * Read the 440GX memory controller to get size of system memory.
13920 + */
13921 +static unsigned long __init
13922 +ocotea_find_end_of_memory(void)
13923 +{
13924 +       u32 i, bank_config;
13925 +       u32 mem_size = 0;
13926 +
13927 +       for (i=0; i<4; i++)
13928 +       {
13929 +               switch (i)
13930 +               {
13931 +                       case 0:
13932 +                               mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B0CR);
13933 +                               break;
13934 +                       case 1:
13935 +                               mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B1CR);
13936 +                               break;
13937 +                       case 2:
13938 +                               mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B2CR);
13939 +                               break;
13940 +                       case 3:
13941 +                               mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B3CR);
13942 +                               break;
13943 +               }
13944 +
13945 +               bank_config = mfdcr(DCRN_SDRAM0_CFGDATA);
13946 +
13947 +               if (!(bank_config & SDRAM_CONFIG_BANK_ENABLE))
13948 +                       continue;
13949 +               switch (SDRAM_CONFIG_BANK_SIZE(bank_config))
13950 +               {
13951 +                       case SDRAM_CONFIG_SIZE_8M:
13952 +                               mem_size += PPC44x_MEM_SIZE_8M;
13953 +                               break;
13954 +                       case SDRAM_CONFIG_SIZE_16M:
13955 +                               mem_size += PPC44x_MEM_SIZE_16M;
13956 +                               break;
13957 +                       case SDRAM_CONFIG_SIZE_32M:
13958 +                               mem_size += PPC44x_MEM_SIZE_32M;
13959 +                               break;
13960 +                       case SDRAM_CONFIG_SIZE_64M:
13961 +                               mem_size += PPC44x_MEM_SIZE_64M;
13962 +                               break;
13963 +                       case SDRAM_CONFIG_SIZE_128M:
13964 +                               mem_size += PPC44x_MEM_SIZE_128M;
13965 +                               break;
13966 +                       case SDRAM_CONFIG_SIZE_256M:
13967 +                               mem_size += PPC44x_MEM_SIZE_256M;
13968 +                               break;
13969 +                       case SDRAM_CONFIG_SIZE_512M:
13970 +                               mem_size += PPC44x_MEM_SIZE_512M;
13971 +                               break;
13972 +               }
13973 +       }
13974 +       return mem_size;
13975 +}
13976 +
13977 +static void __init
13978 +ocotea_init_irq(void)
13979 +{
13980 +       int i;
13981 +
13982 +       /* Enable PPC440GP interrupt compatibility mode */
13983 +       SDR_WRITE(DCRN_SDR_MFR,SDR_READ(DCRN_SDR_MFR) | DCRN_SDR_MFR_PCM);
13984 +
13985 +       ppc4xx_pic_init();
13986 +
13987 +       for (i = 0; i < NR_IRQS; i++)
13988 +               irq_desc[i].handler = ppc4xx_pic;
13989 +}
13990 +
13991 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
13992 +#include <linux/serialP.h>
13993 +#include <linux/serial_reg.h>
13994 +#include <asm/serial.h>
13995 +struct serial_state rs_table[RS_TABLE_SIZE] = {
13996 +       SERIAL_PORT_DFNS        /* Defined in <asm/serial.h> */
13997 +};
13998 +
13999 +static void
14000 +ocotea_progress(char *s, unsigned short hex)
14001 +{
14002 +       volatile char c;
14003 +       volatile unsigned long com_port;
14004 +       u16 shift;
14005 +
14006 +       com_port = (unsigned long)rs_table[0].iomem_base;
14007 +       shift = rs_table[0].iomem_reg_shift;
14008 +
14009 +       while ((c = *s++) != 0) {
14010 +               while ((*((volatile unsigned char *)com_port +
14011 +                               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
14012 +                       ;
14013 +               *(volatile unsigned char *)com_port = c;
14014 +
14015 +       }
14016 +
14017 +       /* Send LF/CR to pretty up output */
14018 +       while ((*((volatile unsigned char *)com_port +
14019 +               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
14020 +               ;
14021 +       *(volatile unsigned char *)com_port = '\r';
14022 +       while ((*((volatile unsigned char *)com_port +
14023 +               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
14024 +               ;
14025 +       *(volatile unsigned char *)com_port = '\n';
14026 +}
14027 +#endif /* CONFIG_SERIAL_TEXT_DEBUG */
14028 +
14029 +#if 0
14030 +static void __init
14031 +ocotea_map_io(void)
14032 +{
14033 +       io_block_mapping(0xe0000000, 0x0000000140000000,
14034 +                        0x00001000, _PAGE_IO);
14035 +}
14036 +#endif
14037 +
14038 +void __init platform_init(unsigned long r3, unsigned long r4,
14039 +               unsigned long r5, unsigned long r6, unsigned long r7)
14040 +{
14041 +       parse_bootinfo((struct bi_record *) (r3 + KERNELBASE));
14042 +
14043 +       ppc_md.setup_arch = ocotea_setup_arch;
14044 +       ppc_md.show_cpuinfo = ocotea_show_cpuinfo;
14045 +       ppc_md.init_IRQ = ocotea_init_irq;
14046 +       ppc_md.get_irq = NULL;          /* Set in ppc4xx_pic_init() */
14047 +
14048 +       ppc_md.find_end_of_memory = ocotea_find_end_of_memory;
14049 +
14050 +       ppc_md.restart = ocotea_restart;
14051 +       ppc_md.power_off = ocotea_power_off;
14052 +       ppc_md.halt = ocotea_halt;
14053 +
14054 +       ppc_md.calibrate_decr = ocotea_calibrate_decr;
14055 +       ppc_md.time_init = todc_time_init;
14056 +       ppc_md.set_rtc_time = todc_set_rtc_time;
14057 +       ppc_md.get_rtc_time = todc_get_rtc_time;
14058 +
14059 +       ppc_md.nvram_read_val = todc_direct_read_val;
14060 +       ppc_md.nvram_write_val = todc_direct_write_val;
14061 +
14062 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
14063 +       ppc_md.progress = ocotea_progress;
14064 +#endif /* CONFIG_SERIAL_TEXT_DEBUG */
14065 +#ifdef CONFIG_KGDB
14066 +       ppc_md.early_serial_map = ocotea_early_serial_map;
14067 +#endif
14068 +}
14069 diff -Nru a/arch/ppc/platforms/4xx/ocotea.h b/arch/ppc/platforms/4xx/ocotea.h
14070 --- /dev/null   Wed Dec 31 16:00:00 1969
14071 +++ b/arch/ppc/platforms/4xx/ocotea.h   Wed Sep  3 05:16:34 2003
14072 @@ -0,0 +1,84 @@
14073 +/*
14074 + * arch/ppc/platforms/ocotea.h
14075 + *
14076 + * Ocotea board definitions
14077 + *
14078 + * Matt Porter <mporter@mvista.com>
14079 + *
14080 + * Copyright 2003 MontaVista Software Inc.
14081 + *
14082 + * This program is free software; you can redistribute  it and/or modify it
14083 + * under  the terms of  the GNU General  Public License as published by the
14084 + * Free Software Foundation;  either version 2 of the  License, or (at your
14085 + * option) any later version.
14086 + *
14087 + */
14088 +
14089 +#ifdef __KERNEL__
14090 +#ifndef __ASM_OCOTEA_H__
14091 +#define __ASM_OCOTEA_H__
14092 +
14093 +#include <linux/config.h>
14094 +#include <platforms/4xx/ibm440gx.h>
14095 +
14096 +/* F/W TLB mapping used in bootloader glue to reset EMAC */
14097 +#define PPC44x_EMAC0_MR0       0xE0000800
14098 +
14099 +/* Location of MAC addresses in firmware */
14100 +#define OCOTEA_MAC_BASE                (OCOTEA_SMALL_FLASH_HIGH+0xc0500)
14101 +#define OCOTEA_MAC_SIZE                0x200
14102 +#define OCOTEA_MAC1_OFFSET     0x100
14103 +
14104 +/* Default clock rate */
14105 +#define OCOTEA_SYSCLK          25000000
14106 +
14107 +/* RTC/NVRAM location */
14108 +#define OCOTEA_RTC_ADDR                0x0000000148000000ULL
14109 +#define OCOTEA_RTC_SIZE                0x2000
14110 +
14111 +/* Flash */
14112 +#define OCOTEA_FPGA_ADDR               0x0000000148300000ULL
14113 +#define OCOTEA_BOOT_LARGE_FLASH(x)     (x & 0x40)
14114 +#define OCOTEA_SMALL_FLASH_LOW         0x00000001ff900000ULL
14115 +#define OCOTEA_SMALL_FLASH_HIGH                0x00000001fff00000ULL
14116 +#define OCOTEA_SMALL_FLASH_SIZE                0x100000
14117 +#define OCOTEA_LARGE_FLASH_LOW         0x00000001ff800000ULL
14118 +#define OCOTEA_LARGE_FLASH_HIGH                0x00000001ffc00000ULL
14119 +#define OCOTEA_LARGE_FLASH_SIZE                0x400000
14120 +
14121 +/*
14122 + * Serial port defines
14123 + */
14124 +#define RS_TABLE_SIZE  2
14125 +
14126 +/* OpenBIOS defined UART mappings, used before early_serial_setup */
14127 +#define UART0_IO_BASE  (u8 *) 0xE0000200
14128 +#define UART1_IO_BASE  (u8 *) 0xE0000300
14129 +
14130 +#define BASE_BAUD      11059200/16
14131 +#define STD_UART_OP(num)                                       \
14132 +       { 0, BASE_BAUD, 0, UART##num##_IRQ,                     \
14133 +               (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST),        \
14134 +               iomem_base: UART##num##_IO_BASE,                \
14135 +               io_type: SERIAL_IO_MEM},
14136 +
14137 +#define SERIAL_PORT_DFNS       \
14138 +       STD_UART_OP(0)          \
14139 +       STD_UART_OP(1)
14140 +
14141 +/* PCI support */
14142 +#define OCOTEA_PCI_LOWER_IO    0x00000000
14143 +#define OCOTEA_PCI_UPPER_IO    0x0000ffff
14144 +#define OCOTEA_PCI_LOWER_MEM   0x80000000
14145 +#define OCOTEA_PCI_UPPER_MEM   0xffffefff
14146 +
14147 +#define OCOTEA_PCI_CFGREGS_BASE        0x000000020ec00000ULL
14148 +#define OCOTEA_PCI_CFGA_PLB32  0x0ec00000
14149 +#define OCOTEA_PCI_CFGD_PLB32  0x0ec00004
14150 +
14151 +#define OCOTEA_PCI_IO_BASE     0x0000000208000000ULL
14152 +#define OCOTEA_PCI_IO_SIZE     0x00010000
14153 +#define OCOTEA_PCI_MEM_OFFSET  0x00000000
14154 +
14155 +#endif                         /* __ASM_OCOTEA_H__ */
14156 +#endif                         /* __KERNEL__ */
14157 diff -Nru a/arch/ppc/platforms/mcpn765_serial.h b/arch/ppc/platforms/mcpn765_serial.h
14158 --- a/arch/ppc/platforms/mcpn765_serial.h       Tue Feb 11 15:48:53 2003
14159 +++ b/arch/ppc/platforms/mcpn765_serial.h       Mon Jul 21 09:05:22 2003
14160 @@ -30,7 +30,8 @@
14161  #endif
14162  
14163  /* Rate for the 1.8432 Mhz clock for the onboard serial chip */
14164 -#define BASE_BAUD ( 1843200 / 16 )
14165 +#define BASE_BAUD      ( 1843200 / 16 )
14166 +#define UART_CLK       1843200
14167  
14168  #ifdef CONFIG_SERIAL_DETECT_IRQ
14169  #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
14170 diff -Nru a/arch/ppc/platforms/mcpn765_setup.c b/arch/ppc/platforms/mcpn765_setup.c
14171 --- a/arch/ppc/platforms/mcpn765_setup.c        Wed Apr 23 00:49:34 2003
14172 +++ b/arch/ppc/platforms/mcpn765_setup.c        Mon Jul 21 09:05:22 2003
14173 @@ -31,6 +31,9 @@
14174  #include <linux/ide.h>
14175  #include <linux/seq_file.h>
14176  #include <linux/root_dev.h>
14177 +#include <linux/serial.h>
14178 +#include <linux/tty.h> /* for linux/serial_core.h */
14179 +#include <linux/serial_core.h>
14180  
14181  #include <asm/system.h>
14182  #include <asm/pgtable.h>
14183 @@ -49,36 +52,94 @@
14184  #include <asm/pplus.h>
14185  
14186  #include "mcpn765.h"
14187 +#include "mcpn765_serial.h"
14188 +
14189  
14190  static u_char mcpn765_openpic_initsenses[] __initdata = {
14191 -       0,      /* 16: i8259 cascade (active high) */
14192 -       1,      /* 17: COM1,2,3,4 */
14193 -       1,      /* 18: Enet 1 (front panel) */
14194 -       1,      /* 19: HAWK WDT XXXX */
14195 -       1,      /* 20: 21554 PCI-PCI bridge */
14196 -       1,      /* 21: cPCI INTA# */
14197 -       1,      /* 22: cPCI INTB# */
14198 -       1,      /* 23: cPCI INTC# */
14199 -       1,      /* 24: cPCI INTD# */
14200 -       1,      /* 25: PMC1 INTA#, PMC2 INTB# */
14201 -       1,      /* 26: PMC1 INTB#, PMC2 INTC# */
14202 -       1,      /* 27: PMC1 INTC#, PMC2 INTD# */
14203 -       1,      /* 28: PMC1 INTD#, PMC2 INTA# */
14204 -       1,      /* 29: Enet 2 (connected to J3) */
14205 -       1,      /* 30: Abort Switch */
14206 -       1,      /* 31: RTC Alarm */
14207 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),/* 16: i8259 cascade */
14208 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 17: COM1,2,3,4 */
14209 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 18: Enet 1 (front) */
14210 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 19: HAWK WDT XXXX */
14211 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 20: 21554 bridge */
14212 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 21: cPCI INTA# */
14213 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 22: cPCI INTB# */
14214 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 23: cPCI INTC# */
14215 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 24: cPCI INTD# */
14216 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 25: PMC1 INTA#,PMC2 INTB#*/
14217 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 26: PMC1 INTB#,PMC2 INTC#*/
14218 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 27: PMC1 INTC#,PMC2 INTD#*/
14219 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 28: PMC1 INTD#,PMC2 INTA#*/
14220 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 29: Enet 2 (J3) */
14221 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 30: Abort Switch */
14222 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 31: RTC Alarm */
14223  };
14224  
14225  
14226  extern u_int openpic_irq(void);
14227  extern char cmd_line[];
14228  
14229 +extern void gen550_progress(char *, unsigned short);
14230 +extern void gen550_init(int, struct uart_port *);
14231 +
14232  int use_of_interrupt_tree = 0;
14233  
14234  static void mcpn765_halt(void);
14235  
14236  TODC_ALLOC();
14237  
14238 +#if defined(CONFIG_SERIAL_8250) && \
14239 +       (defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG))
14240 +static void __init
14241 +mcpn765_early_serial_map(void)
14242 +{
14243 +       struct uart_port serial_req;
14244 +
14245 +       /* Setup serial port access */
14246 +       memset(&serial_req, 0, sizeof(serial_req));
14247 +       serial_req.uartclk = UART_CLK;
14248 +       serial_req.irq = 17;
14249 +       serial_req.flags = STD_COM_FLAGS;
14250 +       serial_req.iotype = SERIAL_IO_MEM;
14251 +       serial_req.membase = (u_char *)MCPN765_SERIAL_1;
14252 +       serial_req.regshift = 4;
14253 +
14254 +       gen550_init(0, &serial_req);
14255 +
14256 +       if (early_serial_setup(&serial_req) != 0)
14257 +               printk(KERN_ERR "Early serial init of port 0 failed\n");
14258 +
14259 +       /* Assume early_serial_setup() doesn't modify serial_req */
14260 +       serial_req.line = 1;
14261 +       serial_req.irq = 17;
14262 +       serial_req.membase = (u_char *)MCPN765_SERIAL_2;
14263 +
14264 +       gen550_init(1, &serial_req);
14265 +
14266 +       if (early_serial_setup(&serial_req) != 0)
14267 +               printk(KERN_ERR "Early serial init of port 1 failed\n");
14268 +
14269 +       /* Assume early_serial_setup() doesn't modify serial_req */
14270 +       serial_req.line = 2;
14271 +       serial_req.irq = 17;
14272 +       serial_req.membase = (u_char *)MCPN765_SERIAL_3;
14273 +
14274 +       gen550_init(2, &serial_req);
14275 +
14276 +       if (early_serial_setup(&serial_req) != 0)
14277 +               printk(KERN_ERR "Early serial init of port 2 failed\n");
14278 +
14279 +       /* Assume early_serial_setup() doesn't modify serial_req */
14280 +       serial_req.line = 3;
14281 +       serial_req.irq = 17;
14282 +       serial_req.membase = (u_char *)MCPN765_SERIAL_4;
14283 +
14284 +       gen550_init(3, &serial_req);
14285 +
14286 +       if (early_serial_setup(&serial_req) != 0)
14287 +               printk(KERN_ERR "Early serial init of port 3 failed\n");
14288 +}
14289 +#endif
14290 +
14291  static void __init
14292  mcpn765_setup_arch(void)
14293  {
14294 @@ -187,12 +248,12 @@
14295         if ( ppc_md.progress )
14296                 ppc_md.progress("init_irq: enter", 0);
14297  
14298 -       openpic_init(1, NUM_8259_INTERRUPTS, NULL, -1);
14299 +       openpic_init(NUM_8259_INTERRUPTS);
14300  
14301         for(i=0; i < NUM_8259_INTERRUPTS; i++)
14302                 irq_desc[i].handler = &i8259_pic;
14303  
14304 -       i8259_init(NULL);
14305 +       i8259_init(0);
14306  
14307         if ( ppc_md.progress )
14308                 ppc_md.progress("init_irq: exit", 0);
14309 @@ -361,65 +422,15 @@
14310  static __inline__ void
14311  mcpn765_set_bat(void)
14312  {
14313 -       unsigned long   bat3u, bat3l;
14314 -       static int      mapping_set = 0;
14315 -
14316 -       if (!mapping_set) {
14317 -
14318 -               __asm__ __volatile__(
14319 -               " lis %0,0xf000\n \
14320 -                 ori %1,%0,0x002a\n \
14321 -                 ori %0,%0,0x1ffe\n \
14322 -                 mtspr 0x21e,%0\n \
14323 -                 mtspr 0x21f,%1\n \
14324 -                 isync\n \
14325 -                 sync "
14326 -               : "=r" (bat3u), "=r" (bat3l));
14327 -
14328 -               mapping_set = 1;
14329 -       }
14330 -
14331 -       return;
14332 -}
14333 -
14334 -#ifdef CONFIG_SERIAL_TEXT_DEBUG
14335 -#include <linux/serialP.h>
14336 -#include <linux/serial_reg.h>
14337 -#include <asm/serial.h>
14338 -
14339 -static struct serial_state rs_table[RS_TABLE_SIZE] = {
14340 -       SERIAL_PORT_DFNS        /* Defined in <asm/serial.h> */
14341 -};
14342 -
14343 -static void
14344 -mcpn765_progress(char *s, unsigned short hex)
14345 -{
14346 -       volatile char c;
14347 -       volatile unsigned long com_port;
14348 -       u16 shift;
14349 -
14350 -       com_port = rs_table[0].port;
14351 -       shift = rs_table[0].iomem_reg_shift;
14352 -
14353 -       while ((c = *s++) != 0) {
14354 -               while ((*((volatile unsigned char *)com_port +
14355 -                               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
14356 -                               ;
14357 -               *(volatile unsigned char *)com_port = c;
14358 -
14359 -               if (c == '\n') {
14360 -                       while ((*((volatile unsigned char *)com_port +
14361 -                               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
14362 -                                       ;
14363 -                       *(volatile unsigned char *)com_port = '\r';
14364 -               }
14365 -       }
14366 +       mb();
14367 +       mtspr(DBAT1U, 0xfe8000fe);
14368 +       mtspr(DBAT1L, 0xfe80002a);
14369 +       mb();
14370  }
14371 -#endif /* CONFIG_SERIAL_TEXT_DEBUG */
14372  
14373  void __init
14374  platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
14375 -             unsigned long r6, unsigned long r7)
14376 +               unsigned long r6, unsigned long r7)
14377  {
14378         parse_bootinfo(find_bootinfo());
14379  
14380 @@ -458,11 +469,13 @@
14381         ppc_md.heartbeat_reset = 0;
14382         ppc_md.heartbeat_count = 0;
14383  
14384 -#ifdef CONFIG_SERIAL_TEXT_DEBUG
14385 -       ppc_md.progress = mcpn765_progress;
14386 -#else  /* !CONFIG_SERIAL_TEXT_DEBUG */
14387 -       ppc_md.progress = NULL;
14388 -#endif /* CONFIG_SERIAL_TEXT_DEBUG */
14389 +#if defined(CONFIG_SERIAL_8250) && \
14390 +       (defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG))
14391 +       mcpn765_early_serial_map();
14392 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
14393 +       ppc_md.progress = gen550_progress;
14394 +#endif
14395 +#endif
14396  
14397  #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
14398          ppc_ide_md.default_irq = mcpn765_ide_default_irq;
14399 diff -Nru a/arch/ppc/platforms/pmac_cpufreq.c b/arch/ppc/platforms/pmac_cpufreq.c
14400 --- a/arch/ppc/platforms/pmac_cpufreq.c Wed Jul 23 17:04:23 2003
14401 +++ b/arch/ppc/platforms/pmac_cpufreq.c Mon Aug 25 09:51:43 2003
14402 @@ -21,6 +21,7 @@
14403  #include <linux/slab.h>
14404  #include <linux/cpufreq.h>
14405  #include <linux/init.h>
14406 +#include <linux/sysdev.h>
14407  #include <asm/prom.h>
14408  #include <asm/machdep.h>
14409  #include <asm/irq.h>
14410 @@ -31,12 +32,16 @@
14411  #include <asm/cputable.h>
14412  #include <asm/time.h>
14413  
14414 +/* WARNING !!! This will cause calibrate_delay() to be called,
14415 + * but this is an __init function ! So you MUST go edit
14416 + * init/main.c to make it non-init before enabling DEBUG_FREQ
14417 + */
14418  #undef DEBUG_FREQ
14419  
14420  extern void low_choose_750fx_pll(int pll);
14421  extern void low_sleep_handler(void);
14422 -extern void openpic_sleep_save_intrs(void);
14423 -extern void openpic_sleep_restore_intrs(void);
14424 +extern void openpic_suspend(struct sys_device *sysdev, u32 state);
14425 +extern void openpic_resume(struct sys_device *sysdev);
14426  extern void enable_kernel_altivec(void);
14427  extern void enable_kernel_fp(void);
14428  
14429 @@ -116,10 +121,7 @@
14430         printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));      
14431  #endif
14432         /* Disable all interrupt sources on openpic */
14433 -       openpic_sleep_save_intrs();
14434 -
14435 -       /* Make sure the PMU is idle */
14436 -       pmu_suspend();
14437 +       openpic_suspend(NULL, 1);
14438  
14439         /* Make sure the decrementer won't interrupt us */
14440         asm volatile("mtdec %0" : : "r" (0x7fffffff));
14441 @@ -153,11 +155,16 @@
14442         pmu_request(&req, NULL, 6, PMU_CPU_SPEED, 'W', 'O', 'O', 'F', low_speed);
14443         while (!req.complete)
14444                 pmu_poll();
14445 -       
14446 -       pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,1);
14447  
14448 +       /* Prepare the northbridge for the speed transition */
14449 +       pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,1);
14450 +       
14451 +       /* Call low level code to backup CPU state and recover from
14452 +        * hardware reset
14453 +        */
14454         low_sleep_handler();
14455         
14456 +       /* Restore the northbridge */
14457         pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,0);
14458  
14459         /* Restore L2 cache */
14460 @@ -174,13 +181,14 @@
14461         printk(KERN_DEBUG "HID1, after: %x\n", mfspr(SPRN_HID1));       
14462  #endif
14463  
14464 +       /* Restore low level PMU operations */
14465 +       pmu_unlock();
14466 +
14467         /* Restore decrementer */
14468         wakeup_decrementer();
14469  
14470         /* Restore interrupts */
14471 -       openpic_sleep_restore_intrs();
14472 -
14473 -       pmu_resume();
14474 +       openpic_resume(NULL);
14475  
14476         /* Let interrupts flow again ... */
14477         local_irq_enable();
14478 @@ -195,13 +203,16 @@
14479  static int __pmac
14480  do_set_cpu_speed(int speed_mode)
14481  {
14482 -       struct cpufreq_freqs    freqs;
14483 +       struct cpufreq_freqs freqs;
14484         int rc;
14485         
14486         freqs.old = cur_freq;
14487         freqs.new = (speed_mode == PMAC_CPU_HIGH_SPEED) ? hi_freq : low_freq;
14488         freqs.cpu = smp_processor_id();
14489  
14490 +       if (freqs.old == freqs.new)
14491 +               return 0;
14492 +
14493         cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
14494         if (cpufreq_uses_pmu)
14495                 rc = pmu_set_cpu_speed(speed_mode);
14496 @@ -275,7 +286,10 @@
14497         struct device_node      *cpunode;
14498         u32                     *value;
14499         int                     has_freq_ctl = 0;
14500 -       
14501 +       
14502 +       if (strstr(cmd_line, "nocpufreq"))
14503 +               return 0;
14504 +
14505         /* Assume only one CPU */
14506         cpunode = find_type_devices("cpu");
14507         if (!cpunode)
14508 diff -Nru a/arch/ppc/platforms/pmac_pic.c b/arch/ppc/platforms/pmac_pic.c
14509 --- a/arch/ppc/platforms/pmac_pic.c     Wed Apr 30 05:41:43 2003
14510 +++ b/arch/ppc/platforms/pmac_pic.c     Sun Aug 24 04:12:57 2003
14511 @@ -22,6 +22,9 @@
14512  #include <linux/signal.h>
14513  #include <linux/pci.h>
14514  #include <linux/interrupt.h>
14515 +#include <linux/sysdev.h>
14516 +#include <linux/adb.h>
14517 +#include <linux/pmu.h>
14518  
14519  #include <asm/sections.h>
14520  #include <asm/io.h>
14521 @@ -506,7 +509,7 @@
14522  #endif /* CONFIG_XMON */
14523  }
14524  
14525 -#ifdef CONFIG_PMAC_PBOOK
14526 +#ifdef CONFIG_PM
14527  /*
14528   * These procedures are used in implementing sleep on the powerbooks.
14529   * sleep_save_intrs() saves the states of all interrupt enables
14530 @@ -515,9 +518,32 @@
14531   */
14532  unsigned long sleep_save_mask[2];
14533  
14534 -void __pmac
14535 -pmac_sleep_save_intrs(int viaint)
14536 +/* This used to be passed by the PMU driver but that link got
14537 + * broken with the new driver model. We use this tweak for now...
14538 + */
14539 +static int pmacpic_find_viaint(void)
14540  {
14541 +       int viaint = -1;
14542 +       
14543 +#ifdef CONFIG_ADB_PMU
14544 +       struct device_node *np;
14545 +
14546 +       if (pmu_get_model() != PMU_OHARE_BASED)
14547 +               goto not_found;
14548 +       np = of_find_node_by_name(NULL, "via-pmu");
14549 +       if (np == NULL)
14550 +               goto not_found;
14551 +       viaint = np->intrs[0].line;
14552 +#endif /* CONFIG_ADB_PMU */
14553 +
14554 +not_found:
14555 +       return viaint;
14556 +}
14557 +
14558 +static int pmacpic_suspend(struct sys_device *sysdev, u32 state)
14559 +{
14560 +       int viaint = pmacpic_find_viaint();
14561 +       
14562         sleep_save_mask[0] = ppc_cached_irq_mask[0];
14563         sleep_save_mask[1] = ppc_cached_irq_mask[1];
14564         ppc_cached_irq_mask[0] = 0;
14565 @@ -531,10 +557,11 @@
14566         /* make sure mask gets to controller before we return to caller */
14567         mb();
14568          (void)in_le32(&pmac_irq_hw[0]->enable);
14569 +
14570 +        return 0;
14571  }
14572  
14573 -void __pmac
14574 -pmac_sleep_restore_intrs(void)
14575 +static int pmacpic_resume(struct sys_device *sysdev)
14576  {
14577         int i;
14578  
14579 @@ -545,5 +572,39 @@
14580         for (i = 0; i < max_real_irqs; ++i)
14581                 if (test_bit(i, sleep_save_mask))
14582                         pmac_unmask_irq(i);
14583 +
14584 +       return 0;
14585  }
14586 -#endif /* CONFIG_PMAC_PBOOK */
14587 +
14588 +#endif /* CONFIG_PM */
14589 +
14590 +static struct sysdev_class pmacpic_sysclass = {
14591 +       set_kset_name("pmac_pic"),
14592 +};
14593 +
14594 +static struct sys_device device_pmacpic = {
14595 +       .id             = 0,
14596 +       .cls            = &pmacpic_sysclass,
14597 +};
14598 +
14599 +static struct sysdev_driver driver_pmacpic = {
14600 +#ifdef CONFIG_PM
14601 +       .suspend        = &pmacpic_suspend,
14602 +       .resume         = &pmacpic_resume,
14603 +#endif /* CONFIG_PM */ 
14604 +};
14605 +
14606 +static int __init init_pmacpic_sysfs(void)
14607 +{
14608 +       if (max_irqs == 0)
14609 +               return -ENODEV;
14610 +
14611 +       printk(KERN_DEBUG "Registering pmac pic with sysfs...\n");
14612 +       sysdev_class_register(&pmacpic_sysclass);
14613 +       sys_device_register(&device_pmacpic);
14614 +       sysdev_driver_register(&pmacpic_sysclass, &driver_pmacpic);
14615 +       return 0;
14616 +}
14617 +
14618 +subsys_initcall(init_pmacpic_sysfs);
14619 +
14620 diff -Nru a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
14621 --- a/arch/ppc/platforms/sandpoint.c    Tue Jul  1 10:56:46 2003
14622 +++ b/arch/ppc/platforms/sandpoint.c    Thu Aug 21 10:19:10 2003
14623 @@ -357,6 +357,21 @@
14624  }
14625  
14626  /*
14627 + * Fix IDE interrupts.
14628 + */
14629 +static int __init
14630 +sandpoint_fix_winbond_83553(void)
14631 +{
14632 +       /* Make all 8259 interrupt level sensitive */
14633 +       outb(0xf8, 0x4d0);
14634 +       outb(0xde, 0x4d1);
14635 +
14636 +       return 0;
14637 +}
14638 +
14639 +arch_initcall(sandpoint_fix_winbond_83553);
14640 +
14641 +/*
14642   * Initialize the ISA devices on the Nat'l PC87308VUL SuperIO chip.
14643   */
14644  static int __init
14645 @@ -390,21 +405,6 @@
14646  }
14647  
14648  arch_initcall(sandpoint_setup_natl_87308);
14649 -
14650 -/*
14651 - * Fix IDE interrupts.
14652 - */
14653 -static int __init
14654 -sandpoint_fix_winbond_83553(void)
14655 -{
14656 -       /* Make all 8259 interrupt level sensitive */
14657 -       outb(0xf8, 0x4d0);
14658 -       outb(0xde, 0x4d1);
14659 -
14660 -       return 0;
14661 -}
14662 -
14663 -arch_initcall(sandpoint_fix_winbond_83553);
14664  
14665  static int __init
14666  sandpoint_request_io(void)
14667 diff -Nru a/arch/ppc/platforms/sandpoint.h b/arch/ppc/platforms/sandpoint.h
14668 --- a/arch/ppc/platforms/sandpoint.h    Tue Jul  1 10:56:46 2003
14669 +++ b/arch/ppc/platforms/sandpoint.h    Thu Aug 21 10:19:10 2003
14670 @@ -61,9 +61,9 @@
14671  #define UART_CLK                       1843200
14672  
14673  #ifdef CONFIG_SERIAL_DETECT_IRQ
14674 -#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
14675 +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_AUTO_IRQ)
14676  #else
14677 -#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
14678 +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF)
14679  #endif
14680  
14681  #define STD_SERIAL_PORT_DFNS \
14682 diff -Nru a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
14683 --- a/arch/ppc/syslib/Makefile  Sat Aug  9 09:39:19 2003
14684 +++ b/arch/ppc/syslib/Makefile  Wed Sep  3 05:16:34 2003
14685 @@ -13,6 +13,8 @@
14686  CFLAGS_btext.o          += -mrelocatable-lib
14687  
14688  obj-$(CONFIG_PPCBUG_NVRAM)     += prep_nvram.o
14689 +obj-$(CONFIG_44x)              += ibm44x_common.o
14690 +obj-$(CONFIG_440GP)            += ibm440gp_common.o
14691  ifeq ($(CONFIG_4xx),y)
14692  obj-$(CONFIG_4xx)              += ppc4xx_pic.o
14693  obj-$(CONFIG_40x)              += ppc4xx_setup.o
14694 @@ -33,6 +35,7 @@
14695  obj-$(CONFIG_PPC_PREP)         += open_pic.o indirect_pci.o i8259.o
14696  obj-$(CONFIG_ADIR)             += i8259.o indirect_pci.o pci_auto.o \
14697                                         todc_time.o
14698 +obj-$(CONFIG_EBONY)            += indirect_pci.o pci_auto.o todc_time.o
14699  obj-$(CONFIG_EV64260)          += gt64260_common.o gt64260_pic.o \
14700                                         indirect_pci.o todc_time.o pci_auto.o
14701  obj-$(CONFIG_GEMINI)           += open_pic.o i8259.o indirect_pci.o
14702 @@ -46,6 +49,7 @@
14703                                         pci_auto.o indirect_pci.o
14704  obj-$(CONFIG_MVME5100)         += open_pic.o todc_time.o indirect_pci.o \
14705                                         i8259.o pci_auto.o pplus_common.o
14706 +obj-$(CONFIG_OCOTEA)           += indirect_pci.o pci_auto.o todc_time.o
14707  obj-$(CONFIG_PAL4)             += cpc700_pic.o
14708  obj-$(CONFIG_PCORE)            += mpc10x_common.o todc_time.o i8259.o \
14709                                         indirect_pci.o pci_auto.o
14710 diff -Nru a/arch/ppc/syslib/ibm440gp_common.c b/arch/ppc/syslib/ibm440gp_common.c
14711 --- /dev/null   Wed Dec 31 16:00:00 1969
14712 +++ b/arch/ppc/syslib/ibm440gp_common.c Wed Sep  3 02:15:08 2003
14713 @@ -0,0 +1,77 @@
14714 +/*
14715 + * arch/ppc/syslib/ibm440gp_common.c
14716 + *
14717 + * PPC440GP system library
14718 + *
14719 + * Matt Porter <mporter@mvista.com>
14720 + * Copyright 2002-2003 MontaVista Software Inc.
14721 + *
14722 + * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
14723 + * Copyright (c) 2003 Zultys Technologies
14724 + *
14725 + * This program is free software; you can redistribute  it and/or modify it
14726 + * under  the terms of  the GNU General  Public License as published by the
14727 + * Free Software Foundation;  either version 2 of the  License, or (at your
14728 + * option) any later version.
14729 + *
14730 + */
14731 +#include <linux/config.h>
14732 +#include <linux/types.h>
14733 +#include <asm/ibm44x.h>
14734 +#include <asm/mmu.h>
14735 +
14736 +/*
14737 + * Calculate 440GP clocks
14738 + */
14739 +void __init ibm440gp_get_clocks(struct ibm440gp_clocks* p,
14740 +                               unsigned int sys_clk, 
14741 +                               unsigned int ser_clk)
14742 +{
14743 +       u32 cpc0_sys0 = mfdcr(DCRN_CPC0_SYS0);
14744 +       u32 cpc0_cr0 = mfdcr(DCRN_CPC0_CR0);
14745 +       u32 opdv, epdv;
14746 +       
14747 +       if (cpc0_sys0 & 0x2){
14748 +               /* Bypass system PLL */
14749 +               p->cpu = p->plb = sys_clk;
14750 +       }
14751 +       else {
14752 +               u32 fbdv, fwdva, fwdvb, m, vco;
14753 +               
14754 +               fbdv = (cpc0_sys0 >> 18) & 0x0f;
14755 +               if (!fbdv)
14756 +                       fbdv = 16;
14757 +    
14758 +               fwdva = 8 - ((cpc0_sys0 >> 15) & 0x7);
14759 +               fwdvb = 8 - ((cpc0_sys0 >> 12) & 0x7);
14760 +    
14761 +               /* Feedback path */         
14762 +               if (cpc0_sys0 & 0x00000080){
14763 +                       /* PerClk */
14764 +                       m = fwdvb * opdv * epdv;
14765 +               }
14766 +               else {
14767 +                       /* CPU clock */
14768 +                       m = fbdv * fwdva;
14769 +               }
14770 +               vco = sys_clk * m;
14771 +               p->cpu = vco / fwdva;
14772 +               p->plb = vco / fwdvb;
14773 +       }
14774 +    
14775 +       opdv = ((cpc0_sys0 >> 10) & 0x3) + 1;
14776 +       epdv = ((cpc0_sys0 >> 8) & 0x3) + 1;
14777 +       
14778 +       p->opb = p->plb / opdv;
14779 +       p->ebc = p->opb / epdv;
14780 +    
14781 +       if (cpc0_cr0 & 0x00400000){
14782 +               /* External UART clock */
14783 +               p->uart = ser_clk;
14784 +       }
14785 +       else {
14786 +               /* Internal UART clock */    
14787 +               u32 uart_div = ((cpc0_cr0 >> 16) & 0x1f) + 1;
14788 +               p->uart = p->plb / uart_div;
14789 +       }
14790 +}
14791 diff -Nru a/arch/ppc/syslib/ibm440gp_common.h b/arch/ppc/syslib/ibm440gp_common.h
14792 --- /dev/null   Wed Dec 31 16:00:00 1969
14793 +++ b/arch/ppc/syslib/ibm440gp_common.h Wed Sep  3 02:15:09 2003
14794 @@ -0,0 +1,45 @@
14795 +/*
14796 + * arch/ppc/syslib/ibm440gp_common.h
14797 + *
14798 + * PPC440GP system library
14799 + *
14800 + * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
14801 + * Copyright (c) 2003 Zultys Technologies
14802 + *
14803 + * This program is free software; you can redistribute  it and/or modify it
14804 + * under  the terms of  the GNU General  Public License as published by the
14805 + * Free Software Foundation;  either version 2 of the  License, or (at your
14806 + * option) any later version.
14807 + *
14808 + */
14809 +#ifdef __KERNEL__
14810 +#ifndef __PPC_SYSLIB_IBM440GP_COMMON_H
14811 +#define __PPC_SYSLIB_IBM440GP_COMMON_H
14812 +
14813 +#ifndef __ASSEMBLY__
14814 +
14815 +#include <linux/config.h>
14816 +#include <linux/init.h>
14817 +
14818 +/*
14819 + * All clocks are in Hz
14820 + */
14821 +struct ibm440gp_clocks {
14822 +       unsigned int cpu;       /* CPUCoreClk */
14823 +       unsigned int plb;       /* PLBClk */
14824 +       unsigned int opb;       /* OPBClk */
14825 +       unsigned int ebc;       /* PerClk */
14826 +       unsigned int uart;      
14827 +};
14828 +
14829 +/*
14830 + * Please, refer to the Figure 13.1 in 440GP user manual
14831 + * 
14832 + * if internal UART clock is used, ser_clk is ignored
14833 + */
14834 +void ibm440gp_get_clocks(struct ibm440gp_clocks*, unsigned int sys_clk, 
14835 +       unsigned int ser_clk) __init;
14836
14837 +#endif /* __ASSEMBLY__ */
14838 +#endif /* __PPC_SYSLIB_IBM440GP_COMMON_H */
14839 +#endif /* __KERNEL__ */
14840 diff -Nru a/arch/ppc/syslib/ibm44x_common.c b/arch/ppc/syslib/ibm44x_common.c
14841 --- /dev/null   Wed Dec 31 16:00:00 1969
14842 +++ b/arch/ppc/syslib/ibm44x_common.c   Wed Sep  3 02:15:10 2003
14843 @@ -0,0 +1,37 @@
14844 +/*
14845 + * arch/ppc/syslib/ibm44x_common.c
14846 + *
14847 + * PPC44x system library
14848 + *
14849 + * Matt Porter <mporter@mvista.com>
14850 + * Copyright 2002-2003 MontaVista Software Inc.
14851 + *
14852 + * This program is free software; you can redistribute  it and/or modify it
14853 + * under  the terms of  the GNU General  Public License as published by the
14854 + * Free Software Foundation;  either version 2 of the  License, or (at your
14855 + * option) any later version.
14856 + *
14857 + */
14858 +#include <linux/config.h>
14859 +#include <linux/types.h>
14860 +#include <asm/ibm44x.h>
14861 +#include <asm/mmu.h>
14862 +
14863 +phys_addr_t fixup_bigphys_addr(phys_addr_t addr, phys_addr_t size)
14864 +{
14865 +       phys_addr_t page_4gb = 0;
14866 +
14867 +        /*
14868 +        * Trap the least significant 32-bit portions of an
14869 +        * address in the 440's 36-bit address space.  Fix
14870 +        * them up with the appropriate ERPN
14871 +        */
14872 +       if ((addr >= PPC44x_IO_LO) && (addr < PPC44x_IO_HI))
14873 +               page_4gb = PPC44x_IO_PAGE;
14874 +       else if ((addr >= PPC44x_PCICFG_LO) && (addr < PPC44x_PCICFG_HI))
14875 +               page_4gb = PPC44x_PCICFG_PAGE;
14876 +       else if ((addr >= PPC44x_PCIMEM_LO) && (addr < PPC44x_PCIMEM_HI))
14877 +               page_4gb = PPC44x_PCIMEM_PAGE;
14878 +
14879 +       return (page_4gb | addr);
14880 +};
14881 diff -Nru a/arch/ppc/syslib/of_device.c b/arch/ppc/syslib/of_device.c
14882 --- a/arch/ppc/syslib/of_device.c       Sat Aug 16 11:48:20 2003
14883 +++ b/arch/ppc/syslib/of_device.c       Tue Aug 26 06:35:38 2003
14884 @@ -15,8 +15,8 @@
14885   * Used by a driver to check whether an of_device present in the
14886   * system is in its list of supported devices. 
14887   */
14888 -const struct of_match *
14889 -of_match_device(const struct of_match *matches, const struct of_device *dev)
14890 +const struct of_match * of_match_device(const struct of_match *matches,
14891 +                                       const struct of_device *dev)
14892  {
14893         if (!dev->node)
14894                 return NULL;
14895 @@ -38,8 +38,7 @@
14896         return NULL;
14897  }
14898  
14899 -static int
14900 -of_platform_bus_match(struct device *dev, struct device_driver *drv) 
14901 +static int of_platform_bus_match(struct device *dev, struct device_driver *drv) 
14902  {
14903         struct of_device * of_dev = to_of_device(dev);
14904         struct of_platform_driver * of_drv = to_of_platform_driver(drv);
14905 @@ -51,21 +50,27 @@
14906         return of_match_device(matches, of_dev) != NULL;
14907  }
14908  
14909 -struct bus_type of_platform_bus_type = {
14910 -       name:   "of_platform",
14911 -       match:  of_platform_bus_match,
14912 -};
14913 +struct of_device *of_dev_get(struct of_device *dev)
14914 +{
14915 +       struct device *tmp;
14916 +
14917 +       if (!dev)
14918 +               return NULL;
14919 +       tmp = get_device(&dev->dev);
14920 +       if (tmp)
14921 +               return to_of_device(tmp);
14922 +       else
14923 +               return NULL;
14924 +}
14925  
14926 -static int __init
14927 -of_bus_driver_init(void)
14928 +void of_dev_put(struct of_device *dev)
14929  {
14930 -       return bus_register(&of_platform_bus_type);
14931 +       if (dev)
14932 +               put_device(&dev->dev);
14933  }
14934  
14935 -postcore_initcall(of_bus_driver_init);
14936  
14937 -static int
14938 -of_device_probe(struct device *dev)
14939 +static int of_device_probe(struct device *dev)
14940  {
14941         int error = -ENODEV;
14942         struct of_platform_driver *drv;
14943 @@ -78,22 +83,18 @@
14944         if (!drv->probe)
14945                 return error;
14946  
14947 -/*     if (!try_module_get(driver->owner)) {
14948 -               printk(KERN_ERR "Can't get a module reference for %s\n", driver->name);
14949 -               return error;
14950 -       }
14951 -*/
14952 +       of_dev_get(of_dev);
14953 +
14954         match = of_match_device(drv->match_table, of_dev);
14955         if (match)
14956                 error = drv->probe(of_dev, match);
14957 -/*
14958 -       module_put(driver->owner);
14959 -*/     
14960 +       if (error)
14961 +               of_dev_put(of_dev);
14962 +
14963         return error;
14964  }
14965  
14966 -static int
14967 -of_device_remove(struct device *dev)
14968 +static int of_device_remove(struct device *dev)
14969  {
14970         struct of_device * of_dev = to_of_device(dev);
14971         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
14972 @@ -103,32 +104,43 @@
14973         return 0;
14974  }
14975  
14976 -static int
14977 -of_device_suspend(struct device *dev, u32 state, u32 level)
14978 +static int of_device_suspend(struct device *dev, u32 state)
14979  {
14980         struct of_device * of_dev = to_of_device(dev);
14981         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
14982         int error = 0;
14983  
14984         if (drv && drv->suspend)
14985 -               error = drv->suspend(of_dev, state, level);
14986 +               error = drv->suspend(of_dev, state);
14987         return error;
14988  }
14989  
14990 -static int
14991 -of_device_resume(struct device * dev, u32 level)
14992 +static int of_device_resume(struct device * dev)
14993  {
14994         struct of_device * of_dev = to_of_device(dev);
14995         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
14996         int error = 0;
14997  
14998         if (drv && drv->resume)
14999 -               error = drv->resume(of_dev, level);
15000 +               error = drv->resume(of_dev);
15001         return error;
15002  }
15003  
15004 -int
15005 -of_register_driver(struct of_platform_driver *drv)
15006 +struct bus_type of_platform_bus_type = {
15007 +       .name   = "of_platform",
15008 +       .match  = of_platform_bus_match,
15009 +       .suspend        = of_device_suspend,
15010 +       .resume = of_device_resume,
15011 +};
15012 +
15013 +static int __init of_bus_driver_init(void)
15014 +{
15015 +       return bus_register(&of_platform_bus_type);
15016 +}
15017 +
15018 +postcore_initcall(of_bus_driver_init);
15019 +
15020 +int of_register_driver(struct of_platform_driver *drv)
15021  {
15022         int count = 0;
15023  
15024 @@ -136,8 +148,6 @@
15025         drv->driver.name = drv->name;
15026         drv->driver.bus = &of_platform_bus_type;
15027         drv->driver.probe = of_device_probe;
15028 -       drv->driver.resume = of_device_resume;
15029 -       drv->driver.suspend = of_device_suspend;
15030         drv->driver.remove = of_device_remove;
15031  
15032         /* register with core */
15033 @@ -145,15 +155,13 @@
15034         return count ? count : 1;
15035  }
15036  
15037 -void
15038 -of_unregister_driver(struct of_platform_driver *drv)
15039 +void of_unregister_driver(struct of_platform_driver *drv)
15040  {
15041         driver_unregister(&drv->driver);
15042  }
15043  
15044  
15045 -static ssize_t
15046 -dev_show_devspec(struct device *dev, char *buf)
15047 +static ssize_t dev_show_devspec(struct device *dev, char *buf)
15048  {
15049         struct of_device *ofdev;
15050  
15051 @@ -163,8 +171,22 @@
15052  
15053  static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL);
15054  
15055 -int
15056 -of_device_register(struct of_device *ofdev)
15057 +/**
15058 + * of_release_dev - free an of device structure when all users of it are finished.
15059 + * @dev: device that's been disconnected
15060 + *
15061 + * Will be called only by the device core when all users of this of device are
15062 + * done.
15063 + */
15064 +void of_release_dev(struct device *dev)
15065 +{
15066 +       struct of_device *ofdev;
15067 +
15068 +        ofdev = to_of_device(dev);
15069 +       kfree(ofdev);
15070 +}
15071 +
15072 +int of_device_register(struct of_device *ofdev)
15073  {
15074         int rc;
15075         struct of_device **odprop;
15076 @@ -197,21 +219,20 @@
15077         return 0;
15078  }
15079  
15080 -void
15081 -of_device_unregister(struct of_device *ofdev)
15082 +void of_device_unregister(struct of_device *ofdev)
15083  {
15084         struct of_device **odprop;
15085  
15086         device_remove_file(&ofdev->dev, &dev_attr_devspec);
15087 -       device_unregister(&ofdev->dev);
15088  
15089         odprop = (struct of_device **)get_property(ofdev->node, "linux,device", NULL);
15090         if (odprop)
15091                 *odprop = NULL;
15092 +
15093 +       device_unregister(&ofdev->dev);
15094  }
15095  
15096 -struct of_device*
15097 -of_platform_device_create(struct device_node *np, const char *bus_id)
15098 +struct of_device* of_platform_device_create(struct device_node *np, const char *bus_id)
15099  {
15100         struct of_device *dev;
15101         u32 *reg;
15102 @@ -226,6 +247,7 @@
15103         dev->dev.dma_mask = &dev->dma_mask;
15104         dev->dev.parent = NULL;
15105         dev->dev.bus = &of_platform_bus_type;
15106 +       dev->dev.release = of_release_dev;
15107  
15108         reg = (u32 *)get_property(np, "reg", NULL);
15109         strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
15110 @@ -244,4 +266,7 @@
15111  EXPORT_SYMBOL(of_unregister_driver);
15112  EXPORT_SYMBOL(of_device_register);
15113  EXPORT_SYMBOL(of_device_unregister);
15114 +EXPORT_SYMBOL(of_dev_get);
15115 +EXPORT_SYMBOL(of_dev_put);
15116  EXPORT_SYMBOL(of_platform_device_create);
15117 +EXPORT_SYMBOL(of_release_dev);
15118 diff -Nru a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
15119 --- a/arch/ppc/syslib/open_pic.c        Tue Jul 15 10:01:29 2003
15120 +++ b/arch/ppc/syslib/open_pic.c        Sun Aug 24 04:11:21 2003
15121 @@ -15,6 +15,7 @@
15122  #include <linux/init.h>
15123  #include <linux/irq.h>
15124  #include <linux/interrupt.h>
15125 +#include <linux/sysdev.h>
15126  #include <asm/ptrace.h>
15127  #include <asm/signal.h>
15128  #include <asm/io.h>
15129 @@ -276,7 +277,7 @@
15130  }
15131  #endif
15132  
15133 -#if defined(CONFIG_EPIC_SERIAL_MODE) || defined(CONFIG_PMAC_PBOOK)
15134 +#if defined(CONFIG_EPIC_SERIAL_MODE) || defined(CONFIG_PM)
15135  static void openpic_reset(void)
15136  {
15137         openpic_setfield(&OpenPIC->Global.Global_Configuration0,
15138 @@ -532,7 +533,7 @@
15139         openpic_write(&OpenPIC->Global.Processor_Initialization, mask);
15140  }
15141  
15142 -#if defined(CONFIG_SMP) || defined(CONFIG_PMAC_PBOOK)
15143 +#if defined(CONFIG_SMP) || defined(CONFIG_PM)
15144  static spinlock_t openpic_setup_lock = SPIN_LOCK_UNLOCKED;
15145  #endif
15146  
15147 @@ -864,20 +865,55 @@
15148  }
15149  #endif /* CONFIG_SMP */
15150  
15151 -#ifdef CONFIG_PMAC_PBOOK
15152 +#ifdef CONFIG_PM
15153 +
15154 +/*
15155 + * We implement the IRQ controller as a sysdev and put it
15156 + * to sleep at powerdown stage (the callback is named suspend,
15157 + * but it's old semantics, for the Device Model, it's really
15158 + * powerdown). The possible problem is that another sysdev that
15159 + * happens to be suspend after this one will have interrupts off,
15160 + * that may be an issue... For now, this isn't an issue on pmac
15161 + * though...
15162 + */
15163 +
15164  static u32 save_ipi_vp[OPENPIC_NUM_IPI];
15165  static u32 save_irq_src_vp[OPENPIC_MAX_SOURCES];
15166  static u32 save_irq_src_dest[OPENPIC_MAX_SOURCES];
15167  static u32 save_cpu_task_pri[OPENPIC_MAX_PROCESSORS];
15168 +static int openpic_suspend_count;
15169 +
15170 +static void openpic_cached_enable_irq(u_int irq)
15171 +{
15172 +       check_arg_irq(irq);
15173 +       save_irq_src_vp[irq - open_pic_irq_offset] &= ~OPENPIC_MASK; 
15174 +}
15175  
15176 -void __pmac
15177 -openpic_sleep_save_intrs(void)
15178 +static void openpic_cached_disable_irq(u_int irq)
15179 +{
15180 +       check_arg_irq(irq);
15181 +       save_irq_src_vp[irq - open_pic_irq_offset] |= OPENPIC_MASK; 
15182 +}
15183 +
15184 +/* WARNING: Can be called directly by the cpufreq code with NULL parameter,
15185 + * we need something better to deal with that... Maybe switch to S1 for
15186 + * cpufreq changes
15187 + */
15188 +int openpic_suspend(struct sys_device *sysdev, u32 state)
15189  {
15190         int     i;
15191         unsigned long flags;
15192         
15193         spin_lock_irqsave(&openpic_setup_lock, flags);
15194  
15195 +       if (openpic_suspend_count++ > 0) {
15196 +               spin_unlock_irqrestore(&openpic_setup_lock, flags);
15197 +               return 0;
15198 +       }
15199 +
15200 +       open_pic.enable = openpic_cached_enable_irq;
15201 +       open_pic.disable = openpic_cached_disable_irq;
15202 +
15203         for (i=0; i<NumProcessors; i++) {
15204                 save_cpu_task_pri[i] = openpic_read(&OpenPIC->Processor[i].Current_Task_Priority);
15205                 openpic_writefield(&OpenPIC->Processor[i].Current_Task_Priority,
15206 @@ -889,38 +925,112 @@
15207         for (i=0; i<NumSources; i++) {
15208                 if (ISR[i] == 0)
15209                         continue;
15210 -               save_irq_src_vp[i] = openpic_read(&ISR[i]->Vector_Priority)
15211 -                       & ~OPENPIC_ACTIVITY;
15212 +               save_irq_src_vp[i] = openpic_read(&ISR[i]->Vector_Priority) & ~OPENPIC_ACTIVITY;
15213                 save_irq_src_dest[i] = openpic_read(&ISR[i]->Destination);
15214         }
15215 +
15216         spin_unlock_irqrestore(&openpic_setup_lock, flags);
15217 +
15218 +       return 0;
15219  }
15220  
15221 -void __pmac
15222 -openpic_sleep_restore_intrs(void)
15223 +/* WARNING: Can be called directly by the cpufreq code with NULL parameter,
15224 + * we need something better to deal with that... Maybe switch to S1 for
15225 + * cpufreq changes
15226 + */
15227 +int openpic_resume(struct sys_device *sysdev)
15228  {
15229         int             i;
15230         unsigned long   flags;
15231 +       u32             vppmask =       OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |
15232 +                                       OPENPIC_SENSE_MASK | OPENPIC_POLARITY_MASK |
15233 +                                       OPENPIC_MASK;
15234  
15235         spin_lock_irqsave(&openpic_setup_lock, flags);
15236         
15237 +       if ((--openpic_suspend_count) > 0) {
15238 +               spin_unlock_irqrestore(&openpic_setup_lock, flags);
15239 +               return 0;
15240 +       }
15241 +
15242         openpic_reset();
15243  
15244 +       /* OpenPIC sometimes seem to need some time to be fully back up... */
15245 +       do {
15246 +               openpic_set_spurious(OPENPIC_VEC_SPURIOUS+open_pic_irq_offset);
15247 +       } while(openpic_readfield(&OpenPIC->Global.Spurious_Vector, OPENPIC_VECTOR_MASK)
15248 +                       != (OPENPIC_VEC_SPURIOUS + open_pic_irq_offset));
15249 +                       
15250 +       openpic_disable_8259_pass_through();
15251 +
15252         for (i=0; i<OPENPIC_NUM_IPI; i++)
15253                 openpic_write(&OpenPIC->Global.IPI_Vector_Priority(i),
15254                               save_ipi_vp[i]);
15255         for (i=0; i<NumSources; i++) {
15256                 if (ISR[i] == 0)
15257                         continue;
15258 -               openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
15259                 openpic_write(&ISR[i]->Destination, save_irq_src_dest[i]);
15260 +               openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
15261 +               /* make sure mask gets to controller before we return to user */
15262 +               do {
15263 +                       openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
15264 +               } while (openpic_readfield(&ISR[i]->Vector_Priority, vppmask)
15265 +                        != (save_irq_src_vp[i] & vppmask));
15266         }
15267 -       openpic_set_spurious(OPENPIC_VEC_SPURIOUS+open_pic_irq_offset);
15268 -       openpic_disable_8259_pass_through();
15269         for (i=0; i<NumProcessors; i++)
15270                 openpic_write(&OpenPIC->Processor[i].Current_Task_Priority,
15271                               save_cpu_task_pri[i]);
15272  
15273 +       open_pic.enable = openpic_enable_irq;
15274 +       open_pic.disable = openpic_disable_irq;
15275 +
15276         spin_unlock_irqrestore(&openpic_setup_lock, flags);
15277 +
15278 +       return 0;
15279 +}
15280 +
15281 +#endif /* CONFIG_PM */
15282 +
15283 +static struct sysdev_class openpic_sysclass = {
15284 +       set_kset_name("openpic"),
15285 +};
15286 +
15287 +static struct sys_device device_openpic = {
15288 +       .id             = 0,
15289 +       .cls            = &openpic_sysclass,
15290 +};
15291 +
15292 +static struct sysdev_driver driver_openpic = {
15293 +#ifdef CONFIG_PM
15294 +       .suspend        = &openpic_suspend,
15295 +       .resume         = &openpic_resume,
15296 +#endif /* CONFIG_PM */ 
15297 +};
15298 +
15299 +static int __init init_openpic_sysfs(void)
15300 +{
15301 +       int rc;
15302 +
15303 +       if (!OpenPIC_Addr)
15304 +               return -ENODEV;
15305 +       printk(KERN_DEBUG "Registering openpic with sysfs...\n");
15306 +       rc = sysdev_class_register(&openpic_sysclass);
15307 +       if (rc) {
15308 +               printk(KERN_ERR "Failed registering openpic sys class\n");
15309 +               return -ENODEV;
15310 +       }
15311 +       rc = sys_device_register(&device_openpic);
15312 +       if (rc) {
15313 +               printk(KERN_ERR "Failed registering openpic sys device\n");
15314 +               return -ENODEV;
15315 +       }
15316 +       rc = sysdev_driver_register(&openpic_sysclass, &driver_openpic);
15317 +       if (rc) {
15318 +               printk(KERN_ERR "Failed registering openpic sys driver\n");
15319 +               return -ENODEV;
15320 +       }
15321 +       return 0;
15322  }
15323 -#endif /* CONFIG_PMAC_PBOOK */
15324 +
15325 +subsys_initcall(init_openpic_sysfs);
15326 +
15327 diff -Nru a/arch/ppc/syslib/prom.c b/arch/ppc/syslib/prom.c
15328 --- a/arch/ppc/syslib/prom.c    Sat Jun  7 02:18:01 2003
15329 +++ b/arch/ppc/syslib/prom.c    Sun Aug 24 03:57:52 2003
15330 @@ -941,6 +941,184 @@
15331         return NULL;
15332  }
15333  
15334 +/*******
15335 + *
15336 + * New implementation of the OF "find" APIs, return a refcounted
15337 + * object, call of_node_put() when done. Currently, still lacks
15338 + * locking as old implementation, this is beeing done for ppc64.
15339 + *
15340 + * Note that property management will need some locking as well,
15341 + * this isn't dealt with yet
15342 + *
15343 + *******/
15344 +
15345 +/**
15346 + *     of_find_node_by_name - Find a node by it's "name" property
15347 + *     @from:  The node to start searching from or NULL, the node
15348 + *             you pass will not be searched, only the next one
15349 + *             will; typically, you pass what the previous call
15350 + *             returned. of_node_put() will be called on it
15351 + *     @name:  The name string to match against
15352 + *
15353 + *     Returns a node pointer with refcount incremented, use
15354 + *     of_node_put() on it when done.
15355 + */ 
15356 +struct device_node *of_find_node_by_name(struct device_node *from,
15357 +       const char *name)
15358 +{
15359 +       struct device_node *np = from ? from->allnext : allnodes;
15360 +
15361 +       for (; np != 0; np = np->allnext)
15362 +               if (np->name != 0 && strcasecmp(np->name, name) == 0)
15363 +                       break;
15364 +       if (from)
15365 +               of_node_put(from);
15366 +       return of_node_get(np);
15367 +}
15368 +
15369 +/**
15370 + *     of_find_node_by_type - Find a node by it's "device_type" property
15371 + *     @from:  The node to start searching from or NULL, the node
15372 + *             you pass will not be searched, only the next one
15373 + *             will; typically, you pass what the previous call
15374 + *             returned. of_node_put() will be called on it
15375 + *     @name:  The type string to match against
15376 + *
15377 + *     Returns a node pointer with refcount incremented, use
15378 + *     of_node_put() on it when done.
15379 + */
15380 +struct device_node *of_find_node_by_type(struct device_node *from,
15381 +       const char *type)
15382 +{
15383 +       struct device_node *np = from ? from->allnext : allnodes;
15384 +
15385 +       for (; np != 0; np = np->allnext)
15386 +               if (np->type != 0 && strcasecmp(np->type, type) == 0)
15387 +                       break;
15388 +       if (from)
15389 +               of_node_put(from);
15390 +       return of_node_get(np);
15391 +}
15392 +
15393 +/**
15394 + *     of_find_compatible_node - Find a node based on type and one of the
15395 + *                                tokens in it's "compatible" property
15396 + *     @from:          The node to start searching from or NULL, the node
15397 + *                     you pass will not be searched, only the next one
15398 + *                     will; typically, you pass what the previous call
15399 + *                     returned. of_node_put() will be called on it
15400 + *     @type:          The type string to match "device_type" or NULL to ignore
15401 + *     @compatible:    The string to match to one of the tokens in the device
15402 + *                     "compatible" list.
15403 + *
15404 + *     Returns a node pointer with refcount incremented, use
15405 + *     of_node_put() on it when done.
15406 + */
15407 +struct device_node *of_find_compatible_node(struct device_node *from,
15408 +       const char *type, const char *compatible)
15409 +{
15410 +       struct device_node *np = from ? from->allnext : allnodes;
15411 +
15412 +       for (; np != 0; np = np->allnext) {
15413 +               if (type != NULL
15414 +                   && !(np->type != 0 && strcasecmp(np->type, type) == 0))
15415 +                       continue;
15416 +               if (device_is_compatible(np, compatible))
15417 +                       break;
15418 +       }
15419 +       if (from)
15420 +               of_node_put(from);
15421 +       return of_node_get(np);
15422 +}
15423 +
15424 +/**
15425 + *     of_find_node_by_path - Find a node matching a full OF path
15426 + *     @path:  The full path to match
15427 + *
15428 + *     Returns a node pointer with refcount incremented, use
15429 + *     of_node_put() on it when done.
15430 + */
15431 +struct device_node *of_find_node_by_path(const char *path)
15432 +{
15433 +       struct device_node *np = allnodes;
15434 +
15435 +       for (; np != 0; np = np->allnext)
15436 +               if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0)
15437 +                       break;
15438 +       return of_node_get(np);
15439 +}
15440 +
15441 +/**
15442 + *     of_find_all_nodes - Get next node in global list
15443 + *     @prev:  Previous node or NULL to start iteration
15444 + *             of_node_put() will be called on it
15445 + *
15446 + *     Returns a node pointer with refcount incremented, use
15447 + *     of_node_put() on it when done.
15448 + */
15449 +struct device_node *of_find_all_nodes(struct device_node *prev)
15450 +{
15451 +       return of_node_get(prev ? prev->allnext : allnodes);
15452 +}
15453 +
15454 +/**
15455 + *     of_get_parent - Get a node's parent if any
15456 + *     @node:  Node to get parent
15457 + *
15458 + *     Returns a node pointer with refcount incremented, use
15459 + *     of_node_put() on it when done.
15460 + */
15461 +struct device_node *of_get_parent(const struct device_node *node)
15462 +{
15463 +       return node ? of_node_get(node->parent) : NULL;
15464 +}
15465 +
15466 +/**
15467 + *     of_get_next_child - Iterate a node childs
15468 + *     @node:  parent node
15469 + *     @prev:  previous child of the parent node, or NULL to get first
15470 + *
15471 + *     Returns a node pointer with refcount incremented, use
15472 + *     of_node_put() on it when done.
15473 + */
15474 +struct device_node *of_get_next_child(const struct device_node *node,
15475 +                                     struct device_node *prev)
15476 +{
15477 +       struct device_node *next = prev ? prev->sibling : node->child;
15478 +
15479 +       for (; next != 0; next = next->sibling)
15480 +               if (of_node_get(next))
15481 +                       break;
15482 +       if (prev)
15483 +               of_node_put(prev);
15484 +       return next;
15485 +}
15486 +
15487 +/**
15488 + *     of_node_get - Increment refcount of a node
15489 + *     @node:  Node to inc refcount, NULL is supported to
15490 + *             simplify writing of callers
15491 + *
15492 + *     Returns the node itself or NULL if gone. Current implementation
15493 + *     does nothing as we don't yet do dynamic node allocation on ppc32
15494 + */
15495 +struct device_node *of_node_get(struct device_node *node)
15496 +{
15497 +       return node;
15498 +}
15499 +
15500 +/**
15501 + *     of_node_put - Decrement refcount of a node
15502 + *     @node:  Node to dec refcount, NULL is supported to
15503 + *             simplify writing of callers
15504 + *
15505 + *     Current implementation does nothing as we don't yet do dynamic node
15506 + *     allocation on ppc32
15507 + */
15508 +void  of_node_put(struct device_node *node)
15509 +{    
15510 +}
15511 +
15512  /*
15513   * Find the device_node with a given phandle.
15514   */
15515 diff -Nru a/arch/ppc/xmon/start.c b/arch/ppc/xmon/start.c
15516 --- a/arch/ppc/xmon/start.c     Sat Jun  7 02:18:02 2003
15517 +++ b/arch/ppc/xmon/start.c     Sun Aug 24 07:39:33 2003
15518 @@ -225,14 +225,13 @@
15519  static int scc_initialized = 0;
15520  
15521  void xmon_init_scc(void);
15522 -extern void pmu_poll(void);
15523  extern void cuda_poll(void);
15524  
15525  static inline void do_poll_adb(void)
15526  {
15527  #ifdef CONFIG_ADB_PMU
15528         if (sys_ctrler == SYS_CTRLER_PMU)
15529 -               pmu_poll();
15530 +               pmu_poll_adb();
15531  #endif /* CONFIG_ADB_PMU */
15532  #ifdef CONFIG_ADB_CUDA
15533         if (sys_ctrler == SYS_CTRLER_CUDA)
15534 diff -Nru a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
15535 --- a/arch/ppc64/Kconfig        Mon Aug 18 19:46:23 2003
15536 +++ b/arch/ppc64/Kconfig        Sun Aug 31 16:14:22 2003
15537 @@ -175,22 +175,6 @@
15538         bool
15539         default PCI
15540  
15541 -# only elf supported, a.out is not -- Cort
15542 -config KCORE_ELF
15543 -       bool
15544 -       depends on PROC_FS
15545 -       default y
15546 -       help
15547 -         If you enabled support for /proc file system then the file
15548 -         /proc/kcore will contain the kernel core image in ELF format. This
15549 -         can be used in gdb:
15550 -
15551 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
15552 -
15553 -         This is especially useful if you have compiled the kernel with the
15554 -         "-g" option to preserve debugging information. It is mainly used
15555 -         for examining kernel data structures on the live kernel.
15556 -
15557  source "fs/Kconfig.binfmt"
15558  
15559  source "drivers/pci/Kconfig"
15560 diff -Nru a/arch/ppc64/kernel/ioctl32.c b/arch/ppc64/kernel/ioctl32.c
15561 --- a/arch/ppc64/kernel/ioctl32.c       Fri Aug  8 14:53:47 2003
15562 +++ b/arch/ppc64/kernel/ioctl32.c       Sun Aug 31 16:14:44 2003
15563 @@ -725,7 +725,7 @@
15564  #define IOCTL_TABLE_START \
15565         struct ioctl_trans ioctl_start[] = {
15566  #define IOCTL_TABLE_END \
15567 -       }; struct ioctl_trans ioctl_end[0];
15568 +       };
15569  
15570  IOCTL_TABLE_START
15571  #include <linux/compat_ioctl.h>
15572 @@ -763,3 +763,5 @@
15573  HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
15574  HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
15575  IOCTL_TABLE_END
15576 +
15577 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
15578 diff -Nru a/arch/ppc64/kernel/proc_ppc64.c b/arch/ppc64/kernel/proc_ppc64.c
15579 --- a/arch/ppc64/kernel/proc_ppc64.c    Tue Mar 25 20:30:59 2003
15580 +++ b/arch/ppc64/kernel/proc_ppc64.c    Sun Aug 31 16:14:08 2003
15581 @@ -47,9 +47,9 @@
15582  static int     page_map_mmap( struct file *file, struct vm_area_struct *vma );
15583  
15584  static struct file_operations page_map_fops = {
15585 -       llseek: page_map_seek,
15586 -       read:   page_map_read,
15587 -       mmap:   page_map_mmap
15588 +       .llseek = page_map_seek,
15589 +       .read   = page_map_read,
15590 +       .mmap   = page_map_mmap
15591  };
15592  
15593  
15594 diff -Nru a/arch/ppc64/kernel/scanlog.c b/arch/ppc64/kernel/scanlog.c
15595 --- a/arch/ppc64/kernel/scanlog.c       Thu Feb 13 00:47:26 2003
15596 +++ b/arch/ppc64/kernel/scanlog.c       Sun Aug 31 16:14:08 2003
15597 @@ -190,11 +190,11 @@
15598  }
15599  
15600  struct file_operations scanlog_fops = {
15601 -       owner:          THIS_MODULE,
15602 -       read:           scanlog_read,
15603 -       write:          scanlog_write,
15604 -       open:           scanlog_open,
15605 -       release:        scanlog_release,
15606 +       .owner          = THIS_MODULE,
15607 +       .read           = scanlog_read,
15608 +       .write          = scanlog_write,
15609 +       .open           = scanlog_open,
15610 +       .release        = scanlog_release,
15611  };
15612  
15613  int __init scanlog_init(void)
15614 diff -Nru a/arch/s390/Kconfig b/arch/s390/Kconfig
15615 --- a/arch/s390/Kconfig Mon Jul 21 13:25:16 2003
15616 +++ b/arch/s390/Kconfig Sun Aug 31 16:14:22 2003
15617 @@ -217,10 +217,6 @@
15618  
15619  endchoice
15620  
15621 -config KCORE_ELF
15622 -       bool
15623 -       default y
15624 -
15625  source "fs/Kconfig.binfmt"
15626  
15627  config PROCESS_DEBUG
15628 diff -Nru a/arch/s390/kernel/compat_ioctl.c b/arch/s390/kernel/compat_ioctl.c
15629 --- a/arch/s390/kernel/compat_ioctl.c   Tue May 27 12:34:41 2003
15630 +++ b/arch/s390/kernel/compat_ioctl.c   Sun Aug 31 16:14:44 2003
15631 @@ -808,7 +808,7 @@
15632  #define IOCTL_TABLE_START \
15633         struct ioctl_trans ioctl_start[] = {
15634  #define IOCTL_TABLE_END \
15635 -       }; struct ioctl_trans ioctl_end[0];
15636 +       };
15637  
15638  IOCTL_TABLE_START
15639  #include <linux/compat_ioctl.h>
15640 @@ -899,3 +899,5 @@
15641  HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
15642  
15643  IOCTL_TABLE_END
15644 +
15645 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
15646 diff -Nru a/arch/sh/Kconfig b/arch/sh/Kconfig
15647 --- a/arch/sh/Kconfig   Sat Aug  2 14:26:16 2003
15648 +++ b/arch/sh/Kconfig   Sun Aug 31 16:14:22 2003
15649 @@ -729,40 +729,6 @@
15650  
15651  menu "Executable file formats"
15652  
15653 -choice
15654 -       prompt "Kernel core (/proc/kcore) format"
15655 -       depends on PROC_FS
15656 -       default KCORE_ELF
15657 -
15658 -config KCORE_ELF
15659 -       bool "ELF"
15660 -       ---help---
15661 -         If you enabled support for /proc file system then the file
15662 -         /proc/kcore will contain the kernel core image. This can be used
15663 -         in gdb:
15664 -
15665 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
15666 -
15667 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
15668 -         /proc/kcore appear in ELF core format as defined by the Executable
15669 -         and Linking Format specification. Selecting A.OUT will choose the
15670 -         old "a.out" format which may be necessary for some old versions
15671 -         of binutils or on some architectures.
15672 -
15673 -         This is especially useful if you have compiled the kernel with the
15674 -         "-g" option to preserve debugging information. It is mainly used
15675 -         for examining kernel data structures on the live kernel so if you
15676 -         don't understand what this means or are not a kernel hacker, just
15677 -         leave it at its default value ELF.
15678 -
15679 -config KCORE_AOUT
15680 -       bool "A.OUT"
15681 -       help
15682 -         Not necessary unless you're using a very out-of-date binutils
15683 -         version.  You probably want KCORE_ELF.
15684 -
15685 -endchoice
15686 -
15687  source "fs/Kconfig.binfmt"
15688  
15689  endmenu
15690 diff -Nru a/arch/sh/boards/adx/mach.c b/arch/sh/boards/adx/mach.c
15691 --- a/arch/sh/boards/adx/mach.c Mon May 19 16:04:36 2003
15692 +++ b/arch/sh/boards/adx/mach.c Sun Aug 31 16:14:08 2003
15693 @@ -24,41 +24,41 @@
15694   */
15695  
15696  struct sh_machine_vector mv_adx __initmv = {
15697 -       mv_nr_irqs:             48,
15698 +       .mv_nr_irqs             = 48,
15699  
15700 -       mv_inb:                 adx_inb,
15701 -       mv_inw:                 adx_inw,
15702 -       mv_inl:                 adx_inl,
15703 -       mv_outb:                adx_outb,
15704 -       mv_outw:                adx_outw,
15705 -       mv_outl:                adx_outl,
15706 -
15707 -       mv_inb_p:               adx_inb_p,
15708 -       mv_inw_p:               adx_inw,
15709 -       mv_inl_p:               adx_inl,
15710 -       mv_outb_p:              adx_outb_p,
15711 -       mv_outw_p:              adx_outw,
15712 -       mv_outl_p:              adx_outl,
15713 -
15714 -       mv_insb:                adx_insb,
15715 -       mv_insw:                adx_insw,
15716 -       mv_insl:                adx_insl,
15717 -       mv_outsb:               adx_outsb,
15718 -       mv_outsw:               adx_outsw,
15719 -       mv_outsl:               adx_outsl,
15720 -
15721 -       mv_readb:               adx_readb,
15722 -       mv_readw:               adx_readw,
15723 -       mv_readl:               adx_readl,
15724 -       mv_writeb:              adx_writeb,
15725 -       mv_writew:              adx_writew,
15726 -       mv_writel:              adx_writel,
15727 +       .mv_inb                 = adx_inb,
15728 +       .mv_inw                 = adx_inw,
15729 +       .mv_inl                 = adx_inl,
15730 +       .mv_outb                = adx_outb,
15731 +       .mv_outw                = adx_outw,
15732 +       .mv_outl                = adx_outl,
15733 +
15734 +       .mv_inb_p               = adx_inb_p,
15735 +       .mv_inw_p               = adx_inw,
15736 +       .mv_inl_p               = adx_inl,
15737 +       .mv_outb_p              = adx_outb_p,
15738 +       .mv_outw_p              = adx_outw,
15739 +       .mv_outl_p              = adx_outl,
15740 +
15741 +       .mv_insb                = adx_insb,
15742 +       .mv_insw                = adx_insw,
15743 +       .mv_insl                = adx_insl,
15744 +       .mv_outsb               = adx_outsb,
15745 +       .mv_outsw               = adx_outsw,
15746 +       .mv_outsl               = adx_outsl,
15747 +
15748 +       .mv_readb               = adx_readb,
15749 +       .mv_readw               = adx_readw,
15750 +       .mv_readl               = adx_readl,
15751 +       .mv_writeb              = adx_writeb,
15752 +       .mv_writew              = adx_writew,
15753 +       .mv_writel              = adx_writel,
15754  
15755 -       mv_ioremap:             adx_ioremap,
15756 -       mv_iounmap:             adx_iounmap,
15757 +       .mv_ioremap             = adx_ioremap,
15758 +       .mv_iounmap             = adx_iounmap,
15759  
15760 -       mv_isa_port2addr:       adx_isa_port2addr,
15761 +       .mv_isa_port2addr       = adx_isa_port2addr,
15762  
15763 -       mv_init_irq:            init_adx_IRQ,
15764 +       .mv_init_irq            = init_adx_IRQ,
15765  };
15766  ALIAS_MV(adx)
15767 diff -Nru a/arch/sh/boards/bigsur/mach.c b/arch/sh/boards/bigsur/mach.c
15768 --- a/arch/sh/boards/bigsur/mach.c      Sat Mar  2 08:57:07 2002
15769 +++ b/arch/sh/boards/bigsur/mach.c      Sun Aug 31 16:14:08 2003
15770 @@ -28,44 +28,44 @@
15771  extern void init_bigsur_IRQ(void);
15772  
15773  struct sh_machine_vector mv_bigsur __initmv = {
15774 -       mv_nr_irqs:             NR_IRQS,     // Defined in <asm/irq.h>
15775 -       mv_inb:                 bigsur_inb,
15776 -       mv_inw:                 bigsur_inw,
15777 -       mv_inl:                 bigsur_inl,
15778 -       mv_outb:                bigsur_outb,
15779 -       mv_outw:                bigsur_outw,
15780 -       mv_outl:                bigsur_outl,
15781 -
15782 -       mv_inb_p:               bigsur_inb_p,
15783 -       mv_inw_p:               bigsur_inw,
15784 -       mv_inl_p:               bigsur_inl,
15785 -       mv_outb_p:              bigsur_outb_p,
15786 -       mv_outw_p:              bigsur_outw,
15787 -       mv_outl_p:              bigsur_outl,
15788 -
15789 -       mv_insb:                bigsur_insb,
15790 -       mv_insw:                bigsur_insw,
15791 -       mv_insl:                bigsur_insl,
15792 -       mv_outsb:               bigsur_outsb,
15793 -       mv_outsw:               bigsur_outsw,
15794 -       mv_outsl:               bigsur_outsl,
15795 -
15796 -       mv_readb:               generic_readb,
15797 -       mv_readw:               generic_readw,
15798 -       mv_readl:               generic_readl,
15799 -       mv_writeb:              generic_writeb,
15800 -       mv_writew:              generic_writew,
15801 -       mv_writel:              generic_writel,
15802 +       .mv_nr_irqs             = NR_IRQS,     // Defined in <asm/irq.h>
15803 +       .mv_inb                 = bigsur_inb,
15804 +       .mv_inw                 = bigsur_inw,
15805 +       .mv_inl                 = bigsur_inl,
15806 +       .mv_outb                = bigsur_outb,
15807 +       .mv_outw                = bigsur_outw,
15808 +       .mv_outl                = bigsur_outl,
15809 +
15810 +       .mv_inb_p               = bigsur_inb_p,
15811 +       .mv_inw_p               = bigsur_inw,
15812 +       .mv_inl_p               = bigsur_inl,
15813 +       .mv_outb_p              = bigsur_outb_p,
15814 +       .mv_outw_p              = bigsur_outw,
15815 +       .mv_outl_p              = bigsur_outl,
15816 +
15817 +       .mv_insb                = bigsur_insb,
15818 +       .mv_insw                = bigsur_insw,
15819 +       .mv_insl                = bigsur_insl,
15820 +       .mv_outsb               = bigsur_outsb,
15821 +       .mv_outsw               = bigsur_outsw,
15822 +       .mv_outsl               = bigsur_outsl,
15823 +
15824 +       .mv_readb               = generic_readb,
15825 +       .mv_readw               = generic_readw,
15826 +       .mv_readl               = generic_readl,
15827 +       .mv_writeb              = generic_writeb,
15828 +       .mv_writew              = generic_writew,
15829 +       .mv_writel              = generic_writel,
15830  
15831 -       mv_ioremap:             generic_ioremap,
15832 -       mv_iounmap:             generic_iounmap,
15833 +       .mv_ioremap             = generic_ioremap,
15834 +       .mv_iounmap             = generic_iounmap,
15835  
15836 -       mv_isa_port2addr:       bigsur_isa_port2addr,
15837 -       mv_irq_demux:       bigsur_irq_demux,
15838 +       .mv_isa_port2addr       = bigsur_isa_port2addr,
15839 +       .mv_irq_demux       = bigsur_irq_demux,
15840  
15841 -       mv_init_irq:            init_bigsur_IRQ,
15842 +       .mv_init_irq            = init_bigsur_IRQ,
15843  #ifdef CONFIG_HEARTBEAT
15844 -       mv_heartbeat:           heartbeat_bigsur,
15845 +       .mv_heartbeat           = heartbeat_bigsur,
15846  #endif
15847  
15848  };
15849 diff -Nru a/arch/sh/boards/cat68701/mach.c b/arch/sh/boards/cat68701/mach.c
15850 --- a/arch/sh/boards/cat68701/mach.c    Sat Mar  2 08:57:07 2002
15851 +++ b/arch/sh/boards/cat68701/mach.c    Sun Aug 31 16:14:08 2003
15852 @@ -23,44 +23,44 @@
15853   */
15854  
15855  struct sh_machine_vector mv_cat68701 __initmv = {
15856 -       mv_nr_irqs:             32,
15857 -       mv_inb:                 cat68701_inb,
15858 -       mv_inw:                 cat68701_inw,
15859 -       mv_inl:                 cat68701_inl,
15860 -       mv_outb:                cat68701_outb,
15861 -       mv_outw:                cat68701_outw,
15862 -       mv_outl:                cat68701_outl,
15863 -
15864 -       mv_inb_p:               cat68701_inb_p,
15865 -       mv_inw_p:               cat68701_inw,
15866 -       mv_inl_p:               cat68701_inl,
15867 -       mv_outb_p:              cat68701_outb_p,
15868 -       mv_outw_p:              cat68701_outw,
15869 -       mv_outl_p:              cat68701_outl,
15870 -
15871 -       mv_insb:                cat68701_insb,
15872 -       mv_insw:                cat68701_insw,
15873 -       mv_insl:                cat68701_insl,
15874 -       mv_outsb:               cat68701_outsb,
15875 -       mv_outsw:               cat68701_outsw,
15876 -       mv_outsl:               cat68701_outsl,
15877 -
15878 -       mv_readb:               cat68701_readb,
15879 -       mv_readw:               cat68701_readw,
15880 -       mv_readl:               cat68701_readl,
15881 -       mv_writeb:              cat68701_writeb,
15882 -       mv_writew:              cat68701_writew,
15883 -       mv_writel:              cat68701_writel,
15884 +       .mv_nr_irqs             = 32,
15885 +       .mv_inb                 = cat68701_inb,
15886 +       .mv_inw                 = cat68701_inw,
15887 +       .mv_inl                 = cat68701_inl,
15888 +       .mv_outb                = cat68701_outb,
15889 +       .mv_outw                = cat68701_outw,
15890 +       .mv_outl                = cat68701_outl,
15891 +
15892 +       .mv_inb_p               = cat68701_inb_p,
15893 +       .mv_inw_p               = cat68701_inw,
15894 +       .mv_inl_p               = cat68701_inl,
15895 +       .mv_outb_p              = cat68701_outb_p,
15896 +       .mv_outw_p              = cat68701_outw,
15897 +       .mv_outl_p              = cat68701_outl,
15898 +
15899 +       .mv_insb                = cat68701_insb,
15900 +       .mv_insw                = cat68701_insw,
15901 +       .mv_insl                = cat68701_insl,
15902 +       .mv_outsb               = cat68701_outsb,
15903 +       .mv_outsw               = cat68701_outsw,
15904 +       .mv_outsl               = cat68701_outsl,
15905 +
15906 +       .mv_readb               = cat68701_readb,
15907 +       .mv_readw               = cat68701_readw,
15908 +       .mv_readl               = cat68701_readl,
15909 +       .mv_writeb              = cat68701_writeb,
15910 +       .mv_writew              = cat68701_writew,
15911 +       .mv_writel              = cat68701_writel,
15912  
15913 -       mv_ioremap:             cat68701_ioremap,
15914 -       mv_iounmap:             cat68701_iounmap,
15915 +       .mv_ioremap             = cat68701_ioremap,
15916 +       .mv_iounmap             = cat68701_iounmap,
15917  
15918 -       mv_isa_port2addr:       cat68701_isa_port2addr,
15919 -       mv_irq_demux:           cat68701_irq_demux,
15920 +       .mv_isa_port2addr       = cat68701_isa_port2addr,
15921 +       .mv_irq_demux           = cat68701_irq_demux,
15922  
15923 -       mv_init_irq:            init_cat68701_IRQ,
15924 +       .mv_init_irq            = init_cat68701_IRQ,
15925  #ifdef CONFIG_HEARTBEAT
15926 -       mv_heartbeat:           heartbeat_cat68701,
15927 +       .mv_heartbeat           = heartbeat_cat68701,
15928  #endif
15929  };
15930  ALIAS_MV(cat68701)
15931 diff -Nru a/arch/sh/boards/cqreek/mach.c b/arch/sh/boards/cqreek/mach.c
15932 --- a/arch/sh/boards/cqreek/mach.c      Sat Jun 14 11:02:09 2003
15933 +++ b/arch/sh/boards/cqreek/mach.c      Sun Aug 31 16:14:08 2003
15934 @@ -21,46 +21,46 @@
15935  
15936  struct sh_machine_vector mv_cqreek __initmv = {
15937  #if defined(CONFIG_CPU_SH4)
15938 -       mv_nr_irqs:             48,
15939 +       .mv_nr_irqs             = 48,
15940  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
15941 -       mv_nr_irqs:             32,
15942 +       .mv_nr_irqs             = 32,
15943  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
15944 -       mv_nr_irqs:             61,
15945 +       .mv_nr_irqs             = 61,
15946  #endif
15947  
15948 -       mv_inb:                 generic_inb,
15949 -       mv_inw:                 generic_inw,
15950 -       mv_inl:                 generic_inl,
15951 -       mv_outb:                generic_outb,
15952 -       mv_outw:                generic_outw,
15953 -       mv_outl:                generic_outl,
15954 -
15955 -       mv_inb_p:               generic_inb_p,
15956 -       mv_inw_p:               generic_inw_p,
15957 -       mv_inl_p:               generic_inl_p,
15958 -       mv_outb_p:              generic_outb_p,
15959 -       mv_outw_p:              generic_outw_p,
15960 -       mv_outl_p:              generic_outl_p,
15961 -
15962 -       mv_insb:                generic_insb,
15963 -       mv_insw:                generic_insw,
15964 -       mv_insl:                generic_insl,
15965 -       mv_outsb:               generic_outsb,
15966 -       mv_outsw:               generic_outsw,
15967 -       mv_outsl:               generic_outsl,
15968 -
15969 -       mv_readb:               generic_readb,
15970 -       mv_readw:               generic_readw,
15971 -       mv_readl:               generic_readl,
15972 -       mv_writeb:              generic_writeb,
15973 -       mv_writew:              generic_writew,
15974 -       mv_writel:              generic_writel,
15975 +       .mv_inb                 = generic_inb,
15976 +       .mv_inw                 = generic_inw,
15977 +       .mv_inl                 = generic_inl,
15978 +       .mv_outb                = generic_outb,
15979 +       .mv_outw                = generic_outw,
15980 +       .mv_outl                = generic_outl,
15981 +
15982 +       .mv_inb_p               = generic_inb_p,
15983 +       .mv_inw_p               = generic_inw_p,
15984 +       .mv_inl_p               = generic_inl_p,
15985 +       .mv_outb_p              = generic_outb_p,
15986 +       .mv_outw_p              = generic_outw_p,
15987 +       .mv_outl_p              = generic_outl_p,
15988 +
15989 +       .mv_insb                = generic_insb,
15990 +       .mv_insw                = generic_insw,
15991 +       .mv_insl                = generic_insl,
15992 +       .mv_outsb               = generic_outsb,
15993 +       .mv_outsw               = generic_outsw,
15994 +       .mv_outsl               = generic_outsl,
15995 +
15996 +       .mv_readb               = generic_readb,
15997 +       .mv_readw               = generic_readw,
15998 +       .mv_readl               = generic_readl,
15999 +       .mv_writeb              = generic_writeb,
16000 +       .mv_writew              = generic_writew,
16001 +       .mv_writel              = generic_writel,
16002  
16003 -       mv_init_irq:            init_cqreek_IRQ,
16004 +       .mv_init_irq            = init_cqreek_IRQ,
16005  
16006 -       mv_isa_port2addr:       cqreek_port2addr,
16007 +       .mv_isa_port2addr       = cqreek_port2addr,
16008  
16009 -       mv_ioremap:             generic_ioremap,
16010 -       mv_iounmap:             generic_iounmap,
16011 +       .mv_ioremap             = generic_ioremap,
16012 +       .mv_iounmap             = generic_iounmap,
16013  };
16014  ALIAS_MV(cqreek)
16015 diff -Nru a/arch/sh/boards/dmida/mach.c b/arch/sh/boards/dmida/mach.c
16016 --- a/arch/sh/boards/dmida/mach.c       Mon May 19 16:04:36 2003
16017 +++ b/arch/sh/boards/dmida/mach.c       Sun Aug 31 16:14:08 2003
16018 @@ -30,42 +30,42 @@
16019   */
16020  
16021  struct sh_machine_vector mv_dmida __initmv = {
16022 -       mv_name:                "DMIDA",
16023 +       .mv_name                = "DMIDA",
16024  
16025 -       mv_nr_irqs:             HD64465_IRQ_BASE+HD64465_IRQ_NUM,
16026 +       .mv_nr_irqs             = HD64465_IRQ_BASE+HD64465_IRQ_NUM,
16027  
16028 -       mv_inb:                 hd64465_inb,
16029 -       mv_inw:                 hd64465_inw,
16030 -       mv_inl:                 hd64465_inl,
16031 -       mv_outb:                hd64465_outb,
16032 -       mv_outw:                hd64465_outw,
16033 -       mv_outl:                hd64465_outl,
16034 -
16035 -       mv_inb_p:               hd64465_inb_p,
16036 -       mv_inw_p:               hd64465_inw,
16037 -       mv_inl_p:               hd64465_inl,
16038 -       mv_outb_p:              hd64465_outb_p,
16039 -       mv_outw_p:              hd64465_outw,
16040 -       mv_outl_p:              hd64465_outl,
16041 -
16042 -       mv_insb:                hd64465_insb,
16043 -       mv_insw:                hd64465_insw,
16044 -       mv_insl:                hd64465_insl,
16045 -       mv_outsb:               hd64465_outsb,
16046 -       mv_outsw:               hd64465_outsw,
16047 -       mv_outsl:               hd64465_outsl,
16048 -
16049 -       mv_readb:               generic_readb,
16050 -       mv_readw:               generic_readw,
16051 -       mv_readl:               generic_readl,
16052 -       mv_writeb:              generic_writeb,
16053 -       mv_writew:              generic_writew,
16054 -       mv_writel:              generic_writel,
16055 +       .mv_inb                 = hd64465_inb,
16056 +       .mv_inw                 = hd64465_inw,
16057 +       .mv_inl                 = hd64465_inl,
16058 +       .mv_outb                = hd64465_outb,
16059 +       .mv_outw                = hd64465_outw,
16060 +       .mv_outl                = hd64465_outl,
16061 +
16062 +       .mv_inb_p               = hd64465_inb_p,
16063 +       .mv_inw_p               = hd64465_inw,
16064 +       .mv_inl_p               = hd64465_inl,
16065 +       .mv_outb_p              = hd64465_outb_p,
16066 +       .mv_outw_p              = hd64465_outw,
16067 +       .mv_outl_p              = hd64465_outl,
16068 +
16069 +       .mv_insb                = hd64465_insb,
16070 +       .mv_insw                = hd64465_insw,
16071 +       .mv_insl                = hd64465_insl,
16072 +       .mv_outsb               = hd64465_outsb,
16073 +       .mv_outsw               = hd64465_outsw,
16074 +       .mv_outsl               = hd64465_outsl,
16075 +
16076 +       .mv_readb               = generic_readb,
16077 +       .mv_readw               = generic_readw,
16078 +       .mv_readl               = generic_readl,
16079 +       .mv_writeb              = generic_writeb,
16080 +       .mv_writew              = generic_writew,
16081 +       .mv_writel              = generic_writel,
16082  
16083 -       mv_irq_demux:           hd64465_irq_demux,
16084 +       .mv_irq_demux           = hd64465_irq_demux,
16085  
16086 -       mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
16087 -       mv_rtc_settimeofday:    sh_rtc_settimeofday,
16088 +       .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
16089 +       .mv_rtc_settimeofday    = sh_rtc_settimeofday,
16090  };
16091  ALIAS_MV(dmida)
16092  
16093 diff -Nru a/arch/sh/boards/dreamcast/irq.c b/arch/sh/boards/dreamcast/irq.c
16094 --- a/arch/sh/boards/dreamcast/irq.c    Sat Jun 14 11:02:09 2003
16095 +++ b/arch/sh/boards/dreamcast/irq.c    Sun Aug 31 16:14:08 2003
16096 @@ -110,13 +110,13 @@
16097  }
16098  
16099  struct hw_interrupt_type systemasic_int = {
16100 -        typename:       "System ASIC",
16101 -        startup:        startup_systemasic_irq,
16102 -        shutdown:       shutdown_systemasic_irq,
16103 -        enable:         enable_systemasic_irq,
16104 -        disable:        disable_systemasic_irq,
16105 -        ack:            ack_systemasic_irq,
16106 -        end:            end_systemasic_irq,
16107 +        .typename       = "System ASIC",
16108 +        .startup        = startup_systemasic_irq,
16109 +        .shutdown       = shutdown_systemasic_irq,
16110 +        .enable         = enable_systemasic_irq,
16111 +        .disable        = disable_systemasic_irq,
16112 +        .ack            = ack_systemasic_irq,
16113 +        .end            = end_systemasic_irq,
16114  };
16115  
16116  /*
16117 diff -Nru a/arch/sh/boards/dreamcast/mach.c b/arch/sh/boards/dreamcast/mach.c
16118 --- a/arch/sh/boards/dreamcast/mach.c   Mon May 19 16:04:36 2003
16119 +++ b/arch/sh/boards/dreamcast/mach.c   Sun Aug 31 16:14:08 2003
16120 @@ -21,40 +21,40 @@
16121   */
16122  
16123  struct sh_machine_vector mv_dreamcast __initmv = {
16124 -       mv_nr_irqs:             NR_IRQS,
16125 +       .mv_nr_irqs             = NR_IRQS,
16126  
16127 -       mv_inb:                 generic_inb,
16128 -       mv_inw:                 generic_inw,
16129 -       mv_inl:                 generic_inl,
16130 -       mv_outb:                generic_outb,
16131 -       mv_outw:                generic_outw,
16132 -       mv_outl:                generic_outl,
16133 -
16134 -       mv_inb_p:               generic_inb_p,
16135 -       mv_inw_p:               generic_inw,
16136 -       mv_inl_p:               generic_inl,
16137 -       mv_outb_p:              generic_outb_p,
16138 -       mv_outw_p:              generic_outw,
16139 -       mv_outl_p:              generic_outl,
16140 -
16141 -       mv_insb:                generic_insb,
16142 -       mv_insw:                generic_insw,
16143 -       mv_insl:                generic_insl,
16144 -       mv_outsb:               generic_outsb,
16145 -       mv_outsw:               generic_outsw,
16146 -       mv_outsl:               generic_outsl,
16147 -
16148 -       mv_readb:               generic_readb,
16149 -       mv_readw:               generic_readw,
16150 -       mv_readl:               generic_readl,
16151 -       mv_writeb:              generic_writeb,
16152 -       mv_writew:              generic_writew,
16153 -       mv_writel:              generic_writel,
16154 +       .mv_inb                 = generic_inb,
16155 +       .mv_inw                 = generic_inw,
16156 +       .mv_inl                 = generic_inl,
16157 +       .mv_outb                = generic_outb,
16158 +       .mv_outw                = generic_outw,
16159 +       .mv_outl                = generic_outl,
16160 +
16161 +       .mv_inb_p               = generic_inb_p,
16162 +       .mv_inw_p               = generic_inw,
16163 +       .mv_inl_p               = generic_inl,
16164 +       .mv_outb_p              = generic_outb_p,
16165 +       .mv_outw_p              = generic_outw,
16166 +       .mv_outl_p              = generic_outl,
16167 +
16168 +       .mv_insb                = generic_insb,
16169 +       .mv_insw                = generic_insw,
16170 +       .mv_insl                = generic_insl,
16171 +       .mv_outsb               = generic_outsb,
16172 +       .mv_outsw               = generic_outsw,
16173 +       .mv_outsl               = generic_outsl,
16174 +
16175 +       .mv_readb               = generic_readb,
16176 +       .mv_readw               = generic_readw,
16177 +       .mv_readl               = generic_readl,
16178 +       .mv_writeb              = generic_writeb,
16179 +       .mv_writew              = generic_writew,
16180 +       .mv_writel              = generic_writel,
16181  
16182 -       mv_ioremap:             generic_ioremap,
16183 -       mv_iounmap:             generic_iounmap,
16184 +       .mv_ioremap             = generic_ioremap,
16185 +       .mv_iounmap             = generic_iounmap,
16186  
16187 -       mv_isa_port2addr:       dreamcast_isa_port2addr,
16188 -       mv_irq_demux:           systemasic_irq_demux,
16189 +       .mv_isa_port2addr       = dreamcast_isa_port2addr,
16190 +       .mv_irq_demux           = systemasic_irq_demux,
16191  };
16192  ALIAS_MV(dreamcast)
16193 diff -Nru a/arch/sh/boards/ec3104/irq.c b/arch/sh/boards/ec3104/irq.c
16194 --- a/arch/sh/boards/ec3104/irq.c       Sat Jun 14 11:02:09 2003
16195 +++ b/arch/sh/boards/ec3104/irq.c       Sun Aug 31 16:14:08 2003
16196 @@ -169,13 +169,13 @@
16197  }
16198  
16199  static struct hw_interrupt_type ec3104_int = {
16200 -        typename:       "EC3104",
16201 -        enable:         enable_ec3104_irq,
16202 -        disable:        disable_ec3104_irq,
16203 -        ack:            mask_and_ack_ec3104_irq,
16204 -        end:            end_ec3104_irq,
16205 -        startup:        startup_ec3104_irq,
16206 -        shutdown:       shutdown_ec3104_irq,
16207 +        .typename       = "EC3104",
16208 +        .enable         = enable_ec3104_irq,
16209 +        .disable        = disable_ec3104_irq,
16210 +        .ack            = mask_and_ack_ec3104_irq,
16211 +        .end            = end_ec3104_irq,
16212 +        .startup        = startup_ec3104_irq,
16213 +        .shutdown       = shutdown_ec3104_irq,
16214  };
16215  
16216  /* Yuck.  the _demux API is ugly */
16217 diff -Nru a/arch/sh/boards/ec3104/mach.c b/arch/sh/boards/ec3104/mach.c
16218 --- a/arch/sh/boards/ec3104/mach.c      Sat Jan 19 10:54:19 2002
16219 +++ b/arch/sh/boards/ec3104/mach.c      Sun Aug 31 16:14:08 2003
16220 @@ -28,42 +28,42 @@
16221   */
16222  
16223  struct sh_machine_vector mv_ec3104 __initmv = {
16224 -       mv_name:                "EC3104",
16225 +       .mv_name                = "EC3104",
16226  
16227 -       mv_nr_irqs:             96,
16228 +       .mv_nr_irqs             = 96,
16229  
16230 -       mv_inb:                 ec3104_inb,
16231 -       mv_inw:                 ec3104_inw,
16232 -       mv_inl:                 ec3104_inl,
16233 -       mv_outb:                ec3104_outb,
16234 -       mv_outw:                ec3104_outw,
16235 -       mv_outl:                ec3104_outl,
16236 -
16237 -       mv_inb_p:               generic_inb_p,
16238 -       mv_inw_p:               generic_inw,
16239 -       mv_inl_p:               generic_inl,
16240 -       mv_outb_p:              generic_outb_p,
16241 -       mv_outw_p:              generic_outw,
16242 -       mv_outl_p:              generic_outl,
16243 -
16244 -       mv_insb:                generic_insb,
16245 -       mv_insw:                generic_insw,
16246 -       mv_insl:                generic_insl,
16247 -       mv_outsb:               generic_outsb,
16248 -       mv_outsw:               generic_outsw,
16249 -       mv_outsl:               generic_outsl,
16250 -
16251 -       mv_readb:               generic_readb,
16252 -       mv_readw:               generic_readw,
16253 -       mv_readl:               generic_readl,
16254 -       mv_writeb:              generic_writeb,
16255 -       mv_writew:              generic_writew,
16256 -       mv_writel:              generic_writel,
16257 +       .mv_inb                 = ec3104_inb,
16258 +       .mv_inw                 = ec3104_inw,
16259 +       .mv_inl                 = ec3104_inl,
16260 +       .mv_outb                = ec3104_outb,
16261 +       .mv_outw                = ec3104_outw,
16262 +       .mv_outl                = ec3104_outl,
16263 +
16264 +       .mv_inb_p               = generic_inb_p,
16265 +       .mv_inw_p               = generic_inw,
16266 +       .mv_inl_p               = generic_inl,
16267 +       .mv_outb_p              = generic_outb_p,
16268 +       .mv_outw_p              = generic_outw,
16269 +       .mv_outl_p              = generic_outl,
16270 +
16271 +       .mv_insb                = generic_insb,
16272 +       .mv_insw                = generic_insw,
16273 +       .mv_insl                = generic_insl,
16274 +       .mv_outsb               = generic_outsb,
16275 +       .mv_outsw               = generic_outsw,
16276 +       .mv_outsl               = generic_outsl,
16277 +
16278 +       .mv_readb               = generic_readb,
16279 +       .mv_readw               = generic_readw,
16280 +       .mv_readl               = generic_readl,
16281 +       .mv_writeb              = generic_writeb,
16282 +       .mv_writew              = generic_writew,
16283 +       .mv_writel              = generic_writel,
16284  
16285 -       mv_irq_demux:           ec3104_irq_demux,
16286 +       .mv_irq_demux           = ec3104_irq_demux,
16287  
16288 -       mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
16289 -       mv_rtc_settimeofday:    sh_rtc_settimeofday,
16290 +       .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
16291 +       .mv_rtc_settimeofday    = sh_rtc_settimeofday,
16292  };
16293  
16294  ALIAS_MV(ec3104)
16295 diff -Nru a/arch/sh/boards/harp/mach.c b/arch/sh/boards/harp/mach.c
16296 --- a/arch/sh/boards/harp/mach.c        Sat Mar  2 08:57:07 2002
16297 +++ b/arch/sh/boards/harp/mach.c        Sun Aug 31 16:14:08 2003
16298 @@ -26,46 +26,46 @@
16299   */
16300  
16301  struct sh_machine_vector mv_harp __initmv = {
16302 -       mv_nr_irqs:             89 + HD64465_IRQ_NUM,
16303 +       .mv_nr_irqs             = 89 + HD64465_IRQ_NUM,
16304  
16305 -       mv_inb:                 hd64465_inb,
16306 -       mv_inw:                 hd64465_inw,
16307 -       mv_inl:                 hd64465_inl,
16308 -       mv_outb:                hd64465_outb,
16309 -       mv_outw:                hd64465_outw,
16310 -       mv_outl:                hd64465_outl,
16311 -
16312 -       mv_inb_p:               hd64465_inb_p,
16313 -       mv_inw_p:               hd64465_inw,
16314 -       mv_inl_p:               hd64465_inl,
16315 -       mv_outb_p:              hd64465_outb_p,
16316 -       mv_outw_p:              hd64465_outw,
16317 -       mv_outl_p:              hd64465_outl,
16318 -
16319 -       mv_insb:                hd64465_insb,
16320 -       mv_insw:                hd64465_insw,
16321 -       mv_insl:                hd64465_insl,
16322 -       mv_outsb:               hd64465_outsb,
16323 -       mv_outsw:               hd64465_outsw,
16324 -       mv_outsl:               hd64465_outsl,
16325 -
16326 -       mv_readb:               generic_readb,
16327 -       mv_readw:               generic_readw,
16328 -       mv_readl:               generic_readl,
16329 -       mv_writeb:              generic_writeb,
16330 -       mv_writew:              generic_writew,
16331 -       mv_writel:              generic_writel,
16332 +       .mv_inb                 = hd64465_inb,
16333 +       .mv_inw                 = hd64465_inw,
16334 +       .mv_inl                 = hd64465_inl,
16335 +       .mv_outb                = hd64465_outb,
16336 +       .mv_outw                = hd64465_outw,
16337 +       .mv_outl                = hd64465_outl,
16338 +
16339 +       .mv_inb_p               = hd64465_inb_p,
16340 +       .mv_inw_p               = hd64465_inw,
16341 +       .mv_inl_p               = hd64465_inl,
16342 +       .mv_outb_p              = hd64465_outb_p,
16343 +       .mv_outw_p              = hd64465_outw,
16344 +       .mv_outl_p              = hd64465_outl,
16345 +
16346 +       .mv_insb                = hd64465_insb,
16347 +       .mv_insw                = hd64465_insw,
16348 +       .mv_insl                = hd64465_insl,
16349 +       .mv_outsb               = hd64465_outsb,
16350 +       .mv_outsw               = hd64465_outsw,
16351 +       .mv_outsl               = hd64465_outsl,
16352 +
16353 +       .mv_readb               = generic_readb,
16354 +       .mv_readw               = generic_readw,
16355 +       .mv_readl               = generic_readl,
16356 +       .mv_writeb              = generic_writeb,
16357 +       .mv_writew              = generic_writew,
16358 +       .mv_writel              = generic_writel,
16359  
16360 -        mv_ioremap:             generic_ioremap,
16361 -        mv_iounmap:             generic_iounmap,
16362 +        .mv_ioremap             = generic_ioremap,
16363 +        .mv_iounmap             = generic_iounmap,
16364   
16365 -        mv_isa_port2addr:       hd64465_isa_port2addr,
16366 +        .mv_isa_port2addr       = hd64465_isa_port2addr,
16367  
16368  #ifdef CONFIG_PCI
16369 -       mv_init_irq:            init_harp_irq,
16370 +       .mv_init_irq            = init_harp_irq,
16371  #endif
16372  #ifdef CONFIG_HEARTBEAT
16373 -       mv_heartbeat:           heartbeat_harp,
16374 +       .mv_heartbeat           = heartbeat_harp,
16375  #endif
16376  };
16377  
16378 diff -Nru a/arch/sh/boards/hp6xx/hp620/mach.c b/arch/sh/boards/hp6xx/hp620/mach.c
16379 --- a/arch/sh/boards/hp6xx/hp620/mach.c Mon May 19 16:04:36 2003
16380 +++ b/arch/sh/boards/hp6xx/hp620/mach.c Sun Aug 31 16:14:08 2003
16381 @@ -24,41 +24,41 @@
16382   */
16383  
16384  struct sh_machine_vector mv_hp620 __initmv = {
16385 -        mv_name:                "hp620",
16386 +        .mv_name                = "hp620",
16387  
16388 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
16389 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
16390  
16391 -        mv_inb:                 hd64461_inb,
16392 -        mv_inw:                 hd64461_inw,
16393 -        mv_inl:                 hd64461_inl,
16394 -        mv_outb:                hd64461_outb,
16395 -        mv_outw:                hd64461_outw,
16396 -        mv_outl:                hd64461_outl,
16397 -
16398 -        mv_inb_p:               hd64461_inb_p,
16399 -        mv_inw_p:               hd64461_inw,
16400 -        mv_inl_p:               hd64461_inl,
16401 -        mv_outb_p:              hd64461_outb_p,
16402 -        mv_outw_p:              hd64461_outw,
16403 -        mv_outl_p:              hd64461_outl,
16404 -
16405 -        mv_insb:                hd64461_insb,
16406 -        mv_insw:                hd64461_insw,
16407 -        mv_insl:                hd64461_insl,
16408 -        mv_outsb:               hd64461_outsb,
16409 -        mv_outsw:               hd64461_outsw,
16410 -        mv_outsl:               hd64461_outsl,
16411 -
16412 -        mv_readb:               generic_readb,
16413 -        mv_readw:               generic_readw,
16414 -        mv_readl:               generic_readl,
16415 -        mv_writeb:              generic_writeb,
16416 -        mv_writew:              generic_writew,
16417 -        mv_writel:              generic_writel,
16418 +        .mv_inb                 = hd64461_inb,
16419 +        .mv_inw                 = hd64461_inw,
16420 +        .mv_inl                 = hd64461_inl,
16421 +        .mv_outb                = hd64461_outb,
16422 +        .mv_outw                = hd64461_outw,
16423 +        .mv_outl                = hd64461_outl,
16424 +
16425 +        .mv_inb_p               = hd64461_inb_p,
16426 +        .mv_inw_p               = hd64461_inw,
16427 +        .mv_inl_p               = hd64461_inl,
16428 +        .mv_outb_p              = hd64461_outb_p,
16429 +        .mv_outw_p              = hd64461_outw,
16430 +        .mv_outl_p              = hd64461_outl,
16431 +
16432 +        .mv_insb                = hd64461_insb,
16433 +        .mv_insw                = hd64461_insw,
16434 +        .mv_insl                = hd64461_insl,
16435 +        .mv_outsb               = hd64461_outsb,
16436 +        .mv_outsw               = hd64461_outsw,
16437 +        .mv_outsl               = hd64461_outsl,
16438 +
16439 +        .mv_readb               = generic_readb,
16440 +        .mv_readw               = generic_readw,
16441 +        .mv_readl               = generic_readl,
16442 +        .mv_writeb              = generic_writeb,
16443 +        .mv_writew              = generic_writew,
16444 +        .mv_writel              = generic_writel,
16445  
16446 -        mv_irq_demux:           hd64461_irq_demux,
16447 +        .mv_irq_demux           = hd64461_irq_demux,
16448  
16449 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
16450 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
16451 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
16452 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
16453  };
16454  ALIAS_MV(hp620)
16455 diff -Nru a/arch/sh/boards/hp6xx/hp680/mach.c b/arch/sh/boards/hp6xx/hp680/mach.c
16456 --- a/arch/sh/boards/hp6xx/hp680/mach.c Mon May 19 16:04:37 2003
16457 +++ b/arch/sh/boards/hp6xx/hp680/mach.c Sun Aug 31 16:14:08 2003
16458 @@ -20,41 +20,41 @@
16459  #include <asm/irq.h>
16460  
16461  struct sh_machine_vector mv_hp680 __initmv = {
16462 -        mv_name:                "hp680",
16463 +        .mv_name                = "hp680",
16464  
16465 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
16466 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
16467  
16468 -        mv_inb:                 hd64461_inb,
16469 -        mv_inw:                 hd64461_inw,
16470 -        mv_inl:                 hd64461_inl,
16471 -        mv_outb:                hd64461_outb,
16472 -        mv_outw:                hd64461_outw,
16473 -        mv_outl:                hd64461_outl,
16474 -
16475 -        mv_inb_p:               hd64461_inb_p,
16476 -        mv_inw_p:               hd64461_inw,
16477 -        mv_inl_p:               hd64461_inl,
16478 -        mv_outb_p:              hd64461_outb_p,
16479 -        mv_outw_p:              hd64461_outw,
16480 -        mv_outl_p:              hd64461_outl,
16481 -
16482 -        mv_insb:                hd64461_insb,
16483 -        mv_insw:                hd64461_insw,
16484 -        mv_insl:                hd64461_insl,
16485 -        mv_outsb:               hd64461_outsb,
16486 -        mv_outsw:               hd64461_outsw,
16487 -        mv_outsl:               hd64461_outsl,
16488 -
16489 -        mv_readb:               generic_readb,
16490 -        mv_readw:               generic_readw,
16491 -        mv_readl:               generic_readl,
16492 -        mv_writeb:              generic_writeb,
16493 -        mv_writew:              generic_writew,
16494 -        mv_writel:              generic_writel,
16495 +        .mv_inb                 = hd64461_inb,
16496 +        .mv_inw                 = hd64461_inw,
16497 +        .mv_inl                 = hd64461_inl,
16498 +        .mv_outb                = hd64461_outb,
16499 +        .mv_outw                = hd64461_outw,
16500 +        .mv_outl                = hd64461_outl,
16501 +
16502 +        .mv_inb_p               = hd64461_inb_p,
16503 +        .mv_inw_p               = hd64461_inw,
16504 +        .mv_inl_p               = hd64461_inl,
16505 +        .mv_outb_p              = hd64461_outb_p,
16506 +        .mv_outw_p              = hd64461_outw,
16507 +        .mv_outl_p              = hd64461_outl,
16508 +
16509 +        .mv_insb                = hd64461_insb,
16510 +        .mv_insw                = hd64461_insw,
16511 +        .mv_insl                = hd64461_insl,
16512 +        .mv_outsb               = hd64461_outsb,
16513 +        .mv_outsw               = hd64461_outsw,
16514 +        .mv_outsl               = hd64461_outsl,
16515 +
16516 +        .mv_readb               = generic_readb,
16517 +        .mv_readw               = generic_readw,
16518 +        .mv_readl               = generic_readl,
16519 +        .mv_writeb              = generic_writeb,
16520 +        .mv_writew              = generic_writew,
16521 +        .mv_writel              = generic_writel,
16522  
16523 -        mv_irq_demux:           hd64461_irq_demux,
16524 +        .mv_irq_demux           = hd64461_irq_demux,
16525  
16526 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
16527 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
16528 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
16529 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
16530  };
16531  ALIAS_MV(hp680)
16532 diff -Nru a/arch/sh/boards/hp6xx/hp690/mach.c b/arch/sh/boards/hp6xx/hp690/mach.c
16533 --- a/arch/sh/boards/hp6xx/hp690/mach.c Mon May 19 16:04:37 2003
16534 +++ b/arch/sh/boards/hp6xx/hp690/mach.c Sun Aug 31 16:14:08 2003
16535 @@ -20,41 +20,41 @@
16536  #include <asm/irq.h>
16537  
16538  struct sh_machine_vector mv_hp690 __initmv = {
16539 -        mv_name:                "hp690",
16540 +        .mv_name                = "hp690",
16541  
16542 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
16543 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
16544  
16545 -        mv_inb:                 hd64461_inb,
16546 -        mv_inw:                 hd64461_inw,
16547 -        mv_inl:                 hd64461_inl,
16548 -        mv_outb:                hd64461_outb,
16549 -        mv_outw:                hd64461_outw,
16550 -        mv_outl:                hd64461_outl,
16551 -
16552 -        mv_inb_p:               hd64461_inb_p,
16553 -        mv_inw_p:               hd64461_inw,
16554 -        mv_inl_p:               hd64461_inl,
16555 -        mv_outb_p:              hd64461_outb_p,
16556 -        mv_outw_p:              hd64461_outw,
16557 -        mv_outl_p:              hd64461_outl,
16558 -
16559 -        mv_insb:                hd64461_insb,
16560 -        mv_insw:                hd64461_insw,
16561 -        mv_insl:                hd64461_insl,
16562 -        mv_outsb:               hd64461_outsb,
16563 -        mv_outsw:               hd64461_outsw,
16564 -        mv_outsl:               hd64461_outsl,
16565 -
16566 -        mv_readb:               generic_readb,
16567 -        mv_readw:               generic_readw,
16568 -        mv_readl:               generic_readl,
16569 -        mv_writeb:              generic_writeb,
16570 -        mv_writew:              generic_writew,
16571 -        mv_writel:              generic_writel,
16572 +        .mv_inb                 = hd64461_inb,
16573 +        .mv_inw                 = hd64461_inw,
16574 +        .mv_inl                 = hd64461_inl,
16575 +        .mv_outb                = hd64461_outb,
16576 +        .mv_outw                = hd64461_outw,
16577 +        .mv_outl                = hd64461_outl,
16578 +
16579 +        .mv_inb_p               = hd64461_inb_p,
16580 +        .mv_inw_p               = hd64461_inw,
16581 +        .mv_inl_p               = hd64461_inl,
16582 +        .mv_outb_p              = hd64461_outb_p,
16583 +        .mv_outw_p              = hd64461_outw,
16584 +        .mv_outl_p              = hd64461_outl,
16585 +
16586 +        .mv_insb                = hd64461_insb,
16587 +        .mv_insw                = hd64461_insw,
16588 +        .mv_insl                = hd64461_insl,
16589 +        .mv_outsb               = hd64461_outsb,
16590 +        .mv_outsw               = hd64461_outsw,
16591 +        .mv_outsl               = hd64461_outsl,
16592 +
16593 +        .mv_readb               = generic_readb,
16594 +        .mv_readw               = generic_readw,
16595 +        .mv_readl               = generic_readl,
16596 +        .mv_writeb              = generic_writeb,
16597 +        .mv_writew              = generic_writew,
16598 +        .mv_writel              = generic_writel,
16599  
16600 -        mv_irq_demux:           hd64461_irq_demux,
16601 +        .mv_irq_demux           = hd64461_irq_demux,
16602  
16603 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
16604 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
16605 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
16606 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
16607  };
16608  ALIAS_MV(hp690)
16609 diff -Nru a/arch/sh/boards/overdrive/mach.c b/arch/sh/boards/overdrive/mach.c
16610 --- a/arch/sh/boards/overdrive/mach.c   Sat Jun 14 11:02:09 2003
16611 +++ b/arch/sh/boards/overdrive/mach.c   Sun Aug 31 16:14:08 2003
16612 @@ -28,46 +28,46 @@
16613   */
16614  
16615  struct sh_machine_vector mv_od __initmv = {
16616 -       mv_nr_irqs:             48,
16617 +       .mv_nr_irqs             = 48,
16618  
16619 -       mv_inb:                 od_inb,
16620 -       mv_inw:                 od_inw,
16621 -       mv_inl:                 od_inl,
16622 -       mv_outb:                od_outb,
16623 -       mv_outw:                od_outw,
16624 -       mv_outl:                od_outl,
16625 -
16626 -       mv_inb_p:               od_inb_p,
16627 -       mv_inw_p:               od_inw_p,
16628 -       mv_inl_p:               od_inl_p,
16629 -       mv_outb_p:              od_outb_p,
16630 -       mv_outw_p:              od_outw_p,
16631 -       mv_outl_p:              od_outl_p,
16632 -
16633 -       mv_insb:                od_insb,
16634 -       mv_insw:                od_insw,
16635 -       mv_insl:                od_insl,
16636 -       mv_outsb:               od_outsb,
16637 -       mv_outsw:               od_outsw,
16638 -       mv_outsl:               od_outsl,
16639 -
16640 -       mv_readb:               generic_readb,
16641 -       mv_readw:               generic_readw,
16642 -       mv_readl:               generic_readl,
16643 -       mv_writeb:              generic_writeb,
16644 -       mv_writew:              generic_writew,
16645 -       mv_writel:              generic_writel,
16646 +       .mv_inb                 = od_inb,
16647 +       .mv_inw                 = od_inw,
16648 +       .mv_inl                 = od_inl,
16649 +       .mv_outb                = od_outb,
16650 +       .mv_outw                = od_outw,
16651 +       .mv_outl                = od_outl,
16652 +
16653 +       .mv_inb_p               = od_inb_p,
16654 +       .mv_inw_p               = od_inw_p,
16655 +       .mv_inl_p               = od_inl_p,
16656 +       .mv_outb_p              = od_outb_p,
16657 +       .mv_outw_p              = od_outw_p,
16658 +       .mv_outl_p              = od_outl_p,
16659 +
16660 +       .mv_insb                = od_insb,
16661 +       .mv_insw                = od_insw,
16662 +       .mv_insl                = od_insl,
16663 +       .mv_outsb               = od_outsb,
16664 +       .mv_outsw               = od_outsw,
16665 +       .mv_outsl               = od_outsl,
16666 +
16667 +       .mv_readb               = generic_readb,
16668 +       .mv_readw               = generic_readw,
16669 +       .mv_readl               = generic_readl,
16670 +       .mv_writeb              = generic_writeb,
16671 +       .mv_writew              = generic_writew,
16672 +       .mv_writel              = generic_writel,
16673  
16674 -       mv_ioremap:             generic_ioremap,
16675 -       mv_iounmap:             generic_iounmap,
16676 +       .mv_ioremap             = generic_ioremap,
16677 +       .mv_iounmap             = generic_iounmap,
16678  
16679 -       mv_isa_port2addr:       generic_isa_port2addr,
16680 +       .mv_isa_port2addr       = generic_isa_port2addr,
16681  
16682  #ifdef CONFIG_PCI
16683 -       mv_init_irq:            init_overdrive_irq,
16684 +       .mv_init_irq            = init_overdrive_irq,
16685  #endif
16686  #ifdef CONFIG_HEARTBEAT
16687 -       mv_heartbeat:           heartbeat_od,
16688 +       .mv_heartbeat           = heartbeat_od,
16689  #endif
16690  };
16691  
16692 diff -Nru a/arch/sh/boards/saturn/irq.c b/arch/sh/boards/saturn/irq.c
16693 --- a/arch/sh/boards/saturn/irq.c       Sat Jun 14 11:02:09 2003
16694 +++ b/arch/sh/boards/saturn/irq.c       Sun Aug 31 16:14:08 2003
16695 @@ -102,13 +102,13 @@
16696  }
16697  
16698  static struct hw_interrupt_type saturn_int = {
16699 -       typename:       "Saturn",
16700 -       enable:         enable_saturn_irq,
16701 -       disable:        disable_saturn_irq,
16702 -       ack:            mask_and_ack_saturn_irq,
16703 -       end:            end_saturn_irq,
16704 -       startup:        startup_saturn_irq,
16705 -       shutdown:       shutdown_saturn_irq,
16706 +       .typename       = "Saturn",
16707 +       .enable         = enable_saturn_irq,
16708 +       .disable        = disable_saturn_irq,
16709 +       .ack            = mask_and_ack_saturn_irq,
16710 +       .end            = end_saturn_irq,
16711 +       .startup        = startup_saturn_irq,
16712 +       .shutdown       = shutdown_saturn_irq,
16713  };
16714  
16715  int saturn_irq_demux(int irq_nr)
16716 diff -Nru a/arch/sh/boards/saturn/mach.c b/arch/sh/boards/saturn/mach.c
16717 --- a/arch/sh/boards/saturn/mach.c      Mon May 19 16:04:39 2003
16718 +++ b/arch/sh/boards/saturn/mach.c      Sun Aug 31 16:14:08 2003
16719 @@ -18,41 +18,41 @@
16720   * The Machine Vector
16721   */
16722  struct sh_machine_vector mv_saturn __initmv = {
16723 -        mv_nr_irqs:             80,    /* Fix this later */
16724 +        .mv_nr_irqs             = 80,  /* Fix this later */
16725  
16726 -        mv_inb:                 generic_inb,
16727 -        mv_inw:                 generic_inw,
16728 -        mv_inl:                 generic_inl,
16729 -        mv_outb:                generic_outb,
16730 -        mv_outw:                generic_outw,
16731 -        mv_outl:                generic_outl,
16732 -
16733 -        mv_inb_p:               generic_inb_p,
16734 -        mv_inw_p:               generic_inw_p,
16735 -        mv_inl_p:               generic_inl_p,
16736 -        mv_outb_p:              generic_outb_p,
16737 -        mv_outw_p:              generic_outw_p,
16738 -        mv_outl_p:              generic_outl_p,
16739 -
16740 -        mv_insb:                generic_insb,
16741 -        mv_insw:                generic_insw,
16742 -        mv_insl:                generic_insl,
16743 -        mv_outsb:               generic_outsb,
16744 -        mv_outsw:               generic_outsw,
16745 -        mv_outsl:               generic_outsl,
16746 -
16747 -        mv_readb:               generic_readb,
16748 -        mv_readw:               generic_readw,
16749 -        mv_readl:               generic_readl,
16750 -        mv_writeb:              generic_writeb,
16751 -        mv_writew:              generic_writew,
16752 -        mv_writel:              generic_writel,
16753 +        .mv_inb                 = generic_inb,
16754 +        .mv_inw                 = generic_inw,
16755 +        .mv_inl                 = generic_inl,
16756 +        .mv_outb                = generic_outb,
16757 +        .mv_outw                = generic_outw,
16758 +        .mv_outl                = generic_outl,
16759 +
16760 +        .mv_inb_p               = generic_inb_p,
16761 +        .mv_inw_p               = generic_inw_p,
16762 +        .mv_inl_p               = generic_inl_p,
16763 +        .mv_outb_p              = generic_outb_p,
16764 +        .mv_outw_p              = generic_outw_p,
16765 +        .mv_outl_p              = generic_outl_p,
16766 +
16767 +        .mv_insb                = generic_insb,
16768 +        .mv_insw                = generic_insw,
16769 +        .mv_insl                = generic_insl,
16770 +        .mv_outsb               = generic_outsb,
16771 +        .mv_outsw               = generic_outsw,
16772 +        .mv_outsl               = generic_outsl,
16773 +
16774 +        .mv_readb               = generic_readb,
16775 +        .mv_readw               = generic_readw,
16776 +        .mv_readl               = generic_readl,
16777 +        .mv_writeb              = generic_writeb,
16778 +        .mv_writew              = generic_writew,
16779 +        .mv_writel              = generic_writel,
16780  
16781 -        mv_isa_port2addr:       saturn_isa_port2addr,
16782 -       mv_irq_demux:           saturn_irq_demux,
16783 +        .mv_isa_port2addr       = saturn_isa_port2addr,
16784 +       .mv_irq_demux           = saturn_irq_demux,
16785  
16786 -        mv_ioremap:             saturn_ioremap,
16787 -        mv_iounmap:             saturn_iounmap,
16788 +        .mv_ioremap             = saturn_ioremap,
16789 +        .mv_iounmap             = saturn_iounmap,
16790  };
16791  
16792  ALIAS_MV(saturn)
16793 diff -Nru a/arch/sh/boards/se/770x/mach.c b/arch/sh/boards/se/770x/mach.c
16794 --- a/arch/sh/boards/se/770x/mach.c     Mon May 19 16:04:39 2003
16795 +++ b/arch/sh/boards/se/770x/mach.c     Sun Aug 31 16:14:08 2003
16796 @@ -28,49 +28,49 @@
16797  
16798  struct sh_machine_vector mv_se __initmv = {
16799  #if defined(CONFIG_CPU_SH4)
16800 -       mv_nr_irqs:             48,
16801 +       .mv_nr_irqs             = 48,
16802  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
16803 -       mv_nr_irqs:             32,
16804 +       .mv_nr_irqs             = 32,
16805  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
16806 -       mv_nr_irqs:             61,
16807 +       .mv_nr_irqs             = 61,
16808  #endif
16809  
16810 -       mv_inb:                 se_inb,
16811 -       mv_inw:                 se_inw,
16812 -       mv_inl:                 se_inl,
16813 -       mv_outb:                se_outb,
16814 -       mv_outw:                se_outw,
16815 -       mv_outl:                se_outl,
16816 -
16817 -       mv_inb_p:               se_inb_p,
16818 -       mv_inw_p:               se_inw,
16819 -       mv_inl_p:               se_inl,
16820 -       mv_outb_p:              se_outb_p,
16821 -       mv_outw_p:              se_outw,
16822 -       mv_outl_p:              se_outl,
16823 -
16824 -       mv_insb:                se_insb,
16825 -       mv_insw:                se_insw,
16826 -       mv_insl:                se_insl,
16827 -       mv_outsb:               se_outsb,
16828 -       mv_outsw:               se_outsw,
16829 -       mv_outsl:               se_outsl,
16830 -
16831 -       mv_readb:               se_readb,
16832 -       mv_readw:               se_readw,
16833 -       mv_readl:               se_readl,
16834 -       mv_writeb:              se_writeb,
16835 -       mv_writew:              se_writew,
16836 -       mv_writel:              se_writel,
16837 +       .mv_inb                 = se_inb,
16838 +       .mv_inw                 = se_inw,
16839 +       .mv_inl                 = se_inl,
16840 +       .mv_outb                = se_outb,
16841 +       .mv_outw                = se_outw,
16842 +       .mv_outl                = se_outl,
16843 +
16844 +       .mv_inb_p               = se_inb_p,
16845 +       .mv_inw_p               = se_inw,
16846 +       .mv_inl_p               = se_inl,
16847 +       .mv_outb_p              = se_outb_p,
16848 +       .mv_outw_p              = se_outw,
16849 +       .mv_outl_p              = se_outl,
16850 +
16851 +       .mv_insb                = se_insb,
16852 +       .mv_insw                = se_insw,
16853 +       .mv_insl                = se_insl,
16854 +       .mv_outsb               = se_outsb,
16855 +       .mv_outsw               = se_outsw,
16856 +       .mv_outsl               = se_outsl,
16857 +
16858 +       .mv_readb               = se_readb,
16859 +       .mv_readw               = se_readw,
16860 +       .mv_readl               = se_readl,
16861 +       .mv_writeb              = se_writeb,
16862 +       .mv_writew              = se_writew,
16863 +       .mv_writel              = se_writel,
16864  
16865 -       mv_ioremap:             generic_ioremap,
16866 -       mv_iounmap:             generic_iounmap,
16867 +       .mv_ioremap             = generic_ioremap,
16868 +       .mv_iounmap             = generic_iounmap,
16869  
16870 -       mv_isa_port2addr:       se_isa_port2addr,
16871 +       .mv_isa_port2addr       = se_isa_port2addr,
16872  
16873 -       mv_init_irq:            init_se_IRQ,
16874 +       .mv_init_irq            = init_se_IRQ,
16875  #ifdef CONFIG_HEARTBEAT
16876 -       mv_heartbeat:           heartbeat_se,
16877 +       .mv_heartbeat           = heartbeat_se,
16878  #endif
16879  };
16880  ALIAS_MV(se)
16881 diff -Nru a/arch/sh/boards/se/7751/mach.c b/arch/sh/boards/se/7751/mach.c
16882 --- a/arch/sh/boards/se/7751/mach.c     Mon May 19 16:04:39 2003
16883 +++ b/arch/sh/boards/se/7751/mach.c     Sun Aug 31 16:14:08 2003
16884 @@ -26,44 +26,44 @@
16885   */
16886  
16887  struct sh_machine_vector mv_7751se __initmv = {
16888 -       mv_nr_irqs:             72,
16889 +       .mv_nr_irqs             = 72,
16890  
16891 -       mv_inb:                 sh7751se_inb,
16892 -       mv_inw:                 sh7751se_inw,
16893 -       mv_inl:                 sh7751se_inl,
16894 -       mv_outb:                sh7751se_outb,
16895 -       mv_outw:                sh7751se_outw,
16896 -       mv_outl:                sh7751se_outl,
16897 -
16898 -       mv_inb_p:               sh7751se_inb_p,
16899 -       mv_inw_p:               sh7751se_inw,
16900 -       mv_inl_p:               sh7751se_inl,
16901 -       mv_outb_p:              sh7751se_outb_p,
16902 -       mv_outw_p:              sh7751se_outw,
16903 -       mv_outl_p:              sh7751se_outl,
16904 -
16905 -       mv_insb:                sh7751se_insb,
16906 -       mv_insw:                sh7751se_insw,
16907 -       mv_insl:                sh7751se_insl,
16908 -       mv_outsb:               sh7751se_outsb,
16909 -       mv_outsw:               sh7751se_outsw,
16910 -       mv_outsl:               sh7751se_outsl,
16911 -
16912 -       mv_readb:               sh7751se_readb,
16913 -       mv_readw:               sh7751se_readw,
16914 -       mv_readl:               sh7751se_readl,
16915 -       mv_writeb:              sh7751se_writeb,
16916 -       mv_writew:              sh7751se_writew,
16917 -       mv_writel:              sh7751se_writel,
16918 +       .mv_inb                 = sh7751se_inb,
16919 +       .mv_inw                 = sh7751se_inw,
16920 +       .mv_inl                 = sh7751se_inl,
16921 +       .mv_outb                = sh7751se_outb,
16922 +       .mv_outw                = sh7751se_outw,
16923 +       .mv_outl                = sh7751se_outl,
16924 +
16925 +       .mv_inb_p               = sh7751se_inb_p,
16926 +       .mv_inw_p               = sh7751se_inw,
16927 +       .mv_inl_p               = sh7751se_inl,
16928 +       .mv_outb_p              = sh7751se_outb_p,
16929 +       .mv_outw_p              = sh7751se_outw,
16930 +       .mv_outl_p              = sh7751se_outl,
16931 +
16932 +       .mv_insb                = sh7751se_insb,
16933 +       .mv_insw                = sh7751se_insw,
16934 +       .mv_insl                = sh7751se_insl,
16935 +       .mv_outsb               = sh7751se_outsb,
16936 +       .mv_outsw               = sh7751se_outsw,
16937 +       .mv_outsl               = sh7751se_outsl,
16938 +
16939 +       .mv_readb               = sh7751se_readb,
16940 +       .mv_readw               = sh7751se_readw,
16941 +       .mv_readl               = sh7751se_readl,
16942 +       .mv_writeb              = sh7751se_writeb,
16943 +       .mv_writew              = sh7751se_writew,
16944 +       .mv_writel              = sh7751se_writel,
16945  
16946 -       mv_ioremap:             generic_ioremap,
16947 -       mv_iounmap:             generic_iounmap,
16948 +       .mv_ioremap             = generic_ioremap,
16949 +       .mv_iounmap             = generic_iounmap,
16950  
16951 -       mv_isa_port2addr:       sh7751se_isa_port2addr,
16952 +       .mv_isa_port2addr       = sh7751se_isa_port2addr,
16953  
16954 -       mv_init_irq:            init_7751se_IRQ,
16955 +       .mv_init_irq            = init_7751se_IRQ,
16956  #ifdef CONFIG_HEARTBEAT
16957 -       mv_heartbeat:           heartbeat_7751se,
16958 +       .mv_heartbeat           = heartbeat_7751se,
16959  #endif
16960  };
16961  ALIAS_MV(7751se)
16962 diff -Nru a/arch/sh/boards/sh2000/mach.c b/arch/sh/boards/sh2000/mach.c
16963 --- a/arch/sh/boards/sh2000/mach.c      Mon May 19 16:04:40 2003
16964 +++ b/arch/sh/boards/sh2000/mach.c      Sun Aug 31 16:14:08 2003
16965 @@ -19,39 +19,39 @@
16966   */
16967  
16968  struct sh_machine_vector mv_sh2000 __initmv = {
16969 -        mv_nr_irqs:             80,
16970 +        .mv_nr_irqs             = 80,
16971  
16972 -        mv_inb:                 generic_inb,
16973 -        mv_inw:                 generic_inw,
16974 -        mv_inl:                 generic_inl,
16975 -        mv_outb:                generic_outb,
16976 -        mv_outw:                generic_outw,
16977 -        mv_outl:                generic_outl,
16978 -
16979 -        mv_inb_p:               generic_inb_p,
16980 -        mv_inw_p:               generic_inw_p,
16981 -        mv_inl_p:               generic_inl_p,
16982 -        mv_outb_p:              generic_outb_p,
16983 -        mv_outw_p:              generic_outw_p,
16984 -        mv_outl_p:              generic_outl_p,
16985 -
16986 -        mv_insb:                generic_insb,
16987 -        mv_insw:                generic_insw,
16988 -        mv_insl:                generic_insl,
16989 -        mv_outsb:               generic_outsb,
16990 -        mv_outsw:               generic_outsw,
16991 -        mv_outsl:               generic_outsl,
16992 -
16993 -        mv_readb:               generic_readb,
16994 -        mv_readw:               generic_readw,
16995 -        mv_readl:               generic_readl,
16996 -        mv_writeb:              generic_writeb,
16997 -        mv_writew:              generic_writew,
16998 -        mv_writel:              generic_writel,
16999 +        .mv_inb                 = generic_inb,
17000 +        .mv_inw                 = generic_inw,
17001 +        .mv_inl                 = generic_inl,
17002 +        .mv_outb                = generic_outb,
17003 +        .mv_outw                = generic_outw,
17004 +        .mv_outl                = generic_outl,
17005 +
17006 +        .mv_inb_p               = generic_inb_p,
17007 +        .mv_inw_p               = generic_inw_p,
17008 +        .mv_inl_p               = generic_inl_p,
17009 +        .mv_outb_p              = generic_outb_p,
17010 +        .mv_outw_p              = generic_outw_p,
17011 +        .mv_outl_p              = generic_outl_p,
17012 +
17013 +        .mv_insb                = generic_insb,
17014 +        .mv_insw                = generic_insw,
17015 +        .mv_insl                = generic_insl,
17016 +        .mv_outsb               = generic_outsb,
17017 +        .mv_outsw               = generic_outsw,
17018 +        .mv_outsl               = generic_outsl,
17019 +
17020 +        .mv_readb               = generic_readb,
17021 +        .mv_readw               = generic_readw,
17022 +        .mv_readl               = generic_readl,
17023 +        .mv_writeb              = generic_writeb,
17024 +        .mv_writew              = generic_writew,
17025 +        .mv_writel              = generic_writel,
17026  
17027 -        mv_isa_port2addr:       sh2000_isa_port2addr,
17028 +        .mv_isa_port2addr       = sh2000_isa_port2addr,
17029  
17030 -        mv_ioremap:             generic_ioremap,
17031 -        mv_iounmap:             generic_iounmap,
17032 +        .mv_ioremap             = generic_ioremap,
17033 +        .mv_iounmap             = generic_iounmap,
17034  };
17035  ALIAS_MV(sh2000)
17036 diff -Nru a/arch/sh/boards/unknown/mach.c b/arch/sh/boards/unknown/mach.c
17037 --- a/arch/sh/boards/unknown/mach.c     Fri Jan 10 04:26:40 2003
17038 +++ b/arch/sh/boards/unknown/mach.c     Sun Aug 31 16:14:08 2003
17039 @@ -24,44 +24,44 @@
17040  
17041  struct sh_machine_vector mv_unknown __initmv = {
17042  #if defined(CONFIG_CPU_SH4)
17043 -       mv_nr_irqs:             48,
17044 +       .mv_nr_irqs             = 48,
17045  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
17046 -       mv_nr_irqs:             32,
17047 +       .mv_nr_irqs             = 32,
17048  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
17049 -       mv_nr_irqs:             61,
17050 +       .mv_nr_irqs             = 61,
17051  #endif
17052  
17053 -       mv_inb:                 unknown_inb,
17054 -       mv_inw:                 unknown_inw,
17055 -       mv_inl:                 unknown_inl,
17056 -       mv_outb:                unknown_outb,
17057 -       mv_outw:                unknown_outw,
17058 -       mv_outl:                unknown_outl,
17059 -
17060 -       mv_inb_p:               unknown_inb_p,
17061 -       mv_inw_p:               unknown_inw_p,
17062 -       mv_inl_p:               unknown_inl_p,
17063 -       mv_outb_p:              unknown_outb_p,
17064 -       mv_outw_p:              unknown_outw_p,
17065 -       mv_outl_p:              unknown_outl_p,
17066 -
17067 -       mv_insb:                unknown_insb,
17068 -       mv_insw:                unknown_insw,
17069 -       mv_insl:                unknown_insl,
17070 -       mv_outsb:               unknown_outsb,
17071 -       mv_outsw:               unknown_outsw,
17072 -       mv_outsl:               unknown_outsl,
17073 -
17074 -       mv_readb:               unknown_readb,
17075 -       mv_readw:               unknown_readw,
17076 -       mv_readl:               unknown_readl,
17077 -       mv_writeb:              unknown_writeb,
17078 -       mv_writew:              unknown_writew,
17079 -       mv_writel:              unknown_writel,
17080 +       .mv_inb                 = unknown_inb,
17081 +       .mv_inw                 = unknown_inw,
17082 +       .mv_inl                 = unknown_inl,
17083 +       .mv_outb                = unknown_outb,
17084 +       .mv_outw                = unknown_outw,
17085 +       .mv_outl                = unknown_outl,
17086 +
17087 +       .mv_inb_p               = unknown_inb_p,
17088 +       .mv_inw_p               = unknown_inw_p,
17089 +       .mv_inl_p               = unknown_inl_p,
17090 +       .mv_outb_p              = unknown_outb_p,
17091 +       .mv_outw_p              = unknown_outw_p,
17092 +       .mv_outl_p              = unknown_outl_p,
17093 +
17094 +       .mv_insb                = unknown_insb,
17095 +       .mv_insw                = unknown_insw,
17096 +       .mv_insl                = unknown_insl,
17097 +       .mv_outsb               = unknown_outsb,
17098 +       .mv_outsw               = unknown_outsw,
17099 +       .mv_outsl               = unknown_outsl,
17100 +
17101 +       .mv_readb               = unknown_readb,
17102 +       .mv_readw               = unknown_readw,
17103 +       .mv_readl               = unknown_readl,
17104 +       .mv_writeb              = unknown_writeb,
17105 +       .mv_writew              = unknown_writew,
17106 +       .mv_writel              = unknown_writel,
17107  
17108 -       mv_ioremap:             unknown_ioremap,
17109 -       mv_iounmap:             unknown_iounmap,
17110 +       .mv_ioremap             = unknown_ioremap,
17111 +       .mv_iounmap             = unknown_iounmap,
17112  
17113 -       mv_isa_port2addr:       unknown_isa_port2addr,
17114 +       .mv_isa_port2addr       = unknown_isa_port2addr,
17115  };
17116  ALIAS_MV(unknown)
17117 diff -Nru a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c
17118 --- a/arch/sh/cchips/hd6446x/hd64465/setup.c    Mon Nov  4 07:33:57 2002
17119 +++ b/arch/sh/cchips/hd6446x/hd64465/setup.c    Sun Aug 31 16:14:08 2003
17120 @@ -89,13 +89,13 @@
17121  
17122  
17123  static struct hw_interrupt_type hd64465_irq_type = {
17124 -       typename:       "HD64465-IRQ",
17125 -       startup:        startup_hd64465_irq,
17126 -       shutdown:       shutdown_hd64465_irq,
17127 -       enable:         enable_hd64465_irq,
17128 -       disable:        disable_hd64465_irq,
17129 -       ack:            mask_and_ack_hd64465,
17130 -       end:            end_hd64465_irq
17131 +       .typename       = "HD64465-IRQ",
17132 +       .startup        = startup_hd64465_irq,
17133 +       .shutdown       = shutdown_hd64465_irq,
17134 +       .enable         = enable_hd64465_irq,
17135 +       .disable        = disable_hd64465_irq,
17136 +       .ack            = mask_and_ack_hd64465,
17137 +       .end            = end_hd64465_irq
17138  };
17139  
17140  
17141 diff -Nru a/arch/sparc/Kconfig b/arch/sparc/Kconfig
17142 --- a/arch/sparc/Kconfig        Sat Aug  2 14:26:16 2003
17143 +++ b/arch/sparc/Kconfig        Sun Aug 31 16:14:22 2003
17144 @@ -254,29 +254,6 @@
17145           <file:Documentation/modules.txt>.
17146           The module will be called openpromfs.  If unsure, say M.
17147  
17148 -config KCORE_ELF
17149 -       bool
17150 -       depends on PROC_FS
17151 -       default y
17152 -       ---help---
17153 -         If you enabled support for /proc file system then the file
17154 -         /proc/kcore will contain the kernel core image. This can be used
17155 -         in gdb:
17156 -
17157 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
17158 -
17159 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
17160 -         /proc/kcore appear in ELF core format as defined by the Executable
17161 -         and Linking Format specification. Selecting A.OUT will choose the
17162 -         old "a.out" format which may be necessary for some old versions
17163 -         of binutils or on some architectures.
17164 -
17165 -         This is especially useful if you have compiled the kernel with the
17166 -         "-g" option to preserve debugging information. It is mainly used
17167 -         for examining kernel data structures on the live kernel so if you
17168 -         don't understand what this means or are not a kernel hacker, just
17169 -         leave it at its default value ELF.
17170 -
17171  source "fs/Kconfig.binfmt"
17172  
17173  config SUNOS_EMUL
17174 diff -Nru a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile
17175 --- a/arch/sparc/boot/Makefile  Sat Jul 12 22:05:29 2003
17176 +++ b/arch/sparc/boot/Makefile  Thu Aug 28 00:18:36 2003
17177 @@ -19,7 +19,7 @@
17178  
17179  BTOBJS := $(HEAD_Y) $(INIT_Y)
17180  BTLIBS := $(CORE_Y) $(LIBS_Y) $(DRIVERS_Y) $(NET_Y)
17181 -LDFLAGS_image := -T arch/sparc/vmlinux.lds.s $(BTOBJS) --start-group $(BTLIBS) --end-group
17182 +LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds.s $(BTOBJS) --start-group $(BTLIBS) --end-group
17183  
17184  # Actual linking
17185  $(obj)/image: $(obj)/btfix.o FORCE
17186 diff -Nru a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
17187 --- a/arch/sparc/kernel/entry.S Sat Aug 16 14:13:18 2003
17188 +++ b/arch/sparc/kernel/entry.S Wed Aug 27 23:52:25 2003
17189 @@ -38,7 +38,7 @@
17190  
17191  #define curptr      g6
17192  
17193 -#define NR_SYSCALLS 266      /* Each OS is different... */
17194 +#define NR_SYSCALLS 267      /* Each OS is different... */
17195  
17196  /* These are just handy. */
17197  #define _SV    save    %sp, -STACKFRAME_SZ, %sp
17198 diff -Nru a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
17199 --- a/arch/sparc/kernel/ioport.c        Sun May 25 17:00:00 2003
17200 +++ b/arch/sparc/kernel/ioport.c        Thu Aug 28 01:15:54 2003
17201 @@ -511,6 +511,26 @@
17202         }
17203  }
17204  
17205 +/*
17206 + * Same as pci_map_single, but with pages.
17207 + */
17208 +dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
17209 +                       unsigned long offset, size_t size, int direction)
17210 +{
17211 +       if (direction == PCI_DMA_NONE)
17212 +               BUG();
17213 +       /* IIep is write-through, not flushing. */
17214 +       return page_to_phys(page) + offset;
17215 +}
17216 +
17217 +void pci_unmap_page(struct pci_dev *hwdev,
17218 +                       dma_addr_t dma_address, size_t size, int direction)
17219 +{
17220 +       if (direction == PCI_DMA_NONE)
17221 +               BUG();
17222 +       /* mmu_inval_dma_area XXX */
17223 +}
17224 +
17225  /* Map a set of buffers described by scatterlist in streaming
17226   * mode for DMA.  This is the scather-gather version of the
17227   * above pci_map_single interface.  Here the scatter gather list
17228 diff -Nru a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c
17229 --- a/arch/sparc/kernel/sys_sunos.c     Sun May 25 17:00:00 2003
17230 +++ b/arch/sparc/kernel/sys_sunos.c     Tue Aug 26 09:25:41 2003
17231 @@ -92,8 +92,8 @@
17232          * SunOS is so stupid some times... hmph!
17233          */
17234         if (file) {
17235 -               if(major(file->f_dentry->d_inode->i_rdev) == MEM_MAJOR &&
17236 -                  minor(file->f_dentry->d_inode->i_rdev) == 5) {
17237 +               if(imajor(file->f_dentry->d_inode) == MEM_MAJOR &&
17238 +                  iminor(file->f_dentry->d_inode) == 5) {
17239                         flags |= MAP_ANONYMOUS;
17240                         fput(file);
17241                         file = 0;
17242 diff -Nru a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
17243 --- a/arch/sparc/kernel/systbls.S       Sat Aug 16 14:13:18 2003
17244 +++ b/arch/sparc/kernel/systbls.S       Thu Aug 28 01:35:18 2003
17245 @@ -72,7 +72,7 @@
17246  /*250*/        .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
17247  /*255*/        .long sys_nis_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
17248  /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
17249 -/*261*/        .long sys_timer_delete, sys_nis_syscall
17250 +/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall
17251  
17252  #ifdef CONFIG_SUNOS_EMUL
17253         /* Now the SunOS syscall table. */
17254 @@ -171,6 +171,6 @@
17255         .long sunos_nosys
17256  /*260*/        .long sunos_nosys, sunos_nosys, sunos_nosys
17257         .long sunos_nosys, sunos_nosys, sunos_nosys
17258 -       .long sunos_nosys
17259 +       .long sunos_nosys, sunos_nosys
17260  
17261  #endif
17262 diff -Nru a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
17263 --- a/arch/sparc64/Kconfig      Sat Aug  2 14:26:53 2003
17264 +++ b/arch/sparc64/Kconfig      Sun Aug 31 16:14:22 2003
17265 @@ -363,29 +363,6 @@
17266           <file:Documentation/modules.txt>.
17267           The module will be called openpromfs.  If unsure, say M.
17268  
17269 -config KCORE_ELF
17270 -       bool
17271 -       depends on PROC_FS
17272 -       default y
17273 -       ---help---
17274 -         If you enabled support for /proc file system then the file
17275 -         /proc/kcore will contain the kernel core image. This can be used
17276 -         in gdb:
17277 -
17278 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
17279 -
17280 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
17281 -         /proc/kcore appear in ELF core format as defined by the Executable
17282 -         and Linking Format specification. Selecting A.OUT will choose the
17283 -         old "a.out" format which may be necessary for some old versions
17284 -         of binutils or on some architectures.
17285 -
17286 -         This is especially useful if you have compiled the kernel with the
17287 -         "-g" option to preserve debugging information. It is mainly used
17288 -         for examining kernel data structures on the live kernel so if you
17289 -         don't understand what this means or are not a kernel hacker, just
17290 -         leave it at its default value ELF.
17291 -
17292  config SPARC32_COMPAT
17293         bool "Kernel support for Linux/Sparc 32bit binary compatibility"
17294         help
17295 diff -Nru a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
17296 --- a/arch/sparc64/kernel/entry.S       Sat Aug 16 14:13:18 2003
17297 +++ b/arch/sparc64/kernel/entry.S       Wed Aug 27 23:52:25 2003
17298 @@ -26,7 +26,7 @@
17299  
17300  #define curptr      g6
17301  
17302 -#define NR_SYSCALLS 266      /* Each OS is different... */
17303 +#define NR_SYSCALLS 267      /* Each OS is different... */
17304  
17305         .text
17306         .align          32
17307 diff -Nru a/arch/sparc64/kernel/ioctl32.c b/arch/sparc64/kernel/ioctl32.c
17308 --- a/arch/sparc64/kernel/ioctl32.c     Fri Aug  8 14:53:47 2003
17309 +++ b/arch/sparc64/kernel/ioctl32.c     Sun Aug 31 16:14:44 2003
17310 @@ -1388,7 +1388,7 @@
17311  #define IOCTL_TABLE_START \
17312         struct ioctl_trans ioctl_start[] = {
17313  #define IOCTL_TABLE_END \
17314 -       }; struct ioctl_trans ioctl_end[0];
17315 +       };
17316  
17317  IOCTL_TABLE_START
17318  #include <linux/compat_ioctl.h>
17319 @@ -1583,3 +1583,5 @@
17320  HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
17321  /* take care of sizeof(sizeof()) breakage */
17322  IOCTL_TABLE_END
17323 +
17324 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
17325 diff -Nru a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
17326 --- a/arch/sparc64/kernel/irq.c Tue Aug 19 19:00:31 2003
17327 +++ b/arch/sparc64/kernel/irq.c Thu Aug 28 17:10:27 2003
17328 @@ -1097,6 +1097,18 @@
17329  
17330         memset(__irq_work + smp_processor_id(), 0, sizeof(*workp));
17331  
17332 +       /* Make sure we are called with PSTATE_IE disabled.  */
17333 +       __asm__ __volatile__("rdpr      %%pstate, %0\n\t"
17334 +                            : "=r" (tmp));
17335 +       if (tmp & PSTATE_IE) {
17336 +               prom_printf("BUG: init_irqwork_curcpu() called with "
17337 +                           "PSTATE_IE enabled, bailing.\n");
17338 +               __asm__ __volatile__("mov       %%i7, %0\n\t"
17339 +                                    : "=r" (tmp));
17340 +               prom_printf("BUG: Called from %lx\n", tmp);
17341 +               prom_halt();
17342 +       }
17343 +
17344         /* Set interrupt globals.  */
17345         workp = &__irq_work[smp_processor_id()];
17346         __asm__ __volatile__(
17347 @@ -1105,7 +1117,7 @@
17348         "mov    %2, %%g6\n\t"
17349         "wrpr   %0, 0x0, %%pstate\n\t"
17350         : "=&r" (tmp)
17351 -       : "i" (PSTATE_IG | PSTATE_IE), "r" (workp));
17352 +       : "i" (PSTATE_IG), "r" (workp));
17353  }
17354  
17355  /* Only invoked on boot processor. */
17356 diff -Nru a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
17357 --- a/arch/sparc64/kernel/pci_psycho.c  Fri Jul 25 08:40:56 2003
17358 +++ b/arch/sparc64/kernel/pci_psycho.c  Sun Aug 24 03:18:58 2003
17359 @@ -874,6 +874,46 @@
17360  #define PSYCHO_PCI_AFAR_A      0x2018UL
17361  #define PSYCHO_PCI_AFAR_B      0x4018UL
17362  
17363 +static irqreturn_t psycho_pcierr_intr_other(struct pci_pbm_info *pbm, int is_pbm_a)
17364 +{
17365 +       unsigned long csr_reg, csr, csr_error_bits;
17366 +       irqreturn_t ret = IRQ_NONE;
17367 +       u16 stat;
17368 +
17369 +       if (is_pbm_a) {
17370 +               csr_reg = pbm->controller_regs + PSYCHO_PCIA_CTRL;
17371 +       } else {
17372 +               csr_reg = pbm->controller_regs + PSYCHO_PCIB_CTRL;
17373 +       }
17374 +       csr = psycho_read(csr_reg);
17375 +       csr_error_bits =
17376 +               csr & (PSYCHO_PCICTRL_SBH_ERR | PSYCHO_PCICTRL_SERR);
17377 +       if (csr_error_bits) {
17378 +               /* Clear the errors.  */
17379 +               psycho_write(csr_reg, csr);
17380 +
17381 +               /* Log 'em.  */
17382 +               if (csr_error_bits & PSYCHO_PCICTRL_SBH_ERR)
17383 +                       printk("%s: PCI streaming byte hole error asserted.\n",
17384 +                              pbm->name);
17385 +               if (csr_error_bits & PSYCHO_PCICTRL_SERR)
17386 +                       printk("%s: PCI SERR signal asserted.\n", pbm->name);
17387 +               ret = IRQ_HANDLED;
17388 +       }
17389 +       pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);
17390 +       if (stat & (PCI_STATUS_PARITY |
17391 +                   PCI_STATUS_SIG_TARGET_ABORT |
17392 +                   PCI_STATUS_REC_TARGET_ABORT |
17393 +                   PCI_STATUS_REC_MASTER_ABORT |
17394 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
17395 +               printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
17396 +                      pbm->name, stat);
17397 +               pci_write_config_word(pbm->pci_bus->self, PCI_STATUS, 0xffff);
17398 +               ret = IRQ_HANDLED;
17399 +       }
17400 +       return ret;
17401 +}
17402 +
17403  static irqreturn_t psycho_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
17404  {
17405         struct pci_pbm_info *pbm = dev_id;
17406 @@ -902,7 +942,7 @@
17407                  PSYCHO_PCIAFSR_SMA | PSYCHO_PCIAFSR_STA |
17408                  PSYCHO_PCIAFSR_SRTRY | PSYCHO_PCIAFSR_SPERR);
17409         if (!error_bits)
17410 -               return IRQ_NONE;
17411 +               return psycho_pcierr_intr_other(pbm, is_pbm_a);
17412         psycho_write(afsr_reg, error_bits);
17413  
17414         /* Log the error. */
17415 @@ -1008,6 +1048,7 @@
17416                 prom_halt();
17417         }
17418  
17419 +       pbm = &p->pbm_A;
17420         irq = psycho_irq_build(pbm, NULL, (portid << 6) | PSYCHO_PCIERR_A_INO);
17421         if (request_irq(irq, psycho_pcierr_intr,
17422                         SA_SHIRQ, "PSYCHO PCIERR", &p->pbm_A) < 0) {
17423 @@ -1016,6 +1057,7 @@
17424                 prom_halt();
17425         }
17426  
17427 +       pbm = &p->pbm_B;
17428         irq = psycho_irq_build(pbm, NULL, (portid << 6) | PSYCHO_PCIERR_B_INO);
17429         if (request_irq(irq, psycho_pcierr_intr,
17430                         SA_SHIRQ, "PSYCHO PCIERR", &p->pbm_B) < 0) {
17431 diff -Nru a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
17432 --- a/arch/sparc64/kernel/pci_sabre.c   Tue Aug 19 16:00:48 2003
17433 +++ b/arch/sparc64/kernel/pci_sabre.c   Sun Aug 24 03:18:58 2003
17434 @@ -221,6 +221,7 @@
17435          ((unsigned long)(REG)))
17436  
17437  static int hummingbird_p;
17438 +static struct pci_bus *sabre_root_bus;
17439  
17440  static void *sabre_pci_config_mkaddr(struct pci_pbm_info *pbm,
17441                                      unsigned char bus,
17442 @@ -860,6 +861,42 @@
17443         return IRQ_HANDLED;
17444  }
17445  
17446 +static irqreturn_t sabre_pcierr_intr_other(struct pci_controller_info *p)
17447 +{
17448 +       unsigned long csr_reg, csr, csr_error_bits;
17449 +       irqreturn_t ret = IRQ_NONE;
17450 +       u16 stat;
17451 +
17452 +       csr_reg = p->pbm_A.controller_regs + SABRE_PCICTRL;
17453 +       csr = sabre_read(csr_reg);
17454 +       csr_error_bits =
17455 +               csr & SABRE_PCICTRL_SERR;
17456 +       if (csr_error_bits) {
17457 +               /* Clear the errors.  */
17458 +               sabre_write(csr_reg, csr);
17459 +
17460 +               /* Log 'em.  */
17461 +               if (csr_error_bits & SABRE_PCICTRL_SERR)
17462 +                       printk("SABRE%d: PCI SERR signal asserted.\n",
17463 +                              p->index);
17464 +               ret = IRQ_HANDLED;
17465 +       }
17466 +       pci_read_config_word(sabre_root_bus->self,
17467 +                            PCI_STATUS, &stat);
17468 +       if (stat & (PCI_STATUS_PARITY |
17469 +                   PCI_STATUS_SIG_TARGET_ABORT |
17470 +                   PCI_STATUS_REC_TARGET_ABORT |
17471 +                   PCI_STATUS_REC_MASTER_ABORT |
17472 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
17473 +               printk("SABRE%d: PCI bus error, PCI_STATUS[%04x]\n",
17474 +                      p->index, stat);
17475 +               pci_write_config_word(sabre_root_bus->self,
17476 +                                     PCI_STATUS, 0xffff);
17477 +               ret = IRQ_HANDLED;
17478 +       }
17479 +       return ret;
17480 +}
17481 +
17482  static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
17483  {
17484         struct pci_controller_info *p = dev_id;
17485 @@ -881,7 +918,7 @@
17486                  SABRE_PIOAFSR_SMA | SABRE_PIOAFSR_STA |
17487                  SABRE_PIOAFSR_SRTRY | SABRE_PIOAFSR_SPERR);
17488         if (!error_bits)
17489 -               return IRQ_NONE;
17490 +               return sabre_pcierr_intr_other(p);
17491         sabre_write(afsr_reg, error_bits);
17492  
17493         /* Log the error. */
17494 @@ -1167,6 +1204,8 @@
17495                                  &p->pbm_A);
17496         pci_fixup_host_bridge_self(sabre_bus);
17497         sabre_bus->self->sysdata = cookie;
17498 +
17499 +       sabre_root_bus = sabre_bus;
17500  
17501         apb_init(p, sabre_bus);
17502  
17503 diff -Nru a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
17504 --- a/arch/sparc64/kernel/pci_schizo.c  Sat Aug  2 18:21:52 2003
17505 +++ b/arch/sparc64/kernel/pci_schizo.c  Sun Aug 24 03:18:58 2003
17506 @@ -845,6 +845,88 @@
17507  #define SCHIZO_PCIAFSR_MEM     0x0000000020000000UL /* Schizo/Tomatillo */
17508  #define SCHIZO_PCIAFSR_IO      0x0000000010000000UL /* Schizo/Tomatillo */
17509  
17510 +#define SCHIZO_PCI_CTRL                (0x2000UL)
17511 +#define SCHIZO_PCICTRL_BUS_UNUS        (1UL << 63UL) /* Safari */
17512 +#define SCHIZO_PCICTRL_ARB_PRIO (0x1ff << 52UL) /* Tomatillo */
17513 +#define SCHIZO_PCICTRL_ESLCK   (1UL << 51UL) /* Safari */
17514 +#define SCHIZO_PCICTRL_ERRSLOT (7UL << 48UL) /* Safari */
17515 +#define SCHIZO_PCICTRL_TTO_ERR (1UL << 38UL) /* Safari/Tomatillo */
17516 +#define SCHIZO_PCICTRL_RTRY_ERR        (1UL << 37UL) /* Safari/Tomatillo */
17517 +#define SCHIZO_PCICTRL_DTO_ERR (1UL << 36UL) /* Safari/Tomatillo */
17518 +#define SCHIZO_PCICTRL_SBH_ERR (1UL << 35UL) /* Safari */
17519 +#define SCHIZO_PCICTRL_SERR    (1UL << 34UL) /* Safari/Tomatillo */
17520 +#define SCHIZO_PCICTRL_PCISPD  (1UL << 33UL) /* Safari */
17521 +#define SCHIZO_PCICTRL_MRM_PREF        (1UL << 28UL) /* Tomatillo */
17522 +#define SCHIZO_PCICTRL_RDO_PREF        (1UL << 27UL) /* Tomatillo */
17523 +#define SCHIZO_PCICTRL_RDL_PREF        (1UL << 26UL) /* Tomatillo */
17524 +#define SCHIZO_PCICTRL_PTO     (3UL << 24UL) /* Safari/Tomatillo */
17525 +#define SCHIZO_PCICTRL_PTO_SHIFT 24UL
17526 +#define SCHIZO_PCICTRL_TRWSW   (7UL << 21UL) /* Tomatillo */
17527 +#define SCHIZO_PCICTRL_F_TGT_A (1UL << 20UL) /* Tomatillo */
17528 +#define SCHIZO_PCICTRL_S_DTO_INT (1UL << 19UL) /* Safari */
17529 +#define SCHIZO_PCICTRL_F_TGT_RT        (1UL << 19UL) /* Tomatillo */
17530 +#define SCHIZO_PCICTRL_SBH_INT (1UL << 18UL) /* Safari */
17531 +#define SCHIZO_PCICTRL_T_DTO_INT (1UL << 18UL) /* Tomatillo */
17532 +#define SCHIZO_PCICTRL_EEN     (1UL << 17UL) /* Safari/Tomatillo */
17533 +#define SCHIZO_PCICTRL_PARK    (1UL << 16UL) /* Safari/Tomatillo */
17534 +#define SCHIZO_PCICTRL_PCIRST  (1UL <<  8UL) /* Safari */
17535 +#define SCHIZO_PCICTRL_ARB_S   (0x3fUL << 0UL) /* Safari */
17536 +#define SCHIZO_PCICTRL_ARB_T   (0xffUL << 0UL) /* Tomatillo */
17537 +
17538 +static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
17539 +{
17540 +       unsigned long csr_reg, csr, csr_error_bits;
17541 +       irqreturn_t ret = IRQ_NONE;
17542 +       u16 stat;
17543 +
17544 +       csr_reg = pbm->pbm_regs + SCHIZO_PCI_CTRL;
17545 +       csr = schizo_read(csr_reg);
17546 +       csr_error_bits =
17547 +               csr & (SCHIZO_PCICTRL_BUS_UNUS |
17548 +                      SCHIZO_PCICTRL_TTO_ERR |
17549 +                      SCHIZO_PCICTRL_RTRY_ERR |
17550 +                      SCHIZO_PCICTRL_DTO_ERR |
17551 +                      SCHIZO_PCICTRL_SBH_ERR |
17552 +                      SCHIZO_PCICTRL_SERR);
17553 +       if (csr_error_bits) {
17554 +               /* Clear the errors.  */
17555 +               schizo_write(csr_reg, csr);
17556 +
17557 +               /* Log 'em.  */
17558 +               if (csr_error_bits & SCHIZO_PCICTRL_BUS_UNUS)
17559 +                       printk("%s: Bus unusable error asserted.\n",
17560 +                              pbm->name);
17561 +               if (csr_error_bits & SCHIZO_PCICTRL_TTO_ERR)
17562 +                       printk("%s: PCI TRDY# timeout error asserted.\n",
17563 +                              pbm->name);
17564 +               if (csr_error_bits & SCHIZO_PCICTRL_RTRY_ERR)
17565 +                       printk("%s: PCI excessive retry error asserted.\n",
17566 +                              pbm->name);
17567 +               if (csr_error_bits & SCHIZO_PCICTRL_DTO_ERR)
17568 +                       printk("%s: PCI discard timeout error asserted.\n",
17569 +                              pbm->name);
17570 +               if (csr_error_bits & SCHIZO_PCICTRL_SBH_ERR)
17571 +                       printk("%s: PCI streaming byte hole error asserted.\n",
17572 +                              pbm->name);
17573 +               if (csr_error_bits & SCHIZO_PCICTRL_SERR)
17574 +                       printk("%s: PCI SERR signal asserted.\n",
17575 +                              pbm->name);
17576 +               ret = IRQ_HANDLED;
17577 +       }
17578 +       pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);
17579 +       if (stat & (PCI_STATUS_PARITY |
17580 +                   PCI_STATUS_SIG_TARGET_ABORT |
17581 +                   PCI_STATUS_REC_TARGET_ABORT |
17582 +                   PCI_STATUS_REC_MASTER_ABORT |
17583 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
17584 +               printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
17585 +                      pbm->name, stat);
17586 +               pci_write_config_word(pbm->pci_bus->self, PCI_STATUS, 0xffff);
17587 +               ret = IRQ_HANDLED;
17588 +       }
17589 +       return ret;
17590 +}
17591 +
17592  static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
17593  {
17594         struct pci_pbm_info *pbm = dev_id;
17595 @@ -871,7 +953,7 @@
17596                  SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
17597                  SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS);
17598         if (!error_bits)
17599 -               return IRQ_NONE;
17600 +               return schizo_pcierr_intr_other(pbm);
17601         schizo_write(afsr_reg, error_bits);
17602  
17603         /* Log the error. */
17604 @@ -1043,34 +1125,6 @@
17605  #define SCHIZO_PCIERR_A_INO    0x32 /* PBM A PCI bus error */
17606  #define SCHIZO_PCIERR_B_INO    0x33 /* PBM B PCI bus error */
17607  #define SCHIZO_SERR_INO                0x34 /* Safari interface error */
17608 -
17609 -#define SCHIZO_PCI_CTRL                (0x2000UL)
17610 -#define SCHIZO_PCICTRL_BUS_UNUS        (1UL << 63UL) /* Safari */
17611 -#define SCHIZO_PCICTRL_ARB_PRIO (0x1ff << 52UL) /* Tomatillo */
17612 -#define SCHIZO_PCICTRL_ESLCK   (1UL << 51UL) /* Safari */
17613 -#define SCHIZO_PCICTRL_ERRSLOT (7UL << 48UL) /* Safari */
17614 -#define SCHIZO_PCICTRL_TTO_ERR (1UL << 38UL) /* Safari/Tomatillo */
17615 -#define SCHIZO_PCICTRL_RTRY_ERR        (1UL << 37UL) /* Safari/Tomatillo */
17616 -#define SCHIZO_PCICTRL_DTO_ERR (1UL << 36UL) /* Safari/Tomatillo */
17617 -#define SCHIZO_PCICTRL_SBH_ERR (1UL << 35UL) /* Safari */
17618 -#define SCHIZO_PCICTRL_SERR    (1UL << 34UL) /* Safari/Tomatillo */
17619 -#define SCHIZO_PCICTRL_PCISPD  (1UL << 33UL) /* Safari */
17620 -#define SCHIZO_PCICTRL_MRM_PREF        (1UL << 28UL) /* Tomatillo */
17621 -#define SCHIZO_PCICTRL_RDO_PREF        (1UL << 27UL) /* Tomatillo */
17622 -#define SCHIZO_PCICTRL_RDL_PREF        (1UL << 26UL) /* Tomatillo */
17623 -#define SCHIZO_PCICTRL_PTO     (3UL << 24UL) /* Safari/Tomatillo */
17624 -#define SCHIZO_PCICTRL_PTO_SHIFT 24UL
17625 -#define SCHIZO_PCICTRL_TRWSW   (7UL << 21UL) /* Tomatillo */
17626 -#define SCHIZO_PCICTRL_F_TGT_A (1UL << 20UL) /* Tomatillo */
17627 -#define SCHIZO_PCICTRL_S_DTO_INT (1UL << 19UL) /* Safari */
17628 -#define SCHIZO_PCICTRL_F_TGT_RT        (1UL << 19UL) /* Tomatillo */
17629 -#define SCHIZO_PCICTRL_SBH_INT (1UL << 18UL) /* Safari */
17630 -#define SCHIZO_PCICTRL_T_DTO_INT (1UL << 18UL) /* Tomatillo */
17631 -#define SCHIZO_PCICTRL_EEN     (1UL << 17UL) /* Safari/Tomatillo */
17632 -#define SCHIZO_PCICTRL_PARK    (1UL << 16UL) /* Safari/Tomatillo */
17633 -#define SCHIZO_PCICTRL_PCIRST  (1UL <<  8UL) /* Safari */
17634 -#define SCHIZO_PCICTRL_ARB_S   (0x3fUL << 0UL) /* Safari */
17635 -#define SCHIZO_PCICTRL_ARB_T   (0xffUL << 0UL) /* Tomatillo */
17636  
17637  struct pci_pbm_info *pbm_for_ino(struct pci_controller_info *p, u32 ino)
17638  {
17639 diff -Nru a/arch/sparc64/kernel/semaphore.c b/arch/sparc64/kernel/semaphore.c
17640 --- a/arch/sparc64/kernel/semaphore.c   Mon Oct 14 05:17:46 2002
17641 +++ b/arch/sparc64/kernel/semaphore.c   Wed Sep  3 23:40:12 2003
17642 @@ -110,6 +110,7 @@
17643  
17644  void down(struct semaphore *sem)
17645  {
17646 +       might_sleep();
17647         /* This atomically does:
17648          *      old_val = sem->count;
17649          *      new_val = sem->count - 1;
17650 @@ -219,6 +220,7 @@
17651  {
17652         int ret = 0;
17653         
17654 +       might_sleep();
17655         /* This atomically does:
17656          *      old_val = sem->count;
17657          *      new_val = sem->count - 1;
17658 diff -Nru a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
17659 --- a/arch/sparc64/kernel/sys_sparc32.c Sat Aug 16 07:09:56 2003
17660 +++ b/arch/sparc64/kernel/sys_sparc32.c Sat Aug 30 22:29:28 2003
17661 @@ -388,7 +388,7 @@
17662   *
17663   * This is really horribly ugly.
17664   */
17665 -#define IPCOP_MASK(__x)        (1UL << (__x))
17666 +#define IPCOP_MASK(__x)        (1UL << ((__x)&~IPC_64))
17667  static int do_sys32_semctl(int first, int second, int third, void *uptr)
17668  {
17669         union semun fourth;
17670 @@ -400,7 +400,7 @@
17671         err = -EFAULT;
17672         if (get_user (pad, (u32 *)uptr))
17673                 goto out;
17674 -       if(third == SETVAL)
17675 +       if ((third & ~IPC_64) == SETVAL)
17676                 fourth.val = (int)pad;
17677         else
17678                 fourth.__pad = (void *)A(pad);
17679 @@ -2779,3 +2779,41 @@
17680         return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
17681                                   buf, len);
17682  }
17683 +
17684 +extern asmlinkage long
17685 +sys_timer_create(clockid_t which_clock, struct sigevent *timer_event_spec,
17686 +                timer_t * created_timer_id);
17687 +
17688 +long
17689 +sys32_timer_create(u32 clock, struct sigevent32 *se32, timer_t *timer_id)
17690 +{
17691 +       struct sigevent se;
17692 +       mm_segment_t oldfs;
17693 +       timer_t t;
17694 +       long err;
17695 +
17696 +       if (se32 == NULL)
17697 +               return sys_timer_create(clock, NULL, timer_id);
17698 +
17699 +       memset(&se, 0, sizeof(struct sigevent));
17700 +       if (get_user(se.sigev_value.sival_int,  &se32->sigev_value.sival_int) ||
17701 +           __get_user(se.sigev_signo, &se32->sigev_signo) ||
17702 +           __get_user(se.sigev_notify, &se32->sigev_notify) ||
17703 +           __copy_from_user(&se._sigev_un._pad, &se32->_sigev_un._pad,
17704 +           sizeof(se._sigev_un._pad)))
17705 +               return -EFAULT;
17706 +
17707 +       if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
17708 +               return -EFAULT;
17709 +
17710 +       oldfs = get_fs();
17711 +       set_fs(KERNEL_DS);
17712 +       err = sys_timer_create(clock, &se, &t);
17713 +       set_fs(oldfs);
17714 +
17715 +       if (!err)
17716 +               err = __put_user (t, timer_id);
17717 +
17718 +       return err;
17719 +}
17720 +
17721 diff -Nru a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c
17722 --- a/arch/sparc64/kernel/sys_sunos32.c Sun May 25 17:00:00 2003
17723 +++ b/arch/sparc64/kernel/sys_sunos32.c Tue Aug 26 09:25:41 2003
17724 @@ -90,7 +90,7 @@
17725                 if (!file)
17726                         goto out;
17727                 inode = file->f_dentry->d_inode;
17728 -               if (minor(inode->i_rdev) == MEM_MAJOR && minor(inode->i_rdev) == 5) {
17729 +               if (imajor(inode) == MEM_MAJOR && iminor(inode) == 5) {
17730                         flags |= MAP_ANONYMOUS;
17731                         fput(file);
17732                         file = NULL;
17733 diff -Nru a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
17734 --- a/arch/sparc64/kernel/systbls.S     Sat Aug 16 14:55:44 2003
17735 +++ b/arch/sparc64/kernel/systbls.S     Thu Aug 28 01:35:18 2003
17736 @@ -72,7 +72,7 @@
17737  /*250*/        .word sys32_mremap, sys32_sysctl, sys_getsid, sys_fdatasync, sys32_nfsservctl
17738         .word sys_ni_syscall, compat_clock_settime, compat_clock_gettime, compat_clock_getres, compat_clock_nanosleep
17739  /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, compat_timer_settime, compat_timer_gettime, sys_timer_getoverrun
17740 -       .word sys_timer_delete, sys_ni_syscall
17741 +       .word sys_timer_delete, sys32_timer_create, sys_ni_syscall
17742  
17743         /* Now the 64-bit native Linux syscall table. */
17744  
17745 @@ -133,7 +133,7 @@
17746  /*250*/        .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
17747         .word sys_ni_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
17748  /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
17749 -       .word sys_timer_delete, sys_ni_syscall
17750 +       .word sys_timer_delete, sys_timer_create, sys_ni_syscall
17751  
17752  #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
17753      defined(CONFIG_SOLARIS_EMUL_MODULE)
17754 @@ -228,10 +228,10 @@
17755         .word sunos_nosys, sunos_nosys, sunos_nosys
17756         .word sunos_nosys, sunos_nosys
17757  /*250*/        .word sunos_nosys, sunos_nosys, sunos_nosys
17758 -       .word sunos_nosys, sunos_nosys, sys_ni_syscall
17759 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
17760 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
17761 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
17762 -       .word sys_ni_syscall, sys_ni_syscall
17763 +       .word sunos_nosys, sunos_nosys, sunos_nosys
17764 +       .word sunos_nosys, sunos_nosys, sunos_nosys
17765 +       .word sunos_nosys, sunos_nosys, sunos_nosys
17766 +       .word sunos_nosys, sunos_nosys, sunos_nosys
17767 +       .word sunos_nosys, sunos_nosys, sunos_nosys
17768  
17769  #endif
17770 diff -Nru a/arch/sparc64/mm/hugetlbpage.c b/arch/sparc64/mm/hugetlbpage.c
17771 --- a/arch/sparc64/mm/hugetlbpage.c     Mon Feb 24 23:13:11 2003
17772 +++ b/arch/sparc64/mm/hugetlbpage.c     Tue Aug 26 09:41:27 2003
17773 @@ -380,207 +380,6 @@
17774         return 1;
17775  }
17776  
17777 -static struct inode *set_new_inode(unsigned long len, int prot, int flag, int key)
17778 -{
17779 -       struct inode *inode;
17780 -       int i;
17781 -
17782 -       for (i = 0; i < MAX_ID; i++) {
17783 -               if (htlbpagek[i].key == 0)
17784 -                       break;
17785 -       }
17786 -       if (i == MAX_ID)
17787 -               return NULL;
17788 -       inode = kmalloc(sizeof (struct inode), GFP_KERNEL);
17789 -       if (inode == NULL)
17790 -               return NULL;
17791 -
17792 -       inode_init_once(inode);
17793 -       atomic_inc(&inode->i_writecount);
17794 -       inode->i_mapping = &inode->i_data;
17795 -       inode->i_mapping->host = inode;
17796 -       inode->i_ino = (unsigned long)key;
17797 -
17798 -       htlbpagek[i].key = key;
17799 -       htlbpagek[i].in = inode;
17800 -       inode->i_uid = current->fsuid;
17801 -       inode->i_gid = current->fsgid;
17802 -       inode->i_mode = prot;
17803 -       inode->i_size = len;
17804 -       return inode;
17805 -}
17806 -
17807 -static int check_size_prot(struct inode *inode, unsigned long len, int prot, int flag)
17808 -{
17809 -       if (inode->i_uid != current->fsuid)
17810 -               return -1;
17811 -       if (inode->i_gid != current->fsgid)
17812 -               return -1;
17813 -       if (inode->i_size != len)
17814 -               return -1;
17815 -       return 0;
17816 -}
17817 -
17818 -static int alloc_shared_hugetlb_pages(int key, unsigned long addr, unsigned long len,
17819 -                                     int prot, int flag)
17820 -{
17821 -       struct mm_struct *mm = current->mm;
17822 -       struct vm_area_struct *vma;
17823 -       struct inode *inode;
17824 -       struct address_space *mapping;
17825 -       struct page *page;
17826 -       int idx;
17827 -       int retval = -ENOMEM;
17828 -       int newalloc = 0;
17829 -
17830 -try_again:
17831 -       spin_lock(&htlbpage_lock);
17832 -
17833 -       inode = find_key_inode(key);
17834 -       if (inode == NULL) {
17835 -               if (!capable(CAP_SYS_ADMIN)) {
17836 -                       if (!in_group_p(0)) {
17837 -                               retval = -EPERM;
17838 -                               goto out_err;
17839 -                       }
17840 -               }
17841 -               if (!(flag & IPC_CREAT)) {
17842 -                       retval = -ENOENT;
17843 -                       goto out_err;
17844 -               }
17845 -               inode = set_new_inode(len, prot, flag, key);
17846 -               if (inode == NULL)
17847 -                       goto out_err;
17848 -               newalloc = 1;
17849 -       } else {
17850 -               if (check_size_prot(inode, len, prot, flag) < 0) {
17851 -                       retval = -EINVAL;
17852 -                       goto out_err;
17853 -               } else if (atomic_read(&inode->i_writecount)) {
17854 -                       spin_unlock(&htlbpage_lock);
17855 -                       goto try_again;
17856 -               }
17857 -       }
17858 -       spin_unlock(&htlbpage_lock);
17859 -       mapping = inode->i_mapping;
17860 -
17861 -       addr = do_mmap_pgoff(NULL, addr, len, (unsigned long) prot,
17862 -                            MAP_NORESERVE|MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, 0);
17863 -       if (IS_ERR((void *) addr))
17864 -               goto freeinode;
17865 -
17866 -       vma = find_vma(mm, addr);
17867 -       if (!vma) {
17868 -               retval = -EINVAL;
17869 -               goto freeinode;
17870 -       }
17871 -
17872 -       spin_lock(&mm->page_table_lock);
17873 -       do {
17874 -               pte_t *pte = huge_pte_alloc_map(mm, addr);
17875 -
17876 -               if (!pte || !pte_none(pte)) {
17877 -                       if (pte)
17878 -                               pte_unmap(pte);
17879 -                       goto out;
17880 -               }
17881 -
17882 -               idx = (addr - vma->vm_start) >> HPAGE_SHIFT;
17883 -               page = find_get_page(mapping, idx);
17884 -               if (page == NULL) {
17885 -                       page = alloc_hugetlb_page();
17886 -                       if (page == NULL) {
17887 -                               pte_unmap(pte);
17888 -                               retval = -ENOMEM;
17889 -                               goto out;
17890 -                       }
17891 -                       retval = add_to_page_cache(page, mapping,
17892 -                                               idx, GFP_ATOMIC);
17893 -                       if (retval) {
17894 -                               pte_unmap(pte);
17895 -                               free_hugetlb_page(page);
17896 -                               goto out;
17897 -                       }
17898 -               }
17899 -               set_huge_pte(mm, vma, page, pte,
17900 -                            (vma->vm_flags & VM_WRITE));
17901 -               pte_unmap(pte);
17902 -
17903 -               addr += HPAGE_SIZE;
17904 -       } while (addr < vma->vm_end);
17905 -
17906 -       retval = 0;
17907 -       vma->vm_flags |= (VM_HUGETLB | VM_RESERVED);
17908 -       vma->vm_ops = &hugetlb_vm_ops;
17909 -       spin_unlock(&mm->page_table_lock);
17910 -       spin_lock(&htlbpage_lock);
17911 -       atomic_set(&inode->i_writecount, 0);
17912 -       spin_unlock(&htlbpage_lock);
17913 -
17914 -       return retval;
17915 -
17916 -out:
17917 -       if (addr > vma->vm_start) {
17918 -               unsigned long raddr;
17919 -               raddr = vma->vm_end;
17920 -               vma->vm_end = addr;
17921 -
17922 -               flush_cache_range(vma, vma->vm_start, vma->vm_end);
17923 -               zap_hugetlb_resources(vma);
17924 -               flush_tlb_range(vma, vma->vm_start, vma->vm_end);
17925 -
17926 -               vma->vm_end = raddr;
17927 -       }
17928 -       spin_unlock(&mm->page_table_lock);
17929 -       do_munmap(mm, vma->vm_start, len);
17930 -       if (newalloc)
17931 -               goto freeinode;
17932 -
17933 -       return retval;
17934 -
17935 -out_err:
17936 -       spin_unlock(&htlbpage_lock);
17937 -
17938 -freeinode:
17939 -       if (newalloc) {
17940 -               for (idx = 0; idx < MAX_ID; idx++) {
17941 -                       if (htlbpagek[idx].key == inode->i_ino) {
17942 -                               htlbpagek[idx].key = 0;
17943 -                               htlbpagek[idx].in = NULL;
17944 -                               break;
17945 -                       }
17946 -               }
17947 -               kfree(inode);
17948 -       }
17949 -       return retval;
17950 -}
17951 -
17952 -static int alloc_private_hugetlb_pages(int key, unsigned long addr, unsigned long len,
17953 -                                      int prot, int flag)
17954 -{
17955 -       if (!capable(CAP_SYS_ADMIN)) {
17956 -               if (!in_group_p(0))
17957 -                       return -EPERM;
17958 -       }
17959 -       addr = do_mmap_pgoff(NULL, addr, len, prot,
17960 -                            MAP_NORESERVE|MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0);
17961 -       if (IS_ERR((void *) addr))
17962 -               return -ENOMEM;
17963 -       if (make_hugetlb_pages_present(addr, (addr + len), flag) < 0) {
17964 -               do_munmap(current->mm, addr, len);
17965 -               return -ENOMEM;
17966 -       }
17967 -       return 0;
17968 -}
17969 -
17970 -int alloc_hugetlb_pages(int key, unsigned long addr, unsigned long len, int prot,
17971 -                   int flag)
17972 -{
17973 -       if (key > 0)
17974 -               return alloc_shared_hugetlb_pages(key, addr, len, prot, flag);
17975 -       return alloc_private_hugetlb_pages(key, addr, len, prot, flag);
17976 -}
17977 -
17978  extern long htlbzone_pages;
17979  extern struct list_head htlbpage_freelist;
17980  
17981 diff -Nru a/arch/sparc64/solaris/misc.c b/arch/sparc64/solaris/misc.c
17982 --- a/arch/sparc64/solaris/misc.c       Tue Aug 19 12:12:41 2003
17983 +++ b/arch/sparc64/solaris/misc.c       Tue Aug 26 09:25:41 2003
17984 @@ -77,8 +77,8 @@
17985                         goto out;
17986                 else {
17987                         struct inode * inode = file->f_dentry->d_inode;
17988 -                       if(major(inode->i_rdev) == MEM_MAJOR &&
17989 -                          minor(inode->i_rdev) == 5) {
17990 +                       if(imajor(inode) == MEM_MAJOR &&
17991 +                          iminor(inode) == 5) {
17992                                 flags |= MAP_ANONYMOUS;
17993                                 fput(file);
17994                                 file = NULL;
17995 diff -Nru a/arch/sparc64/solaris/socksys.c b/arch/sparc64/solaris/socksys.c
17996 --- a/arch/sparc64/solaris/socksys.c    Wed May  7 08:47:29 2003
17997 +++ b/arch/sparc64/solaris/socksys.c    Tue Aug 26 09:25:40 2003
17998 @@ -70,14 +70,14 @@
17999                 (int (*)(int,int,int))SUNOS(97);
18000          struct sol_socket_struct * sock;
18001         
18002 -       family = ((minor(inode->i_rdev) >> 4) & 0xf);
18003 +       family = ((iminor(inode) >> 4) & 0xf);
18004         switch (family) {
18005         case AF_UNIX:
18006                 type = SOCK_STREAM;
18007                 protocol = 0;
18008                 break;
18009         case AF_INET:
18010 -               protocol = af_inet_protocols[minor(inode->i_rdev) & 0xf];
18011 +               protocol = af_inet_protocols[iminor(inode) & 0xf];
18012                 switch (protocol) {
18013                 case IPPROTO_TCP: type = SOCK_STREAM; break;
18014                 case IPPROTO_UDP: type = SOCK_DGRAM; break;
18015 diff -Nru a/arch/sparc64/solaris/systbl.S b/arch/sparc64/solaris/systbl.S
18016 --- a/arch/sparc64/solaris/systbl.S     Mon Aug 18 01:08:52 2003
18017 +++ b/arch/sparc64/solaris/systbl.S     Wed Aug 27 23:52:25 2003
18018 @@ -294,4 +294,5 @@
18019         .word solaris_unimplemented     /*                      264     */
18020         .word solaris_unimplemented     /*                      265     */
18021         .word solaris_unimplemented     /*                      266     */
18022 +       .word solaris_unimplemented     /*                      267     */
18023  
18024 diff -Nru a/arch/sparc64/solaris/timod.c b/arch/sparc64/solaris/timod.c
18025 --- a/arch/sparc64/solaris/timod.c      Fri Jun  6 04:40:53 2003
18026 +++ b/arch/sparc64/solaris/timod.c      Tue Aug 26 09:25:41 2003
18027 @@ -924,7 +924,7 @@
18028         if (!ino) goto out;
18029  
18030         if (!ino->i_sock &&
18031 -               (major(ino->i_rdev) != 30 || minor(ino->i_rdev) != 1))
18032 +               (imajor(ino) != 30 || iminor(ino) != 1))
18033                 goto out;
18034  
18035         ctlptr = (struct strbuf *)A(arg1);
18036 diff -Nru a/arch/v850/Kconfig b/arch/v850/Kconfig
18037 --- a/arch/v850/Kconfig Sat Aug  2 14:26:16 2003
18038 +++ b/arch/v850/Kconfig Sun Aug 31 16:14:22 2003
18039 @@ -262,14 +262,6 @@
18040  
18041  menu "Executable file formats"
18042  
18043 -config KCORE_AOUT
18044 -       bool
18045 -       default y
18046 -
18047 -config KCORE_ELF
18048 -       bool
18049 -       default y
18050 -
18051  source "fs/Kconfig.binfmt"
18052  
18053  endmenu
18054 diff -Nru a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S
18055 --- a/arch/v850/kernel/vmlinux.lds.S    Mon Aug  4 20:42:12 2003
18056 +++ b/arch/v850/kernel/vmlinux.lds.S    Tue Aug 26 00:21:26 2003
18057 @@ -33,6 +33,30 @@
18058                         *(.intv.mach)   /* Machine-specific int. vectors.  */ \
18059                 __intv_end = . ;
18060  
18061 +#define RODATA_CONTENTS                                                              \
18062 +               . = ALIGN (16) ;                                              \
18063 +                       *(.rodata) *(.rodata.*)                               \
18064 +                       *(__vermagic)           /* Kernel version magic */    \
18065 +                       *(.rodata1)                                           \
18066 +               /* Kernel symbol table: Normal symbols */                     \
18067 +               ___start___ksymtab = .;                                       \
18068 +                       *(__ksymtab)                                          \
18069 +               ___stop___ksymtab = .;                                        \
18070 +               /* Kernel symbol table: GPL-only symbols */                   \
18071 +               ___start___ksymtab_gpl = .;                                   \
18072 +                       *(__ksymtab_gpl)                                      \
18073 +               ___stop___ksymtab_gpl = .;                                    \
18074 +               /* Kernel symbol table: strings */                            \
18075 +                       *(__ksymtab_strings)                                  \
18076 +               /* Kernel symbol table: Normal symbols */                     \
18077 +               ___start___kcrctab = .;                                       \
18078 +                       *(__kcrctab)                                          \
18079 +               ___stop___kcrctab = .;                                        \
18080 +               /* Kernel symbol table: GPL-only symbols */                   \
18081 +               ___start___kcrctab_gpl = .;                                   \
18082 +                       *(__kcrctab_gpl)                                      \
18083 +               ___stop___kcrctab_gpl = .;                                    \
18084 +
18085  /* Kernel text segment, and some constant data areas.  */
18086  #define TEXT_CONTENTS                                                        \
18087                 __stext = . ;                                                 \
18088 @@ -42,7 +66,7 @@
18089                         *(.text.lock)                                         \
18090                         *(.exitcall.exit)                                     \
18091                 __real_etext = . ;      /* There may be data after here.  */  \
18092 -               RODATA                                                        \
18093 +               RODATA_CONTENTS                                               \
18094                 . = ALIGN (4) ;                                               \
18095                         *(.call_table_data)                                   \
18096                         *(.call_table_text)                                   \
18097 diff -Nru a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
18098 --- a/arch/x86_64/Kconfig       Sat Aug  2 14:26:16 2003
18099 +++ b/arch/x86_64/Kconfig       Sun Aug 31 16:14:22 2003
18100 @@ -370,11 +370,6 @@
18101  
18102  menu "Executable file formats / Emulations"
18103  
18104 -config KCORE_ELF
18105 -       bool
18106 -       depends on PROC_FS
18107 -       default y
18108 -
18109  source "fs/Kconfig.binfmt"
18110  
18111  config IA32_EMULATION
18112 diff -Nru a/arch/x86_64/defconfig b/arch/x86_64/defconfig
18113 --- a/arch/x86_64/defconfig     Sat Aug  9 07:53:46 2003
18114 +++ b/arch/x86_64/defconfig     Sat Aug 23 04:57:05 2003
18115 @@ -14,6 +14,7 @@
18116  # Code maturity level options
18117  #
18118  CONFIG_EXPERIMENTAL=y
18119 +# CONFIG_BROKEN is not set
18120  
18121  #
18122  # General setup
18123 @@ -23,10 +24,12 @@
18124  # CONFIG_BSD_PROCESS_ACCT is not set
18125  CONFIG_SYSCTL=y
18126  CONFIG_LOG_BUF_SHIFT=18
18127 +# CONFIG_IKCONFIG is not set
18128  # CONFIG_EMBEDDED is not set
18129  CONFIG_KALLSYMS=y
18130  CONFIG_FUTEX=y
18131  CONFIG_EPOLL=y
18132 +CONFIG_IOSCHED_NOOP=y
18133  CONFIG_IOSCHED_AS=y
18134  CONFIG_IOSCHED_DEADLINE=y
18135  
18136 @@ -72,10 +75,10 @@
18137  CONFIG_SOFTWARE_SUSPEND=y
18138  
18139  #
18140 -# ACPI Support
18141 +# ACPI (Advanced Configuration and Power Interface) Support
18142  #
18143 +# CONFIG_ACPI_HT is not set
18144  CONFIG_ACPI=y
18145 -# CONFIG_ACPI_HT_ONLY is not set
18146  CONFIG_ACPI_BOOT=y
18147  CONFIG_ACPI_SLEEP=y
18148  CONFIG_ACPI_SLEEP_PROC_FS=y
18149 @@ -117,7 +120,6 @@
18150  #
18151  # Generic Driver Options
18152  #
18153 -# CONFIG_FW_LOADER is not set
18154  
18155  #
18156  # Memory Technology Devices (MTD)
18157 @@ -159,6 +161,7 @@
18158  CONFIG_IDEDISK_MULTI_MODE=y
18159  # CONFIG_IDEDISK_STROKE is not set
18160  CONFIG_BLK_DEV_IDECD=y
18161 +# CONFIG_BLK_DEV_IDETAPE is not set
18162  # CONFIG_BLK_DEV_IDEFLOPPY is not set
18163  # CONFIG_BLK_DEV_IDESCSI is not set
18164  # CONFIG_IDE_TASK_IOCTL is not set
18165 @@ -318,7 +321,6 @@
18166  # CONFIG_DECNET is not set
18167  # CONFIG_BRIDGE is not set
18168  # CONFIG_NETFILTER is not set
18169 -# CONFIG_XFRM_USER is not set
18170  
18171  #
18172  # SCTP Configuration (EXPERIMENTAL)
18173 @@ -405,6 +407,7 @@
18174  # CONFIG_HAMACHI is not set
18175  # CONFIG_YELLOWFIN is not set
18176  # CONFIG_R8169 is not set
18177 +# CONFIG_SIS190 is not set
18178  # CONFIG_SK98LIN is not set
18179  CONFIG_TIGON3=y
18180  
18181 @@ -595,10 +598,7 @@
18182  CONFIG_REISERFS_FS=y
18183  # CONFIG_REISERFS_CHECK is not set
18184  # CONFIG_REISERFS_PROC_INFO is not set
18185 -CONFIG_JFS_FS=y
18186 -CONFIG_JFS_POSIX_ACL=y
18187 -# CONFIG_JFS_DEBUG is not set
18188 -# CONFIG_JFS_STATISTICS is not set
18189 +# CONFIG_JFS_FS is not set
18190  CONFIG_FS_POSIX_ACL=y
18191  # CONFIG_XFS_FS is not set
18192  # CONFIG_MINIX_FS is not set
18193 @@ -674,49 +674,6 @@
18194  #
18195  # CONFIG_PARTITION_ADVANCED is not set
18196  CONFIG_MSDOS_PARTITION=y
18197 -CONFIG_NLS=y
18198 -
18199 -#
18200 -# Native Language Support
18201 -#
18202 -CONFIG_NLS_DEFAULT="iso8859-1"
18203 -# CONFIG_NLS_CODEPAGE_437 is not set
18204 -# CONFIG_NLS_CODEPAGE_737 is not set
18205 -# CONFIG_NLS_CODEPAGE_775 is not set
18206 -# CONFIG_NLS_CODEPAGE_850 is not set
18207 -# CONFIG_NLS_CODEPAGE_852 is not set
18208 -# CONFIG_NLS_CODEPAGE_855 is not set
18209 -# CONFIG_NLS_CODEPAGE_857 is not set
18210 -# CONFIG_NLS_CODEPAGE_860 is not set
18211 -# CONFIG_NLS_CODEPAGE_861 is not set
18212 -# CONFIG_NLS_CODEPAGE_862 is not set
18213 -# CONFIG_NLS_CODEPAGE_863 is not set
18214 -# CONFIG_NLS_CODEPAGE_864 is not set
18215 -# CONFIG_NLS_CODEPAGE_865 is not set
18216 -# CONFIG_NLS_CODEPAGE_866 is not set
18217 -# CONFIG_NLS_CODEPAGE_869 is not set
18218 -# CONFIG_NLS_CODEPAGE_936 is not set
18219 -# CONFIG_NLS_CODEPAGE_950 is not set
18220 -# CONFIG_NLS_CODEPAGE_932 is not set
18221 -# CONFIG_NLS_CODEPAGE_949 is not set
18222 -# CONFIG_NLS_CODEPAGE_874 is not set
18223 -# CONFIG_NLS_ISO8859_8 is not set
18224 -# CONFIG_NLS_CODEPAGE_1250 is not set
18225 -# CONFIG_NLS_CODEPAGE_1251 is not set
18226 -# CONFIG_NLS_ISO8859_1 is not set
18227 -# CONFIG_NLS_ISO8859_2 is not set
18228 -# CONFIG_NLS_ISO8859_3 is not set
18229 -# CONFIG_NLS_ISO8859_4 is not set
18230 -# CONFIG_NLS_ISO8859_5 is not set
18231 -# CONFIG_NLS_ISO8859_6 is not set
18232 -# CONFIG_NLS_ISO8859_7 is not set
18233 -# CONFIG_NLS_ISO8859_9 is not set
18234 -# CONFIG_NLS_ISO8859_13 is not set
18235 -# CONFIG_NLS_ISO8859_14 is not set
18236 -# CONFIG_NLS_ISO8859_15 is not set
18237 -# CONFIG_NLS_KOI8_R is not set
18238 -# CONFIG_NLS_KOI8_U is not set
18239 -# CONFIG_NLS_UTF8 is not set
18240  
18241  #
18242  # Graphics support
18243 diff -Nru a/arch/x86_64/ia32/ia32_ioctl.c b/arch/x86_64/ia32/ia32_ioctl.c
18244 --- a/arch/x86_64/ia32/ia32_ioctl.c     Fri Jul 11 05:14:13 2003
18245 +++ b/arch/x86_64/ia32/ia32_ioctl.c     Sun Aug 31 16:14:44 2003
18246 @@ -673,12 +673,10 @@
18247         return err;
18248  } 
18249  
18250 -#define REF_SYMBOL(handler) if (0) (void)handler;
18251 -#define HANDLE_IOCTL2(cmd,handler) REF_SYMBOL(handler);  asm volatile(".quad %P0, " #handler ",0"::"i" (cmd)); 
18252 -#define HANDLE_IOCTL(cmd,handler) HANDLE_IOCTL2(cmd,handler)
18253 +#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL },
18254  #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl)
18255 -#define IOCTL_TABLE_START void ioctl_dummy(void) { asm volatile("\n.global ioctl_start\nioctl_start:\n\t" );
18256 -#define IOCTL_TABLE_END  asm volatile("\n.global ioctl_end;\nioctl_end:\n"); }
18257 +#define IOCTL_TABLE_START struct ioctl_trans ioctl_start[] = {
18258 +#define IOCTL_TABLE_END  };
18259  
18260  IOCTL_TABLE_START
18261  #include <linux/compat_ioctl.h>
18262 @@ -765,3 +763,4 @@
18263  HANDLE_IOCTL(MTRRIOC32_KILL_PAGE_ENTRY, mtrr_ioctl32)
18264  IOCTL_TABLE_END
18265  
18266 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
18267 diff -Nru a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
18268 --- a/arch/x86_64/ia32/sys_ia32.c       Mon Jul 14 04:19:39 2003
18269 +++ b/arch/x86_64/ia32/sys_ia32.c       Sun Aug 31 05:33:07 2003
18270 @@ -1170,8 +1170,6 @@
18271         return ret;
18272  }
18273  
18274 -extern void check_pending(int signum);
18275 -
18276  asmlinkage long sys_utimes(char *, struct timeval *);
18277  
18278  asmlinkage long
18279 diff -Nru a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
18280 --- a/arch/x86_64/kernel/apic.c Mon Aug 18 19:46:23 2003
18281 +++ b/arch/x86_64/kernel/apic.c Sat Aug 23 05:13:33 2003
18282 @@ -299,7 +299,7 @@
18283          * This is meaningless in clustered apic mode, so we skip it.
18284          */
18285         if (!clustered_apic_mode &&
18286 -               !cpu_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
18287 +               !physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
18288                 BUG();
18289  
18290         /*
18291 @@ -993,7 +993,7 @@
18292  
18293         connect_bsp_APIC();
18294  
18295 -       phys_cpu_present_map = cpumask_of_cpu(0);
18296 +       phys_cpu_present_map = physid_mask_of_physid(0);
18297         apic_write_around(APIC_ID, boot_cpu_id);
18298  
18299         setup_local_APIC();
18300 diff -Nru a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
18301 --- a/arch/x86_64/kernel/io_apic.c      Tue Aug 19 07:45:10 2003
18302 +++ b/arch/x86_64/kernel/io_apic.c      Sat Aug 23 05:13:33 2003
18303 @@ -1014,7 +1014,7 @@
18304  static void __init setup_ioapic_ids_from_mpc (void)
18305  {
18306         union IO_APIC_reg_00 reg_00;
18307 -       cpumask_t phys_id_present_map = phys_cpu_present_map;
18308 +       physid_mask_t phys_id_present_map = phys_cpu_present_map;
18309         int apic;
18310         int i;
18311         unsigned char old_id;
18312 @@ -1047,22 +1047,22 @@
18313                  * system must have a unique ID or we get lots of nice
18314                  * 'stuck on smp_invalidate_needed IPI wait' messages.
18315                  */
18316 -               if (cpu_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
18317 +               if (physid_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
18318                         printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
18319                                 apic, mp_ioapics[apic].mpc_apicid);
18320                         for (i = 0; i < 0xf; i++)
18321 -                               if (!cpu_isset(i, phys_id_present_map))
18322 +                               if (!physid_isset(i, phys_id_present_map))
18323                                         break;
18324                         if (i >= 0xf)
18325                                 panic("Max APIC ID exceeded!\n");
18326                         printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
18327                                 i);
18328 -                       cpu_set(i, phys_id_present_map);
18329 +                       physid_set(i, phys_id_present_map);
18330                         mp_ioapics[apic].mpc_apicid = i;
18331                 } else {
18332                         printk(KERN_INFO 
18333                                "Using IO-APIC %d\n", mp_ioapics[apic].mpc_apicid);
18334 -                       cpu_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
18335 +                       physid_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
18336                 }
18337  
18338  
18339 @@ -1642,7 +1642,7 @@
18340  int __init io_apic_get_unique_id (int ioapic, int apic_id)
18341  {
18342         union IO_APIC_reg_00 reg_00;
18343 -       static cpumask_t apic_id_map;
18344 +       static physid_mask_t apic_id_map;
18345         unsigned long flags;
18346         int i = 0;
18347  
18348 @@ -1655,7 +1655,7 @@
18349          *      advantage of new APIC bus architecture.
18350          */
18351  
18352 -       if (!cpus_empty(apic_id_map))
18353 +       if (!physids_empty(apic_id_map))
18354                 apic_id_map = phys_cpu_present_map;
18355  
18356         spin_lock_irqsave(&ioapic_lock, flags);
18357 @@ -1672,10 +1672,10 @@
18358          * Every APIC in a system must have a unique ID or we get lots of nice 
18359          * 'stuck on smp_invalidate_needed IPI wait' messages.
18360          */
18361 -       if (cpu_isset(apic_id, apic_id_map)) {
18362 +       if (physid_isset(apic_id, apic_id_map)) {
18363  
18364                 for (i = 0; i < IO_APIC_MAX_ID; i++) {
18365 -                       if (!cpu_isset(i, apic_id_map))
18366 +                       if (!physid_isset(i, apic_id_map))
18367                                 break;
18368                 }
18369  
18370 @@ -1688,7 +1688,7 @@
18371                 apic_id = i;
18372         } 
18373  
18374 -       cpu_set(apic_id, apic_id_map);
18375 +       physid_set(apic_id, apic_id_map);
18376  
18377         if (reg_00.bits.ID != apic_id) {
18378                 reg_00.bits.ID = apic_id;
18379 diff -Nru a/arch/x86_64/kernel/ioport.c b/arch/x86_64/kernel/ioport.c
18380 --- a/arch/x86_64/kernel/ioport.c       Wed Aug 20 10:43:52 2003
18381 +++ b/arch/x86_64/kernel/ioport.c       Sat Aug 23 05:03:34 2003
18382 @@ -10,12 +10,11 @@
18383  #include <linux/errno.h>
18384  #include <linux/types.h>
18385  #include <linux/ioport.h>
18386 -#include <linux/mm.h>
18387  #include <linux/smp.h>
18388  #include <linux/smp_lock.h>
18389  #include <linux/stddef.h>
18390  #include <linux/slab.h>
18391 -#include <asm/io.h>
18392 +#include <linux/thread_info.h>
18393  
18394  /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
18395  static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value)
18396 @@ -118,12 +117,7 @@
18397                         return -EPERM;
18398         }
18399         regs.eflags = (regs.eflags &~ 0x3000UL) | (level << 12);
18400 +       /* Make sure we return the long way (not sysenter) */
18401 +       set_thread_flag(TIF_IRET);
18402         return 0;
18403  }
18404 -
18405 -void eat_key(void)
18406 -{
18407 -       if (inb(0x60) & 1) 
18408 -               inb(0x64);
18409 -}
18410 -
18411 diff -Nru a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
18412 --- a/arch/x86_64/kernel/mpparse.c      Tue Aug 19 07:45:28 2003
18413 +++ b/arch/x86_64/kernel/mpparse.c      Sat Aug 23 05:13:33 2003
18414 @@ -67,7 +67,7 @@
18415  static unsigned int num_processors = 0;
18416  
18417  /* Bitmask of physically existing CPUs */
18418 -cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
18419 +physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
18420  
18421  /* ACPI MADT entry parsing functions */
18422  #ifdef CONFIG_ACPI_BOOT
18423 @@ -126,7 +126,7 @@
18424         }
18425         ver = m->mpc_apicver;
18426  
18427 -       cpu_set(m->mpc_apicid, phys_cpu_present_map);
18428 +       physid_set(m->mpc_apicid, phys_cpu_present_map);
18429         /*
18430          * Validate version
18431          */
18432 diff -Nru a/arch/x86_64/kernel/msr.c b/arch/x86_64/kernel/msr.c
18433 --- a/arch/x86_64/kernel/msr.c  Mon Aug 18 19:46:23 2003
18434 +++ b/arch/x86_64/kernel/msr.c  Tue Aug 26 09:25:40 2003
18435 @@ -194,7 +194,7 @@
18436    u32 data[2];
18437    size_t rv;
18438    u32 reg = *ppos;
18439 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
18440 +  int cpu = iminor(file->f_dentry->d_inode);
18441    int err;
18442  
18443    if ( count % 8 )
18444 @@ -219,7 +219,7 @@
18445    u32 data[2];
18446    size_t rv;
18447    u32 reg = *ppos;
18448 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
18449 +  int cpu = iminor(file->f_dentry->d_inode);
18450    int err;
18451  
18452    if ( count % 8 )
18453 @@ -239,7 +239,7 @@
18454  
18455  static int msr_open(struct inode *inode, struct file *file)
18456  {
18457 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
18458 +  int cpu = iminor(file->f_dentry->d_inode);
18459    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
18460    
18461    if (!cpu_online(cpu))
18462 diff -Nru a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
18463 --- a/arch/x86_64/kernel/setup.c        Mon Aug 18 19:46:23 2003
18464 +++ b/arch/x86_64/kernel/setup.c        Sat Aug 23 04:55:48 2003
18465 @@ -243,6 +243,8 @@
18466  
18467  void __init setup_arch(char **cmdline_p)
18468  {
18469 +       unsigned long low_mem_size;
18470 +
18471         ROOT_DEV = ORIG_ROOT_DEV;
18472         drive_info = DRIVE_INFO;
18473         screen_info = SCREEN_INFO;
18474 @@ -378,7 +380,13 @@
18475                 request_resource(&ioport_resource, standard_io_resources+i);
18476         }
18477  
18478 -       pci_mem_start = IOMAP_START; 
18479 +       /* Will likely break when you have unassigned resources with more
18480 +          than 4GB memory and bridges that don't support more than 4GB. 
18481 +          Doing it properly would require to allocate GFP_DMA memory
18482 +          in this case. */
18483 +       low_mem_size = ((end_pfn << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
18484 +       if (low_mem_size > pci_mem_start)
18485 +               pci_mem_start = low_mem_size;
18486  
18487  #ifdef CONFIG_GART_IOMMU
18488         iommu_hole_init();
18489 diff -Nru a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
18490 --- a/arch/x86_64/kernel/smpboot.c      Mon Aug 18 19:46:23 2003
18491 +++ b/arch/x86_64/kernel/smpboot.c      Sat Aug 23 05:13:33 2003
18492 @@ -734,10 +734,10 @@
18493         current_thread_info()->cpu = 0;
18494         smp_tune_scheduling();
18495  
18496 -       if (!cpu_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
18497 +       if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
18498                 printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
18499                        hard_smp_processor_id());
18500 -               cpu_set(hard_smp_processor_id(), phys_cpu_present_map);
18501 +               physid_set(hard_smp_processor_id(), phys_cpu_present_map);
18502         }
18503  
18504         /*
18505 @@ -748,7 +748,7 @@
18506                 printk(KERN_NOTICE "SMP motherboard not detected.\n");
18507                 io_apic_irqs = 0;
18508                 cpu_online_map = cpumask_of_cpu(0);
18509 -               phys_cpu_present_map = cpumask_of_cpu(0);
18510 +               phys_cpu_present_map = physid_mask_of_physid(0);
18511                 if (APIC_init_uniprocessor())
18512                         printk(KERN_NOTICE "Local APIC not detected."
18513                                            " Using dummy APIC emulation.\n");
18514 @@ -759,10 +759,10 @@
18515          * Should not be necessary because the MP table should list the boot
18516          * CPU too, but we do it for the sake of robustness anyway.
18517          */
18518 -       if (!cpu_isset(boot_cpu_id, phys_cpu_present_map)) {
18519 +       if (!physid_isset(boot_cpu_id, phys_cpu_present_map)) {
18520                 printk(KERN_NOTICE "weird, boot CPU (#%d) not listed by the BIOS.\n",
18521                                                                  boot_cpu_id);
18522 -               cpu_set(hard_smp_processor_id(), phys_cpu_present_map);
18523 +               physid_set(hard_smp_processor_id(), phys_cpu_present_map);
18524         }
18525  
18526         /*
18527 @@ -774,7 +774,7 @@
18528                 printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
18529                 io_apic_irqs = 0;
18530                 cpu_online_map = cpumask_of_cpu(0);
18531 -               phys_cpu_present_map = cpumask_of_cpu(0);
18532 +               phys_cpu_present_map = physid_mask_of_physid(0);
18533                 disable_apic = 1;
18534                 goto smp_done;
18535         }
18536 @@ -789,7 +789,7 @@
18537                 printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n");
18538                 io_apic_irqs = 0;
18539                 cpu_online_map = cpumask_of_cpu(0);
18540 -               phys_cpu_present_map = cpumask_of_cpu(0);
18541 +               phys_cpu_present_map = physid_mask_of_physid(0);
18542                 disable_apic = 1;
18543                 goto smp_done;
18544         }
18545 @@ -803,7 +803,7 @@
18546         /*
18547          * Now scan the CPU present map and fire up the other CPUs.
18548          */
18549 -       Dprintk("CPU present map: %lx\n", phys_cpu_present_map);
18550 +       Dprintk("CPU present map: %lx\n", physids_coerce(phys_cpu_present_map));
18551  
18552         for (apicid = 0; apicid < NR_CPUS; apicid++) {
18553                 /*
18554 diff -Nru a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
18555 --- a/arch/x86_64/kernel/time.c Thu Jul 10 22:22:57 2003
18556 +++ b/arch/x86_64/kernel/time.c Sat Aug 23 04:31:18 2003
18557 @@ -79,6 +79,7 @@
18558         unsigned long t;
18559         unsigned long x;
18560         rdtscll_sync(&t);
18561 +       if (t < vxtime.last_tsc) t = vxtime.last_tsc; /* hack */
18562         x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32;
18563         return x;
18564  }
18565 diff -Nru a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
18566 --- a/arch/x86_64/kernel/vsyscall.c     Fri Jun 13 01:16:29 2003
18567 +++ b/arch/x86_64/kernel/vsyscall.c     Sat Aug 23 04:31:40 2003
18568 @@ -85,6 +85,7 @@
18569                 if (__vxtime.mode == VXTIME_TSC) {
18570                         sync_core();
18571                         rdtscll(t);
18572 +                       if (t < __vxtime.last_tsc) t = __vxtime.last_tsc;
18573                         usec += ((t - __vxtime.last_tsc) *
18574                                  __vxtime.tsc_quot) >> 32;
18575                 } else {
18576 diff -Nru a/drivers/Makefile b/drivers/Makefile
18577 --- a/drivers/Makefile  Tue Aug 12 08:42:21 2003
18578 +++ b/drivers/Makefile  Sun Aug 24 07:59:26 2003
18579 @@ -20,6 +20,7 @@
18580  obj-y                          += base/ block/ misc/ net/ media/
18581  obj-$(CONFIG_NUBUS)            += nubus/
18582  obj-$(CONFIG_ATM)              += atm/
18583 +obj-$(CONFIG_PPC_PMAC)         += macintosh/
18584  obj-$(CONFIG_IDE)              += ide/
18585  obj-$(CONFIG_FC4)              += fc4/
18586  obj-$(CONFIG_SCSI)             += scsi/
18587 @@ -31,7 +32,6 @@
18588  obj-$(CONFIG_DIO)              += dio/
18589  obj-$(CONFIG_SBUS)             += sbus/
18590  obj-$(CONFIG_ZORRO)            += zorro/
18591 -obj-$(CONFIG_PPC_PMAC)         += macintosh/
18592  obj-$(CONFIG_MAC)              += macintosh/
18593  obj-$(CONFIG_PARIDE)           += block/paride/
18594  obj-$(CONFIG_TC)               += tc/
18595 diff -Nru a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c
18596 --- a/drivers/acorn/block/fd1772.c      Thu Aug  7 02:25:23 2003
18597 +++ b/drivers/acorn/block/fd1772.c      Tue Aug 26 09:25:40 2003
18598 @@ -1455,8 +1455,8 @@
18599  
18600  static int floppy_open(struct inode *inode, struct file *filp)
18601  {
18602 -       int drive = minor(inode->i_rdev) & 3;
18603 -       int type =  minor(inode->i_rdev) >> 2;
18604 +       int drive = iminor(inode) & 3;
18605 +       int type =  iminor(inode) >> 2;
18606         int old_dev = fd_device[drive];
18607  
18608         if (fd_ref[drive] && old_dev != type)
18609 @@ -1490,7 +1490,7 @@
18610  
18611  static int floppy_release(struct inode *inode, struct file *filp)
18612  {
18613 -       int drive = minor(inode->i_rdev) & 3;
18614 +       int drive = iminor(inode) & 3;
18615  
18616         if (fd_ref[drive] < 0)
18617                 fd_ref[drive] = 0;
18618 diff -Nru a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
18619 --- a/drivers/acpi/Kconfig      Wed Aug 20 09:06:49 2003
18620 +++ b/drivers/acpi/Kconfig      Sat Aug 23 04:07:34 2003
18621 @@ -69,6 +69,7 @@
18622         bool "Sleep States (EXPERIMENTAL)"
18623         depends on X86 && ACPI
18624         depends on EXPERIMENTAL && PM
18625 +       select SOFTWARE_SUSPEND
18626         default y
18627         ---help---
18628           This option adds support for ACPI suspend states. 
18629 diff -Nru a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
18630 --- a/drivers/acpi/pci_link.c   Tue Jul 29 13:28:29 2003
18631 +++ b/drivers/acpi/pci_link.c   Sun Aug 31 16:14:25 2003
18632 @@ -516,9 +516,8 @@
18633                 return_VALUE(0);
18634         }
18635  
18636 -       if (acpi_pci_link_allocate(link)) {
18637 -               return -ENODEV;
18638 -       }
18639 +       if (acpi_pci_link_allocate(link))
18640 +               return_VALUE(0);
18641            
18642         if (!link->irq.active) {
18643                 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link disabled\n"));
18644 diff -Nru a/drivers/atm/Kconfig b/drivers/atm/Kconfig
18645 --- a/drivers/atm/Kconfig       Tue Jul 29 22:31:46 2003
18646 +++ b/drivers/atm/Kconfig       Mon Aug 25 06:04:02 2003
18647 @@ -241,7 +241,7 @@
18648  
18649  config ATM_AMBASSADOR
18650         tristate "Madge Ambassador (Collage PCI 155 Server)"
18651 -       depends on PCI && ATM
18652 +       depends on PCI && ATM && BROKEN_ON_SMP
18653         help
18654           This is a driver for ATMizer based ATM card produced by Madge
18655           Networks Ltd. Say Y (or M to compile as a module named ambassador)
18656 diff -Nru a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
18657 --- a/drivers/atm/ambassador.c  Tue Aug 19 21:10:45 2003
18658 +++ b/drivers/atm/ambassador.c  Wed Aug 27 23:17:10 2003
18659 @@ -310,10 +310,11 @@
18660    0xdeadbeef
18661  };
18662  
18663 +static void do_housekeeping (unsigned long arg);
18664  /********** globals **********/
18665  
18666  static amb_dev * amb_devs = NULL;
18667 -static struct timer_list housekeeping;
18668 +static struct timer_list housekeeping = TIMER_INITIALIZER(do_housekeeping, 0, 1);
18669  
18670  static unsigned short debug = 0;
18671  static unsigned int cmds = 8;
18672 @@ -937,63 +938,6 @@
18673    return IRQ_HANDLED;
18674  }
18675  
18676 -/********** don't panic... yeah, right **********/
18677 -
18678 -#ifdef DEBUG_AMBASSADOR
18679 -static void dont_panic (amb_dev * dev) {
18680 -  amb_cq * cq = &dev->cq;
18681 -  volatile amb_cq_ptrs * ptrs = &cq->ptrs;
18682 -  amb_txq * txq;
18683 -  amb_rxq * rxq;
18684 -  command * cmd;
18685 -  tx_in * tx;
18686 -  tx_simple * tx_descr;
18687 -  unsigned char pool;
18688 -  rx_in * rx;
18689 -  
18690 -  unsigned long flags;
18691 -  save_flags (flags);
18692 -  cli();
18693 -  
18694 -  PRINTK (KERN_INFO, "don't panic - putting adapter into reset");
18695 -  wr_plain (dev, offsetof(amb_mem, reset_control),
18696 -           rd_plain (dev, offsetof(amb_mem, reset_control)) | AMB_RESET_BITS);
18697 -  
18698 -  PRINTK (KERN_INFO, "marking all commands complete");
18699 -  for (cmd = ptrs->start; cmd < ptrs->limit; ++cmd)
18700 -    cmd->request = cpu_to_be32 (SRB_COMPLETE);
18701 -
18702 -  PRINTK (KERN_INFO, "completing all TXs");
18703 -  txq = &dev->txq;
18704 -  tx = txq->in.ptr;
18705 -  while (txq->pending--) {
18706 -    if (tx == txq->in.start)
18707 -      tx = txq->in.limit;
18708 -    --tx;
18709 -    tx_descr = bus_to_virt (be32_to_cpu (tx->tx_descr_addr));
18710 -    amb_kfree_skb (tx_descr->skb);
18711 -    kfree (tx_descr);
18712 -  }
18713 -  
18714 -  PRINTK (KERN_INFO, "freeing all RX buffers");
18715 -  for (pool = 0; pool < NUM_RX_POOLS; ++pool) {
18716 -    rxq = &dev->rxq[pool];
18717 -    rx = rxq->in.ptr;
18718 -    while (rxq->pending--) {
18719 -      if (rx == rxq->in.start)
18720 -       rx = rxq->in.limit;
18721 -      --rx;
18722 -      dev_kfree_skb_any (bus_to_virt (rx->handle));
18723 -    }
18724 -  }
18725 -  
18726 -  PRINTK (KERN_INFO, "don't panic over - close all VCs and rmmod");
18727 -  set_bit (dead, &dev->flags);
18728 -  restore_flags (flags);
18729 -  return;
18730 -}
18731 -#endif
18732 -
18733  /********** make rate (not quite as much fun as Horizon) **********/
18734  
18735  static unsigned int make_rate (unsigned int rate, rounding r,
18736 @@ -1420,32 +1364,6 @@
18737    return;
18738  }
18739  
18740 -/********** Debug\17Ioctl **********/
18741 -
18742 -#if 0
18743 -static int amb_ioctl (struct atm_dev * dev, unsigned int cmd, void * arg) {
18744 -  unsigned short newdebug;
18745 -  if (cmd == AMB_SETDEBUG) {
18746 -    if (!capable(CAP_NET_ADMIN))
18747 -      return -EPERM;
18748 -    if (copy_from_user (&newdebug, arg, sizeof(newdebug))) {
18749 -      // moan
18750 -      return -EFAULT;
18751 -    } else {
18752 -      debug = newdebug;
18753 -      return 0;
18754 -    }
18755 -  } else if (cmd == AMB_DONTPANIC) {
18756 -    if (!capable(CAP_NET_ADMIN))
18757 -      return -EPERM;
18758 -    dont_panic (dev);
18759 -  } else {
18760 -    // moan
18761 -    return -ENOIOCTLCMD;
18762 -  }
18763 -}
18764 -#endif
18765 -
18766  /********** Set socket options for a VC **********/
18767  
18768  // int amb_getsockopt (struct atm_vcc * atm_vcc, int level, int optname, void * optval, int optlen);
18769 @@ -1524,33 +1442,6 @@
18770    tx.tx_descr_length = cpu_to_be16 (sizeof(tx_frag)+sizeof(tx_frag_end));
18771    tx.tx_descr_addr = cpu_to_be32 (virt_to_bus (&tx_descr->tx_frag));
18772    
18773 -#ifdef DEBUG_AMBASSADOR
18774 -  /* wey-hey! */
18775 -  if (vc == 1023) {
18776 -    unsigned int i;
18777 -    unsigned short d = 0;
18778 -    char * s = skb->data;
18779 -    switch (*s++) {
18780 -      case 'D': {
18781 -       for (i = 0; i < 4; ++i) {
18782 -         d = (d<<4) | ((*s <= '9') ? (*s - '0') : (*s - 'a' + 10));
18783 -         ++s;
18784 -       }
18785 -       PRINTK (KERN_INFO, "debug bitmap is now %hx", debug = d);
18786 -       break;
18787 -      }
18788 -      case 'R': {
18789 -       if (*s++ == 'e' && *s++ == 's' && *s++ == 'e' && *s++ == 't')
18790 -         dont_panic (dev);
18791 -       break;
18792 -      }
18793 -      default: {
18794 -       break;
18795 -      }
18796 -    }
18797 -  }
18798 -#endif
18799 -  
18800    while (tx_give (dev, &tx))
18801      schedule();
18802    return 0;
18803 @@ -1663,21 +1554,14 @@
18804  /********** Operation Structure **********/
18805  
18806  static const struct atmdev_ops amb_ops = {
18807 -  .open        = amb_open,
18808 +  .open         = amb_open,
18809    .close       = amb_close,
18810 -  .send        = amb_send,
18811 +  .send         = amb_send,
18812    .proc_read   = amb_proc_read,
18813    .owner       = THIS_MODULE,
18814  };
18815  
18816  /********** housekeeping **********/
18817 -
18818 -static inline void set_timer (struct timer_list * timer, unsigned long delay) {
18819 -  timer->expires = jiffies + delay;
18820 -  add_timer (timer);
18821 -  return;
18822 -}
18823 -
18824  static void do_housekeeping (unsigned long arg) {
18825    amb_dev * dev = amb_devs;
18826    // data is set to zero at module unload
18827 @@ -1693,7 +1577,7 @@
18828        
18829        dev = dev->prev;
18830      }
18831 -    set_timer (&housekeeping, 10*HZ);
18832 +    mod_timer(&housekeeping, jiffies + 10*HZ);
18833    }
18834    
18835    return;
18836 @@ -2579,11 +2463,7 @@
18837    devs = amb_probe();
18838    
18839    if (devs) {
18840 -    init_timer (&housekeeping);
18841 -    housekeeping.function = do_housekeeping;
18842 -    // paranoia
18843 -    housekeeping.data = 1;
18844 -    set_timer (&housekeeping, 0);
18845 +    mod_timer (&housekeeping, jiffies);
18846    } else {
18847      PRINTK (KERN_INFO, "no (usable) adapters found");
18848    }
18849 @@ -2600,7 +2480,7 @@
18850    
18851    // paranoia
18852    housekeeping.data = 0;
18853 -  del_timer (&housekeeping);
18854 +  del_timer_sync(&housekeeping);
18855    
18856    while (amb_devs) {
18857      dev = amb_devs;
18858 diff -Nru a/drivers/atm/eni.c b/drivers/atm/eni.c
18859 --- a/drivers/atm/eni.c Tue Aug 19 21:10:45 2003
18860 +++ b/drivers/atm/eni.c Mon Sep  1 08:23:55 2003
18861 @@ -1809,10 +1809,6 @@
18862                     "master (0x%02x)\n",dev->number,error);
18863                 return error;
18864         }
18865 -#ifdef __sparc_v9__ /* copied from drivers/net/sunhme.c */
18866 -       /* NOTE: Cache line size is in 32-bit word units. */
18867 -       pci_write_config_byte(eni_dev->pci_dev, PCI_CACHE_LINE_SIZE, 0x10);
18868 -#endif
18869         if ((error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,
18870             END_SWAP_DMA))) {
18871                 printk(KERN_ERR DEV_LABEL "(itf %d): can't set endian swap "
18872 @@ -2345,7 +2341,7 @@
18873         struct sk_buff *skb; /* dummy for sizeof */
18874  
18875         if (sizeof(skb->cb) < sizeof(struct eni_skb_prv)) {
18876 -               printk(KERN_ERR "eni_detect: skb->cb is too small (%d < %d)\n",
18877 +               printk(KERN_ERR "eni_detect: skb->cb is too small (%Zd < %Zd)\n",
18878                     sizeof(skb->cb),sizeof(struct eni_skb_prv));
18879                 return -EIO;
18880         }
18881 diff -Nru a/drivers/atm/firestream.c b/drivers/atm/firestream.c
18882 --- a/drivers/atm/firestream.c  Tue Aug 19 21:10:45 2003
18883 +++ b/drivers/atm/firestream.c  Sun Aug 31 16:14:27 2003
18884 @@ -895,7 +895,7 @@
18885         /* XXX handle qos parameters (rate limiting) ? */
18886  
18887         vcc = kmalloc(sizeof(struct fs_vcc), GFP_KERNEL);
18888 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc VCC: %p(%d)\n", vcc, sizeof(struct fs_vcc));
18889 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc VCC: %p(%Zd)\n", vcc, sizeof(struct fs_vcc));
18890         if (!vcc) {
18891                 clear_bit(ATM_VF_ADDR, &atm_vcc->flags);
18892                 return -ENOMEM;
18893 @@ -946,7 +946,7 @@
18894  
18895         if (DO_DIRECTION (txtp)) {
18896                 tc = kmalloc (sizeof (struct fs_transmit_config), GFP_KERNEL);
18897 -               fs_dprintk (FS_DEBUG_ALLOC, "Alloc tc: %p(%d)\n", 
18898 +               fs_dprintk (FS_DEBUG_ALLOC, "Alloc tc: %p(%Zd)\n",
18899                             tc, sizeof (struct fs_transmit_config));
18900                 if (!tc) {
18901                         fs_dprintk (FS_DEBUG_OPEN, "fs: can't alloc transmit_config.\n");
18902 @@ -1180,7 +1180,7 @@
18903         vcc->last_skb = skb;
18904  
18905         td = kmalloc (sizeof (struct FS_BPENTRY), GFP_ATOMIC);
18906 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc transd: %p(%d)\n", td, sizeof (struct FS_BPENTRY));
18907 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc transd: %p(%Zd)\n", td, sizeof (struct FS_BPENTRY));
18908         if (!td) {
18909                 /* Oops out of mem */
18910                 return -ENOMEM;
18911 @@ -1487,7 +1487,7 @@
18912                 fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-skb: %p(%d)\n", skb, fp->bufsize);
18913                 if (!skb) break;
18914                 ne = kmalloc (sizeof (struct FS_BPENTRY), gfp_flags);
18915 -               fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-d: %p(%d)\n", ne, sizeof (struct FS_BPENTRY));
18916 +               fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-d: %p(%Zd)\n", ne, sizeof (struct FS_BPENTRY));
18917                 if (!ne) {
18918                         fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p\n", skb);
18919                         dev_kfree_skb_any (skb);
18920 @@ -1792,7 +1792,7 @@
18921         }
18922         dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *), 
18923                                  GFP_KERNEL);
18924 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%d)\n", 
18925 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
18926                     dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
18927  
18928         if (!dev->atm_vccs) {
18929 @@ -1900,7 +1900,7 @@
18930                 goto err_out;
18931  
18932         fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
18933 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%d)\n", 
18934 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
18935                     fs_dev, sizeof (struct fs_dev));
18936         if (!fs_dev)
18937                 goto err_out;
18938 diff -Nru a/drivers/block/DAC960.c b/drivers/block/DAC960.c
18939 --- a/drivers/block/DAC960.c    Fri Aug 15 09:39:48 2003
18940 +++ b/drivers/block/DAC960.c    Sun Aug 31 16:13:56 2003
18941 @@ -23,6 +23,7 @@
18942  #include <linux/version.h>
18943  #include <linux/module.h>
18944  #include <linux/types.h>
18945 +#include <linux/miscdevice.h>
18946  #include <linux/blkdev.h>
18947  #include <linux/bio.h>
18948  #include <linux/completion.h>
18949 @@ -44,6 +45,8 @@
18950  #include <asm/uaccess.h>
18951  #include "DAC960.h"
18952  
18953 +#define DAC960_GAM_MINOR       252
18954 +
18955  
18956  static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers];
18957  static int DAC960_ControllerCount;
18958 @@ -71,10 +74,6 @@
18959         DAC960_Controller_T *p = disk->queue->queuedata;
18960         int drive_nr = (int)disk->private_data;
18961  
18962 -       /* bad hack for the "user" ioctls */
18963 -       if (!p->ControllerNumber && !drive_nr && (file->f_flags & O_NONBLOCK))
18964 -               return 0;
18965 -
18966         if (p->FirmwareType == DAC960_V1_Controller) {
18967                 if (p->V1.LogicalDriveInformation[drive_nr].
18968                     LogicalDriveState == DAC960_V1_LogicalDrive_Offline)
18969 @@ -101,9 +100,6 @@
18970         int drive_nr = (int)disk->private_data;
18971         struct hd_geometry g, *loc = (struct hd_geometry *)arg;
18972  
18973 -       if (file && (file->f_flags & O_NONBLOCK))
18974 -               return DAC960_UserIOCTL(inode, file, cmd, arg);
18975 -
18976         if (cmd != HDIO_GETGEO || !loc)
18977                 return -EINVAL;
18978  
18979 @@ -5569,407 +5565,6 @@
18980  }
18981  
18982  /*
18983 -  DAC960_UserIOCTL is the User IOCTL Function for the DAC960 Driver.
18984 -*/
18985 -
18986 -static int DAC960_UserIOCTL(struct inode *inode, struct file *file,
18987 -                           unsigned int Request, unsigned long Argument)
18988 -{
18989 -  int ErrorCode = 0;
18990 -  if (!capable(CAP_SYS_ADMIN)) return -EACCES;
18991 -  switch (Request)
18992 -    {
18993 -    case DAC960_IOCTL_GET_CONTROLLER_COUNT:
18994 -      return DAC960_ControllerCount;
18995 -    case DAC960_IOCTL_GET_CONTROLLER_INFO:
18996 -      {
18997 -       DAC960_ControllerInfo_T *UserSpaceControllerInfo =
18998 -         (DAC960_ControllerInfo_T *) Argument;
18999 -       DAC960_ControllerInfo_T ControllerInfo;
19000 -       DAC960_Controller_T *Controller;
19001 -       int ControllerNumber;
19002 -       if (UserSpaceControllerInfo == NULL) return -EINVAL;
19003 -       ErrorCode = get_user(ControllerNumber,
19004 -                            &UserSpaceControllerInfo->ControllerNumber);
19005 -       if (ErrorCode != 0) return ErrorCode;
19006 -       if (ControllerNumber < 0 ||
19007 -           ControllerNumber > DAC960_ControllerCount - 1)
19008 -         return -ENXIO;
19009 -       Controller = DAC960_Controllers[ControllerNumber];
19010 -       if (Controller == NULL) return -ENXIO;
19011 -       memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
19012 -       ControllerInfo.ControllerNumber = ControllerNumber;
19013 -       ControllerInfo.FirmwareType = Controller->FirmwareType;
19014 -       ControllerInfo.Channels = Controller->Channels;
19015 -       ControllerInfo.Targets = Controller->Targets;
19016 -       ControllerInfo.PCI_Bus = Controller->Bus;
19017 -       ControllerInfo.PCI_Device = Controller->Device;
19018 -       ControllerInfo.PCI_Function = Controller->Function;
19019 -       ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
19020 -       ControllerInfo.PCI_Address = Controller->PCI_Address;
19021 -       strcpy(ControllerInfo.ModelName, Controller->ModelName);
19022 -       strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
19023 -       return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
19024 -                            sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
19025 -      }
19026 -    case DAC960_IOCTL_V1_EXECUTE_COMMAND:
19027 -      {
19028 -       DAC960_V1_UserCommand_T *UserSpaceUserCommand =
19029 -         (DAC960_V1_UserCommand_T *) Argument;
19030 -       DAC960_V1_UserCommand_T UserCommand;
19031 -       DAC960_Controller_T *Controller;
19032 -       DAC960_Command_T *Command = NULL;
19033 -       DAC960_V1_CommandOpcode_T CommandOpcode;
19034 -       DAC960_V1_CommandStatus_T CommandStatus;
19035 -       DAC960_V1_DCDB_T DCDB;
19036 -       DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
19037 -       dma_addr_t      DCDB_IOBUFDMA;
19038 -       unsigned long flags;
19039 -       int ControllerNumber, DataTransferLength;
19040 -       unsigned char *DataTransferBuffer = NULL;
19041 -       dma_addr_t DataTransferBufferDMA;
19042 -       if (UserSpaceUserCommand == NULL) return -EINVAL;
19043 -       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
19044 -                                  sizeof(DAC960_V1_UserCommand_T))) {
19045 -               ErrorCode = -EFAULT;
19046 -               goto Failure1a;
19047 -       }
19048 -       ControllerNumber = UserCommand.ControllerNumber;
19049 -       if (ControllerNumber < 0 ||
19050 -           ControllerNumber > DAC960_ControllerCount - 1)
19051 -         return -ENXIO;
19052 -       Controller = DAC960_Controllers[ControllerNumber];
19053 -       if (Controller == NULL) return -ENXIO;
19054 -       if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
19055 -       CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
19056 -       DataTransferLength = UserCommand.DataTransferLength;
19057 -       if (CommandOpcode & 0x80) return -EINVAL;
19058 -       if (CommandOpcode == DAC960_V1_DCDB)
19059 -         {
19060 -           if (copy_from_user(&DCDB, UserCommand.DCDB,
19061 -                              sizeof(DAC960_V1_DCDB_T))) {
19062 -               ErrorCode = -EFAULT;
19063 -               goto Failure1a;
19064 -           }
19065 -           if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
19066 -           if (!((DataTransferLength == 0 &&
19067 -                  DCDB.Direction
19068 -                  == DAC960_V1_DCDB_NoDataTransfer) ||
19069 -                 (DataTransferLength > 0 &&
19070 -                  DCDB.Direction
19071 -                  == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
19072 -                 (DataTransferLength < 0 &&
19073 -                  DCDB.Direction
19074 -                  == DAC960_V1_DCDB_DataTransferSystemToDevice)))
19075 -             return -EINVAL;
19076 -           if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
19077 -               != abs(DataTransferLength))
19078 -             return -EINVAL;
19079 -           DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
19080 -                       sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
19081 -           if (DCDB_IOBUF == NULL)
19082 -                       return -ENOMEM;
19083 -         }
19084 -       if (DataTransferLength > 0)
19085 -         {
19086 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
19087 -                               DataTransferLength, &DataTransferBufferDMA);
19088 -           if (DataTransferBuffer == NULL) {
19089 -               ErrorCode = -ENOMEM;
19090 -               goto Failure1;
19091 -           }
19092 -           memset(DataTransferBuffer, 0, DataTransferLength);
19093 -         }
19094 -       else if (DataTransferLength < 0)
19095 -         {
19096 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
19097 -                               -DataTransferLength, &DataTransferBufferDMA);
19098 -           if (DataTransferBuffer == NULL) {
19099 -               ErrorCode = -ENOMEM;
19100 -               goto Failure1;
19101 -           }
19102 -           if (copy_from_user(DataTransferBuffer,
19103 -                              UserCommand.DataTransferBuffer,
19104 -                              -DataTransferLength)) {
19105 -               ErrorCode = -EFAULT;
19106 -               goto Failure1;
19107 -           }
19108 -         }
19109 -       if (CommandOpcode == DAC960_V1_DCDB)
19110 -         {
19111 -           spin_lock_irqsave(&Controller->queue_lock, flags);
19112 -           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
19113 -             DAC960_WaitForCommand(Controller);
19114 -           while (Controller->V1.DirectCommandActive[DCDB.Channel]
19115 -                                                    [DCDB.TargetID])
19116 -             {
19117 -               spin_unlock_irq(&Controller->queue_lock);
19118 -               __wait_event(Controller->CommandWaitQueue,
19119 -                            !Controller->V1.DirectCommandActive
19120 -                                            [DCDB.Channel][DCDB.TargetID]);
19121 -               spin_lock_irq(&Controller->queue_lock);
19122 -             }
19123 -           Controller->V1.DirectCommandActive[DCDB.Channel]
19124 -                                             [DCDB.TargetID] = true;
19125 -           spin_unlock_irqrestore(&Controller->queue_lock, flags);
19126 -           DAC960_V1_ClearCommand(Command);
19127 -           Command->CommandType = DAC960_ImmediateCommand;
19128 -           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
19129 -                  sizeof(DAC960_V1_CommandMailbox_T));
19130 -           Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
19131 -           DCDB.BusAddress = DataTransferBufferDMA;
19132 -           memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
19133 -         }
19134 -       else
19135 -         {
19136 -           spin_lock_irqsave(&Controller->queue_lock, flags);
19137 -           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
19138 -             DAC960_WaitForCommand(Controller);
19139 -           spin_unlock_irqrestore(&Controller->queue_lock, flags);
19140 -           DAC960_V1_ClearCommand(Command);
19141 -           Command->CommandType = DAC960_ImmediateCommand;
19142 -           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
19143 -                  sizeof(DAC960_V1_CommandMailbox_T));
19144 -           if (DataTransferBuffer != NULL)
19145 -             Command->V1.CommandMailbox.Type3.BusAddress =
19146 -               DataTransferBufferDMA;
19147 -         }
19148 -       DAC960_ExecuteCommand(Command);
19149 -       CommandStatus = Command->V1.CommandStatus;
19150 -       spin_lock_irqsave(&Controller->queue_lock, flags);
19151 -       DAC960_DeallocateCommand(Command);
19152 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
19153 -       if (DataTransferLength > 0)
19154 -         {
19155 -           if (copy_to_user(UserCommand.DataTransferBuffer,
19156 -                            DataTransferBuffer, DataTransferLength)) {
19157 -               ErrorCode = -EFAULT;
19158 -               goto Failure1;
19159 -            }
19160 -         }
19161 -       if (CommandOpcode == DAC960_V1_DCDB)
19162 -         {
19163 -           /*
19164 -             I don't believe Target or Channel in the DCDB_IOBUF
19165 -             should be any different from the contents of DCDB.
19166 -            */
19167 -           Controller->V1.DirectCommandActive[DCDB.Channel]
19168 -                                             [DCDB.TargetID] = false;
19169 -           if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
19170 -                            sizeof(DAC960_V1_DCDB_T))) {
19171 -               ErrorCode = -EFAULT;
19172 -               goto Failure1;
19173 -           }
19174 -         }
19175 -       ErrorCode = CommandStatus;
19176 -      Failure1:
19177 -       if (DataTransferBuffer != NULL)
19178 -         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
19179 -                       DataTransferBuffer, DataTransferBufferDMA);
19180 -       if (DCDB_IOBUF != NULL)
19181 -         pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
19182 -                       DCDB_IOBUF, DCDB_IOBUFDMA);
19183 -      Failure1a:
19184 -       return ErrorCode;
19185 -      }
19186 -    case DAC960_IOCTL_V2_EXECUTE_COMMAND:
19187 -      {
19188 -       DAC960_V2_UserCommand_T *UserSpaceUserCommand =
19189 -         (DAC960_V2_UserCommand_T *) Argument;
19190 -       DAC960_V2_UserCommand_T UserCommand;
19191 -       DAC960_Controller_T *Controller;
19192 -       DAC960_Command_T *Command = NULL;
19193 -       DAC960_V2_CommandMailbox_T *CommandMailbox;
19194 -       DAC960_V2_CommandStatus_T CommandStatus;
19195 -       unsigned long flags;
19196 -       int ControllerNumber, DataTransferLength;
19197 -       int DataTransferResidue, RequestSenseLength;
19198 -       unsigned char *DataTransferBuffer = NULL;
19199 -       dma_addr_t DataTransferBufferDMA;
19200 -       unsigned char *RequestSenseBuffer = NULL;
19201 -       dma_addr_t RequestSenseBufferDMA;
19202 -       if (UserSpaceUserCommand == NULL) return -EINVAL;
19203 -       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
19204 -                          sizeof(DAC960_V2_UserCommand_T))) {
19205 -               ErrorCode = -EFAULT;
19206 -               goto Failure2a;
19207 -       }
19208 -       ControllerNumber = UserCommand.ControllerNumber;
19209 -       if (ControllerNumber < 0 ||
19210 -           ControllerNumber > DAC960_ControllerCount - 1)
19211 -         return -ENXIO;
19212 -       Controller = DAC960_Controllers[ControllerNumber];
19213 -       if (Controller == NULL) return -ENXIO;
19214 -       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
19215 -       DataTransferLength = UserCommand.DataTransferLength;
19216 -       if (DataTransferLength > 0)
19217 -         {
19218 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
19219 -                               DataTransferLength, &DataTransferBufferDMA);
19220 -           if (DataTransferBuffer == NULL) return -ENOMEM;
19221 -           memset(DataTransferBuffer, 0, DataTransferLength);
19222 -         }
19223 -       else if (DataTransferLength < 0)
19224 -         {
19225 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
19226 -                               -DataTransferLength, &DataTransferBufferDMA);
19227 -           if (DataTransferBuffer == NULL) return -ENOMEM;
19228 -           if (copy_from_user(DataTransferBuffer,
19229 -                              UserCommand.DataTransferBuffer,
19230 -                              -DataTransferLength)) {
19231 -               ErrorCode = -EFAULT;
19232 -               goto Failure2;
19233 -           }
19234 -         }
19235 -       RequestSenseLength = UserCommand.RequestSenseLength;
19236 -       if (RequestSenseLength > 0)
19237 -         {
19238 -           RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
19239 -                       RequestSenseLength, &RequestSenseBufferDMA);
19240 -           if (RequestSenseBuffer == NULL)
19241 -             {
19242 -               ErrorCode = -ENOMEM;
19243 -               goto Failure2;
19244 -             }
19245 -           memset(RequestSenseBuffer, 0, RequestSenseLength);
19246 -         }
19247 -       spin_lock_irqsave(&Controller->queue_lock, flags);
19248 -       while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
19249 -         DAC960_WaitForCommand(Controller);
19250 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
19251 -       DAC960_V2_ClearCommand(Command);
19252 -       Command->CommandType = DAC960_ImmediateCommand;
19253 -       CommandMailbox = &Command->V2.CommandMailbox;
19254 -       memcpy(CommandMailbox, &UserCommand.CommandMailbox,
19255 -              sizeof(DAC960_V2_CommandMailbox_T));
19256 -       CommandMailbox->Common.CommandControlBits
19257 -                             .AdditionalScatterGatherListMemory = false;
19258 -       CommandMailbox->Common.CommandControlBits
19259 -                             .NoAutoRequestSense = true;
19260 -       CommandMailbox->Common.DataTransferSize = 0;
19261 -       CommandMailbox->Common.DataTransferPageNumber = 0;
19262 -       memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
19263 -              sizeof(DAC960_V2_DataTransferMemoryAddress_T));
19264 -       if (DataTransferLength != 0)
19265 -         {
19266 -           if (DataTransferLength > 0)
19267 -             {
19268 -               CommandMailbox->Common.CommandControlBits
19269 -                                     .DataTransferControllerToHost = true;
19270 -               CommandMailbox->Common.DataTransferSize = DataTransferLength;
19271 -             }
19272 -           else
19273 -             {
19274 -               CommandMailbox->Common.CommandControlBits
19275 -                                     .DataTransferControllerToHost = false;
19276 -               CommandMailbox->Common.DataTransferSize = -DataTransferLength;
19277 -             }
19278 -           CommandMailbox->Common.DataTransferMemoryAddress
19279 -                                 .ScatterGatherSegments[0]
19280 -                                 .SegmentDataPointer = DataTransferBufferDMA;
19281 -           CommandMailbox->Common.DataTransferMemoryAddress
19282 -                                 .ScatterGatherSegments[0]
19283 -                                 .SegmentByteCount =
19284 -             CommandMailbox->Common.DataTransferSize;
19285 -         }
19286 -       if (RequestSenseLength > 0)
19287 -         {
19288 -           CommandMailbox->Common.CommandControlBits
19289 -                                 .NoAutoRequestSense = false;
19290 -           CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
19291 -           CommandMailbox->Common.RequestSenseBusAddress =
19292 -                                                       RequestSenseBufferDMA;
19293 -         }
19294 -       DAC960_ExecuteCommand(Command);
19295 -       CommandStatus = Command->V2.CommandStatus;
19296 -       RequestSenseLength = Command->V2.RequestSenseLength;
19297 -       DataTransferResidue = Command->V2.DataTransferResidue;
19298 -       spin_lock_irqsave(&Controller->queue_lock, flags);
19299 -       DAC960_DeallocateCommand(Command);
19300 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
19301 -       if (RequestSenseLength > UserCommand.RequestSenseLength)
19302 -         RequestSenseLength = UserCommand.RequestSenseLength;
19303 -       if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
19304 -                                &DataTransferResidue,
19305 -                                sizeof(DataTransferResidue))) {
19306 -               ErrorCode = -EFAULT;
19307 -               goto Failure2;
19308 -       }
19309 -       if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
19310 -                        &RequestSenseLength, sizeof(RequestSenseLength))) {
19311 -               ErrorCode = -EFAULT;
19312 -               goto Failure2;
19313 -       }
19314 -       if (DataTransferLength > 0)
19315 -         {
19316 -           if (copy_to_user(UserCommand.DataTransferBuffer,
19317 -                            DataTransferBuffer, DataTransferLength)) {
19318 -               ErrorCode = -EFAULT;
19319 -               goto Failure2;
19320 -           }
19321 -         }
19322 -       if (RequestSenseLength > 0)
19323 -         {
19324 -           if (copy_to_user(UserCommand.RequestSenseBuffer,
19325 -                            RequestSenseBuffer, RequestSenseLength)) {
19326 -               ErrorCode = -EFAULT;
19327 -               goto Failure2;
19328 -           }
19329 -         }
19330 -       ErrorCode = CommandStatus;
19331 -      Failure2:
19332 -         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
19333 -               DataTransferBuffer, DataTransferBufferDMA);
19334 -       if (RequestSenseBuffer != NULL)
19335 -         pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
19336 -               RequestSenseBuffer, RequestSenseBufferDMA);
19337 -      Failure2a:
19338 -       return ErrorCode;
19339 -      }
19340 -    case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
19341 -      {
19342 -       DAC960_V2_GetHealthStatus_T *UserSpaceGetHealthStatus =
19343 -         (DAC960_V2_GetHealthStatus_T *) Argument;
19344 -       DAC960_V2_GetHealthStatus_T GetHealthStatus;
19345 -       DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
19346 -       DAC960_Controller_T *Controller;
19347 -       int ControllerNumber;
19348 -       if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
19349 -       if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
19350 -                          sizeof(DAC960_V2_GetHealthStatus_T)))
19351 -               return -EFAULT;
19352 -       ControllerNumber = GetHealthStatus.ControllerNumber;
19353 -       if (ControllerNumber < 0 ||
19354 -           ControllerNumber > DAC960_ControllerCount - 1)
19355 -         return -ENXIO;
19356 -       Controller = DAC960_Controllers[ControllerNumber];
19357 -       if (Controller == NULL) return -ENXIO;
19358 -       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
19359 -       if (copy_from_user(&HealthStatusBuffer,
19360 -                          GetHealthStatus.HealthStatusBuffer,
19361 -                          sizeof(DAC960_V2_HealthStatusBuffer_T)))
19362 -               return -EFAULT;
19363 -       while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
19364 -              == HealthStatusBuffer.StatusChangeCounter &&
19365 -              Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
19366 -              == HealthStatusBuffer.NextEventSequenceNumber)
19367 -         {
19368 -           interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
19369 -                                          DAC960_MonitoringTimerInterval);
19370 -           if (signal_pending(current)) return -EINTR;
19371 -         }
19372 -       if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
19373 -                        Controller->V2.HealthStatusBuffer,
19374 -                        sizeof(DAC960_V2_HealthStatusBuffer_T)))
19375 -               return -EFAULT;
19376 -       return 0;
19377 -      }
19378 -    }
19379 -  return -EINVAL;
19380 -}
19381 -
19382 -
19383 -/*
19384    DAC960_CheckStatusBuffer verifies that there is room to hold ByteCount
19385    additional bytes in the Combined Status Buffer and grows the buffer if
19386    necessary.  It returns true if there is enough room and false otherwise.
19387 @@ -6901,6 +6496,436 @@
19388        Controller->ControllerProcEntry = NULL;
19389  }
19390  
19391 +#ifdef DAC960_GAM_MINOR
19392 +
19393 +/*
19394 + * DAC960_gam_ioctl is the ioctl function for performing RAID operations.
19395 +*/
19396 +
19397 +static int DAC960_gam_ioctl(struct inode *inode, struct file *file,
19398 +                           unsigned int Request, unsigned long Argument)
19399 +{
19400 +  int ErrorCode = 0;
19401 +  if (!capable(CAP_SYS_ADMIN)) return -EACCES;
19402 +  switch (Request)
19403 +    {
19404 +    case DAC960_IOCTL_GET_CONTROLLER_COUNT:
19405 +      return DAC960_ControllerCount;
19406 +    case DAC960_IOCTL_GET_CONTROLLER_INFO:
19407 +      {
19408 +       DAC960_ControllerInfo_T *UserSpaceControllerInfo =
19409 +         (DAC960_ControllerInfo_T *) Argument;
19410 +       DAC960_ControllerInfo_T ControllerInfo;
19411 +       DAC960_Controller_T *Controller;
19412 +       int ControllerNumber;
19413 +       if (UserSpaceControllerInfo == NULL) return -EINVAL;
19414 +       ErrorCode = get_user(ControllerNumber,
19415 +                            &UserSpaceControllerInfo->ControllerNumber);
19416 +       if (ErrorCode != 0) return ErrorCode;
19417 +       if (ControllerNumber < 0 ||
19418 +           ControllerNumber > DAC960_ControllerCount - 1)
19419 +         return -ENXIO;
19420 +       Controller = DAC960_Controllers[ControllerNumber];
19421 +       if (Controller == NULL) return -ENXIO;
19422 +       memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
19423 +       ControllerInfo.ControllerNumber = ControllerNumber;
19424 +       ControllerInfo.FirmwareType = Controller->FirmwareType;
19425 +       ControllerInfo.Channels = Controller->Channels;
19426 +       ControllerInfo.Targets = Controller->Targets;
19427 +       ControllerInfo.PCI_Bus = Controller->Bus;
19428 +       ControllerInfo.PCI_Device = Controller->Device;
19429 +       ControllerInfo.PCI_Function = Controller->Function;
19430 +       ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
19431 +       ControllerInfo.PCI_Address = Controller->PCI_Address;
19432 +       strcpy(ControllerInfo.ModelName, Controller->ModelName);
19433 +       strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
19434 +       return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
19435 +                            sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
19436 +      }
19437 +    case DAC960_IOCTL_V1_EXECUTE_COMMAND:
19438 +      {
19439 +       DAC960_V1_UserCommand_T *UserSpaceUserCommand =
19440 +         (DAC960_V1_UserCommand_T *) Argument;
19441 +       DAC960_V1_UserCommand_T UserCommand;
19442 +       DAC960_Controller_T *Controller;
19443 +       DAC960_Command_T *Command = NULL;
19444 +       DAC960_V1_CommandOpcode_T CommandOpcode;
19445 +       DAC960_V1_CommandStatus_T CommandStatus;
19446 +       DAC960_V1_DCDB_T DCDB;
19447 +       DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
19448 +       dma_addr_t      DCDB_IOBUFDMA;
19449 +       unsigned long flags;
19450 +       int ControllerNumber, DataTransferLength;
19451 +       unsigned char *DataTransferBuffer = NULL;
19452 +       dma_addr_t DataTransferBufferDMA;
19453 +       if (UserSpaceUserCommand == NULL) return -EINVAL;
19454 +       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
19455 +                                  sizeof(DAC960_V1_UserCommand_T))) {
19456 +               ErrorCode = -EFAULT;
19457 +               goto Failure1a;
19458 +       }
19459 +       ControllerNumber = UserCommand.ControllerNumber;
19460 +       if (ControllerNumber < 0 ||
19461 +           ControllerNumber > DAC960_ControllerCount - 1)
19462 +         return -ENXIO;
19463 +       Controller = DAC960_Controllers[ControllerNumber];
19464 +       if (Controller == NULL) return -ENXIO;
19465 +       if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
19466 +       CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
19467 +       DataTransferLength = UserCommand.DataTransferLength;
19468 +       if (CommandOpcode & 0x80) return -EINVAL;
19469 +       if (CommandOpcode == DAC960_V1_DCDB)
19470 +         {
19471 +           if (copy_from_user(&DCDB, UserCommand.DCDB,
19472 +                              sizeof(DAC960_V1_DCDB_T))) {
19473 +               ErrorCode = -EFAULT;
19474 +               goto Failure1a;
19475 +           }
19476 +           if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
19477 +           if (!((DataTransferLength == 0 &&
19478 +                  DCDB.Direction
19479 +                  == DAC960_V1_DCDB_NoDataTransfer) ||
19480 +                 (DataTransferLength > 0 &&
19481 +                  DCDB.Direction
19482 +                  == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
19483 +                 (DataTransferLength < 0 &&
19484 +                  DCDB.Direction
19485 +                  == DAC960_V1_DCDB_DataTransferSystemToDevice)))
19486 +             return -EINVAL;
19487 +           if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
19488 +               != abs(DataTransferLength))
19489 +             return -EINVAL;
19490 +           DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
19491 +                       sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
19492 +           if (DCDB_IOBUF == NULL)
19493 +                       return -ENOMEM;
19494 +         }
19495 +       if (DataTransferLength > 0)
19496 +         {
19497 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
19498 +                               DataTransferLength, &DataTransferBufferDMA);
19499 +           if (DataTransferBuffer == NULL) {
19500 +               ErrorCode = -ENOMEM;
19501 +               goto Failure1;
19502 +           }
19503 +           memset(DataTransferBuffer, 0, DataTransferLength);
19504 +         }
19505 +       else if (DataTransferLength < 0)
19506 +         {
19507 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
19508 +                               -DataTransferLength, &DataTransferBufferDMA);
19509 +           if (DataTransferBuffer == NULL) {
19510 +               ErrorCode = -ENOMEM;
19511 +               goto Failure1;
19512 +           }
19513 +           if (copy_from_user(DataTransferBuffer,
19514 +                              UserCommand.DataTransferBuffer,
19515 +                              -DataTransferLength)) {
19516 +               ErrorCode = -EFAULT;
19517 +               goto Failure1;
19518 +           }
19519 +         }
19520 +       if (CommandOpcode == DAC960_V1_DCDB)
19521 +         {
19522 +           spin_lock_irqsave(&Controller->queue_lock, flags);
19523 +           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
19524 +             DAC960_WaitForCommand(Controller);
19525 +           while (Controller->V1.DirectCommandActive[DCDB.Channel]
19526 +                                                    [DCDB.TargetID])
19527 +             {
19528 +               spin_unlock_irq(&Controller->queue_lock);
19529 +               __wait_event(Controller->CommandWaitQueue,
19530 +                            !Controller->V1.DirectCommandActive
19531 +                                            [DCDB.Channel][DCDB.TargetID]);
19532 +               spin_lock_irq(&Controller->queue_lock);
19533 +             }
19534 +           Controller->V1.DirectCommandActive[DCDB.Channel]
19535 +                                             [DCDB.TargetID] = true;
19536 +           spin_unlock_irqrestore(&Controller->queue_lock, flags);
19537 +           DAC960_V1_ClearCommand(Command);
19538 +           Command->CommandType = DAC960_ImmediateCommand;
19539 +           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
19540 +                  sizeof(DAC960_V1_CommandMailbox_T));
19541 +           Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
19542 +           DCDB.BusAddress = DataTransferBufferDMA;
19543 +           memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
19544 +         }
19545 +       else
19546 +         {
19547 +           spin_lock_irqsave(&Controller->queue_lock, flags);
19548 +           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
19549 +             DAC960_WaitForCommand(Controller);
19550 +           spin_unlock_irqrestore(&Controller->queue_lock, flags);
19551 +           DAC960_V1_ClearCommand(Command);
19552 +           Command->CommandType = DAC960_ImmediateCommand;
19553 +           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
19554 +                  sizeof(DAC960_V1_CommandMailbox_T));
19555 +           if (DataTransferBuffer != NULL)
19556 +             Command->V1.CommandMailbox.Type3.BusAddress =
19557 +               DataTransferBufferDMA;
19558 +         }
19559 +       DAC960_ExecuteCommand(Command);
19560 +       CommandStatus = Command->V1.CommandStatus;
19561 +       spin_lock_irqsave(&Controller->queue_lock, flags);
19562 +       DAC960_DeallocateCommand(Command);
19563 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
19564 +       if (DataTransferLength > 0)
19565 +         {
19566 +           if (copy_to_user(UserCommand.DataTransferBuffer,
19567 +                            DataTransferBuffer, DataTransferLength)) {
19568 +               ErrorCode = -EFAULT;
19569 +               goto Failure1;
19570 +            }
19571 +         }
19572 +       if (CommandOpcode == DAC960_V1_DCDB)
19573 +         {
19574 +           /*
19575 +             I don't believe Target or Channel in the DCDB_IOBUF
19576 +             should be any different from the contents of DCDB.
19577 +            */
19578 +           Controller->V1.DirectCommandActive[DCDB.Channel]
19579 +                                             [DCDB.TargetID] = false;
19580 +           if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
19581 +                            sizeof(DAC960_V1_DCDB_T))) {
19582 +               ErrorCode = -EFAULT;
19583 +               goto Failure1;
19584 +           }
19585 +         }
19586 +       ErrorCode = CommandStatus;
19587 +      Failure1:
19588 +       if (DataTransferBuffer != NULL)
19589 +         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
19590 +                       DataTransferBuffer, DataTransferBufferDMA);
19591 +       if (DCDB_IOBUF != NULL)
19592 +         pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
19593 +                       DCDB_IOBUF, DCDB_IOBUFDMA);
19594 +      Failure1a:
19595 +       return ErrorCode;
19596 +      }
19597 +    case DAC960_IOCTL_V2_EXECUTE_COMMAND:
19598 +      {
19599 +       DAC960_V2_UserCommand_T *UserSpaceUserCommand =
19600 +         (DAC960_V2_UserCommand_T *) Argument;
19601 +       DAC960_V2_UserCommand_T UserCommand;
19602 +       DAC960_Controller_T *Controller;
19603 +       DAC960_Command_T *Command = NULL;
19604 +       DAC960_V2_CommandMailbox_T *CommandMailbox;
19605 +       DAC960_V2_CommandStatus_T CommandStatus;
19606 +       unsigned long flags;
19607 +       int ControllerNumber, DataTransferLength;
19608 +       int DataTransferResidue, RequestSenseLength;
19609 +       unsigned char *DataTransferBuffer = NULL;
19610 +       dma_addr_t DataTransferBufferDMA;
19611 +       unsigned char *RequestSenseBuffer = NULL;
19612 +       dma_addr_t RequestSenseBufferDMA;
19613 +       if (UserSpaceUserCommand == NULL) return -EINVAL;
19614 +       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
19615 +                          sizeof(DAC960_V2_UserCommand_T))) {
19616 +               ErrorCode = -EFAULT;
19617 +               goto Failure2a;
19618 +       }
19619 +       ControllerNumber = UserCommand.ControllerNumber;
19620 +       if (ControllerNumber < 0 ||
19621 +           ControllerNumber > DAC960_ControllerCount - 1)
19622 +         return -ENXIO;
19623 +       Controller = DAC960_Controllers[ControllerNumber];
19624 +       if (Controller == NULL) return -ENXIO;
19625 +       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
19626 +       DataTransferLength = UserCommand.DataTransferLength;
19627 +       if (DataTransferLength > 0)
19628 +         {
19629 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
19630 +                               DataTransferLength, &DataTransferBufferDMA);
19631 +           if (DataTransferBuffer == NULL) return -ENOMEM;
19632 +           memset(DataTransferBuffer, 0, DataTransferLength);
19633 +         }
19634 +       else if (DataTransferLength < 0)
19635 +         {
19636 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
19637 +                               -DataTransferLength, &DataTransferBufferDMA);
19638 +           if (DataTransferBuffer == NULL) return -ENOMEM;
19639 +           if (copy_from_user(DataTransferBuffer,
19640 +                              UserCommand.DataTransferBuffer,
19641 +                              -DataTransferLength)) {
19642 +               ErrorCode = -EFAULT;
19643 +               goto Failure2;
19644 +           }
19645 +         }
19646 +       RequestSenseLength = UserCommand.RequestSenseLength;
19647 +       if (RequestSenseLength > 0)
19648 +         {
19649 +           RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
19650 +                       RequestSenseLength, &RequestSenseBufferDMA);
19651 +           if (RequestSenseBuffer == NULL)
19652 +             {
19653 +               ErrorCode = -ENOMEM;
19654 +               goto Failure2;
19655 +             }
19656 +           memset(RequestSenseBuffer, 0, RequestSenseLength);
19657 +         }
19658 +       spin_lock_irqsave(&Controller->queue_lock, flags);
19659 +       while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
19660 +         DAC960_WaitForCommand(Controller);
19661 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
19662 +       DAC960_V2_ClearCommand(Command);
19663 +       Command->CommandType = DAC960_ImmediateCommand;
19664 +       CommandMailbox = &Command->V2.CommandMailbox;
19665 +       memcpy(CommandMailbox, &UserCommand.CommandMailbox,
19666 +              sizeof(DAC960_V2_CommandMailbox_T));
19667 +       CommandMailbox->Common.CommandControlBits
19668 +                             .AdditionalScatterGatherListMemory = false;
19669 +       CommandMailbox->Common.CommandControlBits
19670 +                             .NoAutoRequestSense = true;
19671 +       CommandMailbox->Common.DataTransferSize = 0;
19672 +       CommandMailbox->Common.DataTransferPageNumber = 0;
19673 +       memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
19674 +              sizeof(DAC960_V2_DataTransferMemoryAddress_T));
19675 +       if (DataTransferLength != 0)
19676 +         {
19677 +           if (DataTransferLength > 0)
19678 +             {
19679 +               CommandMailbox->Common.CommandControlBits
19680 +                                     .DataTransferControllerToHost = true;
19681 +               CommandMailbox->Common.DataTransferSize = DataTransferLength;
19682 +             }
19683 +           else
19684 +             {
19685 +               CommandMailbox->Common.CommandControlBits
19686 +                                     .DataTransferControllerToHost = false;
19687 +               CommandMailbox->Common.DataTransferSize = -DataTransferLength;
19688 +             }
19689 +           CommandMailbox->Common.DataTransferMemoryAddress
19690 +                                 .ScatterGatherSegments[0]
19691 +                                 .SegmentDataPointer = DataTransferBufferDMA;
19692 +           CommandMailbox->Common.DataTransferMemoryAddress
19693 +                                 .ScatterGatherSegments[0]
19694 +                                 .SegmentByteCount =
19695 +             CommandMailbox->Common.DataTransferSize;
19696 +         }
19697 +       if (RequestSenseLength > 0)
19698 +         {
19699 +           CommandMailbox->Common.CommandControlBits
19700 +                                 .NoAutoRequestSense = false;
19701 +           CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
19702 +           CommandMailbox->Common.RequestSenseBusAddress =
19703 +                                                       RequestSenseBufferDMA;
19704 +         }
19705 +       DAC960_ExecuteCommand(Command);
19706 +       CommandStatus = Command->V2.CommandStatus;
19707 +       RequestSenseLength = Command->V2.RequestSenseLength;
19708 +       DataTransferResidue = Command->V2.DataTransferResidue;
19709 +       spin_lock_irqsave(&Controller->queue_lock, flags);
19710 +       DAC960_DeallocateCommand(Command);
19711 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
19712 +       if (RequestSenseLength > UserCommand.RequestSenseLength)
19713 +         RequestSenseLength = UserCommand.RequestSenseLength;
19714 +       if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
19715 +                                &DataTransferResidue,
19716 +                                sizeof(DataTransferResidue))) {
19717 +               ErrorCode = -EFAULT;
19718 +               goto Failure2;
19719 +       }
19720 +       if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
19721 +                        &RequestSenseLength, sizeof(RequestSenseLength))) {
19722 +               ErrorCode = -EFAULT;
19723 +               goto Failure2;
19724 +       }
19725 +       if (DataTransferLength > 0)
19726 +         {
19727 +           if (copy_to_user(UserCommand.DataTransferBuffer,
19728 +                            DataTransferBuffer, DataTransferLength)) {
19729 +               ErrorCode = -EFAULT;
19730 +               goto Failure2;
19731 +           }
19732 +         }
19733 +       if (RequestSenseLength > 0)
19734 +         {
19735 +           if (copy_to_user(UserCommand.RequestSenseBuffer,
19736 +                            RequestSenseBuffer, RequestSenseLength)) {
19737 +               ErrorCode = -EFAULT;
19738 +               goto Failure2;
19739 +           }
19740 +         }
19741 +       ErrorCode = CommandStatus;
19742 +      Failure2:
19743 +         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
19744 +               DataTransferBuffer, DataTransferBufferDMA);
19745 +       if (RequestSenseBuffer != NULL)
19746 +         pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
19747 +               RequestSenseBuffer, RequestSenseBufferDMA);
19748 +      Failure2a:
19749 +       return ErrorCode;
19750 +      }
19751 +    case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
19752 +      {
19753 +       DAC960_V2_GetHealthStatus_T *UserSpaceGetHealthStatus =
19754 +         (DAC960_V2_GetHealthStatus_T *) Argument;
19755 +       DAC960_V2_GetHealthStatus_T GetHealthStatus;
19756 +       DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
19757 +       DAC960_Controller_T *Controller;
19758 +       int ControllerNumber;
19759 +       if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
19760 +       if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
19761 +                          sizeof(DAC960_V2_GetHealthStatus_T)))
19762 +               return -EFAULT;
19763 +       ControllerNumber = GetHealthStatus.ControllerNumber;
19764 +       if (ControllerNumber < 0 ||
19765 +           ControllerNumber > DAC960_ControllerCount - 1)
19766 +         return -ENXIO;
19767 +       Controller = DAC960_Controllers[ControllerNumber];
19768 +       if (Controller == NULL) return -ENXIO;
19769 +       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
19770 +       if (copy_from_user(&HealthStatusBuffer,
19771 +                          GetHealthStatus.HealthStatusBuffer,
19772 +                          sizeof(DAC960_V2_HealthStatusBuffer_T)))
19773 +               return -EFAULT;
19774 +       while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
19775 +              == HealthStatusBuffer.StatusChangeCounter &&
19776 +              Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
19777 +              == HealthStatusBuffer.NextEventSequenceNumber)
19778 +         {
19779 +           interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
19780 +                                          DAC960_MonitoringTimerInterval);
19781 +           if (signal_pending(current)) return -EINTR;
19782 +         }
19783 +       if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
19784 +                        Controller->V2.HealthStatusBuffer,
19785 +                        sizeof(DAC960_V2_HealthStatusBuffer_T)))
19786 +               return -EFAULT;
19787 +       return 0;
19788 +      }
19789 +    }
19790 +  return -EINVAL;
19791 +}
19792 +
19793 +static struct file_operations DAC960_gam_fops = {
19794 +       .owner          = THIS_MODULE,
19795 +       .ioctl          = DAC960_gam_ioctl
19796 +};
19797 +
19798 +static struct miscdevice DAC960_gam_dev = {
19799 +       DAC960_GAM_MINOR,
19800 +       "dac960_gam",
19801 +       &DAC960_gam_fops
19802 +};
19803 +
19804 +static int DAC960_gam_init(void)
19805 +{
19806 +       int ret;
19807 +
19808 +       ret = misc_register(&DAC960_gam_dev);
19809 +       if (ret)
19810 +               printk(KERN_ERR "DAC960_gam: can't misc_register on minor %d\n", DAC960_GAM_MINOR);
19811 +       return ret;
19812 +}
19813 +
19814 +static void DAC960_gam_cleanup(void)
19815 +{
19816 +       misc_deregister(&DAC960_gam_dev);
19817 +}
19818 +
19819 +#endif /* DAC960_GAM_MINOR */
19820 +
19821  static struct DAC960_privdata DAC960_BA_privdata = {
19822         .HardwareType =         DAC960_BA_Controller,
19823         .FirmwareType   =       DAC960_V2_Controller,
19824 @@ -7000,12 +7025,23 @@
19825  
19826  static int DAC960_init_module(void)
19827  {
19828 -       return pci_module_init(&DAC960_pci_driver);
19829 +       int ret;
19830 +
19831 +       ret =  pci_module_init(&DAC960_pci_driver);
19832 +#ifdef DAC960_GAM_MINOR
19833 +       if (!ret)
19834 +               DAC960_gam_init();
19835 +#endif
19836 +       return ret;
19837  }
19838  
19839  static void DAC960_cleanup_module(void)
19840  {
19841         int i;
19842 +
19843 +#ifdef DAC960_GAM_MINOR
19844 +       DAC960_gam_cleanup();
19845 +#endif
19846  
19847         for (i = 0; i < DAC960_ControllerCount; i++) {
19848                 DAC960_Controller_T *Controller = DAC960_Controllers[i];
19849 diff -Nru a/drivers/block/DAC960.h b/drivers/block/DAC960.h
19850 --- a/drivers/block/DAC960.h    Thu Aug  7 06:13:28 2003
19851 +++ b/drivers/block/DAC960.h    Sun Aug 31 16:13:56 2003
19852 @@ -4138,8 +4138,6 @@
19853  static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *);
19854  static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *);
19855  static void DAC960_MonitoringTimerFunction(unsigned long);
19856 -static int DAC960_UserIOCTL(struct inode *, struct file *,
19857 -                           unsigned int, unsigned long);
19858  static void DAC960_Message(DAC960_MessageLevel_T, unsigned char *,
19859                            DAC960_Controller_T *, ...);
19860  static void DAC960_CreateProcEntries(DAC960_Controller_T *);
19861 diff -Nru a/drivers/block/acsi_slm.c b/drivers/block/acsi_slm.c
19862 --- a/drivers/block/acsi_slm.c  Sun Jun  8 04:05:16 2003
19863 +++ b/drivers/block/acsi_slm.c  Tue Aug 26 09:25:40 2003
19864 @@ -374,7 +374,7 @@
19865         if (!(page = __get_free_page( GFP_KERNEL )))
19866                 return( -ENOMEM );
19867         
19868 -       length = slm_getstats( (char *)page, MINOR(node->i_rdev) );
19869 +       length = slm_getstats( (char *)page, iminor(node) );
19870         if (length < 0) {
19871                 count = length;
19872                 goto out;
19873 @@ -622,7 +622,7 @@
19874  
19875  {
19876         struct inode *node = file->f_dentry->d_inode;
19877 -       int             device = MINOR( node->i_rdev );
19878 +       int             device = iminor(node);
19879         int             n, filled, w, h;
19880  
19881         while( SLMState == PRINTING ||
19882 @@ -694,7 +694,7 @@
19883  static int slm_ioctl( struct inode *inode, struct file *file,
19884                                           unsigned int cmd, unsigned long arg )
19885  
19886 -{      int             device = MINOR( inode->i_rdev ), err;
19887 +{      int             device = iminor(inode), err;
19888         
19889         /* I can think of setting:
19890          *  - manual feed
19891 @@ -768,7 +768,7 @@
19892  {      int device;
19893         struct slm *sip;
19894         
19895 -       device = MINOR(inode->i_rdev);
19896 +       device = iminor(inode);
19897         if (device >= N_SLM_Printers)
19898                 return( -ENXIO );
19899         sip = &slm_info[device];
19900 @@ -797,7 +797,7 @@
19901  {      int device;
19902         struct slm *sip;
19903         
19904 -       device = MINOR(inode->i_rdev);
19905 +       device = iminor(inode);
19906         sip = &slm_info[device];
19907  
19908         if (file->f_mode & 2)
19909 diff -Nru a/drivers/block/amiflop.c b/drivers/block/amiflop.c
19910 --- a/drivers/block/amiflop.c   Thu Aug  7 02:25:23 2003
19911 +++ b/drivers/block/amiflop.c   Wed Sep  3 03:32:10 2003
19912 @@ -55,24 +55,15 @@
19913  
19914  #include <linux/module.h>
19915  
19916 -#include <linux/sched.h>
19917 -#include <linux/fs.h>
19918 -#include <linux/fcntl.h>
19919 -#include <linux/kernel.h>
19920 -#include <linux/timer.h>
19921  #include <linux/fd.h>
19922  #include <linux/hdreg.h>
19923 -#include <linux/errno.h>
19924 -#include <linux/types.h>
19925  #include <linux/delay.h>
19926 -#include <linux/string.h>
19927 -#include <linux/slab.h>
19928  #include <linux/init.h>
19929  #include <linux/amifdreg.h>
19930  #include <linux/amifd.h>
19931 -#include <linux/ioport.h>
19932  #include <linux/buffer_head.h>
19933 -#include <linux/interrupt.h>
19934 +#include <linux/blkdev.h>
19935 +#include <linux/elevator.h>
19936  
19937  #include <asm/setup.h>
19938  #include <asm/uaccess.h>
19939 @@ -1446,7 +1437,7 @@
19940  static int fd_ioctl(struct inode *inode, struct file *filp,
19941                     unsigned int cmd, unsigned long param)
19942  {
19943 -       int drive = minor(inode->i_rdev) & 3;
19944 +       int drive = iminor(inode) & 3;
19945         static struct floppy_struct getprm;
19946  
19947         switch(cmd){
19948 @@ -1570,8 +1561,8 @@
19949   */
19950  static int floppy_open(struct inode *inode, struct file *filp)
19951  {
19952 -       int drive = minor(inode->i_rdev) & 3;
19953 -       int system =  (minor(inode->i_rdev) & 4) >> 2;
19954 +       int drive = iminor(inode) & 3;
19955 +       int system =  (iminor(inode) & 4) >> 2;
19956         int old_dev;
19957         unsigned long flags;
19958  
19959 @@ -1618,7 +1609,7 @@
19960  
19961  static int floppy_release(struct inode * inode, struct file * filp)
19962  {
19963 -       int drive = minor(inode->i_rdev) & 3;
19964 +       int drive = iminor(inode) & 3;
19965  
19966         if (unit[drive].dirty == 1) {
19967                 del_timer (flush_track_timer + drive);
19968 @@ -1740,7 +1731,7 @@
19969  
19970  int __init amiga_floppy_init(void)
19971  {
19972 -       int i;
19973 +       int i, ret;
19974  
19975         if (!AMIGAHW_PRESENT(AMI_FLOPPY))
19976                 return -ENXIO;
19977 @@ -1752,41 +1743,39 @@
19978          *  We request DSKPTR, DSKLEN and DSKDATA only, because the other
19979          *  floppy registers are too spreaded over the custom register space
19980          */
19981 +       ret = -EBUSY;
19982         if (!request_mem_region(CUSTOM_PHYSADDR+0x20, 8, "amiflop [Paula]")) {
19983                 printk("fd: cannot get floppy registers\n");
19984 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
19985 -               return -EBUSY;
19986 +               goto out_blkdev;
19987         }
19988 +
19989 +       ret = -ENOMEM;
19990         if ((raw_buf = (char *)amiga_chip_alloc (RAW_BUF_SIZE, "Floppy")) ==
19991             NULL) {
19992                 printk("fd: cannot get chip mem buffer\n");
19993 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
19994 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
19995 -               return -ENOMEM;
19996 +               goto out_memregion;
19997         }
19998 +
19999 +       ret = -EBUSY;
20000         if (request_irq(IRQ_AMIGA_DSKBLK, fd_block_done, 0, "floppy_dma", NULL)) {
20001                 printk("fd: cannot get irq for dma\n");
20002 -               amiga_chip_free(raw_buf);
20003 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
20004 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
20005 -               return -EBUSY;
20006 +               goto out_irq;
20007         }
20008 +
20009         if (request_irq(IRQ_AMIGA_CIAA_TB, ms_isr, 0, "floppy_timer", NULL)) {
20010                 printk("fd: cannot get irq for timer\n");
20011 -               free_irq(IRQ_AMIGA_DSKBLK, NULL);
20012 -               amiga_chip_free(raw_buf);
20013 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
20014 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
20015 -               return -EBUSY;
20016 -       }
20017 -       if (fd_probe_drives() < 1) { /* No usable drives */
20018 -               free_irq(IRQ_AMIGA_CIAA_TB, NULL);
20019 -               free_irq(IRQ_AMIGA_DSKBLK, NULL);
20020 -               amiga_chip_free(raw_buf);
20021 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
20022 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
20023 -               return -ENXIO;
20024 +               goto out_irq2;
20025         }
20026 +
20027 +       ret = -ENOMEM;
20028 +       floppy_queue = blk_init_queue(do_fd_request, &amiflop_lock);
20029 +       if (!floppy_queue)
20030 +               goto out_queue;
20031 +
20032 +       ret = -ENXIO;
20033 +       if (fd_probe_drives() < 1) /* No usable drives */
20034 +               goto out_probe;
20035 +
20036         blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
20037                                 floppy_find, NULL, NULL);
20038  
20039 @@ -1813,17 +1802,6 @@
20040         post_write_timer.data = 0;
20041         post_write_timer.function = post_write;
20042    
20043 -       floppy_queue = blk_init_queue(do_fd_request, &amiflop_lock);
20044 -       if (!floppy_queue) {
20045 -               free_irq(IRQ_AMIGA_CIAA_TB, NULL);
20046 -               free_irq(IRQ_AMIGA_DSKBLK, NULL);
20047 -               amiga_chip_free(raw_buf);
20048 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
20049 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
20050 -               blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
20051 -               return -ENOMEM;
20052 -       }
20053 -
20054         for (i = 0; i < 128; i++)
20055                 mfmdecode[i]=255;
20056         for (i = 0; i < 16; i++)
20057 @@ -1835,6 +1813,20 @@
20058         /* init ms timer */
20059         ciaa.crb = 8; /* one-shot, stop */
20060         return 0;
20061 +
20062 +out_probe:
20063 +       blk_cleanup_queue(floppy_queue);
20064 +out_queue:
20065 +       free_irq(IRQ_AMIGA_CIAA_TB, NULL);
20066 +out_irq2:
20067 +       free_irq(IRQ_AMIGA_DSKBLK, NULL);
20068 +out_irq:
20069 +       amiga_chip_free(raw_buf);
20070 +out_memregion:
20071 +       release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
20072 +out_blkdev:
20073 +       unregister_blkdev(FLOPPY_MAJOR,"fd");
20074 +       return ret;
20075  }
20076  
20077  #ifdef MODULE
20078 diff -Nru a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c
20079 --- a/drivers/block/as-iosched.c        Fri Aug 15 00:57:28 2003
20080 +++ b/drivers/block/as-iosched.c        Wed Sep  3 23:40:09 2003
20081 @@ -709,6 +709,14 @@
20082                 return 1;
20083         }
20084  
20085 +       if (aic->seek_samples == 0 || aic->ttime_samples == 0) {
20086 +               /*
20087 +                * Process has just started IO so default to not anticipate.
20088 +                * Maybe should be smarter.
20089 +                */
20090 +               return 1;
20091 +       }
20092 +
20093         if (aic->ttime_mean > ad->antic_expire) {
20094                 /* the process thinks too much between requests */
20095                 return 1;
20096 @@ -902,12 +910,7 @@
20097         struct as_rq *arq = RQ_DATA(rq);
20098         struct as_io_context *aic;
20099  
20100 -       if (unlikely(!blk_fs_request(rq)))
20101 -               return;
20102 -
20103 -       WARN_ON(blk_fs_request(rq) && arq->state == AS_RQ_NEW);
20104 -
20105 -       if (arq->state != AS_RQ_DISPATCHED)
20106 +       if (unlikely(arq->state != AS_RQ_DISPATCHED))
20107                 return;
20108  
20109         if (ad->changed_batch && ad->nr_dispatched == 1) {
20110 @@ -1027,7 +1030,7 @@
20111  {
20112         struct as_rq *arq = RQ_DATA(rq);
20113  
20114 -       if (unlikely(!blk_fs_request(rq)))
20115 +       if (unlikely(arq->state == AS_RQ_NEW))
20116                 return;
20117  
20118         if (!arq) {
20119 @@ -1333,9 +1336,9 @@
20120                         atomic_inc(&arq->io_context->aic->nr_dispatched);
20121         } else
20122                 WARN_ON(blk_fs_request(rq)
20123 -                               && (!(rq->flags & REQ_HARDBARRIER)) );
20124 +                       && (!(rq->flags & (REQ_HARDBARRIER|REQ_SOFTBARRIER))) );
20125  
20126 -       list_add_tail(&rq->queuelist, ad->dispatch);
20127 +       list_add(&rq->queuelist, ad->dispatch);
20128  
20129         /* Stop anticipating - let this request get through */
20130         as_antic_stop(ad);
20131 @@ -1350,26 +1353,31 @@
20132         struct as_data *ad = q->elevator.elevator_data;
20133         struct as_rq *arq = RQ_DATA(rq);
20134  
20135 -       if (unlikely(rq->flags & REQ_HARDBARRIER)) {
20136 +       if (unlikely(rq->flags & (REQ_HARDBARRIER|REQ_SOFTBARRIER))) {
20137                 q->last_merge = NULL;
20138  
20139 -               while (ad->next_arq[REQ_SYNC])
20140 -                       as_move_to_dispatch(ad, ad->next_arq[REQ_SYNC]);
20141 +               if (insert_here != ad->dispatch) {
20142 +                       while (ad->next_arq[REQ_SYNC])
20143 +                               as_move_to_dispatch(ad, ad->next_arq[REQ_SYNC]);
20144 +
20145 +                       while (ad->next_arq[REQ_ASYNC])
20146 +                               as_move_to_dispatch(ad, ad->next_arq[REQ_ASYNC]);
20147 +               }
20148  
20149 -               while (ad->next_arq[REQ_ASYNC])
20150 -                       as_move_to_dispatch(ad, ad->next_arq[REQ_ASYNC]);
20151 +               if (!insert_here)
20152 +                       insert_here = ad->dispatch->prev;
20153         }
20154  
20155         if (unlikely(!blk_fs_request(rq))) {
20156                 if (!insert_here)
20157 -                       insert_here = ad->dispatch->prev;
20158 +                       insert_here = ad->dispatch;
20159 +       }
20160  
20161 +       if (insert_here) {
20162                 list_add(&rq->queuelist, insert_here);
20163  
20164                 /* Stop anticipating - let this request get through */
20165 -               if (!list_empty(ad->dispatch)
20166 -                       && (ad->antic_status == ANTIC_WAIT_REQ
20167 -                               || ad->antic_status == ANTIC_WAIT_NEXT))
20168 +               if (list_empty(ad->dispatch))
20169                         as_antic_stop(ad);
20170  
20171                 return;
20172 diff -Nru a/drivers/block/ataflop.c b/drivers/block/ataflop.c
20173 --- a/drivers/block/ataflop.c   Thu Aug  7 02:25:23 2003
20174 +++ b/drivers/block/ataflop.c   Wed Jul 30 15:49:57 2003
20175 @@ -63,35 +63,16 @@
20176  
20177  #include <linux/module.h>
20178  
20179 -#include <linux/sched.h>
20180 -#include <linux/string.h>
20181 -#include <linux/fs.h>
20182 -#include <linux/fcntl.h>
20183 -#include <linux/kernel.h>
20184 -#include <linux/timer.h>
20185  #include <linux/fd.h>
20186 -#include <linux/errno.h>
20187 -#include <linux/types.h>
20188  #include <linux/delay.h>
20189 -#include <linux/mm.h>
20190 -#include <linux/slab.h>
20191  #include <linux/init.h>
20192 -#include <linux/buffer_head.h>         /* for invalidate_buffers() */
20193 -
20194 -#include <asm/setup.h>
20195 -#include <asm/system.h>
20196 -#include <asm/bitops.h>
20197 -#include <asm/irq.h>
20198 -#include <asm/pgtable.h>
20199 -#include <asm/uaccess.h>
20200 +#include <linux/blkdev.h>
20201  
20202  #include <asm/atafd.h>
20203  #include <asm/atafdreg.h>
20204 -#include <asm/atarihw.h>
20205  #include <asm/atariints.h>
20206  #include <asm/atari_stdma.h>
20207  #include <asm/atari_stram.h>
20208 -#include <linux/blkpg.h>
20209  
20210  #define        FD_MAX_UNITS 2
20211  
20212 @@ -1838,7 +1819,7 @@
20213  static int floppy_open( struct inode *inode, struct file *filp )
20214  {
20215         struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data;
20216 -       int type  = minor(inode->i_rdev) >> 2;
20217 +       int type  = iminor(inode) >> 2;
20218  
20219         DPRINT(("fd_open: type=%d\n",type));
20220         if (p->ref && p->type != type)
20221 diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c
20222 --- a/drivers/block/cciss.c     Thu Aug  7 06:13:28 2003
20223 +++ b/drivers/block/cciss.c     Wed Sep  3 23:45:21 2003
20224 @@ -356,11 +356,11 @@
20225   */
20226  static int cciss_open(struct inode *inode, struct file *filep)
20227  {
20228 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
20229 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
20230 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
20231 +       int dsk  = iminor(inode) >> NWD_SHIFT;
20232  
20233  #ifdef CCISS_DEBUG
20234 -       printk(KERN_DEBUG "cciss_open %x (%x:%x)\n", inode->i_rdev, ctlr, dsk);
20235 +       printk(KERN_DEBUG "cciss_open %s (%x:%x)\n", inode->i_bdev->bd_disk->disk_name, ctlr, dsk);
20236  #endif /* CCISS_DEBUG */ 
20237  
20238         if (ctlr >= MAX_CTLR || hba[ctlr] == NULL)
20239 @@ -372,7 +372,7 @@
20240          * for "raw controller".
20241          */
20242         if (hba[ctlr]->drv[dsk].nr_blocks == 0) {
20243 -               if (minor(inode->i_rdev) != 0)
20244 +               if (iminor(inode) != 0)
20245                         return -ENXIO;
20246                 if (!capable(CAP_SYS_ADMIN))
20247                         return -EPERM;
20248 @@ -386,11 +386,11 @@
20249   */
20250  static int cciss_release(struct inode *inode, struct file *filep)
20251  {
20252 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
20253 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
20254 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
20255 +       int dsk  = iminor(inode) >> NWD_SHIFT;
20256  
20257  #ifdef CCISS_DEBUG
20258 -       printk(KERN_DEBUG "cciss_release %x (%x:%x)\n", inode->i_rdev, ctlr, dsk);
20259 +       printk(KERN_DEBUG "cciss_release %s (%x:%x)\n", inode->i_bdev->bd_disk->disk_name, ctlr, dsk);
20260  #endif /* CCISS_DEBUG */
20261  
20262         /* fsync_dev(inode->i_rdev); */
20263 @@ -406,8 +406,8 @@
20264  static int cciss_ioctl(struct inode *inode, struct file *filep, 
20265                 unsigned int cmd, unsigned long arg)
20266  {
20267 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
20268 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
20269 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
20270 +       int dsk  = iminor(inode) >> NWD_SHIFT;
20271  
20272  #ifdef CCISS_DEBUG
20273         printk(KERN_DEBUG "cciss_ioctl: Called with cmd=%x %lx\n", cmd, arg);
20274 @@ -2447,11 +2447,8 @@
20275         if( i < 0 ) 
20276                 return (-1);
20277         if (cciss_pci_init(hba[i], pdev) != 0)
20278 -       {
20279 -               release_io_mem(hba[i]);
20280 -               free_hba(i);
20281 -               return (-1);
20282 -       }
20283 +               goto clean1;
20284 +
20285         sprintf(hba[i]->devname, "cciss%d", i);
20286         hba[i]->ctlr = i;
20287         hba[i]->pdev = pdev;
20288 @@ -2463,28 +2460,23 @@
20289                 printk("cciss: not using DAC cycles\n");
20290         else {
20291                 printk("cciss: no suitable DMA available\n");
20292 -               free_hba(i);
20293 -               return -ENODEV;
20294 +               goto clean1;
20295         }
20296  
20297         if (register_blkdev(COMPAQ_CISS_MAJOR+i, hba[i]->devname)) {
20298 -               release_io_mem(hba[i]);
20299 -               free_hba(i);
20300 -               return -1;
20301 +               printk(KERN_ERR "cciss: Unable to register device %s\n",
20302 +                               hba[i]->devname);
20303 +               goto clean1;
20304         }
20305  
20306         /* make sure the board interrupts are off */
20307         hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_OFF);
20308         if( request_irq(hba[i]->intr, do_cciss_intr, 
20309                 SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, 
20310 -                       hba[i]->devname, hba[i]))
20311 -       {
20312 -               printk(KERN_ERR "ciss: Unable to get irq %d for %s\n",
20313 +                       hba[i]->devname, hba[i])) {
20314 +               printk(KERN_ERR "cciss: Unable to get irq %d for %s\n",
20315                         hba[i]->intr, hba[i]->devname);
20316 -               unregister_blkdev( COMPAQ_CISS_MAJOR+i, hba[i]->devname);
20317 -               release_io_mem(hba[i]);
20318 -               free_hba(i);
20319 -               return(-1);
20320 +               goto clean2;
20321         }
20322         hba[i]->cmd_pool_bits = kmalloc(((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long), GFP_KERNEL);
20323         hba[i]->cmd_pool = (CommandList_struct *)pci_alloc_consistent(
20324 @@ -2495,35 +2487,18 @@
20325                 &(hba[i]->errinfo_pool_dhandle));
20326         if((hba[i]->cmd_pool_bits == NULL) 
20327                 || (hba[i]->cmd_pool == NULL)
20328 -               || (hba[i]->errinfo_pool == NULL))
20329 -        {
20330 -err_all:
20331 -               if(hba[i]->cmd_pool_bits)
20332 -                       kfree(hba[i]->cmd_pool_bits);
20333 -                if(hba[i]->cmd_pool)
20334 -                       pci_free_consistent(hba[i]->pdev,  
20335 -                               NR_CMDS * sizeof(CommandList_struct), 
20336 -                               hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);    
20337 -               if(hba[i]->errinfo_pool)
20338 -                       pci_free_consistent(hba[i]->pdev,
20339 -                               NR_CMDS * sizeof( ErrorInfo_struct),
20340 -                               hba[i]->errinfo_pool, 
20341 -                               hba[i]->errinfo_pool_dhandle);
20342 -                free_irq(hba[i]->intr, hba[i]);
20343 -                unregister_blkdev(COMPAQ_CISS_MAJOR+i, hba[i]->devname);
20344 -               release_io_mem(hba[i]);
20345 -               free_hba(i);
20346 +               || (hba[i]->errinfo_pool == NULL)) {
20347                  printk( KERN_ERR "cciss: out of memory");
20348 -               return(-1);
20349 +               goto clean4;
20350         }
20351  
20352 -       /*
20353 -        * someone needs to clean up this failure handling mess
20354 -        */
20355         spin_lock_init(&hba[i]->lock);
20356         q = blk_init_queue(do_cciss_request, &hba[i]->lock);
20357         if (!q)
20358 -               goto err_all;
20359 +               goto clean4;
20360 +
20361 +       hba[i]->queue = q;
20362 +       q->queuedata = hba[i];
20363  
20364         /* Initialize the pdev driver private data. 
20365                 have it point to hba[i].  */
20366 @@ -2545,7 +2520,6 @@
20367  
20368         cciss_procinit(i);
20369  
20370 -        q->queuedata = hba[i];
20371         blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
20372  
20373         /* This is a hardware imposed limit. */
20374 @@ -2574,6 +2548,26 @@
20375                 add_disk(disk);
20376         }
20377         return(1);
20378 +
20379 +clean4:
20380 +       if(hba[i]->cmd_pool_bits)
20381 +                       kfree(hba[i]->cmd_pool_bits);
20382 +       if(hba[i]->cmd_pool)
20383 +               pci_free_consistent(hba[i]->pdev,
20384 +                       NR_CMDS * sizeof(CommandList_struct),
20385 +                       hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
20386 +       if(hba[i]->errinfo_pool)
20387 +               pci_free_consistent(hba[i]->pdev,
20388 +                       NR_CMDS * sizeof( ErrorInfo_struct),
20389 +                       hba[i]->errinfo_pool,
20390 +                       hba[i]->errinfo_pool_dhandle);
20391 +       free_irq(hba[i]->intr, hba[i]);
20392 +clean2:
20393 +       unregister_blkdev(COMPAQ_CISS_MAJOR+i, hba[i]->devname);
20394 +clean1:
20395 +       release_io_mem(hba[i]);
20396 +       free_hba(i);
20397 +       return(-1);
20398  }
20399  
20400  static void __devexit cciss_remove_one (struct pci_dev *pdev)
20401 diff -Nru a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
20402 --- a/drivers/block/cpqarray.c  Thu Aug  7 02:25:24 2003
20403 +++ b/drivers/block/cpqarray.c  Tue Aug 26 09:25:41 2003
20404 @@ -1078,7 +1078,7 @@
20405                 put_user(host->ctlr_sig, (int*)arg);
20406                 return 0;
20407         case IDAREVALIDATEVOLS:
20408 -               if (minor(inode->i_rdev) != 0)
20409 +               if (iminor(inode) != 0)
20410                         return -ENXIO;
20411                 return revalidate_allvol(host);
20412         case IDADRIVERVERSION:
20413 diff -Nru a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c
20414 --- a/drivers/block/deadline-iosched.c  Fri Jul 25 11:20:53 2003
20415 +++ b/drivers/block/deadline-iosched.c  Wed Sep  3 23:40:09 2003
20416 @@ -627,21 +627,25 @@
20417         struct deadline_data *dd = q->elevator.elevator_data;
20418         struct deadline_rq *drq = RQ_DATA(rq);
20419  
20420 -       if (unlikely(rq->flags & REQ_HARDBARRIER)) {
20421 +       if (unlikely(rq->flags & (REQ_HARDBARRIER|REQ_SOFTBARRIER))) {
20422                 DL_INVALIDATE_HASH(dd);
20423                 q->last_merge = NULL;
20424  
20425 -               while (deadline_dispatch_requests(dd))
20426 -                       ;
20427 +               if (insert_here != dd->dispatch) {
20428 +                       while (deadline_dispatch_requests(dd))
20429 +                               ;
20430 +               }
20431  
20432 -               list_add_tail(&rq->queuelist, dd->dispatch);
20433 -               return;
20434 +               if (!insert_here)
20435 +                       insert_here = dd->dispatch->prev;
20436         }
20437  
20438         if (unlikely(!blk_fs_request(rq))) {
20439                 if (!insert_here)
20440 -                       insert_here = dd->dispatch->prev;
20441 +                       insert_here = dd->dispatch;
20442 +       }
20443  
20444 +       if (insert_here) {
20445                 list_add(&rq->queuelist, insert_here);
20446                 return;
20447         }
20448 diff -Nru a/drivers/block/elevator.c b/drivers/block/elevator.c
20449 --- a/drivers/block/elevator.c  Thu Aug 14 18:16:57 2003
20450 +++ b/drivers/block/elevator.c  Wed Sep  3 23:40:09 2003
20451 @@ -162,10 +162,10 @@
20452  void __elv_add_request(request_queue_t *q, struct request *rq, int at_end,
20453                        int plug)
20454  {
20455 -       struct list_head *insert = &q->queue_head;
20456 +       struct list_head *insert = NULL;
20457  
20458 -       if (at_end)
20459 -               insert = insert->prev;
20460 +       if (!at_end)
20461 +               insert = &q->queue_head;
20462         if (plug)
20463                 blk_plug_device(q);
20464  
20465 diff -Nru a/drivers/block/floppy.c b/drivers/block/floppy.c
20466 --- a/drivers/block/floppy.c    Fri Aug 15 10:27:03 2003
20467 +++ b/drivers/block/floppy.c    Wed Sep  3 23:40:13 2003
20468 @@ -695,23 +695,9 @@
20469         spin_unlock_irqrestore(&floppy_lock, flags);
20470  }
20471  
20472 -static int maximum(int a, int b)
20473 -{
20474 -       if (a > b)
20475 -               return a;
20476 -       else
20477 -               return b;
20478 -}
20479 -#define INFBOUND(a,b) (a)=maximum((a),(b));
20480 +#define INFBOUND(a,b) (a)=max_t(int, a, b)
20481  
20482 -static int minimum(int a, int b)
20483 -{
20484 -       if (a < b)
20485 -               return a;
20486 -       else
20487 -               return b;
20488 -}
20489 -#define SUPBOUND(a,b) (a)=minimum((a),(b));
20490 +#define SUPBOUND(a,b) (a)=min_t(int, a, b)
20491  
20492  
20493  /*
20494 @@ -1021,9 +1007,9 @@
20495  
20496  static DECLARE_WORK(floppy_work, NULL, NULL);
20497  
20498 -static void schedule_bh( void (*handler)(void*) )
20499 +static void schedule_bh(void (*handler) (void))
20500  {
20501 -       PREPARE_WORK(&floppy_work, handler, NULL);
20502 +       PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL);
20503         schedule_work(&floppy_work);
20504  }
20505  
20506 @@ -1035,7 +1021,7 @@
20507  
20508         spin_lock_irqsave(&floppy_lock, flags);
20509         do_floppy = NULL;
20510 -       PREPARE_WORK(&floppy_work, (void*)(void*)empty, NULL);
20511 +       PREPARE_WORK(&floppy_work, (void*)empty, NULL);
20512         del_timer(&fd_timer);
20513         spin_unlock_irqrestore(&floppy_lock, flags);
20514  }
20515 @@ -1813,9 +1799,9 @@
20516                         max_sensei--;
20517                 } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2 && max_sensei);
20518         }
20519 -       if (handler) {
20520 -               schedule_bh( (void *)(void *) handler);
20521 -       } else
20522 +       if (handler)
20523 +               schedule_bh(handler);
20524 +       else
20525                 FDCS->reset = 1;
20526         is_alive("normal interrupt end");
20527  
20528 @@ -2058,26 +2044,26 @@
20529         wake_up(&command_done);
20530  }
20531  
20532 -static struct cont_t wakeup_cont={
20533 -       empty,
20534 -       do_wakeup,
20535 -       empty,
20536 -       (done_f)empty
20537 +static struct cont_t wakeup_cont = {
20538 +       .interrupt = empty,
20539 +       .redo = do_wakeup,
20540 +       .error = empty,
20541 +       .done = (done_f) empty
20542  };
20543  
20544  
20545 -static struct cont_t intr_cont={
20546 -       empty,
20547 -       process_fd_request,
20548 -       empty,
20549 -       (done_f) empty
20550 +static struct cont_t intr_cont = {
20551 +       .interrupt = empty,
20552 +       .redo = process_fd_request,
20553 +       .error = empty,
20554 +       .done = (done_f) empty
20555  };
20556  
20557  static int wait_til_done(void (*handler)(void), int interruptible)
20558  {
20559         int ret;
20560  
20561 -       schedule_bh((void *)(void *)handler);
20562 +       schedule_bh(handler);
20563  
20564         if (command_status < 2 && NO_SIGNAL) {
20565                 DECLARE_WAITQUEUE(wait, current);
20566 @@ -2281,11 +2267,12 @@
20567  #endif
20568  }
20569  
20570 -static struct cont_t format_cont={
20571 -       format_interrupt,
20572 -       redo_format,
20573 -       bad_flp_intr,
20574 -       generic_done };
20575 +static struct cont_t format_cont = {
20576 +       .interrupt = format_interrupt,
20577 +       .redo = redo_format,
20578 +       .error = bad_flp_intr,
20579 +       .done = generic_done
20580 +};
20581  
20582  static int do_format(int drive, struct format_descr *tmp_format_req)
20583  {
20584 @@ -2523,12 +2510,12 @@
20585         int size, i;
20586  
20587         max_sector = transfer_size(ssize,
20588 -                                  minimum(max_sector, max_sector_2),
20589 +                                  min(max_sector, max_sector_2),
20590                                    current_req->nr_sectors);
20591  
20592         if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
20593             buffer_max > fsector_t + current_req->nr_sectors)
20594 -               current_count_sectors = minimum(buffer_max - fsector_t,
20595 +               current_count_sectors = min_t(int, buffer_max - fsector_t,
20596                                                 current_req->nr_sectors);
20597  
20598         remaining = current_count_sectors << 9;
20599 @@ -2546,7 +2533,7 @@
20600         }
20601  #endif
20602  
20603 -       buffer_max = maximum(max_sector, buffer_max);
20604 +       buffer_max = max(max_sector, buffer_max);
20605  
20606         dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
20607  
20608 @@ -2697,7 +2684,7 @@
20609         if ((_floppy->rate & FD_2M) && (!TRACK) && (!HEAD)){
20610                 max_sector = 2 * _floppy->sect / 3;
20611                 if (fsector_t >= max_sector){
20612 -                       current_count_sectors = minimum(_floppy->sect - fsector_t,
20613 +                       current_count_sectors = min_t(int, _floppy->sect - fsector_t,
20614                                                         current_req->nr_sectors);
20615                         return 1;
20616                 }
20617 @@ -2987,7 +2974,7 @@
20618  
20619                 if (TESTF(FD_NEED_TWADDLE))
20620                         twaddle();
20621 -               schedule_bh( (void *)(void *) floppy_start);
20622 +               schedule_bh(floppy_start);
20623  #ifdef DEBUGT
20624                 debugt("queue fd request");
20625  #endif
20626 @@ -2996,16 +2983,17 @@
20627  #undef REPEAT
20628  }
20629  
20630 -static struct cont_t rw_cont={
20631 -       rw_interrupt,
20632 -       redo_fd_request,
20633 -       bad_flp_intr,
20634 -       request_done };
20635 +static struct cont_t rw_cont = {
20636 +       .interrupt = rw_interrupt,
20637 +       .redo = redo_fd_request,
20638 +       .error = bad_flp_intr,
20639 +       .done = request_done
20640 +};
20641  
20642  static void process_fd_request(void)
20643  {
20644         cont = &rw_cont;
20645 -       schedule_bh( (void *)(void *) redo_fd_request);
20646 +       schedule_bh(redo_fd_request);
20647  }
20648  
20649  static void do_fd_request(request_queue_t * q)
20650 @@ -3031,11 +3019,12 @@
20651         is_alive("do fd request");
20652  }
20653  
20654 -static struct cont_t poll_cont={
20655 -       success_and_wakeup,
20656 -       floppy_ready,
20657 -       generic_failure,
20658 -       generic_done };
20659 +static struct cont_t poll_cont = {
20660 +       .interrupt = success_and_wakeup,
20661 +       .redo = floppy_ready,
20662 +       .error = generic_failure,
20663 +       .done = generic_done
20664 +};
20665  
20666  static int poll_drive(int interruptible, int flag)
20667  {
20668 @@ -3066,11 +3055,12 @@
20669         printk("weird, reset interrupt called\n");
20670  }
20671  
20672 -static struct cont_t reset_cont={
20673 -       reset_intr,
20674 -       success_and_wakeup,
20675 -       generic_failure,
20676 -       generic_done };
20677 +static struct cont_t reset_cont = {
20678 +       .interrupt = reset_intr,
20679 +       .redo = success_and_wakeup,
20680 +       .error = generic_failure,
20681 +       .done = generic_done
20682 +};
20683  
20684  static int user_reset_fdc(int drive, int arg, int interruptible)
20685  {
20686 @@ -3174,11 +3164,11 @@
20687  }
20688  
20689  
20690 -static struct cont_t raw_cmd_cont={
20691 -       success_and_wakeup,
20692 -       floppy_start,
20693 -       generic_failure,
20694 -       raw_cmd_done
20695 +static struct cont_t raw_cmd_cont = {
20696 +       .interrupt = success_and_wakeup,
20697 +       .redo = floppy_start,
20698 +       .error = generic_failure,
20699 +       .done = raw_cmd_done
20700  };
20701  
20702  static inline int raw_cmd_copyout(int cmd, char *param,
20703 @@ -3781,9 +3771,9 @@
20704                 }
20705         }
20706  
20707 -       UDRS->fd_device = minor(inode->i_rdev);
20708 -       set_capacity(disks[drive], floppy_sizes[minor(inode->i_rdev)]);
20709 -       if (old_dev != -1 && old_dev != minor(inode->i_rdev)) {
20710 +       UDRS->fd_device = iminor(inode);
20711 +       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
20712 +       if (old_dev != -1 && old_dev != iminor(inode)) {
20713                 if (buffer_drive == drive)
20714                         buffer_track = -1;
20715         }
20716 @@ -3910,22 +3900,6 @@
20717         return 0;
20718  }
20719  
20720 -static int floppy_read_block_0(struct gendisk *disk)
20721 -{
20722 -       struct block_device *bdev;
20723 -       int ret;
20724 -
20725 -       bdev = bdget_disk(disk, 0);
20726 -       if (!bdev) {
20727 -               printk("No block device for %s\n", disk->disk_name);
20728 -               BUG();
20729 -       }
20730 -       bdev->bd_disk = disk;   /* ewww */
20731 -       ret = __floppy_read_block_0(bdev);
20732 -       atomic_dec(&bdev->bd_count);
20733 -       return ret;
20734 -}
20735 -
20736  /* revalidate the floppy disk, i.e. trigger format autodetection by reading
20737   * the bootblock (block 0). "Autodetection" is also needed to check whether
20738   * there is a disk in the drive at all... Thus we also do it for fixed
20739 @@ -3961,7 +3935,7 @@
20740                         UDRS->generation++;
20741                 if (NO_GEOM){
20742                         /* auto-sensing */
20743 -                       res = floppy_read_block_0(disk);
20744 +                       res = __floppy_read_block_0(opened_bdev[drive]);
20745                 } else {
20746                         if (cf)
20747                                 poll_drive(0, FD_RAW_NEED_DISK);
20748 @@ -4633,3 +4607,5 @@
20749  __setup ("floppy=", floppy_setup);
20750  module_init(floppy_init)
20751  #endif
20752 +
20753 +MODULE_ALIAS_BLOCKDEV_MAJOR(FLOPPY_MAJOR);
20754 diff -Nru a/drivers/block/floppy98.c b/drivers/block/floppy98.c
20755 --- a/drivers/block/floppy98.c  Thu Aug  7 02:25:24 2003
20756 +++ b/drivers/block/floppy98.c  Tue Aug 26 09:44:42 2003
20757 @@ -3844,9 +3844,9 @@
20758                 }
20759         }
20760  
20761 -       UDRS->fd_device = minor(inode->i_rdev);
20762 -       set_capacity(disks[drive], floppy_sizes[minor(inode->i_rdev)]);
20763 -       if (old_dev != -1 && old_dev != minor(inode->i_rdev)) {
20764 +       UDRS->fd_device = iminor(inode);
20765 +       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
20766 +       if (old_dev != -1 && old_dev != iminor(inode)) {
20767                 if (buffer_drive == drive)
20768                         buffer_track = -1;
20769         }
20770 @@ -3989,22 +3989,6 @@
20771         return 0;
20772  }
20773  
20774 -static int floppy_read_block_0(struct gendisk *disk)
20775 -{
20776 -       struct block_device *bdev;
20777 -       int ret;
20778 -
20779 -       bdev = bdget_disk(disk, 0);
20780 -       if (!bdev) {
20781 -               printk("No block device for %s\n", disk->disk_name);
20782 -               BUG();
20783 -       }
20784 -       bdev->bd_disk = disk;   /* ewww */
20785 -       ret = __floppy_read_block_0(bdev);
20786 -       atomic_dec(&bdev->bd_count);
20787 -       return ret;
20788 -}
20789 -
20790  /* revalidate the floppy disk, i.e. trigger format autodetection by reading
20791   * the bootblock (block 0). "Autodetection" is also needed to check whether
20792   * there is a disk in the drive at all... Thus we also do it for fixed
20793 @@ -4040,7 +4024,7 @@
20794                         UDRS->generation++;
20795                 if (NO_GEOM){
20796                         /* auto-sensing */
20797 -                       res = floppy_read_block_0(disk);
20798 +                       res = __floppy_read_block_0(opened_bdev[drive]);
20799                 } else {
20800                         if (cf)
20801                                 poll_drive(0, FD_RAW_NEED_DISK);
20802 diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c
20803 --- a/drivers/block/genhd.c     Fri Aug  1 02:22:20 2003
20804 +++ b/drivers/block/genhd.c     Wed Sep  3 23:40:17 2003
20805 @@ -372,7 +372,7 @@
20806                 disk_stat_read(disk, write_merges),
20807                 (unsigned long long)disk_stat_read(disk, write_sectors),
20808                 jiffies_to_msec(disk_stat_read(disk, write_ticks)),
20809 -               disk_stat_read(disk, in_flight), 
20810 +               disk->in_flight,
20811                 jiffies_to_msec(disk_stat_read(disk, io_ticks)),
20812                 jiffies_to_msec(disk_stat_read(disk, time_in_queue)));
20813  }
20814 @@ -492,7 +492,7 @@
20815                 disk_stat_read(gp, writes), disk_stat_read(gp, write_merges),
20816                 (unsigned long long)disk_stat_read(gp, write_sectors),
20817                 jiffies_to_msec(disk_stat_read(gp, write_ticks)),
20818 -               disk_stat_read(gp, in_flight),
20819 +               gp->in_flight,
20820                 jiffies_to_msec(disk_stat_read(gp, io_ticks)),
20821                 jiffies_to_msec(disk_stat_read(gp, time_in_queue)));
20822  
20823 @@ -576,13 +576,10 @@
20824  
20825  void set_device_ro(struct block_device *bdev, int flag)
20826  {
20827 -       struct gendisk *disk = bdev->bd_disk;
20828 -       if (bdev->bd_contains != bdev) {
20829 -               int part = bdev->bd_dev - MKDEV(disk->major, disk->first_minor);
20830 -               struct hd_struct *p = disk->part[part-1];
20831 -               if (p) p->policy = flag;
20832 -       } else
20833 -               disk->policy = flag;
20834 +       if (bdev->bd_contains != bdev)
20835 +               bdev->bd_part->policy = flag;
20836 +       else
20837 +               bdev->bd_disk->policy = flag;
20838  }
20839  
20840  void set_disk_ro(struct gendisk *disk, int flag)
20841 @@ -595,17 +592,12 @@
20842  
20843  int bdev_read_only(struct block_device *bdev)
20844  {
20845 -       struct gendisk *disk;
20846         if (!bdev)
20847                 return 0;
20848 -       disk = bdev->bd_disk;
20849 -       if (bdev->bd_contains != bdev) {
20850 -               int part = bdev->bd_dev - MKDEV(disk->major, disk->first_minor);
20851 -               struct hd_struct *p = disk->part[part-1];
20852 -               if (p) return p->policy;
20853 -               return 0;
20854 -       } else
20855 -               return disk->policy;
20856 +       else if (bdev->bd_contains != bdev)
20857 +               return bdev->bd_part->policy;
20858 +       else
20859 +               return bdev->bd_disk->policy;
20860  }
20861  
20862  int invalidate_partition(struct gendisk *disk, int index)
20863 diff -Nru a/drivers/block/ioctl.c b/drivers/block/ioctl.c
20864 --- a/drivers/block/ioctl.c     Thu Jul 17 22:30:42 2003
20865 +++ b/drivers/block/ioctl.c     Tue Aug 26 12:06:15 2003
20866 @@ -8,7 +8,6 @@
20867  static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg *arg)
20868  {
20869         struct block_device *bdevp;
20870 -       int holder;
20871         struct gendisk *disk;
20872         struct blkpg_ioctl_arg a;
20873         struct blkpg_partition p;
20874 @@ -41,8 +40,11 @@
20875                                         return -EINVAL;
20876                         }
20877                         /* partition number in use? */
20878 -                       if (disk->part[part - 1])
20879 +                       down(&bdev->bd_sem);
20880 +                       if (disk->part[part - 1]) {
20881 +                               up(&bdev->bd_sem);
20882                                 return -EBUSY;
20883 +                       }
20884                         /* overlap? */
20885                         for (i = 0; i < disk->minors - 1; i++) {
20886                                 struct hd_struct *s = disk->part[i];
20887 @@ -50,22 +52,26 @@
20888                                 if (!s)
20889                                         continue;
20890                                 if (!(start+length <= s->start_sect ||
20891 -                                     start >= s->start_sect + s->nr_sects))
20892 +                                     start >= s->start_sect + s->nr_sects)) {
20893 +                                       up(&bdev->bd_sem);
20894                                         return -EBUSY;
20895 +                               }
20896                         }
20897                         /* all seems OK */
20898                         add_partition(disk, part, start, length);
20899 +                       up(&bdev->bd_sem);
20900                         return 0;
20901                 case BLKPG_DEL_PARTITION:
20902                         if (!disk->part[part-1])
20903                                 return -ENXIO;
20904                         if (disk->part[part - 1]->nr_sects == 0)
20905                                 return -ENXIO;
20906 -                       /* partition in use? Incomplete check for now. */
20907                         bdevp = bdget_disk(disk, part);
20908                         if (!bdevp)
20909                                 return -ENOMEM;
20910 -                       if (bd_claim(bdevp, &holder) < 0) {
20911 +                       down(&bdevp->bd_sem);
20912 +                       if (bdevp->bd_openers) {
20913 +                               up(&bdevp->bd_sem);
20914                                 bdput(bdevp);
20915                                 return -EBUSY;
20916                         }
20917 @@ -73,9 +79,12 @@
20918                         fsync_bdev(bdevp);
20919                         invalidate_bdev(bdevp, 0);
20920  
20921 +                       down(&bdev->bd_sem);
20922                         delete_partition(disk, part);
20923 -                       bd_release(bdevp);
20924 +                       up(&bdev->bd_sem);
20925 +                       up(&bdevp->bd_sem);
20926                         bdput(bdevp);
20927 +
20928                         return 0;
20929                 default:
20930                         return -EINVAL;
20931 diff -Nru a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
20932 --- a/drivers/block/ll_rw_blk.c Mon Aug 18 22:28:54 2003
20933 +++ b/drivers/block/ll_rw_blk.c Wed Sep  3 23:40:17 2003
20934 @@ -136,6 +136,12 @@
20935         return ret;
20936  }
20937  
20938 +void blk_queue_activity_fn(request_queue_t *q, activity_fn *fn, void *data)
20939 +{
20940 +       q->activity_fn = fn;
20941 +       q->activity_data = data;
20942 +}
20943 +
20944  /**
20945   * blk_queue_prep_rq - set a prepare_request function for queue
20946   * @q:         queue
20947 @@ -225,6 +231,8 @@
20948         blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
20949  
20950         INIT_LIST_HEAD(&q->plug_list);
20951 +
20952 +       blk_queue_activity_fn(q, NULL, NULL);
20953  }
20954  
20955  /**
20956 @@ -1314,7 +1322,7 @@
20957  
20958         if (!printed) {
20959                 printed = 1;
20960 -               printk("Using %s elevator\n", chosen_elevator->elevator_name);
20961 +               printk("Using %s io scheduler\n", chosen_elevator->elevator_name);
20962         }
20963  
20964         if (elevator_init(q, chosen_elevator))
20965 @@ -1652,7 +1660,7 @@
20966         }
20967         if (new_io) {
20968                 disk_round_stats(rq->rq_disk);
20969 -               disk_stat_inc(rq->rq_disk, in_flight);
20970 +               rq->rq_disk->in_flight++;
20971         }
20972  }
20973  
20974 @@ -1666,6 +1674,9 @@
20975  {
20976         drive_stat_acct(req, req->nr_sectors, 1);
20977  
20978 +       if (q->activity_fn)
20979 +               q->activity_fn(q->activity_data, rq_data_dir(req));
20980 +
20981         /*
20982          * elevator indicated where it wants this request to be
20983          * inserted at elevator_merge time
20984 @@ -1693,10 +1704,10 @@
20985         unsigned long now = jiffies;
20986  
20987         disk_stat_add(disk, time_in_queue, 
20988 -                       disk_stat_read(disk, in_flight) * (now - disk->stamp));
20989 +                       disk->in_flight * (now - disk->stamp));
20990         disk->stamp = now;
20991  
20992 -       if (disk_stat_read(disk, in_flight))
20993 +       if (disk->in_flight)
20994                 disk_stat_add(disk, io_ticks, (now - disk->stamp_idle));
20995         disk->stamp_idle = now;
20996  }
20997 @@ -1808,7 +1819,7 @@
20998  
20999         if (req->rq_disk) {
21000                 disk_round_stats(req->rq_disk);
21001 -               disk_stat_dec(req->rq_disk, in_flight);
21002 +               req->rq_disk->in_flight--;
21003         }
21004  
21005         __blk_put_request(q, next);
21006 @@ -2043,24 +2054,23 @@
21007  static inline void blk_partition_remap(struct bio *bio)
21008  {
21009         struct block_device *bdev = bio->bi_bdev;
21010 -       struct gendisk *disk = bdev->bd_disk;
21011 -       struct hd_struct *p;
21012 -       if (bdev == bdev->bd_contains)
21013 -               return;
21014  
21015 -       p = disk->part[bdev->bd_dev-MKDEV(disk->major,disk->first_minor)-1];
21016 -       switch (bio->bi_rw) {
21017 -       case READ:
21018 -               p->read_sectors += bio_sectors(bio);
21019 -               p->reads++;
21020 -               break;
21021 -       case WRITE:
21022 -               p->write_sectors += bio_sectors(bio);
21023 -               p->writes++;
21024 -               break;
21025 +       if (bdev != bdev->bd_contains) {
21026 +               struct hd_struct *p = bdev->bd_part;
21027 +
21028 +               switch (bio->bi_rw) {
21029 +               case READ:
21030 +                       p->read_sectors += bio_sectors(bio);
21031 +                       p->reads++;
21032 +                       break;
21033 +               case WRITE:
21034 +                       p->write_sectors += bio_sectors(bio);
21035 +                       p->writes++;
21036 +                       break;
21037 +               }
21038 +               bio->bi_sector += p->start_sect;
21039 +               bio->bi_bdev = bdev->bd_contains;
21040         }
21041 -       bio->bi_sector += bdev->bd_offset;
21042 -       bio->bi_bdev = bdev->bd_contains;
21043  }
21044  
21045  /**
21046 @@ -2470,7 +2480,7 @@
21047                         break;
21048                 }
21049                 disk_round_stats(disk);
21050 -               disk_stat_dec(disk, in_flight);
21051 +               disk->in_flight--;
21052         }
21053         __blk_put_request(req->q, req);
21054         /* Do this LAST! The structure may be freed immediately afterwards */
21055 diff -Nru a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
21056 --- a/drivers/block/paride/pg.c Sun May 25 02:45:05 2003
21057 +++ b/drivers/block/paride/pg.c Tue Aug 26 09:25:41 2003
21058 @@ -527,11 +527,9 @@
21059         return -1;
21060  }
21061  
21062 -#define DEVICE_NR(dev) (minor(dev) & 0x7F)
21063 -
21064  static int pg_open(struct inode *inode, struct file *file)
21065  {
21066 -       int unit = DEVICE_NR(inode->i_rdev);
21067 +       int unit = iminor(inode) & 0x7f;
21068         struct pg *dev = &devices[unit];
21069  
21070         if ((unit >= PG_UNITS) || (!dev->present))
21071 diff -Nru a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
21072 --- a/drivers/block/paride/pt.c Sun May 25 02:45:06 2003
21073 +++ b/drivers/block/paride/pt.c Tue Aug 26 09:25:41 2003
21074 @@ -670,11 +670,11 @@
21075         return -1;
21076  }
21077  
21078 -#define DEVICE_NR(dev) (minor(dev) & 0x7F)
21079 +#define DEVICE_NR(inode)       (iminor(inode) & 0x7F)
21080  
21081  static int pt_open(struct inode *inode, struct file *file)
21082  {
21083 -       int unit = DEVICE_NR(inode->i_rdev);
21084 +       int unit = DEVICE_NR(inode);
21085  
21086         if ((unit >= PT_UNITS) || (!PT.present))
21087                 return -ENODEV;
21088 @@ -696,7 +696,7 @@
21089                 return -EROFS;
21090         }
21091  
21092 -       if (!(minor(inode->i_rdev) & 128))
21093 +       if (!(iminor(inode) & 128))
21094                 PT.flags |= PT_REWIND;
21095  
21096         PT.bufptr = kmalloc(PT_BUFSIZE, GFP_KERNEL);
21097 @@ -715,7 +715,7 @@
21098         int unit;
21099         struct mtop mtop;
21100  
21101 -       unit = DEVICE_NR(inode->i_rdev);
21102 +       unit = DEVICE_NR(inode);
21103         if (unit >= PT_UNITS)
21104                 return -EINVAL;
21105         if (!PT.present)
21106 @@ -753,7 +753,7 @@
21107  static int
21108  pt_release(struct inode *inode, struct file *file)
21109  {
21110 -       int unit = DEVICE_NR(inode->i_rdev);
21111 +       int unit = DEVICE_NR(inode);
21112  
21113         if ((unit >= PT_UNITS) || (atomic_read(&PT.available) > 1))
21114                 return -EINVAL;
21115 @@ -776,7 +776,7 @@
21116  static ssize_t pt_read(struct file *filp, char *buf, size_t count, loff_t * ppos)
21117  {
21118         struct inode *ino = filp->f_dentry->d_inode;
21119 -       int unit = DEVICE_NR(ino->i_rdev);
21120 +       int unit = DEVICE_NR(ino);
21121         char rd_cmd[12] = { ATAPI_READ_6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
21122         int k, n, r, p, s, t, b;
21123  
21124 @@ -873,7 +873,7 @@
21125  static ssize_t pt_write(struct file *filp, const char *buf, size_t count, loff_t * ppos)
21126  {
21127         struct inode *ino = filp->f_dentry->d_inode;
21128 -       int unit = DEVICE_NR(ino->i_rdev);
21129 +       int unit = DEVICE_NR(ino);
21130         char wr_cmd[12] = { ATAPI_WRITE_6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
21131         int k, n, r, p, s, t, b;
21132  
21133 diff -Nru a/drivers/block/rd.c b/drivers/block/rd.c
21134 --- a/drivers/block/rd.c        Thu Aug  7 02:25:24 2003
21135 +++ b/drivers/block/rd.c        Tue Aug 26 10:05:56 2003
21136 @@ -245,6 +245,7 @@
21137  static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
21138  {
21139         int error;
21140 +       struct block_device *bdev = inode->i_bdev;
21141  
21142         if (cmd != BLKFLSBUF)
21143                 return -EINVAL;
21144 @@ -253,12 +254,12 @@
21145            it's not like with the other blockdevices where
21146            this ioctl only flushes away the buffer cache. */
21147         error = -EBUSY;
21148 -       down(&inode->i_bdev->bd_sem);
21149 -       if (inode->i_bdev->bd_openers <= 2) {
21150 -               truncate_inode_pages(inode->i_mapping, 0);
21151 +       down(&bdev->bd_sem);
21152 +       if (bdev->bd_openers <= 2) {
21153 +               truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
21154                 error = 0;
21155         }
21156 -       up(&inode->i_bdev->bd_sem);
21157 +       up(&bdev->bd_sem);
21158         return error;
21159  }
21160  
21161 @@ -269,18 +270,18 @@
21162  
21163  static int rd_open(struct inode * inode, struct file * filp)
21164  {
21165 -       unsigned unit = minor(inode->i_rdev);
21166 +       unsigned unit = iminor(inode);
21167  
21168         /*
21169          * Immunize device against invalidate_buffers() and prune_icache().
21170          */
21171         if (rd_bdev[unit] == NULL) {
21172                 struct block_device *bdev = inode->i_bdev;
21173 -               atomic_inc(&bdev->bd_count);
21174 +               inode = igrab(bdev->bd_inode);
21175                 rd_bdev[unit] = bdev;
21176                 bdev->bd_openers++;
21177                 bdev->bd_block_size = rd_blocksize;
21178 -               bdev->bd_inode->i_size = get_capacity(rd_disks[unit])<<9;
21179 +               inode->i_size = get_capacity(rd_disks[unit])<<9;
21180                 inode->i_mapping->a_ops = &ramdisk_aops;
21181                 inode->i_mapping->backing_dev_info = &rd_backing_dev_info;
21182         }
21183 diff -Nru a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c
21184 --- a/drivers/block/scsi_ioctl.c        Thu Aug  7 11:22:15 2003
21185 +++ b/drivers/block/scsi_ioctl.c        Mon Sep  1 12:24:06 2003
21186 @@ -438,11 +438,7 @@
21187                         err = sg_emulated_host(q, (int *) arg);
21188                         break;
21189                 case SG_IO:
21190 -                       err = bd_claim(bdev, current);
21191 -                       if (err)
21192 -                               break;
21193                         err = sg_io(q, bdev, (struct sg_io_hdr *) arg);
21194 -                       bd_release(bdev);
21195                         break;
21196                 /*
21197                  * old junk scsi send command ioctl
21198 @@ -452,11 +448,7 @@
21199                         if (!arg)
21200                                 break;
21201  
21202 -                       err = bd_claim(bdev, current);
21203 -                       if (err)
21204 -                               break;
21205                         err = sg_scsi_ioctl(q, bdev, (Scsi_Ioctl_Command *)arg);
21206 -                       bd_release(bdev);
21207                         break;
21208                 case CDROMCLOSETRAY:
21209                         close = 1;
21210 diff -Nru a/drivers/block/xd.c b/drivers/block/xd.c
21211 --- a/drivers/block/xd.c        Thu Aug  7 02:25:24 2003
21212 +++ b/drivers/block/xd.c        Wed Sep  3 23:40:13 2003
21213 @@ -1103,5 +1103,5 @@
21214  
21215  #endif /* MODULE */
21216  
21217 -module_init(xd_init)
21218 -
21219 +module_init(xd_init);
21220 +MODULE_ALIAS_BLOCKDEV_MAJOR(XT_DISK_MAJOR);
21221 diff -Nru a/drivers/block/z2ram.c b/drivers/block/z2ram.c
21222 --- a/drivers/block/z2ram.c     Thu Aug  7 02:25:24 2003
21223 +++ b/drivers/block/z2ram.c     Wed Jul 30 15:20:18 2003
21224 @@ -28,10 +28,10 @@
21225  #define DEVICE_NAME "Z2RAM"
21226  
21227  #include <linux/major.h>
21228 -#include <linux/slab.h>
21229  #include <linux/vmalloc.h>
21230  #include <linux/init.h>
21231  #include <linux/module.h>
21232 +#include <linux/blkdev.h>
21233  
21234  #include <asm/setup.h>
21235  #include <asm/bitops.h>
21236 @@ -150,7 +150,7 @@
21237         sizeof( z2ram_map[0] );
21238      int rc = -ENOMEM;
21239  
21240 -    device = minor( inode->i_rdev );
21241 +    device = iminor(inode);
21242  
21243      if ( current_device != -1 && current_device != device )
21244      {
21245 diff -Nru a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
21246 --- a/drivers/bluetooth/hci_ldisc.c     Thu May  8 16:38:32 2003
21247 +++ b/drivers/bluetooth/hci_ldisc.c     Wed Sep  3 23:40:16 2003
21248 @@ -574,3 +574,4 @@
21249  MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>");
21250  MODULE_DESCRIPTION("Bluetooth HCI UART driver ver " VERSION);
21251  MODULE_LICENSE("GPL");
21252 +MODULE_ALIAS_LDISC(N_HCI);
21253 diff -Nru a/drivers/cdrom/Kconfig b/drivers/cdrom/Kconfig
21254 --- a/drivers/cdrom/Kconfig     Thu Jun 26 23:05:31 2003
21255 +++ b/drivers/cdrom/Kconfig     Mon Aug 25 06:13:29 2003
21256 @@ -74,7 +74,7 @@
21257  
21258  config SBPCD
21259         tristate "Matsushita/Panasonic/Creative, Longshine, TEAC CDROM support"
21260 -       depends on CD_NO_IDESCSI
21261 +       depends on CD_NO_IDESCSI && BROKEN_ON_SMP
21262         ---help---
21263           This driver supports most of the drives which use the Panasonic or
21264           Sound Blaster interface.  Please read the file
21265 @@ -199,7 +199,7 @@
21266  
21267  config CM206
21268         tristate "Philips/LMS CM206 CDROM support"
21269 -       depends on CD_NO_IDESCSI
21270 +       depends on CD_NO_IDESCSI && BROKEN_ON_SMP
21271         ---help---
21272           If you have a Philips/LMS CD-ROM drive cm206 in combination with a
21273           cm260 host adapter card, say Y here. Please also read the file
21274 @@ -245,7 +245,7 @@
21275  
21276  config CDU31A
21277         tristate "Sony CDU31A/CDU33A CDROM support"
21278 -       depends on CD_NO_IDESCSI
21279 +       depends on CD_NO_IDESCSI && BROKEN_ON_SMP
21280         ---help---
21281           These CD-ROM drives have a spring-pop-out caddyless drawer, and a
21282           rectangular green LED centered beneath it.  NOTE: these CD-ROM
21283 @@ -267,7 +267,7 @@
21284  
21285  config CDU535
21286         tristate "Sony CDU535 CDROM support"
21287 -       depends on CD_NO_IDESCSI
21288 +       depends on CD_NO_IDESCSI && BROKEN_ON_SMP
21289         ---help---
21290           This is the driver for the older Sony CDU-535 and CDU-531 CD-ROM
21291           drives. Please read the file <file:Documentation/cdrom/sonycd535>.
21292 diff -Nru a/drivers/cdrom/aztcd.c b/drivers/cdrom/aztcd.c
21293 --- a/drivers/cdrom/aztcd.c     Thu Aug  7 02:25:24 2003
21294 +++ b/drivers/cdrom/aztcd.c     Wed Sep  3 23:40:13 2003
21295 @@ -2499,3 +2499,4 @@
21296  }
21297  
21298  MODULE_LICENSE("GPL");
21299 +MODULE_ALIAS_BLOCKDEV_MAJOR(AZTECH_CDROM_MAJOR);
21300 diff -Nru a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
21301 --- a/drivers/cdrom/cdu31a.c    Thu Aug  7 02:25:24 2003
21302 +++ b/drivers/cdrom/cdu31a.c    Wed Sep  3 23:40:13 2003
21303 @@ -3500,3 +3500,4 @@
21304  module_exit(cdu31a_exit);
21305  
21306  MODULE_LICENSE("GPL");
21307 +MODULE_ALIAS_BLOCKDEV_MAJOR(CDU31A_CDROM_MAJOR);
21308 diff -Nru a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
21309 --- a/drivers/cdrom/cm206.c     Thu Aug  7 02:25:24 2003
21310 +++ b/drivers/cdrom/cm206.c     Wed Sep  3 23:40:13 2003
21311 @@ -1616,7 +1616,7 @@
21312  __setup("cm206=", cm206_setup);
21313  
21314  #endif                         /* !MODULE */
21315 -
21316 +MODULE_ALIAS_BLOCKDEV_MAJOR(CM206_CDROM_MAJOR);
21317  
21318  /*
21319   * Local variables:
21320 diff -Nru a/drivers/cdrom/gscd.c b/drivers/cdrom/gscd.c
21321 --- a/drivers/cdrom/gscd.c      Thu Aug  7 02:25:24 2003
21322 +++ b/drivers/cdrom/gscd.c      Wed Sep  3 23:40:13 2003
21323 @@ -1029,3 +1029,4 @@
21324  MODULE_LICENSE("GPL");
21325  module_init(gscd_init);
21326  module_exit(gscd_exit);
21327 +MODULE_ALIAS_BLOCKDEV_MAJOR(GOLDSTAR_CDROM_MAJOR);
21328 diff -Nru a/drivers/cdrom/mcd.c b/drivers/cdrom/mcd.c
21329 --- a/drivers/cdrom/mcd.c       Thu Aug  7 02:25:24 2003
21330 +++ b/drivers/cdrom/mcd.c       Wed Sep  3 23:40:13 2003
21331 @@ -1559,3 +1559,4 @@
21332  
21333  MODULE_AUTHOR("Martin Harriss");
21334  MODULE_LICENSE("GPL");
21335 +MODULE_ALIAS_BLOCKDEV_MAJOR(MITSUMI_CDROM_MAJOR);
21336 diff -Nru a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
21337 --- a/drivers/cdrom/mcdx.c      Thu Aug  7 02:25:24 2003
21338 +++ b/drivers/cdrom/mcdx.c      Wed Sep  3 23:40:13 2003
21339 @@ -1970,3 +1970,4 @@
21340  }
21341  
21342  MODULE_LICENSE("GPL");
21343 +MODULE_ALIAS_BLOCKDEV_MAJOR(MITSUMI_X_CDROM_MAJOR);
21344 diff -Nru a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c
21345 --- a/drivers/cdrom/optcd.c     Thu Aug  7 02:25:24 2003
21346 +++ b/drivers/cdrom/optcd.c     Wed Sep  3 23:40:13 2003
21347 @@ -2102,3 +2102,4 @@
21348  module_exit(optcd_exit);
21349  
21350  MODULE_LICENSE("GPL");
21351 +MODULE_ALIAS_BLOCKDEV_MAJOR(OPTICS_CDROM_MAJOR);
21352 diff -Nru a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
21353 --- a/drivers/cdrom/sbpcd.c     Thu Aug  7 02:25:24 2003
21354 +++ b/drivers/cdrom/sbpcd.c     Wed Sep  3 23:40:13 2003
21355 @@ -5954,6 +5954,9 @@
21356  }
21357  
21358  MODULE_LICENSE("GPL");
21359 +/* FIXME: Old modules.conf claims MATSUSHITA_CDROM2_MAJOR and CDROM3, but
21360 +   AFAICT this doesn't support those majors, so why? --RR 30 Jul 2003 */
21361 +MODULE_ALIAS_BLOCKDEV_MAJOR(MATSUSHITA_CDROM_MAJOR);
21362  
21363  /*==========================================================================*/
21364  /*
21365 diff -Nru a/drivers/cdrom/sjcd.c b/drivers/cdrom/sjcd.c
21366 --- a/drivers/cdrom/sjcd.c      Thu Aug  7 02:25:24 2003
21367 +++ b/drivers/cdrom/sjcd.c      Wed Sep  3 23:40:13 2003
21368 @@ -1813,3 +1813,4 @@
21369  module_exit(sjcd_exit);
21370  
21371  MODULE_LICENSE("GPL");
21372 +MODULE_ALIAS_BLOCKDEV_MAJOR(SANYO_CDROM_MAJOR);
21373 diff -Nru a/drivers/cdrom/sonycd535.c b/drivers/cdrom/sonycd535.c
21374 --- a/drivers/cdrom/sonycd535.c Thu Aug  7 02:25:24 2003
21375 +++ b/drivers/cdrom/sonycd535.c Wed Sep  3 23:40:13 2003
21376 @@ -1684,3 +1684,4 @@
21377  
21378  
21379  MODULE_LICENSE("GPL");
21380 +MODULE_ALIAS_BLOCKDEV_MAJOR(CDU535_CDROM_MAJOR);
21381 diff -Nru a/drivers/char/Kconfig b/drivers/char/Kconfig
21382 --- a/drivers/char/Kconfig      Fri Aug 22 09:52:20 2003
21383 +++ b/drivers/char/Kconfig      Tue Sep  2 11:28:13 2003
21384 @@ -80,7 +80,7 @@
21385  
21386  config COMPUTONE
21387         tristate "Computone IntelliPort Plus serial support"
21388 -       depends on SERIAL_NONSTANDARD
21389 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21390         ---help---
21391           This driver supports the entire family of Intelliport II/Plus
21392           controllers with the exception of the MicroChannel controllers and
21393 @@ -113,7 +113,7 @@
21394  
21395  config CYCLADES
21396         tristate "Cyclades async mux support"
21397 -       depends on SERIAL_NONSTANDARD
21398 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21399         ---help---
21400           This is a driver for a card that gives you many serial ports. You
21401           would need something like this to connect more than two modems to
21402 @@ -145,7 +145,7 @@
21403  
21404  config DIGIEPCA
21405         tristate "Digiboard Intelligent Async Support"
21406 -       depends on SERIAL_NONSTANDARD
21407 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21408         ---help---
21409           This is a driver for Digi International's Xx, Xeve, and Xem series
21410           of cards which provide multiple serial ports. You would need
21411 @@ -164,7 +164,7 @@
21412  
21413  config DIGI
21414         tristate "Digiboard PC/Xx Support"
21415 -       depends on SERIAL_NONSTANDARD && DIGIEPCA=n
21416 +       depends on SERIAL_NONSTANDARD && DIGIEPCA=n && BROKEN_ON_SMP
21417         help
21418           This is a driver for the Digiboard PC/Xe, PC/Xi, and PC/Xeve cards
21419           that give you many serial ports. You would need something like this
21420 @@ -177,7 +177,7 @@
21421  
21422  config ESPSERIAL
21423         tristate "Hayes ESP serial port support"
21424 -       depends on SERIAL_NONSTANDARD && ISA
21425 +       depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP
21426         help
21427           This is a driver which supports Hayes ESP serial ports.  Both single
21428           port cards and multiport cards are supported.  Make sure to read
21429 @@ -190,7 +190,7 @@
21430  
21431  config MOXA_INTELLIO
21432         tristate "Moxa Intellio support"
21433 -       depends on SERIAL_NONSTANDARD
21434 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21435         help
21436           Say Y here if you have a Moxa Intellio multiport serial card.
21437  
21438 @@ -201,7 +201,7 @@
21439  
21440  config MOXA_SMARTIO
21441         tristate "Moxa SmartIO support"
21442 -       depends on SERIAL_NONSTANDARD
21443 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21444         help
21445           Say Y here if you have a Moxa SmartIO multiport serial card.
21446  
21447 @@ -212,7 +212,7 @@
21448  
21449  config ISI
21450         tristate "Multi-Tech multiport card support (EXPERIMENTAL)"
21451 -       depends on SERIAL_NONSTANDARD && EXPERIMENTAL && m
21452 +       depends on SERIAL_NONSTANDARD && EXPERIMENTAL && BROKEN_ON_SMP && m
21453         help
21454           This is a driver for the Multi-Tech cards which provide several
21455           serial ports.  The driver is experimental and can currently only be
21456 @@ -262,7 +262,7 @@
21457  
21458  config RISCOM8
21459         tristate "SDL RISCom/8 card support"
21460 -       depends on SERIAL_NONSTANDARD
21461 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21462         help
21463           This is a driver for the SDL Communications RISCom/8 multiport card,
21464           which gives you many serial ports. You would need something like
21465 @@ -275,7 +275,7 @@
21466  
21467  config SPECIALIX
21468         tristate "Specialix IO8+ card support"
21469 -       depends on SERIAL_NONSTANDARD
21470 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21471         help
21472           This is a driver for the Specialix IO8+ multiport card (both the
21473           ISA and the PCI version) which gives you many serial ports. You
21474 @@ -299,7 +299,7 @@
21475  
21476  config SX
21477         tristate "Specialix SX (and SI) card support"
21478 -       depends on SERIAL_NONSTANDARD
21479 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21480         help
21481           This is a driver for the SX and SI multiport serial cards.
21482           Please read the file <file:Documentation/sx.txt> for details.
21483 @@ -310,7 +310,7 @@
21484  
21485  config RIO
21486         tristate "Specialix RIO system support"
21487 -       depends on SERIAL_NONSTANDARD
21488 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
21489         help
21490           This is a driver for the Specialix RIO, a smart serial card which
21491           drives an outboard box that can support up to 128 ports.  Product
21492 @@ -339,7 +339,7 @@
21493  
21494  config STALLION
21495         tristate "Stallion EasyIO or EC8/32 support"
21496 -       depends on STALDRV
21497 +       depends on STALDRV && BROKEN_ON_SMP
21498         help
21499           If you have an EasyIO or EasyConnection 8/32 multiport Stallion
21500           card, then this is for you; say Y.  Make sure to read
21501 @@ -352,7 +352,7 @@
21502  
21503  config ISTALLION
21504         tristate "Stallion EC8/64, ONboard, Brumby support"
21505 -       depends on STALDRV
21506 +       depends on STALDRV && BROKEN
21507         help
21508           If you have an EasyConnection 8/64, ONboard, Brumby or Stallion
21509           serial multiport card, say Y here. Make sure to read
21510 @@ -365,7 +365,7 @@
21511  
21512  config SERIAL_TX3912
21513         bool "TMPTX3912/PR31700 serial port support"
21514 -       depends on SERIAL_NONSTANDARD && MIPS
21515 +       depends on SERIAL_NONSTANDARD && MIPS && BROKEN_ON_SMP
21516         help
21517           The TX3912 is a Toshiba RISC processor based o the MIPS 3900 core;
21518           see <http://www.toshiba.com/taec/components/Generic/risc/tx3912.htm>.
21519 @@ -425,7 +425,7 @@
21520  
21521  config A2232
21522         tristate "Commodore A2232 serial support (EXPERIMENTAL)"
21523 -       depends on EXPERIMENTAL && ZORRO
21524 +       depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP
21525         ---help---
21526           This option supports the 2232 7-port serial card shipped with the
21527           Amiga 2000 and other Zorro-bus machines, dating from 1989.  At
21528 @@ -909,6 +909,7 @@
21529  
21530  config FTAPE
21531         tristate "Ftape (QIC-80/Travan) support"
21532 +       depends on BROKEN_ON_SMP
21533         ---help---
21534           If you have a tape drive that is connected to your floppy
21535           controller, say Y here.
21536 diff -Nru a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
21537 --- a/drivers/char/agp/Kconfig  Fri Aug 15 07:33:19 2003
21538 +++ b/drivers/char/agp/Kconfig  Thu Aug 28 16:22:00 2003
21539 @@ -63,15 +63,19 @@
21540           You should say Y here if you use XFree86 3.3.6 or 4.x and want to
21541           use GLX or DRI.  If unsure, say N.
21542  
21543 +# RED-PEN this option is misnamed, it's not 8151 specific
21544  config AGP_AMD_8151
21545 -       tristate "AMD Opteron/Athlon64 on-CPU GART support"
21546 +       tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU
21547         depends on AGP && X86
21548 -       default GART_IOMMU
21549 +       default y if GART_IOMMU
21550         help
21551           This option gives you AGP support for the GLX component of
21552 -         XFree86 4.x using the on-CPU AGP bridge of the AMD Athlon64/Opteron CPUs.
21553 +         XFree86 4.x using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.
21554 +         You still need an external AGP bridge like the AMD 8151, VIA
21555 +          K8T400M, SiS755. It may also support other AGP bridges when loaded
21556 +         with agp_try_unsupported=1.
21557           You should say Y here if you use XFree86 3.3.6 or 4.x and want to
21558 -         use GLX or DRI.  If unsure, say N
21559 +         use GLX or DRI.  If unsure, say Y
21560  
21561  config AGP_INTEL
21562         tristate "Intel 440LX/BX/GX, I8xx and E7x05 chipset support"
21563 diff -Nru a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
21564 --- a/drivers/char/agp/agp.h    Fri Aug 15 06:28:58 2003
21565 +++ b/drivers/char/agp/agp.h    Thu Aug 28 18:04:31 2003
21566 @@ -167,8 +167,10 @@
21567  
21568  #define PGE_EMPTY(b, p)        (!(p) || (p) == (unsigned long) (b)->scratch_page)
21569  
21570 -/* intel register */
21571 -#define INTEL_APBASE   0x10
21572 +/* Chipset independant registers (from AGP Spec) */
21573 +#define AGP_APBASE     0x10
21574 +
21575 +/* Intel registers */
21576  #define INTEL_APSIZE   0xb4
21577  #define INTEL_ATTBASE  0xb8
21578  #define INTEL_AGPCTRL  0xb0
21579 @@ -176,7 +178,6 @@
21580  #define INTEL_ERRSTS   0x91
21581  
21582  /* Intel 460GX Registers */
21583 -#define INTEL_I460_APBASE              0x10
21584  #define INTEL_I460_BAPBASE             0x98
21585  #define INTEL_I460_GXBCTL              0xa0
21586  #define INTEL_I460_AGPSIZ              0xa2
21587 @@ -184,7 +185,7 @@
21588  #define INTEL_I460_GATT_VALID          (1UL << 24)
21589  #define INTEL_I460_GATT_COHERENT       (1UL << 25)
21590  
21591 -/* intel i830 registers */
21592 +/* Intel i830 registers */
21593  #define I830_GMCH_CTRL                 0x52
21594  #define I830_GMCH_ENABLED              0x4
21595  #define I830_GMCH_MEM_MASK             0x1
21596 @@ -218,31 +219,31 @@
21597  #define I852_GME                       0x2
21598  #define I852_GM                                0x5
21599  
21600 -/* intel 815 register */
21601 +/* Intel 815 register */
21602  #define INTEL_815_APCONT       0x51
21603  #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
21604  
21605 -/* intel i820 registers */
21606 +/* Intel i820 registers */
21607  #define INTEL_I820_RDCR                0x51
21608  #define INTEL_I820_ERRSTS      0xc8
21609  
21610 -/* intel i840 registers */
21611 +/* Intel i840 registers */
21612  #define INTEL_I840_MCHCFG      0x50
21613  #define INTEL_I840_ERRSTS      0xc8
21614   
21615 -/* intel i845 registers */
21616 +/* Intel i845 registers */
21617  #define INTEL_I845_AGPM                0x51
21618  #define INTEL_I845_ERRSTS      0xc8
21619  
21620 -/* intel i850 registers */
21621 +/* Intel i850 registers */
21622  #define INTEL_I850_MCHCFG      0x50
21623  #define INTEL_I850_ERRSTS      0xc8
21624  
21625 -/* intel i860 registers */
21626 +/* Intel i860 registers */
21627  #define INTEL_I860_MCHCFG      0x50
21628  #define INTEL_I860_ERRSTS      0xc8
21629  
21630 -/* intel i810 registers */
21631 +/* Intel i810 registers */
21632  #define I810_GMADDR            0x10
21633  #define I810_MMADDR            0x14
21634  #define I810_PTE_BASE          0x10000
21635 @@ -261,7 +262,6 @@
21636  #define I810_DRAM_ROW_0_SDRAM  0x00000001
21637  
21638  /* Intel 7505 registers */
21639 -#define INTEL_I7505_NAPBASELO  0x10
21640  #define INTEL_I7505_APSIZE     0x74
21641  #define INTEL_I7505_NCAPID     0x60
21642  #define INTEL_I7505_NISTAT     0x6c
21643 @@ -271,26 +271,23 @@
21644  #define INTEL_I7505_MCHCFG     0x50
21645  
21646  /* VIA register */
21647 -#define VIA_APBASE     0x10
21648  #define VIA_GARTCTRL   0x80
21649  #define VIA_APSIZE     0x84
21650  #define VIA_ATTBASE    0x88
21651  
21652  /* VIA KT400 */
21653  #define VIA_AGP3_GARTCTRL      0x90
21654 -#define VIA_AGP3_APSIZE        0x94
21655 +#define VIA_AGP3_APSIZE                0x94
21656  #define VIA_AGP3_ATTBASE       0x98
21657 -#define VIA_AGPSEL     0xfd
21658 +#define VIA_AGPSEL             0xfd
21659  
21660  /* SiS registers */
21661 -#define SIS_APBASE     0x10
21662  #define SIS_ATTBASE    0x90
21663  #define SIS_APSIZE     0x94
21664  #define SIS_TLBCNTRL   0x97
21665  #define SIS_TLBFLUSH   0x98
21666  
21667  /* AMD registers */
21668 -#define AMD_APBASE     0x10
21669  #define AMD_MMBASE     0x14
21670  #define AMD_APSIZE     0xac
21671  #define AMD_MODECNTL   0xb0
21672 @@ -300,24 +297,14 @@
21673  #define AMD_TLBFLUSH   0x0c    /* In mmio region (32-bit register) */
21674  #define AMD_CACHEENTRY 0x10    /* In mmio region (32-bit register) */
21675  
21676 -#define AMD_8151_APSIZE        0xb4
21677 -#define AMD_8151_GARTBLOCK     0xb8
21678 -
21679 -#define AMD_X86_64_GARTAPERTURECTL     0x90
21680 -#define AMD_X86_64_GARTAPERTUREBASE    0x94
21681 -#define AMD_X86_64_GARTTABLEBASE       0x98
21682 -#define AMD_X86_64_GARTCACHECTL                0x9c
21683 -#define AMD_X86_64_GARTEN      1<<0
21684 -
21685 -#define AMD_8151_VMAPERTURE            0x10
21686 -#define AMD_8151_AGP_CTL               0xb0
21687 -#define AMD_8151_APERTURESIZE  0xb4
21688 -#define AMD_8151_GARTPTR               0xb8
21689 -#define AMD_8151_GTLBEN        1<<7
21690 -#define AMD_8151_APEREN        1<<8
21691 +/* AMD64 registers */
21692 +#define AMD64_GARTAPERTURECTL  0x90
21693 +#define AMD64_GARTAPERTUREBASE 0x94
21694 +#define AMD64_GARTTABLEBASE    0x98
21695 +#define AMD64_GARTCACHECTL             0x9c
21696 +#define AMD64_GARTEN           1<<0
21697  
21698  /* ALi registers */
21699 -#define ALI_APBASE                     0x10
21700  #define ALI_AGPCTRL                    0xb8
21701  #define ALI_ATTBASE                    0xbc
21702  #define ALI_TLBCTRL                    0xc0
21703 @@ -327,19 +314,17 @@
21704  #define ALI_CACHE_FLUSH_EN             0x100
21705  
21706  /* ATI register */
21707 -#define ATI_APBASE                  0x10
21708 -#define ATI_GART_MMBASE_ADDR        0x14
21709 -#define ATI_RS100_APSIZE            0xac
21710 -#define ATI_RS300_APSIZE            0xf8
21711 -#define ATI_RS100_IG_AGPMODE        0xb0
21712 -#define ATI_RS300_IG_AGPMODE        0xfc
21713 -
21714 -#define ATI_GART_FEATURE_ID         0x00
21715 -#define ATI_GART_BASE               0x04
21716 -#define ATI_GART_CACHE_SZBASE       0x08
21717 -#define ATI_GART_CACHE_CNTRL        0x0c
21718 -#define ATI_GART_CACHE_ENTRY_CNTRL  0x10
21719 -
21720 +#define ATI_GART_MMBASE_ADDR   0x14
21721 +#define ATI_RS100_APSIZE       0xac
21722 +#define ATI_RS300_APSIZE       0xf8
21723 +#define ATI_RS100_IG_AGPMODE   0xb0
21724 +#define ATI_RS300_IG_AGPMODE   0xfc
21725 +
21726 +#define ATI_GART_FEATURE_ID            0x00
21727 +#define ATI_GART_BASE                  0x04
21728 +#define ATI_GART_CACHE_SZBASE          0x08
21729 +#define ATI_GART_CACHE_CNTRL           0x0c
21730 +#define ATI_GART_CACHE_ENTRY_CNTRL     0x10
21731  
21732  /* Serverworks Registers */
21733  #define SVWRKS_APSIZE          0x10
21734 @@ -369,6 +354,17 @@
21735  #define HP_ZX1_PDIR_BASE       0x320
21736  #define HP_ZX1_CACHE_FLUSH     0x428
21737  
21738 +/* NVIDIA registers */
21739 +#define NVIDIA_0_APSIZE                0x80
21740 +#define NVIDIA_1_WBC           0xf0
21741 +#define NVIDIA_2_GARTCTRL      0xd0
21742 +#define NVIDIA_2_APBASE                0xd8
21743 +#define NVIDIA_2_APLIMIT       0xdc
21744 +#define NVIDIA_2_ATTBASE(i)    (0xe0 + (i) * 4)
21745 +#define NVIDIA_3_APBASE                0x50
21746 +#define NVIDIA_3_APLIMIT       0x54
21747 +
21748 +
21749  struct agp_device_ids {
21750         unsigned short device_id; /* first, to make table easier to read */
21751         enum chipset_type chipset;
21752 @@ -405,6 +401,9 @@
21753  void global_cache_flush(void);
21754  void get_agp_version(struct agp_bridge_data *bridge);
21755  unsigned long agp_generic_mask_memory(unsigned long addr, int type);
21756 +
21757 +extern int agp_off;
21758 +extern int agp_try_unsupported_boot;
21759  
21760  /* Standard agp registers */
21761  #define AGPSTAT                        0x4
21762 diff -Nru a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
21763 --- a/drivers/char/agp/ali-agp.c        Mon Aug 18 10:39:21 2003
21764 +++ b/drivers/char/agp/ali-agp.c        Thu Aug 28 16:44:18 2003
21765 @@ -76,7 +76,7 @@
21766         pci_write_config_dword(agp_bridge->dev, ALI_TLBCTRL, ((temp & 0xffffff00) | 0x00000010));
21767  
21768         /* address to map to */
21769 -       pci_read_config_dword(agp_bridge->dev, ALI_APBASE, &temp);
21770 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
21771         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
21772  
21773  #if 0
21774 diff -Nru a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
21775 --- a/drivers/char/agp/amd-k7-agp.c     Mon Aug 18 10:39:21 2003
21776 +++ b/drivers/char/agp/amd-k7-agp.c     Thu Aug 28 16:44:18 2003
21777 @@ -148,7 +148,7 @@
21778          * used to program the agp master not the cpu
21779          */
21780  
21781 -       pci_read_config_dword(agp_bridge->dev, AMD_APBASE, &temp);
21782 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
21783         addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
21784         agp_bridge->gart_bus_addr = addr;
21785  
21786 diff -Nru a/drivers/char/agp/amd-k8-agp.c b/drivers/char/agp/amd-k8-agp.c
21787 --- a/drivers/char/agp/amd-k8-agp.c     Thu Jul 31 08:58:45 2003
21788 +++ b/drivers/char/agp/amd-k8-agp.c     Thu Aug 28 18:04:31 2003
21789 @@ -8,12 +8,6 @@
21790   * work is done in the northbridge(s).
21791   */
21792  
21793 -/*
21794 - * On x86-64 the AGP driver needs to be initialized early by the IOMMU 
21795 - * code.  When you use this driver as a template for a new K8 AGP bridge
21796 - * driver don't forget to change arch/x86_64/kernel/pci-gart.c too -AK.
21797 - */
21798 -
21799  #include <linux/module.h>
21800  #include <linux/pci.h>
21801  #include <linux/init.h>
21802 @@ -21,7 +15,11 @@
21803  #include "agp.h"
21804  
21805  /* Will need to be increased if hammer ever goes >8-way. */
21806 +#ifdef CONFIG_SMP
21807  #define MAX_HAMMER_GARTS   8
21808 +#else
21809 +#define MAX_HAMMER_GARTS   1
21810 +#endif
21811  
21812  /* PTE bits. */
21813  #define GPTE_VALID     1
21814 @@ -39,6 +37,8 @@
21815  static int nr_garts;
21816  static struct pci_dev * hammers[MAX_HAMMER_GARTS];
21817  
21818 +static int __initdata agp_try_unsupported;
21819 +
21820  static int gart_iterator;
21821  #define for_each_nb() for(gart_iterator=0;gart_iterator<nr_garts;gart_iterator++)
21822  
21823 @@ -46,9 +46,9 @@
21824  {
21825         u32 tmp;
21826  
21827 -       pci_read_config_dword (dev, AMD_X86_64_GARTCACHECTL, &tmp);
21828 +       pci_read_config_dword (dev, AMD64_GARTCACHECTL, &tmp);
21829         tmp |= INVGART;
21830 -       pci_write_config_dword (dev, AMD_X86_64_GARTCACHECTL, tmp);
21831 +       pci_write_config_dword (dev, AMD64_GARTCACHECTL, tmp);
21832  }
21833  
21834  static void amd_x86_64_tlbflush(struct agp_memory *temp)
21835 @@ -135,7 +135,7 @@
21836         if (dev==NULL)
21837                 return 0;
21838  
21839 -       pci_read_config_dword(dev, AMD_X86_64_GARTAPERTURECTL, &temp);
21840 +       pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &temp);
21841         temp = (temp & 0xe);
21842         values = A_SIZE_32(x86_64_aperture_sizes);
21843  
21844 @@ -162,7 +162,7 @@
21845         u64 addr, aper_base;
21846  
21847         /* Address to map to */
21848 -       pci_read_config_dword (hammer, AMD_X86_64_GARTAPERTUREBASE, &tmp);
21849 +       pci_read_config_dword (hammer, AMD64_GARTAPERTUREBASE, &tmp);
21850         aperturebase = tmp << 25;
21851         aper_base = (aperturebase & PCI_BASE_ADDRESS_MEM_MASK);
21852  
21853 @@ -171,13 +171,13 @@
21854         addr >>= 12;
21855         tmp = (u32) addr<<4;
21856         tmp &= ~0xf;
21857 -       pci_write_config_dword (hammer, AMD_X86_64_GARTTABLEBASE, tmp);
21858 +       pci_write_config_dword (hammer, AMD64_GARTTABLEBASE, tmp);
21859  
21860         /* Enable GART translation for this hammer. */
21861 -       pci_read_config_dword(hammer, AMD_X86_64_GARTAPERTURECTL, &tmp);
21862 +       pci_read_config_dword(hammer, AMD64_GARTAPERTURECTL, &tmp);
21863         tmp |= GARTEN;
21864         tmp &= ~(DISGARTCPU | DISGARTIO);
21865 -       pci_write_config_dword(hammer, AMD_X86_64_GARTAPERTURECTL, tmp);
21866 +       pci_write_config_dword(hammer, AMD64_GARTAPERTURECTL, tmp);
21867  
21868         /* keep CPU's coherent. */
21869         flush_x86_64_tlb (hammer);
21870 @@ -216,9 +216,9 @@
21871  
21872         for_each_nb() {
21873                 /* disable gart translation */
21874 -               pci_read_config_dword (hammers[gart_iterator], AMD_X86_64_GARTAPERTURECTL, &tmp);
21875 -               tmp &= ~(AMD_X86_64_GARTEN);
21876 -               pci_write_config_dword (hammers[gart_iterator], AMD_X86_64_GARTAPERTURECTL, tmp);
21877 +               pci_read_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, &tmp);
21878 +               tmp &= ~AMD64_GARTEN;
21879 +               pci_write_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, tmp);
21880         }
21881  }
21882  
21883 @@ -246,24 +246,123 @@
21884         .agp_destroy_page       = agp_generic_destroy_page,
21885  };
21886  
21887 +/* Some basic sanity checks for the aperture. */
21888 +static int __init aperture_valid(u64 aper, u32 size)
21889 +{ 
21890 +       static int not_first_call; 
21891 +       u32 pfn, c;
21892 +       if (aper == 0) { 
21893 +               printk(KERN_ERR "No aperture\n");
21894 +               return 0; 
21895 +       }
21896 +       if (size < 32*1024*1024) {
21897 +               printk(KERN_ERR "Aperture too small (%d MB)\n", size>>20);
21898 +               return 0;
21899 +       }
21900 +       if (aper + size > 0xffffffff) { 
21901 +               printk(KERN_ERR "Aperture out of bounds\n"); 
21902 +               return 0;
21903 +       } 
21904 +       pfn = aper >> PAGE_SHIFT;
21905 +       for (c = 0; c < size/PAGE_SIZE; c++) { 
21906 +               if (!pfn_valid(pfn + c))
21907 +                       break;
21908 +               if (!PageReserved(pfn_to_page(pfn + c))) { 
21909 +                       printk(KERN_ERR "Aperture pointing to RAM\n");
21910 +                       return 0;
21911 +               }
21912 +       }
21913  
21914 -#ifdef CONFIG_SMP
21915 -static int cache_nbs (void)
21916 +       /* Request the Aperture. This catches cases when someone else
21917 +          already put a mapping in there - happens with some very broken BIOS 
21918 +
21919 +          Maybe better to use pci_assign_resource/pci_enable_device instead trusting
21920 +          the bridges? */
21921 +       if (!not_first_call && request_mem_region(aper, size, "aperture") < 0) { 
21922 +               printk(KERN_ERR "Aperture conflicts with PCI mapping.\n"); 
21923 +               return 0;
21924 +       }
21925 +
21926 +       not_first_call = 1;
21927 +       return 1;
21928 +} 
21929 +
21930 +/* 
21931 + * W*s centric BIOS sometimes only set up the aperture in the AGP
21932 + * bridge, not the northbridge. On AMD64 this is handled early 
21933 + * in aperture.c, but when GART_IOMMU is not enabled or we run
21934 + * on a 32bit kernel this needs to be redone. 
21935 + * Unfortunately it is impossible to fix the aperture here because it's too late
21936 + * to allocate that much memory. But at least error out cleanly instead of
21937 + * crashing.
21938 + */ 
21939 +static __init int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, 
21940 +                                                                u16 cap)
21941 +{
21942 +       u32 aper_low, aper_hi;
21943 +       u64 aper, nb_aper;
21944 +       int order = 0;
21945 +       u32 nb_order, nb_base;
21946 +       u16 apsize;
21947 +
21948 +       pci_read_config_dword(nb, 0x90, &nb_order); 
21949 +       nb_order = (nb_order >> 1) & 7;
21950 +       pci_read_config_dword(nb, 0x94, &nb_base); 
21951 +       nb_aper = nb_base << 25;        
21952 +       if (aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) { 
21953 +               return 0;
21954 +       }
21955 +
21956 +       /* Northbridge seems to contain crap. Try the AGP bridge. */
21957 +
21958 +       pci_read_config_word(agp, cap+0x14, &apsize); 
21959 +       if (apsize == 0xffff) 
21960 +               return -1; 
21961 +
21962 +       apsize &= 0xfff;
21963 +       /* Some BIOS use weird encodings not in the AGPv3 table. */
21964 +       if (apsize & 0xff) 
21965 +               apsize |= 0xf00; 
21966 +       order = 7 - hweight16(apsize); 
21967 +
21968 +       pci_read_config_dword(agp, 0x10, &aper_low);
21969 +       pci_read_config_dword(agp, 0x14, &aper_hi);
21970 +       aper = (aper_low & ~((1<<22)-1)) | ((u64)aper_hi << 32); 
21971 +       printk(KERN_INFO "Aperture from AGP @ %Lx size %u MB\n", aper, 32 << order);
21972 +       if (order < 0 || !aperture_valid(aper, (32*1024*1024)<<order))
21973 +               return -1; 
21974 +       
21975 +       pci_write_config_dword(nb, 0x90, order << 1); 
21976 +       pci_write_config_dword(nb, 0x94, aper >> 25); 
21977 +
21978 +       return 0;
21979 +} 
21980 +
21981 +static __init int cache_nbs (struct pci_dev *pdev, u32 cap_ptr)
21982  {
21983         struct pci_dev *loop_dev = NULL;
21984         int i = 0;
21985  
21986         /* cache pci_devs of northbridges. */
21987 -       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) != NULL) {
21988 +       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) 
21989 +                       != NULL) {
21990 +               if (fix_northbridge(loop_dev, pdev, cap_ptr) < 0) { 
21991 +                       printk("No usable aperture found.\n");
21992 +#ifdef __x86_64__ 
21993 +                       /* should port this to i386 */
21994 +                       printk("Consider rebooting with iommu=memaper=2 to get a good aperture.\n");
21995 +#endif 
21996 +                       return -1;  
21997 +               }
21998                 hammers[i++] = loop_dev;
21999                 nr_garts = i;
22000 -               if (i == MAX_HAMMER_GARTS)
22001 +               if (i == MAX_HAMMER_GARTS) { 
22002 +                       printk(KERN_INFO "Too many northbridges for AGP\n");
22003                         return -1;
22004 +               }
22005         }
22006 -       return 0;
22007 +       return i == 0 ? -1 : 0;
22008  }
22009 -#endif
22010 -
22011  
22012  static int __init agp_amdk8_probe(struct pci_dev *pdev,
22013                                   const struct pci_device_id *ent)
22014 @@ -277,7 +376,7 @@
22015         if (!cap_ptr)
22016                 return -ENODEV;
22017  
22018 -       printk(KERN_INFO PFX "Detected Opteron/Athlon64 on-CPU GART\n");
22019 +       /* Could check for AGPv3 here */
22020  
22021         bridge = agp_alloc_bridge();
22022         if (!bridge)
22023 @@ -311,6 +410,9 @@
22024                         bridge->major_version = 3;
22025                         bridge->minor_version = 0;
22026                 }
22027 +       } else {
22028 +               printk(KERN_INFO PFX "Detected AGP bridge %x\n",
22029 +                       pdev->devfn);
22030         }
22031  
22032         bridge->driver = &amd_8151_driver;
22033 @@ -320,22 +422,10 @@
22034         /* Fill in the mode register */
22035         pci_read_config_dword(pdev, bridge->capndx+PCI_AGP_STATUS, &bridge->mode);
22036  
22037 -#ifdef CONFIG_SMP
22038 -       if (cache_nbs() == -1) {
22039 +       if (cache_nbs(pdev, cap_ptr) == -1) {
22040                 agp_put_bridge(bridge);
22041 -               return -ENOMEM;
22042 -       }
22043 -#else
22044 -       {
22045 -       struct pci_dev *loop_dev = NULL;
22046 -       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) != NULL) {
22047 -               /* For UP, we only care about the first GART. */
22048 -               hammers[0] = loop_dev;
22049 -               nr_garts = 1;
22050 -               break;
22051 -       }
22052 +               return -ENODEV;
22053         }
22054 -#endif
22055  
22056         pci_set_drvdata(pdev, bridge);
22057         return agp_add_bridge(bridge);
22058 @@ -345,6 +435,8 @@
22059  {
22060         struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
22061  
22062 +       release_mem_region(virt_to_phys(bridge->gatt_table_real), 
22063 +                          x86_64_aperture_sizes[bridge->aperture_size_idx].size); 
22064         agp_remove_bridge(bridge);
22065         agp_put_bridge(bridge);
22066  }
22067 @@ -358,11 +450,21 @@
22068         .subvendor      = PCI_ANY_ID,
22069         .subdevice      = PCI_ANY_ID,
22070         },
22071 +       /* VIA K8T800 */
22072         {
22073         .class          = (PCI_CLASS_BRIDGE_HOST << 8),
22074         .class_mask     = ~0,
22075         .vendor         = PCI_VENDOR_ID_VIA,
22076 -       .device         = PCI_DEVICE_ID_VIA_K8T400M_0,
22077 +       .device         = PCI_DEVICE_ID_VIA_8385_0,
22078 +       .subvendor      = PCI_ANY_ID,
22079 +       .subdevice      = PCI_ANY_ID,
22080 +       },
22081 +       /* VIA K8M800 / K8N800 */
22082 +       {
22083 +       .class          = (PCI_CLASS_BRIDGE_HOST << 8),
22084 +       .class_mask     = ~0,
22085 +       .vendor         = PCI_VENDOR_ID_VIA,
22086 +       .device         = PCI_DEVICE_ID_VIA_8380_0,
22087         .subvendor      = PCI_ANY_ID,
22088         .subdevice      = PCI_ANY_ID,
22089         },
22090 @@ -386,10 +488,43 @@
22091         .remove         = agp_amdk8_remove,
22092  };
22093  
22094 +
22095  /* Not static due to IOMMU code calling it early. */
22096  int __init agp_amdk8_init(void)
22097  {
22098 -       return pci_module_init(&agp_amdk8_pci_driver);
22099 +       int err = 0;
22100 +       if (agp_off)
22101 +               return -EINVAL;
22102 +       if (pci_module_init(&agp_amdk8_pci_driver) == 0) { 
22103 +               struct pci_dev *dev;
22104 +               if (!agp_try_unsupported && !agp_try_unsupported_boot) { 
22105 +                       printk(KERN_INFO "No supported AGP bridge found.\n");
22106 +#ifdef MODULE                  
22107 +                       printk(KERN_INFO "You can try agp_try_unsupported=1\n");
22108 +#else
22109 +                       printk(KERN_INFO "You can boot with agp=try_unsupported\n");
22110 +#endif                 
22111 +                       return -ENODEV;
22112 +               }
22113 +
22114 +               /* First check that we have at least one K8 NB */
22115 +               if (!pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, NULL))
22116 +                       return -ENODEV;
22117 +
22118 +               /* Look for any AGP bridge */
22119 +               dev = NULL;
22120 +               err = -ENODEV;
22121 +               while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev))) {
22122 +                       if (!pci_find_capability(dev, PCI_CAP_ID_AGP))
22123 +                               continue;
22124 +                       /* Only one bridge supported right now */       
22125 +                       if (agp_amdk8_probe(dev, NULL) == 0) {
22126 +                               err = 0;
22127 +                               break;
22128 +                       }       
22129 +               }               
22130 +       }
22131 +       return err;
22132  }
22133  
22134  static void __exit agp_amdk8_cleanup(void)
22135 @@ -404,6 +539,6 @@
22136  module_exit(agp_amdk8_cleanup);
22137  #endif
22138  
22139 -MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
22140 +MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>, Andi Kleen");
22141 +MODULE_PARM(agp_try_unsupported, "1i");
22142  MODULE_LICENSE("GPL and additional rights");
22143 -
22144 diff -Nru a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
22145 --- a/drivers/char/agp/ati-agp.c        Mon Aug 18 10:39:21 2003
22146 +++ b/drivers/char/agp/ati-agp.c        Thu Aug 28 16:44:18 2003
22147 @@ -1,5 +1,5 @@
22148  /*
22149 - * ALi AGPGART routines.
22150 + * ATi AGPGART routines.
22151   */
22152  
22153  #include <linux/types.h>
22154 @@ -212,7 +212,7 @@
22155  
22156         /* address to map too */
22157          /*
22158 -       pci_read_config_dword(agp_bridge.dev, ATI_APBASE, &temp);
22159 +       pci_read_config_dword(agp_bridge.dev, AGP_APBASE, &temp);
22160         agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22161         printk(KERN_INFO "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr);
22162          */
22163 @@ -355,7 +355,7 @@
22164          * This is a bus address even on the alpha, b/c its
22165          * used to program the agp master not the cpu
22166          */
22167 -       pci_read_config_dword(agp_bridge->dev, ATI_APBASE, &temp);
22168 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22169         addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22170         agp_bridge->gart_bus_addr = addr;
22171  
22172 diff -Nru a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
22173 --- a/drivers/char/agp/backend.c        Wed Aug 13 10:20:16 2003
22174 +++ b/drivers/char/agp/backend.c        Wed Sep  3 23:40:14 2003
22175 @@ -301,9 +301,14 @@
22176  }
22177  EXPORT_SYMBOL_GPL(agp_remove_bridge);
22178  
22179 +int agp_off;
22180 +int agp_try_unsupported_boot;
22181 +EXPORT_SYMBOL(agp_off);
22182 +EXPORT_SYMBOL(agp_try_unsupported_boot);
22183  
22184  static int __init agp_init(void)
22185  {
22186 +       if (!agp_off) 
22187         printk(KERN_INFO "Linux agpgart interface v%d.%d (c) Dave Jones\n",
22188                AGPGART_VERSION_MAJOR, AGPGART_VERSION_MINOR);
22189         return 0;
22190 @@ -313,10 +318,20 @@
22191  {
22192  }
22193  
22194 +static __init int agp_setup(char *s)
22195 +{
22196 +       if (!strcmp(s,"off"))
22197 +               agp_off = 1;
22198 +       if (!strcmp(s,"try_unsupported"))
22199 +               agp_try_unsupported_boot = 1;
22200 +       return 1;       
22201 +}
22202 +__setup("agp=", agp_setup);
22203  
22204  MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
22205  MODULE_DESCRIPTION("AGP GART driver");
22206  MODULE_LICENSE("GPL and additional rights");
22207 +MODULE_ALIAS_MISCDEV(AGPGART_MINOR);
22208  
22209  module_init(agp_init);
22210  module_exit(agp_exit);
22211 diff -Nru a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
22212 --- a/drivers/char/agp/frontend.c       Sun Jul 13 05:36:05 2003
22213 +++ b/drivers/char/agp/frontend.c       Wed Sep  3 23:40:14 2003
22214 @@ -698,7 +698,7 @@
22215  
22216  static int agp_open(struct inode *inode, struct file *file)
22217  {
22218 -       int minor = minor(inode->i_rdev);
22219 +       int minor = iminor(inode);
22220         struct agp_file_private *priv;
22221         struct agp_client *client;
22222         int rc = -ENXIO;
22223 @@ -1097,4 +1097,3 @@
22224  {
22225         misc_deregister(&agp_miscdev);
22226  }
22227 -
22228 diff -Nru a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
22229 --- a/drivers/char/agp/generic.c        Wed Aug 13 01:35:50 2003
22230 +++ b/drivers/char/agp/generic.c        Wed Aug 27 11:06:10 2003
22231 @@ -577,12 +577,12 @@
22232                         agp_device_command(command, TRUE);
22233                         return;
22234                 } else {
22235 -                   /* Disable calibration cycle in RX91<1> when not in AGP3.0 mode of operation.*/            
22236 +                   /* Disable calibration cycle in RX91<1> when not in AGP3.0 mode of operation.*/
22237                     command &= ~(7<<10) ;
22238                     pci_read_config_dword(agp_bridge->dev, agp_bridge->capndx+AGPCTRL, &temp);
22239                     temp |= (1<<9);
22240                     pci_write_config_dword(agp_bridge->dev, agp_bridge->capndx+AGPCTRL, temp);
22241 -                   
22242 +
22243                     printk (KERN_INFO PFX "Device is in legacy mode,"
22244                                 " falling back to 2.x\n");
22245                 }
22246 diff -Nru a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
22247 --- a/drivers/char/agp/intel-agp.c      Fri Aug 15 07:25:05 2003
22248 +++ b/drivers/char/agp/intel-agp.c      Thu Aug 28 16:44:18 2003
22249 @@ -618,7 +618,7 @@
22250         pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
22251  
22252         /* address to map to */
22253 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22254 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22255         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22256  
22257         /* attbase - aperture base */
22258 @@ -657,7 +657,7 @@
22259                         current_size->size_value); 
22260  
22261         /* address to map to */
22262 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22263 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22264         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22265  
22266         pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr);
22267 @@ -708,7 +708,7 @@
22268         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
22269  
22270         /* address to map to */
22271 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22272 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22273         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22274  
22275         /* attbase - aperture base */
22276 @@ -739,7 +739,7 @@
22277         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
22278  
22279         /* address to map to */
22280 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22281 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22282         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22283  
22284         /* attbase - aperture base */
22285 @@ -768,7 +768,7 @@
22286         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
22287  
22288         /* address to map to */
22289 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22290 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22291         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22292  
22293         /* attbase - aperture base */
22294 @@ -797,7 +797,7 @@
22295         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
22296  
22297         /* address to map to */
22298 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22299 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22300         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22301  
22302         /* attbase - aperture base */
22303 @@ -826,7 +826,7 @@
22304         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
22305  
22306         /* address to map to */
22307 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22308 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22309         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22310  
22311         /* attbase - aperture base */
22312 @@ -855,7 +855,7 @@
22313         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
22314  
22315         /* address to map to */
22316 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22317 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22318         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22319  
22320         /* attbase - aperture base */
22321 @@ -884,7 +884,7 @@
22322         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
22323  
22324         /* address to map to */
22325 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
22326 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22327         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22328  
22329         /* attbase - aperture base */
22330 diff -Nru a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
22331 --- a/drivers/char/agp/nvidia-agp.c     Fri Aug 15 07:22:22 2003
22332 +++ b/drivers/char/agp/nvidia-agp.c     Thu Aug 28 16:56:50 2003
22333 @@ -13,18 +13,6 @@
22334  #include <linux/mm.h>
22335  #include "agp.h"
22336  
22337 -
22338 -/* registers */
22339 -#define NVIDIA_0_APBASE                0x10
22340 -#define NVIDIA_0_APSIZE                0x80
22341 -#define NVIDIA_1_WBC           0xf0
22342 -#define NVIDIA_2_GARTCTRL      0xd0
22343 -#define NVIDIA_2_APBASE                0xd8
22344 -#define NVIDIA_2_APLIMIT       0xdc
22345 -#define NVIDIA_2_ATTBASE(i)    (0xe0 + (i) * 4)
22346 -#define NVIDIA_3_APBASE                0x50
22347 -#define NVIDIA_3_APLIMIT       0x54
22348 -
22349  static struct _nvidia_private {
22350         struct pci_dev *dev_1;
22351         struct pci_dev *dev_2;
22352 @@ -73,7 +61,7 @@
22353                 current_size->size_value);
22354  
22355      /* address to map to */
22356 -       pci_read_config_dword(agp_bridge->dev, NVIDIA_0_APBASE, &apbase);
22357 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &apbase);
22358         apbase &= PCI_BASE_ADDRESS_MEM_MASK;
22359         agp_bridge->gart_bus_addr = apbase;
22360         aplimit = apbase + (current_size->size * 1024 * 1024) - 1;
22361 diff -Nru a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
22362 --- a/drivers/char/agp/sis-agp.c        Mon Aug 18 10:39:21 2003
22363 +++ b/drivers/char/agp/sis-agp.c        Thu Aug 28 16:44:18 2003
22364 @@ -43,7 +43,7 @@
22365  
22366         current_size = A_SIZE_8(agp_bridge->current_size);
22367         pci_write_config_byte(agp_bridge->dev, SIS_TLBCNTRL, 0x05);
22368 -       pci_read_config_dword(agp_bridge->dev, SIS_APBASE, &temp);
22369 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22370         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22371         pci_write_config_dword(agp_bridge->dev, SIS_ATTBASE,
22372                                agp_bridge->gatt_bus_addr);
22373 diff -Nru a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
22374 --- a/drivers/char/agp/via-agp.c        Wed Aug 13 01:41:04 2003
22375 +++ b/drivers/char/agp/via-agp.c        Thu Aug 28 17:14:45 2003
22376 @@ -39,7 +39,7 @@
22377         pci_write_config_byte(agp_bridge->dev, VIA_APSIZE,
22378                               current_size->size_value);
22379         /* address to map too */
22380 -       pci_read_config_dword(agp_bridge->dev, VIA_APBASE, &temp);
22381 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22382         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22383  
22384         /* GART control register */
22385 @@ -114,7 +114,7 @@
22386         current_size = A_SIZE_16(agp_bridge->current_size);
22387  
22388         /* address to map too */
22389 -       pci_read_config_dword(agp_bridge->dev, VIA_APBASE, &temp);
22390 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
22391         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
22392  
22393         /* attbase - aperture GATT base */
22394 @@ -215,52 +215,52 @@
22395  {
22396         {
22397                 .device_id      = PCI_DEVICE_ID_VIA_82C597_0,
22398 -               .chipset_name   = "VP3",
22399 +               .chipset_name   = "Apollo VP3",
22400         },
22401  
22402         {
22403                 .device_id      = PCI_DEVICE_ID_VIA_82C598_0,
22404 -               .chipset_name   = "MVP3",
22405 +               .chipset_name   = "Apollo MVP3",
22406         },
22407  
22408         {
22409                 .device_id      = PCI_DEVICE_ID_VIA_8501_0,
22410 -               .chipset_name   = "MVP4",
22411 +               .chipset_name   = "Apollo MVP4",
22412         },
22413  
22414         /* VT8601 */
22415         {
22416                 .device_id      = PCI_DEVICE_ID_VIA_8601_0,
22417 -               .chipset_name   = "PLE133 ProMedia",
22418 +               .chipset_name   = "Apollo ProMedia/PLE133Ta",
22419         },
22420  
22421         /* VT82C693A / VT28C694T */
22422         {
22423 -               .device_id      = PCI_DEVICE_ID_VIA_82C691,
22424 +               .device_id      = PCI_DEVICE_ID_VIA_82C691_0,
22425                 .chipset_name   = "Apollo Pro 133",
22426         },
22427  
22428         {
22429                 .device_id      = PCI_DEVICE_ID_VIA_8371_0,
22430 -               .chipset_name   = "Apollo Pro KX133",
22431 +               .chipset_name   = "KX133",
22432         },
22433  
22434         /* VT8633 */
22435         {
22436                 .device_id      = PCI_DEVICE_ID_VIA_8633_0,
22437 -               .chipset_name   = "Apollo Pro 266",
22438 +               .chipset_name   = "Pro 266",
22439         },
22440  
22441         /* VT8361 */
22442         {
22443                 .device_id      = PCI_DEVICE_ID_VIA_8361,
22444 -               .chipset_name   = "Apollo KLE133",
22445 +               .chipset_name   = "KLE133",
22446         },
22447  
22448         /* VT8365 / VT8362 */
22449         {
22450                 .device_id      = PCI_DEVICE_ID_VIA_8363_0,
22451 -               .chipset_name   = "Apollo Pro KT133/KM133/TwisterK",
22452 +               .chipset_name   = "Twister-K/KT133x/KM133",
22453         },
22454  
22455         /* VT8753A */
22456 @@ -272,79 +272,79 @@
22457         /* VT8366 */
22458         {
22459                 .device_id      = PCI_DEVICE_ID_VIA_8367_0,
22460 -               .chipset_name   = "Apollo Pro KT266/KT333",
22461 +               .chipset_name   = "KT266/KY266x/KT333",
22462         },
22463  
22464         /* VT8633 (for CuMine/ Celeron) */
22465         {
22466                 .device_id      = PCI_DEVICE_ID_VIA_8653_0,
22467 -               .chipset_name   = "Apollo Pro 266T",
22468 +               .chipset_name   = "Pro266T",
22469         },
22470  
22471         /* KM266 / PM266 */
22472         {
22473 -               .device_id      = PCI_DEVICE_ID_VIA_KM266,
22474 -               .chipset_name   = "KM266/PM266",
22475 +               .device_id      = PCI_DEVICE_ID_VIA_XM266,
22476 +               .chipset_name   = "PM266/KM266",
22477         },
22478  
22479         /* CLE266 */
22480         {
22481 -               .device_id      = PCI_DEVICE_ID_VIA_CLE266,
22482 +               .device_id      = PCI_DEVICE_ID_VIA_862X_0,
22483                 .chipset_name   = "CLE266",
22484         },
22485  
22486         {
22487                 .device_id      = PCI_DEVICE_ID_VIA_8377_0,
22488 -               .chipset_name   = "Apollo Pro KT400",
22489 +               .chipset_name   = "KT400/KT400A/KT600",
22490         },
22491  
22492 -       /* VT8604 / VT8605 / VT8603 / TwisterT
22493 +       /* VT8604 / VT8605 / VT8603
22494          * (Apollo Pro133A chipset with S3 Savage4) */
22495         {
22496 -               .device_id      = PCI_DEVICE_ID_VIA_82C694X_0,
22497 -               .chipset_name   = "Apollo ProSavage PM133/PL133/PN133/Twister"
22498 +               .device_id      = PCI_DEVICE_ID_VIA_8605_0,
22499 +               .chipset_name   = "ProSavage PM133/PL133/PN133"
22500         },
22501  
22502 -       /* VT8752*/
22503 +       /* P4M266x/P4N266 */
22504         {
22505 -               .device_id      = PCI_DEVICE_ID_VIA_8752,
22506 -               .chipset_name   = "ProSavage DDR P4M266",
22507 +               .device_id      = PCI_DEVICE_ID_VIA_8703_51_0,
22508 +               .chipset_name   = "P4M266x/P4N266",
22509         },
22510  
22511 -       /* KN266/PN266 */
22512 +       /* VT8754 */
22513         {
22514 -               .device_id      = PCI_DEVICE_ID_VIA_KN266,
22515 -               .chipset_name   = "KN266/PN266",
22516 +               .device_id      = PCI_DEVICE_ID_VIA_8754C_0,
22517 +               .chipset_name   = "PT800",
22518         },
22519  
22520 -       /* VT8754 */
22521 +       /* P4X600 */
22522         {
22523 -               .device_id      = PCI_DEVICE_ID_VIA_8754,
22524 -               .chipset_name   = "Apollo P4X333/P4X400"
22525 +               .device_id      = PCI_DEVICE_ID_VIA_8763_0,
22526 +               .chipset_name   = "P4X600"
22527         },
22528  
22529 -       /* P4N333 */
22530 +       /* KM400 */
22531         {
22532 -               .device_id      = PCI_DEVICE_ID_VIA_P4N333,
22533 -               .chipset_name   = "P4N333",
22534 +               .device_id      = PCI_DEVICE_ID_VIA_8378_0,
22535 +               .chipset_name   = "KM400/KM400A",
22536         },
22537  
22538 -       /* P4X600 */
22539 +       /* PT880 */
22540         {
22541 -               .device_id      = PCI_DEVICE_ID_VIA_P4X600,
22542 -               .chipset_name   = "P4X600",
22543 +               .device_id      = PCI_DEVICE_ID_VIA_PT880,
22544 +               .chipset_name   = "PT880",
22545         },
22546  
22547 -       /* KM400 */
22548 +       /* PT890 */
22549         {
22550 -               .device_id      = PCI_DEVICE_ID_VIA_KM400,
22551 -               .chipset_name   = "KM400",
22552 +               .device_id      = PCI_DEVICE_ID_VIA_8783_0,
22553 +               .chipset_name   = "PT890",
22554         },
22555  
22556 -       /* P4M400 */
22557 +       /* PM800/PN800/PM880/PN880 */
22558         {
22559 -               .device_id      = PCI_DEVICE_ID_VIA_P4M400,
22560 -               .chipset_name   = "P4M400",
22561 +               .device_id      = PCI_DEVICE_ID_VIA_PX8X0_0,
22562 +               .chipset_name   = "PM800/PN800/PM880/PN880",
22563         },
22564  
22565         { }, /* dummy final entry, always present */
22566 diff -Nru a/drivers/char/busmouse.c b/drivers/char/busmouse.c
22567 --- a/drivers/char/busmouse.c   Fri Jul 11 23:17:17 2003
22568 +++ b/drivers/char/busmouse.c   Wed Sep  3 23:40:14 2003
22569 @@ -51,7 +51,7 @@
22570  
22571  #define NR_MICE                        15
22572  #define FIRST_MOUSE            0
22573 -#define DEV_TO_MOUSE(dev)      MINOR_TO_MOUSE(minor(dev))
22574 +#define DEV_TO_MOUSE(inode)    MINOR_TO_MOUSE(iminor(inode))
22575  #define MINOR_TO_MOUSE(minor)  ((minor) - FIRST_MOUSE)
22576  
22577  /*
22578 @@ -190,7 +190,7 @@
22579         unsigned int mousedev;
22580         int ret;
22581  
22582 -       mousedev = DEV_TO_MOUSE(inode->i_rdev);
22583 +       mousedev = DEV_TO_MOUSE(inode);
22584         if (mousedev >= NR_MICE)
22585                 return -EINVAL;
22586  
22587 @@ -452,4 +452,5 @@
22588  EXPORT_SYMBOL(register_busmouse);
22589  EXPORT_SYMBOL(unregister_busmouse);
22590  
22591 +MODULE_ALIAS_MISCDEV(BUSMOUSE_MINOR);
22592  MODULE_LICENSE("GPL");
22593 diff -Nru a/drivers/char/cyclades.c b/drivers/char/cyclades.c
22594 --- a/drivers/char/cyclades.c   Fri Aug  1 02:20:44 2003
22595 +++ b/drivers/char/cyclades.c   Sun Aug 31 16:14:39 2003
22596 @@ -1050,14 +1050,14 @@
22597      udelay(5000L);
22598  
22599      /* Enable the Tx interrupts on the CD1400 */
22600 -    save_flags(flags); cli();
22601 +    local_irq_save(flags);
22602         cy_writeb((u_long)address + (CyCAR<<index), 0);
22603         cyy_issue_cmd(address, CyCHAN_CTL|CyENB_XMTR, index);
22604  
22605         cy_writeb((u_long)address + (CyCAR<<index), 0);
22606         cy_writeb((u_long)address + (CySRER<<index), 
22607                 cy_readb(address + (CySRER<<index)) | CyTxRdy);
22608 -    restore_flags(flags);
22609 +    local_irq_restore(flags);
22610  
22611      /* Wait ... */
22612      udelay(5000L);
22613 @@ -5665,7 +5665,7 @@
22614  cy_cleanup_module(void)
22615  {
22616      int i;
22617 -    int e1;
22618 +    int e1, e2;
22619      unsigned long flags;
22620  
22621  #ifndef CONFIG_CYZ_INTR
22622 @@ -5675,13 +5675,10 @@
22623      }
22624  #endif /* CONFIG_CYZ_INTR */
22625  
22626 -    save_flags(flags); cli();
22627 -
22628      if ((e1 = tty_unregister_driver(cy_serial_driver)))
22629              printk("cyc: failed to unregister Cyclades serial driver(%d)\n",
22630                 e1);
22631  
22632 -    restore_flags(flags);
22633      put_tty_driver(cy_serial_driver);
22634  
22635      for (i = 0; i < NR_CARDS; i++) {
22636 diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
22637 --- a/drivers/char/drm/drm_drv.h        Thu Aug  7 15:37:26 2003
22638 +++ b/drivers/char/drm/drm_drv.h        Tue Aug 26 09:25:41 2003
22639 @@ -795,7 +795,7 @@
22640         int i;
22641  
22642         for (i = 0; i < DRM(numdevs); i++) {
22643 -               if (minor(inode->i_rdev) == DRM(minor)[i]) {
22644 +               if (iminor(inode) == DRM(minor)[i]) {
22645                         dev = &(DRM(device)[i]);
22646                         break;
22647                 }
22648 diff -Nru a/drivers/char/drm/drm_fops.h b/drivers/char/drm/drm_fops.h
22649 --- a/drivers/char/drm/drm_fops.h       Thu Jul 10 23:18:01 2003
22650 +++ b/drivers/char/drm/drm_fops.h       Tue Aug 26 09:25:41 2003
22651 @@ -51,7 +51,7 @@
22652   */
22653  int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
22654  {
22655 -       int          minor = minor(inode->i_rdev);
22656 +       int          minor = iminor(inode);
22657         drm_file_t   *priv;
22658  
22659         if (filp->f_flags & O_EXCL)   return -EBUSY; /* No exclusive opens */
22660 diff -Nru a/drivers/char/drm/drm_stub.h b/drivers/char/drm/drm_stub.h
22661 --- a/drivers/char/drm/drm_stub.h       Thu Jul 10 23:18:01 2003
22662 +++ b/drivers/char/drm/drm_stub.h       Tue Aug 26 09:25:41 2003
22663 @@ -62,7 +62,7 @@
22664   */
22665  static int DRM(stub_open)(struct inode *inode, struct file *filp)
22666  {
22667 -       int                    minor = minor(inode->i_rdev);
22668 +       int                    minor = iminor(inode);
22669         int                    err   = -ENODEV;
22670         struct file_operations *old_fops;
22671  
22672 diff -Nru a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
22673 --- a/drivers/char/dsp56k.c     Wed May  7 08:47:29 2003
22674 +++ b/drivers/char/dsp56k.c     Tue Aug 26 09:25:41 2003
22675 @@ -207,7 +207,7 @@
22676                            loff_t *ppos)
22677  {
22678         struct inode *inode = file->f_dentry->d_inode;
22679 -       int dev = minor(inode->i_rdev) & 0x0f;
22680 +       int dev = iminor(inode) & 0x0f;
22681  
22682         switch(dev)
22683         {
22684 @@ -270,7 +270,7 @@
22685                             loff_t *ppos)
22686  {
22687         struct inode *inode = file->f_dentry->d_inode;
22688 -       int dev = minor(inode->i_rdev) & 0x0f;
22689 +       int dev = iminor(inode) & 0x0f;
22690  
22691         switch(dev)
22692         {
22693 @@ -331,7 +331,7 @@
22694  static int dsp56k_ioctl(struct inode *inode, struct file *file,
22695                         unsigned int cmd, unsigned long arg)
22696  {
22697 -       int dev = minor(inode->i_rdev) & 0x0f;
22698 +       int dev = iminor(inode) & 0x0f;
22699  
22700         switch(dev)
22701         {
22702 @@ -424,7 +424,7 @@
22703  #if 0
22704  static unsigned int dsp56k_poll(struct file *file, poll_table *wait)
22705  {
22706 -       int dev = minor(file->f_dentry->d_inode->i_rdev) & 0x0f;
22707 +       int dev = iminor(file->f_dentry->d_inode) & 0x0f;
22708  
22709         switch(dev)
22710         {
22711 @@ -441,7 +441,7 @@
22712  
22713  static int dsp56k_open(struct inode *inode, struct file *file)
22714  {
22715 -       int dev = minor(inode->i_rdev) & 0x0f;
22716 +       int dev = iminor(inode) & 0x0f;
22717  
22718         switch(dev)
22719         {
22720 @@ -472,7 +472,7 @@
22721  
22722  static int dsp56k_release(struct inode *inode, struct file *file)
22723  {
22724 -       int dev = minor(inode->i_rdev) & 0x0f;
22725 +       int dev = iminor(inode) & 0x0f;
22726  
22727         switch(dev)
22728         {
22729 diff -Nru a/drivers/char/dtlk.c b/drivers/char/dtlk.c
22730 --- a/drivers/char/dtlk.c       Fri Jul 11 06:34:28 2003
22731 +++ b/drivers/char/dtlk.c       Tue Aug 26 09:25:41 2003
22732 @@ -125,7 +125,7 @@
22733  static ssize_t dtlk_read(struct file *file, char *buf,
22734                          size_t count, loff_t * ppos)
22735  {
22736 -       unsigned int minor = minor(file->f_dentry->d_inode->i_rdev);
22737 +       unsigned int minor = iminor(file->f_dentry->d_inode);
22738         char ch;
22739         int i = 0, retries;
22740  
22741 @@ -185,7 +185,7 @@
22742         if (ppos != &file->f_pos)
22743                 return -ESPIPE;
22744  
22745 -       if (minor(file->f_dentry->d_inode->i_rdev) != DTLK_MINOR)
22746 +       if (iminor(file->f_dentry->d_inode) != DTLK_MINOR)
22747                 return -EINVAL;
22748  
22749         while (1) {
22750 @@ -304,7 +304,7 @@
22751  {
22752         TRACE_TEXT("(dtlk_open");
22753  
22754 -       switch (minor(inode->i_rdev)) {
22755 +       switch (iminor(inode)) {
22756         case DTLK_MINOR:
22757                 if (dtlk_busy)
22758                         return -EBUSY;
22759 @@ -319,7 +319,7 @@
22760  {
22761         TRACE_TEXT("(dtlk_release");
22762  
22763 -       switch (minor(inode->i_rdev)) {
22764 +       switch (iminor(inode)) {
22765         case DTLK_MINOR:
22766                 break;
22767  
22768 diff -Nru a/drivers/char/epca.c b/drivers/char/epca.c
22769 --- a/drivers/char/epca.c       Thu Jul 31 08:58:45 2003
22770 +++ b/drivers/char/epca.c       Sun Aug 31 16:01:49 2003
22771 @@ -40,6 +40,7 @@
22772  #include <linux/tty_flip.h>
22773  #include <linux/slab.h>
22774  #include <linux/ioport.h>
22775 +#include <linux/interrupt.h>
22776  #include <asm/uaccess.h>
22777  #include <asm/io.h>
22778  
22779 diff -Nru a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c
22780 --- a/drivers/char/ftape/lowlevel/fdc-io.c      Tue Jul 15 10:01:29 2003
22781 +++ b/drivers/char/ftape/lowlevel/fdc-io.c      Sun Aug 31 16:13:58 2003
22782 @@ -1305,7 +1305,7 @@
22783         } else {
22784                 TRACE(ft_t_bug, "Unexpected ftape interrupt");
22785         }
22786 -       return IRQ_RETVAL(handled);
22787 +       TRACE_EXIT IRQ_RETVAL(handled);
22788  }
22789  
22790  int fdc_grab_irq_and_dma(void)
22791 diff -Nru a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
22792 --- a/drivers/char/ftape/zftape/zftape-init.c   Tue Jul 15 10:01:29 2003
22793 +++ b/drivers/char/ftape/zftape/zftape-init.c   Tue Aug 26 09:25:41 2003
22794 @@ -110,11 +110,11 @@
22795         int result;
22796         TRACE_FUN(ft_t_flow);
22797  
22798 -       TRACE(ft_t_flow, "called for minor %d", minor(ino->i_rdev));
22799 +       TRACE(ft_t_flow, "called for minor %d", iminor(ino));
22800         if ( test_and_set_bit(0,&busy_flag) ) {
22801                 TRACE_ABORT(-EBUSY, ft_t_warn, "failed: already busy");
22802         }
22803 -       if ((minor(ino->i_rdev) & ~(ZFT_MINOR_OP_MASK | FTAPE_NO_REWIND))
22804 +       if ((iminor(ino) & ~(ZFT_MINOR_OP_MASK | FTAPE_NO_REWIND))
22805              > 
22806             FTAPE_SEL_D) {
22807                 clear_bit(0,&busy_flag);
22808 @@ -122,7 +122,7 @@
22809         }
22810         orig_sigmask = current->blocked;
22811         sigfillset(&current->blocked);
22812 -       result = _zft_open(minor(ino->i_rdev), filep->f_flags & O_ACCMODE);
22813 +       result = _zft_open(iminor(ino), filep->f_flags & O_ACCMODE);
22814         if (result < 0) {
22815                 current->blocked = orig_sigmask; /* restore mask */
22816                 clear_bit(0,&busy_flag);
22817 @@ -144,7 +144,7 @@
22818         int result;
22819         TRACE_FUN(ft_t_flow);
22820  
22821 -       if ( !test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit) {
22822 +       if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit) {
22823                 TRACE(ft_t_err, "failed: not busy or wrong unit");
22824                 TRACE_EXIT 0;
22825         }
22826 @@ -167,7 +167,7 @@
22827         sigset_t old_sigmask;
22828         TRACE_FUN(ft_t_flow);
22829  
22830 -       if ( !test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit || ft_failure) {
22831 +       if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
22832                 TRACE_ABORT(-EIO, ft_t_err,
22833                             "failed: not busy, failure or wrong unit");
22834         }
22835 @@ -188,7 +188,7 @@
22836         TRACE_FUN(ft_t_flow);
22837  
22838         if ( !test_bit(0,&busy_flag) || 
22839 -           minor(filep->f_dentry->d_inode->i_rdev) != zft_unit || 
22840 +           iminor(filep->f_dentry->d_inode) != zft_unit || 
22841             ft_failure)
22842         {
22843                 TRACE_ABORT(-EIO, ft_t_err,
22844 @@ -217,7 +217,7 @@
22845         TRACE_FUN(ft_t_flow);
22846  
22847         TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len);
22848 -       if (!test_bit(0,&busy_flag)  || minor(ino->i_rdev) != zft_unit || ft_failure) {
22849 +       if (!test_bit(0,&busy_flag)  || iminor(ino) != zft_unit || ft_failure) {
22850                 TRACE_ABORT(-EIO, ft_t_err,
22851                             "failed: not busy, failure or wrong unit");
22852         }
22853 @@ -240,7 +240,7 @@
22854         TRACE_FUN(ft_t_flow);
22855  
22856         TRACE(ft_t_flow, "called with count: %ld", (unsigned long)req_len);
22857 -       if (!test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit || ft_failure) {
22858 +       if (!test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
22859                 TRACE_ABORT(-EIO, ft_t_err,
22860                             "failed: not busy, failure or wrong unit");
22861         }
22862 diff -Nru a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
22863 --- a/drivers/char/generic_serial.c     Wed Jun 11 12:32:33 2003
22864 +++ b/drivers/char/generic_serial.c     Sun Aug 31 16:09:23 2003
22865 @@ -25,6 +25,7 @@
22866  #include <linux/serial.h>
22867  #include <linux/mm.h>
22868  #include <linux/generic_serial.h>
22869 +#include <linux/interrupt.h>
22870  #include <asm/semaphore.h>
22871  #include <asm/uaccess.h>
22872  
22873 diff -Nru a/drivers/char/ip2main.c b/drivers/char/ip2main.c
22874 --- a/drivers/char/ip2main.c    Mon Jul 14 06:47:09 2003
22875 +++ b/drivers/char/ip2main.c    Tue Aug 26 09:25:41 2003
22876 @@ -2733,7 +2733,7 @@
22877  ssize_t
22878  ip2_ipl_read(struct file *pFile, char *pData, size_t count, loff_t *off )
22879  {
22880 -       unsigned int minor = minor( pFile->f_dentry->d_inode->i_rdev );
22881 +       unsigned int minor = iminor(pFile->f_dentry->d_inode);
22882         int rc = 0;
22883  
22884  #ifdef IP2DEBUG_IPL
22885 @@ -2863,7 +2863,7 @@
22886  static int
22887  ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
22888  {
22889 -       unsigned int iplminor = minor(pInode->i_rdev);
22890 +       unsigned int iplminor = iminor(pInode);
22891         int rc = 0;
22892         ULONG *pIndex = (ULONG*)arg;
22893         i2eBordStrPtr pB = i2BoardPtrTable[iplminor / 4];
22894 @@ -2998,7 +2998,7 @@
22895  static int
22896  ip2_ipl_open( struct inode *pInode, struct file *pFile )
22897  {
22898 -       unsigned int iplminor = minor(pInode->i_rdev);
22899 +       unsigned int iplminor = iminor(pInode);
22900         i2eBordStrPtr pB;
22901         i2ChanStrPtr  pCh;
22902  
22903 diff -Nru a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
22904 --- a/drivers/char/ipmi/ipmi_devintf.c  Wed May  7 08:47:29 2003
22905 +++ b/drivers/char/ipmi/ipmi_devintf.c  Tue Aug 26 09:25:41 2003
22906 @@ -110,7 +110,7 @@
22907  
22908  static int ipmi_open(struct inode *inode, struct file *file)
22909  {
22910 -       int                      if_num = minor(inode->i_rdev);
22911 +       int                      if_num = iminor(inode);
22912         int                      rv;
22913         struct ipmi_file_private *priv;
22914  
22915 diff -Nru a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
22916 --- a/drivers/char/ipmi/ipmi_watchdog.c Mon Aug 11 04:34:37 2003
22917 +++ b/drivers/char/ipmi/ipmi_watchdog.c Tue Aug 26 09:25:41 2003
22918 @@ -645,7 +645,7 @@
22919  
22920  static int ipmi_open(struct inode *ino, struct file *filep)
22921  {
22922 -        switch (minor(ino->i_rdev))
22923 +        switch (iminor(ino))
22924          {
22925                  case WATCHDOG_MINOR:
22926                      if (ipmi_wdog_open)
22927 @@ -688,7 +688,7 @@
22928  
22929  static int ipmi_close(struct inode *ino, struct file *filep)
22930  {
22931 -       if (minor(ino->i_rdev)==WATCHDOG_MINOR)
22932 +       if (iminor(ino)==WATCHDOG_MINOR)
22933         {
22934  #ifndef CONFIG_WATCHDOG_NOWAYOUT       
22935                 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
22936 diff -Nru a/drivers/char/istallion.c b/drivers/char/istallion.c
22937 --- a/drivers/char/istallion.c  Mon Jun 23 18:43:58 2003
22938 +++ b/drivers/char/istallion.c  Tue Aug 26 09:25:41 2003
22939 @@ -4805,7 +4805,7 @@
22940                         (int) fp, (int) buf, count, (int) offp);
22941  #endif
22942  
22943 -       brdnr = minor(fp->f_dentry->d_inode->i_rdev);
22944 +       brdnr = iminor(fp->f_dentry->d_inode);
22945         if (brdnr >= stli_nrbrds)
22946                 return(-ENODEV);
22947         brdp = stli_brds[brdnr];
22948 @@ -4860,7 +4860,7 @@
22949                         (int) fp, (int) buf, count, (int) offp);
22950  #endif
22951  
22952 -       brdnr = minor(fp->f_dentry->d_inode->i_rdev);
22953 +       brdnr = iminor(fp->f_dentry->d_inode);
22954         if (brdnr >= stli_nrbrds)
22955                 return(-ENODEV);
22956         brdp = stli_brds[brdnr];
22957 @@ -5201,7 +5201,7 @@
22958   *     Now handle the board specific ioctls. These all depend on the
22959   *     minor number of the device they were called from.
22960   */
22961 -       brdnr = minor(ip->i_rdev);
22962 +       brdnr = iminor(ip);
22963         if (brdnr >= STL_MAXBRDS)
22964                 return(-ENODEV);
22965         brdp = stli_brds[brdnr];
22966 diff -Nru a/drivers/char/ite_gpio.c b/drivers/char/ite_gpio.c
22967 --- a/drivers/char/ite_gpio.c   Thu Mar  6 14:03:51 2003
22968 +++ b/drivers/char/ite_gpio.c   Tue Aug 26 09:25:41 2003
22969 @@ -238,7 +238,7 @@
22970  
22971  static int ite_gpio_open(struct inode *inode, struct file *file)
22972  {
22973 -       unsigned int minor = minor(inode->i_rdev); 
22974 +       unsigned int minor = iminor(inode); 
22975         if (minor != GPIO_MINOR)
22976                 return -ENODEV;
22977  
22978 diff -Nru a/drivers/char/lcd.c b/drivers/char/lcd.c
22979 --- a/drivers/char/lcd.c        Wed May 29 12:05:13 2002
22980 +++ b/drivers/char/lcd.c        Sun Aug 31 16:14:08 2003
22981 @@ -551,9 +551,9 @@
22982   */
22983  
22984  static struct file_operations lcd_fops = {
22985 -       read:           lcd_read,
22986 -       ioctl:          lcd_ioctl,
22987 -       open:           lcd_open,
22988 +       .read           = lcd_read,
22989 +       .ioctl          = lcd_ioctl,
22990 +       .open           = lcd_open,
22991  };
22992  
22993  static struct miscdevice lcd_dev=
22994 diff -Nru a/drivers/char/lp.c b/drivers/char/lp.c
22995 --- a/drivers/char/lp.c Wed May  7 08:47:29 2003
22996 +++ b/drivers/char/lp.c Wed Sep  3 23:40:14 2003
22997 @@ -292,7 +292,7 @@
22998  static ssize_t lp_write(struct file * file, const char * buf,
22999                         size_t count, loff_t *ppos)
23000  {
23001 -       unsigned int minor = minor(file->f_dentry->d_inode->i_rdev);
23002 +       unsigned int minor = iminor(file->f_dentry->d_inode);
23003         struct parport *port = lp_table[minor].dev->port;
23004         char *kbuf = lp_table[minor].lp_buffer;
23005         ssize_t retv = 0;
23006 @@ -408,7 +408,7 @@
23007  static ssize_t lp_read(struct file * file, char * buf,
23008                        size_t count, loff_t *ppos)
23009  {
23010 -       unsigned int minor=minor(file->f_dentry->d_inode->i_rdev);
23011 +       unsigned int minor=iminor(file->f_dentry->d_inode);
23012         struct parport *port = lp_table[minor].dev->port;
23013         ssize_t retval = 0;
23014         char *kbuf = lp_table[minor].lp_buffer;
23015 @@ -483,7 +483,7 @@
23016  
23017  static int lp_open(struct inode * inode, struct file * file)
23018  {
23019 -       unsigned int minor = minor(inode->i_rdev);
23020 +       unsigned int minor = iminor(inode);
23021  
23022         if (minor >= LP_NO)
23023                 return -ENXIO;
23024 @@ -540,7 +540,7 @@
23025  
23026  static int lp_release(struct inode * inode, struct file * file)
23027  {
23028 -       unsigned int minor = minor(inode->i_rdev);
23029 +       unsigned int minor = iminor(inode);
23030  
23031         lp_claim_parport_or_block (&lp_table[minor]);
23032         parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT);
23033 @@ -555,7 +555,7 @@
23034  static int lp_ioctl(struct inode *inode, struct file *file,
23035                     unsigned int cmd, unsigned long arg)
23036  {
23037 -       unsigned int minor = minor(inode->i_rdev);
23038 +       unsigned int minor = iminor(inode);
23039         int status;
23040         int retval = 0;
23041  
23042 @@ -965,4 +965,5 @@
23043  module_init(lp_init_module);
23044  module_exit(lp_cleanup_module);
23045  
23046 +MODULE_ALIAS("char-major-" __stringify(LP_MAJOR));
23047  MODULE_LICENSE("GPL");
23048 diff -Nru a/drivers/char/lp_old98.c b/drivers/char/lp_old98.c
23049 --- a/drivers/char/lp_old98.c   Thu Apr 24 03:30:40 2003
23050 +++ b/drivers/char/lp_old98.c   Tue Aug 26 09:25:41 2003
23051 @@ -219,7 +219,7 @@
23052  
23053  static int lp_old98_open(struct inode * inode, struct file * file)
23054  {
23055 -       if (minor(inode->i_rdev) != 0)
23056 +       if (iminor(inode) != 0)
23057                 return -ENXIO;
23058  
23059         if (lp.flags & LP_BUSY)
23060 diff -Nru a/drivers/char/mem.c b/drivers/char/mem.c
23061 --- a/drivers/char/mem.c        Tue Jun 10 23:33:17 2003
23062 +++ b/drivers/char/mem.c        Tue Aug 26 09:25:41 2003
23063 @@ -607,7 +607,7 @@
23064  
23065  static int memory_open(struct inode * inode, struct file * filp)
23066  {
23067 -       switch (minor(inode->i_rdev)) {
23068 +       switch (iminor(inode)) {
23069                 case 1:
23070                         filp->f_op = &mem_fops;
23071                         break;
23072 diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
23073 --- a/drivers/char/misc.c       Sat May 17 12:39:13 2003
23074 +++ b/drivers/char/misc.c       Tue Aug 26 09:25:41 2003
23075 @@ -100,7 +100,7 @@
23076  
23077  static int misc_open(struct inode * inode, struct file * file)
23078  {
23079 -       int minor = minor(inode->i_rdev);
23080 +       int minor = iminor(inode);
23081         struct miscdevice *c;
23082         int err = -ENODEV;
23083         struct file_operations *old_fops, *new_fops = NULL;
23084 diff -Nru a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
23085 --- a/drivers/char/n_hdlc.c     Fri May 30 19:53:01 2003
23086 +++ b/drivers/char/n_hdlc.c     Wed Sep  3 23:40:16 2003
23087 @@ -182,9 +182,9 @@
23088  
23089  /* TTY callbacks */
23090  
23091 -static int n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
23092 +static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
23093                            __u8 *buf, size_t nr);
23094 -static int n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
23095 +static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
23096                             const __u8 *buf, size_t nr);
23097  static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
23098                             unsigned int cmd, unsigned long arg);
23099 @@ -572,7 +572,7 @@
23100   *     
23101   * Returns the number of bytes returned or error code.
23102   */
23103 -static int n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
23104 +static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
23105                            __u8 *buf, size_t nr)
23106  {
23107         struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
23108 @@ -649,7 +649,7 @@
23109   *             
23110   * Returns the number of bytes written (or error code).
23111   */
23112 -static int n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
23113 +static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
23114                             const __u8 *data, size_t count)
23115  {
23116         struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
23117 @@ -658,7 +658,7 @@
23118         struct n_hdlc_buf *tbuf;
23119  
23120         if (debuglevel >= DEBUG_LEVEL_INFO)     
23121 -               printk("%s(%d)n_hdlc_tty_write() called count=%d\n",
23122 +               printk("%s(%d)n_hdlc_tty_write() called count=%Zd\n",
23123                         __FILE__,__LINE__,count);
23124                 
23125         /* Verify pointers */
23126 @@ -673,7 +673,7 @@
23127                 if (debuglevel & DEBUG_LEVEL_INFO)
23128                         printk (KERN_WARNING
23129                                 "n_hdlc_tty_write: truncating user packet "
23130 -                               "from %lu to %d\n", (unsigned long) count,
23131 +                               "from %lu to %Zd\n", (unsigned long) count,
23132                                 maxframe );
23133                 count = maxframe;
23134         }
23135 @@ -982,3 +982,4 @@
23136  MODULE_AUTHOR("Paul Fulghum paulkf@microgate.com");
23137  MODULE_PARM(debuglevel, "i");
23138  MODULE_PARM(maxframe, "i");
23139 +MODULE_ALIAS_LDISC(N_HDLC);
23140 diff -Nru a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
23141 --- a/drivers/char/n_r3964.c    Tue Jul 15 10:01:29 2003
23142 +++ b/drivers/char/n_r3964.c    Wed Sep  3 23:40:16 2003
23143 @@ -1428,4 +1428,4 @@
23144  
23145  
23146  MODULE_LICENSE("GPL");
23147 -
23148 +MODULE_ALIAS_LDISC(N_R3964);
23149 diff -Nru a/drivers/char/nvram.c b/drivers/char/nvram.c
23150 --- a/drivers/char/nvram.c      Tue Feb 25 10:47:17 2003
23151 +++ b/drivers/char/nvram.c      Wed Sep  3 23:40:14 2003
23152 @@ -923,3 +923,4 @@
23153  EXPORT_SYMBOL(nvram_check_checksum);
23154  EXPORT_SYMBOL(__nvram_set_checksum);
23155  EXPORT_SYMBOL(nvram_set_checksum);
23156 +MODULE_ALIAS_MISCDEV(NVRAM_MINOR);
23157 diff -Nru a/drivers/char/pcxx.c b/drivers/char/pcxx.c
23158 --- a/drivers/char/pcxx.c       Wed Aug 20 14:20:10 2003
23159 +++ b/drivers/char/pcxx.c       Sun Aug 31 16:14:07 2003
23160 @@ -121,7 +121,7 @@
23161  MODULE_PARM(altpin,      "1-4i");
23162  MODULE_PARM(numports,    "1-4i");
23163  
23164 -#endif MODULE
23165 +#endif /* MODULE */
23166  
23167  static int numcards = 1;
23168  static int nbdevs = 0;
23169 diff -Nru a/drivers/char/ppdev.c b/drivers/char/ppdev.c
23170 --- a/drivers/char/ppdev.c      Wed May  7 08:47:29 2003
23171 +++ b/drivers/char/ppdev.c      Tue Aug 26 09:25:41 2003
23172 @@ -104,7 +104,7 @@
23173  static ssize_t pp_read (struct file * file, char * buf, size_t count,
23174                         loff_t * ppos)
23175  {
23176 -       unsigned int minor = minor (file->f_dentry->d_inode->i_rdev);
23177 +       unsigned int minor = iminor(file->f_dentry->d_inode);
23178         struct pp_struct *pp = file->private_data;
23179         char * kbuffer;
23180         ssize_t bytes_read = 0;
23181 @@ -187,7 +187,7 @@
23182  static ssize_t pp_write (struct file * file, const char * buf, size_t count,
23183                          loff_t * ppos)
23184  {
23185 -       unsigned int minor = minor (file->f_dentry->d_inode->i_rdev);
23186 +       unsigned int minor = iminor(file->f_dentry->d_inode);
23187         struct pp_struct *pp = file->private_data;
23188         char * kbuffer;
23189         ssize_t bytes_written = 0;
23190 @@ -330,7 +330,7 @@
23191  static int pp_ioctl(struct inode *inode, struct file *file,
23192                     unsigned int cmd, unsigned long arg)
23193  {
23194 -       unsigned int minor = minor(inode->i_rdev);
23195 +       unsigned int minor = iminor(inode);
23196         struct pp_struct *pp = file->private_data;
23197         struct parport * port;
23198  
23199 @@ -638,7 +638,7 @@
23200  
23201  static int pp_open (struct inode * inode, struct file * file)
23202  {
23203 -       unsigned int minor = minor (inode->i_rdev);
23204 +       unsigned int minor = iminor(inode);
23205         struct pp_struct *pp;
23206  
23207         if (minor >= PARPORT_MAX)
23208 @@ -667,7 +667,7 @@
23209  
23210  static int pp_release (struct inode * inode, struct file * file)
23211  {
23212 -       unsigned int minor = minor (inode->i_rdev);
23213 +       unsigned int minor = iminor(inode);
23214         struct pp_struct *pp = file->private_data;
23215         int compat_negot;
23216  
23217 diff -Nru a/drivers/char/pty.c b/drivers/char/pty.c
23218 --- a/drivers/char/pty.c        Wed Jun 11 12:33:13 2003
23219 +++ b/drivers/char/pty.c        Wed Sep  3 23:40:19 2003
23220 @@ -354,7 +354,7 @@
23221         pty_slave_driver->init_termios = tty_std_termios;
23222         pty_slave_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
23223         pty_slave_driver->flags = TTY_DRIVER_RESET_TERMIOS |
23224 -                       TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
23225 +                                       TTY_DRIVER_REAL_RAW;
23226         pty_slave_driver->other = pty_driver;
23227         tty_set_operations(pty_slave_driver, &pty_ops);
23228  
23229 diff -Nru a/drivers/char/random.c b/drivers/char/random.c
23230 --- a/drivers/char/random.c     Wed Aug  6 10:59:31 2003
23231 +++ b/drivers/char/random.c     Sun Aug 31 16:13:54 2003
23232 @@ -269,9 +269,9 @@
23233  
23234  /*
23235   * The minimum number of bits of entropy before we wake up a read on
23236 - * /dev/random.  Should always be at least 8, or at least 1 byte.
23237 + * /dev/random.  Should be enough to do a significant reseed.
23238   */
23239 -static int random_read_wakeup_thresh = 8;
23240 +static int random_read_wakeup_thresh = 64;
23241  
23242  /*
23243   * If the entropy count falls under this number of bits, then we
23244 @@ -483,9 +483,9 @@
23245         unsigned        add_ptr;
23246         int             entropy_count;
23247         int             input_rotate;
23248 -       int             extract_count;
23249         struct poolinfo poolinfo;
23250         __u32           *pool;
23251 +       spinlock_t lock;
23252  };
23253  
23254  /*
23255 @@ -502,7 +502,7 @@
23256  
23257         poolwords = (size + 3) / 4; /* Convert bytes->words */
23258         /* The pool size must be a multiple of 16 32-bit words */
23259 -       poolwords = ((poolwords + 15) / 16) * 16; 
23260 +       poolwords = ((poolwords + 15) / 16) * 16;
23261  
23262         for (p = poolinfo_table; p->poolwords; p++) {
23263                 if (poolwords == p->poolwords)
23264 @@ -524,6 +524,7 @@
23265                 return -ENOMEM;
23266         }
23267         memset(r->pool, 0, POOLBYTES);
23268 +       r->lock = SPIN_LOCK_UNLOCKED;
23269         *ret_bucket = r;
23270         return 0;
23271  }
23272 @@ -534,7 +535,6 @@
23273         r->add_ptr = 0;
23274         r->entropy_count = 0;
23275         r->input_rotate = 0;
23276 -       r->extract_count = 0;
23277         memset(r->pool, 0, r->poolinfo.POOLBYTES);
23278  }
23279  #ifdef CONFIG_SYSCTL
23280 @@ -565,6 +565,9 @@
23281         int new_rotate;
23282         int wordmask = r->poolinfo.poolwords - 1;
23283         __u32 w;
23284 +       unsigned long flags;
23285 +
23286 +       spin_lock_irqsave(&r->lock, flags);
23287  
23288         while (nwords--) {
23289                 w = rotate_left(r->input_rotate, *in++);
23290 @@ -589,6 +592,8 @@
23291                 w ^= r->pool[i];
23292                 r->pool[i] = (w >> 3) ^ twist_table[w & 7];
23293         }
23294 +
23295 +       spin_unlock_irqrestore(&r->lock, flags);
23296  }
23297  
23298  /*
23299 @@ -596,6 +601,10 @@
23300   */
23301  static void credit_entropy_store(struct entropy_store *r, int nbits)
23302  {
23303 +       unsigned long flags;
23304 +
23305 +       spin_lock_irqsave(&r->lock, flags);
23306 +
23307         if (r->entropy_count + nbits < 0) {
23308                 DEBUG_ENT("negative entropy/overflow (%d+%d)\n",
23309                           r->entropy_count, nbits);
23310 @@ -605,11 +614,15 @@
23311         } else {
23312                 r->entropy_count += nbits;
23313                 if (nbits)
23314 -                       DEBUG_ENT("%s added %d bits, now %d\n",
23315 +                       DEBUG_ENT("%04d %04d : added %d bits to %s\n",
23316 +                                 random_state->entropy_count,
23317 +                                 sec_random_state->entropy_count,
23318 +                                 nbits,
23319                                   r == sec_random_state ? "secondary" :
23320 -                                 r == random_state ? "primary" : "unknown",
23321 -                                 nbits, r->entropy_count);
23322 +                                 r == random_state ? "primary" : "unknown");
23323         }
23324 +
23325 +       spin_unlock_irqrestore(&r->lock, flags);
23326  }
23327  
23328  /**********************************************************************
23329 @@ -620,27 +633,33 @@
23330   *
23331   **********************************************************************/
23332  
23333 -static __u32   *batch_entropy_pool;
23334 -static int     *batch_entropy_credit;
23335 -static int     batch_max;
23336 +struct sample {
23337 +       __u32 data[2];
23338 +       int credit;
23339 +};
23340 +
23341 +static struct sample *batch_entropy_pool, *batch_entropy_copy;
23342  static int     batch_head, batch_tail;
23343 +static spinlock_t batch_lock = SPIN_LOCK_UNLOCKED;
23344 +
23345 +static int     batch_max;
23346  static void batch_entropy_process(void *private_);
23347  static DECLARE_WORK(batch_work, batch_entropy_process, NULL);
23348  
23349  /* note: the size must be a power of 2 */
23350  static int __init batch_entropy_init(int size, struct entropy_store *r)
23351  {
23352 -       batch_entropy_pool = kmalloc(2*size*sizeof(__u32), GFP_KERNEL);
23353 +       batch_entropy_pool = kmalloc(size*sizeof(struct sample), GFP_KERNEL);
23354         if (!batch_entropy_pool)
23355                 return -1;
23356 -       batch_entropy_credit =kmalloc(size*sizeof(int), GFP_KERNEL);
23357 -       if (!batch_entropy_credit) {
23358 +       batch_entropy_copy = kmalloc(size*sizeof(struct sample), GFP_KERNEL);
23359 +       if (!batch_entropy_copy) {
23360                 kfree(batch_entropy_pool);
23361                 return -1;
23362         }
23363         batch_head = batch_tail = 0;
23364 -       batch_max = size;
23365         batch_work.data = r;
23366 +       batch_max = size;
23367         return 0;
23368  }
23369  
23370 @@ -652,27 +671,33 @@
23371   */
23372  void batch_entropy_store(u32 a, u32 b, int num)
23373  {
23374 -       int     new;
23375 +       int new;
23376 +       unsigned long flags;
23377  
23378         if (!batch_max)
23379                 return;
23380 -       
23381 -       batch_entropy_pool[2*batch_head] = a;
23382 -       batch_entropy_pool[(2*batch_head) + 1] = b;
23383 -       batch_entropy_credit[batch_head] = num;
23384  
23385 -       new = (batch_head+1) & (batch_max-1);
23386 -       if ((unsigned)(new - batch_tail) >= (unsigned)(batch_max / 2)) {
23387 +       spin_lock_irqsave(&batch_lock, flags);
23388 +
23389 +       batch_entropy_pool[batch_head].data[0] = a;
23390 +       batch_entropy_pool[batch_head].data[1] = b;
23391 +       batch_entropy_pool[batch_head].credit = num;
23392 +
23393 +       if (((batch_head - batch_tail) & (batch_max-1)) >= (batch_max / 2)) {
23394                 /*
23395                  * Schedule it for the next timer tick:
23396                  */
23397                 schedule_delayed_work(&batch_work, 1);
23398 -               batch_head = new;
23399 -       } else if (new == batch_tail) {
23400 +       }
23401 +
23402 +       new = (batch_head+1) & (batch_max-1);
23403 +       if (new == batch_tail) {
23404                 DEBUG_ENT("batch entropy buffer full\n");
23405         } else {
23406                 batch_head = new;
23407         }
23408 +
23409 +       spin_unlock_irqrestore(&batch_lock, flags);
23410  }
23411  
23412  /*
23413 @@ -684,20 +709,34 @@
23414  {
23415         struct entropy_store *r = (struct entropy_store *) private_, *p;
23416         int max_entropy = r->poolinfo.POOLBITS;
23417 +       unsigned head, tail;
23418  
23419 -       if (!batch_max)
23420 -               return;
23421 +       /* Mixing into the pool is expensive, so copy over the batch
23422 +        * data and release the batch lock. The pool is at least half
23423 +        * full, so don't worry too much about copying only the used
23424 +        * part.
23425 +        */
23426 +       spin_lock_irq(&batch_lock);
23427 +
23428 +       memcpy(batch_entropy_copy, batch_entropy_pool,
23429 +              batch_max*sizeof(struct sample));
23430 +
23431 +       head = batch_head;
23432 +       tail = batch_tail;
23433 +       batch_tail = batch_head;
23434 +
23435 +       spin_unlock_irq(&batch_lock);
23436  
23437         p = r;
23438 -       while (batch_head != batch_tail) {
23439 +       while (head != tail) {
23440                 if (r->entropy_count >= max_entropy) {
23441                         r = (r == sec_random_state) ?   random_state :
23442                                                         sec_random_state;
23443                         max_entropy = r->poolinfo.POOLBITS;
23444                 }
23445 -               add_entropy_words(r, batch_entropy_pool + 2*batch_tail, 2);
23446 -               credit_entropy_store(r, batch_entropy_credit[batch_tail]);
23447 -               batch_tail = (batch_tail+1) & (batch_max-1);
23448 +               add_entropy_words(r, batch_entropy_copy[tail].data, 2);
23449 +               credit_entropy_store(r, batch_entropy_copy[tail].credit);
23450 +               tail = (tail+1) & (batch_max-1);
23451         }
23452         if (p->entropy_count >= random_read_wakeup_thresh)
23453                 wake_up_interruptible(&random_read_wait);
23454 @@ -1216,6 +1255,7 @@
23455  
23456  #define EXTRACT_ENTROPY_USER           1
23457  #define EXTRACT_ENTROPY_SECONDARY      2
23458 +#define EXTRACT_ENTROPY_LIMIT          4
23459  #define TMP_BUF_SIZE                   (HASH_BUFFER_SIZE + HASH_EXTRA_SIZE)
23460  #define SEC_XFER_SIZE                  (TMP_BUF_SIZE*4)
23461  
23462 @@ -1224,36 +1264,28 @@
23463  
23464  /*
23465   * This utility inline function is responsible for transfering entropy
23466 - * from the primary pool to the secondary extraction pool.  We pull
23467 - * randomness under two conditions; one is if there isn't enough entropy
23468 - * in the secondary pool.  The other is after we have extracted 1024 bytes,
23469 - * at which point we do a "catastrophic reseeding".
23470 + * from the primary pool to the secondary extraction pool. We make
23471 + * sure we pull enough for a 'catastrophic reseed'.
23472   */
23473  static inline void xfer_secondary_pool(struct entropy_store *r,
23474                                        size_t nbytes, __u32 *tmp)
23475  {
23476         if (r->entropy_count < nbytes * 8 &&
23477             r->entropy_count < r->poolinfo.POOLBITS) {
23478 -               int nwords = min_t(int,
23479 -                                  r->poolinfo.poolwords - r->entropy_count/32,
23480 -                                  sizeof(tmp) / 4);
23481 +               int bytes = max_t(int, random_read_wakeup_thresh / 8,
23482 +                               min_t(int, nbytes, TMP_BUF_SIZE));
23483  
23484 -               DEBUG_ENT("xfer %d from primary to %s (have %d, need %d)\n",
23485 -                         nwords * 32,
23486 +               DEBUG_ENT("%04d %04d : going to reseed %s with %d bits "
23487 +                         "(%d of %d requested)\n",
23488 +                         random_state->entropy_count,
23489 +                         sec_random_state->entropy_count,
23490                           r == sec_random_state ? "secondary" : "unknown",
23491 -                         r->entropy_count, nbytes * 8);
23492 +                         bytes * 8, nbytes * 8, r->entropy_count);
23493  
23494 -               extract_entropy(random_state, tmp, nwords * 4, 0);
23495 -               add_entropy_words(r, tmp, nwords);
23496 -               credit_entropy_store(r, nwords * 32);
23497 -       }
23498 -       if (r->extract_count > 1024) {
23499 -               DEBUG_ENT("reseeding %s with %d from primary\n",
23500 -                         r == sec_random_state ? "secondary" : "unknown",
23501 -                         sizeof(tmp) * 8);
23502 -               extract_entropy(random_state, tmp, sizeof(tmp), 0);
23503 -               add_entropy_words(r, tmp, sizeof(tmp) / 4);
23504 -               r->extract_count = 0;
23505 +               bytes=extract_entropy(random_state, tmp, bytes,
23506 +                                     EXTRACT_ENTROPY_LIMIT);
23507 +               add_entropy_words(r, tmp, bytes);
23508 +               credit_entropy_store(r, bytes*8);
23509         }
23510  }
23511  
23512 @@ -1276,8 +1308,8 @@
23513         ssize_t ret, i;
23514         __u32 tmp[TMP_BUF_SIZE];
23515         __u32 x;
23516 +       unsigned long cpuflags;
23517  
23518 -       add_timer_randomness(&extract_timer_state, nbytes);
23519  
23520         /* Redundant, but just in case... */
23521         if (r->entropy_count > r->poolinfo.POOLBITS)
23522 @@ -1286,10 +1318,18 @@
23523         if (flags & EXTRACT_ENTROPY_SECONDARY)
23524                 xfer_secondary_pool(r, nbytes, tmp);
23525  
23526 -       DEBUG_ENT("%s has %d bits, want %d bits\n",
23527 +       /* Hold lock while accounting */
23528 +       spin_lock_irqsave(&r->lock, cpuflags);
23529 +
23530 +       DEBUG_ENT("%04d %04d : trying to extract %d bits from %s\n",
23531 +                 random_state->entropy_count,
23532 +                 sec_random_state->entropy_count,
23533 +                 nbytes * 8,
23534                   r == sec_random_state ? "secondary" :
23535 -                 r == random_state ? "primary" : "unknown",
23536 -                 r->entropy_count, nbytes * 8);
23537 +                 r == random_state ? "primary" : "unknown");
23538 +
23539 +       if (flags & EXTRACT_ENTROPY_LIMIT && nbytes >= r->entropy_count / 8)
23540 +               nbytes = r->entropy_count / 8;
23541  
23542         if (r->entropy_count / 8 >= nbytes)
23543                 r->entropy_count -= nbytes*8;
23544 @@ -1299,8 +1339,16 @@
23545         if (r->entropy_count < random_write_wakeup_thresh)
23546                 wake_up_interruptible(&random_write_wait);
23547  
23548 -       r->extract_count += nbytes;
23549 -       
23550 +       DEBUG_ENT("%04d %04d : debiting %d bits from %s%s\n",
23551 +                 random_state->entropy_count,
23552 +                 sec_random_state->entropy_count,
23553 +                 nbytes * 8,
23554 +                 r == sec_random_state ? "secondary" :
23555 +                 r == random_state ? "primary" : "unknown",
23556 +                 flags & EXTRACT_ENTROPY_LIMIT ? "" : " (unlimited)");
23557 +
23558 +       spin_unlock_irqrestore(&r->lock, cpuflags);
23559 +
23560         ret = 0;
23561         while (nbytes) {
23562                 /*
23563 @@ -1312,7 +1360,16 @@
23564                                         ret = -ERESTARTSYS;
23565                                 break;
23566                         }
23567 +
23568 +                       DEBUG_ENT("%04d %04d : extract feeling sleepy (%d bytes left)\n",
23569 +                                 random_state->entropy_count,
23570 +                                 sec_random_state->entropy_count, nbytes);
23571 +
23572                         schedule();
23573 +
23574 +                       DEBUG_ENT("%04d %04d : extract woke up\n",
23575 +                                 random_state->entropy_count,
23576 +                                 sec_random_state->entropy_count);
23577                 }
23578  
23579                 /* Hash the pool to get the output */
23580 @@ -1361,7 +1418,6 @@
23581                 nbytes -= i;
23582                 buf += i;
23583                 ret += i;
23584 -               add_timer_randomness(&extract_timer_state, nbytes);
23585         }
23586  
23587         /* Wipe data just returned from memory */
23588 @@ -1488,15 +1544,27 @@
23589         if (nbytes == 0)
23590                 return 0;
23591  
23592 -       add_wait_queue(&random_read_wait, &wait);
23593         while (nbytes > 0) {
23594 -               set_current_state(TASK_INTERRUPTIBLE);
23595 -               
23596                 n = nbytes;
23597                 if (n > SEC_XFER_SIZE)
23598                         n = SEC_XFER_SIZE;
23599 -               if (n > random_state->entropy_count / 8)
23600 -                       n = random_state->entropy_count / 8;
23601 +
23602 +               DEBUG_ENT("%04d %04d : reading %d bits, p: %d s: %d\n",
23603 +                         random_state->entropy_count,
23604 +                         sec_random_state->entropy_count,
23605 +                         n*8, random_state->entropy_count,
23606 +                         sec_random_state->entropy_count);
23607 +
23608 +               n = extract_entropy(sec_random_state, buf, n,
23609 +                                   EXTRACT_ENTROPY_USER |
23610 +                                   EXTRACT_ENTROPY_LIMIT |
23611 +                                   EXTRACT_ENTROPY_SECONDARY);
23612 +
23613 +               DEBUG_ENT("%04d %04d : read got %d bits (%d still needed)\n",
23614 +                         random_state->entropy_count,
23615 +                         sec_random_state->entropy_count,
23616 +                         n*8, (nbytes-n)*8);
23617 +
23618                 if (n == 0) {
23619                         if (file->f_flags & O_NONBLOCK) {
23620                                 retval = -EAGAIN;
23621 @@ -1506,12 +1574,27 @@
23622                                 retval = -ERESTARTSYS;
23623                                 break;
23624                         }
23625 -                       schedule();
23626 +
23627 +                       DEBUG_ENT("%04d %04d : sleeping?\n",
23628 +                                 random_state->entropy_count,
23629 +                                 sec_random_state->entropy_count);
23630 +
23631 +                       set_current_state(TASK_INTERRUPTIBLE);
23632 +                       add_wait_queue(&random_read_wait, &wait);
23633 +
23634 +                       if (sec_random_state->entropy_count / 8 == 0)
23635 +                               schedule();
23636 +
23637 +                       set_current_state(TASK_RUNNING);
23638 +                       remove_wait_queue(&random_read_wait, &wait);
23639 +
23640 +                       DEBUG_ENT("%04d %04d : waking up\n",
23641 +                                 random_state->entropy_count,
23642 +                                 sec_random_state->entropy_count);
23643 +
23644                         continue;
23645                 }
23646 -               n = extract_entropy(sec_random_state, buf, n,
23647 -                                   EXTRACT_ENTROPY_USER |
23648 -                                   EXTRACT_ENTROPY_SECONDARY);
23649 +
23650                 if (n < 0) {
23651                         retval = n;
23652                         break;
23653 @@ -1522,8 +1605,6 @@
23654                 break;          /* This break makes the device work */
23655                                 /* like a named pipe */
23656         }
23657 -       current->state = TASK_RUNNING;
23658 -       remove_wait_queue(&random_read_wait, &wait);
23659  
23660         /*
23661          * If we gave the user some bytes, update the access time.
23662 @@ -1595,8 +1676,9 @@
23663  random_ioctl(struct inode * inode, struct file * file,
23664              unsigned int cmd, unsigned long arg)
23665  {
23666 -       int *p, size, ent_count;
23667 +       int *p, *tmp, size, ent_count;
23668         int retval;
23669 +       unsigned long flags;
23670         
23671         switch (cmd) {
23672         case RNDGETENTCNT:
23673 @@ -1621,17 +1703,36 @@
23674                 if (!capable(CAP_SYS_ADMIN))
23675                         return -EPERM;
23676                 p = (int *) arg;
23677 -               ent_count = random_state->entropy_count;
23678 -               if (put_user(ent_count, p++) ||
23679 -                   get_user(size, p) ||
23680 +               if (get_user(size, p) ||
23681                     put_user(random_state->poolinfo.poolwords, p++))
23682                         return -EFAULT;
23683                 if (size < 0)
23684 -                       return -EINVAL;
23685 +                       return -EFAULT;
23686                 if (size > random_state->poolinfo.poolwords)
23687                         size = random_state->poolinfo.poolwords;
23688 -               if (copy_to_user(p, random_state->pool, size * sizeof(__u32)))
23689 +
23690 +               /* prepare to atomically snapshot pool */
23691 +
23692 +               tmp = kmalloc(size * sizeof(__u32), GFP_KERNEL);
23693 +
23694 +               if (!tmp)
23695                         return -EFAULT;
23696 +
23697 +               spin_lock_irqsave(&random_state->lock, flags);
23698 +               ent_count = random_state->entropy_count;
23699 +               memcpy(tmp, random_state->pool, size * sizeof(__u32));
23700 +               spin_unlock_irqrestore(&random_state->lock, flags);
23701 +
23702 +               if (!copy_to_user(p, tmp, size * sizeof(__u32))) {
23703 +                       kfree(tmp);
23704 +                       return -EFAULT;
23705 +               }
23706 +
23707 +               kfree(tmp);
23708 +
23709 +               if(put_user(ent_count, p++))
23710 +                       return -EFAULT;
23711 +
23712                 return 0;
23713         case RNDADDENTROPY:
23714                 if (!capable(CAP_SYS_ADMIN))
23715 diff -Nru a/drivers/char/raw.c b/drivers/char/raw.c
23716 --- a/drivers/char/raw.c        Fri Jun 20 13:16:17 2003
23717 +++ b/drivers/char/raw.c        Sun Aug 31 16:14:45 2003
23718 @@ -43,7 +43,7 @@
23719   */
23720  static int raw_open(struct inode *inode, struct file *filp)
23721  {
23722 -       const int minor = minor(inode->i_rdev);
23723 +       const int minor = iminor(inode);
23724         struct block_device *bdev;
23725         int err;
23726  
23727 @@ -60,23 +60,25 @@
23728         bdev = raw_devices[minor].binding;
23729         err = -ENODEV;
23730         if (bdev) {
23731 -               err = bd_claim(bdev, raw_open);
23732 +               err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
23733                 if (err)
23734                         goto out;
23735 -               atomic_inc(&bdev->bd_count);
23736 -               err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
23737 +               igrab(bdev->bd_inode);
23738 +               err = bd_claim(bdev, raw_open);
23739 +               if (err) {
23740 +                       blkdev_put(bdev, BDEV_RAW);
23741 +                       goto out;
23742 +               }
23743 +               err = set_blocksize(bdev, bdev_hardsect_size(bdev));
23744                 if (err) {
23745                         bd_release(bdev);
23746 +                       blkdev_put(bdev, BDEV_RAW);
23747                         goto out;
23748 -               } else {
23749 -                       err = set_blocksize(bdev, bdev_hardsect_size(bdev));
23750 -                       if (err == 0) {
23751 -                               filp->f_flags |= O_DIRECT;
23752 -                               if (++raw_devices[minor].inuse == 1)
23753 -                                       filp->f_dentry->d_inode->i_mapping =
23754 -                                               bdev->bd_inode->i_mapping;
23755 -                       }
23756                 }
23757 +               filp->f_flags |= O_DIRECT;
23758 +               if (++raw_devices[minor].inuse == 1)
23759 +                       filp->f_dentry->d_inode->i_mapping =
23760 +                               bdev->bd_inode->i_mapping;
23761         }
23762         filp->private_data = bdev;
23763  out:
23764 @@ -90,7 +92,7 @@
23765   */
23766  static int raw_release(struct inode *inode, struct file *filp)
23767  {
23768 -       const int minor= minor(inode->i_rdev);
23769 +       const int minor= iminor(inode);
23770         struct block_device *bdev;
23771  
23772         down(&raw_mutex);
23773 diff -Nru a/drivers/char/riscom8.c b/drivers/char/riscom8.c
23774 --- a/drivers/char/riscom8.c    Mon Aug 18 09:59:49 2003
23775 +++ b/drivers/char/riscom8.c    Wed Sep  3 23:39:56 2003
23776 @@ -1036,7 +1036,6 @@
23777         int error;
23778         struct riscom_port * port;
23779         struct riscom_board * bp;
23780 -       unsigned long flags;
23781         
23782         board = RC_BOARD(tty->index);
23783         if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
23784 diff -Nru a/drivers/char/rtc.c b/drivers/char/rtc.c
23785 --- a/drivers/char/rtc.c        Tue Aug 12 13:25:18 2003
23786 +++ b/drivers/char/rtc.c        Wed Sep  3 23:40:14 2003
23787 @@ -44,10 +44,12 @@
23788   *      1.11    Takashi Iwai: Kernel access functions
23789   *                           rtc_register/rtc_unregister/rtc_control
23790   *      1.11a   Daniele Bellucci: Audit create_proc_read_entry in rtc_init
23791 + *     1.12    Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer
23792 + *             CONFIG_HPET_EMULATE_RTC
23793   *
23794   */
23795  
23796 -#define RTC_VERSION            "1.11a"
23797 +#define RTC_VERSION            "1.12"
23798  
23799  #define RTC_IO_EXTENT  0x8
23800  
23801 @@ -80,6 +82,10 @@
23802  #include <asm/uaccess.h>
23803  #include <asm/system.h>
23804  
23805 +#if defined(__i386__)
23806 +#include <asm/hpet.h>
23807 +#endif
23808 +
23809  #ifdef __sparc__
23810  #include <linux/pci.h>
23811  #include <asm/ebus.h>
23812 @@ -95,6 +101,17 @@
23813  static int rtc_has_irq = 1;
23814  #endif
23815  
23816 +#ifndef CONFIG_HPET_EMULATE_RTC
23817 +#define is_hpet_enabled()                      0
23818 +#define hpet_set_alarm_time(hrs, min, sec)     0
23819 +#define hpet_set_periodic_freq(arg)            0
23820 +#define hpet_mask_rtc_irq_bit(arg)             0
23821 +#define hpet_set_rtc_irq_bit(arg)              0
23822 +#define hpet_rtc_timer_init()                  do { } while (0)
23823 +#define hpet_rtc_dropped_irq()                         0
23824 +static inline irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs) {return 0;}
23825 +#endif
23826 +
23827  /*
23828   *     We sponge a minor off of the misc major. No need slurping
23829   *     up another valuable major dev number for this. If you add
23830 @@ -120,7 +137,6 @@
23831  static unsigned int rtc_poll(struct file *file, poll_table *wait);
23832  #endif
23833  
23834 -static void get_rtc_time (struct rtc_time *rtc_tm);
23835  static void get_rtc_alm_time (struct rtc_time *alm_tm);
23836  #if RTC_IRQ
23837  static void rtc_dropped_irq(unsigned long data);
23838 @@ -182,7 +198,7 @@
23839   *     (See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.)
23840   */
23841  
23842 -static irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
23843 +irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
23844  {
23845         /*
23846          *      Can be an alarm interrupt, update complete interrupt,
23847 @@ -194,7 +210,16 @@
23848         spin_lock (&rtc_lock);
23849         rtc_irq_data += 0x100;
23850         rtc_irq_data &= ~0xff;
23851 -       rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);
23852 +       if (is_hpet_enabled()) {
23853 +               /*
23854 +                * In this case it is HPET RTC interrupt handler
23855 +                * calling us, with the interrupt information
23856 +                * passed as arg1, instead of irq.
23857 +                */
23858 +               rtc_irq_data |= (unsigned long)irq & 0xF0;
23859 +       } else {
23860 +               rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);
23861 +       }
23862  
23863         if (rtc_status & RTC_TIMER_ON)
23864                 mod_timer(&rtc_irq_timer, jiffies + HZ/rtc_freq + 2*HZ/100);
23865 @@ -429,6 +454,12 @@
23866                 sec = alm_tm.tm_sec;
23867  
23868                 spin_lock_irq(&rtc_lock);
23869 +               if (hpet_set_alarm_time(hrs, min, sec)) {
23870 +                       /*
23871 +                        * Fallthru and set alarm time in CMOS too,
23872 +                        * so that we will get proper value in RTC_ALM_READ
23873 +                        */
23874 +               }
23875                 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) ||
23876                     RTC_ALWAYS_BCD)
23877                 {
23878 @@ -450,7 +481,7 @@
23879         }
23880         case RTC_RD_TIME:       /* Read the time/date from RTC  */
23881         {
23882 -               get_rtc_time(&wtime);
23883 +               rtc_get_rtc_time(&wtime);
23884                 break;
23885         }
23886         case RTC_SET_TIME:      /* Set the RTC */
23887 @@ -582,6 +613,10 @@
23888                         return -EINVAL;
23889  
23890                 spin_lock_irq(&rtc_lock);
23891 +               if (hpet_set_periodic_freq(arg)) {
23892 +                       spin_unlock_irq(&rtc_lock);
23893 +                       return 0;
23894 +               }
23895                 rtc_freq = arg;
23896  
23897                 val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0;
23898 @@ -667,13 +702,14 @@
23899          */
23900  
23901         spin_lock_irq(&rtc_lock);
23902 -       tmp = CMOS_READ(RTC_CONTROL);
23903 -       tmp &=  ~RTC_PIE;
23904 -       tmp &=  ~RTC_AIE;
23905 -       tmp &=  ~RTC_UIE;
23906 -       CMOS_WRITE(tmp, RTC_CONTROL);
23907 -       CMOS_READ(RTC_INTR_FLAGS);
23908 -
23909 +       if (!hpet_mask_rtc_irq_bit(RTC_PIE | RTC_AIE | RTC_UIE)) {
23910 +               tmp = CMOS_READ(RTC_CONTROL);
23911 +               tmp &=  ~RTC_PIE;
23912 +               tmp &=  ~RTC_AIE;
23913 +               tmp &=  ~RTC_UIE;
23914 +               CMOS_WRITE(tmp, RTC_CONTROL);
23915 +               CMOS_READ(RTC_INTR_FLAGS);
23916 +       }
23917         if (rtc_status & RTC_TIMER_ON) {
23918                 rtc_status &= ~RTC_TIMER_ON;
23919                 del_timer(&rtc_irq_timer);
23920 @@ -765,12 +801,14 @@
23921         rtc_callback = NULL;
23922         
23923         /* disable controls */
23924 -       tmp = CMOS_READ(RTC_CONTROL);
23925 -       tmp &= ~RTC_PIE;
23926 -       tmp &= ~RTC_AIE;
23927 -       tmp &= ~RTC_UIE;
23928 -       CMOS_WRITE(tmp, RTC_CONTROL);
23929 -       CMOS_READ(RTC_INTR_FLAGS);
23930 +       if (!hpet_mask_rtc_irq_bit(RTC_PIE | RTC_AIE | RTC_UIE)) {
23931 +               tmp = CMOS_READ(RTC_CONTROL);
23932 +               tmp &= ~RTC_PIE;
23933 +               tmp &= ~RTC_AIE;
23934 +               tmp &= ~RTC_UIE;
23935 +               CMOS_WRITE(tmp, RTC_CONTROL);
23936 +               CMOS_READ(RTC_INTR_FLAGS);
23937 +       }
23938         if (rtc_status & RTC_TIMER_ON) {
23939                 rtc_status &= ~RTC_TIMER_ON;
23940                 del_timer(&rtc_irq_timer);
23941 @@ -822,6 +860,10 @@
23942         &rtc_fops
23943  };
23944  
23945 +#if RTC_IRQ
23946 +static irqreturn_t (*rtc_int_handler_ptr)(int irq, void *dev_id, struct pt_regs *regs);
23947 +#endif
23948 +
23949  static int __init rtc_init(void)
23950  {
23951  #if defined(__alpha__) || defined(__mips__)
23952 @@ -889,12 +931,20 @@
23953         }
23954  
23955  #if RTC_IRQ
23956 -       if (request_irq(RTC_IRQ, rtc_interrupt, SA_INTERRUPT, "rtc", NULL)) {
23957 +       if (is_hpet_enabled()) {
23958 +               rtc_int_handler_ptr = hpet_rtc_interrupt;
23959 +       } else {
23960 +               rtc_int_handler_ptr = rtc_interrupt;
23961 +       }
23962 +
23963 +       if(request_irq(RTC_IRQ, rtc_int_handler_ptr, SA_INTERRUPT, "rtc", NULL)) {
23964                 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */
23965                 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
23966                 release_region(RTC_PORT(0), RTC_IO_EXTENT);
23967                 return -EIO;
23968         }
23969 +       hpet_rtc_timer_init();
23970 +
23971  #endif
23972  
23973  #endif /* __sparc__ vs. others */
23974 @@ -965,10 +1015,12 @@
23975         init_timer(&rtc_irq_timer);
23976         rtc_irq_timer.function = rtc_dropped_irq;
23977         spin_lock_irq(&rtc_lock);
23978 -       /* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
23979 -       CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
23980 -       spin_unlock_irq(&rtc_lock);
23981         rtc_freq = 1024;
23982 +       if (!hpet_set_periodic_freq(rtc_freq)) {
23983 +               /* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
23984 +               CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
23985 +       }
23986 +       spin_unlock_irq(&rtc_lock);
23987  no_irq2:
23988  #endif
23989  
23990 @@ -1019,6 +1071,11 @@
23991  
23992         spin_lock_irq (&rtc_lock);
23993  
23994 +       if (hpet_rtc_dropped_irq()) {
23995 +               spin_unlock_irq(&rtc_lock);
23996 +               return;
23997 +       }
23998 +
23999         /* Just in case someone disabled the timer from behind our back... */
24000         if (rtc_status & RTC_TIMER_ON)
24001                 mod_timer(&rtc_irq_timer, jiffies + HZ/rtc_freq + 2*HZ/100);
24002 @@ -1061,7 +1118,7 @@
24003  
24004         p = buf;
24005  
24006 -       get_rtc_time(&tm);
24007 +       rtc_get_rtc_time(&tm);
24008  
24009         /*
24010          * There is no way to tell if the luser has the RTC set for local
24011 @@ -1148,7 +1205,7 @@
24012         return uip;
24013  }
24014  
24015 -static void get_rtc_time(struct rtc_time *rtc_tm)
24016 +void rtc_get_rtc_time(struct rtc_time *rtc_tm)
24017  {
24018         unsigned long uip_watchdog = jiffies;
24019         unsigned char ctrl;
24020 @@ -1254,6 +1311,10 @@
24021         unsigned char val;
24022  
24023         spin_lock_irq(&rtc_lock);
24024 +       if (hpet_mask_rtc_irq_bit(bit)) {
24025 +               spin_unlock_irq(&rtc_lock);
24026 +               return;
24027 +       }
24028         val = CMOS_READ(RTC_CONTROL);
24029         val &=  ~bit;
24030         CMOS_WRITE(val, RTC_CONTROL);
24031 @@ -1268,6 +1329,10 @@
24032         unsigned char val;
24033  
24034         spin_lock_irq(&rtc_lock);
24035 +       if (hpet_set_rtc_irq_bit(bit)) {
24036 +               spin_unlock_irq(&rtc_lock);
24037 +               return;
24038 +       }
24039         val = CMOS_READ(RTC_CONTROL);
24040         val |= bit;
24041         CMOS_WRITE(val, RTC_CONTROL);
24042 @@ -1280,3 +1345,4 @@
24043  
24044  MODULE_AUTHOR("Paul Gortmaker");
24045  MODULE_LICENSE("GPL");
24046 +MODULE_ALIAS_MISCDEV(RTC_MINOR);
24047 diff -Nru a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
24048 --- a/drivers/char/scx200_gpio.c        Sat Dec  7 08:54:07 2002
24049 +++ b/drivers/char/scx200_gpio.c        Tue Aug 26 09:25:41 2003
24050 @@ -29,7 +29,7 @@
24051  static ssize_t scx200_gpio_write(struct file *file, const char *data, 
24052                                  size_t len, loff_t *ppos)
24053  {
24054 -       unsigned m = minor(file->f_dentry->d_inode->i_rdev);
24055 +       unsigned m = iminor(file->f_dentry->d_inode);
24056         size_t i;
24057  
24058         if (ppos != &file->f_pos)
24059 @@ -80,7 +80,7 @@
24060  static ssize_t scx200_gpio_read(struct file *file, char *buf,
24061                                 size_t len, loff_t *ppos)
24062  {
24063 -       unsigned m = minor(file->f_dentry->d_inode->i_rdev);
24064 +       unsigned m = iminor(file->f_dentry->d_inode);
24065         int value;
24066  
24067         if (ppos != &file->f_pos)
24068 @@ -95,7 +95,7 @@
24069  
24070  static int scx200_gpio_open(struct inode *inode, struct file *file)
24071  {
24072 -       unsigned m = minor(inode->i_rdev);
24073 +       unsigned m = iminor(inode);
24074         if (m > 63)
24075                 return -EINVAL;
24076         return 0;
24077 diff -Nru a/drivers/char/sonypi.c b/drivers/char/sonypi.c
24078 --- a/drivers/char/sonypi.c     Fri Jun 13 07:30:24 2003
24079 +++ b/drivers/char/sonypi.c     Fri Aug  1 05:36:14 2003
24080 @@ -308,7 +308,7 @@
24081         int i, j;
24082  
24083         v1 = inb_p(sonypi_device.ioport1);
24084 -       v2 = inb_p(sonypi_device.ioport2);
24085 +       v2 = inb_p(sonypi_device.ioport1 + sonypi_device.evtype_offset);
24086  
24087         for (i = 0; sonypi_eventtypes[i].model; i++) {
24088                 if (sonypi_device.model != sonypi_eventtypes[i].model)
24089 @@ -670,11 +670,13 @@
24090         if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) {
24091                 ioport_list = sonypi_type2_ioport_list;
24092                 sonypi_device.region_size = SONYPI_TYPE2_REGION_SIZE;
24093 +               sonypi_device.evtype_offset = SONYPI_TYPE2_EVTYPE_OFFSET;
24094                 irq_list = sonypi_type2_irq_list;
24095         }
24096         else {
24097                 ioport_list = sonypi_type1_ioport_list;
24098                 sonypi_device.region_size = SONYPI_TYPE1_REGION_SIZE;
24099 +               sonypi_device.evtype_offset = SONYPI_TYPE1_EVTYPE_OFFSET;
24100                 irq_list = sonypi_type1_irq_list;
24101         }
24102  
24103 diff -Nru a/drivers/char/sonypi.h b/drivers/char/sonypi.h
24104 --- a/drivers/char/sonypi.h     Tue Jun 10 03:03:28 2003
24105 +++ b/drivers/char/sonypi.h     Mon Sep  1 03:37:24 2003
24106 @@ -56,12 +56,14 @@
24107  #define SONYPI_BASE                    0x50
24108  #define SONYPI_G10A                    (SONYPI_BASE+0x14)
24109  #define SONYPI_TYPE1_REGION_SIZE       0x08
24110 +#define SONYPI_TYPE1_EVTYPE_OFFSET     0x04
24111  
24112  /* type2 series specifics */
24113  #define SONYPI_SIRQ                    0x9b
24114  #define SONYPI_SLOB                    0x9c
24115  #define SONYPI_SHIB                    0x9d
24116  #define SONYPI_TYPE2_REGION_SIZE       0x20
24117 +#define SONYPI_TYPE2_EVTYPE_OFFSET     0x12
24118  
24119  /* battery / brightness addresses */
24120  #define SONYPI_BAT_FLAGS       0x81
24121 @@ -167,6 +169,7 @@
24122  #define SONYPI_THUMBPHRASE_MASK                        0x00000200
24123  #define SONYPI_MEYE_MASK                       0x00000400
24124  #define SONYPI_MEMORYSTICK_MASK                        0x00000800
24125 +#define SONYPI_BATTERY_MASK                    0x00001000
24126  
24127  struct sonypi_event {
24128         u8      data;
24129 @@ -293,6 +296,13 @@
24130         { 0, 0 }
24131  };
24132  
24133 +/* The set of possible battery events */
24134 +static struct sonypi_event sonypi_batteryev[] = {
24135 +       { 0x20, SONYPI_EVENT_BATTERY_INSERT },
24136 +       { 0x30, SONYPI_EVENT_BATTERY_REMOVE },
24137 +       { 0, 0 }
24138 +};
24139 +
24140  struct sonypi_eventtypes {
24141         int                     model;
24142         u8                      data;
24143 @@ -307,19 +317,22 @@
24144         { SONYPI_DEVICE_MODEL_TYPE1, 0x20, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
24145         { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
24146         { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_PKEY_MASK, sonypi_pkeyev },
24147 +       { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
24148 +       { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_BATTERY_MASK, sonypi_batteryev },
24149  
24150         { SONYPI_DEVICE_MODEL_TYPE2, 0, 0xffffffff, sonypi_releaseev },
24151         { SONYPI_DEVICE_MODEL_TYPE2, 0x38, SONYPI_LID_MASK, sonypi_lidev },
24152 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_JOGGER_MASK, sonypi_joggerev },
24153 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_CAPTURE_MASK, sonypi_captureev },
24154 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
24155 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
24156 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_JOGGER_MASK, sonypi_joggerev },
24157 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x61, SONYPI_CAPTURE_MASK, sonypi_captureev },
24158 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
24159 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
24160         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev },
24161 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_BACK_MASK, sonypi_backev },
24162 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev },
24163         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_HELP_MASK, sonypi_helpev },
24164         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_ZOOM_MASK, sonypi_zoomev },
24165         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev },
24166 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
24167 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
24168 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev },
24169  
24170         { 0, 0, 0, 0 }
24171  };
24172 @@ -354,6 +367,7 @@
24173         u16 ioport1;
24174         u16 ioport2;
24175         u16 region_size;
24176 +       u16 evtype_offset;
24177         int camera_power;
24178         int bluetooth_power;
24179         struct semaphore lock;
24180 diff -Nru a/drivers/char/stallion.c b/drivers/char/stallion.c
24181 --- a/drivers/char/stallion.c   Wed Jul 30 04:37:51 2003
24182 +++ b/drivers/char/stallion.c   Sun Aug 24 05:39:23 2003
24183 @@ -3078,7 +3078,7 @@
24184                 (int) fp, cmd, (int) arg);
24185  #endif
24186  
24187 -       brdnr = minor(ip->i_rdev);
24188 +       brdnr = iminor(ip);
24189         if (brdnr >= STL_MAXBRDS)
24190                 return(-ENODEV);
24191         rc = 0;
24192 @@ -4234,7 +4234,7 @@
24193         misr = inb(ioaddr + EREG_DATA);
24194         if (misr & MISR_DCD) {
24195                 set_bit(ASYI_DCDCHANGE, &portp->istate);
24196 -               schedule_task(&portp->tqueue);
24197 +               schedule_work(&portp->tqueue);
24198                 portp->stats.modem++;
24199         }
24200  
24201 @@ -5031,7 +5031,7 @@
24202         if ((len == 0) || ((len < STL_TXBUFLOW) &&
24203             (test_bit(ASYI_TXLOW, &portp->istate) == 0))) {
24204                 set_bit(ASYI_TXLOW, &portp->istate);
24205 -               schedule_task(&portp->tqueue); 
24206 +               schedule_work(&portp->tqueue); 
24207         }
24208  
24209         if (len == 0) {
24210 @@ -5248,7 +5248,7 @@
24211                 ipr = stl_sc26198getreg(portp, IPR);
24212                 if (ipr & IPR_DCDCHANGE) {
24213                         set_bit(ASYI_DCDCHANGE, &portp->istate);
24214 -                       schedule_task(&portp->tqueue); 
24215 +                       schedule_work(&portp->tqueue); 
24216                         portp->stats.modem++;
24217                 }
24218                 break;
24219 diff -Nru a/drivers/char/tipar.c b/drivers/char/tipar.c
24220 --- a/drivers/char/tipar.c      Wed May  7 08:47:30 2003
24221 +++ b/drivers/char/tipar.c      Tue Aug 26 09:25:41 2003
24222 @@ -248,7 +248,7 @@
24223  static int
24224  tipar_open(struct inode *inode, struct file *file)
24225  {
24226 -       unsigned int minor = minor(inode->i_rdev) - TIPAR_MINOR;
24227 +       unsigned int minor = iminor(inode) - TIPAR_MINOR;
24228  
24229         if (minor > tp_count - 1)
24230                 return -ENXIO;
24231 @@ -266,7 +266,7 @@
24232  static int
24233  tipar_close(struct inode *inode, struct file *file)
24234  {
24235 -       unsigned int minor = minor(inode->i_rdev) - TIPAR_MINOR;
24236 +       unsigned int minor = iminor(inode) - TIPAR_MINOR;
24237  
24238         if (minor > tp_count - 1)
24239                 return -ENXIO;
24240 @@ -279,8 +279,7 @@
24241  static ssize_t
24242  tipar_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
24243  {
24244 -       unsigned int minor =
24245 -           minor(file->f_dentry->d_inode->i_rdev) - TIPAR_MINOR;
24246 +       unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
24247         ssize_t n;
24248  
24249         parport_claim_or_block(table[minor].dev);
24250 @@ -308,8 +307,7 @@
24251  tipar_read(struct file *file, char *buf, size_t count, loff_t * ppos)
24252  {
24253         int b = 0;
24254 -       unsigned int minor =
24255 -           minor(file->f_dentry->d_inode->i_rdev) - TIPAR_MINOR;
24256 +       unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
24257         ssize_t retval = 0;
24258         ssize_t n = 0;
24259  
24260 diff -Nru a/drivers/char/tpqic02.c b/drivers/char/tpqic02.c
24261 --- a/drivers/char/tpqic02.c    Wed May  7 08:47:30 2003
24262 +++ b/drivers/char/tpqic02.c    Tue Aug 26 09:25:41 2003
24263 @@ -169,7 +169,7 @@
24264  static volatile unsigned dma_mode;     /* !=0 also means DMA in use */
24265  static flag need_rewind = YES;
24266  
24267 -static kdev_t current_tape_dev;
24268 +static int current_type;
24269  static int extra_blocks_left = BLOCKS_BEYOND_EW;
24270  static struct timer_list tp_timer;
24271  
24272 @@ -677,7 +677,7 @@
24273          * exception flag from previous exception which we are trying to clear.
24274          */
24275  
24276 -       if (TP_DIAGS(current_tape_dev))
24277 +       if (TP_DIAGS(current_type))
24278                 printk(TPQIC02_NAME ": reading status bytes: ");
24279  
24280         for (q = stp; q < stp + size; q++) {
24281 @@ -693,7 +693,7 @@
24282  
24283                 *q = inb_p(QIC02_DATA_PORT);    /* read status byte */
24284  
24285 -               if (TP_DIAGS(current_tape_dev))
24286 +               if (TP_DIAGS(current_type))
24287                         printk("[%1d]=0x%x  ", q - stp, (unsigned) (*q) & 0xff);
24288  
24289                 outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);    /* set request */
24290 @@ -714,7 +714,7 @@
24291                 cpu_relax();
24292         /* wait for ready */
24293  
24294 -       if (TP_DIAGS(current_tape_dev))
24295 +       if (TP_DIAGS(current_type))
24296                 printk("\n");
24297  
24298         return TE_OK;
24299 @@ -1614,7 +1614,7 @@
24300  
24301         if (status_expect_int) {
24302  #ifdef WANT_EXTRA_FULL_DEBUGGING
24303 -               if (TP_DIAGS(current_tape_dev))
24304 +               if (TP_DIAGS(current_type))
24305                         printk("@");
24306  #endif
24307                 stat = inb(QIC02_STAT_PORT);    /* Knock, knock */
24308 @@ -1726,7 +1726,7 @@
24309  
24310  static ssize_t qic02_tape_read(struct file *filp, char *buf, size_t count, loff_t * ppos)
24311  {
24312 -       kdev_t dev = filp->f_dentry->d_inode->i_rdev;
24313 +       int type = iminor(filp->f_dentry->d_inode);
24314         unsigned short flags = filp->f_flags;
24315         unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
24316         int stat;
24317 @@ -1736,8 +1736,8 @@
24318                 return -ENXIO;
24319         }
24320  
24321 -       if (TP_DIAGS(current_tape_dev))
24322 -               printk(TPQIC02_NAME ": request READ, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n", minor(dev), buf,
24323 +       if (TP_DIAGS(current_type))
24324 +               printk(TPQIC02_NAME ": request READ, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n", type, buf,
24325                        (long) count, filp->f_pos, flags);
24326  
24327         if (count % TAPE_BLKSIZE) {     /* Only allow mod 512 bytes at a time. */
24328 @@ -1904,7 +1904,7 @@
24329   */
24330  static ssize_t qic02_tape_write(struct file *filp, const char *buf, size_t count, loff_t * ppos)
24331  {
24332 -       kdev_t dev = filp->f_dentry->d_inode->i_rdev;
24333 +       int type = iminor(filp->f_dentry->d_inode);
24334         unsigned short flags = filp->f_flags;
24335         unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
24336  
24337 @@ -1913,9 +1913,9 @@
24338                 return -ENXIO;
24339         }
24340  
24341 -       if (TP_DIAGS(current_tape_dev)) {
24342 +       if (TP_DIAGS(current_type)) {
24343                 printk(TPQIC02_NAME ": request WRITE, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n",
24344 -                      minor(dev), buf, (long) count, filp->f_pos, flags);
24345 +                      type, buf, (long) count, filp->f_pos, flags);
24346         }
24347  
24348         if (count % TAPE_BLKSIZE) {     /* only allow mod 512 bytes at a time */
24349 @@ -2070,17 +2070,18 @@
24350  static int qic02_tape_open_no_use_count(struct inode *inode,
24351                                         struct file *filp)
24352  {
24353 -       kdev_t dev = inode->i_rdev;
24354 +       int type = iminor(inode);
24355         unsigned short flags = filp->f_flags;
24356         unsigned short dens = 0;
24357         int s;
24358  
24359  
24360 -       if (TP_DIAGS(dev)) {
24361 -               printk("qic02_tape_open: dev=%s, flags=%x     ", cdevname(dev), flags);
24362 +       if (TP_DIAGS(type)) {
24363 +               printk("qic02_tape_open: dev=tpqic2(%d), flags=%x     ",
24364 +                       type, flags);
24365         }
24366  
24367 -       if (minor(dev) == 255) {        /* special case for resetting */
24368 +       if (type == 255) {      /* special case for resetting */
24369                 if (capable(CAP_SYS_ADMIN)) {
24370                         return (tape_reset(1) == TE_OK) ? -EAGAIN : -ENXIO;
24371                 } else {
24372 @@ -2162,7 +2163,7 @@
24373          */
24374  
24375         /* not allowed to do QCMD_DENS_* unless tape is rewound */
24376 -       if ((TP_DENS(dev) != 0) && (TP_DENS(current_tape_dev) != TP_DENS(dev))) {
24377 +       if ((TP_DENS(type) != 0) && (TP_DENS(current_type) != TP_DENS(type))) {
24378                 /* force rewind if minor bits have changed,
24379                  * i.e. user wants to use tape in different format.
24380                  * [assuming single drive operation]
24381 @@ -2175,7 +2176,7 @@
24382                 /* density bits still the same, but TP_DIAGS bit 
24383                  * may have changed.
24384                  */
24385 -               current_tape_dev = dev;
24386 +               current_type = type;
24387         }
24388  
24389         if (need_rewind == YES) {
24390 @@ -2212,14 +2213,14 @@
24391          * so we must have done a rewind by now. If not, just skip over.
24392          * Only give set density command when minor bits have changed.
24393          */
24394 -       if (TP_DENS(current_tape_dev) == TP_DENS(dev)) {
24395 +       if (TP_DENS(current_type) == TP_DENS(type)) {
24396                 return 0;
24397         }
24398  
24399 -       current_tape_dev = dev;
24400 +       current_type = type;
24401         need_rewind = NO;
24402         if (TP_HAVE_DENS) {
24403 -               dens = TP_DENS(dev);
24404 +               dens = TP_DENS(type);
24405         }
24406  
24407         if (dens < sizeof(format_names) / sizeof(char *))
24408 @@ -2227,7 +2228,7 @@
24409         else
24410                 tpqputs(TPQD_REWIND, "Wait for retensioning...");
24411  
24412 -       switch (TP_DENS(dev)) {
24413 +       switch (TP_DENS(type)) {
24414         case 0:         /* Minor 0 is for drives without set-density support */
24415                 s = 0;
24416                 break;
24417 @@ -2254,7 +2255,7 @@
24418         }
24419         if (s != 0) {
24420                 status_dead = YES;      /* force reset */
24421 -               current_tape_dev = NODEV;/* earlier 0xff80 */
24422 +               current_type = 0;/* earlier 0xff80 */
24423                 return -EIO;
24424         }
24425  
24426 @@ -2264,10 +2265,10 @@
24427  
24428  static int qic02_tape_release(struct inode *inode, struct file *filp)
24429  {
24430 -       kdev_t dev = inode->i_rdev;
24431 +       int type = iminor(inode);
24432  
24433 -       if (TP_DIAGS(dev)) {
24434 -               printk("qic02_tape_release: dev=%s\n", cdevname(dev));
24435 +       if (TP_DIAGS(type)) {
24436 +               printk("qic02_tape_release: dev=tpqic2(%d)\n", type);
24437         }
24438  
24439         if (status_zombie == NO) {      /* don't rewind in zombie mode */
24440 @@ -2283,7 +2284,7 @@
24441                 /* Rewind only if minor number requires it AND 
24442                  * read/writes have been done. ************* IS THIS CORRECT??????????
24443                  */
24444 -               if ((TP_REWCLOSE(dev)) && (status_bytes_rd | status_bytes_wr)) {
24445 +               if (TP_REWCLOSE(type) && (status_bytes_rd | status_bytes_wr)) {
24446                         tpqputs(TPQD_REWIND, "release: Doing rewind...");
24447                         (void) do_qic_cmd(QCMD_REWIND, TIM_R);
24448                 }
24449 @@ -2398,7 +2399,7 @@
24450         struct mtpos ioctl_tell;
24451  
24452  
24453 -       if (TP_DIAGS(current_tape_dev))
24454 +       if (TP_DIAGS(current_type))
24455                 printk(TPQIC02_NAME ": ioctl(%4x, %4lx)\n", iocmd, ioarg);
24456  
24457         if (!inode)
24458 @@ -2459,7 +2460,7 @@
24459                  * ---      tape at the beginning of the current file.
24460                  */
24461  
24462 -               if (TP_DIAGS(current_tape_dev))
24463 +               if (TP_DIAGS(current_type))
24464                         printk("OP op=%4x, count=%4x\n", operation.mt_op, operation.mt_count);
24465  
24466                 if (operation.mt_count < 0)
24467 @@ -2492,7 +2493,7 @@
24468                 return 0;
24469  
24470         } else if (c == _IOC_NR(MTIOCGET)) {
24471 -               if (TP_DIAGS(current_tape_dev))
24472 +               if (TP_DIAGS(current_type))
24473                         printk("GET ");
24474  
24475                 CHECK_IOC_SIZE(mtget);
24476 @@ -2507,7 +2508,7 @@
24477                         return -EFAULT;
24478                 return 0;
24479         } else if (TP_HAVE_TELL && (c == _IOC_NR(MTIOCPOS))) {
24480 -               if (TP_DIAGS(current_tape_dev))
24481 +               if (TP_DIAGS(current_type))
24482                         printk("POS ");
24483  
24484                 CHECK_IOC_SIZE(mtpos);
24485 @@ -2664,7 +2665,7 @@
24486                 return -ENODEV;
24487         }
24488  
24489 -       current_tape_dev = mk_kdev(QIC02_TAPE_MAJOR, 0);
24490 +       current_type = 0;
24491  
24492  #ifndef CONFIG_QIC02_DYNCONF
24493         printk(TPQIC02_NAME ": IRQ %d, DMA %d, IO 0x%x, IFC %s, %s, %s\n",
24494 diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
24495 --- a/drivers/char/tty_io.c     Fri Aug  1 02:22:20 2003
24496 +++ b/drivers/char/tty_io.c     Sun Aug 31 16:15:47 2003
24497 @@ -177,7 +177,7 @@
24498  
24499  EXPORT_SYMBOL(tty_name);
24500  
24501 -inline int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
24502 +inline int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
24503                               const char *routine)
24504  {
24505  #ifdef TTY_PARANOIA_CHECK
24506 @@ -187,11 +187,11 @@
24507                 "Warning: null TTY for (%s) in %s\n";
24508  
24509         if (!tty) {
24510 -               printk(badtty, cdevname(device), routine);
24511 +               printk(badtty, cdevname(inode->i_rdev), routine);
24512                 return 1;
24513         }
24514         if (tty->magic != TTY_MAGIC) {
24515 -               printk(badmagic, cdevname(device), routine);
24516 +               printk(badmagic, cdevname(inode->i_rdev), routine);
24517                 return 1;
24518         }
24519  #endif
24520 @@ -646,7 +646,7 @@
24521  
24522         tty = (struct tty_struct *)file->private_data;
24523         inode = file->f_dentry->d_inode;
24524 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_read"))
24525 +       if (tty_paranoia_check(tty, inode, "tty_read"))
24526                 return -EIO;
24527         if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags)))
24528                 return -EIO;
24529 @@ -763,7 +763,7 @@
24530         }
24531  
24532         tty = (struct tty_struct *)file->private_data;
24533 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_write"))
24534 +       if (tty_paranoia_check(tty, inode, "tty_write"))
24535                 return -EIO;
24536         if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags)))
24537                 return -EIO;
24538 @@ -1023,7 +1023,7 @@
24539                 o_tty->magic = 0;
24540                 o_tty->driver->refcount--;
24541                 file_list_lock();
24542 -               list_del(&o_tty->tty_files);
24543 +               list_del_init(&o_tty->tty_files);
24544                 file_list_unlock();
24545                 free_tty_struct(o_tty);
24546         }
24547 @@ -1037,7 +1037,7 @@
24548         tty->magic = 0;
24549         tty->driver->refcount--;
24550         file_list_lock();
24551 -       list_del(&tty->tty_files);
24552 +       list_del_init(&tty->tty_files);
24553         file_list_unlock();
24554         module_put(tty->driver->owner);
24555         free_tty_struct(tty);
24556 @@ -1059,7 +1059,7 @@
24557         char    buf[64];
24558         
24559         tty = (struct tty_struct *)filp->private_data;
24560 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "release_dev"))
24561 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "release_dev"))
24562                 return;
24563  
24564         check_tty_count(tty, "release_dev");
24565 @@ -1439,7 +1439,7 @@
24566         struct tty_struct * tty;
24567  
24568         tty = (struct tty_struct *)filp->private_data;
24569 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "tty_poll"))
24570 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "tty_poll"))
24571                 return 0;
24572  
24573         if (tty->ldisc.poll)
24574 @@ -1453,7 +1453,7 @@
24575         int retval;
24576  
24577         tty = (struct tty_struct *)filp->private_data;
24578 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "tty_fasync"))
24579 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "tty_fasync"))
24580                 return 0;
24581         
24582         retval = fasync_helper(fd, filp, on, &tty->fasync);
24583 @@ -1727,7 +1727,7 @@
24584         int retval;
24585         
24586         tty = (struct tty_struct *)file->private_data;
24587 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
24588 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
24589                 return -EINVAL;
24590  
24591         real_tty = tty;
24592 diff -Nru a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
24593 --- a/drivers/char/vc_screen.c  Wed May  7 08:47:30 2003
24594 +++ b/drivers/char/vc_screen.c  Tue Aug 26 09:25:41 2003
24595 @@ -49,7 +49,7 @@
24596  vcs_size(struct inode *inode)
24597  {
24598         int size;
24599 -       int minor = minor(inode->i_rdev);
24600 +       int minor = iminor(inode);
24601         int currcons = minor & 127;
24602         if (currcons == 0)
24603                 currcons = fg_console;
24604 @@ -104,7 +104,7 @@
24605  vcs_read(struct file *file, char *buf, size_t count, loff_t *ppos)
24606  {
24607         struct inode *inode = file->f_dentry->d_inode;
24608 -       unsigned int currcons = minor(inode->i_rdev);
24609 +       unsigned int currcons = iminor(inode);
24610         long pos = *ppos;
24611         long viewed, attr, read;
24612         int col, maxcol;
24613 @@ -273,7 +273,7 @@
24614  vcs_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
24615  {
24616         struct inode *inode = file->f_dentry->d_inode;
24617 -       unsigned int currcons = minor(inode->i_rdev);
24618 +       unsigned int currcons = iminor(inode);
24619         long pos = *ppos;
24620         long viewed, attr, size, written;
24621         char *con_buf0;
24622 @@ -456,7 +456,7 @@
24623  static int
24624  vcs_open(struct inode *inode, struct file *filp)
24625  {
24626 -       unsigned int currcons = minor(inode->i_rdev) & 127;
24627 +       unsigned int currcons = iminor(inode) & 127;
24628         if(currcons && !vc_cons_allocated(currcons-1))
24629                 return -ENXIO;
24630         return 0;
24631 diff -Nru a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
24632 --- a/drivers/char/watchdog/Kconfig     Mon Jul 28 13:28:55 2003
24633 +++ b/drivers/char/watchdog/Kconfig     Sun Aug 31 11:39:56 2003
24634 @@ -346,6 +346,18 @@
24635           module, say M here and read <file:Documentation/modules.txt>.  Most
24636           people will say N.
24637  
24638 +config ALIM1535_WDT
24639 +       tristate "ALi M1535 PMU Watchdog Timer"
24640 +       depends on WATCHDOG
24641 +       ---help---
24642 +         This is the driver for the hardware watchdog on the ALi M1535 PMU.
24643 +
24644 +         This driver is also available as a module ( = code which can be
24645 +         inserted in and removed from the running kernel whenever you want).
24646 +         The module is called alim1535_wdt.  If you want to compile it as a
24647 +         module, say M here and read <file:Documentation/modules.txt>.  Most
24648 +         people will say N.
24649 +
24650  config SC1200_WDT
24651         tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"
24652         depends on WATCHDOG
24653 diff -Nru a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
24654 --- a/drivers/char/watchdog/Makefile    Thu Feb 27 12:38:45 2003
24655 +++ b/drivers/char/watchdog/Makefile    Sun Aug 31 11:39:56 2003
24656 @@ -27,6 +27,7 @@
24657  obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
24658  obj-$(CONFIG_SC520_WDT) += sc520_wdt.o
24659  obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o
24660 +obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o
24661  obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
24662  obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
24663  obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
24664 diff -Nru a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c
24665 --- a/drivers/char/watchdog/acquirewdt.c        Fri Aug  8 03:28:08 2003
24666 +++ b/drivers/char/watchdog/acquirewdt.c        Sun Aug 31 14:15:12 2003
24667 @@ -1,5 +1,5 @@
24668  /*
24669 - *     Acquire Single Board Computer Watchdog Timer driver for Linux 2.1.x
24670 + *     Acquire Single Board Computer Watchdog Timer driver
24671   *
24672   *      Based on wdt.c. Original copyright messages:
24673   *
24674 @@ -10,10 +10,10 @@
24675   *     modify it under the terms of the GNU General Public License
24676   *     as published by the Free Software Foundation; either version
24677   *     2 of the License, or (at your option) any later version.
24678 - *     
24679 - *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
24680 - *     warranty for any of this software. This material is provided 
24681 - *     "AS-IS" and at no charge.       
24682 + *
24683 + *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
24684 + *     warranty for any of this software. This material is provided
24685 + *     "AS-IS" and at no charge.
24686   *
24687   *     (c) Copyright 1995    Alan Cox <alan@redhat.com>
24688   *
24689 @@ -22,33 +22,39 @@
24690   *          Can't add timeout - driver doesn't allow changing value
24691   */
24692  
24693 -#include <linux/config.h>
24694  #include <linux/module.h>
24695  #include <linux/moduleparam.h>
24696  #include <linux/types.h>
24697  #include <linux/miscdevice.h>
24698  #include <linux/watchdog.h>
24699 +#include <linux/fs.h>
24700  #include <linux/ioport.h>
24701  #include <linux/notifier.h>
24702 -#include <linux/fs.h>
24703  #include <linux/reboot.h>
24704  #include <linux/init.h>
24705 -#include <linux/spinlock.h>
24706  
24707  #include <asm/io.h>
24708  #include <asm/uaccess.h>
24709  #include <asm/system.h>
24710  
24711 -static int acq_is_open;
24712 -static spinlock_t acq_lock;
24713 -static int expect_close = 0;
24714 +#define WATCHDOG_NAME "Acquire WDT"
24715 +#define PFX WATCHDOG_NAME ": "
24716 +#define WATCHDOG_TIMEOUT 0     /* ??? Is the timeout hardcoded to 1 minute ??? */
24717 +
24718 +static unsigned long acq_is_open;
24719 +static char expect_close;
24720  
24721  /*
24722   *     You must set these - there is no sane way to probe for this board.
24723   */
24724
24725 -#define WDT_STOP 0x43
24726 -#define WDT_START 0x443
24727 +
24728 +static int wdt_stop = 0x43;
24729 +module_param(wdt_stop, int, 0);
24730 +MODULE_PARM_DESC(wdt_stop, "Acquire WDT 'stop' io port (default 0x43)");
24731 +
24732 +static int wdt_start = 0x443;
24733 +module_param(wdt_start, int, 0);
24734 +MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)");
24735  
24736  #ifdef CONFIG_WATCHDOG_NOWAYOUT
24737  static int nowayout = 1;
24738 @@ -62,38 +68,52 @@
24739  /*
24740   *     Kernel methods.
24741   */
24742
24743  
24744  static void acq_ping(void)
24745  {
24746         /* Write a watchdog value */
24747 -       inb_p(WDT_START);
24748 +       inb_p(wdt_start);
24749  }
24750  
24751 +static void acq_stop(void)
24752 +{
24753 +       /* Turn the card off */
24754 +       inb_p(wdt_stop);
24755 +}
24756 +
24757 +/*
24758 + *     /dev/watchdog handling.
24759 + */
24760 +
24761  static ssize_t acq_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
24762  {
24763         /*  Can't seek (pwrite) on this device  */
24764         if (ppos != &file->f_pos)
24765                 return -ESPIPE;
24766  
24767 +       /* See if we got the magic character 'V' and reload the timer */
24768         if(count) {
24769                 if (!nowayout) {
24770                         size_t i;
24771  
24772 +                       /* note: just in case someone wrote the magic character
24773 +                        * five months ago... */
24774                         expect_close = 0;
24775  
24776 +                       /* scan to see wether or not we got the magic character */
24777                         for (i = 0; i != count; i++) {
24778                                 char c;
24779                                 if (get_user(c, buf + i))
24780                                         return -EFAULT;
24781                                 if (c == 'V')
24782 -                                       expect_close = 1;
24783 +                                       expect_close = 42;
24784                         }
24785                 }
24786 +
24787 +               /* Well, anyhow someone wrote to us, we should return that favour */
24788                 acq_ping();
24789 -               return 1;
24790         }
24791 -       return 0;
24792 +       return count;
24793  }
24794  
24795  static int acq_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
24796 @@ -103,65 +123,75 @@
24797         {
24798                 .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
24799                 .firmware_version = 1,
24800 -               .identity = "Acquire WDT"
24801 +               .identity = "Acquire WDT",
24802         };
24803 -       
24804 +
24805         switch(cmd)
24806         {
24807         case WDIOC_GETSUPPORT:
24808 -         if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
24809 -           return -EFAULT;
24810 -         break;
24811 -         
24812 +         return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)) ? -EFAULT : 0;
24813 +
24814         case WDIOC_GETSTATUS:
24815 -         if (copy_to_user((int *)arg, &acq_is_open,  sizeof(int)))
24816 -           return -EFAULT;
24817 -         break;
24818 +       case WDIOC_GETBOOTSTATUS:
24819 +         return put_user(0, (int *)arg);
24820  
24821         case WDIOC_KEEPALIVE:
24822           acq_ping();
24823 -         break;
24824 +         return 0;
24825 +
24826 +       case WDIOC_GETTIMEOUT:
24827 +         return put_user(WATCHDOG_TIMEOUT, (int *)arg);
24828 +
24829 +       case WDIOC_SETOPTIONS:
24830 +       {
24831 +           int options, retval = -EINVAL;
24832 +
24833 +           if (get_user(options, (int *)arg))
24834 +             return -EFAULT;
24835 +
24836 +           if (options & WDIOS_DISABLECARD)
24837 +           {
24838 +             acq_stop();
24839 +             retval = 0;
24840 +           }
24841 +
24842 +           if (options & WDIOS_ENABLECARD)
24843 +           {
24844 +             acq_ping();
24845 +             retval = 0;
24846 +           }
24847 +
24848 +           return retval;
24849 +       }
24850  
24851         default:
24852 -         return -ENOTTY;
24853 +         return -ENOIOCTLCMD;
24854         }
24855 -       return 0;
24856  }
24857  
24858  static int acq_open(struct inode *inode, struct file *file)
24859  {
24860 -       if ((minor(inode->i_rdev) == WATCHDOG_MINOR)) {
24861 -               spin_lock(&acq_lock);
24862 -               if(acq_is_open) {
24863 -                       spin_unlock(&acq_lock);
24864 -                       return -EBUSY;
24865 -               }
24866 -               if (nowayout)
24867 -                       __module_get(THIS_MODULE);
24868 +       if (test_and_set_bit(0, &acq_is_open))
24869 +               return -EBUSY;
24870  
24871 -               /* Activate */
24872 -               acq_is_open=1;
24873 -               inb_p(WDT_START);      
24874 -               spin_unlock(&acq_lock);
24875 -               return 0;
24876 +       if (nowayout)
24877 +               __module_get(THIS_MODULE);
24878  
24879 -       } else {
24880 -               return -ENODEV;
24881 -       }
24882 +       /* Activate */
24883 +       acq_ping();
24884 +       return 0;
24885  }
24886  
24887  static int acq_close(struct inode *inode, struct file *file)
24888  {
24889 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR) {
24890 -               spin_lock(&acq_lock);
24891 -               if (expect_close)
24892 -                       inb_p(WDT_STOP);
24893 -               else
24894 -                       printk(KERN_CRIT "WDT closed unexpectedly.  WDT will not stop!\n");
24895 -
24896 -               acq_is_open=0;
24897 -               spin_unlock(&acq_lock);
24898 +       if (expect_close == 42) {
24899 +               acq_stop();
24900 +       } else {
24901 +               printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
24902 +               acq_ping();
24903         }
24904 +       clear_bit(0, &acq_is_open);
24905 +       expect_close = 0;
24906         return 0;
24907  }
24908  
24909 @@ -172,20 +202,20 @@
24910  static int acq_notify_sys(struct notifier_block *this, unsigned long code,
24911         void *unused)
24912  {
24913 -       if(code==SYS_DOWN || code==SYS_HALT)
24914 -               /* Turn the card off */
24915 -               inb_p(WDT_STOP);
24916 -
24917 +       if(code==SYS_DOWN || code==SYS_HALT) {
24918 +               /* Turn the WDT off */
24919 +               acq_stop();
24920 +       }
24921         return NOTIFY_DONE;
24922  }
24923
24924 +
24925  /*
24926   *     Kernel Interfaces
24927   */
24928
24929
24930 +
24931  static struct file_operations acq_fops = {
24932         .owner          = THIS_MODULE,
24933 +       .llseek         = no_llseek,
24934         .write          = acq_write,
24935         .ioctl          = acq_ioctl,
24936         .open           = acq_open,
24937 @@ -196,52 +226,84 @@
24938  {
24939         .minor = WATCHDOG_MINOR,
24940         .name = "watchdog",
24941 -       .fops = &acq_fops
24942 +       .fops = &acq_fops,
24943  };
24944  
24945 -
24946  /*
24947   *     The WDT card needs to learn about soft shutdowns in order to
24948 - *     turn the timebomb registers off. 
24949 + *     turn the timebomb registers off.
24950   */
24951
24952 +
24953  static struct notifier_block acq_notifier =
24954  {
24955         .notifier_call = acq_notify_sys,
24956         .next = NULL,
24957 -       .priority = 0
24958 +       .priority = 0,
24959  };
24960  
24961  static int __init acq_init(void)
24962  {
24963 +       int ret;
24964 +
24965         printk(KERN_INFO "WDT driver for Acquire single board computer initialising.\n");
24966  
24967 -       spin_lock_init(&acq_lock);
24968 -       if (misc_register(&acq_miscdev))
24969 -               return -ENODEV;
24970 -       if (!request_region(WDT_STOP, 1, "Acquire WDT")) {
24971 -               misc_deregister(&acq_miscdev);
24972 -               return -EIO;
24973 -       }
24974 -       if (!request_region(WDT_START, 1, "Acquire WDT")) {
24975 -               release_region(WDT_STOP, 1);
24976 -               misc_deregister(&acq_miscdev);
24977 -               return -EIO;
24978 +       if (wdt_stop != wdt_start) {
24979 +               if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
24980 +                       printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
24981 +                               wdt_stop);
24982 +                       ret = -EIO;
24983 +                       goto out;
24984 +               }
24985         }
24986  
24987 -       register_reboot_notifier(&acq_notifier);
24988 -       return 0;
24989 +       if (!request_region(wdt_start, 1, WATCHDOG_NAME)) {
24990 +               printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
24991 +                       wdt_start);
24992 +               ret = -EIO;
24993 +               goto unreg_stop;
24994 +       }
24995 +
24996 +        ret = register_reboot_notifier(&acq_notifier);
24997 +        if (ret != 0) {
24998 +                printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
24999 +                        ret);
25000 +                goto unreg_regions;
25001 +        }
25002 +                                                                                                 
25003 +        ret = misc_register(&acq_miscdev);
25004 +        if (ret != 0) {
25005 +                printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
25006 +                        WATCHDOG_MINOR, ret);
25007 +                goto unreg_reboot;
25008 +        }
25009 +                                                                                                 
25010 +        printk (KERN_INFO PFX "initialized. (nowayout=%d)\n",
25011 +                nowayout);
25012 +                                                                                                 
25013 +out:
25014 +        return ret;
25015 +unreg_reboot:
25016 +        unregister_reboot_notifier(&acq_notifier);
25017 +unreg_regions:
25018 +        release_region(wdt_start, 1);
25019 +unreg_stop:
25020 +        if (wdt_stop != wdt_start)
25021 +                release_region(wdt_stop, 1);
25022 +        goto out;
25023  }
25024 -       
25025 +
25026  static void __exit acq_exit(void)
25027  {
25028         misc_deregister(&acq_miscdev);
25029         unregister_reboot_notifier(&acq_notifier);
25030 -       release_region(WDT_STOP,1);
25031 -       release_region(WDT_START,1);
25032 +       if(wdt_stop != wdt_start)
25033 +               release_region(wdt_stop,1);
25034 +       release_region(wdt_start,1);
25035  }
25036  
25037  module_init(acq_init);
25038  module_exit(acq_exit);
25039  
25040  MODULE_LICENSE("GPL");
25041 +MODULE_AUTHOR("Unkown");
25042 +MODULE_DESCRIPTION("Acquire Single Board Computer Watchdog Timer driver");
25043 diff -Nru a/drivers/char/watchdog/advantechwdt.c b/drivers/char/watchdog/advantechwdt.c
25044 --- a/drivers/char/watchdog/advantechwdt.c      Sat Aug  9 07:00:04 2003
25045 +++ b/drivers/char/watchdog/advantechwdt.c      Sat Aug 30 04:48:19 2003
25046 @@ -133,7 +133,7 @@
25047         static struct watchdog_info ident = {
25048                 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
25049                 .firmware_version = 1,
25050 -               .identity = "Advantech WDT"
25051 +               .identity = "Advantech WDT",
25052         };
25053  
25054         switch (cmd) {
25055 diff -Nru a/drivers/char/watchdog/alim1535_wdt.c b/drivers/char/watchdog/alim1535_wdt.c
25056 --- /dev/null   Wed Dec 31 16:00:00 1969
25057 +++ b/drivers/char/watchdog/alim1535_wdt.c      Sun Aug 31 11:38:01 2003
25058 @@ -0,0 +1,465 @@
25059 +/*
25060 + *     Watchdog for the 7101 PMU version found in the ALi M1535 chipsets
25061 + *
25062 + *     This program is free software; you can redistribute it and/or
25063 + *     modify it under the terms of the GNU General Public License
25064 + *     as published by the Free Software Foundation; either version
25065 + *     2 of the License, or (at your option) any later version.
25066 + */
25067 +
25068 +#include <linux/module.h>
25069 +#include <linux/moduleparam.h>
25070 +#include <linux/types.h>
25071 +#include <linux/miscdevice.h>
25072 +#include <linux/watchdog.h>
25073 +#include <linux/ioport.h>
25074 +#include <linux/notifier.h>
25075 +#include <linux/reboot.h>
25076 +#include <linux/init.h>
25077 +#include <linux/pci.h>
25078 +
25079 +#include <asm/uaccess.h>
25080 +#include <asm/io.h>
25081 +
25082 +#define WATCHDOG_NAME "ALi_M1535"
25083 +#define PFX WATCHDOG_NAME ": "
25084 +#define WATCHDOG_TIMEOUT 60    /* 60 sec default timeout */
25085 +
25086 +/* internal variables */
25087 +static unsigned long ali_is_open;
25088 +static char ali_expect_release;
25089 +static struct pci_dev *ali_pci;
25090 +static u32 ali_timeout_bits;   /* stores the computed timeout */
25091 +static spinlock_t ali_lock;    /* Guards the hardware */
25092 +
25093 +/* module parameters */
25094 +static int timeout = WATCHDOG_TIMEOUT;
25095 +module_param(timeout, int, 0);
25096 +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (0<timeout<18000, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
25097 +
25098 +#ifdef CONFIG_WATCHDOG_NOWAYOUT
25099 +static int nowayout = 1;
25100 +#else
25101 +static int nowayout = 0;
25102 +#endif
25103 +
25104 +module_param(nowayout, int, 0);
25105 +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
25106 +
25107 +/*
25108 + *     ali_start       -       start watchdog countdown
25109 + *
25110 + *     Starts the timer running providing the timer has a counter
25111 + *     configuration set.
25112 + */
25113 +
25114 +static void ali_start(void)
25115 +{
25116 +       u32 val;
25117 +
25118 +       spin_lock(&ali_lock);
25119 +
25120 +       pci_read_config_dword(ali_pci, 0xCC, &val);
25121 +       val &= ~0x3F;   /* Mask count */
25122 +       val |= (1<<25) | ali_timeout_bits;
25123 +       pci_write_config_dword(ali_pci, 0xCC, val);
25124 +
25125 +       spin_unlock(&ali_lock);
25126 +}
25127 +
25128 +/*
25129 + *     ali_stop        -       stop the timer countdown
25130 + *
25131 + *     Stop the ALi watchdog countdown
25132 + */
25133 +
25134 +static void ali_stop(void)
25135 +{
25136 +       u32 val;
25137 +
25138 +       spin_lock(&ali_lock);
25139 +
25140 +       pci_read_config_dword(ali_pci, 0xCC, &val);
25141 +       val &= ~0x3F;   /* Mask count to zero (disabled) */
25142 +       val &= ~(1<<25);/* and for safety mask the reset enable */
25143 +       pci_write_config_dword(ali_pci, 0xCC, val);
25144 +
25145 +       spin_unlock(&ali_lock);
25146 +}
25147 +
25148 +/*
25149 + *     ali_keepalive   -       send a keepalive to the watchdog
25150 + *
25151 + *      Send a keepalive to the timer (actually we restart the timer).
25152 + */
25153 +
25154 +static void ali_keepalive(void)
25155 +{
25156 +       ali_start();
25157 +}
25158 +
25159 +/*
25160 + *     ali_settimer    -       compute the timer reload value
25161 + *     @t: time in seconds
25162 + *
25163 + *     Computes the timeout values needed
25164 + */
25165 +
25166 +static int ali_settimer(int t)
25167 +{
25168 +       if(t < 0)
25169 +               return -EINVAL;
25170 +       else if(t < 60)
25171 +               ali_timeout_bits = t|(1<<6);
25172 +       else if(t < 3600)
25173 +               ali_timeout_bits = (t/60)|(1<<7);
25174 +       else if(t < 18000)
25175 +               ali_timeout_bits = (t/300)|(1<<6)|(1<<7);
25176 +       else return -EINVAL;
25177 +
25178 +       timeout = t;
25179 +       return 0;
25180 +}
25181 +
25182 +/*
25183 + *     /dev/watchdog handling
25184 + */
25185 +
25186 +/*
25187 + *     ali_write       -       writes to ALi watchdog
25188 + *     @file: file from VFS
25189 + *     @data: user address of data
25190 + *     @len: length of data
25191 + *     @ppos: pointer to the file offset
25192 + *
25193 + *     Handle a write to the ALi watchdog. Writing to the file pings
25194 + *     the watchdog and resets it. Writing the magic 'V' sequence allows
25195 + *     the next close to turn off the watchdog.
25196 + */
25197 +
25198 +static ssize_t ali_write(struct file *file, const char *data,
25199 +                             size_t len, loff_t * ppos)
25200 +{
25201 +       /*  Can't seek (pwrite) on this device  */
25202 +       if (ppos != &file->f_pos)
25203 +               return -ESPIPE;
25204 +
25205 +       /* See if we got the magic character 'V' and reload the timer */
25206 +       if (len) {
25207 +               if (!nowayout) {
25208 +                       size_t i;
25209 +
25210 +                       /* note: just in case someone wrote the magic character
25211 +                        * five months ago... */
25212 +                       ali_expect_release = 0;
25213 +
25214 +                       /* scan to see wether or not we got the magic character */
25215 +                       for (i = 0; i != len; i++) {
25216 +                               char c;
25217 +                               if(get_user(c, data+i))
25218 +                                       return -EFAULT;
25219 +                               if (c == 'V')
25220 +                                       ali_expect_release = 42;
25221 +                       }
25222 +               }
25223 +
25224 +               /* someone wrote to us, we should reload the timer */
25225 +               ali_start();
25226 +       }
25227 +       return len;
25228 +}
25229 +
25230 +/*
25231 + *     ali_ioctl       -       handle watchdog ioctls
25232 + *     @inode: VFS inode
25233 + *     @file: VFS file pointer
25234 + *     @cmd: ioctl number
25235 + *     @arg: arguments to the ioctl
25236 + *
25237 + *     Handle the watchdog ioctls supported by the ALi driver. Really
25238 + *     we want an extension to enable irq ack monitoring and the like
25239 + */
25240 +
25241 +static int ali_ioctl(struct inode *inode, struct file *file,
25242 +                         unsigned int cmd, unsigned long arg)
25243 +{
25244 +       static struct watchdog_info ident = {
25245 +               .options =              WDIOF_KEEPALIVEPING |
25246 +                                       WDIOF_SETTIMEOUT |
25247 +                                       WDIOF_MAGICCLOSE,
25248 +               .firmware_version =     0,
25249 +               .identity =             "ALi M1535 WatchDog Timer",
25250 +       };
25251 +
25252 +       switch (cmd) {
25253 +               case WDIOC_GETSUPPORT:
25254 +                       return copy_to_user((struct watchdog_info *) arg, &ident,
25255 +                               sizeof (ident)) ? -EFAULT : 0;
25256 +
25257 +               case WDIOC_GETSTATUS:
25258 +               case WDIOC_GETBOOTSTATUS:
25259 +                       return put_user(0, (int *) arg);
25260 +
25261 +               case WDIOC_KEEPALIVE:
25262 +                       ali_keepalive();
25263 +                       return 0;
25264 +
25265 +               case WDIOC_SETOPTIONS:
25266 +               {
25267 +                       int new_options, retval = -EINVAL;
25268 +
25269 +                       if (get_user (new_options, (int *) arg))
25270 +                               return -EFAULT;
25271 +
25272 +                       if (new_options & WDIOS_DISABLECARD) {
25273 +                               ali_stop();
25274 +                               retval = 0;
25275 +                       }
25276 +
25277 +                       if (new_options & WDIOS_ENABLECARD) {
25278 +                               ali_start();
25279 +                               retval = 0;
25280 +                       }
25281 +
25282 +                       return retval;
25283 +               }
25284 +
25285 +               case WDIOC_SETTIMEOUT:
25286 +               {
25287 +                       int new_timeout;
25288 +
25289 +                       if (get_user(new_timeout, (int *) arg))
25290 +                               return -EFAULT;
25291 +
25292 +                       if (ali_settimer(new_timeout))
25293 +                           return -EINVAL;
25294 +
25295 +                       ali_keepalive();
25296 +                       /* Fall */
25297 +               }
25298 +
25299 +               case WDIOC_GETTIMEOUT:
25300 +                       return put_user(timeout, (int *)arg);
25301 +
25302 +               default:
25303 +                       return -ENOIOCTLCMD;
25304 +       }
25305 +}
25306 +
25307 +/*
25308 + *     ali_open        -       handle open of ali watchdog
25309 + *     @inode: inode from VFS
25310 + *     @file: file from VFS
25311 + *
25312 + *     Open the ALi watchdog device. Ensure only one person opens it
25313 + *     at a time. Also start the watchdog running.
25314 + */
25315 +
25316 +static int ali_open(struct inode *inode, struct file *file)
25317 +{
25318 +       /* /dev/watchdog can only be opened once */
25319 +       if (test_and_set_bit(0, &ali_is_open))
25320 +               return -EBUSY;
25321 +
25322 +       /* Activate */
25323 +       ali_start();
25324 +       return 0;
25325 +}
25326 +
25327 +/*
25328 + *     ali_release     -       close an ALi watchdog
25329 + *     @inode: inode from VFS
25330 + *     @file: file from VFS
25331 + *
25332 + *     Close the ALi watchdog device. Actual shutdown of the timer
25333 + *     only occurs if the magic sequence has been set.
25334 + */
25335 +
25336 +static int ali_release(struct inode *inode, struct file *file)
25337 +{
25338 +       /*
25339 +        *      Shut off the timer.
25340 +        */
25341 +       if (ali_expect_release == 42) {
25342 +               ali_stop();
25343 +       } else {
25344 +               printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
25345 +               ali_keepalive();
25346 +       }
25347 +       clear_bit(0, &ali_is_open);
25348 +       ali_expect_release = 0;
25349 +       return 0;
25350 +}
25351 +
25352 +/*
25353 + *     ali_notify_sys  -       System down notifier
25354 + *
25355 + *     Notifier for system down
25356 + */
25357 +
25358 +
25359 +static int ali_notify_sys(struct notifier_block *this, unsigned long code, void *unused)
25360 +{
25361 +       if (code==SYS_DOWN || code==SYS_HALT) {
25362 +               /* Turn the WDT off */
25363 +               ali_stop();
25364 +       }
25365 +
25366 +       return NOTIFY_DONE;
25367 +}
25368 +
25369 +/*
25370 + *     Data for PCI driver interface
25371 + *
25372 + *     This data only exists for exporting the supported
25373 + *     PCI ids via MODULE_DEVICE_TABLE.  We do not actually
25374 + *     register a pci_driver, because someone else might one day
25375 + *     want to register another driver on the same PCI id.
25376 + */
25377 +
25378 +static struct pci_device_id ali_pci_tbl[] __initdata = {
25379 +       { PCI_VENDOR_ID_AL, 1535, PCI_ANY_ID, PCI_ANY_ID,},
25380 +       { 0, },
25381 +};
25382 +MODULE_DEVICE_TABLE(pci, ali_pci_tbl);
25383 +
25384 +/*
25385 + *     ali_find_watchdog       -       find a 1535 and 7101
25386 + *
25387 + *     Scans the PCI hardware for a 1535 series bridge and matching 7101
25388 + *     watchdog device. This may be overtight but it is better to be safe
25389 + */
25390 +
25391 +static int __init ali_find_watchdog(void)
25392 +{
25393 +       struct pci_dev *pdev;
25394 +       u32 wdog;
25395 +
25396 +       /* Check for a 1535 series bridge */
25397 +       pdev = pci_find_device(PCI_VENDOR_ID_AL, 0x1535, NULL);
25398 +       if(pdev == NULL)
25399 +               return -ENODEV;
25400 +
25401 +       /* Check for the a 7101 PMU */
25402 +       pdev = pci_find_device(PCI_VENDOR_ID_AL, 0x7101, NULL);
25403 +       if(pdev == NULL)
25404 +               return -ENODEV;
25405 +
25406 +       if(pci_enable_device(pdev))
25407 +               return -EIO;
25408 +
25409 +       ali_pci = pdev;
25410 +
25411 +       /*
25412 +        *      Initialize the timer bits
25413 +        */
25414 +       pci_read_config_dword(pdev, 0xCC, &wdog);
25415 +
25416 +       wdog &= ~0x3F;          /* Timer bits */
25417 +       wdog &= ~((1<<27)|(1<<26)|(1<<25)|(1<<24));     /* Issued events */
25418 +       wdog &= ~((1<<16)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9));      /* No monitor bits */
25419 +
25420 +       pci_write_config_dword(pdev, 0xCC, wdog);
25421 +
25422 +       return 0;
25423 +}
25424 +
25425 +/*
25426 + *     Kernel Interfaces
25427 + */
25428 +
25429 +static struct file_operations ali_fops = {
25430 +       .owner =        THIS_MODULE,
25431 +       .llseek =       no_llseek,
25432 +       .write =        ali_write,
25433 +       .ioctl =        ali_ioctl,
25434 +       .open =         ali_open,
25435 +       .release =      ali_release,
25436 +};
25437 +
25438 +static struct miscdevice ali_miscdev = {
25439 +       .minor =        WATCHDOG_MINOR,
25440 +       .name =         "watchdog",
25441 +       .fops =         &ali_fops,
25442 +};
25443 +
25444 +static struct notifier_block ali_notifier = {
25445 +       .notifier_call =        ali_notify_sys,
25446 +       .next =                 NULL,
25447 +       .priority =             0,
25448 +};
25449 +
25450 +/*
25451 + *     watchdog_init   -       module initialiser
25452 + *
25453 + *     Scan for a suitable watchdog and if so initialize it. Return an error
25454 + *     if we cannot, the error causes the module to unload
25455 + */
25456 +
25457 +static int __init watchdog_init(void)
25458 +{
25459 +       int ret;
25460 +
25461 +       spin_lock_init(&ali_lock);
25462 +
25463 +       /* Check wether or not the hardware watchdog is there */
25464 +       if (ali_find_watchdog() != 0) {
25465 +               return -ENODEV;
25466 +       }
25467 +
25468 +       /* Check that the timeout value is within it's range ; if not reset to the default */
25469 +       if (timeout < 1 || timeout >= 18000) {
25470 +               timeout = WATCHDOG_TIMEOUT;
25471 +               printk(KERN_INFO PFX "timeout value must be 0<timeout<18000, using %d\n",
25472 +                       timeout);
25473 +       }
25474 +
25475 +       /* Calculate the watchdog's timeout */
25476 +       ali_settimer(timeout);
25477 +
25478 +       ret = misc_register(&ali_miscdev);
25479 +       if (ret != 0) {
25480 +               printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
25481 +                       WATCHDOG_MINOR, ret);
25482 +               goto out;
25483 +       }
25484 +
25485 +       ret = register_reboot_notifier(&ali_notifier);
25486 +       if (ret != 0) {
25487 +               printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
25488 +                       ret);
25489 +               goto unreg_miscdev;
25490 +       }
25491 +
25492 +       printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
25493 +               timeout, nowayout);
25494 +
25495 +out:
25496 +       return ret;
25497 +unreg_miscdev:
25498 +       misc_deregister(&ali_miscdev);
25499 +       goto out;
25500 +}
25501 +
25502 +/*
25503 + *     watchdog_exit   -       module de-initialiser
25504 + *
25505 + *     Called while unloading a successfully installed watchdog module.
25506 + */
25507 +
25508 +static void __exit watchdog_exit(void)
25509 +{
25510 +       /* Stop the timer before we leave */
25511 +       ali_stop();
25512 +
25513 +       /* Deregister */
25514 +       unregister_reboot_notifier(&ali_notifier);
25515 +       misc_deregister(&ali_miscdev);
25516 +}
25517 +
25518 +module_init(watchdog_init);
25519 +module_exit(watchdog_exit);
25520 +
25521 +MODULE_AUTHOR("Alan Cox");
25522 +MODULE_DESCRIPTION("ALi M1535 PMU Watchdog Timer driver");
25523 +MODULE_LICENSE("GPL");
25524 diff -Nru a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c
25525 --- a/drivers/char/watchdog/cpu5wdt.c   Thu Feb 13 06:54:43 2003
25526 +++ b/drivers/char/watchdog/cpu5wdt.c   Tue Aug 26 09:25:41 2003
25527 @@ -134,7 +134,7 @@
25528  
25529  static int cpu5wdt_open(struct inode *inode, struct file *file)
25530  {
25531 -       switch(minor(inode->i_rdev)) {
25532 +       switch(iminor(inode)) {
25533                 case WATCHDOG_MINOR:
25534                         if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
25535                                 return -EBUSY;
25536 @@ -148,7 +148,7 @@
25537  
25538  static int cpu5wdt_release(struct inode *inode, struct file *file)
25539  {
25540 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR) {
25541 +       if(iminor(inode)==WATCHDOG_MINOR) {
25542                 clear_bit(0, &cpu5wdt_device.inuse);
25543         }
25544         return 0;
25545 diff -Nru a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c
25546 --- a/drivers/char/watchdog/ib700wdt.c  Fri Aug  8 03:28:08 2003
25547 +++ b/drivers/char/watchdog/ib700wdt.c  Tue Aug 26 09:25:41 2003
25548 @@ -218,7 +218,7 @@
25549  static int
25550  ibwdt_open(struct inode *inode, struct file *file)
25551  {
25552 -       if (minor(inode->i_rdev) == WATCHDOG_MINOR) {
25553 +       if (iminor(inode) == WATCHDOG_MINOR) {
25554                 spin_lock(&ibwdt_lock);
25555                 if (ibwdt_is_open) {
25556                         spin_unlock(&ibwdt_lock);
25557 @@ -240,7 +240,7 @@
25558  static int
25559  ibwdt_close(struct inode *inode, struct file *file)
25560  {
25561 -       if (minor(inode->i_rdev) == WATCHDOG_MINOR) {
25562 +       if (iminor(inode) == WATCHDOG_MINOR) {
25563                 spin_lock(&ibwdt_lock);
25564                 if (expect_close)
25565                         outb_p(wd_times[wd_margin], WDT_STOP);
25566 diff -Nru a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c
25567 --- a/drivers/char/watchdog/machzwd.c   Fri Aug  8 03:28:08 2003
25568 +++ b/drivers/char/watchdog/machzwd.c   Tue Aug 26 09:25:41 2003
25569 @@ -377,7 +377,7 @@
25570  
25571  static int zf_open(struct inode *inode, struct file *file)
25572  {
25573 -       switch(minor(inode->i_rdev)){
25574 +       switch(iminor(inode)){
25575                 case WATCHDOG_MINOR:
25576                         spin_lock(&zf_lock);
25577                         if(zf_is_open){
25578 @@ -402,7 +402,7 @@
25579  
25580  static int zf_close(struct inode *inode, struct file *file)
25581  {
25582 -       if(minor(inode->i_rdev) == WATCHDOG_MINOR){
25583 +       if(iminor(inode) == WATCHDOG_MINOR){
25584  
25585                 if(zf_expect_close){
25586                         zf_timer_off();
25587 diff -Nru a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c
25588 --- a/drivers/char/watchdog/pcwd.c      Fri Aug  1 03:02:31 2003
25589 +++ b/drivers/char/watchdog/pcwd.c      Tue Aug 26 09:25:41 2003
25590 @@ -426,7 +426,7 @@
25591  
25592  static int pcwd_open(struct inode *ino, struct file *filep)
25593  {
25594 -       switch (minor(ino->i_rdev)) {
25595 +       switch (iminor(ino)) {
25596         case WATCHDOG_MINOR:
25597                 if (!atomic_dec_and_test(&open_allowed) ) {
25598                         atomic_inc( &open_allowed );
25599 @@ -457,7 +457,7 @@
25600         /*  Can't seek (pread) on this device  */
25601         if (ppos != &file->f_pos)
25602                 return -ESPIPE;
25603 -       switch(minor(file->f_dentry->d_inode->i_rdev)) 
25604 +       switch(iminor(file->f_dentry->d_inode)) 
25605         {
25606                 case TEMP_MINOR:
25607                         /*
25608 @@ -477,7 +477,7 @@
25609  
25610  static int pcwd_close(struct inode *ino, struct file *filep)
25611  {
25612 -       if (minor(ino->i_rdev)==WATCHDOG_MINOR) {
25613 +       if (iminor(ino)==WATCHDOG_MINOR) {
25614                 if (expect_close) {
25615                         /*  Disable the board  */
25616                         if (revision == PCWD_REVISION_C) {
25617 diff -Nru a/drivers/char/watchdog/wafer5823wdt.c b/drivers/char/watchdog/wafer5823wdt.c
25618 --- a/drivers/char/watchdog/wafer5823wdt.c      Fri Aug  1 03:02:31 2003
25619 +++ b/drivers/char/watchdog/wafer5823wdt.c      Wed Sep  3 12:58:44 2003
25620 @@ -1,5 +1,5 @@
25621  /*
25622 - *     ICP Wafer 5823 Single Board Computer WDT driver for Linux 2.4.x
25623 + *     ICP Wafer 5823 Single Board Computer WDT driver
25624   *      http://www.icpamerica.com/wafer_5823.php
25625   *      May also work on other similar models
25626   *
25627 @@ -17,10 +17,10 @@
25628   *     modify it under the terms of the GNU General Public License
25629   *     as published by the Free Software Foundation; either version
25630   *     2 of the License, or (at your option) any later version.
25631 - *     
25632 - *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
25633 - *     warranty for any of this software. This material is provided 
25634 - *     "AS-IS" and at no charge.       
25635 + *
25636 + *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
25637 + *     warranty for any of this software. This material is provided
25638 + *     "AS-IS" and at no charge.
25639   *
25640   *     (c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
25641   *
25642 @@ -39,9 +39,13 @@
25643  #include <asm/io.h>
25644  #include <asm/uaccess.h>
25645  
25646 +#define WATCHDOG_NAME "Wafer 5823 WDT"
25647 +#define PFX WATCHDOG_NAME ": "
25648 +#define WD_TIMO 60                     /* 60 sec default timeout */
25649 +
25650  static unsigned long wafwdt_is_open;
25651 +static char expect_close;
25652  static spinlock_t wafwdt_lock;
25653 -static int expect_close = 0;
25654  
25655  /*
25656   *     You must set these - there is no sane way to probe for this board.
25657 @@ -52,11 +56,12 @@
25658   *      to restart it again.
25659   */
25660  
25661 -#define WDT_START 0x443
25662 -#define WDT_STOP 0x843
25663 +static int wdt_stop = 0x843;
25664 +static int wdt_start = 0x443;
25665  
25666 -#define WD_TIMO 60             /* 1 minute */
25667 -static int wd_margin = WD_TIMO;
25668 +static int timeout = WD_TIMO;  /* in seconds */
25669 +module_param(timeout, int, 0);
25670 +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WD_TIMO) ".");
25671  
25672  #ifdef CONFIG_WATCHDOG_NOWAYOUT
25673  static int nowayout = 1;
25674 @@ -70,24 +75,24 @@
25675  static void wafwdt_ping(void)
25676  {
25677         /* pat watchdog */
25678 -        spin_lock(&wafwdt_lock);
25679 -       inb_p(WDT_STOP);
25680 -       inb_p(WDT_START);
25681 -        spin_unlock(&wafwdt_lock);
25682 +       spin_lock(&wafwdt_lock);
25683 +       inb_p(wdt_stop);
25684 +       inb_p(wdt_start);
25685 +       spin_unlock(&wafwdt_lock);
25686  }
25687  
25688  static void wafwdt_start(void)
25689  {
25690         /* start up watchdog */
25691 -       outb_p(wd_margin, WDT_START);
25692 -       inb_p(WDT_START);
25693 +       outb_p(timeout, wdt_start);
25694 +       inb_p(wdt_start);
25695  }
25696  
25697  static void
25698  wafwdt_stop(void)
25699  {
25700         /* stop watchdog */
25701 -       inb_p(WDT_STOP);
25702 +       inb_p(wdt_stop);
25703  }
25704  
25705  static ssize_t wafwdt_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
25706 @@ -96,6 +101,7 @@
25707         if (ppos != &file->f_pos)
25708                 return -ESPIPE;
25709  
25710 +       /* See if we got the magic character 'V' and reload the timer */
25711         if (count) {
25712                 if (!nowayout) {
25713                         size_t i;
25714 @@ -103,30 +109,30 @@
25715                         /* In case it was set long ago */
25716                         expect_close = 0;
25717  
25718 +                       /* scan to see wether or not we got the magic character */
25719                         for (i = 0; i != count; i++) {
25720                                 char c;
25721                                 if (get_user(c, buf + i))
25722                                         return -EFAULT;
25723                                 if (c == 'V')
25724 -                                       expect_close = 1;
25725 +                                       expect_close = 42;
25726                         }
25727                 }
25728 +               /* Well, anyhow someone wrote to us, we should return that favour */
25729                 wafwdt_ping();
25730 -               return 1;
25731         }
25732 -       return 0;
25733 +       return count;
25734  }
25735  
25736  static int wafwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
25737              unsigned long arg)
25738  {
25739 -       int new_margin;
25740 +       int new_timeout;
25741         static struct watchdog_info ident = {
25742                 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
25743                 .firmware_version = 1,
25744 -               .identity = "Wafer 5823 WDT"
25745 +               .identity = "Wafer 5823 WDT",
25746         };
25747 -       int one=1;
25748  
25749         switch (cmd) {
25750         case WDIOC_GETSUPPORT:
25751 @@ -136,25 +142,44 @@
25752                 break;
25753  
25754         case WDIOC_GETSTATUS:
25755 -               if (copy_to_user((int *) arg, &one, sizeof (int)))
25756 -                       return -EFAULT;
25757 -               break;
25758 +       case WDIOC_GETBOOTSTATUS:
25759 +               return put_user(0, (int *)arg);
25760  
25761         case WDIOC_KEEPALIVE:
25762                 wafwdt_ping();
25763                 break;
25764  
25765         case WDIOC_SETTIMEOUT:
25766 -               if (get_user(new_margin, (int *)arg))
25767 +               if (get_user(new_timeout, (int *)arg))
25768                         return -EFAULT;
25769 -               if ((new_margin < 1) || (new_margin > 255))
25770 +               if ((new_timeout < 1) || (new_timeout > 255))
25771                         return -EINVAL;
25772 -               wd_margin = new_margin;
25773 +               timeout = new_timeout;
25774                 wafwdt_stop();
25775                 wafwdt_start();
25776                 /* Fall */
25777         case WDIOC_GETTIMEOUT:
25778 -               return put_user(wd_margin, (int *)arg);
25779 +               return put_user(timeout, (int *)arg);
25780 +
25781 +       case WDIOC_SETOPTIONS:
25782 +       {
25783 +               int options, retval = -EINVAL;
25784 +
25785 +               if (get_user(options, (int *)arg))
25786 +                       return -EFAULT;
25787 +
25788 +               if (options & WDIOS_DISABLECARD) {
25789 +                       wafwdt_start();
25790 +                       retval = 0;
25791 +               }
25792 +
25793 +               if (options & WDIOS_ENABLECARD) {
25794 +                       wafwdt_stop();
25795 +                       retval = 0;
25796 +               }
25797 +
25798 +               return retval;
25799 +       }
25800  
25801         default:
25802                 return -ENOTTY;
25803 @@ -166,6 +191,10 @@
25804  {
25805         if (test_and_set_bit(0, &wafwdt_is_open))
25806                 return -EBUSY;
25807 +
25808 +       /*
25809 +        *      Activate
25810 +        */
25811         wafwdt_start();
25812         return 0;
25813  }
25814 @@ -173,12 +202,14 @@
25815  static int
25816  wafwdt_close(struct inode *inode, struct file *file)
25817  {
25818 -       clear_bit(0, &wafwdt_is_open);
25819 -       if (expect_close) {   
25820 +       if (expect_close == 42) {
25821                 wafwdt_stop();
25822         } else {
25823 -               printk(KERN_CRIT "WDT device closed unexpectedly.  WDT will not stop!\n");
25824 +               printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will not stop!\n");
25825 +               wafwdt_ping();
25826         }
25827 +       clear_bit(0, &wafwdt_is_open);
25828 +       expect_close = 0;
25829         return 0;
25830  }
25831  
25832 @@ -201,6 +232,7 @@
25833  
25834  static struct file_operations wafwdt_fops = {
25835         .owner          = THIS_MODULE,
25836 +       .llseek         = no_llseek,
25837         .write          = wafwdt_write,
25838         .ioctl          = wafwdt_ioctl,
25839         .open           = wafwdt_open,
25840 @@ -210,53 +242,93 @@
25841  static struct miscdevice wafwdt_miscdev = {
25842         .minor  = WATCHDOG_MINOR,
25843         .name   = "watchdog",
25844 -       .fops   = &wafwdt_fops
25845 +       .fops   = &wafwdt_fops,
25846  };
25847  
25848  /*
25849   *     The WDT needs to learn about soft shutdowns in order to
25850 - *     turn the timebomb registers off. 
25851 + *     turn the timebomb registers off.
25852   */
25853  
25854  static struct notifier_block wafwdt_notifier = {
25855         .notifier_call = wafwdt_notify_sys,
25856         .next = NULL,
25857 -       .priority = 0
25858 +       .priority = 0,
25859  };
25860  
25861  static int __init wafwdt_init(void)
25862  {
25863 +       int ret;
25864 +
25865         printk(KERN_INFO "WDT driver for Wafer 5823 single board computer initialising.\n");
25866  
25867         spin_lock_init(&wafwdt_lock);
25868 -       if(!request_region(WDT_STOP, 1, "Wafer 5823 WDT"))
25869 -               goto error;
25870 -       if(!request_region(WDT_START, 1, "Wafer 5823 WDT"))
25871 +
25872 +       if (timeout < 1 || timeout > 255) {
25873 +               timeout = WD_TIMO;
25874 +               printk (KERN_INFO PFX "timeout value must be 1<=x<=255, using %d\n",
25875 +                       timeout);
25876 +       }
25877 +
25878 +       if (wdt_stop != wdt_start) {
25879 +               if(!request_region(wdt_stop, 1, "Wafer 5823 WDT")) {
25880 +                       printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
25881 +                       wdt_stop);
25882 +                       ret = -EIO;
25883 +                       goto error;
25884 +               }
25885 +       }
25886 +
25887 +       if(!request_region(wdt_start, 1, "Wafer 5823 WDT")) {
25888 +               printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
25889 +                       wdt_start);
25890 +               ret = -EIO;
25891                 goto error2;
25892 -       if(misc_register(&wafwdt_miscdev)<0)
25893 +       }
25894 +
25895 +       ret = register_reboot_notifier(&wafwdt_notifier);
25896 +       if (ret != 0) {
25897 +               printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
25898 +                       ret);
25899                 goto error3;
25900 -       register_reboot_notifier(&wafwdt_notifier);
25901 -       return 0;
25902 +       }
25903 +
25904 +       ret = misc_register(&wafwdt_miscdev);
25905 +       if (ret != 0) {
25906 +               printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
25907 +                       WATCHDOG_MINOR, ret);
25908 +               goto error4;
25909 +       }
25910 +
25911 +       printk (KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
25912 +               timeout, nowayout);
25913 +
25914 +       return ret;
25915 +error4:
25916 +       unregister_reboot_notifier(&wafwdt_notifier);
25917  error3:
25918 -       release_region(WDT_START, 1);
25919 +       release_region(wdt_start, 1);
25920  error2:
25921 -       release_region(WDT_STOP, 1);
25922 +       if (wdt_stop != wdt_start)
25923 +               release_region(wdt_stop, 1);
25924  error:
25925 -       return -ENODEV;
25926 +       return ret;
25927  }
25928  
25929  static void __exit wafwdt_exit(void)
25930  {
25931         misc_deregister(&wafwdt_miscdev);
25932         unregister_reboot_notifier(&wafwdt_notifier);
25933 -       release_region(WDT_STOP, 1);
25934 -       release_region(WDT_START, 1);
25935 +       if(wdt_stop != wdt_start)
25936 +               release_region(wdt_stop, 1);
25937 +       release_region(wdt_start, 1);
25938  }
25939  
25940  module_init(wafwdt_init);
25941  module_exit(wafwdt_exit);
25942  
25943  MODULE_AUTHOR("Justin Cormack");
25944 +MODULE_DESCRIPTION("ICP Wafer 5823 Single Board Computer WDT driver");
25945  MODULE_LICENSE("GPL");
25946  
25947  /* end of wafer5823wdt.c */
25948 diff -Nru a/drivers/char/watchdog/wdt.c b/drivers/char/watchdog/wdt.c
25949 --- a/drivers/char/watchdog/wdt.c       Thu Apr 24 05:36:57 2003
25950 +++ b/drivers/char/watchdog/wdt.c       Wed Sep  3 23:40:14 2003
25951 @@ -290,7 +290,7 @@
25952         if (ptr != &file->f_pos)
25953                 return -ESPIPE;
25954  
25955 -       switch(minor(file->f_dentry->d_inode->i_rdev))
25956 +       switch(iminor(file->f_dentry->d_inode))
25957         {
25958                 case TEMP_MINOR:
25959                         c*=11;
25960 @@ -373,7 +373,7 @@
25961   
25962  static int wdt_open(struct inode *inode, struct file *file)
25963  {
25964 -       switch(minor(inode->i_rdev))
25965 +       switch(iminor(inode))
25966         {
25967                 case WATCHDOG_MINOR:
25968                         if(test_and_set_bit(0, &wdt_is_open))
25969 @@ -413,7 +413,7 @@
25970   
25971  static int wdt_release(struct inode *inode, struct file *file)
25972  {
25973 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR)
25974 +       if(iminor(inode)==WATCHDOG_MINOR)
25975         {
25976                 if (expect_close) {
25977                         inb_p(WDT_DC);          /* Disable counters */
25978 @@ -579,4 +579,6 @@
25979  
25980  MODULE_AUTHOR("Alan Cox");
25981  MODULE_DESCRIPTION("Driver for ISA ICS watchdog cards (WDT500/501)");
25982 +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
25983 +MODULE_ALIAS_MISCDEV(TEMP_MINOR);
25984  MODULE_LICENSE("GPL");
25985 diff -Nru a/drivers/char/watchdog/wdt_pci.c b/drivers/char/watchdog/wdt_pci.c
25986 --- a/drivers/char/watchdog/wdt_pci.c   Fri Aug  1 11:59:44 2003
25987 +++ b/drivers/char/watchdog/wdt_pci.c   Tue Aug 26 09:25:41 2003
25988 @@ -276,7 +276,7 @@
25989         if (ptr != &file->f_pos)
25990                 return -ESPIPE;
25991  
25992 -       switch(minor(file->f_dentry->d_inode->i_rdev))
25993 +       switch(iminor(file->f_dentry->d_inode))
25994         {
25995                 case TEMP_MINOR:
25996                         c*=11;
25997 @@ -361,7 +361,7 @@
25998  {
25999         unsigned long flags;
26000  
26001 -       switch(minor(inode->i_rdev))
26002 +       switch(iminor(inode))
26003         {
26004                 case WATCHDOG_MINOR:
26005                         if (down_trylock(&open_sem))
26006 @@ -423,7 +423,7 @@
26007  static int wdtpci_release(struct inode *inode, struct file *file)
26008  {
26009  
26010 -       if (minor(inode->i_rdev)==WATCHDOG_MINOR) {
26011 +       if (iminor(inode)==WATCHDOG_MINOR) {
26012                 unsigned long flags;
26013                 if (expect_close) {
26014                         spin_lock_irqsave(&wdtpci_lock, flags);
26015 diff -Nru a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
26016 --- a/drivers/i2c/Kconfig       Fri Aug  1 21:55:21 2003
26017 +++ b/drivers/i2c/Kconfig       Tue Aug 26 11:58:28 2003
26018 @@ -150,7 +150,7 @@
26019  
26020  config I2C_ELEKTOR
26021         tristate "Elektor ISA card"
26022 -       depends on I2C_ALGOPCF
26023 +       depends on I2C_ALGOPCF && BROKEN_ON_SMP
26024         help
26025           This supports the PCF8584 ISA bus I2C adapter.  Say Y if you own
26026           such an adapter.
26027 diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
26028 --- a/drivers/i2c/i2c-dev.c     Wed Aug  6 02:26:55 2003
26029 +++ b/drivers/i2c/i2c-dev.c     Tue Aug 26 09:25:41 2003
26030 @@ -138,7 +138,7 @@
26031                 return -ENOMEM;
26032  
26033         pr_debug("i2c-dev.o: i2c-%d reading %d bytes.\n",
26034 -               minor(file->f_dentry->d_inode->i_rdev), count);
26035 +               iminor(file->f_dentry->d_inode), count);
26036  
26037         ret = i2c_master_recv(client,tmp,count);
26038         if (ret >= 0)
26039 @@ -166,7 +166,7 @@
26040         }
26041  
26042         pr_debug("i2c-dev.o: i2c-%d writing %d bytes.\n",
26043 -               minor(file->f_dentry->d_inode->i_rdev), count);
26044 +               iminor(file->f_dentry->d_inode), count);
26045  
26046         ret = i2c_master_send(client,tmp,count);
26047         kfree(tmp);
26048 @@ -186,7 +186,7 @@
26049         unsigned long funcs;
26050  
26051         dev_dbg(&client->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n",
26052 -               minor(inode->i_rdev),cmd, arg);
26053 +               iminor(inode),cmd, arg);
26054  
26055         switch ( cmd ) {
26056         case I2C_SLAVE:
26057 @@ -373,7 +373,7 @@
26058  
26059  static int i2cdev_open(struct inode *inode, struct file *file)
26060  {
26061 -       unsigned int minor = minor(inode->i_rdev);
26062 +       unsigned int minor = iminor(inode);
26063         struct i2c_client *client;
26064         struct i2c_adapter *adap;
26065         struct i2c_dev *i2c_dev;
26066 diff -Nru a/drivers/i2c/i2c-keywest.c b/drivers/i2c/i2c-keywest.c
26067 --- a/drivers/i2c/i2c-keywest.c Wed Jul  9 04:45:34 2003
26068 +++ b/drivers/i2c/i2c-keywest.c Tue Aug 26 06:35:38 2003
26069 @@ -81,9 +81,6 @@
26070  int probe = 0;
26071  int debug = 0;
26072  
26073 -static struct keywest_iface *ifaces = NULL;
26074 -
26075 -
26076  static void
26077  do_stop(struct keywest_iface* iface, int result)
26078  {
26079 @@ -306,6 +303,7 @@
26080         write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
26081         write_reg(reg_ier, KW_I2C_IRQ_MASK);
26082  
26083 +       /* Wait interrupt operations completion */
26084         wait_for_completion(&iface->complete);  
26085  
26086         rc = iface->result;     
26087 @@ -385,6 +383,7 @@
26088                 write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
26089                 write_reg(reg_ier, KW_I2C_IRQ_MASK);
26090  
26091 +               /* Wait interrupt operations completion */
26092                 wait_for_completion(&iface->complete);  
26093  
26094                 rc = iface->result;
26095 @@ -409,16 +408,16 @@
26096  
26097  /* For now, we only handle combined mode (smbus) */
26098  static struct i2c_algorithm keywest_algorithm = {
26099 -       name:           "Keywest i2c",
26100 -       id:             I2C_ALGO_SMBUS,
26101 -       smbus_xfer:     keywest_smbus_xfer,
26102 -       master_xfer:    keywest_xfer,
26103 -       functionality:  keywest_func,
26104 +       .name           = "Keywest i2c",
26105 +       .id             = I2C_ALGO_SMBUS,
26106 +       .smbus_xfer     = keywest_smbus_xfer,
26107 +       .master_xfer    = keywest_xfer,
26108 +       .functionality  = keywest_func,
26109  };
26110  
26111  
26112  static int
26113 -create_iface(struct device_node* np)
26114 +create_iface(struct device_node *np, struct device *dev)
26115  {
26116         unsigned long steps, *psteps, *prate;
26117         unsigned bsteps, tsize, i, nchan, addroffset;
26118 @@ -487,8 +486,8 @@
26119                         *prate);
26120         }
26121         
26122 -       /* Select standard mode by default */
26123 -       iface->cur_mode |= KW_I2C_MODE_STANDARD;
26124 +       /* Select standard sub mode */
26125 +       iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
26126         
26127         /* Write mode */
26128         write_reg(reg_mode, iface->cur_mode);
26129 @@ -506,11 +505,13 @@
26130                 return -ENODEV;
26131         }
26132  
26133 +       dev_set_drvdata(dev, iface);
26134 +       
26135         for (i=0; i<nchan; i++) {
26136                 struct keywest_chan* chan = &iface->channels[i];
26137                 u8 addr;
26138                 
26139 -               sprintf(chan->adapter.dev.name, "%s %d", np->parent->name, i);
26140 +               sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
26141                 chan->iface = iface;
26142                 chan->chan_no = i;
26143                 chan->adapter.id = I2C_ALGO_SMBUS;
26144 @@ -519,11 +520,12 @@
26145                 chan->adapter.client_register = NULL;
26146                 chan->adapter.client_unregister = NULL;
26147                 i2c_set_adapdata(&chan->adapter, chan);
26148 +               chan->adapter.dev.parent = dev;
26149  
26150                 rc = i2c_add_adapter(&chan->adapter);
26151                 if (rc) {
26152                         printk("i2c-keywest.c: Adapter %s registration failed\n",
26153 -                               chan->adapter.dev.name);
26154 +                               chan->adapter.name);
26155                         i2c_set_adapdata(&chan->adapter, NULL);
26156                 }
26157                 if (probe) {
26158 @@ -540,20 +542,18 @@
26159         printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n",
26160                 np->parent->name, nchan, nchan > 1 ? "s" : "", bsteps);
26161                 
26162 -       iface->next = ifaces;
26163 -       ifaces = iface;
26164         return 0;
26165  }
26166  
26167 -static void
26168 -dispose_iface(struct keywest_iface *iface)
26169 +static int
26170 +dispose_iface(struct device *dev)
26171  {
26172 +       struct keywest_iface *iface = dev_get_drvdata(dev);
26173         int i, rc;
26174         
26175 -       ifaces = iface->next;
26176 -
26177         /* Make sure we stop all activity */
26178         down(&iface->sem);
26179 +
26180         spin_lock_irq(&iface->lock);
26181         while (iface->state != state_idle) {
26182                 spin_unlock_irq(&iface->lock);
26183 @@ -578,31 +578,76 @@
26184                         printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
26185         }
26186         iounmap((void *)iface->base);
26187 +       dev_set_drvdata(dev, NULL);
26188         kfree(iface);
26189 +
26190 +       return 0;
26191 +}
26192 +
26193 +static int
26194 +create_iface_macio(struct macio_dev* dev, const struct of_match *match)
26195 +{
26196 +       return create_iface(dev->ofdev.node, &dev->ofdev.dev);
26197 +}
26198 +
26199 +static int
26200 +dispose_iface_macio(struct macio_dev* dev)
26201 +{
26202 +       return dispose_iface(&dev->ofdev.dev);
26203 +}
26204 +
26205 +static int
26206 +create_iface_of_platform(struct of_device* dev, const struct of_match *match)
26207 +{
26208 +       return create_iface(dev->node, &dev->dev);
26209 +}
26210 +
26211 +static int
26212 +dispose_iface_of_platform(struct of_device* dev)
26213 +{
26214 +       return dispose_iface(&dev->dev);
26215  }
26216  
26217 +static struct of_match i2c_keywest_match[] = 
26218 +{
26219 +       {
26220 +       .name           = OF_ANY_MATCH,
26221 +       .type           = "i2c",
26222 +       .compatible     = "keywest"
26223 +       },
26224 +       {},
26225 +};
26226 +
26227 +static struct macio_driver i2c_keywest_macio_driver = 
26228 +{
26229 +       .name           = "i2c-keywest",
26230 +       .match_table    = i2c_keywest_match,
26231 +       .probe          = create_iface_macio,
26232 +       .remove         = dispose_iface_macio
26233 +};
26234 +
26235 +static struct of_platform_driver i2c_keywest_of_platform_driver = 
26236 +{
26237 +       .name           = "i2c-keywest",
26238 +       .match_table    = i2c_keywest_match,
26239 +       .probe          = create_iface_of_platform,
26240 +       .remove         = dispose_iface_of_platform
26241 +};
26242 +
26243  static int __init
26244  i2c_keywest_init(void)
26245  {
26246 -       struct device_node *np;
26247 -       int rc = -ENODEV;
26248 -       
26249 -       np = find_compatible_devices("i2c", "keywest");
26250 -       while (np != 0) {
26251 -               if (np->n_addrs >= 1 && np->n_intrs >= 1)
26252 -                       rc = create_iface(np);
26253 -               np = np->next;
26254 -       }
26255 -       if (ifaces)
26256 -               rc = 0;
26257 -       return rc;
26258 +       macio_register_driver(&i2c_keywest_macio_driver);
26259 +       of_register_driver(&i2c_keywest_of_platform_driver);
26260 +
26261 +       return 0;
26262  }
26263  
26264  static void __exit
26265  i2c_keywest_cleanup(void)
26266  {
26267 -       while(ifaces)
26268 -               dispose_iface(ifaces);
26269 +       macio_unregister_driver(&i2c_keywest_macio_driver);
26270 +       of_unregister_driver(&i2c_keywest_of_platform_driver);
26271  }
26272  
26273  module_init(i2c_keywest_init);
26274 diff -Nru a/drivers/i2c/i2c-keywest.h b/drivers/i2c/i2c-keywest.h
26275 --- a/drivers/i2c/i2c-keywest.h Fri Feb 15 14:32:09 2002
26276 +++ b/drivers/i2c/i2c-keywest.h Sun Aug 24 06:10:14 2003
26277 @@ -67,7 +67,6 @@
26278         int                     stopretry;
26279         struct timer_list       timeout_timer;
26280         struct completion       complete;
26281 -       struct keywest_iface*   next;
26282  };
26283  
26284  enum {
26285 diff -Nru a/drivers/ide/Kconfig b/drivers/ide/Kconfig
26286 --- a/drivers/ide/Kconfig       Wed Aug 13 14:35:06 2003
26287 +++ b/drivers/ide/Kconfig       Wed Sep  3 09:52:16 2003
26288 @@ -815,6 +815,17 @@
26289           most of the recent Apple Power Macintoshes and PowerBooks.
26290           If unsure, say Y.
26291  
26292 +config BLK_DEV_IDE_PMAC_ATA100FIRST
26293 +       bool "Probe internal ATA/100 (Kauai) first"
26294 +       depends on BLK_DEV_IDE_PMAC
26295 +       help
26296 +         This option will cause the ATA/100 controller found in UniNorth2
26297 +         based machines (Windtunnel PowerMac, Aluminium PowerBooks, ...)
26298 +         to be probed before the ATA/66 and ATA/33 controllers. Without
26299 +         these, those machine used to have the hard disk on hdc and the
26300 +         CD-ROM on hda. This option changes this to more natural hda for
26301 +         hard disk and hdc for CD-ROM.
26302 +
26303  config BLK_DEV_IDEDMA_PMAC
26304         bool "PowerMac IDE DMA support"
26305         depends on BLK_DEV_IDE_PMAC
26306 @@ -823,6 +834,13 @@
26307           Power Macintoshes and PowerBooks to use DMA (direct memory access)
26308           to transfer data to and from memory.  Saying Y is safe and improves
26309           performance.
26310 +
26311 +config BLK_DEV_IDE_PMAC_BLINK
26312 +       bool "Blink laptop LED on drive activity"
26313 +       depends on BLK_DEV_IDE_PMAC && ADB_PMU
26314 +       help
26315 +         This option enables the use of the sleep LED as a hard drive
26316 +         activity LED.
26317  
26318  config BLK_DEV_IDEDMA_PMAC_AUTO
26319         bool "Use DMA by default"
26320 diff -Nru a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
26321 --- a/drivers/ide/ide-cd.c      Wed Aug 20 09:01:03 2003
26322 +++ b/drivers/ide/ide-cd.c      Fri Aug 22 18:04:49 2003
26323 @@ -794,16 +794,16 @@
26324                            request or data protect error.*/
26325                         ide_dump_status (drive, "command error", stat);
26326                         do_end_request = 1;
26327 -               } else if ((err & ~ABRT_ERR) != 0) {
26328 -                       /* Go to the default handler
26329 -                          for other errors. */
26330 -                       DRIVER(drive)->error(drive, "cdrom_decode_status",stat);
26331 -                       return 1;
26332                 } else if (sense_key == MEDIUM_ERROR) {
26333                         /* No point in re-trying a zillion times on a bad 
26334                          * sector...  If we got here the error is not correctable */
26335                         ide_dump_status (drive, "media error (bad sector)", stat);
26336                         do_end_request = 1;
26337 +               } else if ((err & ~ABRT_ERR) != 0) {
26338 +                       /* Go to the default handler
26339 +                          for other errors. */
26340 +                       DRIVER(drive)->error(drive, "cdrom_decode_status",stat);
26341 +                       return 1;
26342                 } else if ((++rq->errors > ERROR_MAX)) {
26343                         /* We've racked up too many retries.  Abort. */
26344                         do_end_request = 1;
26345 diff -Nru a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
26346 --- a/drivers/ide/ide-io.c      Thu Aug  7 02:25:24 2003
26347 +++ b/drivers/ide/ide-io.c      Sun Aug 24 15:33:30 2003
26348 @@ -54,8 +54,6 @@
26349  #include <asm/io.h>
26350  #include <asm/bitops.h>
26351  
26352 -#include "ide_modes.h"
26353 -
26354  #if (DISK_RECOVERY_TIME > 0)
26355  
26356  #error So the User Has To Fix the Compilation And Stop Hacking Port 0x43. Does anyone ever use this anyway ??
26357 diff -Nru a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
26358 --- a/drivers/ide/ide-lib.c     Thu Aug  7 02:25:25 2003
26359 +++ b/drivers/ide/ide-lib.c     Sun Aug 24 15:33:30 2003
26360 @@ -22,8 +22,6 @@
26361  #include <asm/io.h>
26362  #include <asm/bitops.h>
26363  
26364 -#include "ide_modes.h"
26365 -
26366  /*
26367   *     IDE library routines. These are plug in code that most 
26368   *     drivers can use but occasionally may be weird enough
26369 @@ -170,7 +168,7 @@
26370                 BUG();
26371         return min(speed, speed_max[mode]);
26372  #else /* !CONFIG_BLK_DEV_IDEDMA */
26373 -       return min(speed, XFER_PIO_4);
26374 +       return min(speed, (u8)XFER_PIO_4);
26375  #endif /* CONFIG_BLK_DEV_IDEDMA */
26376  }
26377  
26378 @@ -188,6 +186,12 @@
26379  
26380  EXPORT_SYMBOL(ide_dma_enable);
26381  
26382 +/*
26383 + * Standard (generic) timings for PIO modes, from ATA2 specification.
26384 + * These timings are for access to the IDE data port register *only*.
26385 + * Some drives may specify a mode, while also specifying a different
26386 + * value for cycle_time (from drive identification data).
26387 + */
26388  const ide_pio_timings_t ide_pio_timings[6] = {
26389         { 70,   165,    600 },  /* PIO Mode 0 */
26390         { 50,   125,    383 },  /* PIO Mode 1 */
26391 @@ -198,6 +202,13 @@
26392  };
26393  
26394  EXPORT_SYMBOL_GPL(ide_pio_timings);
26395 +
26396 +/*
26397 + * Shared data/functions for determining best PIO mode for an IDE drive.
26398 + * Most of this stuff originally lived in cmd640.c, and changes to the
26399 + * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
26400 + * breaking the fragile cmd640.c support.
26401 + */
26402  
26403  /*
26404   * Black list. Some drives incorrectly report their maximal PIO mode,
26405 diff -Nru a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
26406 --- a/drivers/ide/ide-probe.c   Thu Aug 14 16:52:06 2003
26407 +++ b/drivers/ide/ide-probe.c   Wed Sep  3 09:52:16 2003
26408 @@ -644,15 +644,26 @@
26409         return drive->present;
26410  }
26411  
26412 +static void hwif_release_dev (struct device *dev)
26413 +{
26414 +       ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev);
26415 +
26416 +       up(&hwif->gendev_rel_sem);
26417 +}
26418 +
26419  static void hwif_register (ide_hwif_t *hwif)
26420  {
26421         /* register with global device tree */
26422         strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE);
26423         hwif->gendev.driver_data = hwif;
26424 -       if (hwif->pci_dev)
26425 -               hwif->gendev.parent = &hwif->pci_dev->dev;
26426 -       else
26427 -               hwif->gendev.parent = NULL; /* Would like to do = &device_legacy */
26428 +       if (hwif->gendev.parent == NULL) {
26429 +               if (hwif->pci_dev)
26430 +                       hwif->gendev.parent = &hwif->pci_dev->dev;
26431 +               else
26432 +                       /* Would like to do = &device_legacy */
26433 +                       hwif->gendev.parent = NULL;
26434 +       }
26435 +       hwif->gendev.release = hwif_release_dev;
26436         device_register(&hwif->gendev);
26437  }
26438  
26439 @@ -770,8 +781,7 @@
26440          */
26441         for (unit = 0; unit < MAX_DRIVES; ++unit) {
26442                 ide_drive_t *drive = &hwif->drives[unit];
26443 -               drive->dn = ((hwif->channel ? 2 : 0) + unit);
26444 -               hwif->drives[unit].dn = ((hwif->channel ? 2 : 0) + unit);
26445 +               drive->dn = (hwif->channel ? 2 : 0) + unit;
26446                 (void) probe_for_drive(drive);
26447                 if (drive->present && !hwif->present) {
26448                         hwif->present = 1;
26449 @@ -945,15 +955,14 @@
26450         if (drive->disk)
26451                 drive->disk->queue = drive->queue;
26452  
26453 -       return 0;
26454 -}
26455 -
26456 -/*
26457 - * Setup the drive for request handling.
26458 - */
26459 -static void ide_init_drive(ide_drive_t *drive)
26460 -{
26461 +       /* needs drive->queue to be set */
26462         ide_toggle_bounce(drive, 1);
26463 +
26464 +       /* enable led activity for disk drives only */
26465 +       if (drive->media == ide_disk && hwif->led_act)
26466 +               blk_queue_activity_fn(q, hwif->led_act, drive);
26467 +
26468 +       return 0;
26469  }
26470  
26471  /*
26472 @@ -1068,10 +1077,9 @@
26473         }
26474  
26475         /*
26476 -        * Link any new drives into the hwgroup, allocate
26477 -        * the block device queue and initialize the drive.
26478 -        * Note that ide_init_drive sends commands to the new
26479 -        * drive.
26480 +        * For any present drive:
26481 +        * - allocate the block device queue
26482 +        * - link drive into the hwgroup
26483          */
26484         for (index = 0; index < MAX_DRIVES; ++index) {
26485                 ide_drive_t *drive = &hwif->drives[index];
26486 @@ -1092,7 +1100,6 @@
26487                         hwgroup->drive->next = drive;
26488                 }
26489                 spin_unlock_irq(&ide_lock);
26490 -               ide_init_drive(drive);
26491         }
26492  
26493  #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
26494 @@ -1201,6 +1208,13 @@
26495         return -ENOMEM;
26496  }
26497  
26498 +static void drive_release_dev (struct device *dev)
26499 +{
26500 +       ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
26501 +
26502 +       up(&drive->gendev_rel_sem);
26503 +}
26504 +
26505  /*
26506   * init_gendisk() (as opposed to ide_geninit) is called for each major device,
26507   * after probing for drives, to allocate partition tables and other data
26508 @@ -1219,6 +1233,7 @@
26509                 drive->gendev.parent = &hwif->gendev;
26510                 drive->gendev.bus = &ide_bus_type;
26511                 drive->gendev.driver_data = drive;
26512 +               drive->gendev.release = drive_release_dev;
26513                 if (drive->present) {
26514                         device_register(&drive->gendev);
26515                         sprintf(drive->devfs_name, "ide/host%d/bus%d/target%d/lun%d",
26516 @@ -1303,31 +1318,6 @@
26517  
26518  EXPORT_SYMBOL(hwif_init);
26519  
26520 -int export_ide_init_queue (ide_drive_t *drive)
26521 -{
26522 -       if (ide_init_queue(drive))
26523 -               return 1;
26524 -
26525 -       ide_init_drive(drive);
26526 -       return 0;
26527 -}
26528 -
26529 -EXPORT_SYMBOL(export_ide_init_queue);
26530 -
26531 -u8 export_probe_for_drive (ide_drive_t *drive)
26532 -{
26533 -       return probe_for_drive(drive);
26534 -}
26535 -
26536 -EXPORT_SYMBOL(export_probe_for_drive);
26537 -
26538 -int ideprobe_init (void);
26539 -static ide_module_t ideprobe_module = {
26540 -       IDE_PROBE_MODULE,
26541 -       ideprobe_init,
26542 -       NULL
26543 -};
26544 -
26545  int ideprobe_init (void)
26546  {
26547         unsigned int index;
26548 @@ -1359,7 +1349,7 @@
26549                 }
26550         }
26551         if (!ide_probe)
26552 -               ide_probe = &ideprobe_module;
26553 +               ide_probe = &ideprobe_init;
26554         MOD_DEC_USE_COUNT;
26555         return 0;
26556  }
26557 diff -Nru a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
26558 --- a/drivers/ide/ide-tape.c    Wed Aug 20 14:21:56 2003
26559 +++ b/drivers/ide/ide-tape.c    Tue Aug 26 09:25:41 2003
26560 @@ -4922,7 +4922,7 @@
26561         struct inode *inode = file->f_dentry->d_inode;
26562         ide_drive_t *drive = file->private_data;
26563         idetape_tape_t *tape = drive->driver_data;
26564 -       unsigned int minor = minor(inode->i_rdev);
26565 +       unsigned int minor = iminor(inode);
26566         ssize_t retval, actually_written = 0;
26567         int position;
26568  
26569 @@ -5568,7 +5568,7 @@
26570   */
26571  static int idetape_chrdev_open (struct inode *inode, struct file *filp)
26572  {
26573 -       unsigned int minor = minor(inode->i_rdev), i = minor & ~0xc0;
26574 +       unsigned int minor = iminor(inode), i = minor & ~0xc0;
26575         ide_drive_t *drive;
26576         idetape_tape_t *tape;
26577         idetape_pc_t pc;
26578 @@ -5649,7 +5649,7 @@
26579         ide_drive_t *drive = filp->private_data;
26580         idetape_tape_t *tape;
26581         idetape_pc_t pc;
26582 -       unsigned int minor = minor(inode->i_rdev);
26583 +       unsigned int minor = iminor(inode);
26584  
26585         lock_kernel();
26586         tape = drive->driver_data;
26587 diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
26588 --- a/drivers/ide/ide.c Wed Aug 20 09:01:03 2003
26589 +++ b/drivers/ide/ide.c Tue Sep  2 07:18:29 2003
26590 @@ -161,8 +161,6 @@
26591  #include <asm/io.h>
26592  #include <asm/bitops.h>
26593  
26594 -#include "ide_modes.h"
26595 -
26596  
26597  /* default maximum number of failures */
26598  #define IDE_DEFAULT_MAX_FAILURES       1
26599 @@ -180,7 +178,9 @@
26600  DECLARE_MUTEX(ide_cfg_sem);
26601  spinlock_t ide_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
26602  
26603 +#ifdef CONFIG_BLK_DEV_IDEPCI
26604  static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */
26605 +#endif
26606  
26607  #ifdef CONFIG_IDEDMA_AUTO
26608  int noautodma = 0;
26609 @@ -190,11 +190,7 @@
26610  
26611  EXPORT_SYMBOL(noautodma);
26612  
26613 -/*
26614 - * ide_modules keeps track of the available IDE chipset/probe/driver modules.
26615 - */
26616 -ide_module_t *ide_chipsets;
26617 -ide_module_t *ide_probe;
26618 +int (*ide_probe)(void);
26619  
26620  /*
26621   * This is declared extern in ide.h, for access by other IDE modules:
26622 @@ -255,6 +251,8 @@
26623         hwif->mwdma_mask = 0x80;        /* disable all mwdma */
26624         hwif->swdma_mask = 0x80;        /* disable all swdma */
26625  
26626 +       sema_init(&hwif->gendev_rel_sem, 0);
26627 +
26628         default_hwif_iops(hwif);
26629         default_hwif_transport(hwif);
26630         for (unit = 0; unit < MAX_DRIVES; ++unit) {
26631 @@ -277,6 +275,7 @@
26632                 drive->driver                   = &idedefault_driver;
26633                 drive->vdma                     = 0;
26634                 INIT_LIST_HEAD(&drive->list);
26635 +               sema_init(&drive->gendev_rel_sem, 0);
26636         }
26637  }
26638  
26639 @@ -452,7 +451,7 @@
26640                 (void) request_module("ide-probe-mod");
26641  #endif /* (CONFIG_KMOD) && (CONFIG_BLK_DEV_IDE_MODULE) */
26642         } else {
26643 -               (void) ide_probe->init();
26644 +               (void)ide_probe();
26645         }
26646  }
26647  
26648 @@ -749,6 +748,7 @@
26649                 spin_unlock_irq(&ide_lock);
26650                 blk_cleanup_queue(drive->queue);
26651                 device_unregister(&drive->gendev);
26652 +               down(&drive->gendev_rel_sem);
26653                 spin_lock_irq(&ide_lock);
26654                 drive->queue = NULL;
26655         }
26656 @@ -778,6 +778,7 @@
26657         /* More messed up locking ... */
26658         spin_unlock_irq(&ide_lock);
26659         device_unregister(&hwif->gendev);
26660 +       down(&hwif->gendev_rel_sem);
26661  
26662         /*
26663          * Remove us from the kernel's knowledge
26664 @@ -1046,21 +1047,6 @@
26665  EXPORT_SYMBOL(ide_register_hw);
26666  
26667  /*
26668 - * Compatibility function with existing drivers.  If you want
26669 - * something different, use the function above.
26670 - */
26671 -int ide_register (int arg1, int arg2, int irq)
26672 -{
26673 -       hw_regs_t hw;
26674 -       ide_init_hwif_ports(&hw, (unsigned long) arg1, (unsigned long) arg2, NULL);
26675 -       hw.irq = irq;
26676 -       return ide_register_hw(&hw, NULL);
26677 -}
26678 -
26679 -EXPORT_SYMBOL(ide_register);
26680 -
26681 -
26682 -/*
26683   *     Locks for IDE setting functionality
26684   */
26685  
26686 @@ -1658,11 +1644,15 @@
26687  
26688                 case HDIO_SCAN_HWIF:
26689                 {
26690 +                       hw_regs_t hw;
26691                         int args[3];
26692                         if (!capable(CAP_SYS_RAWIO)) return -EACCES;
26693                         if (copy_from_user(args, (void *)arg, 3 * sizeof(int)))
26694                                 return -EFAULT;
26695 -                       if (ide_register(args[0], args[1], args[2]) == -1)
26696 +                       ide_init_hwif_ports(&hw, (unsigned long) args[0],
26697 +                                           (unsigned long) args[1], NULL);
26698 +                       hw.irq = args[2];
26699 +                       if (ide_register_hw(&hw, NULL) == -1)
26700                                 return -EIO;
26701                         return 0;
26702                 }
26703 @@ -1870,7 +1860,7 @@
26704   *                             registered. In most cases, only one device
26705   *                             will be present.
26706   * "hdx=scsi"          : the return of the ide-scsi flag, this is useful for
26707 - *                             allowwing ide-floppy, ide-tape, and ide-cdrom|writers
26708 + *                             allowing ide-floppy, ide-tape, and ide-cdrom|writers
26709   *                             to use ide-scsi emulation on a device specific option.
26710   * "idebus=xx"         : inform IDE driver of VESA/PCI bus speed in MHz,
26711   *                             where "xx" is between 20 and 66 inclusive,
26712 diff -Nru a/drivers/ide/ide_modes.h b/drivers/ide/ide_modes.h
26713 --- a/drivers/ide/ide_modes.h   Mon Sep 16 05:54:57 2002
26714 +++ /dev/null   Wed Dec 31 16:00:00 1969
26715 @@ -1,41 +0,0 @@
26716 -/*
26717 - *  linux/drivers/ide/ide_modes.h
26718 - *
26719 - *  Copyright (C) 1996  Linus Torvalds, Igor Abramov, and Mark Lord
26720 - */
26721 -
26722 -#ifndef _IDE_MODES_H
26723 -#define _IDE_MODES_H
26724 -
26725 -#include <linux/config.h>
26726 -
26727 -/*
26728 - * Shared data/functions for determining best PIO mode for an IDE drive.
26729 - * Most of this stuff originally lived in cmd640.c, and changes to the
26730 - * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
26731 - * breaking the fragile cmd640.c support.
26732 - */
26733 -
26734 -/*
26735 - * Standard (generic) timings for PIO modes, from ATA2 specification.
26736 - * These timings are for access to the IDE data port register *only*.
26737 - * Some drives may specify a mode, while also specifying a different
26738 - * value for cycle_time (from drive identification data).
26739 - */
26740 -typedef struct ide_pio_timings_s {
26741 -       int     setup_time;     /* Address setup (ns) minimum */
26742 -       int     active_time;    /* Active pulse (ns) minimum */
26743 -       int     cycle_time;     /* Cycle time (ns) minimum = (setup + active + recovery) */
26744 -} ide_pio_timings_t;
26745 -
26746 -typedef struct ide_pio_data_s {
26747 -       u8 pio_mode;
26748 -       u8 use_iordy;
26749 -       u8 overridden;
26750 -       u8 blacklisted;
26751 -       unsigned int cycle_time;
26752 -} ide_pio_data_t;
26753 -       
26754 -u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d);
26755 -extern const ide_pio_timings_t ide_pio_timings[6];
26756 -#endif /* _IDE_MODES_H */
26757 diff -Nru a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
26758 --- a/drivers/ide/legacy/ali14xx.c      Tue Aug 12 13:29:09 2003
26759 +++ b/drivers/ide/legacy/ali14xx.c      Sun Aug 24 15:33:30 2003
26760 @@ -54,8 +54,6 @@
26761  
26762  #include <asm/io.h>
26763  
26764 -#include "ide_modes.h"
26765 -
26766  /* port addresses for auto-detection */
26767  #define ALI_NUM_PORTS 4
26768  static int ports[ALI_NUM_PORTS] __initdata = {0x074, 0x0f4, 0x034, 0x0e4};
26769 diff -Nru a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c
26770 --- a/drivers/ide/legacy/dtc2278.c      Tue Aug 12 13:29:09 2003
26771 +++ b/drivers/ide/legacy/dtc2278.c      Sun Aug 24 15:33:30 2003
26772 @@ -21,8 +21,6 @@
26773  
26774  #include <asm/io.h>
26775  
26776 -#include "ide_modes.h"
26777 -
26778  /*
26779   * Changing this #undef to #define may solve start up problems in some systems.
26780   */
26781 diff -Nru a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
26782 --- a/drivers/ide/legacy/ht6560b.c      Tue Aug 12 13:29:09 2003
26783 +++ b/drivers/ide/legacy/ht6560b.c      Sun Aug 24 15:33:30 2003
26784 @@ -53,8 +53,6 @@
26785  
26786  #include <asm/io.h>
26787  
26788 -#include "ide_modes.h"
26789 -
26790  /* #define DEBUG */  /* remove comments for DEBUG messages */
26791  
26792  /*
26793 diff -Nru a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
26794 --- a/drivers/ide/legacy/macide.c       Tue Feb 18 10:06:19 2003
26795 +++ b/drivers/ide/legacy/macide.c       Sun Aug 24 05:37:06 2003
26796 @@ -126,7 +126,7 @@
26797                         /* probing the drive which freezes a 190.       */
26798  
26799                         ide_drive_t *drive = &ide_hwifs[index].drives[0];
26800 -                       drive->capacity = drive->cyl*drive->head*drive->sect;
26801 +                       drive->capacity64 = drive->cyl*drive->head*drive->sect;
26802  
26803  #ifdef CONFIG_BLK_DEV_MAC_MEDIABAY
26804                         request_irq(IRQ_BABOON_2, macide_mediabay_interrupt,
26805 diff -Nru a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
26806 --- a/drivers/ide/legacy/qd65xx.c       Tue Aug 12 13:29:09 2003
26807 +++ b/drivers/ide/legacy/qd65xx.c       Sun Aug 24 15:33:30 2003
26808 @@ -42,7 +42,6 @@
26809  #include <asm/system.h>
26810  #include <asm/io.h>
26811  
26812 -#include "ide_modes.h"
26813  #include "qd65xx.h"
26814  
26815  /*
26816 diff -Nru a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c
26817 --- a/drivers/ide/legacy/umc8672.c      Tue Aug 12 13:29:09 2003
26818 +++ b/drivers/ide/legacy/umc8672.c      Sun Aug 24 15:33:30 2003
26819 @@ -54,8 +54,6 @@
26820  
26821  #include <asm/io.h>
26822  
26823 -#include "ide_modes.h"
26824 -
26825  /*
26826   * Default speeds.  These can be changed with "auto-tune" and/or hdparm.
26827   */
26828 diff -Nru a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
26829 --- a/drivers/ide/pci/aec62xx.c Thu Jul 31 08:58:49 2003
26830 +++ b/drivers/ide/pci/aec62xx.c Sun Aug 24 15:33:30 2003
26831 @@ -16,7 +16,6 @@
26832  
26833  #include <asm/io.h>
26834  
26835 -#include "ide_modes.h"
26836  #include "aec62xx.h"
26837  
26838  #if defined(DISPLAY_AEC62XX_TIMINGS) && defined(CONFIG_PROC_FS)
26839 diff -Nru a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
26840 --- a/drivers/ide/pci/alim15x3.c        Sat Aug 16 06:34:25 2003
26841 +++ b/drivers/ide/pci/alim15x3.c        Sun Aug 24 15:33:30 2003
26842 @@ -37,7 +37,6 @@
26843  
26844  #include <asm/io.h>
26845  
26846 -#include "ide_modes.h"
26847  #include "alim15x3.h"
26848  
26849  /*
26850 diff -Nru a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
26851 --- a/drivers/ide/pci/cmd640.c  Thu Mar 13 16:49:44 2003
26852 +++ b/drivers/ide/pci/cmd640.c  Sun Aug 24 15:33:30 2003
26853 @@ -115,8 +115,6 @@
26854  
26855  #include <asm/io.h>
26856  
26857 -#include "ide_modes.h"
26858 -
26859  /*
26860   * This flag is set in ide.c by the parameter:  ide0=cmd640_vlb
26861   */
26862 diff -Nru a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
26863 --- a/drivers/ide/pci/cmd64x.c  Thu Jul 31 08:58:49 2003
26864 +++ b/drivers/ide/pci/cmd64x.c  Mon Sep  1 08:23:55 2003
26865 @@ -25,7 +25,6 @@
26866  
26867  #include <asm/io.h>
26868  
26869 -#include "ide_modes.h"
26870  #include "cmd64x.h"
26871  
26872  #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS)
26873 @@ -629,10 +628,7 @@
26874  
26875         /* Set a good latency timer and cache line size value. */
26876         (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
26877 -#ifdef __sparc_v9__
26878 -       (void) pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x10);
26879 -#endif
26880 -
26881 +       /* FIXME: pci_set_master() to ensure a good latency timer value */
26882  
26883         /* Setup interrupts. */
26884         (void) pci_read_config_byte(dev, MRDMODE, &mrdmode);
26885 diff -Nru a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
26886 --- a/drivers/ide/pci/cs5520.c  Thu Jul 31 08:58:49 2003
26887 +++ b/drivers/ide/pci/cs5520.c  Sun Aug 24 15:33:30 2003
26888 @@ -51,7 +51,6 @@
26889  #include <asm/io.h>
26890  #include <asm/irq.h>
26891  
26892 -#include "ide_modes.h"
26893  #include "cs5520.h"
26894  
26895  #if defined(DISPLAY_CS5520_TIMINGS) && defined(CONFIG_PROC_FS)
26896 diff -Nru a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
26897 --- a/drivers/ide/pci/cs5530.c  Thu Jul 31 08:58:49 2003
26898 +++ b/drivers/ide/pci/cs5530.c  Sun Aug 24 15:33:30 2003
26899 @@ -31,7 +31,6 @@
26900  #include <asm/io.h>
26901  #include <asm/irq.h>
26902  
26903 -#include "ide_modes.h"
26904  #include "cs5530.h"
26905  
26906  #if defined(DISPLAY_CS5530_TIMINGS) && defined(CONFIG_PROC_FS)
26907 diff -Nru a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
26908 --- a/drivers/ide/pci/cy82c693.c        Thu Jul 31 08:58:49 2003
26909 +++ b/drivers/ide/pci/cy82c693.c        Sun Aug 24 15:33:30 2003
26910 @@ -54,7 +54,6 @@
26911  
26912  #include <asm/io.h>
26913  
26914 -#include "ide_modes.h"
26915  #include "cy82c693.h"
26916  
26917  /*
26918 @@ -113,7 +112,7 @@
26919  
26920         /* note: we use the same values for 16bit IOR and IOW
26921           *     those are all the same, since I don't have other
26922 -        *      timings than those from ide_modes.h
26923 +        *      timings than those from ide-lib.c
26924          */
26925  
26926         p_pclk->time_16r = (u8)clk1;
26927 diff -Nru a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
26928 --- a/drivers/ide/pci/generic.c Thu Jul 31 08:58:49 2003
26929 +++ b/drivers/ide/pci/generic.c Wed Sep  3 07:34:35 2003
26930 @@ -140,6 +140,7 @@
26931         { PCI_VENDOR_ID_HINT,   PCI_DEVICE_ID_HINT_VXPROII_IDE,    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6},
26932         { PCI_VENDOR_ID_VIA,    PCI_DEVICE_ID_VIA_82C561,          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7},
26933         { PCI_VENDOR_ID_OPTI,   PCI_DEVICE_ID_OPTI_82C558,         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8},
26934 +       { PCI_VENDOR_ID_VIA,    PCI_DEVICE_ID_VIA_8237_SATA,       PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9},
26935         { 0, },
26936  };
26937  
26938 diff -Nru a/drivers/ide/pci/generic.h b/drivers/ide/pci/generic.h
26939 --- a/drivers/ide/pci/generic.h Mon Jan 13 17:12:03 2003
26940 +++ b/drivers/ide/pci/generic.h Wed Sep  3 07:37:12 2003
26941 @@ -127,6 +127,19 @@
26942                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
26943                 .bootable       = ON_BOARD,
26944                 .extra          = 0,
26945 +       },{     /* 9 */
26946 +               .vendor         = PCI_VENDOR_ID_VIA,
26947 +               .device         = PCI_DEVICE_ID_VIA_8237_SATA,
26948 +               .name           = "VIA8237SATA",
26949 +               .init_chipset   = init_chipset_generic,
26950 +               .init_iops      = NULL,
26951 +               .init_hwif      = init_hwif_generic,
26952 +               .init_dma       = init_dma_generic,
26953 +               .channels       = 2,
26954 +               .autodma        = AUTODMA,
26955 +               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
26956 +               .bootable       = OFF_BOARD,
26957 +               .extra          = 0,
26958         },{
26959                 .vendor         = 0,
26960                 .device         = 0,
26961 diff -Nru a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
26962 --- a/drivers/ide/pci/hpt34x.c  Thu Jul 31 08:58:49 2003
26963 +++ b/drivers/ide/pci/hpt34x.c  Sun Aug 24 15:33:30 2003
26964 @@ -42,7 +42,6 @@
26965  #include <asm/io.h>
26966  #include <asm/irq.h>
26967  
26968 -#include "ide_modes.h"
26969  #include "hpt34x.h"
26970  
26971  #if defined(DISPLAY_HPT34X_TIMINGS) && defined(CONFIG_PROC_FS)
26972 diff -Nru a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
26973 --- a/drivers/ide/pci/hpt366.c  Mon Aug 11 09:04:06 2003
26974 +++ b/drivers/ide/pci/hpt366.c  Sun Aug 24 15:33:30 2003
26975 @@ -62,7 +62,6 @@
26976  #include <asm/io.h>
26977  #include <asm/irq.h>
26978  
26979 -#include "ide_modes.h"
26980  #include "hpt366.h"
26981  
26982  #if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
26983 @@ -989,7 +988,40 @@
26984         hwif->intrproc                  = &hpt3xx_intrproc;
26985         hwif->maskproc                  = &hpt3xx_maskproc;
26986  
26987 -       pci_read_config_byte(hwif->pci_dev, 0x5a, &ata66);
26988 +       /*
26989 +        * The HPT37x uses the CBLID pins as outputs for MA15/MA16
26990 +        * address lines to access an external eeprom.  To read valid
26991 +        * cable detect state the pins must be enabled as inputs.
26992 +        */
26993 +       if (hpt_minimum_revision(dev, 8) && PCI_FUNC(dev->devfn) & 1) {
26994 +               /*
26995 +                * HPT374 PCI function 1
26996 +                * - set bit 15 of reg 0x52 to enable TCBLID as input
26997 +                * - set bit 15 of reg 0x56 to enable FCBLID as input
26998 +                */
26999 +               u16 mcr3, mcr6;
27000 +               pci_read_config_word(dev, 0x52, &mcr3);
27001 +               pci_read_config_word(dev, 0x56, &mcr6);
27002 +               pci_write_config_word(dev, 0x52, mcr3 | 0x8000);
27003 +               pci_write_config_word(dev, 0x56, mcr6 | 0x8000);
27004 +               /* now read cable id register */
27005 +               pci_read_config_byte(dev, 0x5a, &ata66);
27006 +               pci_write_config_word(dev, 0x52, mcr3);
27007 +               pci_write_config_word(dev, 0x56, mcr6);
27008 +       } else if (hpt_minimum_revision(dev, 3)) {
27009 +               /*
27010 +                * HPT370/372 and 374 pcifn 0
27011 +                * - clear bit 0 of 0x5b to enable P/SCBLID as inputs
27012 +                */
27013 +               u8 scr2;
27014 +               pci_read_config_byte(dev, 0x5b, &scr2);
27015 +               pci_write_config_byte(dev, 0x5b, scr2 & ~1);
27016 +               /* now read cable id register */
27017 +               pci_read_config_byte(dev, 0x5a, &ata66);
27018 +               pci_write_config_byte(dev, 0x5b, scr2);
27019 +       } else {
27020 +               pci_read_config_byte(dev, 0x5a, &ata66);
27021 +       }
27022  
27023  #ifdef DEBUG
27024         printk("HPT366: reg5ah=0x%02x ATA-%s Cable Port%d\n",
27025 diff -Nru a/drivers/ide/pci/it8172.c b/drivers/ide/pci/it8172.c
27026 --- a/drivers/ide/pci/it8172.c  Thu Jul 31 08:58:49 2003
27027 +++ b/drivers/ide/pci/it8172.c  Sun Aug 24 15:33:30 2003
27028 @@ -42,7 +42,6 @@
27029  #include <asm/io.h>
27030  #include <asm/it8172/it8172_int.h>
27031  
27032 -#include "ide_modes.h"
27033  #include "it8172.h"
27034  
27035  /*
27036 diff -Nru a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
27037 --- a/drivers/ide/pci/ns87415.c Thu Jul 31 08:58:49 2003
27038 +++ b/drivers/ide/pci/ns87415.c Mon Sep  1 08:23:55 2003
27039 @@ -147,9 +147,7 @@
27040  
27041         /* Set a good latency timer and cache line size value. */
27042         (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
27043 -#ifdef __sparc_v9__
27044 -       (void) pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x10);
27045 -#endif
27046 +       /* FIXME: use pci_set_master() to ensure good latency timer value */
27047  
27048         /*
27049          * We cannot probe for IRQ: both ports share common IRQ on INTA.
27050 diff -Nru a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
27051 --- a/drivers/ide/pci/opti621.c Thu Jul 31 08:58:49 2003
27052 +++ b/drivers/ide/pci/opti621.c Sun Aug 24 15:33:30 2003
27053 @@ -104,7 +104,6 @@
27054  
27055  #include <asm/io.h>
27056  
27057 -#include "ide_modes.h"
27058  #include "opti621.h"
27059  
27060  #define OPTI621_MAX_PIO 3
27061 diff -Nru a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
27062 --- a/drivers/ide/pci/pdc202xx_new.c    Thu Jul 31 08:58:49 2003
27063 +++ b/drivers/ide/pci/pdc202xx_new.c    Sun Aug 24 15:33:30 2003
27064 @@ -32,7 +32,6 @@
27065  #include <asm/io.h>
27066  #include <asm/irq.h>
27067  
27068 -#include "ide_modes.h"
27069  #include "pdc202xx_new.h"
27070  
27071  #define PDC202_DEBUG_CABLE     0
27072 diff -Nru a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
27073 --- a/drivers/ide/pci/pdc202xx_old.c    Wed Aug 13 17:45:49 2003
27074 +++ b/drivers/ide/pci/pdc202xx_old.c    Wed Sep  3 06:34:40 2003
27075 @@ -46,7 +46,6 @@
27076  #include <asm/io.h>
27077  #include <asm/irq.h>
27078  
27079 -#include "ide_modes.h"
27080  #include "pdc202xx_old.h"
27081  
27082  #define PDC202_DEBUG_CABLE     0
27083 @@ -748,9 +747,6 @@
27084         hwif->autodma = 0;
27085         hwif->tuneproc  = &config_chipset_for_pio;
27086         hwif->quirkproc = &pdc202xx_quirkproc;
27087 -
27088 -       if (hwif->pci_dev->device == PCI_DEVICE_ID_PROMISE_20265)
27089 -               hwif->no_lba48 = (hwif->channel) ? 0 : 1;
27090  
27091         if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) {
27092                 hwif->busproc   = &pdc202xx_tristate;
27093 diff -Nru a/drivers/ide/pci/pdcadma.c b/drivers/ide/pci/pdcadma.c
27094 --- a/drivers/ide/pci/pdcadma.c Thu Jul 31 08:58:49 2003
27095 +++ b/drivers/ide/pci/pdcadma.c Sun Aug 24 15:33:30 2003
27096 @@ -24,7 +24,6 @@
27097  #include <asm/io.h>
27098  #include <asm/irq.h>
27099  
27100 -#include "ide_modes.h"
27101  #include "pdcadma.h"
27102  
27103  #if defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS)
27104 diff -Nru a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
27105 --- a/drivers/ide/pci/piix.c    Thu Jul 31 08:58:49 2003
27106 +++ b/drivers/ide/pci/piix.c    Sun Aug 24 15:33:30 2003
27107 @@ -103,7 +103,6 @@
27108  
27109  #include <asm/io.h>
27110  
27111 -#include "ide_modes.h"
27112  #include "piix.h"
27113  
27114  static int no_piix_dma;
27115 diff -Nru a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
27116 --- a/drivers/ide/pci/sc1200.c  Thu Jul 31 08:58:49 2003
27117 +++ b/drivers/ide/pci/sc1200.c  Sun Aug 24 15:33:30 2003
27118 @@ -29,7 +29,6 @@
27119  #include <asm/io.h>
27120  #include <asm/irq.h>
27121  
27122 -#include "ide_modes.h"
27123  #include "sc1200.h"
27124  
27125  #define SC1200_REV_A   0x00
27126 diff -Nru a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
27127 --- a/drivers/ide/pci/serverworks.c     Thu Jul 31 08:58:49 2003
27128 +++ b/drivers/ide/pci/serverworks.c     Sun Aug 24 15:33:30 2003
27129 @@ -39,7 +39,6 @@
27130  
27131  #include <asm/io.h>
27132  
27133 -#include "ide_modes.h"
27134  #include "serverworks.h"
27135  
27136  static u8 svwks_revision = 0;
27137 diff -Nru a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
27138 --- a/drivers/ide/pci/siimage.c Wed Aug 13 17:45:20 2003
27139 +++ b/drivers/ide/pci/siimage.c Mon Sep  1 15:53:57 2003
27140 @@ -1,7 +1,24 @@
27141  /*
27142 - * linux/drivers/ide/pci/siimage.c             Version 1.02    Jan 30, 2003
27143 + * linux/drivers/ide/pci/siimage.c             Version 1.06    June 11, 2003
27144   *
27145   * Copyright (C) 2001-2002     Andre Hedrick <andre@linux-ide.org>
27146 + * Copyright (C) 2003          Red Hat <alan@redhat.com>
27147 + *
27148 + *  May be copied or modified under the terms of the GNU General Public License
27149 + *
27150 + *  Documentation available under NDA only
27151 + *
27152 + *
27153 + *  FAQ Items:
27154 + *     If you are using Marvell SATA-IDE adapters with Maxtor drives
27155 + *     ensure the system is set up for ATA100/UDMA5 not UDMA6.
27156 + *
27157 + *     If you are using WD drives with SATA bridges you must set the
27158 + *     drive to "Single". "Master" will hang
27159 + *
27160 + *     If you have strange problems with nVidia chipset systems please
27161 + *     see the SI support documentation and update your system BIOS
27162 + *     if neccessary
27163   */
27164  
27165  #include <linux/config.h>
27166 @@ -15,7 +32,6 @@
27167  
27168  #include <asm/io.h>
27169  
27170 -#include "ide_modes.h"
27171  #include "siimage.h"
27172  
27173  #if defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS)
27174 @@ -23,16 +39,107 @@
27175  #include <linux/proc_fs.h>
27176  
27177  static u8 siimage_proc = 0;
27178 -#define SIIMAGE_MAX_DEVS               5
27179 +#define SIIMAGE_MAX_DEVS               16
27180  static struct pci_dev *siimage_devs[SIIMAGE_MAX_DEVS];
27181  static int n_siimage_devs;
27182  
27183 -static char * print_siimage_get_info (char *buf, struct pci_dev *dev, int index)
27184 +/**
27185 + *     pdev_is_sata            -       check if device is SATA
27186 + *     @pdev:  PCI device to check
27187 + *     
27188 + *     Returns true if this is a SATA controller
27189 + */
27190
27191 +static int pdev_is_sata(struct pci_dev *pdev)
27192 +{
27193 +       switch(pdev->device)
27194 +       {
27195 +               case PCI_DEVICE_ID_SII_3112:
27196 +               case PCI_DEVICE_ID_SII_1210SA:
27197 +                       return 1;
27198 +               case PCI_DEVICE_ID_SII_680:
27199 +                       return 0;
27200 +       }
27201 +       BUG();
27202 +       return 0;
27203 +}
27204
27205 +/**
27206 + *     is_sata                 -       check if hwif is SATA
27207 + *     @hwif:  interface to check
27208 + *     
27209 + *     Returns true if this is a SATA controller
27210 + */
27211
27212 +static inline int is_sata(ide_hwif_t *hwif)
27213 +{
27214 +       return pdev_is_sata(hwif->pci_dev);
27215 +}
27216 +
27217 +/**
27218 + *     siimage_selreg          -       return register base
27219 + *     @hwif: interface
27220 + *     @r: config offset
27221 + *
27222 + *     Turn a config register offset into the right address in either
27223 + *     PCI space or MMIO space to access the control register in question
27224 + *     Thankfully this is a configuration operation so isnt performance
27225 + *     criticial. 
27226 + */
27227
27228 +static unsigned long siimage_selreg(ide_hwif_t *hwif, int r)
27229 +{
27230 +       unsigned long base = (unsigned long)hwif->hwif_data;
27231 +       base += 0xA0 + r;
27232 +       if(hwif->mmio)
27233 +               base += (hwif->channel << 6);
27234 +       else
27235 +               base += (hwif->channel << 4);
27236 +       return base;
27237 +}
27238 +       
27239 +/**
27240 + *     siimage_seldev          -       return register base
27241 + *     @hwif: interface
27242 + *     @r: config offset
27243 + *
27244 + *     Turn a config register offset into the right address in either
27245 + *     PCI space or MMIO space to access the control register in question
27246 + *     including accounting for the unit shift.
27247 + */
27248
27249 +static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
27250 +{
27251 +       ide_hwif_t *hwif        = HWIF(drive);
27252 +       unsigned long base = (unsigned long)hwif->hwif_data;
27253 +       base += 0xA0 + r;
27254 +       if(hwif->mmio)
27255 +               base += (hwif->channel << 6);
27256 +       else
27257 +               base += (hwif->channel << 4);
27258 +       base |= drive->select.b.unit << drive->select.b.unit;
27259 +       return base;
27260 +}
27261 +       
27262 +/**
27263 + *     print_siimage_get_info  -       print minimal proc information
27264 + *     @buf: buffer to write into (kernel space)
27265 + *     @dev: PCI device we are describing
27266 + *     @index: Controller number
27267 + *
27268 + *     Print the basic information for the state of the CMD680/SI3112
27269 + *     channel. We don't actually dump a lot of information out for
27270 + *     this controller although we could expand it if we needed.
27271 + */
27272
27273 +static char *print_siimage_get_info (char *buf, struct pci_dev *dev, int index)
27274  {
27275         char *p         = buf;
27276         u8 mmio         = (pci_get_drvdata(dev) != NULL) ? 1 : 0;
27277 -       unsigned long bmdma     = (mmio) ? ((unsigned long) pci_get_drvdata(dev)) :
27278 -                                   (pci_resource_start(dev, 4));
27279 +       unsigned long bmdma = pci_resource_start(dev, 4);
27280 +       
27281 +       if(mmio)
27282 +               bmdma = pci_resource_start(dev, 5);
27283  
27284         p += sprintf(p, "\nController: %d\n", index);
27285         p += sprintf(p, "SiI%x Chipset.\n", dev->device);
27286 @@ -40,18 +147,20 @@
27287                 p += sprintf(p, "MMIO Base 0x%lx\n", bmdma);
27288         p += sprintf(p, "%s-DMA Base 0x%lx\n", (mmio)?"MMIO":"BM", bmdma);
27289         p += sprintf(p, "%s-DMA Base 0x%lx\n", (mmio)?"MMIO":"BM", bmdma+8);
27290 -
27291 -       p += sprintf(p, "--------------- Primary Channel "
27292 -                       "---------------- Secondary Channel "
27293 -                       "-------------\n");
27294 -       p += sprintf(p, "--------------- drive0 --------- drive1 "
27295 -                       "-------- drive0 ---------- drive1 ------\n");
27296 -       p += sprintf(p, "PIO Mode:       %s                %s"
27297 -                       "               %s                 %s\n",
27298 -                       "?", "?", "?", "?");
27299         return (char *)p;
27300  }
27301  
27302 +/**
27303 + *     siimage_get_info        -       proc callback
27304 + *     @buffer: kernel buffer to complete
27305 + *     @addr: written with base of data to return
27306 + *     offset: seek offset
27307 + *     count: bytes to fill in 
27308 + *
27309 + *     Called when the user reads data from the virtual file for this
27310 + *     controller from /proc
27311 + */
27312
27313  static int siimage_get_info (char *buffer, char **addr, off_t offset, int count)
27314  {
27315         char *p = buffer;
27316 @@ -72,46 +181,70 @@
27317  
27318  #endif /* defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS) */
27319  
27320 +/**
27321 + *     siimage_ratemask        -       Compute available modes
27322 + *     @drive: IDE drive
27323 + *
27324 + *     Compute the available speeds for the devices on the interface.
27325 + *     For the CMD680 this depends on the clocking mode (scsc), for the
27326 + *     SI3312 SATA controller life is a bit simpler. Enforce UDMA33
27327 + *     as a limit if there is no 80pin cable present.
27328 + */
27329
27330  static byte siimage_ratemask (ide_drive_t *drive)
27331  {
27332         ide_hwif_t *hwif        = HWIF(drive);
27333         u8 mode = 0, scsc = 0;
27334 +       unsigned long base = (unsigned long) hwif->hwif_data;
27335  
27336         if (hwif->mmio)
27337 -               scsc = hwif->INB(HWIFADDR(0x4A));
27338 +               scsc = hwif->INB(base + 0x4A);
27339         else
27340                 pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc);
27341  
27342 -       switch(hwif->pci_dev->device) {
27343 -               case PCI_DEVICE_ID_SII_3112:
27344 -                       return 4;
27345 -               case PCI_DEVICE_ID_SII_680:
27346 -                       if ((scsc & 0x10) == 0x10)      /* 133 */
27347 -                               mode = 4;
27348 -                       else if ((scsc & 0x30) == 0x00) /* 100 */
27349 -                               mode = 3;
27350 -                       else if ((scsc & 0x20) == 0x20) /* 66 eek */
27351 -                               BUG();  // mode = 2;
27352 -                       break;
27353 -               default:        return 0;
27354 +       if(is_sata(hwif))
27355 +       {
27356 +               if(strstr(drive->id->model, "Maxtor"))
27357 +                       return 3;
27358 +               return 4;
27359         }
27360 +       
27361 +       if ((scsc & 0x30) == 0x10)      /* 133 */
27362 +               mode = 4;
27363 +       else if ((scsc & 0x30) == 0x20) /* 2xPCI */
27364 +               mode = 4;
27365 +       else if ((scsc & 0x30) == 0x00) /* 100 */
27366 +               mode = 3;
27367 +       else    /* Disabled ? */
27368 +               BUG();
27369 +
27370         if (!eighty_ninty_three(drive))
27371                 mode = min(mode, (u8)1);
27372         return mode;
27373  }
27374  
27375 +/**
27376 + *     siimage_taskfile_timing -       turn timing data to a mode
27377 + *     @hwif: interface to query
27378 + *
27379 + *     Read the timing data for the interface and return the 
27380 + *     mode that is being used.
27381 + */
27382
27383  static byte siimage_taskfile_timing (ide_hwif_t *hwif)
27384  {
27385         u16 timing      = 0x328a;
27386 +       unsigned long addr = siimage_selreg(hwif, 2);
27387  
27388         if (hwif->mmio)
27389 -               timing = hwif->INW(SELADDR(2));
27390 +               timing = hwif->INW(addr);
27391         else
27392 -               pci_read_config_word(hwif->pci_dev, SELREG(2), &timing);
27393 +               pci_read_config_word(hwif->pci_dev, addr, &timing);
27394  
27395         switch (timing) {
27396                 case 0x10c1:    return 4;
27397                 case 0x10c3:    return 3;
27398 +               case 0x1104:
27399                 case 0x1281:    return 2;
27400                 case 0x2283:    return 1;
27401                 case 0x328a:
27402 @@ -119,34 +252,88 @@
27403         }
27404  }
27405  
27406 +/**
27407 + *     simmage_tuneproc        -       tune a drive
27408 + *     @drive: drive to tune
27409 + *     @mode_wanted: the target operating mode
27410 + *
27411 + *     Load the timing settings for this device mode into the
27412 + *     controller. If we are in PIO mode 3 or 4 turn on IORDY
27413 + *     monitoring (bit 9). The TF timing is bits 31:16
27414 + */
27415
27416  static void siimage_tuneproc (ide_drive_t *drive, byte mode_wanted)
27417  {
27418         ide_hwif_t *hwif        = HWIF(drive);
27419 -       struct pci_dev *dev     = hwif->pci_dev;
27420 -       u16 speedt              = 0;
27421 -       u8 unit                 = drive->select.b.unit;
27422 -
27423 -       if (hwif->mmio)
27424 -               speedt = hwif->INW(SELADDR(0x04|(unit<<unit)));
27425 -       else
27426 -               pci_read_config_word(dev, SELADDR(0x04|(unit<<unit)), &speedt);
27427 -
27428 +       u32 speedt              = 0;
27429 +       u16 speedp              = 0;
27430 +       unsigned long addr      = siimage_seldev(drive, 0x04);
27431 +       unsigned long tfaddr    = siimage_selreg(hwif, 0x02);
27432 +       
27433         /* cheat for now and use the docs */
27434 -//     switch(siimage_taskfile_timing(hwif)) {
27435         switch(mode_wanted) {
27436 -               case 4:         speedt = 0x10c1; break;
27437 -               case 3:         speedt = 0x10C3; break;
27438 -               case 2:         speedt = 0x1104; break;
27439 -               case 1:         speedt = 0x2283; break;
27440 +               case 4: 
27441 +                       speedp = 0x10c1; 
27442 +                       speedt = 0x10c1;
27443 +                       break;
27444 +               case 3: 
27445 +                       speedp = 0x10C3; 
27446 +                       speedt = 0x10C3;
27447 +                       break;
27448 +               case 2: 
27449 +                       speedp = 0x1104; 
27450 +                       speedt = 0x1281;
27451 +                       break;
27452 +               case 1:         
27453 +                       speedp = 0x2283; 
27454 +                       speedt = 0x1281;
27455 +                       break;
27456                 case 0:
27457 -               default:        speedt = 0x328A; break;
27458 +               default:
27459 +                       speedp = 0x328A; 
27460 +                       speedt = 0x328A;
27461 +                       break;
27462         }
27463         if (hwif->mmio)
27464 -               hwif->OUTW(speedt, SELADDR(0x04|(unit<<unit)));
27465 +       {
27466 +               hwif->OUTW(speedt, addr);
27467 +               hwif->OUTW(speedp, tfaddr);
27468 +               /* Now set up IORDY */
27469 +               if(mode_wanted == 3 || mode_wanted == 4)
27470 +                       hwif->OUTW(hwif->INW(tfaddr-2)|0x200, tfaddr-2);
27471 +               else
27472 +                       hwif->OUTW(hwif->INW(tfaddr-2)&~0x200, tfaddr-2);
27473 +       }
27474         else
27475 -               pci_write_config_word(dev, SELADDR(0x04|(unit<<unit)), speedt);
27476 +       {
27477 +               pci_write_config_word(hwif->pci_dev, addr, speedp);
27478 +               pci_write_config_word(hwif->pci_dev, tfaddr, speedt);
27479 +               pci_read_config_word(hwif->pci_dev, tfaddr-2, &speedp);
27480 +               speedp &= ~0x200;
27481 +               /* Set IORDY for mode 3 or 4 */
27482 +               if(mode_wanted == 3 || mode_wanted == 4)
27483 +                       speedp |= 0x200;
27484 +               pci_write_config_word(hwif->pci_dev, tfaddr-2, speedp);
27485 +       }
27486  }
27487  
27488 +/**
27489 + *     config_siimage_chipset_for_pio  -       set drive timings
27490 + *     @drive: drive to tune
27491 + *     @speed we want
27492 + *
27493 + *     Compute the best pio mode we can for a given device. Also honour
27494 + *     the timings for the driver when dealing with mixed devices. Some
27495 + *     of this is ugly but its all wrapped up here
27496 + *
27497 + *     The SI680 can also do VDMA - we need to start using that
27498 + *
27499 + *     FIXME: we use the BIOS channel timings to avoid driving the task
27500 + *     files too fast at the disk. We need to compute the master/slave
27501 + *     drive PIO mode properly so that we can up the speed on a hotplug
27502 + *     system.
27503 + */
27504
27505  static void config_siimage_chipset_for_pio (ide_drive_t *drive, byte set_speed)
27506  {
27507         u8 channel_timings      = siimage_taskfile_timing(HWIF(drive));
27508 @@ -167,6 +354,16 @@
27509         config_siimage_chipset_for_pio(drive, set_speed);
27510  }
27511  
27512 +/**
27513 + *     siimage_tune_chipset    -       set controller timings
27514 + *     @drive: Drive to set up
27515 + *     @xferspeed: speed we want to achieve
27516 + *
27517 + *     Tune the SII chipset for the desired mode. If we can't achieve
27518 + *     the desired mode then tune for a lower one, but ultimately
27519 + *     make the thing work.
27520 + */
27521
27522  static int siimage_tune_chipset (ide_drive_t *drive, byte xferspeed)
27523  {
27524         u8 ultra6[]             = { 0x0F, 0x0B, 0x07, 0x05, 0x03, 0x02, 0x01 };
27525 @@ -176,30 +373,32 @@
27526         ide_hwif_t *hwif        = HWIF(drive);
27527         u16 ultra = 0, multi    = 0;
27528         u8 mode = 0, unit       = drive->select.b.unit;
27529 -       u8 speed        = ide_rate_filter(siimage_ratemask(drive), xferspeed);
27530 +       u8 speed                = ide_rate_filter(siimage_ratemask(drive), xferspeed);
27531 +       unsigned long base      = (unsigned long)hwif->hwif_data;
27532         u8 scsc = 0, addr_mask  = ((hwif->channel) ?
27533                                     ((hwif->mmio) ? 0xF4 : 0x84) :
27534                                     ((hwif->mmio) ? 0xB4 : 0x80));
27535 +                                   
27536 +       unsigned long ma        = siimage_seldev(drive, 0x08);
27537 +       unsigned long ua        = siimage_seldev(drive, 0x0C);
27538  
27539         if (hwif->mmio) {
27540 -               scsc = hwif->INB(HWIFADDR(0x4A));
27541 -               mode = hwif->INB(HWIFADDR(addr_mask));
27542 -               multi = hwif->INW(SELADDR(0x08|(unit<<unit)));
27543 -               ultra = hwif->INW(SELADDR(0x0C|(unit<<unit)));
27544 +               scsc = hwif->INB(base + 0x4A);
27545 +               mode = hwif->INB(base + addr_mask);
27546 +               multi = hwif->INW(ma);
27547 +               ultra = hwif->INW(ua);
27548         } else {
27549 -               pci_read_config_byte(hwif->pci_dev, HWIFADDR(0x8A), &scsc);
27550 +               pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc);
27551                 pci_read_config_byte(hwif->pci_dev, addr_mask, &mode);
27552 -               pci_read_config_word(hwif->pci_dev,
27553 -                               SELREG(0x08|(unit<<unit)), &multi);
27554 -               pci_read_config_word(hwif->pci_dev,
27555 -                               SELREG(0x0C|(unit<<unit)), &ultra);
27556 +               pci_read_config_word(hwif->pci_dev, ma, &multi);
27557 +               pci_read_config_word(hwif->pci_dev, ua, &ultra);
27558         }
27559  
27560         mode &= ~((unit) ? 0x30 : 0x03);
27561         ultra &= ~0x3F;
27562         scsc = ((scsc & 0x30) == 0x00) ? 0 : 1;
27563  
27564 -       scsc = (hwif->pci_dev->device == PCI_DEVICE_ID_SII_3112) ? 1 : scsc;
27565 +       scsc = is_sata(hwif) ? 1 : scsc;
27566  
27567         switch(speed) {
27568                 case XFER_PIO_4:
27569 @@ -225,8 +424,8 @@
27570                 case XFER_UDMA_1:
27571                 case XFER_UDMA_0:
27572                         multi = dma[2];
27573 -                       ultra |= ((scsc) ? (ultra5[speed - XFER_UDMA_0]) :
27574 -                                          (ultra6[speed - XFER_UDMA_0]));
27575 +                       ultra |= ((scsc) ? (ultra6[speed - XFER_UDMA_0]) :
27576 +                                          (ultra5[speed - XFER_UDMA_0]));
27577                         mode |= ((unit) ? 0x30 : 0x03);
27578                         config_siimage_chipset_for_pio(drive, 0);
27579                         break;
27580 @@ -235,20 +434,26 @@
27581         }
27582  
27583         if (hwif->mmio) {
27584 -               hwif->OUTB(mode, HWIFADDR(addr_mask));
27585 -               hwif->OUTW(multi, SELADDR(0x08|(unit<<unit)));
27586 -               hwif->OUTW(ultra, SELADDR(0x0C|(unit<<unit)));
27587 +               hwif->OUTB(mode, base + addr_mask);
27588 +               hwif->OUTW(multi, ma);
27589 +               hwif->OUTW(ultra, ua);
27590         } else {
27591                 pci_write_config_byte(hwif->pci_dev, addr_mask, mode);
27592 -               pci_write_config_word(hwif->pci_dev,
27593 -                               SELREG(0x08|(unit<<unit)), multi);
27594 -               pci_write_config_word(hwif->pci_dev,
27595 -                               SELREG(0x0C|(unit<<unit)), ultra);
27596 +               pci_write_config_word(hwif->pci_dev, ma, multi);
27597 +               pci_write_config_word(hwif->pci_dev, ua, ultra);
27598         }
27599 -
27600         return (ide_config_drive_speed(drive, speed));
27601  }
27602  
27603 +/**
27604 + *     config_chipset_for_dma  -       configure for DMA
27605 + *     @drive: drive to configure
27606 + *
27607 + *     Called by the IDE layer when it wants the timings set up.
27608 + *     For the CMD680 we also need to set up the PIO timings and
27609 + *     enable DMA.
27610 + */
27611
27612  static int config_chipset_for_dma (ide_drive_t *drive)
27613  {
27614         u8 speed        = ide_dma_speed(drive, siimage_ratemask(drive));
27615 @@ -267,14 +472,22 @@
27616         return ide_dma_enable(drive);
27617  }
27618  
27619 +/**
27620 + *     siimage_configure_drive_for_dma -       set up for DMA transfers
27621 + *     @drive: drive we are going to set up
27622 + *
27623 + *     Set up the drive for DMA, tune the controller and drive as 
27624 + *     required. If the drive isn't suitable for DMA or we hit
27625 + *     other problems then we will drop down to PIO and set up
27626 + *     PIO appropriately
27627 + */
27628
27629  static int siimage_config_drive_for_dma (ide_drive_t *drive)
27630  {
27631         ide_hwif_t *hwif        = HWIF(drive);
27632         struct hd_driveid *id   = drive->id;
27633  
27634 -       if (id != NULL && (id->capability & 1) != 0 && drive->autodma) {
27635 -               if (!(hwif->atapi_dma))
27636 -                       goto fast_ata_pio;
27637 +       if ((id->capability & 1) != 0 && drive->autodma) {
27638                 /* Consult the list of known "bad" drives */
27639                 if (hwif->ide_dma_bad_drive(drive))
27640                         goto fast_ata_pio;
27641 @@ -316,18 +529,28 @@
27642  {
27643         ide_hwif_t *hwif        = HWIF(drive);
27644         u8 dma_altstat          = 0;
27645 +       unsigned long addr      = siimage_selreg(hwif, 1);
27646  
27647         /* return 1 if INTR asserted */
27648         if ((hwif->INB(hwif->dma_status) & 4) == 4)
27649                 return 1;
27650  
27651         /* return 1 if Device INTR asserted */
27652 -       pci_read_config_byte(hwif->pci_dev, SELREG(1), &dma_altstat);
27653 +       pci_read_config_byte(hwif->pci_dev, addr, &dma_altstat);
27654         if (dma_altstat & 8)
27655                 return 0;       //return 1;
27656         return 0;
27657  }
27658  
27659 +/**
27660 + *     siimage_mmio_ide_dma_count      -       DMA bytes done
27661 + *     @drive
27662 + *
27663 + *     If we are doing VDMA the CMD680 requires a little bit
27664 + *     of more careful handling and we have to read the counts
27665 + *     off ourselves. For non VDMA life is normal.
27666 + */
27667
27668  static int siimage_mmio_ide_dma_count (ide_drive_t *drive)
27669  {
27670  #ifdef SIIMAGE_VIRTUAL_DMAPIO
27671 @@ -335,9 +558,10 @@
27672         ide_hwif_t *hwif        = HWIF(drive);
27673         u32 count               = (rq->nr_sectors * SECTOR_SIZE);
27674         u32 rcount              = 0;
27675 +       unsigned long addr      = siimage_selreg(hwif, 0x1C);
27676  
27677 -       hwif->OUTL(count, SELADDR(0x1C));
27678 -       rcount = hwif->INL(SELADDR(0x1C));
27679 +       hwif->OUTL(count, addr);
27680 +       rcount = hwif->INL(addr);
27681  
27682         printk("\n%s: count = %d, rcount = %d, nr_sectors = %lu\n",
27683                 drive->name, count, rcount, rq->nr_sectors);
27684 @@ -346,13 +570,22 @@
27685         return __ide_dma_count(drive);
27686  }
27687  
27688 -/* returns 1 if dma irq issued, 0 otherwise */
27689 +/**
27690 + *     siimage_mmio_ide_dma_test_irq   -       check we caused an IRQ
27691 + *     @drive: drive we are testing
27692 + *
27693 + *     Check if we caused an IDE DMA interrupt. We may also have caused
27694 + *     SATA status interrupts, if so we clean them up and continue.
27695 + */
27696
27697  static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
27698  {
27699         ide_hwif_t *hwif        = HWIF(drive);
27700 +       unsigned long base      = (unsigned long)hwif->hwif_data;
27701 +       unsigned long addr      = siimage_selreg(hwif, 0x1);
27702  
27703         if (SATA_ERROR_REG) {
27704 -               u32 ext_stat = hwif->INL(HWIFADDR(0x10));
27705 +               u32 ext_stat = hwif->INL(base + 0x10);
27706                 u8 watchdog = 0;
27707                 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) {
27708                         u32 sata_error = hwif->INL(SATA_ERROR_REG);
27709 @@ -379,7 +612,7 @@
27710                 return 1;
27711  
27712         /* return 1 if Device INTR asserted */
27713 -       if ((hwif->INB(SELADDR(1)) & 8) == 8)
27714 +       if ((hwif->INB(addr) & 8) == 8)
27715                 return 0;       //return 1;
27716  
27717         return 0;
27718 @@ -388,21 +621,29 @@
27719  static int siimage_mmio_ide_dma_verbose (ide_drive_t *drive)
27720  {
27721         int temp = __ide_dma_verbose(drive);
27722 -#if 0
27723 -       drive->using_dma = 0;
27724 -#endif
27725         return temp;
27726  }
27727  
27728 +/**
27729 + *     siimage_busproc         -       bus isolation ioctl
27730 + *     @drive: drive to isolate/restore
27731 + *     @state: bus state to set
27732 + *
27733 + *     Used by the SII3112 to handle bus isolation. As this is a 
27734 + *     SATA controller the work required is quite limited, we 
27735 + *     just have to clean up the statistics
27736 + */
27737
27738  static int siimage_busproc (ide_drive_t * drive, int state)
27739  {
27740         ide_hwif_t *hwif        = HWIF(drive);
27741         u32 stat_config         = 0;
27742 +       unsigned long addr      = siimage_selreg(hwif, 0);
27743  
27744         if (hwif->mmio) {
27745 -               stat_config = hwif->INL(SELADDR(0));
27746 +               stat_config = hwif->INL(addr);
27747         } else
27748 -               pci_read_config_dword(hwif->pci_dev, SELREG(0), &stat_config);
27749 +               pci_read_config_dword(hwif->pci_dev, addr, &stat_config);
27750  
27751         switch (state) {
27752                 case BUSSTATE_ON:
27753 @@ -418,12 +659,20 @@
27754                         hwif->drives[1].failures = hwif->drives[1].max_failures + 1;
27755                         break;
27756                 default:
27757 -                       return 0;
27758 +                       return -EINVAL;
27759         }
27760         hwif->bus_state = state;
27761         return 0;
27762  }
27763  
27764 +/**
27765 + *     siimage_reset_poll      -       wait for sata reset
27766 + *     @drive: drive we are resetting
27767 + *
27768 + *     Poll the SATA phy and see whether it has come back from the dead
27769 + *     yet.
27770 + */
27771
27772  static int siimage_reset_poll (ide_drive_t *drive)
27773  {
27774         if (SATA_STATUS_REG) {
27775 @@ -433,13 +682,7 @@
27776                         printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n",
27777                                 hwif->name, hwif->INL(SATA_STATUS_REG));
27778                         HWGROUP(drive)->poll_timeout = 0;
27779 -#if 0
27780 -                       drive->failures++;
27781 -                       return ide_stopped;
27782 -#else
27783                         return ide_started;
27784 -#endif
27785 -                       return 1;
27786                 }
27787                 return 0;
27788         } else {
27789 @@ -447,34 +690,53 @@
27790         }
27791  }
27792  
27793 +/**
27794 + *     siimage_pre_reset       -       reset hook
27795 + *     @drive: IDE device being reset
27796 + *
27797 + *     For the SATA devices we need to handle recalibration/geometry
27798 + *     differently
27799 + */
27800
27801  static void siimage_pre_reset (ide_drive_t *drive)
27802  {
27803         if (drive->media != ide_disk)
27804                 return;
27805  
27806 -       if (HWIF(drive)->pci_dev->device == PCI_DEVICE_ID_SII_3112) {
27807 +       if (is_sata(HWIF(drive)))
27808 +       {
27809                 drive->special.b.set_geometry = 0;
27810                 drive->special.b.recalibrate = 0;
27811         }
27812  }
27813  
27814 +/**
27815 + *     siimage_reset   -       reset a device on an siimage controller
27816 + *     @drive: drive to reset
27817 + *
27818 + *     Perform a controller level reset fo the device. For
27819 + *     SATA we must also check the PHY.
27820 + */
27821
27822  static void siimage_reset (ide_drive_t *drive)
27823  {
27824         ide_hwif_t *hwif        = HWIF(drive);
27825         u8 reset                = 0;
27826 +       unsigned long addr      = siimage_selreg(hwif, 0);
27827  
27828         if (hwif->mmio) {
27829 -               reset = hwif->INB(SELADDR(0));
27830 -               hwif->OUTB((reset|0x03), SELADDR(0));
27831 +               reset = hwif->INB(addr);
27832 +               hwif->OUTB((reset|0x03), addr);
27833 +               /* FIXME:posting */
27834                 udelay(25);
27835 -               hwif->OUTB(reset, SELADDR(0));
27836 -               (void) hwif->INB(SELADDR(0));
27837 +               hwif->OUTB(reset, addr);
27838 +               (void) hwif->INB(addr);
27839         } else {
27840 -               pci_read_config_byte(hwif->pci_dev, SELREG(0), &reset);
27841 -               pci_write_config_byte(hwif->pci_dev, SELREG(0), reset|0x03);
27842 +               pci_read_config_byte(hwif->pci_dev, addr, &reset);
27843 +               pci_write_config_byte(hwif->pci_dev, addr, reset|0x03);
27844                 udelay(25);
27845 -               pci_write_config_byte(hwif->pci_dev, SELREG(0), reset);
27846 -               pci_read_config_byte(hwif->pci_dev, SELREG(0), &reset);
27847 +               pci_write_config_byte(hwif->pci_dev, addr, reset);
27848 +               pci_read_config_byte(hwif->pci_dev, addr, &reset);
27849         }
27850  
27851         if (SATA_STATUS_REG) {
27852 @@ -490,20 +752,28 @@
27853  
27854  }
27855  
27856 +/**
27857 + *     proc_reports_siimage            -       add siimage controller to proc
27858 + *     @dev: PCI device
27859 + *     @clocking: SCSC value
27860 + *     @name: controller name
27861 + *
27862 + *     Report the clocking mode of the controller and add it to
27863 + *     the /proc interface layer
27864 + */
27865
27866  static void proc_reports_siimage (struct pci_dev *dev, u8 clocking, const char *name)
27867  {
27868 -       if (dev->device == PCI_DEVICE_ID_SII_3112)
27869 +       if(pdev_is_sata(dev))
27870                 goto sata_skip;
27871  
27872         printk(KERN_INFO "%s: BASE CLOCK ", name);
27873 -       clocking &= ~0x0C;
27874 +       clocking &= 0x03;
27875         switch(clocking) {
27876                 case 0x03: printk("DISABLED !\n"); break;
27877                 case 0x02: printk("== 2X PCI \n"); break;
27878                 case 0x01: printk("== 133 \n"); break;
27879                 case 0x00: printk("== 100 \n"); break;
27880 -               default:
27881 -                       BUG();
27882         }
27883  
27884  sata_skip:
27885 @@ -518,75 +788,108 @@
27886  #endif /* DISPLAY_SIIMAGE_TIMINGS && CONFIG_PROC_FS */
27887  }
27888  
27889 +/**
27890 + *     setup_mmio_siimage      -       switch an SI controller into MMIO
27891 + *     @dev: PCI device we are configuring
27892 + *     @name: device name
27893 + *
27894 + *     Attempt to put the device into mmio mode. There are some slight
27895 + *     complications here with certain systems where the mmio bar isnt
27896 + *     mapped so we have to be sure we can fall back to I/O.
27897 + */
27898
27899  static unsigned int setup_mmio_siimage (struct pci_dev *dev, const char *name)
27900  {
27901         unsigned long bar5      = pci_resource_start(dev, 5);
27902 -       unsigned long end5      = pci_resource_end(dev, 5);
27903 +       unsigned long barsize   = pci_resource_len(dev, 5);
27904         u8 tmpbyte      = 0;
27905         unsigned long addr;
27906         void *ioaddr;
27907  
27908 -       ioaddr = ioremap_nocache(bar5, (end5 - bar5));
27909 +       /*
27910 +        *      Drop back to PIO if we can't map the mmio. Some
27911 +        *      systems seem to get terminally confused in the PCI
27912 +        *      spaces.
27913 +        */
27914 +        
27915 +       if(!request_mem_region(bar5, barsize, name))
27916 +       {
27917 +               printk(KERN_WARNING "siimage: IDE controller MMIO ports not available.\n");
27918 +               return 0;
27919 +       }
27920 +               
27921 +       ioaddr = ioremap(bar5, barsize);
27922  
27923         if (ioaddr == NULL)
27924 +       {
27925 +               release_mem_region(bar5, barsize);
27926                 return 0;
27927 +       }
27928  
27929         pci_set_master(dev);
27930         pci_set_drvdata(dev, ioaddr);
27931         addr = (unsigned long) ioaddr;
27932  
27933 -       if (dev->device == PCI_DEVICE_ID_SII_3112) {
27934 -               writel(0, DEVADDR(0x148));
27935 -               writel(0, DEVADDR(0x1C8));
27936 +       if (pdev_is_sata(dev)) {
27937 +               writel(0, addr + 0x148);
27938 +               writel(0, addr + 0x1C8);
27939         }
27940  
27941 -       writeb(0, DEVADDR(0xB4));
27942 -       writeb(0, DEVADDR(0xF4));
27943 -       tmpbyte = readb(DEVADDR(0x4A));
27944 -
27945 -       switch(tmpbyte) {
27946 -               case 0x01:
27947 -                       writeb(tmpbyte|0x10, DEVADDR(0x4A));
27948 -                       tmpbyte = readb(DEVADDR(0x4A));
27949 -               case 0x31:
27950 -                       /* if clocking is disabled */
27951 -                       /* 133 clock attempt to force it on */
27952 -                       writeb(tmpbyte & ~0x20, DEVADDR(0x4A));
27953 -                       tmpbyte = readb(DEVADDR(0x4A));
27954 -               case 0x11:
27955 -               case 0x21:
27956 +       writeb(0, addr + 0xB4);
27957 +       writeb(0, addr + 0xF4);
27958 +       tmpbyte = readb(addr + 0x4A);
27959 +
27960 +       switch(tmpbyte & 0x30) {
27961 +               case 0x00:
27962 +                       /* In 100 MHz clocking, try and switch to 133 */
27963 +                       writeb(tmpbyte|0x10, addr + 0x4A);
27964                         break;
27965 -               default:
27966 -                       tmpbyte &= ~0x30;
27967 -                       tmpbyte |= 0x20;
27968 -                       writeb(tmpbyte, DEVADDR(0x4A));
27969 +               case 0x10:
27970 +                       /* On 133Mhz clocking */
27971 +                       break;
27972 +               case 0x20:
27973 +                       /* On PCIx2 clocking */
27974 +                       break;
27975 +               case 0x30:
27976 +                       /* Clocking is disabled */
27977 +                       /* 133 clock attempt to force it on */
27978 +                       writeb(tmpbyte & ~0x20, addr + 0x4A);
27979                         break;
27980         }
27981         
27982 -       writeb(0x72, DEVADDR(0xA1));
27983 -       writew(0x328A, DEVADDR(0xA2));
27984 -       writel(0x62DD62DD, DEVADDR(0xA4));
27985 -       writel(0x43924392, DEVADDR(0xA8));
27986 -       writel(0x40094009, DEVADDR(0xAC));
27987 -       writeb(0x72, DEVADDR(0xE1));
27988 -       writew(0x328A, DEVADDR(0xE2));
27989 -       writel(0x62DD62DD, DEVADDR(0xE4));
27990 -       writel(0x43924392, DEVADDR(0xE8));
27991 -       writel(0x40094009, DEVADDR(0xEC));
27992 -
27993 -       if (dev->device == PCI_DEVICE_ID_SII_3112) {
27994 -               writel(0xFFFF0000, DEVADDR(0x108));
27995 -               writel(0xFFFF0000, DEVADDR(0x188));
27996 -               writel(0x00680000, DEVADDR(0x148));
27997 -               writel(0x00680000, DEVADDR(0x1C8));
27998 +       writeb(      0x72, addr + 0xA1);
27999 +       writew(    0x328A, addr + 0xA2);
28000 +       writel(0x62DD62DD, addr + 0xA4);
28001 +       writel(0x43924392, addr + 0xA8);
28002 +       writel(0x40094009, addr + 0xAC);
28003 +       writeb(      0x72, addr + 0xE1);
28004 +       writew(    0x328A, addr + 0xE2);
28005 +       writel(0x62DD62DD, addr + 0xE4);
28006 +       writel(0x43924392, addr + 0xE8);
28007 +       writel(0x40094009, addr + 0xEC);
28008 +
28009 +       if (pdev_is_sata(dev)) {
28010 +               writel(0xFFFF0000, addr + 0x108);
28011 +               writel(0xFFFF0000, addr + 0x188);
28012 +               writel(0x00680000, addr + 0x148);
28013 +               writel(0x00680000, addr + 0x1C8);
28014         }
28015  
28016 -       tmpbyte = readb(DEVADDR(0x4A));
28017 +       tmpbyte = readb(addr + 0x4A);
28018  
28019 -       proc_reports_siimage(dev, (tmpbyte>>=4), name);
28020 +       proc_reports_siimage(dev, (tmpbyte>>4), name);
28021         return 1;
28022  }
28023  
28024 +/**
28025 + *     init_chipset_siimage    -       set up an SI device
28026 + *     @dev: PCI device
28027 + *     @name: device name
28028 + *
28029 + *     Perform the initial PCI set up for this device. Attempt to switch
28030 + *     to 133MHz clocking if the system isn't already set up to do it.
28031 + */
28032 +
28033  static unsigned int __init init_chipset_siimage (struct pci_dev *dev, const char *name)
28034  {
28035         u32 class_rev   = 0;
28036 @@ -607,139 +910,150 @@
28037         pci_write_config_byte(dev, 0x80, 0x00);
28038         pci_write_config_byte(dev, 0x84, 0x00);
28039         pci_read_config_byte(dev, 0x8A, &tmpbyte);
28040 -       switch(tmpbyte) {
28041 +       switch(tmpbyte & 0x30) {
28042                 case 0x00:
28043 -               case 0x01:
28044                         /* 133 clock attempt to force it on */
28045                         pci_write_config_byte(dev, 0x8A, tmpbyte|0x10);
28046 -                       pci_read_config_byte(dev, 0x8A, &tmpbyte);
28047                 case 0x30:
28048 -               case 0x31:
28049                         /* if clocking is disabled */
28050                         /* 133 clock attempt to force it on */
28051                         pci_write_config_byte(dev, 0x8A, tmpbyte & ~0x20);
28052 -                       pci_read_config_byte(dev, 0x8A, &tmpbyte);
28053                 case 0x10:
28054 -               case 0x11:
28055 -               case 0x20:
28056 -               case 0x21:
28057 +                       /* 133 already */
28058                         break;
28059 -               default:
28060 -                       tmpbyte &= ~0x30;
28061 -                       tmpbyte |= 0x20;
28062 -                       pci_write_config_byte(dev, 0x8A, tmpbyte);
28063 +               case 0x20:
28064 +                       /* BIOS set PCI x2 clocking */
28065                         break;
28066         }
28067  
28068 -       pci_read_config_byte(dev, 0x8A, &tmpbyte);
28069 -       pci_write_config_byte(dev, 0xA1, 0x72);
28070 -       pci_write_config_word(dev, 0xA2, 0x328A);
28071 +       pci_read_config_byte(dev,   0x8A, &tmpbyte);
28072 +
28073 +       pci_write_config_byte(dev,  0xA1, 0x72);
28074 +       pci_write_config_word(dev,  0xA2, 0x328A);
28075         pci_write_config_dword(dev, 0xA4, 0x62DD62DD);
28076         pci_write_config_dword(dev, 0xA8, 0x43924392);
28077         pci_write_config_dword(dev, 0xAC, 0x40094009);
28078 -       pci_write_config_byte(dev, 0xB1, 0x72);
28079 -       pci_write_config_word(dev, 0xB2, 0x328A);
28080 +       pci_write_config_byte(dev,  0xB1, 0x72);
28081 +       pci_write_config_word(dev,  0xB2, 0x328A);
28082         pci_write_config_dword(dev, 0xB4, 0x62DD62DD);
28083         pci_write_config_dword(dev, 0xB8, 0x43924392);
28084         pci_write_config_dword(dev, 0xBC, 0x40094009);
28085  
28086 -       pci_read_config_byte(dev, 0x8A, &tmpbyte);
28087 -       proc_reports_siimage(dev, (tmpbyte>>=4), name);
28088 +       proc_reports_siimage(dev, (tmpbyte>>4), name);
28089         return 0;
28090  }
28091  
28092 +/**
28093 + *     init_mmio_iops_siimage  -       set up the iops for MMIO
28094 + *     @hwif: interface to set up
28095 + *
28096 + *     The basic setup here is fairly simple, we can use standard MMIO
28097 + *     operations. However we do have to set the taskfile register offsets
28098 + *     by hand as there isnt a standard defined layout for them this
28099 + *     time.
28100 + *
28101 + *     The hardware supports buffered taskfiles and also some rather nice
28102 + *     extended PRD tables. Unfortunately right now we don't.
28103 + */
28104
28105  static void __init init_mmio_iops_siimage (ide_hwif_t *hwif)
28106  {
28107         struct pci_dev *dev     = hwif->pci_dev;
28108 -       unsigned long addr      = (unsigned long) pci_get_drvdata(hwif->pci_dev);
28109 +       void *addr              = pci_get_drvdata(dev);
28110         u8 ch                   = hwif->channel;
28111 -//     u16 i                   = 0;
28112 -       hw_regs_t hw;
28113 +       hw_regs_t               hw;
28114 +       unsigned long           base;
28115 +
28116 +       /*
28117 +        *      Fill in the basic HWIF bits
28118 +        */
28119  
28120         default_hwif_mmiops(hwif);
28121 +       hwif->hwif_data                 = addr;
28122 +
28123 +       /*
28124 +        *      Now set up the hw. We have to do this ourselves as
28125 +        *      the MMIO layout isnt the same as the the standard port
28126 +        *      based I/O
28127 +        */
28128 +        
28129         memset(&hw, 0, sizeof(hw_regs_t));
28130 +       hw.priv                         = addr;
28131  
28132 -#if 1
28133 -#ifdef SIIMAGE_BUFFERED_TASKFILE
28134 -       hw.io_ports[IDE_DATA_OFFSET]    = DEVADDR((ch) ? 0xD0 : 0x90);
28135 -       hw.io_ports[IDE_ERROR_OFFSET]   = DEVADDR((ch) ? 0xD1 : 0x91);
28136 -       hw.io_ports[IDE_NSECTOR_OFFSET] = DEVADDR((ch) ? 0xD2 : 0x92);
28137 -       hw.io_ports[IDE_SECTOR_OFFSET]  = DEVADDR((ch) ? 0xD3 : 0x93);
28138 -       hw.io_ports[IDE_LCYL_OFFSET]    = DEVADDR((ch) ? 0xD4 : 0x94);
28139 -       hw.io_ports[IDE_HCYL_OFFSET]    = DEVADDR((ch) ? 0xD5 : 0x95);
28140 -       hw.io_ports[IDE_SELECT_OFFSET]  = DEVADDR((ch) ? 0xD6 : 0x96);
28141 -       hw.io_ports[IDE_STATUS_OFFSET]  = DEVADDR((ch) ? 0xD7 : 0x97);
28142 -       hw.io_ports[IDE_CONTROL_OFFSET] = DEVADDR((ch) ? 0xDA : 0x9A);
28143 -#else /* ! SIIMAGE_BUFFERED_TASKFILE */
28144 -       hw.io_ports[IDE_DATA_OFFSET]    = DEVADDR((ch) ? 0xC0 : 0x80);
28145 -       hw.io_ports[IDE_ERROR_OFFSET]   = DEVADDR((ch) ? 0xC1 : 0x81);
28146 -       hw.io_ports[IDE_NSECTOR_OFFSET] = DEVADDR((ch) ? 0xC2 : 0x82);
28147 -       hw.io_ports[IDE_SECTOR_OFFSET]  = DEVADDR((ch) ? 0xC3 : 0x83);
28148 -       hw.io_ports[IDE_LCYL_OFFSET]    = DEVADDR((ch) ? 0xC4 : 0x84);
28149 -       hw.io_ports[IDE_HCYL_OFFSET]    = DEVADDR((ch) ? 0xC5 : 0x85);
28150 -       hw.io_ports[IDE_SELECT_OFFSET]  = DEVADDR((ch) ? 0xC6 : 0x86);
28151 -       hw.io_ports[IDE_STATUS_OFFSET]  = DEVADDR((ch) ? 0xC7 : 0x87);
28152 -       hw.io_ports[IDE_CONTROL_OFFSET] = DEVADDR((ch) ? 0xCA : 0x8A);
28153 -#endif /* SIIMAGE_BUFFERED_TASKFILE */
28154 -#else
28155 -#ifdef SIIMAGE_BUFFERED_TASKFILE
28156 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
28157 -               hw.io_ports[i] = DEVADDR((ch) ? 0xD0 : 0x90)|(i);
28158 -       hw.io_ports[IDE_CONTROL_OFFSET] = DEVADDR((ch) ? 0xDA : 0x9A);
28159 -#else /* ! SIIMAGE_BUFFERED_TASKFILE */
28160 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
28161 -               hw.io_ports[i] = DEVADDR((ch) ? 0xC0 : 0x80)|(i);
28162 -       hw.io_ports[IDE_CONTROL_OFFSET] = DEVADDR((ch) ? 0xCA : 0x8A);
28163 -#endif /* SIIMAGE_BUFFERED_TASKFILE */
28164 -#endif
28165 +       base                            = (unsigned long)addr;
28166 +       if(ch)
28167 +               base += 0xC0;
28168 +       else
28169 +               base += 0x80;
28170  
28171 -#if 0
28172 -       printk(KERN_DEBUG "%s: ", hwif->name);
28173 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
28174 -               printk("0x%08x ", DEVADDR((ch) ? 0xC0 : 0x80)|(i));
28175 -       printk("0x%08x ", DEVADDR((ch) ? 0xCA : 0x8A)|(i));
28176 -#endif
28177 +       /*
28178 +        *      The buffered task file doesn't have status/control
28179 +        *      so we can't currently use it sanely since we want to
28180 +        *      use LBA48 mode.
28181 +        */     
28182 +//     base += 0x10;
28183 +//     hwif->no_lba48 = 1;
28184 +
28185 +       hw.io_ports[IDE_DATA_OFFSET]    = base;
28186 +       hw.io_ports[IDE_ERROR_OFFSET]   = base + 1;
28187 +       hw.io_ports[IDE_NSECTOR_OFFSET] = base + 2;
28188 +       hw.io_ports[IDE_SECTOR_OFFSET]  = base + 3;
28189 +       hw.io_ports[IDE_LCYL_OFFSET]    = base + 4;
28190 +       hw.io_ports[IDE_HCYL_OFFSET]    = base + 5;
28191 +       hw.io_ports[IDE_SELECT_OFFSET]  = base + 6;
28192 +       hw.io_ports[IDE_STATUS_OFFSET]  = base + 7;
28193 +       hw.io_ports[IDE_CONTROL_OFFSET] = base + 10;
28194  
28195         hw.io_ports[IDE_IRQ_OFFSET]     = 0;
28196  
28197 -        if (dev->device == PCI_DEVICE_ID_SII_3112) {
28198 -               hw.sata_scr[SATA_STATUS_OFFSET] = DEVADDR((ch) ? 0x184 : 0x104);
28199 -               hw.sata_scr[SATA_ERROR_OFFSET]  = DEVADDR((ch) ? 0x188 : 0x108);
28200 -               hw.sata_scr[SATA_CONTROL_OFFSET]= DEVADDR((ch) ? 0x180 : 0x100);
28201 -               hw.sata_misc[SATA_MISC_OFFSET]  = DEVADDR((ch) ? 0x1C0 : 0x140);
28202 -               hw.sata_misc[SATA_PHY_OFFSET]   = DEVADDR((ch) ? 0x1C4 : 0x144);
28203 -               hw.sata_misc[SATA_IEN_OFFSET]   = DEVADDR((ch) ? 0x1C8 : 0x148);
28204 +        if (pdev_is_sata(dev)) {
28205 +               base = (unsigned long) addr;
28206 +               if(ch)
28207 +                       base += 0x80;
28208 +               hw.sata_scr[SATA_STATUS_OFFSET] = base + 0x104;
28209 +               hw.sata_scr[SATA_ERROR_OFFSET]  = base + 0x108;
28210 +               hw.sata_scr[SATA_CONTROL_OFFSET]= base + 0x100;
28211 +               hw.sata_misc[SATA_MISC_OFFSET]  = base + 0x140;
28212 +               hw.sata_misc[SATA_PHY_OFFSET]   = base + 0x144;
28213 +               hw.sata_misc[SATA_IEN_OFFSET]   = base + 0x148;
28214         }
28215  
28216 -       hw.priv                         = (void *) addr;
28217 -//     hw.priv                         = pci_get_drvdata(hwif->pci_dev);
28218         hw.irq                          = hwif->pci_dev->irq;
28219  
28220         memcpy(&hwif->hw, &hw, sizeof(hw));
28221         memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
28222  
28223 -       if (hwif->pci_dev->device == PCI_DEVICE_ID_SII_3112) {
28224 +       if (is_sata(hwif)) {
28225                 memcpy(hwif->sata_scr, hwif->hw.sata_scr, sizeof(hwif->hw.sata_scr));
28226                 memcpy(hwif->sata_misc, hwif->hw.sata_misc, sizeof(hwif->hw.sata_misc));
28227         }
28228  
28229 -#ifdef SIIMAGE_BUFFERED_TASKFILE
28230 -       hwif->no_lba48 = 1;
28231 -#endif /* SIIMAGE_BUFFERED_TASKFILE */
28232         hwif->irq                       = hw.irq;
28233 -       hwif->hwif_data                 = pci_get_drvdata(hwif->pci_dev);
28234 +
28235 +               base = (unsigned long) addr;
28236  
28237  #ifdef SIIMAGE_LARGE_DMA
28238 -       hwif->dma_base                  = DEVADDR((ch) ? 0x18 : 0x10);
28239 -       hwif->dma_base2                 = DEVADDR((ch) ? 0x08 : 0x00);
28240 -       hwif->dma_prdtable              = (hwif->dma_base2 + 4);
28241 +/* Watch the brackets - even Ken and Dennis get some language design wrong */
28242 +       hwif->dma_base                  = base + (ch ? 0x18 : 0x10);
28243 +       hwif->dma_base2                 = base + (ch ? 0x08 : 0x00);
28244 +       hwif->dma_prdtable              = hwif->dma_base2 + 4;
28245  #else /* ! SIIMAGE_LARGE_DMA */
28246 -       hwif->dma_base                  = DEVADDR((ch) ? 0x08 : 0x00);
28247 -       hwif->dma_base2                 = DEVADDR((ch) ? 0x18 : 0x10);
28248 +       hwif->dma_base                  = base + (ch ? 0x08 : 0x00);
28249 +       hwif->dma_base2                 = base + (ch ? 0x18 : 0x10);
28250  #endif /* SIIMAGE_LARGE_DMA */
28251 -       hwif->mmio                      = 1;
28252 +       hwif->mmio                      = 2;
28253  }
28254  
28255 +/**
28256 + *     init_iops_siimage       -       set up iops
28257 + *     @hwif: interface to set up
28258 + *
28259 + *     Do the basic setup for the SIIMAGE hardware interface
28260 + *     and then do the MMIO setup if we can. This is the first
28261 + *     look in we get for setting up the hwif so that we
28262 + *     can get the iops right before using them.
28263 + */
28264
28265  static void __init init_iops_siimage (ide_hwif_t *hwif)
28266  {
28267         struct pci_dev *dev     = hwif->pci_dev;
28268 @@ -747,37 +1061,60 @@
28269  
28270         pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
28271         class_rev &= 0xff;
28272 +       
28273 +       hwif->hwif_data = 0;
28274  
28275         hwif->rqsize = 128;
28276 -       if ((dev->device == PCI_DEVICE_ID_SII_3112) && (!(class_rev)))
28277 -               hwif->rqsize = 16;
28278 +       if (is_sata(hwif))
28279 +               hwif->rqsize = 15;
28280  
28281         if (pci_get_drvdata(dev) == NULL)
28282                 return;
28283         init_mmio_iops_siimage(hwif);
28284  }
28285  
28286 +/**
28287 + *     ata66_siimage   -       check for 80 pin cable
28288 + *     @hwif: interface to check
28289 + *
28290 + *     Check for the presence of an ATA66 capable cable on the
28291 + *     interface.
28292 + */
28293
28294  static unsigned int __init ata66_siimage (ide_hwif_t *hwif)
28295  {
28296 +       unsigned long addr = siimage_selreg(hwif, 0);
28297         if (pci_get_drvdata(hwif->pci_dev) == NULL) {
28298                 u8 ata66 = 0;
28299 -               pci_read_config_byte(hwif->pci_dev, SELREG(0), &ata66);
28300 +               pci_read_config_byte(hwif->pci_dev, addr, &ata66);
28301                 return (ata66 & 0x01) ? 1 : 0;
28302         }
28303  
28304 -       return (hwif->INB(SELADDR(0)) & 0x01) ? 1 : 0;
28305 +       return (hwif->INB(addr) & 0x01) ? 1 : 0;
28306  }
28307  
28308 +/**
28309 + *     init_hwif_siimage       -       set up hwif structs
28310 + *     @hwif: interface to set up
28311 + *
28312 + *     We do the basic set up of the interface structure. The SIIMAGE
28313 + *     requires several custom handlers so we override the default
28314 + *     ide DMA handlers appropriately
28315 + */
28316
28317  static void __init init_hwif_siimage (ide_hwif_t *hwif)
28318  {
28319         hwif->autodma = 0;
28320 -       hwif->busproc   = &siimage_busproc;
28321 +       
28322         hwif->resetproc = &siimage_reset;
28323         hwif->speedproc = &siimage_tune_chipset;
28324         hwif->tuneproc  = &siimage_tuneproc;
28325         hwif->reset_poll = &siimage_reset_poll;
28326         hwif->pre_reset = &siimage_pre_reset;
28327  
28328 +       if(is_sata(hwif))
28329 +               hwif->busproc   = &siimage_busproc;
28330 +
28331         if (!hwif->dma_base) {
28332                 hwif->drives[0].autotune = 1;
28333                 hwif->drives[1].autotune = 1;
28334 @@ -788,7 +1125,7 @@
28335         hwif->mwdma_mask = 0x07;
28336         hwif->swdma_mask = 0x07;
28337  
28338 -       if (hwif->pci_dev->device != PCI_DEVICE_ID_SII_3112)
28339 +       if (!is_sata(hwif))
28340                 hwif->atapi_dma = 1;
28341  
28342         hwif->ide_dma_check = &siimage_config_drive_for_dma;
28343 @@ -802,12 +1139,26 @@
28344         } else {
28345                 hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq;
28346         }
28347 -       if (!noautodma)
28348 -               hwif->autodma = 1;
28349 +       
28350 +       /*
28351 +        *      The BIOS often doesn't set up DMA on this controller
28352 +        *      so we always do it.
28353 +        */
28354 +
28355 +       hwif->autodma = 1;
28356         hwif->drives[0].autodma = hwif->autodma;
28357         hwif->drives[1].autodma = hwif->autodma;
28358  }
28359  
28360 +/**
28361 + *     init_dma_siimage        -       set up IDE DMA
28362 + *     @hwif: interface
28363 + *     @dmabase: DMA base address to use
28364 + *     
28365 + *     For the SI chips this requires no special set up so we can just
28366 + *     let the IDE DMA core do the usual work.
28367 + */
28368
28369  static void __init init_dma_siimage (ide_hwif_t *hwif, unsigned long dmabase)
28370  {
28371         ide_setup_dma(hwif, dmabase, 8);
28372 @@ -816,6 +1167,15 @@
28373  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
28374  
28375  
28376 +/**
28377 + *     siimage_init_one        -       pci layer discovery entry
28378 + *     @dev: PCI device
28379 + *     @id: ident table entry
28380 + *
28381 + *     Called by the PCI code when it finds an SI680 or SI3112 controller.
28382 + *     We then use the IDE PCI generic helper to do most of the work.
28383 + */
28384
28385  static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id)
28386  {
28387         ide_pci_device_t *d = &siimage_chipsets[id->driver_data];
28388 @@ -829,6 +1189,7 @@
28389  static struct pci_device_id siimage_pci_tbl[] = {
28390         { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_680,  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
28391         { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
28392 +       { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_1210SA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
28393         { 0, },
28394  };
28395  
28396 @@ -851,6 +1212,6 @@
28397  module_init(siimage_ide_init);
28398  module_exit(siimage_ide_exit);
28399  
28400 -MODULE_AUTHOR("Andre Hedrick");
28401 +MODULE_AUTHOR("Andre Hedrick, Alan Cox");
28402  MODULE_DESCRIPTION("PCI driver module for SiI IDE");
28403  MODULE_LICENSE("GPL");
28404 diff -Nru a/drivers/ide/pci/siimage.h b/drivers/ide/pci/siimage.h
28405 --- a/drivers/ide/pci/siimage.h Mon Feb 17 11:01:34 2003
28406 +++ b/drivers/ide/pci/siimage.h Mon Sep  1 15:53:57 2003
28407 @@ -13,12 +13,6 @@
28408  #undef SIIMAGE_BUFFERED_TASKFILE
28409  #undef SIIMAGE_LARGE_DMA
28410  
28411 -#if 0
28412 -typedef struct ide_io_ops_s siimage_iops {
28413 -
28414 -}
28415 -#endif
28416 -
28417  #define SII_DEBUG 0
28418  
28419  #if SII_DEBUG
28420 @@ -27,12 +21,6 @@
28421  #define siiprintk(x...)
28422  #endif
28423  
28424 -#define ADJREG(B,R)    ((B)|(R)|((hwif->channel)<<(4+(2*(hwif->mmio)))))
28425 -#define SELREG(R)      ADJREG((0xA0),(R))
28426 -#define SELADDR(R)     ((((unsigned long)hwif->hwif_data)*(hwif->mmio))|SELREG((R)))
28427 -#define HWIFADDR(R)    ((((unsigned long)hwif->hwif_data)*(hwif->mmio))|(R))
28428 -#define DEVADDR(R)     (((unsigned long) pci_get_drvdata(dev))|(R))
28429 -
28430  
28431  #if defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS)
28432  #include <linux/stat.h>
28433 @@ -76,6 +64,19 @@
28434                 .vendor         = PCI_VENDOR_ID_CMD,
28435                 .device         = PCI_DEVICE_ID_SII_3112,
28436                 .name           = "SiI3112 Serial ATA",
28437 +               .init_chipset   = init_chipset_siimage,
28438 +               .init_iops      = init_iops_siimage,
28439 +               .init_hwif      = init_hwif_siimage,
28440 +               .init_dma       = init_dma_siimage,
28441 +               .channels       = 2,
28442 +               .autodma        = AUTODMA,
28443 +               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
28444 +               .bootable       = ON_BOARD,
28445 +               .extra          = 0,
28446 +       },{     /* 2 */
28447 +               .vendor         = PCI_VENDOR_ID_CMD,
28448 +               .device         = PCI_DEVICE_ID_SII_1210SA,
28449 +               .name           = "Adaptec AAR-1210SA",
28450                 .init_chipset   = init_chipset_siimage,
28451                 .init_iops      = init_iops_siimage,
28452                 .init_hwif      = init_hwif_siimage,
28453 diff -Nru a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
28454 --- a/drivers/ide/pci/sis5513.c Thu Jul 31 08:58:49 2003
28455 +++ b/drivers/ide/pci/sis5513.c Sun Aug 24 15:33:30 2003
28456 @@ -63,7 +63,6 @@
28457  #include <asm/irq.h>
28458  
28459  #include "ide-timing.h"
28460 -#include "ide_modes.h"
28461  #include "sis5513.h"
28462  
28463  /* registers layout and init values are chipset family dependant */
28464 diff -Nru a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
28465 --- a/drivers/ide/pci/sl82c105.c        Thu Jul 31 08:58:49 2003
28466 +++ b/drivers/ide/pci/sl82c105.c        Sun Aug 24 15:33:30 2003
28467 @@ -29,7 +29,6 @@
28468  #include <asm/io.h>
28469  #include <asm/dma.h>
28470  
28471 -#include "ide_modes.h"
28472  #include "sl82c105.h"
28473  
28474  #undef DEBUG
28475 diff -Nru a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
28476 --- a/drivers/ide/pci/slc90e66.c        Thu Jul 31 08:58:49 2003
28477 +++ b/drivers/ide/pci/slc90e66.c        Sun Aug 24 15:33:30 2003
28478 @@ -21,7 +21,6 @@
28479  
28480  #include <asm/io.h>
28481  
28482 -#include "ide_modes.h"
28483  #include "slc90e66.h"
28484  
28485  #if defined(DISPLAY_SLC90E66_TIMINGS) && defined(CONFIG_PROC_FS)
28486 diff -Nru a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
28487 --- a/drivers/ide/pci/triflex.c Sat Feb 22 15:52:14 2003
28488 +++ b/drivers/ide/pci/triflex.c Sun Aug 24 15:33:30 2003
28489 @@ -41,7 +41,6 @@
28490  #include <linux/ide.h>
28491  #include <linux/init.h>
28492  
28493 -#include "ide_modes.h"
28494  #include "triflex.h"
28495  
28496  static struct pci_dev *triflex_dev;
28497 diff -Nru a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c
28498 --- a/drivers/ide/ppc/mpc8xx.c  Fri May  2 10:53:08 2003
28499 +++ b/drivers/ide/ppc/mpc8xx.c  Sun Aug 24 15:33:30 2003
28500 @@ -42,7 +42,6 @@
28501  #include <asm/machdep.h>
28502  #include <asm/irq.h>
28503  
28504 -#include "ide_modes.h"
28505  static int identify  (volatile u8 *p);
28506  static void print_fixed (volatile u8 *p);
28507  static void print_funcid (int func);
28508 diff -Nru a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
28509 --- a/drivers/ide/ppc/pmac.c    Sat Aug 16 11:46:50 2003
28510 +++ b/drivers/ide/ppc/pmac.c    Sun Aug 31 14:09:16 2003
28511 @@ -5,7 +5,7 @@
28512   * These IDE interfaces are memory-mapped and have a DBDMA channel
28513   * for doing DMA.
28514   *
28515 - *  Copyright (C) 1998-2001 Paul Mackerras & Ben. Herrenschmidt
28516 + *  Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt
28517   *
28518   *  This program is free software; you can redistribute it and/or
28519   *  modify it under the terms of the GNU General Public License
28520 @@ -16,6 +16,11 @@
28521   *
28522   *  Copyright (c) 1995-1998  Mark Lord
28523   *
28524 + * TODO: - Use pre-calculated (kauai) timing tables all the time and
28525 + * get rid of the "rounded" tables used previously, so we have the
28526 + * same table format for all controllers and can then just have one
28527 + * big table
28528 + * 
28529   */
28530  #include <linux/config.h>
28531  #include <linux/types.h>
28532 @@ -27,6 +32,8 @@
28533  #include <linux/notifier.h>
28534  #include <linux/reboot.h>
28535  #include <linux/pci.h>
28536 +#include <linux/adb.h>
28537 +#include <linux/pmu.h>
28538  
28539  #include <asm/prom.h>
28540  #include <asm/io.h>
28541 @@ -38,26 +45,27 @@
28542  #include <asm/pmac_feature.h>
28543  #include <asm/sections.h>
28544  #include <asm/irq.h>
28545 -#ifdef CONFIG_PMAC_PBOOK
28546 -#include <linux/adb.h>
28547 -#include <linux/pmu.h>
28548 -#endif
28549 -#include "ide_modes.h"
28550 +
28551 +#include "ide-timing.h"
28552  
28553  extern void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq);
28554  
28555  #define IDE_PMAC_DEBUG
28556  
28557 -#define DMA_WAIT_TIMEOUT       500
28558 +#define DMA_WAIT_TIMEOUT       100
28559  
28560  typedef struct pmac_ide_hwif {
28561         unsigned long                   regbase;
28562         int                             irq;
28563         int                             kind;
28564         int                             aapl_bus_id;
28565 +       int                             cable_80 : 1;
28566 +       int                             mediabay : 1;
28567 +       int                             broken_dma : 1;
28568 +       int                             broken_dma_warn : 1;
28569         struct device_node*             node;
28570 -       u32                             timings[2];
28571 -       int                             index;
28572 +       struct macio_dev                *mdev;
28573 +       u32                             timings[4];
28574  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
28575         /* Those fields are duplicating what is in hwif. We currently
28576          * can't use the hwif ones because of some assumptions that are
28577 @@ -82,7 +90,15 @@
28578         controller_heathrow,    /* Heathrow/Paddington */
28579         controller_kl_ata3,     /* KeyLargo ATA-3 */
28580         controller_kl_ata4,     /* KeyLargo ATA-4 */
28581 -       controller_kl_ata4_80   /* KeyLargo ATA-4 with 80 conductor cable */
28582 +       controller_un_ata6      /* UniNorth2 ATA-6 */
28583 +};
28584 +
28585 +static const char* model_name[] = {
28586 +       "OHare ATA",            /* OHare based */
28587 +       "Heathrow ATA",         /* Heathrow/Paddington */
28588 +       "KeyLargo ATA-3",       /* KeyLargo ATA-3 */
28589 +       "KeyLargo ATA-4",       /* KeyLargo ATA-4 */
28590 +       "UniNorth ATA-6"        /* UniNorth2 ATA-6 */
28591  };
28592  
28593  /*
28594 @@ -91,6 +107,11 @@
28595  #define IDE_TIMING_CONFIG      0x200
28596  #define IDE_INTERRUPT          0x300
28597  
28598 +/* Kauai (U2) ATA has different register setup */
28599 +#define IDE_KAUAI_PIO_CONFIG   0x200
28600 +#define IDE_KAUAI_ULTRA_CONFIG 0x210
28601 +#define IDE_KAUAI_POLL_CONFIG  0x220
28602 +
28603  /*
28604   * Timing configuration register definitions
28605   */
28606 @@ -101,6 +122,28 @@
28607  #define IDE_SYSCLK_NS          30      /* 33Mhz cell */
28608  #define IDE_SYSCLK_66_NS       15      /* 66Mhz cell */
28609  
28610 +/* 100Mhz cell, found in Uninorth 2. I don't have much infos about
28611 + * this one yet, it appears as a pci device (106b/0033) on uninorth
28612 + * internal PCI bus and it's clock is controlled like gem or fw. It
28613 + * appears to be an evolution of keylargo ATA4 with a timing register
28614 + * extended to 2 32bits registers and a similar DBDMA channel. Other
28615 + * registers seem to exist but I can't tell much about them.
28616 + * 
28617 + * So far, I'm using pre-calculated tables for this extracted from
28618 + * the values used by the MacOS X driver.
28619 + * 
28620 + * The "PIO" register controls PIO and MDMA timings, the "ULTRA"
28621 + * register controls the UDMA timings. At least, it seems bit 0
28622 + * of this one enables UDMA vs. MDMA, and bits 4..7 are the
28623 + * cycle time in units of 10ns. Bits 8..15 are used by I don't
28624 + * know their meaning yet
28625 + */
28626 +#define TR_100_PIOREG_PIO_MASK         0xff000fff
28627 +#define TR_100_PIOREG_MDMA_MASK                0x00fff000
28628 +#define TR_100_UDMAREG_UDMA_MASK       0x0000ffff
28629 +#define TR_100_UDMAREG_UDMA_EN         0x00000001
28630 +
28631 +
28632  /* 66Mhz cell, found in KeyLargo. Can do ultra mode 0 to 2 on
28633   * 40 connector cable and to 4 on 80 connector one.
28634   * Clock unit is 15ns (66Mhz)
28635 @@ -115,8 +158,7 @@
28636   *    well, despite a comment that would lead to think it has a
28637   *    min value of 45ns.
28638   * Apple also add 60ns to the write data setup (or cycle time ?) on
28639 - * reads. I can't explain that, I tried it and it broke everything
28640 - * here.
28641 + * reads.
28642   */
28643  #define TR_66_UDMA_MASK                        0xfff00000
28644  #define TR_66_UDMA_EN                  0x00100000 /* Enable Ultra mode for DMA */
28645 @@ -220,12 +262,12 @@
28646      {   0,   0,   0 }
28647  };
28648  
28649 -/* Ultra DMA timings (rounded) */
28650 +/* KeyLargo ATA-4 Ultra DMA timings (rounded) */
28651  struct {
28652         int     addrSetup; /* ??? */
28653         int     rdy2pause;
28654         int     wrDataSetup;
28655 -} udma_timings[] __pmacdata =
28656 +} kl66_udma_timings[] __pmacdata =
28657  {
28658      {   0, 180,  120 },        /* Mode 0 */
28659      {   0, 150,  90 }, /*      1 */
28660 @@ -234,6 +276,63 @@
28661      {   0, 90,   30 }  /*      4 */
28662  };
28663  
28664 +/* UniNorth 2 ATA/100 timings */
28665 +struct kauai_timing {
28666 +       int     cycle_time;
28667 +       u32     timing_reg;
28668 +};
28669 +
28670 +static struct kauai_timing     kauai_pio_timings[] __pmacdata =
28671 +{
28672 +       { 930   , 0x08000fff },
28673 +       { 600   , 0x08000a92 },
28674 +       { 383   , 0x0800060f },
28675 +       { 360   , 0x08000492 },
28676 +       { 330   , 0x0800048f },
28677 +       { 300   , 0x080003cf },
28678 +       { 270   , 0x080003cc },
28679 +       { 240   , 0x0800038b },
28680 +       { 239   , 0x0800030c },
28681 +       { 180   , 0x05000249 },
28682 +       { 120   , 0x04000148 }
28683 +};
28684 +
28685 +static struct kauai_timing     kauai_mdma_timings[] __pmacdata =
28686 +{
28687 +       { 1260  , 0x00fff000 },
28688 +       { 480   , 0x00618000 },
28689 +       { 360   , 0x00492000 },
28690 +       { 270   , 0x0038e000 },
28691 +       { 240   , 0x0030c000 },
28692 +       { 210   , 0x002cb000 },
28693 +       { 180   , 0x00249000 },
28694 +       { 150   , 0x00209000 },
28695 +       { 120   , 0x00148000 },
28696 +       { 0     , 0 },
28697 +};
28698 +
28699 +static struct kauai_timing     kauai_udma_timings[] __pmacdata =
28700 +{
28701 +       { 120   , 0x000070c0 },
28702 +       { 90    , 0x00005d80 },
28703 +       { 60    , 0x00004a60 },
28704 +       { 45    , 0x00003a50 },
28705 +       { 30    , 0x00002a30 },
28706 +       { 20    , 0x00002921 },
28707 +       { 0     , 0 },
28708 +};
28709 +
28710 +static inline u32
28711 +kauai_lookup_timing(struct kauai_timing* table, int cycle_time)
28712 +{
28713 +       int i;
28714 +       
28715 +       for (i=0; table[i].cycle_time; i++)
28716 +               if (cycle_time > table[i+1].cycle_time)
28717 +                       return table[i].timing_reg;
28718 +       return 0;
28719 +}
28720 +
28721  /* allow up to 256 DBDMA commands per xfer */
28722  #define MAX_DCMDS              256
28723  
28724 @@ -242,24 +341,106 @@
28725   * NOTE: There is at least one case I know of a disk that needs about 10sec
28726   *       before anwering on the bus. I beleive we could add a kernel command
28727   *       line arg to override this delay for such cases.
28728 + *       
28729 + * NOTE2: This has to be fixed with a BSY wait loop. I'm working on adding
28730 + *        that to the generic probe code.
28731   */
28732  #define IDE_WAKEUP_DELAY_MS    2000
28733  
28734 -static void pmac_ide_setup_dma(struct device_node *np, int ix);
28735 -static int pmac_ide_build_dmatable(ide_drive_t *drive, int wr);
28736 +static void pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif);
28737 +static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq);
28738  static int pmac_ide_tune_chipset(ide_drive_t *drive, u8 speed);
28739  static void pmac_ide_tuneproc(ide_drive_t *drive, u8 pio);
28740  static void pmac_ide_selectproc(ide_drive_t *drive);
28741 +static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
28742  static int pmac_ide_dma_begin (ide_drive_t *drive);
28743  
28744  #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
28745  
28746 -#ifdef CONFIG_PMAC_PBOOK
28747 -static int idepmac_notify_sleep(struct pmu_sleep_notifier *self, int when);
28748 -struct pmu_sleep_notifier idepmac_sleep_notifier = {
28749 -       idepmac_notify_sleep, SLEEP_LEVEL_BLOCK,
28750 -};
28751 -#endif /* CONFIG_PMAC_PBOOK */
28752 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
28753 +
28754 +/* Set to 50ms */
28755 +#define PMU_HD_BLINK_TIME      (HZ/50)
28756 +
28757 +static struct adb_request pmu_blink_on, pmu_blink_off;
28758 +static spinlock_t pmu_blink_lock;
28759 +static unsigned long pmu_blink_stoptime;
28760 +static int pmu_blink_ledstate;
28761 +static struct timer_list pmu_blink_timer;
28762 +static int pmu_ide_blink_enabled;
28763 +
28764 +
28765 +static void
28766 +pmu_hd_blink_timeout(unsigned long data)
28767 +{
28768 +       unsigned long flags;
28769 +       
28770 +       spin_lock_irqsave(&pmu_blink_lock, flags);
28771 +
28772 +       /* We may have been triggered again in a racy way, check
28773 +        * that we really want to switch it off
28774 +        */
28775 +       if (time_after(pmu_blink_stoptime, jiffies))
28776 +               goto done;
28777 +
28778 +       /* Previous req. not complete, try 100ms more */
28779 +       if (pmu_blink_off.complete == 0)
28780 +               mod_timer(&pmu_blink_timer, jiffies + PMU_HD_BLINK_TIME);
28781 +       else if (pmu_blink_ledstate) {
28782 +               pmu_request(&pmu_blink_off, NULL, 4, 0xee, 4, 0, 0);
28783 +               pmu_blink_ledstate = 0;
28784 +       }
28785 +done:
28786 +       spin_unlock_irqrestore(&pmu_blink_lock, flags);
28787 +}
28788 +
28789 +static void
28790 +pmu_hd_kick_blink(void *data, int rw)
28791 +{
28792 +       unsigned long flags;
28793 +       
28794 +       pmu_blink_stoptime = jiffies + PMU_HD_BLINK_TIME;
28795 +       wmb();
28796 +       mod_timer(&pmu_blink_timer, pmu_blink_stoptime);
28797 +       if (pmu_blink_ledstate == 1)
28798 +               return;
28799 +       spin_lock_irqsave(&pmu_blink_lock, flags);
28800 +       if (pmu_blink_on.complete && !pmu_blink_ledstate) {
28801 +               pmu_request(&pmu_blink_on, NULL, 4, 0xee, 4, 0, 1);
28802 +               pmu_blink_ledstate = 1;
28803 +       }
28804 +       spin_unlock_irqrestore(&pmu_blink_lock, flags);
28805 +}
28806 +
28807 +static int
28808 +pmu_hd_blink_init(void)
28809 +{
28810 +       struct device_node *dt;
28811 +       const char *model;
28812 +
28813 +       if (pmu_get_model() != PMU_KEYLARGO_BASED)
28814 +               return 0;
28815 +       
28816 +       dt = find_devices("device-tree");
28817 +       if (dt == NULL)
28818 +               return 0;
28819 +       model = (const char *)get_property(dt, "model", NULL);
28820 +       if (model == NULL)
28821 +               return 0;
28822 +       if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
28823 +           strncmp(model, "iBook", strlen("iBook")) != 0)
28824 +               return 0;
28825 +       
28826 +       pmu_blink_on.complete = 1;
28827 +       pmu_blink_off.complete = 1;
28828 +       spin_lock_init(&pmu_blink_lock);
28829 +       init_timer(&pmu_blink_timer);
28830 +       pmu_blink_timer.function = pmu_hd_blink_timeout;
28831 +
28832 +       return 1;
28833 +}
28834 +
28835 +#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
28836  
28837  /*
28838   * N.B. this can't be an initfunc, because the media-bay task can
28839 @@ -315,6 +496,41 @@
28840         (void)readl((unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
28841  }
28842  
28843 +static void __pmac
28844 +pmac_ide_kauai_selectproc(ide_drive_t *drive)
28845 +{
28846 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
28847 +
28848 +       if (pmif == NULL)
28849 +               return;
28850 +
28851 +       if (drive->select.b.unit & 0x01) {
28852 +               writel(pmif->timings[1],
28853 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
28854 +               writel(pmif->timings[3],
28855 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_ULTRA_CONFIG));
28856 +       } else {
28857 +               writel(pmif->timings[0],
28858 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
28859 +               writel(pmif->timings[2],
28860 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_ULTRA_CONFIG));
28861 +       }
28862 +       (void)readl((unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
28863 +}
28864 +
28865 +static void __pmac
28866 +pmac_ide_do_update_timings(ide_drive_t *drive)
28867 +{
28868 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
28869 +
28870 +       if (pmif == NULL)
28871 +               return;
28872 +
28873 +       if (pmif->kind == controller_un_ata6)
28874 +               pmac_ide_kauai_selectproc(drive);
28875 +       else
28876 +               pmac_ide_selectproc(drive);
28877 +}
28878  
28879  static int __pmac
28880  pmac_ide_do_setfeature(ide_drive_t *drive, u8 command)
28881 @@ -322,7 +538,7 @@
28882         ide_hwif_t *hwif = HWIF(drive);
28883         int result = 1;
28884         
28885 -       disable_irq(hwif->irq); /* disable_irq_nosync ?? */
28886 +       disable_irq_nosync(hwif->irq);
28887         udelay(1);
28888         SELECT_DRIVE(drive);
28889         SELECT_MASK(drive, 0);
28890 @@ -332,22 +548,22 @@
28891         /* Timeout bumped for some powerbooks */
28892         if (wait_for_ready(drive, 2000)) {
28893                 /* Timeout bumped for some powerbooks */
28894 -               printk(KERN_ERR "pmac_ide_do_setfeature disk not ready "
28895 -                       "before SET_FEATURE!\n");
28896 +               printk(KERN_ERR "%s: pmac_ide_do_setfeature disk not ready "
28897 +                       "before SET_FEATURE!\n", drive->name);
28898                 goto out;
28899         }
28900         udelay(10);
28901         hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG);
28902         hwif->OUTB(command, IDE_NSECTOR_REG);
28903         hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG);
28904 -       hwif->OUTB(WIN_SETFEATURES, IDE_COMMAND_REG);
28905 +       hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG);
28906         udelay(1);
28907         /* Timeout bumped for some powerbooks */
28908         result = wait_for_ready(drive, 2000);
28909         hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
28910         if (result)
28911 -               printk(KERN_ERR "pmac_ide_do_setfeature disk not ready "
28912 -                       "after SET_FEATURE !\n");
28913 +               printk(KERN_ERR "%s: pmac_ide_do_setfeature disk not ready "
28914 +                       "after SET_FEATURE !\n", drive->name);
28915  out:
28916         SELECT_MASK(drive, 0);
28917         if (result == 0) {
28918 @@ -403,21 +619,27 @@
28919         if (pmif == NULL)
28920                 return;
28921                 
28922 +       /* which drive is it ? */
28923 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
28924 +
28925         pio = ide_get_best_pio_mode(drive, pio, 4, &d);
28926 -       accessTicks = SYSCLK_TICKS(ide_pio_timings[pio].active_time);
28927 -       if (drive->select.b.unit & 0x01)
28928 -               timings = &pmif->timings[1];
28929 -       else
28930 -               timings = &pmif->timings[0];
28931  
28932 -       recTime = d.cycle_time - ide_pio_timings[pio].active_time
28933 -                       - ide_pio_timings[pio].setup_time;
28934 -       recTime = max(recTime, 150U);
28935 -       accessTime = ide_pio_timings[pio].active_time;
28936 -       accessTime = max(accessTime, 150U);
28937 -       if (pmif->kind == controller_kl_ata4 ||
28938 -               pmif->kind == controller_kl_ata4_80) {
28939 +       switch (pmif->kind) {
28940 +       case controller_un_ata6: {
28941 +               /* 100Mhz cell */
28942 +               u32 tr = kauai_lookup_timing(kauai_pio_timings, d.cycle_time);
28943 +               if (tr == 0)
28944 +                       return;
28945 +               *timings = ((*timings) & ~TR_100_PIOREG_PIO_MASK) | tr;
28946 +               break;
28947 +               }
28948 +       case controller_kl_ata4:
28949                 /* 66Mhz cell */
28950 +               recTime = d.cycle_time - ide_pio_timings[pio].active_time
28951 +                               - ide_pio_timings[pio].setup_time;
28952 +               recTime = max(recTime, 150U);
28953 +               accessTime = ide_pio_timings[pio].active_time;
28954 +               accessTime = max(accessTime, 150U);
28955                 accessTicks = SYSCLK_TICKS_66(accessTime);
28956                 accessTicks = min(accessTicks, 0x1fU);
28957                 recTicks = SYSCLK_TICKS_66(recTime);
28958 @@ -425,9 +647,15 @@
28959                 *timings = ((*timings) & ~TR_66_PIO_MASK) |
28960                                 (accessTicks << TR_66_PIO_ACCESS_SHIFT) |
28961                                 (recTicks << TR_66_PIO_RECOVERY_SHIFT);
28962 -       } else {
28963 +               break;
28964 +       default: {
28965                 /* 33Mhz cell */
28966                 int ebit = 0;
28967 +               recTime = d.cycle_time - ide_pio_timings[pio].active_time
28968 +                               - ide_pio_timings[pio].setup_time;
28969 +               recTime = max(recTime, 150U);
28970 +               accessTime = ide_pio_timings[pio].active_time;
28971 +               accessTime = max(accessTime, 150U);
28972                 accessTicks = SYSCLK_TICKS(accessTime);
28973                 accessTicks = min(accessTicks, 0x1fU);
28974                 accessTicks = max(accessTicks, 4U);
28975 @@ -443,26 +671,31 @@
28976                                 (recTicks << TR_33_PIO_RECOVERY_SHIFT);
28977                 if (ebit)
28978                         *timings |= TR_33_PIO_E;
28979 +               break;
28980 +               }
28981         }
28982  
28983  #ifdef IDE_PMAC_DEBUG
28984 -       printk(KERN_ERR "ide_pmac: Set PIO timing for mode %d, reg: 0x%08x\n",
28985 -               pio,  *timings);
28986 +       printk(KERN_ERR "%s: Set PIO timing for mode %d, reg: 0x%08x\n",
28987 +               drive->name, pio,  *timings);
28988  #endif 
28989  
28990         if (drive->select.all == HWIF(drive)->INB(IDE_SELECT_REG))
28991 -               pmac_ide_selectproc(drive);
28992 +               pmac_ide_do_update_timings(drive);
28993  }
28994  
28995  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
28996  static int __pmac
28997 -set_timings_udma(u32 *timings, u8 speed)
28998 +set_timings_udma_ata4(u32 *timings, u8 speed)
28999  {
29000         unsigned rdyToPauseTicks, wrDataSetupTicks, addrTicks;
29001  
29002 -       rdyToPauseTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].rdy2pause);
29003 -       wrDataSetupTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].wrDataSetup);
29004 -       addrTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].addrSetup);
29005 +       if (speed > XFER_UDMA_4)
29006 +               return 1;
29007 +
29008 +       rdyToPauseTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].rdy2pause);
29009 +       wrDataSetupTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].wrDataSetup);
29010 +       addrTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].addrSetup);
29011  
29012         *timings = ((*timings) & ~(TR_66_UDMA_MASK | TR_66_MDMA_MASK)) |
29013                         (wrDataSetupTicks << TR_66_UDMA_WRDATASETUP_SHIFT) | 
29014 @@ -478,11 +711,29 @@
29015  }
29016  
29017  static int __pmac
29018 -set_timings_mdma(int intf_type, u32 *timings, u8 speed, int drive_cycle_time)
29019 +set_timings_udma_ata6(u32 *pio_timings, u32 *ultra_timings, u8 speed)
29020 +{
29021 +       struct ide_timing *t = ide_timing_find_mode(speed);
29022 +       u32 tr;
29023 +
29024 +       if (speed > XFER_UDMA_5 || t == NULL)
29025 +               return 1;
29026 +       tr = kauai_lookup_timing(kauai_udma_timings, (int)t->udma);
29027 +       if (tr == 0)
29028 +               return 1;
29029 +       *ultra_timings = ((*ultra_timings) & ~TR_100_UDMAREG_UDMA_MASK) | tr;
29030 +       *ultra_timings = (*ultra_timings) | TR_100_UDMAREG_UDMA_EN;
29031 +
29032 +       return 0;
29033 +}
29034 +
29035 +static int __pmac
29036 +set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2,
29037 +                       u8 speed, int drive_cycle_time)
29038  {
29039         int cycleTime, accessTime, recTime;
29040         unsigned accessTicks, recTicks;
29041 -       struct mdma_timings_t* tm;
29042 +       struct mdma_timings_t* tm = NULL;
29043         int i;
29044  
29045         /* Get default cycle time for mode */
29046 @@ -491,7 +742,7 @@
29047                 case 1: cycleTime = 150; break;
29048                 case 2: cycleTime = 120; break;
29049                 default:
29050 -                       return -1;
29051 +                       return 1;
29052         }
29053         /* Adjust for drive */
29054         if (drive_cycle_time && drive_cycle_time > cycleTime)
29055 @@ -501,8 +752,9 @@
29056                 cycleTime = 150;
29057         /* Get the proper timing array for this controller */
29058         switch(intf_type) {
29059 +               case controller_un_ata6:
29060 +                       break;
29061                 case controller_kl_ata4:
29062 -               case controller_kl_ata4_80:
29063                         tm = mdma_timings_66;
29064                         break;
29065                 case controller_kl_ata3:
29066 @@ -512,24 +764,36 @@
29067                         tm = mdma_timings_33;
29068                         break;
29069         }
29070 -       /* Lookup matching access & recovery times */
29071 -       i = -1;
29072 -       for (;;) {
29073 -               if (tm[i+1].cycleTime < cycleTime)
29074 -                       break;
29075 -               i++;
29076 -       }
29077 -       if (i < 0)
29078 -               return -1;
29079 -       cycleTime = tm[i].cycleTime;
29080 -       accessTime = tm[i].accessTime;
29081 -       recTime = tm[i].recoveryTime;
29082 +       if (tm != NULL) {
29083 +               /* Lookup matching access & recovery times */
29084 +               i = -1;
29085 +               for (;;) {
29086 +                       if (tm[i+1].cycleTime < cycleTime)
29087 +                               break;
29088 +                       i++;
29089 +               }
29090 +               if (i < 0)
29091 +                       return 1;
29092 +               cycleTime = tm[i].cycleTime;
29093 +               accessTime = tm[i].accessTime;
29094 +               recTime = tm[i].recoveryTime;
29095  
29096  #ifdef IDE_PMAC_DEBUG
29097 -       printk(KERN_ERR "ide_pmac: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n",
29098 -               cycleTime, accessTime, recTime);
29099 -#endif 
29100 -       if (intf_type == controller_kl_ata4 || intf_type == controller_kl_ata4_80) {
29101 +               printk(KERN_ERR "%s: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n",
29102 +                       drive->name, cycleTime, accessTime, recTime);
29103 +#endif
29104 +       }
29105 +       switch(intf_type) {
29106 +       case controller_un_ata6: {
29107 +               /* 100Mhz cell */
29108 +               u32 tr = kauai_lookup_timing(kauai_mdma_timings, cycleTime);
29109 +               if (tr == 0)
29110 +                       return 1;
29111 +               *timings = ((*timings) & ~TR_100_PIOREG_MDMA_MASK) | tr;
29112 +               *timings2 = (*timings2) & ~TR_100_UDMAREG_UDMA_EN;
29113 +               }
29114 +               break;
29115 +       case controller_kl_ata4:
29116                 /* 66Mhz cell */
29117                 accessTicks = SYSCLK_TICKS_66(accessTime);
29118                 accessTicks = min(accessTicks, 0x1fU);
29119 @@ -541,7 +805,8 @@
29120                 *timings = ((*timings) & ~(TR_66_MDMA_MASK | TR_66_UDMA_MASK)) |
29121                         (accessTicks << TR_66_MDMA_ACCESS_SHIFT) |
29122                         (recTicks << TR_66_MDMA_RECOVERY_SHIFT);
29123 -       } else if (intf_type == controller_kl_ata3) {
29124 +               break;
29125 +       case controller_kl_ata3:
29126                 /* 33Mhz cell on KeyLargo */
29127                 accessTicks = SYSCLK_TICKS(accessTime);
29128                 accessTicks = max(accessTicks, 1U);
29129 @@ -553,7 +818,8 @@
29130                 *timings = ((*timings) & ~TR_33_MDMA_MASK) |
29131                                 (accessTicks << TR_33_MDMA_ACCESS_SHIFT) |
29132                                 (recTicks << TR_33_MDMA_RECOVERY_SHIFT);
29133 -       } else {
29134 +               break;
29135 +       default: {
29136                 /* 33Mhz cell on others */
29137                 int halfTick = 0;
29138                 int origAccessTime = accessTime;
29139 @@ -578,10 +844,11 @@
29140                                 (recTicks << TR_33_MDMA_RECOVERY_SHIFT);
29141                 if (halfTick)
29142                         *timings |= TR_33_MDMA_HALFTICK;
29143 +               }
29144         }
29145  #ifdef IDE_PMAC_DEBUG
29146 -       printk(KERN_ERR "ide_pmac: Set MDMA timing for mode %d, reg: 0x%08x\n",
29147 -               speed & 0xf,  *timings);
29148 +       printk(KERN_ERR "%s: Set MDMA timing for mode %d, reg: 0x%08x\n",
29149 +               drive->name, speed & 0xf,  *timings);
29150  #endif 
29151         return 0;
29152  }
29153 @@ -591,36 +858,42 @@
29154   * our, normal mdma function is supposed to be more precise
29155   */
29156  static int __pmac
29157 -pmac_ide_tune_chipset (ide_drive_t *drive, u8 speed)
29158 +pmac_ide_tune_chipset (ide_drive_t *drive, byte speed)
29159  {
29160         int unit = (drive->select.b.unit & 0x01);
29161         int ret = 0;
29162         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
29163 -       u32 *timings;
29164 -       
29165 +       u32 *timings, *timings2;
29166 +
29167         if (pmif == NULL)
29168                 return 1;
29169 -
29170 +               
29171         timings = &pmif->timings[unit];
29172 +       timings2 = &pmif->timings[unit+2];
29173         
29174         switch(speed) {
29175  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
29176 +               case XFER_UDMA_5:
29177 +                       if (pmif->kind != controller_un_ata6)
29178 +                               return 1;
29179                 case XFER_UDMA_4:
29180                 case XFER_UDMA_3:
29181 -                       if (pmif->kind != controller_kl_ata4_80)
29182 +                       if (HWIF(drive)->udma_four == 0)
29183                                 return 1;               
29184                 case XFER_UDMA_2:
29185                 case XFER_UDMA_1:
29186                 case XFER_UDMA_0:
29187 -                       if (pmif->kind != controller_kl_ata4 &&
29188 -                               pmif->kind != controller_kl_ata4_80)
29189 -                               return 1;               
29190 -                       ret = set_timings_udma(timings, speed);
29191 +                       if (pmif->kind == controller_kl_ata4)
29192 +                               ret = set_timings_udma_ata4(timings, speed);
29193 +                       else if (pmif->kind == controller_un_ata6)
29194 +                               ret = set_timings_udma_ata6(timings, timings2, speed);
29195 +                       else
29196 +                               ret = 1;                
29197                         break;
29198                 case XFER_MW_DMA_2:
29199                 case XFER_MW_DMA_1:
29200                 case XFER_MW_DMA_0:
29201 -                       ret = set_timings_mdma(pmif->kind, timings, speed, 0);
29202 +                       ret = set_timings_mdma(drive, pmif->kind, timings, timings2, speed, 0);
29203                         break;
29204                 case XFER_SW_DMA_2:
29205                 case XFER_SW_DMA_1:
29206 @@ -644,7 +917,7 @@
29207         if (ret)
29208                 return ret;
29209                 
29210 -       pmac_ide_selectproc(drive);     
29211 +       pmac_ide_do_update_timings(drive);      
29212         drive->current_speed = speed;
29213  
29214         return 0;
29215 @@ -653,11 +926,14 @@
29216  static void __pmac
29217  sanitize_timings(pmac_ide_hwif_t *pmif)
29218  {
29219 -       unsigned value;
29220 +       unsigned int value, value2 = 0;
29221         
29222         switch(pmif->kind) {
29223 +               case controller_un_ata6:
29224 +                       value = 0x08618a92;
29225 +                       value2 = 0x00002921;
29226 +                       break;
29227                 case controller_kl_ata4:
29228 -               case controller_kl_ata4_80:
29229                         value = 0x0008438c;
29230                         break;
29231                 case controller_kl_ata3:
29232 @@ -670,6 +946,7 @@
29233                         break;
29234         }
29235         pmif->timings[0] = pmif->timings[1] = value;
29236 +       pmif->timings[2] = pmif->timings[3] = value2;
29237  }
29238  
29239  unsigned long __pmac
29240 @@ -724,214 +1001,474 @@
29241         return 0;
29242  }
29243  
29244 -void __init
29245 -pmac_ide_probe(void)
29246 +/* Suspend call back, should be called after the child devices
29247 + * have actually been suspended
29248 + */
29249 +static int
29250 +pmac_ide_do_suspend(ide_hwif_t *hwif)
29251  {
29252 -       struct device_node *np;
29253 -       int i;
29254 -       struct device_node *atas;
29255 -       struct device_node *p, **pp, *removables, **rp;
29256 -       unsigned long base;
29257 -       int irq, big_delay;
29258 -       ide_hwif_t *hwif;
29259 +       pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
29260 +       
29261 +       /* We clear the timings */
29262 +       pmif->timings[0] = 0;
29263 +       pmif->timings[1] = 0;
29264 +       
29265 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
29266 +       /* Note: This code will be called for every hwif, thus we'll
29267 +        * try several time to stop the LED blinker timer,  but that
29268 +        * should be harmless
29269 +        */
29270 +       if (pmu_ide_blink_enabled) {
29271 +               unsigned long flags;
29272  
29273 -       if (_machine != _MACH_Pmac)
29274 -               return;
29275 -       pp = &atas;
29276 -       rp = &removables;
29277 -       p = find_devices("ATA");
29278 -       if (p == NULL)
29279 -               p = find_devices("IDE");
29280 -       if (p == NULL)
29281 -               p = find_type_devices("ide");
29282 -       if (p == NULL)
29283 -               p = find_type_devices("ata");
29284 -       /* Move removable devices such as the media-bay CDROM
29285 -          on the PB3400 to the end of the list. */
29286 -       for (; p != NULL; p = p->next) {
29287 -               if (p->parent && p->parent->type
29288 -                   && strcasecmp(p->parent->type, "media-bay") == 0) {
29289 -                       *rp = p;
29290 -                       rp = &p->next;
29291 -               } else {
29292 -                       *pp = p;
29293 -                       pp = &p->next;
29294 -               }
29295 +               /* Make sure we don't hit the PMU blink */
29296 +               spin_lock_irqsave(&pmu_blink_lock, flags);
29297 +               if (pmu_blink_ledstate)
29298 +                       del_timer(&pmu_blink_timer);
29299 +               pmu_blink_ledstate = 0;
29300 +               spin_unlock_irqrestore(&pmu_blink_lock, flags);
29301         }
29302 -       *rp = NULL;
29303 -       *pp = removables;
29304 -       big_delay = 0;
29305 -
29306 -       for (i = 0, np = atas; i < MAX_HWIFS && np != NULL; np = np->next) {
29307 -               struct device_node *tp;
29308 -               struct pmac_ide_hwif* pmif;
29309 -               int *bidp;
29310 -               int in_bay = 0;
29311 -               u8 pbus, pid;
29312 -               struct pci_dev *pdev = NULL;
29313 -
29314 -               /*
29315 -                * If this node is not under a mac-io or dbdma node,
29316 -                * leave it to the generic PCI driver.
29317 -                */
29318 -               for (tp = np->parent; tp != 0; tp = tp->parent)
29319 -                       if (tp->type && (strcmp(tp->type, "mac-io") == 0
29320 -                                        || strcmp(tp->type, "dbdma") == 0))
29321 -                               break;
29322 -               if (tp == 0)
29323 -                       continue;
29324 +#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
29325  
29326 -               if (np->n_addrs == 0) {
29327 -                       printk(KERN_WARNING "ide: no address for device %s\n",
29328 -                              np->full_name);
29329 -                       continue;
29330 -               }
29331 +       /* The media bay will handle itself just fine */
29332 +       if (pmif->mediabay)
29333 +               return 0;
29334 +       
29335 +       /* Disable the bus */
29336 +       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 0);
29337  
29338 -               /* We need to find the pci_dev of the mac-io holding the
29339 -                * IDE interface
29340 -                */
29341 -               if (pci_device_from_OF_node(tp, &pbus, &pid) == 0)
29342 -                       pdev = pci_find_slot(pbus, pid);
29343 -               if (pdev == NULL)
29344 -                       printk(KERN_WARNING "ide: no PCI host for device %s, DMA disabled\n",
29345 -                              np->full_name);
29346 +       return 0;
29347 +}
29348  
29349 -               /*
29350 -                * If this slot is taken (e.g. by ide-pci.c) try the next one.
29351 -                */
29352 -               while (i < MAX_HWIFS
29353 -                      && ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0)
29354 -                       ++i;
29355 -               if (i >= MAX_HWIFS)
29356 -                       break;
29357 -               pmif = &pmac_ide[i];
29358 +/* Resume call back, should be called before the child devices
29359 + * are resumed
29360 + */
29361 +static int
29362 +pmac_ide_do_resume(ide_hwif_t *hwif)
29363 +{
29364 +       pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
29365 +       
29366 +       /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */
29367 +       if (!pmif->mediabay) {
29368 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1);
29369 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1);
29370 +               mdelay(10);
29371 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0);
29372 +               mdelay(100);
29373 +       }
29374  
29375 -               /*
29376 -                * Some older OFs have bogus sizes, causing request_OF_resource
29377 -                * to fail. We fix them up here
29378 -                */
29379 -               if (np->addrs[0].size > 0x1000)
29380 -                       np->addrs[0].size = 0x1000;
29381 -               if (np->n_addrs > 1 && np->addrs[1].size > 0x100)
29382 -                       np->addrs[1].size = 0x100;
29383 +       /* Sanitize drive timings */
29384 +       sanitize_timings(pmif);
29385  
29386 -               if (request_OF_resource(np, 0, "  (mac-io IDE IO)") == NULL) {
29387 -                       printk(KERN_ERR "ide-pmac(%s): can't request IO resource !\n", np->name);
29388 -                       continue;
29389 -               }
29390 +       return 0;
29391 +}
29392  
29393 -               base = (unsigned long) ioremap(np->addrs[0].address, 0x400);
29394 +static int
29395 +pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
29396 +{
29397 +       struct device_node *np = pmif->node;
29398 +       int *bidp, i;
29399  
29400 -               /* XXX This is bogus. Should be fixed in the registry by checking
29401 -                  the kind of host interrupt controller, a bit like gatwick
29402 -                  fixes in irq.c
29403 -                */
29404 -               if (np->n_intrs == 0) {
29405 -                       printk(KERN_WARNING "ide: no intrs for device %s, using 13\n",
29406 -                              np->full_name);
29407 -                       irq = 13;
29408 -               } else {
29409 -                       irq = np->intrs[0].line;
29410 -               }
29411 -               pmif->regbase = base;
29412 -               pmif->irq = irq;
29413 -               pmif->node = np;
29414 -               pmif->index = i;
29415 -               if (device_is_compatible(np, "keylargo-ata")) {
29416 -                       if (strcmp(np->name, "ata-4") == 0)
29417 -                               pmif->kind = controller_kl_ata4;
29418 -                       else
29419 -                               pmif->kind = controller_kl_ata3;
29420 -               } else if (device_is_compatible(np, "heathrow-ata"))
29421 -                       pmif->kind = controller_heathrow;
29422 +       pmif->cable_80 = 0;
29423 +       pmif->broken_dma = pmif->broken_dma_warn = 0;
29424 +       if (device_is_compatible(np, "kauai-ata"))
29425 +               pmif->kind = controller_un_ata6;
29426 +       else if (device_is_compatible(np, "keylargo-ata")) {
29427 +               if (strcmp(np->name, "ata-4") == 0)
29428 +                       pmif->kind = controller_kl_ata4;
29429                 else
29430 -                       pmif->kind = controller_ohare;
29431 +                       pmif->kind = controller_kl_ata3;
29432 +       } else if (device_is_compatible(np, "heathrow-ata"))
29433 +               pmif->kind = controller_heathrow;
29434 +       else {
29435 +               pmif->kind = controller_ohare;
29436 +               pmif->broken_dma = 1;
29437 +       }
29438  
29439 -               bidp = (int *)get_property(np, "AAPL,bus-id", NULL);
29440 -               pmif->aapl_bus_id =  bidp ? *bidp : 0;
29441 +       bidp = (int *)get_property(np, "AAPL,bus-id", NULL);
29442 +       pmif->aapl_bus_id =  bidp ? *bidp : 0;
29443  
29444 -               if (pmif->kind == controller_kl_ata4) {
29445 -                       char* cable = get_property(np, "cable-type", NULL);
29446 -                       if (cable && !strncmp(cable, "80-", 3))
29447 -                               pmif->kind = controller_kl_ata4_80;
29448 -               }
29449 +       /* Get cable type from device-tree */
29450 +       if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6) {
29451 +               char* cable = get_property(np, "cable-type", NULL);
29452 +               if (cable && !strncmp(cable, "80-", 3))
29453 +                       pmif->cable_80 = 1;
29454 +       }
29455  
29456 -               /* Make sure we have sane timings */
29457 -               sanitize_timings(pmif);
29458 +       pmif->mediabay = 0;
29459 +       
29460 +       /* Make sure we have sane timings */
29461 +       sanitize_timings(pmif);
29462  
29463 -               if (np->parent && np->parent->name
29464 -                   && strcasecmp(np->parent->name, "media-bay") == 0) {
29465 +       /* XXX FIXME: Media bay stuff need re-organizing */
29466 +       if (np->parent && np->parent->name
29467 +           && strcasecmp(np->parent->name, "media-bay") == 0) {
29468  #ifdef CONFIG_PMAC_PBOOK
29469 -                       media_bay_set_ide_infos(np->parent,base,irq,i);
29470 +               media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq, hwif->index);
29471  #endif /* CONFIG_PMAC_PBOOK */
29472 -                       in_bay = 1;
29473 -                       if (!bidp)
29474 -                               pmif->aapl_bus_id = 1;
29475 -               } else if (pmif->kind == controller_ohare) {
29476 -                       /* The code below is having trouble on some ohare machines
29477 -                        * (timing related ?). Until I can put my hand on one of these
29478 -                        * units, I keep the old way
29479 -                        */
29480 -                       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1);
29481 -               } else {
29482 -                       /* This is necessary to enable IDE when net-booting */
29483 -                       printk(KERN_INFO "pmac_ide: enabling IDE bus ID %d\n",
29484 -                               pmif->aapl_bus_id);
29485 -                       ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
29486 -                       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
29487 -                       mdelay(10);
29488 -                       ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
29489 -                       big_delay = 1;
29490 -               }
29491 +               pmif->mediabay = 1;
29492 +               if (!bidp)
29493 +                       pmif->aapl_bus_id = 1;
29494 +       } else if (pmif->kind == controller_ohare) {
29495 +               /* The code below is having trouble on some ohare machines
29496 +                * (timing related ?). Until I can put my hand on one of these
29497 +                * units, I keep the old way
29498 +                */
29499 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1);
29500 +       } else {
29501 +               /* This is necessary to enable IDE when net-booting */
29502 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
29503 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
29504 +               mdelay(10);
29505 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
29506 +               mdelay(100);
29507 +       }
29508  
29509 -               hwif = &ide_hwifs[i];
29510 -               /* Setup MMIO ops */
29511 -               default_hwif_mmiops(hwif);
29512 -               /* Tell common code _not_ to mess with resources */
29513 -               hwif->mmio = 2;
29514 -               hwif->hwif_data = pmif;
29515 -               pmac_ide_init_hwif_ports(&hwif->hw, base, 0, &hwif->irq);
29516 -               memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
29517 -               hwif->chipset = ide_pmac;
29518 -               hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || in_bay;
29519 -               hwif->udma_four = (pmif->kind == controller_kl_ata4_80);
29520 -               hwif->pci_dev = pdev;
29521 -               hwif->drives[0].unmask = 1;
29522 -               hwif->drives[1].unmask = 1;
29523 -               hwif->tuneproc = pmac_ide_tuneproc;
29524 +       /* Setup MMIO ops */
29525 +       default_hwif_mmiops(hwif);
29526 +
29527 +       /* Tell common code _not_ to mess with resources */
29528 +       hwif->mmio = 2;
29529 +       hwif->hwif_data = pmif;
29530 +       pmac_ide_init_hwif_ports(&hwif->hw, pmif->regbase, 0, &hwif->irq);
29531 +       memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
29532 +       hwif->chipset = ide_pmac;
29533 +       hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || pmif->mediabay;
29534 +       hwif->hold = pmif->mediabay;
29535 +       hwif->udma_four = pmif->cable_80;
29536 +       hwif->drives[0].unmask = 1;
29537 +       hwif->drives[1].unmask = 1;
29538 +       hwif->tuneproc = pmac_ide_tuneproc;
29539 +       if (pmif->kind == controller_un_ata6)
29540 +               hwif->selectproc = pmac_ide_kauai_selectproc;
29541 +       else
29542                 hwif->selectproc = pmac_ide_selectproc;
29543 -               hwif->speedproc = pmac_ide_tune_chipset;
29544 +       hwif->speedproc = pmac_ide_tune_chipset;
29545 +
29546 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
29547 +       pmu_ide_blink_enabled = pmu_hd_blink_init();
29548 +
29549 +       if (pmu_ide_blink_enabled)
29550 +               hwif->led_act = pmu_hd_kick_blink;
29551 +#endif
29552 +
29553 +       printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s\n",
29554 +                       hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
29555 +                       pmif->mediabay ? " (mediabay)" : "");
29556 +                       
29557  #ifdef CONFIG_PMAC_PBOOK
29558 -               if (in_bay && check_media_bay_by_base(base, MB_CD) == 0)
29559 -                       hwif->noprobe = 0;
29560 +       if (pmif->mediabay && check_media_bay_by_base(pmif->regbase, MB_CD) == 0)
29561 +               hwif->noprobe = 0;
29562  #endif /* CONFIG_PMAC_PBOOK */
29563  
29564  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
29565 -               if (np->n_addrs >= 2) {
29566 -                       /* has a DBDMA controller channel */
29567 -                       pmac_ide_setup_dma(np, i);
29568 -               }
29569 -               hwif->atapi_dma = 1;
29570 -               hwif->ultra_mask = 0x1f;
29571 -               hwif->mwdma_mask = 0x07;
29572 -               hwif->swdma_mask = 0x07;
29573 -
29574 +       /* has a DBDMA controller channel */
29575 +       if (pmif->dma_regs)
29576 +               pmac_ide_setup_dma(pmif, hwif);
29577  #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
29578  
29579 +       /* We probe the hwif now */
29580 +       probe_hwif_init(hwif);
29581 +
29582 +       /* The code IDE code will have set hwif->present if we have devices attached,
29583 +        * if we don't, the discard the interface except if we are on a media bay slot
29584 +        */
29585 +       if (!hwif->present && !pmif->mediabay) {
29586 +               printk(KERN_INFO "ide%d: Bus empty, interface released.\n",
29587 +                       hwif->index);
29588 +               default_hwif_iops(hwif);
29589 +               for (i = IDE_DATA_OFFSET; i <= IDE_CONTROL_OFFSET; ++i)
29590 +                       hwif->io_ports[i] = 0;
29591 +               hwif->chipset = ide_unknown;
29592 +               hwif->noprobe = 1;
29593 +               return -ENODEV;
29594 +       }
29595 +
29596 +       return 0;
29597 +}
29598 +
29599 +static int __devinit
29600 +pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_match *match)
29601 +{
29602 +       unsigned long base, regbase;
29603 +       int irq;
29604 +       ide_hwif_t *hwif;
29605 +       pmac_ide_hwif_t *pmif;
29606 +       int i, rc;
29607 +
29608 +       i = 0;
29609 +       while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0
29610 +           || pmac_ide[i].node != NULL))
29611                 ++i;
29612 +       if (i >= MAX_HWIFS) {
29613 +               printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n");
29614 +               printk(KERN_ERR "          %s\n", mdev->ofdev.node->full_name);
29615 +               return -ENODEV;
29616         }
29617 -       pmac_ide_count = i;
29618 -       if (big_delay)
29619 -               mdelay(IDE_WAKEUP_DELAY_MS);
29620  
29621 -#ifdef CONFIG_PMAC_PBOOK
29622 -       pmu_register_sleep_notifier(&idepmac_sleep_notifier);
29623 -#endif /* CONFIG_PMAC_PBOOK */
29624 +       pmif = &pmac_ide[i];
29625 +       hwif = &ide_hwifs[i];
29626 +
29627 +       if (mdev->ofdev.node->n_addrs == 0) {
29628 +               printk(KERN_WARNING "ide%d: no address for %s\n",
29629 +                      i, mdev->ofdev.node->full_name);
29630 +               return -ENXIO;
29631 +       }
29632 +
29633 +       /*
29634 +        * Some older OFs have bogus sizes, causing request_OF_resource
29635 +        * to fail. We fix them up here
29636 +        */
29637 +       if (mdev->ofdev.node->addrs[0].size > 0x1000)
29638 +               mdev->ofdev.node->addrs[0].size = 0x1000;
29639 +       if (mdev->ofdev.node->n_addrs > 1 && mdev->ofdev.node->addrs[1].size > 0x100)
29640 +               mdev->ofdev.node->addrs[1].size = 0x100;
29641 +
29642 +       /* Request memory resource for IO ports */
29643 +       if (request_OF_resource(mdev->ofdev.node, 0, "  (mac-io ata ports)") == NULL) {
29644 +               printk(KERN_ERR "ide%d: can't request mmio resource !\n", i);
29645 +               return -EBUSY;
29646 +       }
29647 +                       
29648 +       /* XXX This is bogus. Should be fixed in the registry by checking
29649 +        * the kind of host interrupt controller, a bit like gatwick
29650 +        * fixes in irq.c. That works well enough for the single case
29651 +        * where that happens though...
29652 +        */
29653 +       if (mdev->ofdev.node->n_intrs == 0) {
29654 +               printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n",
29655 +                       i, mdev->ofdev.node->full_name);
29656 +               irq = 13;
29657 +       } else
29658 +               irq = mdev->ofdev.node->intrs[0].line;
29659 +
29660 +       base =  (unsigned long) ioremap(mdev->ofdev.node->addrs[0].address, 0x400);
29661 +       regbase = base;
29662 +
29663 +       hwif->pci_dev = mdev->bus->pdev;
29664 +       hwif->gendev.parent = &mdev->ofdev.dev;
29665 +
29666 +       pmif->mdev = mdev;
29667 +       pmif->node = mdev->ofdev.node;
29668 +       pmif->regbase = regbase;
29669 +       pmif->irq = irq;
29670 +#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
29671 +       if (mdev->ofdev.node->n_addrs >= 2)
29672 +               pmif->dma_regs = (volatile struct dbdma_regs*)
29673 +                       ioremap(mdev->ofdev.node->addrs[1].address, 0x1000);
29674 +       else
29675 +               pmif->dma_regs = NULL;
29676 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
29677 +       dev_set_drvdata(&mdev->ofdev.dev, hwif);
29678 +
29679 +       rc = pmac_ide_setup_device(pmif, hwif);
29680 +       if (rc != 0) {
29681 +               /* The inteface is released to the common IDE layer */
29682 +               dev_set_drvdata(&mdev->ofdev.dev, NULL);
29683 +               iounmap((void *)base);
29684 +               if (pmif->dma_regs)
29685 +                       iounmap((void *)pmif->dma_regs);
29686 +               memset(pmif, 0, sizeof(*pmif));
29687 +               release_OF_resource(mdev->ofdev.node, 0);
29688 +       }
29689 +
29690 +       return rc;
29691  }
29692  
29693 +static int
29694 +pmac_ide_macio_suspend(struct macio_dev *mdev, u32 state)
29695 +{
29696 +       ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
29697 +       int             rc = 0;
29698 +
29699 +       if (state != mdev->ofdev.dev.power_state && state >= 2) {
29700 +               rc = pmac_ide_do_suspend(hwif);
29701 +               if (rc == 0)
29702 +                       mdev->ofdev.dev.power_state = state;
29703 +       }
29704 +
29705 +       return rc;
29706 +}
29707 +
29708 +static int
29709 +pmac_ide_macio_resume(struct macio_dev *mdev)
29710 +{
29711 +       ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
29712 +       int             rc = 0;
29713 +       
29714 +       if (mdev->ofdev.dev.power_state != 0) {
29715 +               rc = pmac_ide_do_resume(hwif);
29716 +               if (rc == 0)
29717 +                       mdev->ofdev.dev.power_state = 0;
29718 +       }
29719 +
29720 +       return rc;
29721 +}
29722 +
29723 +static int __devinit
29724 +pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
29725 +{
29726 +       ide_hwif_t *hwif;
29727 +       struct device_node *np;
29728 +       pmac_ide_hwif_t *pmif;
29729 +       unsigned long base;
29730 +       unsigned long rbase, rlen;
29731 +       int i, rc;
29732 +
29733 +       np = pci_device_to_OF_node(pdev);
29734 +       if (np == NULL) {
29735 +               printk(KERN_ERR "ide-pmac: cannot find MacIO node for Kauai ATA interface\n");
29736 +               return -ENODEV;
29737 +       }
29738 +       i = 0;
29739 +       while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0
29740 +           || pmac_ide[i].node != NULL))
29741 +               ++i;
29742 +       if (i >= MAX_HWIFS) {
29743 +               printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n");
29744 +               printk(KERN_ERR "          %s\n", np->full_name);
29745 +               return -ENODEV;
29746 +       }
29747 +
29748 +       pmif = &pmac_ide[i];
29749 +       hwif = &ide_hwifs[i];
29750 +
29751 +       if (pci_enable_device(pdev)) {
29752 +               printk(KERN_WARNING "ide%i: Can't enable PCI device for %s\n",
29753 +                       i, np->full_name);
29754 +               return -ENXIO;
29755 +       }
29756 +       pci_set_master(pdev);
29757 +                       
29758 +       if (pci_request_regions(pdev, "Kauai ATA")) {
29759 +               printk(KERN_ERR "ide%d: Cannot obtain PCI resources for %s\n",
29760 +                       i, np->full_name);
29761 +               return -ENXIO;
29762 +       }
29763 +
29764 +       hwif->pci_dev = pdev;
29765 +       hwif->gendev.parent = &pdev->dev;
29766 +       pmif->mdev = NULL;
29767 +       pmif->node = np;
29768 +
29769 +       rbase = pci_resource_start(pdev, 0);
29770 +       rlen = pci_resource_len(pdev, 0);
29771 +
29772 +       base = (unsigned long) ioremap(rbase, rlen);
29773 +       pmif->regbase = base + 0x2000;
29774  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
29775 +       pmif->dma_regs = (volatile struct dbdma_regs*)(base + 0x1000);
29776 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */        
29777 +       pmif->irq = pdev->irq;
29778 +
29779 +       pci_set_drvdata(pdev, hwif);
29780 +
29781 +       rc = pmac_ide_setup_device(pmif, hwif);
29782 +       if (rc != 0) {
29783 +               /* The inteface is released to the common IDE layer */
29784 +               pci_set_drvdata(pdev, NULL);
29785 +               iounmap((void *)base);
29786 +               memset(pmif, 0, sizeof(*pmif));
29787 +               pci_release_regions(pdev);
29788 +       }
29789 +
29790 +       return rc;
29791 +}
29792 +
29793 +static int
29794 +pmac_ide_pci_suspend(struct pci_dev *pdev, u32 state)
29795 +{
29796 +       ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
29797 +       int             rc = 0;
29798 +       
29799 +       if (state != pdev->dev.power_state && state >= 2) {
29800 +               rc = pmac_ide_do_suspend(hwif);
29801 +               if (rc == 0)
29802 +                       pdev->dev.power_state = state;
29803 +       }
29804 +
29805 +       return rc;
29806 +}
29807  
29808  static int
29809 +pmac_ide_pci_resume(struct pci_dev *pdev)
29810 +{
29811 +       ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
29812 +       int             rc = 0;
29813 +       
29814 +       if (pdev->dev.power_state != 0) {
29815 +               rc = pmac_ide_do_resume(hwif);
29816 +               if (rc == 0)
29817 +                       pdev->dev.power_state = 0;
29818 +       }
29819 +
29820 +       return rc;
29821 +}
29822 +
29823 +static struct of_match pmac_ide_macio_match[] = 
29824 +{
29825 +       {
29826 +       .name           = "IDE",
29827 +       .type           = OF_ANY_MATCH,
29828 +       .compatible     = OF_ANY_MATCH
29829 +       },
29830 +       {
29831 +       .name           = "ATA",
29832 +       .type           = OF_ANY_MATCH,
29833 +       .compatible     = OF_ANY_MATCH
29834 +       },
29835 +       {
29836 +       .name           = OF_ANY_MATCH,
29837 +       .type           = "ide",
29838 +       .compatible     = OF_ANY_MATCH
29839 +       },
29840 +       {
29841 +       .name           = OF_ANY_MATCH,
29842 +       .type           = "ata",
29843 +       .compatible     = OF_ANY_MATCH
29844 +       },
29845 +       {},
29846 +};
29847 +
29848 +static struct macio_driver pmac_ide_macio_driver = 
29849 +{
29850 +       .name           = "ide-pmac",
29851 +       .match_table    = pmac_ide_macio_match,
29852 +       .probe          = pmac_ide_macio_attach,
29853 +       .suspend        = pmac_ide_macio_suspend,
29854 +       .resume         = pmac_ide_macio_resume,
29855 +};
29856 +
29857 +static struct pci_device_id pmac_ide_pci_match[] __devinitdata = {
29858 +       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_KAUAI_ATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
29859 +};
29860 +
29861 +static struct pci_driver pmac_ide_pci_driver = {
29862 +       .name           = "ide-pmac",
29863 +       .id_table       = pmac_ide_pci_match,
29864 +       .probe          = pmac_ide_pci_attach,
29865 +       .suspend        = pmac_ide_pci_suspend,
29866 +       .resume         = pmac_ide_pci_resume,
29867 +};
29868 +
29869 +void __init
29870 +pmac_ide_probe(void)
29871 +{
29872 +       if (_machine != _MACH_Pmac)
29873 +               return;
29874 +
29875 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST
29876 +       pci_register_driver(&pmac_ide_pci_driver);
29877 +       macio_register_driver(&pmac_ide_macio_driver);
29878 +#else
29879 +       macio_register_driver(&pmac_ide_macio_driver);
29880 +       pci_register_driver(&pmac_ide_pci_driver);
29881 +#endif 
29882 +}
29883 +
29884 +#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
29885 +
29886 +static int __pmac
29887  pmac_ide_build_sglist(ide_drive_t *drive, struct request *rq)
29888  {
29889         ide_hwif_t *hwif = HWIF(drive);
29890 @@ -942,7 +1479,7 @@
29891         if (hwif->sg_dma_active)
29892                 BUG();
29893                 
29894 -       nents = blk_rq_map_sg(&drive->queue, rq, sg);
29895 +       nents = blk_rq_map_sg(drive->queue, rq, sg);
29896                 
29897         if (rq_data_dir(rq) == READ)
29898                 pmif->sg_dma_direction = PCI_DMA_FROMDEVICE;
29899 @@ -952,7 +1489,7 @@
29900         return pci_map_sg(hwif->pci_dev, sg, nents, pmif->sg_dma_direction);
29901  }
29902  
29903 -static int
29904 +static int __pmac
29905  pmac_ide_raw_build_sglist(ide_drive_t *drive, struct request *rq)
29906  {
29907         ide_hwif_t *hwif = HWIF(drive);
29908 @@ -968,14 +1505,14 @@
29909         else
29910                 pmif->sg_dma_direction = PCI_DMA_FROMDEVICE;
29911         
29912 -       if (sector_count > 127) {
29913 +       if (sector_count > 128) {
29914                 memset(&sg[nents], 0, sizeof(*sg));
29915                 sg[nents].page = virt_to_page(virt_addr);
29916                 sg[nents].offset = offset_in_page(virt_addr);
29917 -               sg[nents].length = 127  * SECTOR_SIZE;
29918 +               sg[nents].length = 128  * SECTOR_SIZE;
29919                 nents++;
29920 -               virt_addr = virt_addr + (127 * SECTOR_SIZE);
29921 -               sector_count -= 127;
29922 +               virt_addr = virt_addr + (128 * SECTOR_SIZE);
29923 +               sector_count -= 128;
29924         }
29925         memset(&sg[nents], 0, sizeof(*sg));
29926         sg[nents].page = virt_to_page(virt_addr);
29927 @@ -990,16 +1527,16 @@
29928   * pmac_ide_build_dmatable builds the DBDMA command list
29929   * for a transfer and sets the DBDMA channel to point to it.
29930   */
29931 -static int
29932 -pmac_ide_build_dmatable(ide_drive_t *drive, int wr)
29933 +static int __pmac
29934 +pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
29935  {
29936         struct dbdma_cmd *table;
29937         int i, count = 0;
29938 -       struct request *rq = HWGROUP(drive)->rq;
29939         ide_hwif_t *hwif = HWIF(drive);
29940         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
29941         volatile struct dbdma_regs *dma = pmif->dma_regs;
29942         struct scatterlist *sg;
29943 +       int wr = (rq_data_dir(rq) == WRITE);
29944  
29945         /* DMA table is already aligned */
29946         table = (struct dbdma_cmd *) pmif->dma_table_cpu;
29947 @@ -1026,10 +1563,18 @@
29948                 cur_addr = sg_dma_address(sg);
29949                 cur_len = sg_dma_len(sg);
29950  
29951 +               if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) {
29952 +                       if (pmif->broken_dma_warn == 0) {
29953 +                               printk(KERN_WARNING "%s: DMA on non aligned address,"
29954 +                                      "switching to PIO on Ohare chipset\n", drive->name);
29955 +                               pmif->broken_dma_warn = 1;
29956 +                       }
29957 +                       goto use_pio_instead;
29958 +               }
29959                 while (cur_len) {
29960                         unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
29961  
29962 -                       if (++count >= MAX_DCMDS) {
29963 +                       if (count++ >= MAX_DCMDS) {
29964                                 printk(KERN_WARNING "%s: DMA table too small\n",
29965                                        drive->name);
29966                                 goto use_pio_instead;
29967 @@ -1070,7 +1615,7 @@
29968  }
29969  
29970  /* Teardown mappings after DMA has completed.  */
29971 -static void
29972 +static void __pmac
29973  pmac_ide_destroy_dmatable (ide_drive_t *drive)
29974  {
29975         struct pci_dev *dev = HWIF(drive)->pci_dev;
29976 @@ -1081,67 +1626,25 @@
29977         if (nents) {
29978                 pci_unmap_sg(dev, sg, nents, pmif->sg_dma_direction);
29979                 pmif->sg_nents = 0;
29980 +               HWIF(drive)->sg_dma_active = 0;
29981         }
29982  }
29983  
29984 -static __inline__ unsigned char
29985 -dma_bits_to_command(unsigned char bits)
29986 -{
29987 -       if(bits & 0x04)
29988 -               return XFER_MW_DMA_2;
29989 -       if(bits & 0x02)
29990 -               return XFER_MW_DMA_1;
29991 -       if(bits & 0x01)
29992 -               return XFER_MW_DMA_0;
29993 -       return 0;
29994 -}
29995 -
29996 -static __inline__ unsigned char
29997 -udma_bits_to_command(unsigned char bits, int high_speed)
29998 -{
29999 -       if (high_speed) {
30000 -               if(bits & 0x10)
30001 -                       return XFER_UDMA_4;
30002 -               if(bits & 0x08)
30003 -                       return XFER_UDMA_3;
30004 -       }
30005 -       if(bits & 0x04)
30006 -               return XFER_UDMA_2;
30007 -       if(bits & 0x02)
30008 -               return XFER_UDMA_1;
30009 -       if(bits & 0x01)
30010 -               return XFER_UDMA_0;
30011 -       return 0;
30012 -}
30013 -
30014  /* Calculate MultiWord DMA timings */
30015  static int __pmac
30016 -pmac_ide_mdma_enable(ide_drive_t *drive)
30017 +pmac_ide_mdma_enable(ide_drive_t *drive, u16 mode)
30018  {
30019 -       u8 bits = drive->id->dma_mword & 0x07;
30020 -       u8 feature = dma_bits_to_command(bits);
30021 -       u32 *timings;
30022 +       ide_hwif_t *hwif = HWIF(drive);
30023 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
30024         int drive_cycle_time;
30025         struct hd_driveid *id = drive->id;
30026 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
30027 +       u32 *timings, *timings2;
30028 +       u32 timing_local[2];
30029         int ret;
30030  
30031 -       /* Set feature on drive */
30032 -       printk(KERN_INFO "%s: Enabling MultiWord DMA %d\n", drive->name, feature & 0xf);
30033 -       ret = pmac_ide_do_setfeature(drive, feature);
30034 -       if (ret) {
30035 -               printk(KERN_WARNING "%s: Failed !\n", drive->name);
30036 -               return 0;
30037 -       }
30038 -
30039 -       if (!drive->init_speed)
30040 -               drive->init_speed = feature;
30041 -       
30042         /* which drive is it ? */
30043 -       if (drive->select.b.unit & 0x01)
30044 -               timings = &pmif->timings[1];
30045 -       else
30046 -               timings = &pmif->timings[0];
30047 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
30048 +       timings2 = &pmif->timings[(drive->select.b.unit & 0x01) + 2];
30049  
30050         /* Check if drive provide explicit cycle time */
30051         if ((id->field_valid & 2) && (id->eide_dma_time))
30052 @@ -1149,201 +1652,220 @@
30053         else
30054                 drive_cycle_time = 0;
30055  
30056 +       /* Copy timings to local image */
30057 +       timing_local[0] = *timings;
30058 +       timing_local[1] = *timings2;
30059 +
30060         /* Calculate controller timings */
30061 -       set_timings_mdma(pmif->kind, timings, feature, drive_cycle_time);
30062 +       ret = set_timings_mdma( drive, pmif->kind,
30063 +                               &timing_local[0],
30064 +                               &timing_local[1],
30065 +                               mode,
30066 +                               drive_cycle_time);
30067 +       if (ret)
30068 +               return 0;
30069 +
30070 +       /* Set feature on drive */
30071 +       printk(KERN_INFO "%s: Enabling MultiWord DMA %d\n", drive->name, mode & 0xf);
30072 +       ret = pmac_ide_do_setfeature(drive, mode);
30073 +       if (ret) {
30074 +               printk(KERN_WARNING "%s: Failed !\n", drive->name);
30075 +               return 0;
30076 +       }
30077 +
30078 +       /* Apply timings to controller */
30079 +       *timings = timing_local[0];
30080 +       *timings2 = timing_local[1];
30081 +       
30082 +       /* Set speed info in drive */
30083 +       drive->current_speed = mode;    
30084 +       if (!drive->init_speed)
30085 +               drive->init_speed = mode;
30086  
30087 -       drive->current_speed = feature; 
30088         return 1;
30089  }
30090  
30091  /* Calculate Ultra DMA timings */
30092  static int __pmac
30093 -pmac_ide_udma_enable(ide_drive_t *drive, int high_speed)
30094 +pmac_ide_udma_enable(ide_drive_t *drive, u16 mode)
30095  {
30096 -       u8 bits = drive->id->dma_ultra & 0x1f;
30097 -       u8 feature = udma_bits_to_command(bits, high_speed);
30098 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
30099 -       u32 *timings;
30100 +       ide_hwif_t *hwif = HWIF(drive);
30101 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
30102 +       u32 *timings, *timings2;
30103 +       u32 timing_local[2];
30104         int ret;
30105 +               
30106 +       /* which drive is it ? */
30107 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
30108 +       timings2 = &pmif->timings[(drive->select.b.unit & 0x01) + 2];
30109  
30110 +       /* Copy timings to local image */
30111 +       timing_local[0] = *timings;
30112 +       timing_local[1] = *timings2;
30113 +       
30114 +       /* Calculate timings for interface */
30115 +       if (pmif->kind == controller_un_ata6)
30116 +               ret = set_timings_udma_ata6(    &timing_local[0],
30117 +                                               &timing_local[1],
30118 +                                               mode);
30119 +       else
30120 +               ret = set_timings_udma_ata4(&timing_local[0], mode);
30121 +       if (ret)
30122 +               return 0;
30123 +               
30124         /* Set feature on drive */
30125 -       printk(KERN_INFO "%s: Enabling Ultra DMA %d\n", drive->name, feature & 0xf);
30126 -       ret = pmac_ide_do_setfeature(drive, feature);
30127 +       printk(KERN_INFO "%s: Enabling Ultra DMA %d\n", drive->name, mode & 0x0f);
30128 +       ret = pmac_ide_do_setfeature(drive, mode);
30129         if (ret) {
30130                 printk(KERN_WARNING "%s: Failed !\n", drive->name);
30131                 return 0;
30132         }
30133  
30134 -       if (!drive->init_speed)
30135 -               drive->init_speed = feature;
30136 +       /* Apply timings to controller */
30137 +       *timings = timing_local[0];
30138 +       *timings2 = timing_local[1];
30139  
30140 -       /* which drive is it ? */
30141 -       if (drive->select.b.unit & 0x01)
30142 -               timings = &pmif->timings[1];
30143 -       else
30144 -               timings = &pmif->timings[0];
30145 -
30146 -       set_timings_udma(timings, feature);
30147 +       /* Set speed info in drive */
30148 +       drive->current_speed = mode;    
30149 +       if (!drive->init_speed)
30150 +               drive->init_speed = mode;
30151  
30152 -       drive->current_speed = feature; 
30153         return 1;
30154  }
30155  
30156 -int pmac_ide_dma_check(ide_drive_t *drive)
30157 +static int __pmac
30158 +pmac_ide_dma_check(ide_drive_t *drive)
30159  {
30160 -       int ata4, udma;
30161         struct hd_driveid *id = drive->id;
30162         ide_hwif_t *hwif = HWIF(drive);
30163         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
30164         int enable = 1;
30165 -
30166 +       int map;
30167         drive->using_dma = 0;
30168         
30169 -       if (pmif == NULL)
30170 -               return 0;
30171 -               
30172         if (drive->media == ide_floppy)
30173                 enable = 0;
30174 -       if (((id->capability & 1) == 0) &&
30175 -           !HWIF(drive)->ide_dma_good_drive(drive))
30176 +       if (((id->capability & 1) == 0) && !__ide_dma_good_drive(drive))
30177                 enable = 0;
30178 -       if (HWIF(drive)->ide_dma_bad_drive(drive))
30179 +       if (__ide_dma_bad_drive(drive))
30180                 enable = 0;
30181 -       udma = 0;
30182 -       ata4 = (pmif->kind == controller_kl_ata4 ||
30183 -               pmif->kind == controller_kl_ata4_80);
30184 -                       
30185 -       if(enable) {
30186 -               if (ata4 && (drive->media == ide_disk) &&
30187 -                   (id->field_valid & 0x0004) && (id->dma_ultra & 0x1f)) {
30188 -                       /* UltraDMA modes. */
30189 -                       drive->using_dma = pmac_ide_udma_enable(drive,
30190 -                               pmif->kind == controller_kl_ata4_80);
30191 -               }
30192 -               if (!drive->using_dma && (id->dma_mword & 0x0007)) {
30193 -                       /* Normal MultiWord DMA modes. */
30194 -                       drive->using_dma = pmac_ide_mdma_enable(drive);
30195 +
30196 +       if (enable) {
30197 +               short mode;
30198 +               
30199 +               map = XFER_MWDMA;
30200 +               if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6) {
30201 +                       map |= XFER_UDMA;
30202 +                       if (pmif->cable_80) {
30203 +                               map |= XFER_UDMA_66;
30204 +                               if (pmif->kind == controller_un_ata6)
30205 +                                       map |= XFER_UDMA_100;
30206 +                       }
30207                 }
30208 +               mode = ide_find_best_mode(drive, map);
30209 +               if (mode & XFER_UDMA)
30210 +                       drive->using_dma = pmac_ide_udma_enable(drive, mode);
30211 +               else if (mode & XFER_MWDMA)
30212 +                       drive->using_dma = pmac_ide_mdma_enable(drive, mode);
30213                 hwif->OUTB(0, IDE_CONTROL_REG);
30214                 /* Apply settings to controller */
30215 -               pmac_ide_selectproc(drive);
30216 +               pmac_ide_do_update_timings(drive);
30217         }
30218         return 0;
30219  }
30220  
30221 -static int
30222 -pmac_ide_dma_read (ide_drive_t *drive)
30223 +static int __pmac
30224 +pmac_ide_dma_start(ide_drive_t *drive, int reading)
30225  {
30226         ide_hwif_t *hwif = HWIF(drive);
30227         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
30228         struct request *rq = HWGROUP(drive)->rq;
30229 -//     ide_task_t *args = rq->special;
30230         u8 unit = (drive->select.b.unit & 0x01);
30231         u8 ata4;
30232 -       u8 lba48 = (drive->addressing == 1) ? 1 : 0;
30233 -       task_ioreg_t command = WIN_NOP;
30234  
30235         if (pmif == NULL)
30236                 return 1;
30237 +       ata4 = (pmif->kind == controller_kl_ata4);      
30238  
30239 -       ata4 = (pmif->kind == controller_kl_ata4 ||
30240 -               pmif->kind == controller_kl_ata4_80);
30241 -
30242 -       if (!pmac_ide_build_dmatable(drive, 0))
30243 +       if (!pmac_ide_build_dmatable(drive, rq))
30244                 return 1;
30245 +
30246         /* Apple adds 60ns to wrDataSetup on reads */
30247         if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
30248 -               writel(pmif->timings[unit]+0x00800000UL,
30249 +               writel(pmif->timings[unit] + (reading ? 0x00800000UL : 0),
30250                         (unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
30251                 (void)readl((unsigned *)(IDE_DATA_REG + IDE_TIMING_CONFIG));
30252         }
30253 +
30254         drive->waiting_for_dma = 1;
30255 +
30256 +       return 0;
30257 +}
30258 +
30259 +static int __pmac
30260 +pmac_ide_dma_read(ide_drive_t *drive)
30261 +{
30262 +       struct request *rq = HWGROUP(drive)->rq;
30263 +       u8 lba48 = (drive->addressing == 1) ? 1 : 0;
30264 +       task_ioreg_t command = WIN_NOP;
30265 +
30266 +       if (pmac_ide_dma_start(drive, 1))
30267 +               return 1;
30268 +
30269         if (drive->media != ide_disk)
30270                 return 0;
30271 -       if (HWGROUP(drive)->handler != NULL)    /* paranoia check */
30272 -               BUG();
30273 -       ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
30274 -       /*
30275 -        * FIX ME to use only ACB ide_task_t args Struct
30276 -        */
30277 -#if 0
30278 -       {
30279 -               ide_task_t *args = rq->special;
30280 -               command = args->tfRegister[IDE_COMMAND_OFFSET];
30281 -       }
30282 -#else
30283 +
30284         command = (lba48) ? WIN_READDMA_EXT : WIN_READDMA;
30285 +       
30286 +       if (drive->vdma)
30287 +               command = (lba48) ? WIN_READ_EXT: WIN_READ;
30288 +               
30289         if (rq->flags & REQ_DRIVE_TASKFILE) {
30290                 ide_task_t *args = rq->special;
30291                 command = args->tfRegister[IDE_COMMAND_OFFSET];
30292         }
30293 -#endif
30294 +
30295         /* issue cmd to drive */
30296 -       hwif->OUTB(command, IDE_COMMAND_REG);
30297 +       ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL);
30298  
30299         return pmac_ide_dma_begin(drive);
30300  }
30301  
30302 -static int
30303 +static int __pmac
30304  pmac_ide_dma_write (ide_drive_t *drive)
30305  {
30306 -       ide_hwif_t *hwif = HWIF(drive);
30307 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
30308         struct request *rq = HWGROUP(drive)->rq;
30309 -//     ide_task_t *args = rq->special;
30310 -       u8 unit = (drive->select.b.unit & 0x01);
30311 -       u8 ata4;
30312         u8 lba48 = (drive->addressing == 1) ? 1 : 0;
30313         task_ioreg_t command = WIN_NOP;
30314  
30315 -       if (pmif == NULL)
30316 +       if (pmac_ide_dma_start(drive, 0))
30317                 return 1;
30318  
30319 -       ata4 = (pmif->kind == controller_kl_ata4 ||
30320 -               pmif->kind == controller_kl_ata4_80);
30321 -
30322 -       if (!pmac_ide_build_dmatable(drive, 1))
30323 -               return 1;
30324 -       /* Apple adds 60ns to wrDataSetup on reads */
30325 -       if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
30326 -               writel(pmif->timings[unit],
30327 -                       (unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
30328 -               (void)readl((unsigned *)(IDE_DATA_REG + IDE_TIMING_CONFIG));
30329 -       }
30330 -       drive->waiting_for_dma = 1;
30331         if (drive->media != ide_disk)
30332                 return 0;
30333 -       if (HWGROUP(drive)->handler != NULL)    /* paranoia check */
30334 -               BUG();
30335 -       ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
30336 -       /*
30337 -        * FIX ME to use only ACB ide_task_t args Struct
30338 -        */
30339 -#if 0
30340 -       {
30341 -               ide_task_t *args = rq->special;
30342 -               command = args->tfRegister[IDE_COMMAND_OFFSET];
30343 -       }
30344 -#else
30345 +
30346         command = (lba48) ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
30347 +       if (drive->vdma)
30348 +               command = (lba48) ? WIN_WRITE_EXT: WIN_WRITE;
30349 +               
30350         if (rq->flags & REQ_DRIVE_TASKFILE) {
30351                 ide_task_t *args = rq->special;
30352                 command = args->tfRegister[IDE_COMMAND_OFFSET];
30353         }
30354 -#endif
30355 +
30356         /* issue cmd to drive */
30357 -       hwif->OUTB(command, IDE_COMMAND_REG);
30358 +       ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL);
30359  
30360         return pmac_ide_dma_begin(drive);
30361  }
30362  
30363 -static int
30364 +static int __pmac
30365  pmac_ide_dma_count (ide_drive_t *drive)
30366  {
30367         return HWIF(drive)->ide_dma_begin(drive);
30368  }
30369  
30370 -static int
30371 +static int __pmac
30372  pmac_ide_dma_begin (ide_drive_t *drive)
30373  {
30374         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
30375 @@ -1359,7 +1881,7 @@
30376         return 0;
30377  }
30378  
30379 -static int
30380 +static int __pmac
30381  pmac_ide_dma_end (ide_drive_t *drive)
30382  {
30383         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
30384 @@ -1378,7 +1900,7 @@
30385         return (dstat & (RUN|DEAD|ACTIVE)) != RUN;
30386  }
30387  
30388 -static int
30389 +static int __pmac
30390  pmac_ide_dma_test_irq (ide_drive_t *drive)
30391  {
30392         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
30393 @@ -1418,33 +1940,33 @@
30394                 return 1;
30395         if (!drive->waiting_for_dma)
30396                 printk(KERN_WARNING "ide%d, ide_dma_test_irq \
30397 -                       called while not waiting\n", pmif->index);
30398 +                       called while not waiting\n", HWIF(drive)->index);
30399  
30400         /* If dbdma didn't execute the STOP command yet, the
30401          * active bit is still set */
30402         drive->waiting_for_dma++;
30403         if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) {
30404                 printk(KERN_WARNING "ide%d, timeout waiting \
30405 -                       for dbdma command stop\n", pmif->index);
30406 +                       for dbdma command stop\n", HWIF(drive)->index);
30407                 return 1;
30408         }
30409 -       udelay(1);
30410 +       udelay(5);
30411         return 0;
30412  }
30413  
30414 -static int
30415 +static int __pmac
30416  pmac_ide_dma_host_off (ide_drive_t *drive)
30417  {
30418         return 0;
30419  }
30420  
30421 -static int
30422 +static int __pmac
30423  pmac_ide_dma_host_on (ide_drive_t *drive)
30424  {
30425         return 0;
30426  }
30427  
30428 -static int
30429 +static int __pmac
30430  pmac_ide_dma_lostirq (ide_drive_t *drive)
30431  {
30432         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
30433 @@ -1461,316 +1983,87 @@
30434  }
30435  
30436  static void __init 
30437 -pmac_ide_setup_dma(struct device_node *np, int ix)
30438 +pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
30439  {
30440 -       struct pmac_ide_hwif *pmif = &pmac_ide[ix];
30441 -
30442 -       if (request_OF_resource(np, 1, " (mac-io IDE DMA)") == NULL) {
30443 -               printk(KERN_ERR "ide-pmac(%s): can't request DMA resource !\n", np->name);
30444 +       /* We won't need pci_dev if we switch to generic consistent
30445 +        * DMA routines ...
30446 +        */
30447 +       if (hwif->pci_dev == NULL)
30448                 return;
30449 -       }
30450 -
30451 -       pmif->dma_regs =
30452 -               (volatile struct dbdma_regs*)ioremap(np->addrs[1].address, 0x200);
30453 -
30454         /*
30455          * Allocate space for the DBDMA commands.
30456          * The +2 is +1 for the stop command and +1 to allow for
30457          * aligning the start address to a multiple of 16 bytes.
30458          */
30459         pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent(
30460 -               ide_hwifs[ix].pci_dev,
30461 +               hwif->pci_dev,
30462                 (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
30463                 &pmif->dma_table_dma);
30464         if (pmif->dma_table_cpu == NULL) {
30465                 printk(KERN_ERR "%s: unable to allocate DMA command list\n",
30466 -                      ide_hwifs[ix].name);
30467 +                      hwif->name);
30468                 return;
30469         }
30470  
30471         pmif->sg_table = kmalloc(sizeof(struct scatterlist) * MAX_DCMDS,
30472                                  GFP_KERNEL);
30473         if (pmif->sg_table == NULL) {
30474 -               pci_free_consistent(    ide_hwifs[ix].pci_dev,
30475 +               pci_free_consistent(    hwif->pci_dev,
30476                                         (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
30477                                         pmif->dma_table_cpu, pmif->dma_table_dma);
30478                 return;
30479         }
30480 -       ide_hwifs[ix].ide_dma_off = &__ide_dma_off;
30481 -       ide_hwifs[ix].ide_dma_off_quietly = &__ide_dma_off_quietly;
30482 -       ide_hwifs[ix].ide_dma_on = &__ide_dma_on;
30483 -       ide_hwifs[ix].ide_dma_check = &pmac_ide_dma_check;
30484 -       ide_hwifs[ix].ide_dma_read = &pmac_ide_dma_read;
30485 -       ide_hwifs[ix].ide_dma_write = &pmac_ide_dma_write;
30486 -       ide_hwifs[ix].ide_dma_count = &pmac_ide_dma_count;
30487 -       ide_hwifs[ix].ide_dma_begin = &pmac_ide_dma_begin;
30488 -       ide_hwifs[ix].ide_dma_end = &pmac_ide_dma_end;
30489 -       ide_hwifs[ix].ide_dma_test_irq = &pmac_ide_dma_test_irq;
30490 -       ide_hwifs[ix].ide_dma_host_off = &pmac_ide_dma_host_off;
30491 -       ide_hwifs[ix].ide_dma_host_on = &pmac_ide_dma_host_on;
30492 -       ide_hwifs[ix].ide_dma_good_drive = &__ide_dma_good_drive;
30493 -       ide_hwifs[ix].ide_dma_bad_drive = &__ide_dma_bad_drive;
30494 -       ide_hwifs[ix].ide_dma_verbose = &__ide_dma_verbose;
30495 -       ide_hwifs[ix].ide_dma_timeout = &__ide_dma_timeout;
30496 -       ide_hwifs[ix].ide_dma_retune = &__ide_dma_retune;
30497 -       ide_hwifs[ix].ide_dma_lostirq = &pmac_ide_dma_lostirq;
30498 -       ide_hwifs[ix].ide_dma_queued_on = &__ide_dma_queued_on;
30499 -       ide_hwifs[ix].ide_dma_queued_off = &__ide_dma_queued_off;
30500 +       hwif->ide_dma_off = &__ide_dma_off;
30501 +       hwif->ide_dma_off_quietly = &__ide_dma_off_quietly;
30502 +       hwif->ide_dma_on = &__ide_dma_on;
30503 +       hwif->ide_dma_check = &pmac_ide_dma_check;
30504 +       hwif->ide_dma_read = &pmac_ide_dma_read;
30505 +       hwif->ide_dma_write = &pmac_ide_dma_write;
30506 +       hwif->ide_dma_count = &pmac_ide_dma_count;
30507 +       hwif->ide_dma_begin = &pmac_ide_dma_begin;
30508 +       hwif->ide_dma_end = &pmac_ide_dma_end;
30509 +       hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq;
30510 +       hwif->ide_dma_host_off = &pmac_ide_dma_host_off;
30511 +       hwif->ide_dma_host_on = &pmac_ide_dma_host_on;
30512 +       hwif->ide_dma_good_drive = &__ide_dma_good_drive;
30513 +       hwif->ide_dma_bad_drive = &__ide_dma_bad_drive;
30514 +       hwif->ide_dma_verbose = &__ide_dma_verbose;
30515 +       hwif->ide_dma_timeout = &__ide_dma_timeout;
30516 +       hwif->ide_dma_retune = &__ide_dma_retune;
30517 +       hwif->ide_dma_lostirq = &pmac_ide_dma_lostirq;
30518 +       hwif->ide_dma_queued_on = &__ide_dma_queued_on;
30519 +       hwif->ide_dma_queued_off = &__ide_dma_queued_off;
30520 +#ifdef CONFIG_BLK_DEV_IDE_TCQ
30521 +       hwif->ide_dma_queued_read = __ide_dma_queued_read;
30522 +       hwif->ide_dma_queued_write = __ide_dma_queued_write;
30523 +       hwif->ide_dma_queued_start = __ide_dma_queued_start;
30524 +#endif
30525  
30526  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO
30527         if (!noautodma)
30528 -               ide_hwifs[ix].autodma = 1;
30529 +               hwif->autodma = 1;
30530  #endif
30531 -       ide_hwifs[ix].drives[0].autodma = ide_hwifs[ix].autodma;
30532 -       ide_hwifs[ix].drives[1].autodma = ide_hwifs[ix].autodma;
30533 -}
30534 -
30535 -#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
30536 -
30537 -static void __pmac
30538 -idepmac_sleep_device(ide_drive_t *drive, unsigned base)
30539 -{
30540 -       ide_hwif_t *hwif = HWIF(drive);
30541 -       int j;
30542 -       
30543 -       /* FIXME: We only handle the master IDE disk, we shoud
30544 -        *        try to fix CD-ROMs here
30545 -        */
30546 -       switch (drive->media) {
30547 -       case ide_disk:
30548 -               /* Spin down the drive */
30549 -               hwif->OUTB(drive->select.all, base+0x60);
30550 -               (void) hwif->INB(base+0x60);
30551 -               udelay(100);
30552 -               hwif->OUTB(0x0, base+0x30);
30553 -               hwif->OUTB(0x0, base+0x20);
30554 -               hwif->OUTB(0x0, base+0x40);
30555 -               hwif->OUTB(0x0, base+0x50);
30556 -               hwif->OUTB(0xe0, base+0x70);
30557 -               hwif->OUTB(0x2, base+0x160);   
30558 -               for (j = 0; j < 10; j++) {
30559 -                       u8 status;
30560 -                       mdelay(100);
30561 -                       status = hwif->INB(base+0x70);
30562 -                       if (!(status & BUSY_STAT) && (status & DRQ_STAT))
30563 -                               break;
30564 -               }
30565 -               break;
30566 -       case ide_cdrom:
30567 -               // todo
30568 -               break;
30569 -       case ide_floppy:
30570 -               // todo
30571 -               break;
30572 -       }
30573 -}
30574 -
30575 -#ifdef CONFIG_PMAC_PBOOK
30576 -static void __pmac
30577 -idepmac_wake_device(ide_drive_t *drive, int used_dma)
30578 -{
30579 -       /* We force the IDE subdriver to check for a media change
30580 -        * This must be done first or we may lost the condition
30581 -        *
30582 -        * Problem: This can schedule. I moved the block device
30583 -        * wakeup almost late by priority because of that.
30584 -        */
30585 -       //if (DRIVER(drive))
30586 -       //      check_disk_change(MKDEV(drive->disk->major, drive->disk->first_minor));
30587 -       
30588 -#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
30589 -       /* We re-enable DMA on the drive if it was active. */
30590 -       /* This doesn't work with the CD-ROM in the media-bay, probably
30591 -        * because of a pending unit attention. The problem if that if I
30592 -        * clear the error, the filesystem dies.
30593 -        */
30594 -       if (used_dma && !ide_spin_wait_hwgroup(drive)) {
30595 -               /* Lock HW group */
30596 -               HWGROUP(drive)->busy = 1;
30597 -               pmac_ide_dma_check(drive);
30598 -               HWGROUP(drive)->busy = 0;
30599 -               if (!list_empty(&drive->queue.queue_head))
30600 -                       ide_do_request(HWGROUP(drive), 0);
30601 -               spin_unlock_irq(&ide_lock);
30602 -       }
30603 -#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
30604 -}
30605 -
30606 -static void __pmac
30607 -idepmac_sleep_interface(pmac_ide_hwif_t *pmif, unsigned base, int mediabay)
30608 -{
30609 -       struct device_node* np = pmif->node;
30610 -
30611 -       /* We clear the timings */
30612 -       pmif->timings[0] = 0;
30613 -       pmif->timings[1] = 0;
30614 -       
30615 -       /* The media bay will handle itself just fine */
30616 -       if (mediabay)
30617 -               return;
30618 -       
30619 -       /* Disable the bus */
30620 -       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 0);
30621 -}
30622 +       hwif->drives[0].autodma = hwif->autodma;
30623 +       hwif->drives[1].autodma = hwif->autodma;
30624  
30625 -static void __pmac
30626 -idepmac_wake_interface(pmac_ide_hwif_t *pmif, unsigned long base, int mediabay)
30627 -{
30628 -       struct device_node* np = pmif->node;
30629 -
30630 -       if (!mediabay) {
30631 -               /* Revive IDE disk and controller */
30632 -               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
30633 -               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
30634 -               mdelay(10);
30635 -               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
30636 -       }
30637 -}
30638 -
30639 -static void
30640 -idepmac_sleep_drive(ide_drive_t *drive, unsigned long base)
30641 -{
30642 -       int unlock = 0;
30643 -
30644 -       /* Wait for HW group to complete operations */
30645 -       if (ide_spin_wait_hwgroup(drive)) {
30646 -               // What can we do here ? Wake drive we had already
30647 -               // put to sleep and return an error ?
30648 -       } else {
30649 -               unlock = 1;
30650 -               /* Lock HW group */
30651 -               HWGROUP(drive)->busy = 1;
30652 -               /* Stop the device */
30653 -               idepmac_sleep_device(drive, base);
30654 -       }
30655 -       if (unlock)
30656 -               spin_unlock_irq(&ide_lock);
30657 -}
30658 -
30659 -static void
30660 -idepmac_wake_drive(ide_drive_t *drive, unsigned long base)
30661 -{
30662 -       ide_hwif_t *hwif = HWIF(drive);
30663 -       unsigned long flags;
30664 -       int j;
30665 -       
30666 -       /* Reset timings */
30667 -       pmac_ide_selectproc(drive);
30668 -       mdelay(10);
30669 -       
30670 -       /* Wait up to 20 seconds for the drive to be ready */
30671 -       for (j = 0; j < 200; j++) {
30672 -               u8 status = 0;
30673 -               mdelay(100);
30674 -               hwif->OUTB(drive->select.all, base + 0x60);
30675 -               if ((hwif->INB(base + 0x60)) != drive->select.all)
30676 -                       continue;
30677 -               status = hwif->INB(base + 0x70);
30678 -               if (!(status & BUSY_STAT))
30679 +       hwif->atapi_dma = 1;
30680 +       switch(pmif->kind) {
30681 +               case controller_un_ata6:
30682 +                       hwif->ultra_mask = pmif->cable_80 ? 0x3f : 0x07;
30683 +                       hwif->mwdma_mask = 0x07;
30684 +                       hwif->swdma_mask = 0x00;
30685                         break;
30686 -       }
30687 -
30688 -       /* We resume processing on the HW group */
30689 -       spin_lock_irqsave(&ide_lock, flags);
30690 -       HWGROUP(drive)->busy = 0;
30691 -       if (!list_empty(&drive->queue.queue_head))
30692 -               ide_do_request(HWGROUP(drive), 0);
30693 -       spin_unlock_irqrestore(&ide_lock, flags);
30694 +               case controller_kl_ata4:
30695 +                       hwif->ultra_mask = pmif->cable_80 ? 0x1f : 0x07;
30696 +                       hwif->mwdma_mask = 0x07;
30697 +                       hwif->swdma_mask = 0x00;
30698 +                       break;
30699 +               default:
30700 +                       hwif->ultra_mask = 0x00;
30701 +                       hwif->mwdma_mask = 0x07;
30702 +                       hwif->swdma_mask = 0x00;
30703 +                       break;
30704 +       }       
30705  }
30706  
30707 -/* Note: We support only master drives for now. This will have to be
30708 - * improved if we want to handle sleep on the iMacDV where the CD-ROM
30709 - * is a slave
30710 - */
30711 -static int __pmac
30712 -idepmac_notify_sleep(struct pmu_sleep_notifier *self, int when)
30713 -{
30714 -       int i, ret;
30715 -       unsigned long base;
30716 -       int big_delay;
30717
30718 -       switch (when) {
30719 -       case PBOOK_SLEEP_REQUEST:
30720 -               break;
30721 -       case PBOOK_SLEEP_REJECT:
30722 -               break;
30723 -       case PBOOK_SLEEP_NOW:
30724 -               for (i = 0; i < pmac_ide_count; ++i) {
30725 -                       ide_hwif_t *hwif;
30726 -                       int dn;
30727 -
30728 -                       if ((base = pmac_ide[i].regbase) == 0)
30729 -                               continue;
30730 -
30731 -                       hwif = &ide_hwifs[i];
30732 -                       for (dn=0; dn<MAX_DRIVES; dn++) {
30733 -                               if (!hwif->drives[dn].present)
30734 -                                       continue;
30735 -                               idepmac_sleep_drive(&hwif->drives[dn], base);
30736 -                       }
30737 -                       /* Disable irq during sleep */
30738 -                       disable_irq(pmac_ide[i].irq);
30739 -                       
30740 -                       /* Check if this is a media bay with an IDE device or not
30741 -                        * a media bay.
30742 -                        */
30743 -                       ret = check_media_bay_by_base(base, MB_CD);
30744 -                       if ((ret == 0) || (ret == -ENODEV))
30745 -                               idepmac_sleep_interface(&pmac_ide[i], base, (ret == 0));
30746 -               }
30747 -               break;
30748 -       case PBOOK_WAKE:
30749 -               big_delay = 0;
30750 -               for (i = 0; i < pmac_ide_count; ++i) {
30751 -
30752 -                       if ((base = pmac_ide[i].regbase) == 0)
30753 -                               continue;
30754 -                               
30755 -                       /* Make sure we have sane timings */            
30756 -                       sanitize_timings(&pmac_ide[i]);
30757 -
30758 -                       /* Check if this is a media bay with an IDE device or not
30759 -                        * a media bay
30760 -                        */
30761 -                       ret = check_media_bay_by_base(base, MB_CD);
30762 -                       if ((ret == 0) || (ret == -ENODEV)) {
30763 -                               idepmac_wake_interface(&pmac_ide[i], base, (ret == 0));                         
30764 -                               big_delay = 1;
30765 -                       }
30766 -
30767 -               }
30768 -               /* Let hardware get up to speed */
30769 -               if (big_delay)
30770 -                       mdelay(IDE_WAKEUP_DELAY_MS);
30771 -       
30772 -               for (i = 0; i < pmac_ide_count; ++i) {
30773 -                       ide_hwif_t *hwif;
30774 -                       int used_dma, dn;
30775 -                       int irq_on = 0;
30776 -                       
30777 -                       if ((base = pmac_ide[i].regbase) == 0)
30778 -                               continue;
30779 -                               
30780 -                       hwif = &ide_hwifs[i];
30781 -                       for (dn=0; dn<MAX_DRIVES; dn++) {
30782 -                               ide_drive_t *drive = &hwif->drives[dn];
30783 -                               if (!drive->present)
30784 -                                       continue;
30785 -                               /* We don't have re-configured DMA yet */
30786 -                               used_dma = drive->using_dma;
30787 -                               drive->using_dma = 0;
30788 -                               idepmac_wake_drive(drive, base);
30789 -                               if (!irq_on) {
30790 -                                       enable_irq(pmac_ide[i].irq);
30791 -                                       irq_on = 1;
30792 -                               }
30793 -                               idepmac_wake_device(drive, used_dma);
30794 -                       }
30795 -                       if (!irq_on)
30796 -                               enable_irq(pmac_ide[i].irq);
30797 -               }
30798 -               break;
30799 -       }
30800 -       return PBOOK_SLEEP_OK;
30801 -}
30802 -#endif /* CONFIG_PMAC_PBOOK */
30803 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
30804 diff -Nru a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
30805 --- a/drivers/ieee1394/csr.c    Wed Aug 20 14:21:56 2003
30806 +++ b/drivers/ieee1394/csr.c    Mon Sep  1 17:00:00 2003
30807 @@ -21,6 +21,7 @@
30808  #include <linux/module.h>
30809  #include <linux/moduleparam.h>
30810  #include <linux/param.h>
30811 +#include <linux/spinlock.h>
30812  
30813  #include "ieee1394_types.h"
30814  #include "hosts.h"
30815 diff -Nru a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
30816 --- a/drivers/ieee1394/eth1394.c        Tue Aug 19 20:56:01 2003
30817 +++ b/drivers/ieee1394/eth1394.c        Mon Sep  1 17:00:00 2003
30818 @@ -89,7 +89,7 @@
30819  #define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
30820  
30821  static char version[] __devinitdata =
30822 -       "$Rev: 1020 $ Ben Collins <bcollins@debian.org>";
30823 +       "$Rev: 1043 $ Ben Collins <bcollins@debian.org>";
30824  
30825  struct fragment_info {
30826         struct list_head list;
30827 @@ -1349,21 +1349,20 @@
30828                                                ptask->dest_node,
30829                                                ptask->addr, ptask->skb->data,
30830                                                tx_len)) {
30831 -               goto fail;
30832 +               free_hpsb_packet(packet);
30833 +               return -1;
30834         }
30835  
30836         ptask->packet = packet;
30837         hpsb_set_packet_complete_task(ptask->packet, ether1394_complete_cb,
30838                                       ptask);
30839  
30840 -       if (hpsb_send_packet(packet))
30841 -               return 0;
30842 -
30843 -fail:
30844 -       if (packet)
30845 +       if (!hpsb_send_packet(packet)) {
30846                 ether1394_free_packet(packet);
30847 +               return -1;
30848 +       }
30849  
30850 -       return -1;
30851 +       return 0;
30852  }
30853  
30854  
30855 @@ -1600,7 +1599,7 @@
30856                 case ETHTOOL_GDRVINFO: {
30857                         struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
30858                         strcpy (info.driver, driver_name);
30859 -                       strcpy (info.version, "$Rev: 1020 $");
30860 +                       strcpy (info.version, "$Rev: 1043 $");
30861                         /* FIXME XXX provide sane businfo */
30862                         strcpy (info.bus_info, "ieee1394");
30863                         if (copy_to_user (useraddr, &info, sizeof (info)))
30864 diff -Nru a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
30865 --- a/drivers/ieee1394/ieee1394_core.c  Sun Aug  3 17:00:00 2003
30866 +++ b/drivers/ieee1394/ieee1394_core.c  Mon Sep  1 17:00:00 2003
30867 @@ -1124,7 +1124,7 @@
30868            to get the index of the ieee1394_driver
30869            we want */
30870  
30871 -       blocknum = (minor(inode->i_rdev) >> 4) & 0xF;
30872 +       blocknum = (iminor(inode) >> 4) & 0xF;
30873  
30874         /* look up the driver */
30875  
30876 @@ -1237,6 +1237,7 @@
30877  EXPORT_SYMBOL(hpsb_free_tlabel);
30878  EXPORT_SYMBOL(hpsb_make_readpacket);
30879  EXPORT_SYMBOL(hpsb_make_writepacket);
30880 +EXPORT_SYMBOL(hpsb_make_streampacket);
30881  EXPORT_SYMBOL(hpsb_make_lockpacket);
30882  EXPORT_SYMBOL(hpsb_make_lock64packet);
30883  EXPORT_SYMBOL(hpsb_make_phypacket);
30884 diff -Nru a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h
30885 --- a/drivers/ieee1394/ieee1394_core.h  Thu Jul 24 17:00:00 2003
30886 +++ b/drivers/ieee1394/ieee1394_core.h  Tue Aug 26 09:25:41 2003
30887 @@ -202,7 +202,7 @@
30888  /* return the index (within a minor number block) of a file */
30889  static inline unsigned char ieee1394_file_to_instance(struct file *file)
30890  {
30891 -       unsigned char minor = minor(file->f_dentry->d_inode->i_rdev);
30892 +       unsigned char minor = iminor(file->f_dentry->d_inode);
30893         
30894         /* return lower 4 bits */
30895         return minor & 0xF;
30896 diff -Nru a/drivers/ieee1394/ieee1394_transactions.c b/drivers/ieee1394/ieee1394_transactions.c
30897 --- a/drivers/ieee1394/ieee1394_transactions.c  Tue Aug  5 10:11:00 2003
30898 +++ b/drivers/ieee1394/ieee1394_transactions.c  Mon Sep  1 17:00:00 2003
30899 @@ -104,7 +104,7 @@
30900                                      int channel, int tag, int sync)
30901  {
30902         packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
30903 -               | (TCODE_STREAM_DATA << 4) | sync;
30904 +                         | (TCODE_STREAM_DATA << 4) | sync;
30905  
30906         packet->header_size = 4;
30907         packet->data_size = length;
30908 @@ -317,6 +317,35 @@
30909         return packet;
30910  }
30911  
30912 +struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, int length,
30913 +                                           int channel, int tag, int sync)
30914 +{
30915 +       struct hpsb_packet *packet;
30916 +
30917 +       if (length == 0)
30918 +               return NULL;
30919 +
30920 +       packet = alloc_hpsb_packet(length + (length % 4 ? 4 - (length % 4) : 0));
30921 +       if (!packet)
30922 +               return NULL;
30923 +
30924 +       if (length % 4) { /* zero padding bytes */
30925 +               packet->data[length >> 2] = 0;
30926 +       }
30927 +       packet->host = host;
30928 +    
30929 +       if (hpsb_get_tlabel(packet)) {
30930 +               free_hpsb_packet(packet);
30931 +               return NULL;
30932 +       }
30933 +
30934 +       fill_async_stream_packet(packet, length, channel, tag, sync);
30935 +       if (buffer)
30936 +               memcpy(packet->data, buffer, length);
30937 +
30938 +       return packet;
30939 +}
30940 +
30941  struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
30942                                           u64 addr, int extcode, quadlet_t *data,
30943                                          quadlet_t arg)
30944 @@ -580,25 +609,18 @@
30945         u16 specifier_id_hi = (specifier_id & 0x00ffff00) >> 8;
30946         u8 specifier_id_lo = specifier_id & 0xff;
30947  
30948 -       HPSB_VERBOSE("Send GASP: channel = %d, length = %d", channel, length);
30949 +       HPSB_VERBOSE("Send GASP: channel = %d, length = %Zd", channel, length);
30950  
30951         length += 8;
30952 -
30953 -       packet = alloc_hpsb_packet(length + (length % 4 ? 4 - (length % 4) : 0));
30954 +    
30955 +       packet = hpsb_make_streampacket(host, NULL, length, channel, 3, 0);
30956         if (!packet)
30957                 return -ENOMEM;
30958  
30959 -       if (length % 4) {
30960 -               packet->data[length / 4] = 0;
30961 -       }
30962 -
30963 -       packet->host = host;
30964 -       fill_async_stream_packet(packet, length, channel, 3, 0);
30965 -        
30966         packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi);
30967         packet->data[1] = cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff));
30968  
30969 -       memcpy(&(packet->data[2]), buffer, length - 4);
30970 +       memcpy(&(packet->data[2]), buffer, length - 8);
30971  
30972         packet->generation = generation;
30973  
30974 diff -Nru a/drivers/ieee1394/ieee1394_transactions.h b/drivers/ieee1394/ieee1394_transactions.h
30975 --- a/drivers/ieee1394/ieee1394_transactions.h  Sun Aug  3 17:00:00 2003
30976 +++ b/drivers/ieee1394/ieee1394_transactions.h  Mon Sep  1 17:00:00 2003
30977 @@ -25,6 +25,8 @@
30978                                         int tag, int sync);
30979  struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node,
30980                                            u64 addr, quadlet_t *buffer, size_t length);
30981 +struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer,
30982 +                                           int length, int channel, int tag, int sync);
30983  
30984  /*
30985   * hpsb_packet_success - Make sense of the ack and reply codes and
30986 diff -Nru a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
30987 --- a/drivers/ieee1394/nodemgr.c        Sat Aug 16 05:08:09 2003
30988 +++ b/drivers/ieee1394/nodemgr.c        Mon Sep  1 17:00:00 2003
30989 @@ -1304,12 +1304,14 @@
30990                  * unregister all the unit directories. */
30991                 nodemgr_remove_node_uds(ne);
30992  
30993 +               /* With all the ud's gone, mark the generation current,
30994 +                * this way the probe will succeed. */
30995 +               ne->generation = generation;
30996 +
30997                 /* This will re-register our unitdir's */
30998                 nodemgr_process_config_rom (hi, ne, busoptions);
30999 -       }
31000 -
31001 -       /* Since that's done, we can declare this record current */
31002 -       ne->generation = generation;
31003 +       } else
31004 +               ne->generation = generation;
31005  
31006         /* Update unit_dirs with attached drivers */
31007         bus_for_each_dev(&ieee1394_bus_type, NULL, ne,
31008 diff -Nru a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
31009 --- a/drivers/ieee1394/ohci1394.c       Sun Aug  3 17:00:00 2003
31010 +++ b/drivers/ieee1394/ohci1394.c       Mon Sep  1 17:00:00 2003
31011 @@ -161,7 +161,7 @@
31012  printk(level "%s_%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
31013  
31014  static char version[] __devinitdata =
31015 -       "$Rev: 1023 $ Ben Collins <bcollins@debian.org>";
31016 +       "$Rev: 1045 $ Ben Collins <bcollins@debian.org>";
31017  
31018  /* Module Parameters */
31019  static int phys_dma = 1;
31020 @@ -1451,7 +1451,7 @@
31021         if (sync != -1) {
31022                 /* set sync flag on first DMA descriptor */
31023                 struct dma_cmd *cmd = &recv->block[recv->block_dma];
31024 -               cmd->control |= DMA_CTL_WAIT;
31025 +               cmd->control |= cpu_to_le32(DMA_CTL_WAIT);
31026  
31027                 /* match sync field */
31028                 contextMatch |= (sync&0xf)<<8;
31029 @@ -1675,10 +1675,10 @@
31030                 struct dma_cmd *im = &recv->block[recv->block_dma];
31031                 
31032                 /* check the DMA descriptor for new writes to xferStatus */
31033 -               u16 xferstatus = im->status >> 16;
31034 +               u16 xferstatus = le32_to_cpu(im->status) >> 16;
31035                 
31036                 /* rescount is the number of bytes *remaining to be written* in the block */
31037 -               u16 rescount = im->status & 0xFFFF;
31038 +               u16 rescount = le32_to_cpu(im->status) & 0xFFFF;
31039  
31040                 unsigned char event = xferstatus & 0x1F;
31041  
31042 diff -Nru a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
31043 --- a/drivers/ieee1394/pcilynx.c        Sat Aug 16 05:08:53 2003
31044 +++ b/drivers/ieee1394/pcilynx.c        Tue Aug 26 09:25:41 2003
31045 @@ -875,7 +875,7 @@
31046  
31047  static int mem_open(struct inode *inode, struct file *file)
31048  {
31049 -        int cid = minor(inode->i_rdev);
31050 +        int cid = iminor(inode);
31051          enum { t_rom, t_aux, t_ram } type;
31052          struct memdata *md;
31053          
31054 diff -Nru a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
31055 --- a/drivers/ieee1394/raw1394.c        Sun Aug  3 17:00:00 2003
31056 +++ b/drivers/ieee1394/raw1394.c        Tue Sep  2 06:26:59 2003
31057 @@ -38,6 +38,7 @@
31058  #include <linux/version.h>
31059  #include <linux/smp_lock.h>
31060  #include <linux/interrupt.h>
31061 +#include <linux/vmalloc.h>
31062  #include <asm/uaccess.h>
31063  #include <asm/atomic.h>
31064  #include <linux/devfs_fs_kernel.h>
31065 @@ -180,6 +181,7 @@
31066  
31067          if ((req->req.type == RAW1394_REQ_ASYNC_READ) ||
31068             (req->req.type == RAW1394_REQ_ASYNC_WRITE) ||
31069 +           (req->req.type == RAW1394_REQ_ASYNC_STREAM) ||
31070             (req->req.type == RAW1394_REQ_LOCK) ||
31071             (req->req.type == RAW1394_REQ_LOCK64))
31072                  hpsb_free_tlabel(packet);
31073 @@ -689,6 +691,21 @@
31074                 req->req.length = 0;
31075             break;
31076  
31077 +       case RAW1394_REQ_ASYNC_STREAM:
31078 +               DBGMSG("stream_request called");
31079 +
31080 +               packet = hpsb_make_streampacket(fi->host, NULL, req->req.length, node & 0x3f/*channel*/,
31081 +                                        (req->req.misc >> 16) & 0x3, req->req.misc & 0xf);
31082 +               if (!packet)
31083 +                       return -ENOMEM;
31084 +
31085 +               if (copy_from_user(packet->data, int2ptr(req->req.sendb),
31086 +                                  req->req.length))
31087 +                       req->req.error = RAW1394_ERROR_MEMFAULT;
31088 +                       
31089 +               req->req.length = 0;
31090 +               break;
31091 +
31092          case RAW1394_REQ_LOCK:
31093                  DBGMSG("lock_request called");
31094                  if ((req->req.misc == EXTCODE_FETCH_ADD)
31095 @@ -892,7 +909,7 @@
31096          struct arm_request_response *arm_req_resp = NULL;
31097  
31098          DBGMSG("arm_read  called by node: %X"
31099 -              "addr: %4.4x %8.8x length: %u", nodeid,
31100 +              "addr: %4.4x %8.8x length: %Zu", nodeid,
31101                (u16) ((addr >>32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
31102                length);
31103          spin_lock(&host_info_lock);
31104 @@ -1028,7 +1045,7 @@
31105          struct arm_request_response *arm_req_resp = NULL;
31106  
31107          DBGMSG("arm_write called by node: %X"
31108 -              "addr: %4.4x %8.8x length: %u", nodeid,
31109 +              "addr: %4.4x %8.8x length: %Zu", nodeid,
31110                (u16) ((addr >>32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
31111                length);
31112          spin_lock(&host_info_lock);
31113 @@ -1566,8 +1583,8 @@
31114                req->req.length, ((req->req.misc >> 8) & 0xFF),
31115                (req->req.misc & 0xFF),((req->req.misc >> 16) & 0xFFFF));
31116          /* check addressrange */
31117 -        if ((((req->req.address) & ~((u64)0xFFFFFFFFFFFFLL)) != 0) ||
31118 -                (((req->req.address + req->req.length) & ~((u64)0xFFFFFFFFFFFFLL)) != 0)) {
31119 +        if ((((req->req.address) & ~(0xFFFFFFFFFFFFULL)) != 0) ||
31120 +                (((req->req.address + req->req.length) & ~(0xFFFFFFFFFFFFULL)) != 0)) {
31121                  req->req.length = 0;
31122                  return (-EINVAL);
31123          }
31124 @@ -1578,7 +1595,7 @@
31125                  return (-ENOMEM);
31126          } 
31127          /* allocation of addr_space_buffer */
31128 -        addr->addr_space_buffer = (u8 *)kmalloc(req->req.length,SLAB_KERNEL);
31129 +        addr->addr_space_buffer = (u8 *)vmalloc(req->req.length);
31130          if (!(addr->addr_space_buffer)) {
31131                  kfree(addr);
31132                  req->req.length = 0;
31133 @@ -1592,7 +1609,7 @@
31134                  /* init: user -> kernel */
31135                  if (copy_from_user(addr->addr_space_buffer,int2ptr(req->req.sendb),
31136                          req->req.length)) {
31137 -                        kfree(addr->addr_space_buffer);
31138 +                        vfree(addr->addr_space_buffer);
31139                          kfree(addr);
31140                          return (-EFAULT);
31141                  }
31142 @@ -1633,7 +1650,7 @@
31143          }
31144          if (same_host) {
31145                  /* addressrange occupied by same host */
31146 -                kfree(addr->addr_space_buffer);
31147 +                vfree(addr->addr_space_buffer);
31148                  kfree(addr);
31149                  spin_unlock_irqrestore(&host_info_lock, flags);
31150                  return (-EALREADY);
31151 @@ -1668,7 +1685,7 @@
31152                          int2ptr(&addr->start),sizeof(u64))) {
31153                          printk(KERN_ERR "raw1394: arm_register failed "
31154                                " address-range-entry is invalid -> EFAULT !!!\n");
31155 -                        kfree(addr->addr_space_buffer);
31156 +                        vfree(addr->addr_space_buffer);
31157                          kfree(addr);
31158                          spin_unlock_irqrestore(&host_info_lock, flags);
31159                          return (-EFAULT);
31160 @@ -1686,7 +1703,7 @@
31161                 list_add_tail(&addr->addr_list, &fi->addr_list);
31162          } else {
31163                  DBGMSG("arm_register failed errno: %d \n",retval);
31164 -                kfree(addr->addr_space_buffer);
31165 +                vfree(addr->addr_space_buffer);
31166                  kfree(addr);
31167                  spin_unlock_irqrestore(&host_info_lock, flags);
31168                  return (-EALREADY); 
31169 @@ -1760,7 +1777,7 @@
31170          if (another_host) {
31171                  DBGMSG("delete entry from list -> success");
31172                  list_del(&addr->addr_list);
31173 -                kfree(addr->addr_space_buffer);
31174 +                vfree(addr->addr_space_buffer);
31175                  kfree(addr);
31176                  free_pending_request(req); /* immediate success or fail */
31177                  spin_unlock_irqrestore(&host_info_lock, flags);
31178 @@ -1775,7 +1792,7 @@
31179          DBGMSG("delete entry from list -> success");
31180          list_del(&addr->addr_list);
31181          spin_unlock_irqrestore(&host_info_lock, flags);
31182 -        kfree(addr->addr_space_buffer);
31183 +        vfree(addr->addr_space_buffer);
31184          kfree(addr);
31185          free_pending_request(req); /* immediate success or fail */
31186          return sizeof(struct raw1394_request);
31187 @@ -2440,7 +2457,7 @@
31188                  }
31189                  DBGMSG("raw1394_release: delete addr_entry from list");
31190                  list_del(&addr->addr_list);
31191 -                kfree(addr->addr_space_buffer);
31192 +                vfree(addr->addr_space_buffer);
31193                  kfree(addr);
31194          } /* while */
31195          spin_unlock_irq(&host_info_lock);
31196 diff -Nru a/drivers/ieee1394/raw1394.h b/drivers/ieee1394/raw1394.h
31197 --- a/drivers/ieee1394/raw1394.h        Wed Feb 12 20:57:18 2003
31198 +++ b/drivers/ieee1394/raw1394.h        Mon Sep  1 17:00:00 2003
31199 @@ -19,6 +19,7 @@
31200  #define RAW1394_REQ_LOCK64          103
31201  #define RAW1394_REQ_ISO_SEND        104
31202  #define RAW1394_REQ_ASYNC_SEND      105
31203 +#define RAW1394_REQ_ASYNC_STREAM    106
31204  
31205  #define RAW1394_REQ_ISO_LISTEN      200
31206  #define RAW1394_REQ_FCP_LISTEN      201
31207 diff -Nru a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
31208 --- a/drivers/ieee1394/sbp2.c   Sun Aug 10 22:11:01 2003
31209 +++ b/drivers/ieee1394/sbp2.c   Mon Sep  1 17:00:00 2003
31210 @@ -80,7 +80,7 @@
31211  #include "sbp2.h"
31212  
31213  static char version[] __devinitdata =
31214 -       "$Rev: 1018 $ Ben Collins <bcollins@debian.org>";
31215 +       "$Rev: 1034 $ Ben Collins <bcollins@debian.org>";
31216  
31217  /*
31218   * Module load parameter definitions
31219 @@ -1002,9 +1002,8 @@
31220         sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
31221  
31222         /* Remove it from the scsi layer now */
31223 -       if (sdev) {
31224 +       if (sdev)
31225                 scsi_remove_device(sdev);
31226 -       }
31227  
31228         sbp2util_remove_command_orb_pool(scsi_id);
31229  
31230 diff -Nru a/drivers/input/evdev.c b/drivers/input/evdev.c
31231 --- a/drivers/input/evdev.c     Tue Aug 12 16:21:11 2003
31232 +++ b/drivers/input/evdev.c     Sun Aug 31 16:14:28 2003
31233 @@ -122,7 +122,7 @@
31234  static int evdev_open(struct inode * inode, struct file * file)
31235  {
31236         struct evdev_list *list;
31237 -       int i = minor(inode->i_rdev) - EVDEV_MINOR_BASE;
31238 +       int i = iminor(inode) - EVDEV_MINOR_BASE;
31239         int accept_err;
31240  
31241         if (i >= EVDEV_MINORS || !evdev_table[i])
31242 @@ -305,6 +305,7 @@
31243                                         case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
31244                                         case EV_REL: bits = dev->relbit; len = REL_MAX; break;
31245                                         case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
31246 +                                       case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
31247                                         case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
31248                                         case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
31249                                         case EV_FF:  bits = dev->ffbit;  len = FF_MAX;  break;
31250 diff -Nru a/drivers/input/input.c b/drivers/input/input.c
31251 --- a/drivers/input/input.c     Tue Aug 12 13:29:25 2003
31252 +++ b/drivers/input/input.c     Tue Aug 26 09:25:41 2003
31253 @@ -280,7 +280,7 @@
31254                         if (id->id.product != dev->id.product)
31255                                 continue;
31256                 
31257 -               if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
31258 +               if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
31259                         if (id->id.version != dev->id.version)
31260                                 continue;
31261  
31262 @@ -527,7 +527,7 @@
31263  
31264  static int input_open_file(struct inode *inode, struct file *file)
31265  {
31266 -       struct input_handler *handler = input_table[minor(inode->i_rdev) >> 5];
31267 +       struct input_handler *handler = input_table[iminor(inode) >> 5];
31268         struct file_operations *old_fops, *new_fops = NULL;
31269         int err;
31270  
31271 diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
31272 --- a/drivers/input/joydev.c    Fri May  2 06:55:04 2003
31273 +++ b/drivers/input/joydev.c    Tue Aug 26 09:25:41 2003
31274 @@ -170,7 +170,7 @@
31275  static int joydev_open(struct inode *inode, struct file *file)
31276  {
31277         struct joydev_list *list;
31278 -       int i = minor(inode->i_rdev) - JOYDEV_MINOR_BASE;
31279 +       int i = iminor(inode) - JOYDEV_MINOR_BASE;
31280  
31281         if (i >= JOYDEV_MINORS || !joydev_table[i])
31282                 return -ENODEV;
31283 diff -Nru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
31284 --- a/drivers/input/mousedev.c  Fri May  2 06:55:04 2003
31285 +++ b/drivers/input/mousedev.c  Tue Aug 26 09:25:41 2003
31286 @@ -228,11 +228,11 @@
31287         int i;
31288  
31289  #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
31290 -       if (major(inode->i_rdev) == MISC_MAJOR)
31291 +       if (imajor(inode) == MISC_MAJOR)
31292                 i = MOUSEDEV_MIX;
31293         else
31294  #endif
31295 -               i = minor(inode->i_rdev) - MOUSEDEV_MINOR_BASE;
31296 +               i = iminor(inode) - MOUSEDEV_MINOR_BASE;
31297  
31298         if (i >= MOUSEDEV_MINORS || !mousedev_table[i])
31299                 return -ENODEV;
31300 diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
31301 --- a/drivers/input/serio/i8042.c       Wed Jul 23 07:37:45 2003
31302 +++ b/drivers/input/serio/i8042.c       Wed Sep  3 23:40:20 2003
31303 @@ -410,6 +410,7 @@
31304                         /* work around hardware that doubles key releases */
31305                         if (index == i8042_last_release) {
31306                                 dbg("i8042 skipped double release (%d)\n", index);
31307 +                               i8042_last_e0 = 0;
31308                                 continue;
31309                         }
31310                         if (index == 0xaa || index == 0xb6)
31311 @@ -581,6 +582,7 @@
31312  static int __init i8042_check_mux(struct i8042_values *values)
31313  {
31314         unsigned char param;
31315 +       static int i8042_check_mux_cookie;
31316         int i;
31317  
31318  /*
31319 @@ -588,9 +590,9 @@
31320   */
31321  
31322         if (request_irq(values->irq, i8042_interrupt, SA_SHIRQ,
31323 -                               "i8042", i8042_request_irq_cookie))
31324 +                               "i8042", &i8042_check_mux_cookie))
31325                  return -1;
31326 -       free_irq(values->irq, i8042_request_irq_cookie);
31327 +       free_irq(values->irq, &i8042_check_mux_cookie);
31328  
31329  /*
31330   * Get rid of bytes in the queue.
31331 @@ -653,6 +655,7 @@
31332  static int __init i8042_check_aux(struct i8042_values *values)
31333  {
31334         unsigned char param;
31335 +       static int i8042_check_aux_cookie;
31336  
31337  /*
31338   * Check if AUX irq is available. If it isn't, then there is no point
31339 @@ -660,9 +663,9 @@
31340   */
31341  
31342         if (request_irq(values->irq, i8042_interrupt, SA_SHIRQ,
31343 -                               "i8042", i8042_request_irq_cookie))
31344 +                               "i8042", &i8042_check_aux_cookie))
31345                  return -1;
31346 -       free_irq(values->irq, i8042_request_irq_cookie);
31347 +       free_irq(values->irq, &i8042_check_aux_cookie);
31348  
31349  /*
31350   * Get rid of bytes in the queue.
31351 diff -Nru a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c
31352 --- a/drivers/input/serio/sa1111ps2.c   Sat May 17 07:47:27 2003
31353 +++ b/drivers/input/serio/sa1111ps2.c   Sun Aug 24 07:45:05 2003
31354 @@ -62,9 +62,9 @@
31355  
31356                 serio_interrupt(&ps2if->io, scancode, flag, regs);
31357  
31358 -                       status = sa1111_readl(ps2if->base + SA1111_PS2STAT);
31359 +               status = sa1111_readl(ps2if->base + SA1111_PS2STAT);
31360  
31361 -                       handled = IRQ_HANDLED;
31362 +               handled = IRQ_HANDLED;
31363          }
31364  
31365          return handled;
31366 @@ -232,9 +232,8 @@
31367  /*
31368   * Add one device to this driver.
31369   */
31370 -static int ps2_probe(struct device *dev)
31371 +static int ps2_probe(struct sa1111_dev *dev)
31372  {
31373 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
31374         struct ps2if *ps2if;
31375         int ret;
31376  
31377 @@ -249,20 +248,20 @@
31378         ps2if->io.write         = ps2_write;
31379         ps2if->io.open          = ps2_open;
31380         ps2if->io.close         = ps2_close;
31381 -       ps2if->io.name          = dev->name;
31382 -       ps2if->io.phys          = dev->bus_id;
31383 +       ps2if->io.name          = dev->dev.bus_id;
31384 +       ps2if->io.phys          = dev->dev.bus_id;
31385         ps2if->io.driver        = ps2if;
31386 -       ps2if->dev              = sadev;
31387 -       dev->driver_data        = ps2if;
31388 +       ps2if->dev              = dev;
31389 +       sa1111_set_drvdata(dev, ps2if);
31390  
31391         spin_lock_init(&ps2if->lock);
31392  
31393         /*
31394          * Request the physical region for this PS2 port.
31395          */
31396 -       if (!request_mem_region(sadev->res.start,
31397 -                               sadev->res.end - sadev->res.start + 1,
31398 -                               SA1111_DRIVER_NAME(sadev))) {
31399 +       if (!request_mem_region(dev->res.start,
31400 +                               dev->res.end - dev->res.start + 1,
31401 +                               SA1111_DRIVER_NAME(dev))) {
31402                 ret = -EBUSY;
31403                 goto free;
31404         }
31405 @@ -270,7 +269,7 @@
31406         /*
31407          * Our parent device has already mapped the region.
31408          */
31409 -       ps2if->base = (unsigned long)sadev->mapbase;
31410 +       ps2if->base = (unsigned long)dev->mapbase;
31411  
31412         sa1111_enable_device(ps2if->dev);
31413  
31414 @@ -301,10 +300,10 @@
31415  
31416   out:
31417         sa1111_disable_device(ps2if->dev);
31418 -       release_mem_region(sadev->res.start,
31419 -                          sadev->res.end - sadev->res.start + 1);
31420 +       release_mem_region(dev->res.start,
31421 +                          dev->res.end - dev->res.start + 1);
31422   free:
31423 -       dev->driver_data = NULL;
31424 +       sa1111_set_drvdata(dev, NULL);
31425         kfree(ps2if);
31426         return ret;
31427  }
31428 @@ -312,31 +311,17 @@
31429  /*
31430   * Remove one device from this driver.
31431   */
31432 -static int ps2_remove(struct device *dev)
31433 +static int ps2_remove(struct sa1111_dev *dev)
31434  {
31435 -       struct ps2if *ps2if = dev->driver_data;
31436 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
31437 +       struct ps2if *ps2if = sa1111_get_drvdata(dev);
31438  
31439         serio_unregister_port(&ps2if->io);
31440 -       release_mem_region(sadev->res.start,
31441 -                          sadev->res.end - sadev->res.start + 1);
31442 -       kfree(ps2if);
31443 -
31444 -       dev->driver_data = NULL;
31445 -
31446 -       return 0;
31447 -}
31448 +       release_mem_region(dev->res.start,
31449 +                          dev->res.end - dev->res.start + 1);
31450 +       sa1111_set_drvdata(dev, NULL);
31451  
31452 -/*
31453 - * We should probably do something here, but what?
31454 - */
31455 -static int ps2_suspend(struct device *dev, u32 state, u32 level)
31456 -{
31457 -       return 0;
31458 -}
31459 +       kfree(ps2if);
31460  
31461 -static int ps2_resume(struct device *dev, u32 level)
31462 -{
31463         return 0;
31464  }
31465  
31466 @@ -345,24 +330,21 @@
31467   */
31468  static struct sa1111_driver ps2_driver = {
31469         .drv = {
31470 -               .name           = "sa1111-ps2",
31471 -               .bus            = &sa1111_bus_type,
31472 -               .probe          = ps2_probe,
31473 -               .remove         = ps2_remove,
31474 -               .suspend        = ps2_suspend,
31475 -               .resume         = ps2_resume,
31476 +               .name   = "sa1111-ps2",
31477         },
31478 -       .devid                  = SA1111_DEVID_PS2,
31479 +       .devid          = SA1111_DEVID_PS2,
31480 +       .probe          = ps2_probe,
31481 +       .remove         = ps2_remove,
31482  };
31483  
31484  static int __init ps2_init(void)
31485  {
31486 -       return driver_register(&ps2_driver.drv);
31487 +       return sa1111_driver_register(&ps2_driver);
31488  }
31489  
31490  static void __exit ps2_exit(void)
31491  {
31492 -       driver_unregister(&ps2_driver.drv);
31493 +       sa1111_driver_unregister(&ps2_driver);
31494  }
31495  
31496  module_init(ps2_init);
31497 diff -Nru a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
31498 --- a/drivers/input/serio/serport.c     Sun May  4 09:36:03 2003
31499 +++ b/drivers/input/serio/serport.c     Wed Sep  3 23:40:16 2003
31500 @@ -24,6 +24,7 @@
31501  MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
31502  MODULE_DESCRIPTION("Input device TTY line discipline");
31503  MODULE_LICENSE("GPL");
31504 +MODULE_ALIAS_LDISC(N_MOUSE);
31505  
31506  #define SERPORT_BUSY   1
31507  
31508 diff -Nru a/drivers/input/tsdev.c b/drivers/input/tsdev.c
31509 --- a/drivers/input/tsdev.c     Fri May  2 06:55:04 2003
31510 +++ b/drivers/input/tsdev.c     Tue Aug 26 09:25:41 2003
31511 @@ -96,7 +96,7 @@
31512  
31513  static int tsdev_open(struct inode *inode, struct file *file)
31514  {
31515 -       int i = minor(inode->i_rdev) - TSDEV_MINOR_BASE;
31516 +       int i = iminor(inode) - TSDEV_MINOR_BASE;
31517         struct tsdev_list *list;
31518  
31519         if (i >= TSDEV_MINORS || !tsdev_table[i])
31520 diff -Nru a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig
31521 --- a/drivers/isdn/Kconfig      Tue Nov 12 12:48:13 2002
31522 +++ b/drivers/isdn/Kconfig      Mon Aug 25 05:49:31 2003
31523 @@ -22,7 +22,7 @@
31524  
31525  
31526  menu "Old ISDN4Linux"
31527 -       depends on NET && ISDN_BOOL
31528 +       depends on NET && ISDN_BOOL && BROKEN_ON_SMP
31529  
31530  config ISDN
31531         tristate "Old ISDN4Linux (obsolete)"
31532 diff -Nru a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
31533 --- a/drivers/isdn/capi/capi.c  Wed Jun 11 12:32:56 2003
31534 +++ b/drivers/isdn/capi/capi.c  Wed Sep  3 03:09:05 2003
31535 @@ -412,7 +412,7 @@
31536  static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)
31537  {
31538         struct sk_buff *nskb;
31539 -       unsigned int datalen;
31540 +       int datalen;
31541         u16 errcode, datahandle;
31542  
31543         datalen = skb->len - CAPIMSG_LEN(skb->data);
31544 @@ -552,12 +552,12 @@
31545         struct capincci *np;
31546         u32 ncci;
31547  
31548 -       if (CAPIMSG_COMMAND(skb->data) == CAPI_CONNECT_B3_CONF) {
31549 +       if (CAPIMSG_CMD(skb->data) == CAPI_CONNECT_B3_CONF) {
31550                 u16 info = CAPIMSG_U16(skb->data, 12); // Info field
31551                 if (info == 0)
31552                         capincci_alloc(cdev, CAPIMSG_NCCI(skb->data));
31553         }
31554 -       if (CAPIMSG_COMMAND(skb->data) == CAPI_CONNECT_B3_IND) {
31555 +       if (CAPIMSG_CMD(skb->data) == CAPI_CONNECT_B3_IND) {
31556                 capincci_alloc(cdev, CAPIMSG_NCCI(skb->data));
31557         }
31558         if (CAPIMSG_COMMAND(skb->data) != CAPI_DATA_B3) {
31559 @@ -688,7 +688,7 @@
31560         }
31561         mlen = CAPIMSG_LEN(skb->data);
31562         if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) {
31563 -               if (mlen + CAPIMSG_DATALEN(skb->data) != count) {
31564 +               if ((size_t)(mlen + CAPIMSG_DATALEN(skb->data)) != count) {
31565                         kfree_skb(skb);
31566                         return -EINVAL;
31567                 }
31568 @@ -700,7 +700,7 @@
31569         }
31570         CAPIMSG_SETAPPID(skb->data, cdev->ap.applid);
31571  
31572 -       if (CAPIMSG_COMMAND(skb->data) == CAPI_DISCONNECT_B3_RESP) {
31573 +       if (CAPIMSG_CMD(skb->data) == CAPI_DISCONNECT_B3_RESP) {
31574                 capincci_free(cdev, CAPIMSG_NCCI(skb->data));
31575                         
31576         }
31577 @@ -964,7 +964,7 @@
31578  {
31579         struct capiminor *mp;
31580  
31581 -       if ((mp = capiminor_find(minor(file->f_dentry->d_inode->i_rdev))) == 0)
31582 +       if ((mp = capiminor_find(iminor(file->f_dentry->d_inode))) == 0)
31583                 return -ENXIO;
31584         if (mp->nccip == 0)
31585                 return -ENXIO;
31586 diff -Nru a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
31587 --- a/drivers/isdn/capi/capidrv.c       Tue Jul 15 10:01:29 2003
31588 +++ b/drivers/isdn/capi/capidrv.c       Wed Sep  3 03:09:05 2003
31589 @@ -48,7 +48,7 @@
31590  struct capidrv_contr {
31591  
31592         struct capidrv_contr *next;
31593 -
31594 +       struct module *owner;
31595         u32 contrnr;
31596         char name[20];
31597  
31598 @@ -1816,7 +1816,7 @@
31599         capidrv_bchan *bchan;
31600         capidrv_ncci *nccip;
31601         int len = skb->len;
31602 -       size_t msglen;
31603 +       int msglen;
31604         u16 errcode;
31605         u16 datahandle;
31606  
31607 @@ -1844,7 +1844,7 @@
31608                               0 /* Flags */
31609             );
31610  
31611 -       if (capidrv_add_ack(nccip, datahandle, doack ? skb->len : -1) < 0)
31612 +       if (capidrv_add_ack(nccip, datahandle, doack ? (int)skb->len : -1) < 0)
31613            return 0;
31614  
31615         capi_cmsg2message(&sendcmsg, sendcmsg.buf);
31616 @@ -1990,16 +1990,19 @@
31617         char id[20];
31618         int i;
31619  
31620 -       MOD_INC_USE_COUNT;
31621 -
31622         sprintf(id, "capidrv-%d", contr);
31623         if (!(card = (capidrv_contr *) kmalloc(sizeof(capidrv_contr), GFP_ATOMIC))) {
31624                 printk(KERN_WARNING
31625                  "capidrv: (%s) Could not allocate contr-struct.\n", id);
31626 -               MOD_DEC_USE_COUNT;
31627                 return -1;
31628         }
31629         memset(card, 0, sizeof(capidrv_contr));
31630 +       card->owner = THIS_MODULE;
31631 +       if (!try_module_get(card->owner)) {
31632 +               printk(KERN_WARNING "capidrv: (%s) Could not reserve module\n", id);
31633 +               kfree(card);
31634 +               return -1;
31635 +       }
31636         init_timer(&card->listentimer);
31637         strcpy(card->name, id);
31638         card->contrnr = contr;
31639 @@ -2008,8 +2011,8 @@
31640         if (!card->bchans) {
31641                 printk(KERN_WARNING
31642                 "capidrv: (%s) Could not allocate bchan-structs.\n", id);
31643 +               module_put(card->owner);
31644                 kfree(card);
31645 -               MOD_DEC_USE_COUNT;
31646                 return -1;
31647         }
31648         card->interface.channels = profp->nbchannel;
31649 @@ -2042,8 +2045,8 @@
31650         if (!register_isdn(&card->interface)) {
31651                 printk(KERN_ERR "capidrv: Unable to register contr %s\n", id);
31652                 kfree(card->bchans);
31653 +               module_put(card->owner);
31654                 kfree(card);
31655 -               MOD_DEC_USE_COUNT;
31656                 return -1;
31657         }
31658         card->myid = card->interface.channels;
31659 @@ -2153,12 +2156,9 @@
31660         }
31661         spin_unlock_irqrestore(&global_lock, flags);
31662  
31663 +       module_put(card->owner);
31664         printk(KERN_INFO "%s: now down.\n", card->name);
31665 -
31666         kfree(card);
31667 -
31668 -       MOD_DEC_USE_COUNT;
31669 -
31670         return 0;
31671  }
31672  
31673 @@ -2245,8 +2245,6 @@
31674         u32 ncontr, contr;
31675         u16 errcode;
31676  
31677 -       MOD_INC_USE_COUNT;
31678 -
31679         if ((p = strchr(revision, ':')) != 0 && p[1]) {
31680                 strncpy(rev, p + 2, sizeof(rev));
31681                 rev[sizeof(rev)-1] = 0;
31682 @@ -2262,7 +2260,6 @@
31683         global.ap.recv_message = capidrv_recv_message;
31684         errcode = capi20_register(&global.ap);
31685         if (errcode) {
31686 -               MOD_DEC_USE_COUNT;
31687                 return -EIO;
31688         }
31689  
31690 @@ -2271,7 +2268,6 @@
31691         errcode = capi20_get_profile(0, &profile);
31692         if (errcode != CAPI_NOERROR) {
31693                 capi20_release(&global.ap);
31694 -               MOD_DEC_USE_COUNT;
31695                 return -EIO;
31696         }
31697  
31698 @@ -2285,8 +2281,6 @@
31699         proc_init();
31700  
31701         printk(KERN_NOTICE "capidrv: Rev %s: loaded\n", rev);
31702 -       MOD_DEC_USE_COUNT;
31703 -
31704         return 0;
31705  }
31706  
31707 diff -Nru a/drivers/isdn/capi/capilib.c b/drivers/isdn/capi/capilib.c
31708 --- a/drivers/isdn/capi/capilib.c       Thu Aug 15 15:06:55 2002
31709 +++ b/drivers/isdn/capi/capilib.c       Wed Sep  3 03:09:05 2003
31710 @@ -29,7 +29,7 @@
31711  
31712  static inline void mq_init(struct capilib_ncci * np)
31713  {
31714 -       int i;
31715 +       u_int i;
31716         np->msgidqueue = 0;
31717         np->msgidlast = 0;
31718         np->nmsg = 0;
31719 diff -Nru a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
31720 --- a/drivers/isdn/capi/kcapi.c Sun May 25 17:00:00 2003
31721 +++ b/drivers/isdn/capi/kcapi.c Wed Sep  3 03:09:05 2003
31722 @@ -72,7 +72,7 @@
31723  static struct work_struct tq_state_notify;
31724  static struct work_struct tq_recv_notify;
31725  
31726 -/* -------- ref counting -------------------------------------- */
31727 +/* -------- controller ref counting -------------------------------------- */
31728  
31729  static inline struct capi_ctr *
31730  capi_ctr_get(struct capi_ctr *card)
31731 @@ -89,6 +89,21 @@
31732         DBG("MOD_COUNT DEC");
31733  }
31734  
31735 +/* -------- own ref counting -------------------------------------- */
31736 +
31737 +static inline void
31738 +kcapi_get_ref(void)
31739 +{
31740 +       if (!try_module_get(THIS_MODULE))
31741 +               printk(KERN_WARNING "%s: cannot reserve module\n", __FUNCTION__);
31742 +}
31743 +
31744 +static inline void
31745 +kcapi_put_ref(void)
31746 +{
31747 +       module_put(THIS_MODULE);
31748 +}
31749 +
31750  /* ------------------------------------------------------------- */
31751  
31752  static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
31753 @@ -209,10 +224,10 @@
31754  {
31755         struct capi_notifier *np;
31756  
31757 -       MOD_INC_USE_COUNT;
31758 +       kcapi_get_ref();
31759         np = (struct capi_notifier *)kmalloc(sizeof(struct capi_notifier), GFP_ATOMIC);
31760         if (!np) {
31761 -               MOD_DEC_USE_COUNT;
31762 +               kcapi_put_ref();
31763                 return -1;
31764         }
31765         memset(np, 0, sizeof(struct capi_notifier));
31766 @@ -226,9 +241,9 @@
31767          * of devices. Devices can only removed in
31768          * user process, not in bh.
31769          */
31770 -       MOD_INC_USE_COUNT;
31771 +       kcapi_get_ref();
31772         if (schedule_work(&tq_state_notify) == 0)
31773 -               MOD_DEC_USE_COUNT;
31774 +               kcapi_put_ref();
31775         return 0;
31776  }
31777  
31778 @@ -286,9 +301,9 @@
31779         while ((np = notify_dequeue()) != 0) {
31780                 notify_doit(np);
31781                 kfree(np);
31782 -               MOD_DEC_USE_COUNT;
31783 +               kcapi_put_ref();
31784         }
31785 -       MOD_DEC_USE_COUNT;
31786 +       kcapi_put_ref();
31787  }
31788         
31789  /* -------- Receiver ------------------------------------------ */
31790 @@ -626,19 +641,18 @@
31791  
31792  EXPORT_SYMBOL(capi20_put_message);
31793  
31794 -u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN])
31795 +u16 capi20_get_manufacturer(u32 contr, u8 *buf)
31796  {
31797         struct capi_ctr *card;
31798  
31799         if (contr == 0) {
31800 -               strlcpy(buf, capi_manufakturer, sizeof(buf));
31801 +               strlcpy(buf, capi_manufakturer, CAPI_MANUFACTURER_LEN);
31802                 return CAPI_NOERROR;
31803         }
31804         card = get_capi_ctr_by_nr(contr);
31805         if (!card || card->cardstate != CARD_RUNNING) 
31806                 return CAPI_REGNOTINSTALLED;
31807 -
31808 -       strlcpy(buf, card->manu, sizeof(buf));
31809 +       strlcpy(buf, card->manu, CAPI_MANUFACTURER_LEN);
31810         return CAPI_NOERROR;
31811  }
31812  
31813 @@ -662,19 +676,19 @@
31814  
31815  EXPORT_SYMBOL(capi20_get_version);
31816  
31817 -u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN])
31818 +u16 capi20_get_serial(u32 contr, u8 *serial)
31819  {
31820         struct capi_ctr *card;
31821  
31822         if (contr == 0) {
31823 -               strlcpy(serial, driver_serial, sizeof(serial));
31824 +               strlcpy(serial, driver_serial, CAPI_SERIAL_LEN);
31825                 return CAPI_NOERROR;
31826         }
31827         card = get_capi_ctr_by_nr(contr);
31828         if (!card || card->cardstate != CARD_RUNNING) 
31829                 return CAPI_REGNOTINSTALLED;
31830  
31831 -       strlcpy((void *) serial, card->serial, sizeof(serial));
31832 +       strlcpy((void *) serial, card->serial, CAPI_SERIAL_LEN);
31833         return CAPI_NOERROR;
31834  }
31835  
31836 diff -Nru a/drivers/isdn/hardware/avm/Kconfig b/drivers/isdn/hardware/avm/Kconfig
31837 --- a/drivers/isdn/hardware/avm/Kconfig Thu Nov 14 08:10:48 2002
31838 +++ b/drivers/isdn/hardware/avm/Kconfig Mon Aug 25 07:15:22 2003
31839 @@ -12,13 +12,13 @@
31840  
31841  config ISDN_DRV_AVMB1_B1ISA
31842         tristate "AVM B1 ISA support"
31843 -       depends on CAPI_AVM && ISDN_CAPI && ISA
31844 +       depends on CAPI_AVM && ISDN_CAPI && ISA && BROKEN_ON_SMP
31845         help
31846           Enable support for the ISA version of the AVM B1 card.
31847  
31848  config ISDN_DRV_AVMB1_B1PCI
31849         tristate "AVM B1 PCI support"
31850 -       depends on CAPI_AVM && ISDN_CAPI && PCI
31851 +       depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
31852         help
31853           Enable support for the PCI version of the AVM B1 card.
31854  
31855 @@ -30,14 +30,14 @@
31856  
31857  config ISDN_DRV_AVMB1_T1ISA
31858         tristate "AVM T1/T1-B ISA support"
31859 -       depends on CAPI_AVM && ISDN_CAPI && ISA
31860 +       depends on CAPI_AVM && ISDN_CAPI && ISA && BROKEN_ON_SMP
31861         help
31862           Enable support for the AVM T1 T1B card.
31863           Note: This is a PRI card and handle 30 B-channels.
31864  
31865  config ISDN_DRV_AVMB1_B1PCMCIA
31866         tristate "AVM B1/M1/M2 PCMCIA support"
31867 -       depends on CAPI_AVM && ISDN_CAPI
31868 +       depends on CAPI_AVM && ISDN_CAPI && BROKEN_ON_SMP
31869         help
31870           Enable support for the PCMCIA version of the AVM B1 card.
31871  
31872 @@ -50,14 +50,14 @@
31873  
31874  config ISDN_DRV_AVMB1_T1PCI
31875         tristate "AVM T1/T1-B PCI support"
31876 -       depends on CAPI_AVM && ISDN_CAPI && PCI
31877 +       depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
31878         help
31879           Enable support for the AVM T1 T1B card.
31880           Note: This is a PRI card and handle 30 B-channels.
31881  
31882  config ISDN_DRV_AVMB1_C4
31883         tristate "AVM C4/C2 support"
31884 -       depends on CAPI_AVM && ISDN_CAPI && PCI
31885 +       depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
31886         help
31887           Enable support for the AVM C4/C2 PCI cards.
31888           These cards handle 4/2 BRI ISDN lines (8/4 channels).
31889 diff -Nru a/drivers/isdn/hardware/avm/avmcard.h b/drivers/isdn/hardware/avm/avmcard.h
31890 --- a/drivers/isdn/hardware/avm/avmcard.h       Mon Apr 21 03:58:37 2003
31891 +++ b/drivers/isdn/hardware/avm/avmcard.h       Wed Sep  3 03:09:05 2003
31892 @@ -95,8 +95,8 @@
31893  
31894         struct avmctrl_info *ctrlinfo;
31895  
31896 -       int nr_controllers;
31897 -       int nlogcontr;
31898 +       u_int nr_controllers;
31899 +       u_int nlogcontr;
31900         struct list_head list;
31901  } avmcard;
31902  
31903 diff -Nru a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
31904 --- a/drivers/isdn/hardware/avm/b1.c    Sun May 25 17:00:00 2003
31905 +++ b/drivers/isdn/hardware/avm/b1.c    Wed Sep  3 03:09:05 2003
31906 @@ -148,30 +148,31 @@
31907      card->revision = inb(card->port + B1_REVISION);
31908  }
31909  
31910 +#define FWBUF_SIZE     256
31911  int b1_load_t4file(avmcard *card, capiloaddatapart * t4file)
31912  {
31913 -       unsigned char buf[256];
31914 +       unsigned char buf[FWBUF_SIZE];
31915         unsigned char *dp;
31916         int i, left;
31917         unsigned int base = card->port;
31918  
31919         dp = t4file->data;
31920         left = t4file->len;
31921 -       while (left > sizeof(buf)) {
31922 +       while (left > FWBUF_SIZE) {
31923                 if (t4file->user) {
31924 -                       if (copy_from_user(buf, dp, sizeof(buf)))
31925 +                       if (copy_from_user(buf, dp, FWBUF_SIZE))
31926                                 return -EFAULT;
31927                 } else {
31928 -                       memcpy(buf, dp, sizeof(buf));
31929 +                       memcpy(buf, dp, FWBUF_SIZE);
31930                 }
31931 -               for (i = 0; i < sizeof(buf); i++)
31932 +               for (i = 0; i < FWBUF_SIZE; i++)
31933                         if (b1_save_put_byte(base, buf[i]) < 0) {
31934                                 printk(KERN_ERR "%s: corrupted firmware file ?\n",
31935                                                 card->name);
31936                                 return -EIO;
31937                         }
31938 -               left -= sizeof(buf);
31939 -               dp += sizeof(buf);
31940 +               left -= FWBUF_SIZE;
31941 +               dp += FWBUF_SIZE;
31942         }
31943         if (left) {
31944                 if (t4file->user) {
31945 @@ -192,7 +193,7 @@
31946  
31947  int b1_load_config(avmcard *card, capiloaddatapart * config)
31948  {
31949 -       unsigned char buf[256];
31950 +       unsigned char buf[FWBUF_SIZE];
31951         unsigned char *dp;
31952         unsigned int base = card->port;
31953         int i, j, left;
31954 @@ -205,21 +206,21 @@
31955                 b1_put_byte(base, SEND_CONFIG);
31956                 b1_put_word(base, left);
31957         }
31958 -       while (left > sizeof(buf)) {
31959 +       while (left > FWBUF_SIZE) {
31960                 if (config->user) {
31961 -                       if (copy_from_user(buf, dp, sizeof(buf)))
31962 +                       if (copy_from_user(buf, dp, FWBUF_SIZE))
31963                                 return -EFAULT;
31964                 } else {
31965 -                       memcpy(buf, dp, sizeof(buf));
31966 +                       memcpy(buf, dp, FWBUF_SIZE);
31967                 }
31968 -               for (i = 0; i < sizeof(buf); ) {
31969 +               for (i = 0; i < FWBUF_SIZE; ) {
31970                         b1_put_byte(base, SEND_CONFIG);
31971                         for (j=0; j < 4; j++) {
31972                                 b1_put_byte(base, buf[i++]);
31973                         }
31974                 }
31975 -               left -= sizeof(buf);
31976 -               dp += sizeof(buf);
31977 +               left -= FWBUF_SIZE;
31978 +               dp += FWBUF_SIZE;
31979         }
31980         if (left) {
31981                 if (config->user) {
31982 @@ -785,7 +786,7 @@
31983         char rev[32];
31984  
31985         if ((p = strchr(revision, ':')) != 0 && p[1]) {
31986 -               strlcpy(rev, p + 2, sizeof(rev));
31987 +               strlcpy(rev, p + 2, 32);
31988                 if ((p = strchr(rev, '$')) != 0 && p > rev)
31989                    *(p-1) = 0;
31990         } else
31991 diff -Nru a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c
31992 --- a/drivers/isdn/hardware/avm/c4.c    Thu Jul 31 08:59:04 2003
31993 +++ b/drivers/isdn/hardware/avm/c4.c    Wed Sep  3 03:09:05 2003
31994 @@ -189,7 +189,7 @@
31995  {
31996         u32 val;
31997         unsigned char *dp;
31998 -       int left;
31999 +       u_int left;
32000         u32 loadoff = 0;
32001  
32002         dp = t4file->data;
32003 @@ -664,7 +664,7 @@
32004         u32 status = c4inmeml(card->mbase+DOORBELL);
32005  
32006         if (status & DBELL_RESET_HOST) {
32007 -               int i;
32008 +               u_int i;
32009                 c4outmeml(card->mbase+PCI_OUT_INT_MASK, 0x0c);
32010                 if (card->nlogcontr == 0)
32011                         return IRQ_HANDLED;
32012 @@ -791,7 +791,8 @@
32013  {
32014         u8 val[4];
32015         unsigned char *dp;
32016 -       int left, retval;
32017 +       u_int left;
32018 +       int retval;
32019         
32020         if ((retval = queue_sendconfigword(card, 1)) != 0)
32021                 return retval;
32022 @@ -880,7 +881,7 @@
32023  {
32024         avmcard *card = ((avmctrl_info *)(ctrl->driverdata))->card;
32025         avmctrl_info *cinfo;
32026 -       int i;
32027 +       u_int i;
32028  
32029         c4_reset(card);
32030  
32031 @@ -896,7 +897,7 @@
32032  {
32033         avmcard *card = pci_get_drvdata(pdev);
32034         avmctrl_info *cinfo;
32035 -       int i;
32036 +       u_int i;
32037  
32038         c4_reset(card);
32039  
32040 diff -Nru a/drivers/isdn/hardware/eicon/capifunc.c b/drivers/isdn/hardware/eicon/capifunc.c
32041 --- a/drivers/isdn/hardware/eicon/capifunc.c    Sun May 25 17:00:00 2003
32042 +++ b/drivers/isdn/hardware/eicon/capifunc.c    Wed Sep  3 15:27:36 2003
32043 @@ -22,8 +22,8 @@
32044  #define DBG_MINIMUM  (DL_LOG + DL_FTL + DL_ERR)
32045  #define DBG_DEFAULT  (DBG_MINIMUM + DL_XLOG + DL_REG)
32046  
32047 -static DIVA_CAPI_ADAPTER *adapter = (DIVA_CAPI_ADAPTER *) NULL;
32048 -static APPL *application = (APPL *) NULL;
32049 +DIVA_CAPI_ADAPTER *adapter = (DIVA_CAPI_ADAPTER *) NULL;
32050 +APPL *application = (APPL *) NULL;
32051  byte max_appl = MAX_APPL;
32052  static CAPI_MSG *mapped_msg = (CAPI_MSG *) NULL;
32053  
32054 @@ -45,7 +45,7 @@
32055  static void DIRequest(ENTITY * e);
32056  static DESCRIPTOR MAdapter;
32057  static DESCRIPTOR DAdapter;
32058 -static byte max_adapter = 0;
32059 +byte max_adapter = 0;
32060  static byte ControllerMap[MAX_DESCRIPTORS + 1];
32061  
32062  
32063 @@ -111,7 +111,7 @@
32064  /*
32065   * Controller mapping
32066   */
32067 -static byte MapController(byte Controller)
32068 +byte MapController(byte Controller)
32069  {
32070         byte i;
32071         byte MappedController = 0;
32072 @@ -750,8 +750,6 @@
32073         void **xbuffer_ptr, **xbuffer_internal;
32074         diva_os_spin_lock_magic_t old_irql;
32075  
32076 -       DIVA_LOCK_MODULE;
32077 -
32078         if (diva_os_in_irq()) {
32079                 DBG_ERR(("CAPI_REGISTER - in irq context !"))
32080                 return;
32081 @@ -777,6 +775,11 @@
32082                 return; /* appl already registered */
32083         }
32084  
32085 +       if (!try_module_get(ctrl->owner)) {
32086 +               printk(KERN_WARNING "%s: cannot reserve module\n", __FUNCTION__);
32087 +               return;
32088 +       }
32089 +
32090         /* alloc memory */
32091  
32092         bnum = rp->level3cnt * rp->datablkcnt;
32093 @@ -784,6 +787,7 @@
32094  
32095         if (!(DataNCCI = diva_os_malloc(0, bnum * sizeof(word)))) {
32096                 DBG_ERR(("CAPI_REGISTER - memory allocation failed"))
32097 +               module_put(ctrl->owner);
32098                 return;
32099         }
32100         memset(DataNCCI, 0, bnum * sizeof(word));
32101 @@ -791,6 +795,7 @@
32102         if (!(DataFlags = diva_os_malloc(0, bnum * sizeof(word)))) {
32103                 DBG_ERR(("CAPI_REGISTER - memory allocation failed"))
32104                 diva_os_free(0, DataNCCI);
32105 +               module_put(ctrl->owner);
32106                 return;
32107         }
32108         memset(DataFlags, 0, bnum * sizeof(word));
32109 @@ -799,6 +804,7 @@
32110                 DBG_ERR(("CAPI_REGISTER - memory allocation failed"))
32111                 diva_os_free(0, DataNCCI);
32112                 diva_os_free(0, DataFlags);
32113 +               module_put(ctrl->owner);
32114                 return;
32115         }
32116         memset(ReceiveBuffer, 0, bnum * rp->datablklen);
32117 @@ -808,6 +814,7 @@
32118                 diva_os_free(0, DataNCCI);
32119                 diva_os_free(0, DataFlags);
32120                 diva_os_free(0, ReceiveBuffer);
32121 +               module_put(ctrl->owner);
32122                 return;
32123         }
32124         memset(xbuffer_used, 0, xnum);
32125 @@ -818,6 +825,7 @@
32126                 diva_os_free(0, DataFlags);
32127                 diva_os_free(0, ReceiveBuffer);
32128                 diva_os_free(0, xbuffer_used);
32129 +               module_put(ctrl->owner);
32130                 return;
32131         }
32132         memset(xbuffer_ptr, 0, xnum * sizeof(void *));
32133 @@ -829,6 +837,7 @@
32134                 diva_os_free(0, ReceiveBuffer);
32135                 diva_os_free(0, xbuffer_used);
32136                 diva_os_free(0, xbuffer_ptr);
32137 +               module_put(ctrl->owner);
32138                 return;
32139         }
32140         memset(xbuffer_internal, 0, xnum * sizeof(void *));
32141 @@ -848,6 +857,7 @@
32142                         diva_os_free(0, xbuffer_used);
32143                         diva_os_free(0, xbuffer_ptr);
32144                         diva_os_free(0, xbuffer_internal);
32145 +                       module_put(ctrl->owner);
32146                         return;
32147                 }
32148         }
32149 @@ -935,7 +945,7 @@
32150         }
32151         diva_os_leave_spin_lock(&api_lock, &old_irql, "release_appl");
32152  
32153 -       DIVA_UNLOCK_MODULE;
32154 +       module_put(ctrl->owner);
32155  }
32156  
32157  /*
32158 diff -Nru a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c
32159 --- a/drivers/isdn/hardware/eicon/divasi.c      Mon Jul 21 12:08:32 2003
32160 +++ b/drivers/isdn/hardware/eicon/divasi.c      Tue Aug 26 09:25:41 2003
32161 @@ -432,7 +432,7 @@
32162  
32163  static int um_idi_release(struct inode *inode, struct file *file)
32164  {
32165 -       unsigned int adapter_nr = minor(inode->i_rdev);
32166 +       unsigned int adapter_nr = iminor(inode);
32167         int ret = 0;
32168  
32169         if (!(file->private_data)) {
32170 diff -Nru a/drivers/isdn/hardware/eicon/platform.h b/drivers/isdn/hardware/eicon/platform.h
32171 --- a/drivers/isdn/hardware/eicon/platform.h    Wed Nov 13 12:59:12 2002
32172 +++ b/drivers/isdn/hardware/eicon/platform.h    Wed Sep  3 15:24:15 2003
32173 @@ -201,8 +201,10 @@
32174  /*
32175  ** module locking
32176  */
32177 +/* 
32178  #define DIVA_LOCK_MODULE MOD_INC_USE_COUNT
32179  #define DIVA_UNLOCK_MODULE MOD_DEC_USE_COUNT
32180 +*/
32181  
32182  /*
32183  **  Spin Lock framework
32184 diff -Nru a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
32185 --- a/drivers/isdn/hisax/amd7930_fn.c   Sat Apr 19 13:06:05 2003
32186 +++ b/drivers/isdn/hisax/amd7930_fn.c   Wed Sep  3 03:09:05 2003
32187 @@ -692,7 +692,7 @@
32188          if (cs->debug & L1_DEB_ISAC)
32189                 debugl1(cs, "Amd7930: dbusy_timer_handler: DSR1=0x%02X, DSR2=0x%02X, DER=0x%04X, cs->tx_skb->len=%u, tx_stat=%u, dtcr=%u, cs->tx_cnt=%u", dsr1, dsr2, der, cs->tx_skb->len, cs->dc.amd7930.tx_xmtlen, dtcr, cs->tx_cnt);
32190  
32191 -               if ((cs->dc.amd7930.tx_xmtlen - dtcr) < cs->tx_cnt) {   /* D-Channel Busy */
32192 +               if ((int)(cs->dc.amd7930.tx_xmtlen - dtcr) < cs->tx_cnt) {      /* D-Channel Busy */
32193                         test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags);
32194                         stptr = cs->stlist;
32195                         while (stptr != NULL) {
32196 diff -Nru a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c
32197 --- a/drivers/isdn/hisax/callc.c        Mon May 26 17:51:43 2003
32198 +++ b/drivers/isdn/hisax/callc.c        Wed Sep  3 03:09:40 2003
32199 @@ -1758,7 +1758,7 @@
32200                 /* protocol specific io commands */
32201                 case (ISDN_CMD_PROT_IO):
32202                         for (st = csta->stlist; st; st = st->next)
32203 -                               if (st->protocol == (ic->arg & 0xFF))
32204 +                               if ((u_int)st->protocol == (ic->arg & 0xFF))
32205                                         return(st->l3.l4l3_proto(st, ic));
32206                         return(-EINVAL);
32207                         break;
32208 diff -Nru a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
32209 --- a/drivers/isdn/hisax/diva.c Mon May 12 18:59:22 2003
32210 +++ b/drivers/isdn/hisax/diva.c Wed Sep  3 02:15:47 2003
32211 @@ -751,17 +751,17 @@
32212                                         card->para[1] = pnp_port_start(pd, 0);
32213                                         card->para[0] = pnp_irq(pd, 0);
32214                                         if (pdev->function == ISAPNP_FUNCTION(0xA1)) {
32215 -                                               if (diva_ipac_isa_probe(cs->card, cs))
32216 +                                               if (diva_ipac_isa_probe(card->cs, card))
32217                                                         return 0;
32218                                                 return 1;
32219                                         } else {
32220 -                                               if (diva_isac_isa_probe(cs->card, cs))
32221 +                                               if (diva_isac_isa_probe(card->cs, card))
32222                                                         return 0;
32223                                                 return 1;
32224 -                                       } else {
32225 -                                               printk(KERN_ERR "Diva PnP: PnP error card found, no device\n");
32226 -                                               return(0);
32227                                         }
32228 +                               } else {
32229 +                                       printk(KERN_ERR "Diva PnP: PnP error card found, no device\n");
32230 +                                       return(0);
32231                                 }
32232                                 pdev++;
32233                                 pnp_c=NULL;
32234 diff -Nru a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
32235 --- a/drivers/isdn/hisax/elsa.c Mon May 12 18:59:22 2003
32236 +++ b/drivers/isdn/hisax/elsa.c Wed Sep  3 04:35:55 2003
32237 @@ -838,7 +838,7 @@
32238                 cs->hw.elsa.status |= ELSA_BAD_PWR;
32239         }
32240         switch (cs->subtyp) {
32241 -       case ELSA_PCFPRO: bytecnt = 16; break;
32242 +               case ELSA_PCFPRO: bytecnt = 16; break;
32243         }
32244         if (!request_io(&cs->rs, cs->hw.elsa.base, bytecnt, "elsa isdn"))
32245                 goto err;
32246 diff -Nru a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
32247 --- a/drivers/isdn/hisax/elsa_ser.c     Sat Jan  4 14:10:11 2003
32248 +++ b/drivers/isdn/hisax/elsa_ser.c     Wed Sep  3 03:09:40 2003
32249 @@ -255,7 +255,7 @@
32250  write_modem(struct BCState *bcs) {
32251         int ret=0;
32252         struct IsdnCardState *cs = bcs->cs;
32253 -       int count, len, fp;
32254 +       u_int count, len, fp;
32255         unsigned long flags;
32256         
32257         if (!bcs->tx_skb)
32258 @@ -435,8 +435,8 @@
32259  }
32260  
32261  void
32262 -modem_write_cmd(struct IsdnCardState *cs, u8 *buf, int len) {
32263 -       int count, fp;
32264 +modem_write_cmd(struct IsdnCardState *cs, u8 *buf, u_int len) {
32265 +       u_int count, fp;
32266         u8 *msg = buf;
32267         unsigned long flags;
32268         
32269 diff -Nru a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c
32270 --- a/drivers/isdn/hisax/hfc_2bds0.c    Sat Jan 11 11:24:09 2003
32271 +++ b/drivers/isdn/hisax/hfc_2bds0.c    Wed Sep  3 03:09:40 2003
32272 @@ -264,8 +264,9 @@
32273  hfc_fill_fifo(struct BCState *bcs)
32274  {
32275         struct IsdnCardState *cs = bcs->cs;
32276 -       int idx, fcnt;
32277 -       int count;
32278 +       u_int idx;
32279 +       int fcnt;
32280 +       u_int count;
32281         u8 cip;
32282  
32283         if (!bcs->tx_skb)
32284 @@ -636,8 +637,8 @@
32285  static void
32286  hfc_fill_dfifo(struct IsdnCardState *cs)
32287  {
32288 -       int idx, fcnt;
32289 -       int count;
32290 +       int fcnt;
32291 +       u_int idx, count;
32292         u8 cip;
32293  
32294         if (!cs->tx_skb)
32295 diff -Nru a/drivers/isdn/hisax/hfc_2bs0.c b/drivers/isdn/hisax/hfc_2bs0.c
32296 --- a/drivers/isdn/hisax/hfc_2bs0.c     Sun Jan 12 16:12:37 2003
32297 +++ b/drivers/isdn/hisax/hfc_2bs0.c     Wed Sep  3 03:09:40 2003
32298 @@ -249,8 +249,8 @@
32299  hfc_fill_fifo(struct BCState *bcs)
32300  {
32301         struct IsdnCardState *cs = bcs->cs;
32302 -       int idx, fcnt;
32303 -       int count;
32304 +       int fcnt;
32305 +       u_int idx, count;
32306         int z1, z2;
32307         u8 cip;
32308  
32309 diff -Nru a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
32310 --- a/drivers/isdn/hisax/hfc_pci.c      Mon Apr 21 03:58:37 2003
32311 +++ b/drivers/isdn/hisax/hfc_pci.c      Wed Sep  3 03:09:40 2003
32312 @@ -487,8 +487,8 @@
32313  static void
32314  hfcpci_fill_dfifo(struct IsdnCardState *cs)
32315  {
32316 -       int fcnt;
32317 -       int count, new_z1, maxlen;
32318 +       int fcnt, new_z1, maxlen;
32319 +       u_int count;
32320         dfifo_type *df;
32321         u8 *src, *dst, new_f1;
32322  
32323 @@ -533,7 +533,7 @@
32324         src = cs->tx_skb->data; /* source pointer */
32325         dst = df->data + le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1);
32326         maxlen = D_FIFO_SIZE - le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1);            /* end fifo */
32327 -       if (maxlen > count)
32328 +       if (maxlen > (int)count)
32329                 maxlen = count; /* limit size */
32330         memcpy(dst, src, maxlen);       /* first copy */
32331  
32332 @@ -559,8 +559,8 @@
32333  hfcpci_fill_fifo(struct BCState *bcs)
32334  {
32335         struct IsdnCardState *cs = bcs->cs;
32336 -       int maxlen, fcnt;
32337 -       int count, new_z1;
32338 +       int maxlen, fcnt, new_z1;
32339 +       u_int count;
32340         bzfifo_type *bz;
32341         u8 *bdata;
32342         u8 new_f1, *src, *dst;
32343 @@ -591,7 +591,7 @@
32344                 fcnt = B_FIFO_SIZE - fcnt;      /* remaining bytes to send */
32345  
32346                 while ((fcnt < 2 * HFCPCI_BTRANS_THRESHOLD) && (bcs->tx_skb)) {
32347 -                       if (bcs->tx_skb->len < B_FIFO_SIZE - fcnt) {
32348 +                       if ((int)bcs->tx_skb->len < (B_FIFO_SIZE - fcnt)) {
32349                                 /* data is suitable for fifo */
32350                                 count = bcs->tx_skb->len;
32351  
32352 @@ -601,7 +601,7 @@
32353                                 src = bcs->tx_skb->data;        /* source pointer */
32354                                 dst = bdata + (le16_to_cpu(*z1t) - B_SUB_VAL);
32355                                 maxlen = (B_FIFO_SIZE + B_SUB_VAL) - le16_to_cpu(*z1t); /* end of fifo */
32356 -                               if (maxlen > count)
32357 +                               if (maxlen > (int)count)
32358                                         maxlen = count;         /* limit size */
32359                                 memcpy(dst, src, maxlen);       /* first copy */
32360  
32361 @@ -661,7 +661,7 @@
32362         src = bcs->tx_skb->data;        /* source pointer */
32363         dst = bdata + (le16_to_cpu(bz->za[bz->f1].z1) - B_SUB_VAL);
32364         maxlen = (B_FIFO_SIZE + B_SUB_VAL) - le16_to_cpu(bz->za[bz->f1].z1);            /* end fifo */
32365 -       if (maxlen > count)
32366 +       if (maxlen > (int)count)
32367                 maxlen = count; /* limit size */
32368         memcpy(dst, src, maxlen);       /* first copy */
32369  
32370 diff -Nru a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
32371 --- a/drivers/isdn/hisax/hfc_sx.c       Mon Apr 21 03:58:37 2003
32372 +++ b/drivers/isdn/hisax/hfc_sx.c       Wed Sep  3 03:09:40 2003
32373 @@ -145,7 +145,7 @@
32374           count = z2 - z1;
32375           if (count <= 0)
32376             count += fifo_size; /* free bytes */
32377 -         if (count < skb->len+1) return(0); /* no room */
32378 +         if (count < (int)(skb->len+1)) return(0); /* no room */
32379           count = fifo_size - count; /* bytes still not send */
32380           if (count > 2 * trans_max) return(0); /* delay too long */
32381           count = skb->len;
32382 @@ -182,7 +182,7 @@
32383         if (cs->debug & L1_DEB_ISAC_FIFO)
32384           debugl1(cs, "hfcsx_write_fifo %d count(%ld/%d)",
32385                   fifo, skb->len, count);
32386 -       if (count < skb->len) {
32387 +       if (count < (int)skb->len) {
32388           if (cs->debug & L1_DEB_ISAC_FIFO)
32389             debugl1(cs, "hfcsx_write_fifo %d no fifo mem", fifo);
32390           return(0);
32391 diff -Nru a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
32392 --- a/drivers/isdn/hisax/hisax.h        Mon Apr 21 03:58:37 2003
32393 +++ b/drivers/isdn/hisax/hisax.h        Wed Sep  3 03:09:40 2003
32394 @@ -265,7 +265,7 @@
32395  struct Layer2 {
32396         int tei;
32397         int sap;
32398 -       int maxlen;
32399 +       u_int maxlen;
32400         unsigned long flag;
32401         unsigned int vs, va, vr;
32402         int rc;
32403 diff -Nru a/drivers/isdn/hisax/hisax_fcpcipnp.c b/drivers/isdn/hisax/hisax_fcpcipnp.c
32404 --- a/drivers/isdn/hisax/hisax_fcpcipnp.c       Thu Jul 31 16:47:19 2003
32405 +++ b/drivers/isdn/hisax/hisax_fcpcipnp.c       Wed Sep  3 03:15:17 2003
32406 @@ -38,6 +38,8 @@
32407  #define __debug_variable debug
32408  #include "hisax_debug.h"
32409  
32410 +// #define CONFIG_PNP_CARD     1
32411 +
32412  #ifdef CONFIG_HISAX_DEBUG
32413  static int debug = 0;
32414  MODULE_PARM(debug, "i");
32415 @@ -365,8 +367,8 @@
32416  {
32417         struct fritz_adapter *adapter = bcs->adapter;
32418         struct sk_buff *skb = bcs->tx_skb;
32419 -       int count;
32420 -       int fifo_size = 32;
32421 +       u_int count;
32422 +       u_int fifo_size = 32;
32423         unsigned long flags;
32424         unsigned char *p;
32425  
32426 diff -Nru a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
32427 --- a/drivers/isdn/hisax/ipacx.c        Sun Jan 12 16:12:37 2003
32428 +++ b/drivers/isdn/hisax/ipacx.c        Wed Sep  3 06:24:04 2003
32429 @@ -736,5 +736,6 @@
32430         cs->bc_hw_ops = ipacx_bc_ops;
32431         val = ipacx_read_reg(cs, IPACX_ID) & 0x3f;
32432         printk(KERN_INFO "HiSax: IPACX Design Id: %#x\n", val);
32433 +       return 0;
32434  }
32435  
32436 diff -Nru a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
32437 --- a/drivers/isdn/hisax/isar.c Sun Jan 12 16:12:37 2003
32438 +++ b/drivers/isdn/hisax/isar.c Wed Sep  3 03:09:40 2003
32439 @@ -677,7 +677,7 @@
32440         if (!(bcs->hw.isar.reg->bstat & 
32441                 (bcs->hw.isar.dpath == 1 ? BSTAT_RDM1 : BSTAT_RDM2)))
32442                 return;
32443 -       if (bcs->tx_skb->len > bcs->hw.isar.mml) {
32444 +       if (bcs->tx_skb->len > (u_int)bcs->hw.isar.mml) {
32445                 msb = 0;
32446                 count = bcs->hw.isar.mml;
32447         } else {
32448 diff -Nru a/drivers/isdn/hisax/isdnl1.h b/drivers/isdn/hisax/isdnl1.h
32449 --- a/drivers/isdn/hisax/isdnl1.h       Sat Feb 22 09:10:42 2003
32450 +++ b/drivers/isdn/hisax/isdnl1.h       Wed Sep  3 03:09:40 2003
32451 @@ -354,7 +354,7 @@
32452  }
32453  
32454  static inline unsigned char *
32455 -xmit_fill_fifo_b(struct BCState *bcs, int fifo_size, int *count, int *more)
32456 +xmit_fill_fifo_b(struct BCState *bcs, u_int fifo_size, int *count, int *more)
32457  {
32458         struct IsdnCardState *cs = bcs->cs;
32459         unsigned char *p;
32460 @@ -391,7 +391,7 @@
32461  }
32462  
32463  static inline unsigned char *
32464 -xmit_fill_fifo_d(struct IsdnCardState *cs, int fifo_size, int *count, int *more)
32465 +xmit_fill_fifo_d(struct IsdnCardState *cs, u_int fifo_size, int *count, int *more)
32466  {
32467         unsigned char *p;
32468  
32469 diff -Nru a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c
32470 --- a/drivers/isdn/hisax/isdnl2.c       Fri Feb  7 00:20:36 2003
32471 +++ b/drivers/isdn/hisax/isdnl2.c       Wed Sep  3 03:09:40 2003
32472 @@ -103,7 +103,7 @@
32473         "EV_L2_FRAME_ERROR",
32474  };
32475  
32476 -static int l2addrsize(struct Layer2 *l2);
32477 +static u_int l2addrsize(struct Layer2 *l2);
32478  
32479  static void
32480  set_peer_busy(struct Layer2 *l2) {
32481 @@ -178,14 +178,14 @@
32482         clear_peer_busy(l2);
32483  }
32484  
32485 -inline int
32486 +inline u_int
32487  l2headersize(struct Layer2 *l2, int ui)
32488  {
32489         return (((test_bit(FLG_MOD128, &l2->flag) && (!ui)) ? 2 : 1) +
32490                 (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1));
32491  }
32492  
32493 -inline int
32494 +inline u_int
32495  l2addrsize(struct Layer2 *l2)
32496  {
32497         return (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1);
32498 @@ -295,7 +295,7 @@
32499  int
32500  iframe_error(struct PStack *st, struct sk_buff *skb)
32501  {
32502 -       int i = l2addrsize(&st->l2) + (test_bit(FLG_MOD128, &st->l2.flag) ? 2 : 1);
32503 +       u_int i = l2addrsize(&st->l2) + (test_bit(FLG_MOD128, &st->l2.flag) ? 2 : 1);
32504         int rsp = *skb->data & 0x2;
32505  
32506         if (test_bit(FLG_ORIG, &st->l2.flag))
32507 @@ -360,7 +360,7 @@
32508  int
32509  FRMR_error(struct PStack *st, struct sk_buff *skb)
32510  {
32511 -       int headers = l2addrsize(&st->l2) + 1;
32512 +       u_int headers = l2addrsize(&st->l2) + 1;
32513         u8 *datap = skb->data + headers;
32514         int rsp = *skb->data & 0x2;
32515  
32516 @@ -1066,8 +1066,8 @@
32517         struct PStack *st = fi->userdata;
32518         struct sk_buff *skb = arg;
32519         struct Layer2 *l2 = &(st->l2);
32520 -       int PollFlag, ns, i;
32521 -       unsigned int nr;
32522 +       int PollFlag, i;
32523 +       unsigned int nr, ns;
32524  
32525         i = l2addrsize(l2);
32526         if (test_bit(FLG_MOD128, &l2->flag)) {
32527 @@ -1251,8 +1251,7 @@
32528         struct sk_buff *skb, *oskb;
32529         struct Layer2 *l2 = &st->l2;
32530         u8 header[MAX_HEADER_LEN];
32531 -       int i;
32532 -       int unsigned p1;
32533 +       int unsigned p1, i;
32534         unsigned long flags;
32535  
32536         if (!cansend(st))
32537 @@ -1632,7 +1631,7 @@
32538  {
32539         struct sk_buff *skb = arg;
32540         u8 *datap;
32541 -       int ret = 1, len;
32542 +       u_int ret = 1, len;
32543         int c = 0;
32544  
32545         switch (pr) {
32546 diff -Nru a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
32547 --- a/drivers/isdn/hisax/l3_1tr6.c      Sat Jan  4 07:35:39 2003
32548 +++ b/drivers/isdn/hisax/l3_1tr6.c      Wed Sep  3 03:09:40 2003
32549 @@ -302,7 +302,8 @@
32550  l3_1tr6_info(struct l3_process *pc, u8 pr, void *arg)
32551  {
32552         u8 *p;
32553 -       int i, tmpcharge = 0;
32554 +       u_int i;
32555 +       int tmpcharge = 0;
32556         char a_charge[8], tmp[32];
32557         struct sk_buff *skb = arg;
32558  
32559 @@ -400,7 +401,8 @@
32560  {
32561         struct sk_buff *skb = arg;
32562         u8 *p;
32563 -       int i, tmpcharge = 0;
32564 +       u_int i;
32565 +       int tmpcharge = 0;
32566         char a_charge[8], tmp[32];
32567  
32568         StopAllL3Timer(pc);
32569 @@ -753,7 +755,8 @@
32570  static void
32571  up1tr6(struct PStack *st, int pr, void *arg)
32572  {
32573 -       int i, mt, cr;
32574 +       u_int i;
32575 +       int mt, cr;
32576         struct l3_process *proc;
32577         struct sk_buff *skb = arg;
32578         char tmp[80];
32579 @@ -868,7 +871,8 @@
32580  static void
32581  down1tr6(struct PStack *st, int pr, void *arg)
32582  {
32583 -       int i, cr;
32584 +       u_int i;
32585 +       int cr;
32586         struct l3_process *proc;
32587         struct Channel *chan;
32588         char tmp[80];
32589 @@ -915,7 +919,7 @@
32590  static void
32591  man1tr6(struct PStack *st, int pr, void *arg)
32592  {
32593 -        int i;
32594 +        u_int i;
32595          struct l3_process *proc = arg;
32596   
32597          if (!proc) {
32598 diff -Nru a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c
32599 --- a/drivers/isdn/hisax/l3dss1.c       Mon Feb 24 10:22:41 2003
32600 +++ b/drivers/isdn/hisax/l3dss1.c       Wed Sep  3 03:09:40 2003
32601 @@ -736,7 +736,7 @@
32602         p += l;
32603         mt = *p++;
32604         oldpos = 0;
32605 -       while ((p - skb->data) < skb->len) {
32606 +       while ((p - skb->data) < (int)skb->len) {
32607                 if ((*p & 0xf0) == 0x90) { /* shift codeset */
32608                         old_codeset = codeset;
32609                         codeset = *p & 7;
32610 @@ -2923,7 +2923,7 @@
32611         u8 tmp[16];
32612         u8 *p = tmp;
32613         int l;
32614 -       int i;
32615 +       u_int i;
32616         struct l3_process *proc = st->l3.global;
32617  
32618         proc->callref = skb->data[2]; /* cr flag */
32619 @@ -2961,7 +2961,8 @@
32620  static void
32621  dss1up(struct PStack *st, int pr, void *arg)
32622  {
32623 -       int i, mt, cr, cause, callState;
32624 +       u_int i;
32625 +       int mt, cr, cause, callState;
32626         char *ptr;
32627         u8 *p;
32628         struct sk_buff *skb = arg;
32629 @@ -2998,7 +2999,7 @@
32630                 return;
32631         }
32632         cr = getcallref(skb->data);
32633 -       if (skb->len < ((skb->data[1] & 0x0f) + 3)) {
32634 +       if (skb->len < (u_int)((skb->data[1] & 0x0f) + 3)) {
32635                 l3_debug(st, "dss1up frame too short(%d)", skb->len);
32636                 dev_kfree_skb(skb);
32637                 return;
32638 @@ -3135,7 +3136,8 @@
32639  static void
32640  dss1down(struct PStack *st, int pr, void *arg)
32641  {
32642 -       int i, cr;
32643 +       u_int i;
32644 +       int cr;
32645         struct l3_process *proc;
32646         struct Channel *chan;
32647  
32648 @@ -3186,29 +3188,29 @@
32649  static void
32650  dss1man(struct PStack *st, int pr, void *arg)
32651  {
32652 -        int i;
32653 -        struct l3_process *proc = arg;
32654
32655 -        if (!proc) {
32656 -                printk(KERN_ERR "HiSax dss1man without proc pr=%04x\n", pr);
32657 -                return;
32658 -        }
32659 -        for (i = 0; i < MANSLLEN; i++)
32660 +       u_int i;
32661 +       struct l3_process *proc = arg;
32662 +
32663 +       if (!proc) {
32664 +               printk(KERN_ERR "HiSax dss1man without proc pr=%04x\n", pr);
32665 +               return;
32666 +       }
32667 +       for (i = 0; i < MANSLLEN; i++)
32668                  if ((pr == manstatelist[i].primitive) &&
32669 -                    ((1 << proc->state) & manstatelist[i].state))
32670 -                        break;
32671 -        if (i == MANSLLEN) {
32672 -                if (st->l3.debug & L3_DEB_STATE) {
32673 -                        l3_debug(st, "cr %d dss1man state %d prim %#x unhandled",
32674 -                                proc->callref & 0x7f, proc->state, pr);
32675 -                }
32676 -        } else {
32677 -                if (st->l3.debug & L3_DEB_STATE) {
32678 -                        l3_debug(st, "cr %d dss1man state %d prim %#x",
32679 -                                proc->callref & 0x7f, proc->state, pr);
32680 -                }
32681 -                manstatelist[i].rout(proc, pr, arg);
32682 -        }
32683 +                       ((1 << proc->state) & manstatelist[i].state))
32684 +                       break;
32685 +       if (i == MANSLLEN) {
32686 +               if (st->l3.debug & L3_DEB_STATE) {
32687 +                       l3_debug(st, "cr %d dss1man state %d prim %#x unhandled",
32688 +                               proc->callref & 0x7f, proc->state, pr);
32689 +               }
32690 +       } else {
32691 +               if (st->l3.debug & L3_DEB_STATE) {
32692 +                       l3_debug(st, "cr %d dss1man state %d prim %#x",
32693 +                               proc->callref & 0x7f, proc->state, pr);
32694 +               }
32695 +               manstatelist[i].rout(proc, pr, arg);
32696 +       }
32697  }
32698   
32699  void
32700 diff -Nru a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c
32701 --- a/drivers/isdn/hisax/l3ni1.c        Mon Feb 24 10:22:43 2003
32702 +++ b/drivers/isdn/hisax/l3ni1.c        Wed Sep  3 03:09:40 2003
32703 @@ -685,7 +685,7 @@
32704         p += l;
32705         mt = *p++;
32706         oldpos = 0;
32707 -       while ((p - skb->data) < skb->len) {
32708 +       while ((u_int)(p - skb->data) < skb->len) {
32709                 if ((*p & 0xf0) == 0x90) { /* shift codeset */
32710                         old_codeset = codeset;
32711                         codeset = *p & 7;
32712 @@ -2859,7 +2859,7 @@
32713         u8 tmp[16];
32714         u8 *p = tmp;
32715         int l;
32716 -       int i;
32717 +       u_int i;
32718         struct l3_process *proc = st->l3.global;
32719  
32720         if ( skb )      
32721 @@ -2900,7 +2900,8 @@
32722  static void
32723  ni1up(struct PStack *st, int pr, void *arg)
32724  {
32725 -       int i, mt, cr, cause, callState;
32726 +       u_int i; 
32727 +       int mt, cr, cause, callState;
32728         char *ptr;
32729         u8 *p;
32730         struct sk_buff *skb = arg;
32731 @@ -2941,7 +2942,7 @@
32732                 return;
32733         }
32734         cr = getcallref(skb->data);
32735 -       if (skb->len < ((skb->data[1] & 0x0f) + 3)) {
32736 +       if (skb->len < (u_int)((skb->data[1] & 0x0f) + 3)) {
32737                 l3_debug(st, "ni1up frame too short(%d)", skb->len);
32738                 dev_kfree_skb(skb);
32739                 return;
32740 @@ -3086,7 +3087,8 @@
32741  static void
32742  ni1down(struct PStack *st, int pr, void *arg)
32743  {
32744 -       int i, cr;
32745 +       u_int i;
32746 +       int cr;
32747         struct l3_process *proc;
32748         struct Channel *chan;
32749  
32750 @@ -3137,7 +3139,7 @@
32751  static void
32752  ni1man(struct PStack *st, int pr, void *arg)
32753  {
32754 -        int i;
32755 +        u_int i;
32756          struct l3_process *proc = arg;
32757  
32758          if (!proc) {
32759 diff -Nru a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
32760 --- a/drivers/isdn/hisax/netjet.c       Sun Jan 12 16:01:56 2003
32761 +++ b/drivers/isdn/hisax/netjet.c       Wed Sep  3 03:09:40 2003
32762 @@ -729,7 +729,7 @@
32763  
32764  static void write_raw(struct BCState *bcs, u_int *buf, int cnt) {
32765         u_int mask, val, *p=buf;
32766 -       u_int i, s_cnt;
32767 +       int i, s_cnt;
32768          
32769          if (cnt <= 0)
32770                 return;
32771 diff -Nru a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
32772 --- a/drivers/isdn/hisax/q931.c Sat Jan  4 07:35:39 2003
32773 +++ b/drivers/isdn/hisax/q931.c Wed Sep  3 03:09:40 2003
32774 @@ -446,7 +446,7 @@
32775  {
32776         u8 *end;
32777         char *dp = dest;
32778 -       int i, cause;
32779 +       u_int i, cause;
32780  
32781         end = p + p[1] + 1;
32782         p += 2;
32783 @@ -871,7 +871,8 @@
32784  disptext_ni1(char *dest, u8 * p)
32785  {
32786         char *dp = dest;
32787 -       int l, tag, len, i;
32788 +       int l, tag, len;
32789 +       u_int i;
32790  
32791         p++;
32792         l = *p++ - 1;
32793 @@ -1200,7 +1201,7 @@
32794         char *dp;
32795         unsigned char pd, cr_l, cr, mt;
32796         unsigned char sapi, tei, ftyp;
32797 -       int i, cset = 0, cs_old = 0, cs_fest = 0;
32798 +       u_int i, cset = 0, cs_old = 0, cs_fest = 0;
32799         int size, finish = 0;
32800  
32801         if (skb->len < 3)
32802 diff -Nru a/drivers/isdn/hisax/sedlbauer.c b/drivers/isdn/hisax/sedlbauer.c
32803 --- a/drivers/isdn/hisax/sedlbauer.c    Mon May 12 18:59:22 2003
32804 +++ b/drivers/isdn/hisax/sedlbauer.c    Wed Sep  3 02:17:10 2003
32805 @@ -760,7 +760,7 @@
32806                                                 printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n",
32807                                                        pnp_irq(pd, 0), pnp_port_start(pd, 0));
32808                                                 pnp_device_detach(pd);
32809 -                                               goto err;
32810 +                                               return 0;
32811                                         }
32812                                         card->para[1] = pnp_port_start(pd, 0);
32813                                         card->para[0] = pnp_irq(pd, 0);
32814 @@ -777,7 +777,7 @@
32815                                         }
32816                                 } else {
32817                                         printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n");
32818 -                                       goto err;
32819 +                                       return 0;
32820                                 }
32821                         }
32822                         pdev++;
32823 diff -Nru a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c
32824 --- a/drivers/isdn/hisax/st5481_b.c     Sat Aug  9 05:20:58 2003
32825 +++ b/drivers/isdn/hisax/st5481_b.c     Wed Sep  3 03:09:40 2003
32826 @@ -31,9 +31,9 @@
32827         struct st5481_b_out *b_out = &bcs->b_out;
32828         struct st5481_adapter *adapter = bcs->adapter;
32829         struct urb *urb;
32830 -       unsigned int packet_size,offset;
32831 -       int len,buf_size,bytes_sent;
32832 -       int i;
32833 +       u_int packet_size, bytes_sent;
32834 +       int len, offset, buf_size;
32835 +       u_int i;
32836         struct sk_buff *skb;
32837         
32838         if (test_and_set_bit(buf_nr, &b_out->busy)) {
32839 diff -Nru a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c
32840 --- a/drivers/isdn/hisax/st5481_d.c     Sat Aug  9 05:20:13 2003
32841 +++ b/drivers/isdn/hisax/st5481_d.c     Wed Sep  3 03:09:40 2003
32842 @@ -294,8 +294,8 @@
32843  {
32844         struct st5481_d_out *d_out = &adapter->d_out;
32845         struct urb *urb;
32846 -       unsigned int num_packets, packet_offset;
32847 -       int len, buf_size, bytes_sent;
32848 +       unsigned int num_packets;
32849 +       int len, buf_size, bytes_sent, packet_offset;
32850         struct sk_buff *skb;
32851         struct usb_iso_packet_descriptor *desc;
32852  
32853 @@ -341,7 +341,7 @@
32854                 desc = &urb->iso_frame_desc[num_packets];
32855                 desc->offset = packet_offset;
32856                 desc->length = SIZE_ISO_PACKETS_D_OUT;
32857 -               if (len - packet_offset < desc->length)
32858 +               if (len - packet_offset < (int)desc->length)
32859                         desc->length = len - packet_offset;
32860                 num_packets++;
32861                 packet_offset += desc->length;
32862 diff -Nru a/drivers/isdn/i4l/Kconfig b/drivers/isdn/i4l/Kconfig
32863 --- a/drivers/isdn/i4l/Kconfig  Sat Feb 22 09:17:33 2003
32864 +++ b/drivers/isdn/i4l/Kconfig  Sun Aug 24 00:59:46 2003
32865 @@ -106,6 +106,7 @@
32866  
32867  config ISDN_DIVERSION
32868         tristate "Support isdn diversion services"
32869 +       depends on BROKEN
32870         help
32871           This option allows you to use some supplementary diversion
32872           services in conjunction with the HiSax driver on an EURO/DSS1
32873 diff -Nru a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c
32874 --- a/drivers/isdn/i4l/isdn_audio.c     Tue Oct 29 19:01:05 2002
32875 +++ b/drivers/isdn/i4l/isdn_audio.c     Wed Sep  3 03:09:40 2003
32876 @@ -517,7 +517,6 @@
32877         dtmf_state *s;
32878         int silence;
32879         int i;
32880 -       unsigned long flags;
32881         int grp[2];
32882         char what;
32883         char *p;
32884 @@ -551,7 +550,7 @@
32885                         *p++ = 0x10;
32886                         *p = what;
32887                         skb_trim(skb, 2);
32888 -                       if (skb_headroom(skb) < sizeof(isdn_audio_skb)) {
32889 +                       if ((size_t)skb_headroom(skb) < sizeof(isdnaudio_header)) {
32890                                 printk(KERN_WARNING
32891                                        "isdn_audio: insufficient skb_headroom, dropping\n");
32892                                 kfree_skb(skb);
32893 @@ -559,11 +558,7 @@
32894                         }
32895                         ISDN_AUDIO_SKB_DLECOUNT(skb) = 0;
32896                         ISDN_AUDIO_SKB_LOCK(skb) = 0;
32897 -                       save_flags(flags);
32898 -                       cli();
32899                         isdn_tty_queue_tail(info, skb, 2);
32900 -                       restore_flags(flags);
32901 -                       /* Schedule dequeuing */
32902                         if ((dev->modempoll) && (info->rcvsched))
32903                                 mod_timer(&info->read_timer, jiffies + 4);
32904                 } else
32905 @@ -653,7 +648,6 @@
32906  isdn_audio_put_dle_code(modem_info * info, u_char code)
32907  {
32908         struct sk_buff *skb;
32909 -       unsigned long flags;
32910         char *p;
32911  
32912         skb = dev_alloc_skb(2);
32913 @@ -666,7 +660,7 @@
32914         p = (char *) skb_put(skb, 2);
32915         p[0] = 0x10;
32916         p[1] = code;
32917 -       if (skb_headroom(skb) < sizeof(isdn_audio_skb)) {
32918 +       if ((size_t)skb_headroom(skb) < sizeof(isdnaudio_header)) {
32919                 printk(KERN_WARNING
32920                        "isdn_audio: insufficient skb_headroom, dropping\n");
32921                 kfree_skb(skb);
32922 @@ -674,10 +668,7 @@
32923         }
32924         ISDN_AUDIO_SKB_DLECOUNT(skb) = 0;
32925         ISDN_AUDIO_SKB_LOCK(skb) = 0;
32926 -       save_flags(flags);
32927 -       cli();
32928         isdn_tty_queue_tail(info, skb, 2);
32929 -       restore_flags(flags);
32930         /* Schedule dequeuing */
32931         if ((dev->modempoll) && (info->rcvsched))
32932                 mod_timer(&info->read_timer, jiffies + 4);
32933 @@ -691,7 +682,7 @@
32934  
32935         what = ' ';
32936  
32937 -       if (s->idx > (info->emu.vpar[2] * 800)) { 
32938 +       if (s->idx > (u_int)(info->emu.vpar[2] * 800)) { 
32939                 s->idx = 0;
32940                 if (!s->state) {        /* silence from beginning of rec */ 
32941                         what = 's';
32942 @@ -699,9 +690,9 @@
32943                         what = 'q';
32944                 }
32945         }
32946 -               if ((what == 's') || (what == 'q')) {
32947 -                       printk(KERN_DEBUG "ttyI%d: %s\n", info->line,
32948 -                               (what=='s') ? "silence":"quiet");
32949 -                       isdn_audio_put_dle_code(info, what);
32950 -               } 
32951 +       if ((what == 's') || (what == 'q')) {
32952 +               printk(KERN_DEBUG "ttyI%d: %s\n", info->line,
32953 +                       (what=='s') ? "silence":"quiet");
32954 +               isdn_audio_put_dle_code(info, what);
32955 +       } 
32956  }
32957 diff -Nru a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
32958 --- a/drivers/isdn/i4l/isdn_common.c    Mon Jul 21 11:39:14 2003
32959 +++ b/drivers/isdn/i4l/isdn_common.c    Wed Sep  3 06:27:32 2003
32960 @@ -598,6 +598,7 @@
32961         iif->statcallb = isdn_status_callback;
32962  
32963         isdn_info_update();
32964 +       return(0);
32965  }
32966  
32967  static int
32968 @@ -609,6 +610,7 @@
32969         drv->features = drv->interface->features;
32970         isdn_v110_add_features(drv);
32971         set_global_features();
32972 +       return(0);
32973  }
32974  
32975  static int
32976 @@ -616,6 +618,7 @@
32977  {
32978         fsm_change_state(fi, ST_DRV_LOADED);
32979         set_global_features();
32980 +       return(0);
32981  }
32982  
32983  static int
32984 @@ -646,6 +649,7 @@
32985         drv->stavail += c->arg;
32986         spin_unlock_irqrestore(&stat_lock, flags);
32987         wake_up_interruptible(&drv->st_waitq);
32988 +       return 0;
32989  }
32990  
32991  static int
32992 @@ -1318,20 +1322,18 @@
32993  isdn_status_read(struct file *file, char *buf, size_t count, loff_t * off)
32994  {
32995         int retval;
32996 -       int len = 0;
32997 +       size_t len = 0;
32998         char *p;
32999  
33000         if (off != &file->f_pos)
33001                 return -ESPIPE;
33002  
33003 -       lock_kernel();
33004         if (!file->private_data) {
33005 -               if (file->f_flags & O_NONBLOCK) {
33006 -                       retval = -EAGAIN;
33007 -                       goto out;
33008 -               }
33009 +               if (file->f_flags & O_NONBLOCK)
33010 +                       return  -EAGAIN;
33011                 interruptible_sleep_on(&(dev->info_waitq));
33012         }
33013 +       lock_kernel();
33014         p = isdn_statstr();
33015         file->private_data = 0;
33016         if ((len = strlen(p)) <= count) {
33017 @@ -1362,12 +1364,10 @@
33018  {
33019         unsigned int mask = 0;
33020  
33021 -       lock_kernel();
33022 -
33023         poll_wait(file, &(dev->info_waitq), wait);
33024 +       lock_kernel();
33025         if (file->private_data)
33026                 mask |= POLLIN | POLLRDNORM;
33027 -
33028         unlock_kernel();
33029         return mask;
33030  }
33031 @@ -1432,7 +1432,7 @@
33032  static int
33033  isdn_ctrl_open(struct inode *ino, struct file *file)
33034  {
33035 -       unsigned int minor = minor(ino->i_rdev);
33036 +       unsigned int minor = iminor(ino);
33037         struct isdn_slot *slot = get_slot_by_minor(minor - ISDN_MINOR_CTRL);
33038  
33039         if (!slot)
33040 @@ -1464,7 +1464,7 @@
33041         struct isdn_slot *slot = file->private_data;
33042         DECLARE_WAITQUEUE(wait, current);
33043         unsigned long flags;
33044 -       int len = 0;
33045 +       size_t len = 0;
33046  
33047         if (off != &file->f_pos)
33048                 return -ESPIPE;
33049 @@ -1795,7 +1795,7 @@
33050  static int
33051  isdn_open(struct inode * inode, struct file * file)
33052  {
33053 -       int minor = minor(inode->i_rdev);
33054 +       int minor = iminor(inode);
33055         int err = -ENODEV;
33056         struct file_operations *old_fops, *new_fops = NULL;
33057         
33058 diff -Nru a/drivers/isdn/i4l/isdn_net_lib.c b/drivers/isdn/i4l/isdn_net_lib.c
33059 --- a/drivers/isdn/i4l/isdn_net_lib.c   Sun May 25 17:00:00 2003
33060 +++ b/drivers/isdn/i4l/isdn_net_lib.c   Wed Sep  3 03:09:40 2003
33061 @@ -758,7 +758,7 @@
33062  isdn_net_getphone(isdn_net_ioctl_phone * phone, char *phones)
33063  {
33064         isdn_net_dev *idev = isdn_net_findif(phone->name);
33065 -       int count = 0;
33066 +       u_int count = 0;
33067         char *buf = (char *)__get_free_page(GFP_KERNEL);
33068         struct isdn_net_phone *n;
33069  
33070 diff -Nru a/drivers/isdn/i4l/isdn_net_lib.h b/drivers/isdn/i4l/isdn_net_lib.h
33071 --- a/drivers/isdn/i4l/isdn_net_lib.h   Tue Oct 29 18:55:59 2002
33072 +++ b/drivers/isdn/i4l/isdn_net_lib.h   Wed Sep  3 03:09:40 2003
33073 @@ -133,47 +133,47 @@
33074  /* per ISDN channel (ISDN interface) data */
33075  
33076  struct isdn_net_dev_s {
33077 -  struct isdn_slot      *isdn_slot;    /* Index to isdn device/channel     */
33078 -  struct isdn_slot      *exclusive;    /* NULL if non excl                 */
33079 -  int                    pre_device;   /* Preselected isdn-device          */
33080 -  int                    pre_channel;  /* Preselected isdn-channel         */
33081 -
33082 -  struct timer_list      dial_timer;   /* dial events timer                */
33083 -  struct fsm_inst        fi;           /* call control state machine       */
33084 -  int                    dial_event;   /* event in case of timer expiry    */
33085 -  int                    dial;         /* # of phone number just dialed    */
33086 -  int                    outgoing;     /* Flag: outgoing call              */
33087 -  int                    dialretry;    /* Counter for Dialout-retries      */
33088 -
33089 -  int                    cps;          /* current speed of this interface  */
33090 -  int                    transcount;   /* byte-counter for cps-calculation */
33091 -  int                    last_jiffies; /* when transcount was reset        */
33092 -  int                    sqfull;       /* Flag: netdev-queue overloaded    */
33093 -  ulong                  sqfull_stamp; /* Start-Time of overload           */
33094 -
33095 -  int                    huptimer;     /* Timeout-counter for auto-hangup  */
33096 -  int                    charge;       /* Counter for charging units       */
33097 -  int                    charge_state; /* ChargeInfo state machine         */
33098 -  unsigned long          chargetime;   /* Timer for Charging info          */
33099 -  int                    chargeint;    /* Interval between charge-infos    */
33100 -
33101 -  int                    pppbind;      /* ippp device for bindings         */
33102 -
33103 -  struct sk_buff_head    super_tx_queue; /* List of supervisory frames to  */
33104 -                                      /* be transmitted asap              */
33105 -  int                    frame_cnt;    /* number of frames currently       */
33106 -                                      /* queued in HL driver              */
33107 -  struct tasklet_struct  tlet;
33108 -
33109 -  isdn_net_local        *mlp;          /* Ptr to master device for all devs*/
33110 -
33111 -  struct list_head       slaves;       /* member of local->slaves          */
33112 -  struct list_head       online;       /* member of local->online          */
33113 -
33114 -  char                   name[10];     /* Name of device                   */
33115 -  struct list_head       global_list;  /* global list of all isdn_net_devs */
33116 -  void                  *ind_priv;     /* interface types can put their
33117 -                                         private data here                */
33118 +  struct isdn_slot     *isdn_slot;     /* Index to isdn device/channel     */
33119 +  struct isdn_slot     *exclusive;     /* NULL if non excl                 */
33120 +  int                  pre_device;     /* Preselected isdn-device          */
33121 +  int                  pre_channel;    /* Preselected isdn-channel         */
33122 +
33123 +  struct timer_list    dial_timer;     /* dial events timer                */
33124 +  struct fsm_inst      fi;             /* call control state machine       */
33125 +  int                  dial_event;     /* event in case of timer expiry    */
33126 +  int                  dial;           /* # of phone number just dialed    */
33127 +  int                  outgoing;       /* Flag: outgoing call              */
33128 +  int                  dialretry;      /* Counter for Dialout-retries      */
33129 +
33130 +  int                  cps;            /* current speed of this interface  */
33131 +  int                  transcount;     /* byte-counter for cps-calculation */
33132 +  u_long               last_jiffies;   /* when transcount was reset        */
33133 +  int                  sqfull;         /* Flag: netdev-queue overloaded    */
33134 +  u_long               sqfull_stamp;   /* Start-Time of overload           */
33135 +
33136 +  int                  huptimer;       /* Timeout-counter for auto-hangup  */
33137 +  int                  charge;         /* Counter for charging units       */
33138 +  int                  charge_state;   /* ChargeInfo state machine         */
33139 +  u_long               chargetime;     /* Timer for Charging info          */
33140 +  int                  chargeint;      /* Interval between charge-infos    */
33141 +
33142 +  int                  pppbind;        /* ippp device for bindings         */
33143 +
33144 +  struct sk_buff_head  super_tx_queue; /* List of supervisory frames to  */
33145 +                                       /* be transmitted asap              */
33146 +  int                  frame_cnt;      /* number of frames currently       */
33147 +                                       /* queued in HL driver              */
33148 +  struct tasklet_struct        tlet;
33149 +
33150 +  isdn_net_local       *mlp;           /* Ptr to master device for all devs*/
33151 +
33152 +  struct list_head     slaves;         /* member of local->slaves          */
33153 +  struct list_head     online;         /* member of local->online          */
33154 +
33155 +  char                 name[10];       /* Name of device                   */
33156 +  struct list_head     global_list;    /* global list of all isdn_net_devs */
33157 +  void                 *ind_priv;      /* interface types can put their
33158 +                                          private data here                */
33159  };
33160  
33161  /* ====================================================================== */
33162 diff -Nru a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
33163 --- a/drivers/isdn/i4l/isdn_ppp.c       Tue Jul 15 10:01:29 2003
33164 +++ b/drivers/isdn/i4l/isdn_ppp.c       Tue Aug 26 09:25:41 2003
33165 @@ -119,7 +119,7 @@
33166  ipppd_open(struct inode *ino, struct file *file)
33167  {
33168         unsigned long flags;
33169 -       unsigned int minor = minor(ino->i_rdev) - ISDN_MINOR_PPP;
33170 +       unsigned int minor = iminor(ino) - ISDN_MINOR_PPP;
33171         struct ipppd *ipppd;
33172  
33173         ipppd = kmalloc(sizeof(*ipppd), GFP_KERNEL);
33174 diff -Nru a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
33175 --- a/drivers/isdn/i4l/isdn_tty.c       Wed Jun 18 21:25:09 2003
33176 +++ b/drivers/isdn/i4l/isdn_tty.c       Wed Sep  3 03:09:40 2003
33177 @@ -132,7 +132,7 @@
33178  isdn_tty_readbchan(struct modem_info *info, u_char * buf, u_char * fp, int len)
33179  {
33180         int count;
33181 -       int count_pull;
33182 +       u_int count_pull;
33183         int count_put;
33184         int dflag;
33185         struct sk_buff *skb;
33186 @@ -179,7 +179,7 @@
33187  #endif
33188                         /* No DLE's in buff, so simply copy it */
33189                         dflag = 1;
33190 -                       if ((count_pull = skb->len) > len) {
33191 +                       if ((int)(count_pull = skb->len) > len) {
33192                                 count_pull = len;
33193                                 dflag = 0;
33194                         }
33195 @@ -315,7 +315,7 @@
33196                                 skb_pull(skb, 4);
33197         }
33198  #ifdef CONFIG_ISDN_AUDIO
33199 -       if (skb_headroom(skb) < sizeof(isdn_audio_skb)) {
33200 +       if ((size_t)skb_headroom(skb) < sizeof(isdnaudio_header)) {
33201                 printk(KERN_WARNING
33202                        "isdn_audio: insufficient skb_headroom, dropping\n");
33203                 kfree_skb(skb);
33204 @@ -1728,9 +1728,6 @@
33205         modem_info *info;
33206         int retval, line;
33207  
33208 -       /* FIXME. This is not unload-race free AFAICS */
33209 -
33210 -       MOD_INC_USE_COUNT;
33211  
33212         line = tty->index;
33213         if (line < 0 || line > ISDN_MAX_CHANNELS)
33214 @@ -1738,6 +1735,8 @@
33215         info = &isdn_mdm.info[line];
33216         if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open"))
33217                 return -ENODEV;
33218 +       if (!try_module_get(info->owner))
33219 +               printk(KERN_WARNING "%s: cannot reserve module\n", __FUNCTION__);
33220  #ifdef ISDN_DEBUG_MODEM_OPEN
33221         printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
33222                info->count);
33223 @@ -1753,6 +1752,7 @@
33224  #ifdef ISDN_DEBUG_MODEM_OPEN
33225                 printk(KERN_DEBUG "isdn_tty_open return after startup\n");
33226  #endif
33227 +               module_put(info->owner);
33228                 return retval;
33229         }
33230         retval = isdn_tty_block_til_ready(tty, filp, info);
33231 @@ -1760,6 +1760,7 @@
33232  #ifdef ISDN_DEBUG_MODEM_OPEN
33233                 printk(KERN_DEBUG "isdn_tty_open return after isdn_tty_block_til_ready \n");
33234  #endif
33235 +               module_put(info->owner);
33236                 return retval;
33237         }
33238  #ifdef ISDN_DEBUG_MODEM_OPEN
33239 @@ -1779,7 +1780,9 @@
33240         ulong flags;
33241         ulong timeout;
33242  
33243 -       if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close"))
33244 +       if (!info)
33245 +               return;
33246 +       if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close"))
33247                 goto out;
33248  
33249         save_flags(flags);
33250 @@ -1859,7 +1862,7 @@
33251         printk(KERN_DEBUG "isdn_tty_close normal exit\n");
33252  #endif
33253   out:
33254 -       MOD_DEC_USE_COUNT;
33255 +       module_put(info->owner);
33256  }
33257  
33258  /*
33259 @@ -2036,6 +2039,7 @@
33260                         return -3;
33261                 }
33262  #endif
33263 +               info->owner = THIS_MODULE;
33264                 init_MUTEX(&info->write_sem);
33265                 sprintf(info->last_cause, "0000");
33266                 sprintf(info->last_num, "none");
33267 @@ -2457,7 +2461,7 @@
33268             (!skb_queue_empty(&info->rpqueue)))) {
33269                 skb = alloc_skb(strlen(msg)
33270  #ifdef CONFIG_ISDN_AUDIO
33271 -                       + sizeof(isdn_audio_skb)
33272 +                       + sizeof(isdnaudio_header)
33273  #endif
33274                         , GFP_ATOMIC);
33275                 if (!skb) {
33276 @@ -2465,7 +2469,7 @@
33277                         return;
33278                 }
33279  #ifdef CONFIG_ISDN_AUDIO
33280 -               skb_reserve(skb, sizeof(isdn_audio_skb));
33281 +               skb_reserve(skb, sizeof(isdnaudio_header));
33282  #endif
33283                 sp = skb_put(skb, strlen(msg));
33284  #ifdef CONFIG_ISDN_AUDIO
33285 diff -Nru a/drivers/isdn/i4l/isdn_ttyfax.c b/drivers/isdn/i4l/isdn_ttyfax.c
33286 --- a/drivers/isdn/i4l/isdn_ttyfax.c    Fri May 23 11:33:46 2003
33287 +++ b/drivers/isdn/i4l/isdn_ttyfax.c    Wed Sep  3 03:09:40 2003
33288 @@ -265,7 +265,7 @@
33289         __u8 RightMask;
33290         __u8 fBit;
33291         __u8 Data;
33292 -       int i;
33293 +       u_int i;
33294  
33295         if (!info->fax->bor) {
33296                 for (i = 0; i < skb->len; i++) {
33297 diff -Nru a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
33298 --- a/drivers/isdn/icn/icn.c    Sun May 25 17:00:00 2003
33299 +++ b/drivers/isdn/icn/icn.c    Wed Sep  3 04:41:06 2003
33300 @@ -43,6 +43,8 @@
33301  static char
33302  *revision = "$Revision$";
33303  
33304 +static spinlock_t icn_lock = SPIN_LOCK_UNLOCKED; 
33305 +
33306  static int icn_addcard(int, char *, char *);
33307  
33308  /*
33309 @@ -59,16 +61,15 @@
33310         unsigned long flags;
33311  
33312         skb_queue_purge(queue);
33313 -       save_flags(flags);
33314 -       cli();
33315 +       spin_lock_irqsave(&icn_lock, flags);
33316         card->xlen[channel] = 0;
33317         card->sndcount[channel] = 0;
33318         if ((skb = card->xskb[channel])) {
33319                 card->xskb[channel] = NULL;
33320 -               restore_flags(flags);
33321 +               spin_unlock_irqrestore(&icn_lock, flags);
33322                 dev_kfree_skb(skb);
33323         } else
33324 -               restore_flags(flags);
33325 +               spin_unlock_irqrestore(&icn_lock, flags);
33326  }
33327  
33328  /* Put a value into a shift-register, highest bit first.
33329 @@ -146,8 +147,7 @@
33330  #ifdef MAP_DEBUG
33331         printk(KERN_DEBUG "icn_lock_channel %d\n", channel);
33332  #endif
33333 -       save_flags(flags);
33334 -       cli();
33335 +       spin_lock_irqsave(&icn_lock, flags);
33336         if ((dev.channel == channel) && (card == dev.mcard)) {
33337                 dev.chanlock++;
33338                 retval = 1;
33339 @@ -160,7 +160,7 @@
33340                 printk(KERN_DEBUG "icn_lock_channel %d FAILED, dc=%d\n", channel, dev.channel);
33341  #endif
33342         }
33343 -       restore_flags(flags);
33344 +       spin_unlock_irqrestore(&icn_lock, flags);
33345         return retval;
33346  }
33347  
33348 @@ -175,11 +175,10 @@
33349  #ifdef MAP_DEBUG
33350         printk(KERN_DEBUG "icn_release_channel l=%d\n", dev.chanlock);
33351  #endif
33352 -       save_flags(flags);
33353 -       cli();
33354 +       spin_lock_irqsave(&icn_lock, flags);
33355         if (dev.chanlock > 0)
33356                 dev.chanlock--;
33357 -       restore_flags(flags);
33358 +       spin_unlock_irqrestore(&icn_lock, flags);
33359  }
33360  
33361  /*
33362 @@ -195,19 +194,18 @@
33363         printk(KERN_DEBUG "trymaplock c=%d dc=%d l=%d\n", channel, dev.channel,
33364                dev.chanlock);
33365  #endif
33366 -       save_flags(flags);
33367 -       cli();
33368 +       spin_lock_irqsave(&icn_lock, flags);
33369         if ((!dev.chanlock) ||
33370             ((dev.channel == channel) && (dev.mcard == card))) {
33371                 dev.chanlock++;
33372                 icn_map_channel(card, channel);
33373 -               restore_flags(flags);
33374 +               spin_unlock_irqrestore(&icn_lock, flags);
33375  #ifdef MAP_DEBUG
33376                 printk(KERN_DEBUG "trymaplock %d OK\n", channel);
33377  #endif
33378                 return 1;
33379         }
33380 -       restore_flags(flags);
33381 +       spin_unlock_irqrestore(&icn_lock, flags);
33382  #ifdef MAP_DEBUG
33383         printk(KERN_DEBUG "trymaplock %d FAILED\n", channel);
33384  #endif
33385 @@ -226,13 +224,12 @@
33386  #ifdef MAP_DEBUG
33387         printk(KERN_DEBUG "map_release c=%d l=%d\n", channel, dev.chanlock);
33388  #endif
33389 -       save_flags(flags);
33390 -       cli();
33391 +       spin_lock_irqsave(&icn_lock, flags);
33392         if (dev.chanlock > 0)
33393                 dev.chanlock--;
33394         if (!dev.chanlock)
33395                 icn_map_channel(card, channel);
33396 -       restore_flags(flags);
33397 +       spin_unlock_irqrestore(&icn_lock, flags);
33398  }
33399  
33400  /* Get Data from the B-Channel, assemble fragmented packets and put them
33401 @@ -308,14 +305,13 @@
33402                        (card->sndcount[channel] ||
33403                         skb_queue_len(&card->spqueue[channel]) ||
33404                         card->xskb[channel])) {
33405 -                       save_flags(flags);
33406 -                       cli();
33407 +                       spin_lock_irqsave(&icn_lock, flags);
33408                         if (card->xmit_lock[channel]) {
33409 -                               restore_flags(flags);
33410 +                               spin_unlock_irqrestore(&icn_lock, flags);
33411                                 break;
33412                         }
33413                         card->xmit_lock[channel]++;
33414 -                       restore_flags(flags);
33415 +                       spin_unlock_irqrestore(&icn_lock, flags);
33416                         skb = card->xskb[channel];
33417                         if (!skb) {
33418                                 skb = skb_dequeue(&card->spqueue[channel]);
33419 @@ -345,11 +341,10 @@
33420                         sbnext; /* switch to next buffer        */
33421                         icn_maprelease_channel(card, mch & 2);
33422                         if (!skb->len) {
33423 -                               save_flags(flags);
33424 -                               cli();
33425 +                               spin_lock_irqsave(&icn_lock, flags);
33426                                 if (card->xskb[channel])
33427                                         card->xskb[channel] = NULL;
33428 -                               restore_flags(flags);
33429 +                               spin_unlock_irqrestore(&icn_lock, flags);
33430                                 dev_kfree_skb(skb);
33431                                 if (card->xlen[channel]) {
33432                                         cmd.command = ISDN_STAT_BSENT;
33433 @@ -359,10 +354,9 @@
33434                                         card->interface.statcallb(&cmd);
33435                                 }
33436                         } else {
33437 -                               save_flags(flags);
33438 -                               cli();
33439 +                               spin_lock_irqsave(&icn_lock, flags);
33440                                 card->xskb[channel] = skb;
33441 -                               restore_flags(flags);
33442 +                               spin_unlock_irqrestore(&icn_lock, flags);
33443                         }
33444                         card->xmit_lock[channel] = 0;
33445                         if (!icn_trymaplock_channel(card, mch))
33446 @@ -393,11 +387,10 @@
33447         }
33448         if (card->flags & (ICN_FLAGS_B1ACTIVE | ICN_FLAGS_B2ACTIVE)) {
33449                 /* schedule b-channel polling again */
33450 -               save_flags(flags);
33451 -               cli();
33452 +               spin_lock_irqsave(&icn_lock, flags);
33453                 mod_timer(&card->rb_timer, jiffies+ICN_TIMER_BCREAD);
33454                 card->flags |= ICN_FLAGS_RBTIMER;
33455 -               restore_flags(flags);
33456 +               spin_unlock_irqrestore(&icn_lock, flags);
33457         } else
33458                 card->flags &= ~ICN_FLAGS_RBTIMER;
33459  }
33460 @@ -464,9 +457,8 @@
33461         cmd.driver = card->myid;
33462         cmd.arg = channel;
33463         switch (action) {
33464 -       case 11:
33465 -                       save_flags(flags);
33466 -                       cli();
33467 +               case 11:
33468 +                       spin_lock_irqsave(&icn_lock, flags);
33469                         icn_free_queue(card,channel);
33470                         card->rcvidx[channel] = 0;
33471  
33472 @@ -483,11 +475,10 @@
33473                                 ncmd.driver = card->myid;
33474                                 ncmd.arg = channel;
33475                                 ncmd.command = ISDN_STAT_BHUP;
33476 -                               restore_flags(flags);
33477 +                               spin_unlock_irqrestore(&icn_lock, flags);
33478                                 card->interface.statcallb(&cmd);
33479                         } else
33480 -                               restore_flags(flags);
33481 -                       
33482 +                               spin_unlock_irqrestore(&icn_lock, flags);
33483                         break;
33484                 case 1:
33485                         icn_free_queue(card,channel);
33486 @@ -498,10 +489,9 @@
33487                         card->flags &= ~((channel) ?
33488                                 ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE);
33489                         icn_free_queue(card, channel);
33490 -                       save_flags(flags);
33491 -                       cli();
33492 +                       spin_lock_irqsave(&icn_lock, flags);
33493                         card->rcvidx[channel] = 0;
33494 -                       restore_flags(flags);
33495 +                       spin_unlock_irqrestore(&icn_lock, flags);
33496                         break;
33497                 case 3:
33498                         {
33499 @@ -557,10 +547,9 @@
33500                 case 8:
33501                         card->flags &= ~ICN_FLAGS_B1ACTIVE;
33502                         icn_free_queue(card, 0);
33503 -                       save_flags(flags);
33504 -                       cli();
33505 +                       spin_lock_irqsave(&icn_lock, flags);
33506                         card->rcvidx[0] = 0;
33507 -                       restore_flags(flags);
33508 +                       spin_unlock_irqrestore(&icn_lock, flags);
33509                         cmd.arg = 0;
33510                         cmd.driver = card->myid;
33511                         card->interface.statcallb(&cmd);
33512 @@ -571,10 +560,9 @@
33513                         cmd.command = ISDN_STAT_BHUP;
33514                         card->flags &= ~ICN_FLAGS_B2ACTIVE;
33515                         icn_free_queue(card, 1);
33516 -                       save_flags(flags);
33517 -                       cli();
33518 +                       spin_lock_irqsave(&icn_lock, flags);
33519                         card->rcvidx[1] = 0;
33520 -                       restore_flags(flags);
33521 +                       spin_unlock_irqrestore(&icn_lock, flags);
33522                         cmd.arg = 1;
33523                         cmd.driver = card->myid;
33524                         card->interface.statcallb(&cmd);
33525 @@ -592,8 +580,7 @@
33526  {
33527         ulong flags;
33528  
33529 -       save_flags(flags);
33530 -       cli();
33531 +       spin_lock_irqsave(&icn_lock, flags);
33532         *card->msg_buf_write++ = (c == 0xff) ? '\n' : c;
33533         if (card->msg_buf_write == card->msg_buf_read) {
33534                 if (++card->msg_buf_read > card->msg_buf_end)
33535 @@ -601,7 +588,7 @@
33536         }
33537         if (card->msg_buf_write > card->msg_buf_end)
33538                 card->msg_buf_write = card->msg_buf;
33539 -       restore_flags(flags);
33540 +       spin_unlock_irqrestore(&icn_lock, flags);
33541  }
33542  
33543  static void
33544 @@ -683,20 +670,18 @@
33545                 if (!(card->flags & ICN_FLAGS_RBTIMER)) {
33546                         /* schedule b-channel polling */
33547                         card->flags |= ICN_FLAGS_RBTIMER;
33548 -                       save_flags(flags);
33549 -                       cli();
33550 +                       spin_lock_irqsave(&icn_lock, flags);
33551                         del_timer(&card->rb_timer);
33552                         card->rb_timer.function = icn_pollbchan;
33553                         card->rb_timer.data = (unsigned long) card;
33554                         card->rb_timer.expires = jiffies + ICN_TIMER_BCREAD;
33555                         add_timer(&card->rb_timer);
33556 -                       restore_flags(flags);
33557 +                       spin_unlock_irqrestore(&icn_lock, flags);
33558                 }
33559         /* schedule again */
33560 -       save_flags(flags);
33561 -       cli();
33562 +       spin_lock_irqsave(&icn_lock, flags);
33563         mod_timer(&card->st_timer, jiffies+ICN_TIMER_DCREAD);
33564 -       restore_flags(flags);
33565 +       spin_unlock_irqrestore(&icn_lock, flags);
33566  }
33567  
33568  /* Append a packet to the transmit buffer-queue.
33569 @@ -725,8 +710,7 @@
33570                         return 0;
33571                 if (card->sndcount[channel] > ICN_MAX_SQUEUE)
33572                         return 0;
33573 -               save_flags(flags);
33574 -               cli();
33575 +               spin_lock_irqsave(&icn_lock, flags);
33576                 nskb = skb_clone(skb, GFP_ATOMIC);
33577                 if (nskb) {
33578                         /* Push ACK flag as one
33579 @@ -738,7 +722,7 @@
33580                 } else
33581                         len = 0;
33582                 card->sndcount[channel] += len;
33583 -               restore_flags(flags);
33584 +               spin_unlock_irqrestore(&icn_lock, flags);
33585         }
33586         return len;
33587  }
33588 @@ -860,11 +844,10 @@
33589  #ifdef BOOT_DEBUG
33590         printk(KERN_DEBUG "Map Bank 0\n");
33591  #endif
33592 -       save_flags(flags);
33593 -       cli();
33594 +       spin_lock_irqsave(&icn_lock, flags);
33595         icn_map_channel(card, 0);       /* Select Bank 0    */
33596         icn_lock_channel(card, 0);      /* Lock Bank 0      */
33597 -       restore_flags(flags);
33598 +       spin_unlock_irqrestore(&icn_lock, flags);
33599         SLEEP(1);
33600         memcpy_toio(dev.shmem, codebuf, ICN_CODE_STAGE1);       /* Copy code        */
33601  #ifdef BOOT_DEBUG
33602 @@ -875,12 +858,11 @@
33603  #ifdef BOOT_DEBUG
33604                 printk(KERN_DEBUG "Map Bank 8\n");
33605  #endif
33606 -               save_flags(flags);
33607 -               cli();
33608 +               spin_lock_irqsave(&icn_lock, flags);
33609                 icn_release_channel();
33610                 icn_map_channel(card, 2);       /* Select Bank 8   */
33611                 icn_lock_channel(card, 2);      /* Lock Bank 8     */
33612 -               restore_flags(flags);
33613 +               spin_unlock_irqrestore(&icn_lock, flags);
33614                 SLEEP(1);
33615                 memcpy_toio(dev.shmem, codebuf, ICN_CODE_STAGE1);       /* Copy code        */
33616  #ifdef BOOT_DEBUG
33617 @@ -900,11 +882,10 @@
33618  #ifdef BOOT_DEBUG
33619         printk(KERN_DEBUG "Map Bank 0\n");
33620  #endif
33621 -       save_flags(flags);
33622 -       cli();
33623 +       spin_lock_irqsave(&icn_lock, flags);
33624         icn_map_channel(card, 0);       /* Select Bank 0   */
33625         icn_lock_channel(card, 0);      /* Lock Bank 0     */
33626 -       restore_flags(flags);
33627 +       spin_unlock_irqrestore(&icn_lock, flags);
33628         SLEEP(1);
33629         ret = (icn_check_loader(1));
33630  
33631 @@ -931,8 +912,7 @@
33632         if ((ret = verify_area(VERIFY_READ, (void *) buffer, ICN_CODE_STAGE2)))
33633                 return ret;
33634         timer = 0;
33635 -       save_flags(flags);
33636 -       cli();
33637 +       spin_lock_irqsave(&icn_lock, flags);
33638         if (card->secondhalf) {
33639                 icn_map_channel(card, 2);
33640                 icn_lock_channel(card, 2);
33641 @@ -940,7 +920,7 @@
33642                 icn_map_channel(card, 0);
33643                 icn_lock_channel(card, 0);
33644         }
33645 -       restore_flags(flags);
33646 +       spin_unlock_irqrestore(&icn_lock, flags);
33647         while (left) {
33648                 if (sbfree) {   /* If there is a free buffer...  */
33649                         cnt = left;
33650 @@ -995,8 +975,7 @@
33651                                 printk(KERN_DEBUG "Proto loaded, install poll-timer %d\n",
33652                                        card->secondhalf);
33653  #endif
33654 -                               save_flags(flags);
33655 -                               cli();
33656 +                               spin_lock_irqsave(&icn_lock, flags);
33657                                 init_timer(&card->st_timer);
33658                                 card->st_timer.expires = jiffies + ICN_TIMER_DCREAD;
33659                                 card->st_timer.function = icn_polldchan;
33660 @@ -1011,7 +990,7 @@
33661                                         add_timer(&card->other->st_timer);
33662                                         card->other->flags |= ICN_FLAGS_RUNNING;
33663                                 }
33664 -                               restore_flags(flags);
33665 +                               spin_unlock_irqrestore(&icn_lock, flags);
33666                         }
33667                         icn_maprelease_channel(card, 0);
33668                         return 0;
33669 @@ -1069,8 +1048,7 @@
33670                 } else
33671                         memcpy(msg, buf, count);
33672  
33673 -               save_flags(flags);
33674 -               cli();
33675 +               spin_lock_irqsave(&icn_lock, flags);
33676                 lastmap_card = dev.mcard;
33677                 lastmap_channel = dev.channel;
33678                 icn_map_channel(card, mch);
33679 @@ -1092,7 +1070,7 @@
33680                 writeb((readb(&cmd_i) + count) & 0xff, &cmd_i);
33681                 if (lastmap_card)
33682                         icn_map_channel(lastmap_card, lastmap_channel);
33683 -               restore_flags(flags);
33684 +               spin_unlock_irqrestore(&icn_lock, flags);
33685                 if (len) {
33686                         mdelay(1);
33687                         if (loop++ > 20)
33688 @@ -1118,8 +1096,7 @@
33689         unsigned long flags;
33690         isdn_ctrl cmd;
33691  
33692 -       save_flags(flags);
33693 -       cli();
33694 +       spin_lock_irqsave(&icn_lock, flags);
33695         if (card->flags & ICN_FLAGS_RUNNING) {
33696                 card->flags &= ~ICN_FLAGS_RUNNING;
33697                 del_timer(&card->st_timer);
33698 @@ -1130,7 +1107,7 @@
33699                 if (card->doubleS0)
33700                         icn_stopcard(card->other);
33701         }
33702 -       restore_flags(flags);
33703 +       spin_unlock_irqrestore(&icn_lock, flags);
33704  }
33705  
33706  static void
33707 @@ -1154,7 +1131,7 @@
33708         icn_card *card = cards;
33709  
33710         while (card) {
33711 -               if (check_region(card->port, ICN_PORTLEN)) {
33712 +               if (!request_region(card->port, ICN_PORTLEN, "icn-isdn")) {
33713                         printk(KERN_WARNING
33714                                "icn: (%s) ports 0x%03x-0x%03x in use.\n",
33715                                CID,
33716 @@ -1163,6 +1140,7 @@
33717                 } else {
33718                         OUTB_P(0, ICN_RUN);     /* Reset Controller     */
33719                         OUTB_P(0, ICN_MAPRAM);  /* Disable RAM          */
33720 +                       release_region(card->port, ICN_PORTLEN);
33721                 }
33722                 card = card->next;
33723         }
33724 @@ -1184,22 +1162,22 @@
33725                         switch (c->arg) {
33726                                 case ICN_IOCTL_SETMMIO:
33727                                         if (dev.memaddr != (a & 0x0ffc000)) {
33728 -                                               if (check_mem_region(a & 0x0ffc000, 0x4000)) {
33729 +                                               if (!request_mem_region(a & 0x0ffc000, 0x4000, "icn-isdn (all cards)")) {
33730                                                         printk(KERN_WARNING
33731                                                                "icn: memory at 0x%08lx in use.\n",
33732                                                                a & 0x0ffc000);
33733                                                         return -EINVAL;
33734                                                 }
33735 +                                               release_mem_region(a & 0x0ffc000, 0x4000);
33736                                                 icn_stopallcards();
33737 -                                               save_flags(flags);
33738 -                                               cli();
33739 +                                               spin_lock_irqsave(&icn_lock, flags);
33740                                                 if (dev.mvalid) {
33741                                                         iounmap(dev.shmem);
33742                                                         release_mem_region(dev.memaddr, 0x4000);
33743                                                 }
33744                                                 dev.mvalid = 0;
33745                                                 dev.memaddr = a & 0x0ffc000;
33746 -                                               restore_flags(flags);
33747 +                                               spin_unlock_irqrestore(&icn_lock, flags);
33748                                                 printk(KERN_INFO
33749                                                        "icn: (%s) mmio set to 0x%08lx\n",
33750                                                        CID,
33751 @@ -1214,15 +1192,15 @@
33752                                             a == 0x308 || a == 0x318 || a == 0x328 || a == 0x338
33753                                             || a == 0x348 || a == 0x358 || a == 0x368) {
33754                                                 if (card->port != (unsigned short) a) {
33755 -                                                       if (check_region((unsigned short) a, ICN_PORTLEN)) {
33756 +                                                       if (!request_region((unsigned short) a, ICN_PORTLEN, "icn-isdn")) {
33757                                                                 printk(KERN_WARNING
33758                                                                        "icn: (%s) ports 0x%03x-0x%03x in use.\n",
33759                                                                        CID, (int) a, (int) a + ICN_PORTLEN);
33760                                                                 return -EINVAL;
33761                                                         }
33762 +                                                       release_region((unsigned short) a, ICN_PORTLEN);
33763                                                         icn_stopcard(card);
33764 -                                                       save_flags(flags);
33765 -                                                       cli();
33766 +                                                       spin_lock_irqsave(&icn_lock, flags);
33767                                                         if (card->rvalid)
33768                                                                 release_region(card->port, ICN_PORTLEN);
33769                                                         card->port = (unsigned short) a;
33770 @@ -1231,7 +1209,7 @@
33771                                                                 card->other->port = (unsigned short) a;
33772                                                                 card->other->rvalid = 0;
33773                                                         }
33774 -                                                       restore_flags(flags);
33775 +                                                       spin_unlock_irqrestore(&icn_lock, flags);
33776                                                         printk(KERN_INFO
33777                                                                "icn: (%s) port set to 0x%03x\n",
33778                                                         CID, card->port);
33779 diff -Nru a/drivers/isdn/sc/card.h b/drivers/isdn/sc/card.h
33780 --- a/drivers/isdn/sc/card.h    Mon Feb  4 23:49:25 2002
33781 +++ b/drivers/isdn/sc/card.h    Wed Sep  3 05:23:34 2003
33782 @@ -94,6 +94,7 @@
33783         int StartOnReset;               /* Indicates startproc after reset */
33784         int EngineUp;                   /* Indicates CommEngine Up */
33785         int trace_mode;                 /* Indicate if tracing is on */
33786 +       spinlock_t lock;                /* local lock */
33787  } board;
33788  
33789  #endif /* CARD_H */
33790 diff -Nru a/drivers/isdn/sc/command.c b/drivers/isdn/sc/command.c
33791 --- a/drivers/isdn/sc/command.c Sun Nov 17 15:08:01 2002
33792 +++ b/drivers/isdn/sc/command.c Wed Sep  3 05:43:20 2003
33793 @@ -419,14 +419,13 @@
33794  
33795         adapter[card]->EngineUp = 0;
33796  
33797 -       save_flags(flags);
33798 -       cli();
33799 +       spin_lock_irqsave(&adapter[card]->lock, flags);
33800         init_timer(&adapter[card]->reset_timer);
33801         adapter[card]->reset_timer.function = check_reset;
33802         adapter[card]->reset_timer.data = card;
33803         adapter[card]->reset_timer.expires = jiffies + CHECKRESET_TIME;
33804         add_timer(&adapter[card]->reset_timer);
33805 -       restore_flags(flags);
33806 +       spin_unlock_irqrestore(&adapter[card]->lock, flags);
33807  
33808         outb(0x1,adapter[card]->ioport[SFT_RESET]); 
33809  
33810 diff -Nru a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
33811 --- a/drivers/isdn/sc/init.c    Thu May 22 19:22:14 2003
33812 +++ b/drivers/isdn/sc/init.c    Wed Sep  3 05:33:51 2003
33813 @@ -97,11 +97,12 @@
33814                          * No, I/O Base has been provided
33815                          */
33816                         for (i = 0 ; i < MAX_IO_REGS - 1 ; i++) {
33817 -                               if(check_region(io[b] + i * 0x400, 1)) {
33818 +                               if(!request_region(io[b] + i * 0x400, 1, "sc test")) {
33819                                         pr_debug("check_region for 0x%x failed\n", io[b] + i * 0x400);
33820                                         io[b] = 0;
33821                                         break;
33822 -                               }
33823 +                               } else
33824 +                                       release_region(io[b] + i * 0x400, 1);
33825                         }
33826  
33827                         /*
33828 @@ -136,11 +137,12 @@
33829                                 last_base = i + IOBASE_OFFSET;
33830                                 pr_debug("  checking 0x%x...", i);
33831                                 for ( j = 0 ; j < MAX_IO_REGS - 1 ; j++) {
33832 -                                       if(check_region(i + j * 0x400, 1)) {
33833 +                                       if(!request_region(i + j * 0x400, 1, "sc test")) {
33834                                                 pr_debug("Failed\n");
33835                                                 found_io = 0;
33836                                                 break;
33837 -                                       }
33838 +                                       } else
33839 +                                               release_region(i + j * 0x400, 1);
33840                                 }       
33841  
33842                                 if(found_io) {
33843 @@ -177,9 +179,10 @@
33844                          * Just look for a signature and ID the
33845                          * board model
33846                          */
33847 -                       if(!check_region(ram[b], SRAM_PAGESIZE)) {
33848 -                               pr_debug("check_region for RAM base 0x%x succeeded\n", ram[b]);
33849 +                       if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) {
33850 +                               pr_debug("request_region for RAM base 0x%x succeeded\n", ram[b]);
33851                                 model = identify_board(ram[b], io[b]);
33852 +                               release_region(ram[b], SRAM_PAGESIZE);
33853                         }
33854                 }
33855                 else {
33856 @@ -189,9 +192,10 @@
33857                          */
33858                         for (i = SRAM_MIN ; i < SRAM_MAX ; i += SRAM_PAGESIZE) {
33859                                 pr_debug("Checking RAM address 0x%x...\n", i);
33860 -                               if(!check_region(i, SRAM_PAGESIZE)) {
33861 +                               if(request_region(i, SRAM_PAGESIZE, "sc test")) {
33862                                         pr_debug("  check_region succeeded\n");
33863                                         model = identify_board(i, io[b]);
33864 +                                       release_region(i, SRAM_PAGESIZE);
33865                                         if (model >= 0) {
33866                                                 pr_debug("  Identified a %s\n",
33867                                                         boardname[model]);
33868 @@ -201,7 +205,7 @@
33869                                         pr_debug("  Unidentifed or inaccessible\n");
33870                                         continue;
33871                                 }
33872 -                               pr_debug("  check_region failed\n");
33873 +                               pr_debug("  request failed\n");
33874                         }
33875                 }
33876                 /*
33877 @@ -310,6 +314,7 @@
33878                         continue;
33879                 }
33880                 memset(adapter[cinst], 0, sizeof(board));
33881 +               spin_lock_init(&adapter[cinst]->lock);
33882  
33883                 if(!register_isdn(interface)) {
33884                         /*
33885 diff -Nru a/drivers/isdn/sc/message.c b/drivers/isdn/sc/message.c
33886 --- a/drivers/isdn/sc/message.c Mon Sep  2 12:15:37 2002
33887 +++ b/drivers/isdn/sc/message.c Wed Sep  3 05:43:22 2003
33888 @@ -55,8 +55,7 @@
33889                 /*
33890                  * Map in the DPM to the base page and copy the message
33891                  */
33892 -               save_flags(flags);
33893 -               cli();
33894 +               spin_lock_irqsave(&adapter[card]->lock, flags);
33895                 outb((adapter[card]->shmem_magic >> 14) | 0x80,
33896                         adapter[card]->ioport[adapter[card]->shmem_pgport]); 
33897                 dpm = (DualPortMemory *) adapter[card]->rambase;
33898 @@ -64,8 +63,7 @@
33899                         MSG_LEN);
33900                 dpm->rsp_tail = (dpm->rsp_tail+1) % MAX_MESSAGES;
33901                 inb(adapter[card]->ioport[FIFO_READ]);
33902 -               restore_flags(flags);
33903 -               
33904 +               spin_unlock_irqrestore(&adapter[card]->lock, flags);
33905                 /*
33906                  * Tell the board that the message is received
33907                  */
33908 @@ -152,15 +150,14 @@
33909         /*
33910          * Disable interrupts and map in shared memory
33911          */
33912 -       save_flags(flags);
33913 -       cli();
33914 +       spin_lock_irqsave(&adapter[card]->lock, flags);
33915         outb((adapter[card]->shmem_magic >> 14) | 0x80,
33916                 adapter[card]->ioport[adapter[card]->shmem_pgport]); 
33917         dpm = (DualPortMemory *) adapter[card]->rambase;        /* Fix me */
33918         memcpy_toio(&(dpm->req_queue[dpm->req_head]),&sndmsg,MSG_LEN);
33919         dpm->req_head = (dpm->req_head+1) % MAX_MESSAGES;
33920         outb(sndmsg.sequence_no, adapter[card]->ioport[FIFO_WRITE]);
33921 -       restore_flags(flags);
33922 +       spin_unlock_irqrestore(&adapter[card]->lock, flags);
33923                 
33924         pr_debug("%s: Sent Message seq:%d pid:%d time:%d "
33925                         "cnt:%d (type,class,code):(%d,%d,%d) "
33926 diff -Nru a/drivers/isdn/sc/shmem.c b/drivers/isdn/sc/shmem.c
33927 --- a/drivers/isdn/sc/shmem.c   Mon Sep  2 12:15:37 2002
33928 +++ b/drivers/isdn/sc/shmem.c   Wed Sep  3 05:42:20 2003
33929 @@ -53,18 +53,17 @@
33930         /*
33931          * Block interrupts and load the page
33932          */
33933 -       save_flags(flags);
33934 -       cli();
33935 +       spin_lock_irqsave(&adapter[card]->lock, flags);
33936  
33937         outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
33938                 adapter[card]->ioport[adapter[card]->shmem_pgport]);
33939 -       pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
33940 -               ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
33941         ret = memcpy_toio(adapter[card]->rambase + 
33942                 ((unsigned long) dest % 0x4000), src, n);
33943 +       spin_unlock_irqrestore(&adapter[card]->lock, flags);
33944 +       pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
33945 +               ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
33946         pr_debug("%s: copying %d bytes from %#x to %#x\n",adapter[card]->devicename, n,
33947                  (unsigned long) src, adapter[card]->rambase + ((unsigned long) dest %0x4000));
33948 -       restore_flags(flags);
33949  
33950         return ret;
33951  }
33952 @@ -97,19 +96,18 @@
33953         /*
33954          * Block interrupts and load the page
33955          */
33956 -       save_flags(flags);
33957 -       cli();
33958 +       spin_lock_irqsave(&adapter[card]->lock, flags);
33959  
33960         outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
33961                 adapter[card]->ioport[adapter[card]->shmem_pgport]);
33962 -       pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
33963 -               ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
33964         ret = memcpy_fromio(dest,(void *)(adapter[card]->rambase + 
33965                 ((unsigned long) src % 0x4000)), n);
33966 +       spin_unlock_irqrestore(&adapter[card]->lock, flags);
33967 +       pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
33968 +               ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
33969  /*     pr_debug("%s: copying %d bytes from %#x to %#x\n",
33970                 adapter[card]->devicename, n,
33971                 adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */
33972 -       restore_flags(flags);
33973  
33974         return ret;
33975  }
33976 @@ -138,16 +136,15 @@
33977         /*
33978          * Block interrupts and load the page
33979          */
33980 -       save_flags(flags);
33981 -       cli();
33982 +       spin_lock_irqsave(&adapter[card]->lock, flags);
33983  
33984         outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
33985                 adapter[card]->ioport[adapter[card]->shmem_pgport]);
33986 -       pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
33987 -               ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
33988         ret = memset_io(adapter[card]->rambase + 
33989                 ((unsigned long) dest % 0x4000), c, n);
33990 -       restore_flags(flags);
33991 +       pr_debug("%s: set page to %#x\n",adapter[card]->devicename,
33992 +               ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
33993 +       spin_unlock_irqrestore(&adapter[card]->lock, flags);
33994  
33995         return ret;
33996  }
33997 diff -Nru a/drivers/isdn/sc/timer.c b/drivers/isdn/sc/timer.c
33998 --- a/drivers/isdn/sc/timer.c   Mon Sep  2 12:15:37 2002
33999 +++ b/drivers/isdn/sc/timer.c   Wed Sep  3 05:49:32 2003
34000 @@ -62,8 +62,7 @@
34001         /* Setup the io ports */
34002         setup_ports(card);
34003  
34004 -       save_flags(flags);
34005 -       cli();
34006 +       spin_lock_irqsave(&adapter[card]->lock, flags);
34007         outb(adapter[card]->ioport[adapter[card]->shmem_pgport],
34008                 (adapter[card]->shmem_magic>>14) | 0x80);       
34009         sig = (unsigned long) *((unsigned long *)(adapter[card]->rambase + SIG_OFFSET));        
34010 @@ -71,18 +70,16 @@
34011         /* check the signature */
34012         if(sig == SIGNATURE) {
34013                 flushreadfifo(card);
34014 -               restore_flags(flags);
34015 +               spin_unlock_irqrestore(&adapter[card]->lock, flags);
34016                 /* See if we need to do a startproc */
34017                 if (adapter[card]->StartOnReset)
34018                         startproc(card);
34019 -       }
34020 -       else  {
34021 +       } else  {
34022                 pr_debug("%s: No signature yet, waiting another %d jiffies.\n", 
34023                         adapter[card]->devicename, CHECKRESET_TIME);
34024                 mod_timer(&adapter[card]->reset_timer, jiffies+CHECKRESET_TIME);
34025 +               spin_unlock_irqrestore(&adapter[card]->lock, flags);
34026         }
34027 -       restore_flags(flags);
34028 -               
34029  }
34030  
34031  /*
34032 @@ -122,10 +119,9 @@
34033         adapter[card]->phystat = adapter[card]->nphystat;
34034  
34035         /* Reinitialize the timer */
34036 -       save_flags(flags);
34037 -       cli();
34038 +       spin_lock_irqsave(&adapter[card]->lock, flags);
34039         mod_timer(&adapter[card]->stat_timer, jiffies+CHECKSTAT_TIME);
34040 -       restore_flags(flags);
34041 +       spin_unlock_irqrestore(&adapter[card]->lock, flags);
34042  
34043         /* Send a new cePhyStatus message */
34044         sendmessage(card, CEPID,ceReqTypePhy,ceReqClass2,
34045 @@ -146,11 +142,5 @@
34046   */
34047  void trace_timer(unsigned long data)
34048  {
34049 -       unsigned long flags;
34050 -
34051 -       /*
34052 -        * Disable interrupts and swap the first page
34053 -        */
34054 -       save_flags(flags);
34055 -       cli();
34056 +       /* not implemented */
34057  }
34058 diff -Nru a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
34059 --- a/drivers/macintosh/adb.c   Sat Jun  7 00:45:03 2003
34060 +++ b/drivers/macintosh/adb.c   Tue Aug 26 09:25:41 2003
34061 @@ -712,7 +712,7 @@
34062  {
34063         struct adbdev_state *state;
34064  
34065 -       if (minor(inode->i_rdev) > 0 || adb_controller == NULL)
34066 +       if (iminor(inode) > 0 || adb_controller == NULL)
34067                 return -ENXIO;
34068         state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
34069         if (state == 0)
34070 diff -Nru a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
34071 --- a/drivers/macintosh/macio_asic.c    Sat Aug 16 11:47:51 2003
34072 +++ b/drivers/macintosh/macio_asic.c    Tue Aug 26 06:35:38 2003
34073 @@ -23,6 +23,8 @@
34074  #include <asm/prom.h>
34075  #include <asm/pci-bridge.h>
34076  
34077 +static struct macio_chip      *macio_on_hold;
34078 +
34079  static int
34080  macio_bus_match(struct device *dev, struct device_driver *drv) 
34081  {
34082 @@ -36,21 +38,27 @@
34083         return of_match_device(matches, &macio_dev->ofdev) != NULL;
34084  }
34085  
34086 -struct bus_type macio_bus_type = {
34087 -       name:   "macio",
34088 -       match:  macio_bus_match,
34089 -};
34090 +struct macio_dev *macio_dev_get(struct macio_dev *dev)
34091 +{
34092 +       struct device *tmp;
34093  
34094 -static int __init
34095 -macio_bus_driver_init(void)
34096 +       if (!dev)
34097 +               return NULL;
34098 +       tmp = get_device(&dev->ofdev.dev);
34099 +       if (tmp)
34100 +               return to_macio_device(tmp);
34101 +       else
34102 +               return NULL;
34103 +}
34104 +
34105 +void macio_dev_put(struct macio_dev *dev)
34106  {
34107 -       return bus_register(&macio_bus_type);
34108 +       if (dev)
34109 +               put_device(&dev->ofdev.dev);
34110  }
34111  
34112 -postcore_initcall(macio_bus_driver_init);
34113  
34114 -static int
34115 -macio_device_probe(struct device *dev)
34116 +static int macio_device_probe(struct device *dev)
34117  {
34118         int error = -ENODEV;
34119         struct macio_driver *drv;
34120 @@ -63,55 +71,89 @@
34121         if (!drv->probe)
34122                 return error;
34123  
34124 -/*     if (!try_module_get(driver->owner)) {
34125 -               printk(KERN_ERR "Can't get a module reference for %s\n", driver->name);
34126 -               return error;
34127 -       }
34128 -*/
34129 +       macio_dev_get(macio_dev);
34130 +
34131         match = of_match_device(drv->match_table, &macio_dev->ofdev);
34132         if (match)
34133                 error = drv->probe(macio_dev, match);
34134 -/*
34135 -       module_put(driver->owner);
34136 -*/     
34137 +       if (error)
34138 +               macio_dev_put(macio_dev);
34139 +
34140         return error;
34141  }
34142  
34143 -static int
34144 -macio_device_remove(struct device *dev)
34145 +static int macio_device_remove(struct device *dev)
34146  {
34147         struct macio_dev * macio_dev = to_macio_device(dev);
34148         struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
34149  
34150         if (drv && drv->remove)
34151                 drv->remove(macio_dev);
34152 +       macio_dev_put(macio_dev);
34153 +
34154         return 0;
34155  }
34156  
34157 -static int
34158 -macio_device_suspend(struct device *dev, u32 state, u32 level)
34159 +static int macio_device_suspend(struct device *dev, u32 state)
34160  {
34161         struct macio_dev * macio_dev = to_macio_device(dev);
34162 -       struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
34163 +       struct macio_driver * drv;
34164         int error = 0;
34165  
34166 -       if (drv && drv->suspend)
34167 -               error = drv->suspend(macio_dev, state, level);
34168 +       if (macio_dev->ofdev.dev.driver == NULL)
34169 +               return 0;
34170 +       drv = to_macio_driver(macio_dev->ofdev.dev.driver);
34171 +       if (drv->suspend)
34172 +               error = drv->suspend(macio_dev, state);
34173         return error;
34174  }
34175  
34176 -static int
34177 -macio_device_resume(struct device * dev, u32 level)
34178 +static int macio_device_resume(struct device * dev)
34179  {
34180         struct macio_dev * macio_dev = to_macio_device(dev);
34181 -       struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
34182 +       struct macio_driver * drv;
34183         int error = 0;
34184  
34185 -       if (drv && drv->resume)
34186 -               error = drv->resume(macio_dev, level);
34187 +       if (macio_dev->ofdev.dev.driver == NULL)
34188 +               return 0;
34189 +       drv = to_macio_driver(macio_dev->ofdev.dev.driver);
34190 +       if (drv->resume)
34191 +               error = drv->resume(macio_dev);
34192         return error;
34193  }
34194  
34195 +struct bus_type macio_bus_type = {
34196 +       .name   = "macio",
34197 +       .match  = macio_bus_match,
34198 +       .suspend        = macio_device_suspend,
34199 +       .resume = macio_device_resume,
34200 +};
34201 +
34202 +static int __init
34203 +macio_bus_driver_init(void)
34204 +{
34205 +       return bus_register(&macio_bus_type);
34206 +}
34207 +
34208 +postcore_initcall(macio_bus_driver_init);
34209 +
34210 +
34211 +/**
34212 + * macio_release_dev - free a macio device structure when all users of it are finished.
34213 + * @dev: device that's been disconnected
34214 + *
34215 + * Will be called only by the device core when all users of this macio device are
34216 + * done. This currently means never as we don't hot remove any macio device yet,
34217 + * though that will happen with mediabay based devices in a later implementation.
34218 + */
34219 +static void macio_release_dev(struct device *dev)
34220 +{
34221 +       struct macio_dev *mdev;
34222 +
34223 +        mdev = to_macio_device(dev);
34224 +       kfree(mdev);
34225 +}
34226 +
34227  /**
34228   * macio_add_one_device - Add one device from OF node to the device tree
34229   * @chip: pointer to the macio_chip holding the device
34230 @@ -121,13 +163,15 @@
34231   * When media-bay is changed to hotswap drivers, this function will
34232   * be exposed to the bay driver some way...
34233   */
34234 -static struct macio_dev *
34235 -macio_add_one_device(struct macio_chip *chip, struct device *parent,
34236 +static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct device *parent,
34237                      struct device_node *np, struct macio_dev *in_bay)
34238  {
34239         struct macio_dev *dev;
34240         u32 *reg;
34241         
34242 +       if (np == NULL)
34243 +               return NULL;
34244 +
34245         dev = kmalloc(sizeof(*dev), GFP_KERNEL);
34246         if (!dev)
34247                 return NULL;
34248 @@ -140,6 +184,7 @@
34249         dev->ofdev.dev.dma_mask = &dev->ofdev.dma_mask;
34250         dev->ofdev.dev.parent = parent;
34251         dev->ofdev.dev.bus = &macio_bus_type;
34252 +       dev->ofdev.dev.release = macio_release_dev;
34253  
34254         /* MacIO itself has a different reg, we use it's PCI base */
34255         if (np == chip->of_node) {
34256 @@ -164,8 +209,7 @@
34257         return dev;
34258  }
34259  
34260 -static int
34261 -macio_skip_device(struct device_node *np)
34262 +static int macio_skip_device(struct device_node *np)
34263  {
34264         if (strncmp(np->name, "battery", 7) == 0)
34265                 return 1;
34266 @@ -185,10 +229,9 @@
34267   * For now, childs of media-bay are added now as well. This will
34268   * change rsn though.
34269   */
34270 -static void
34271 -macio_pci_add_devices(struct macio_chip *chip)
34272 +static void macio_pci_add_devices(struct macio_chip *chip)
34273  {
34274 -       struct device_node *np;
34275 +       struct device_node *np, *pnode;
34276         struct macio_dev *rdev, *mdev, *mbdev = NULL, *sdev = NULL;
34277         struct device *parent = NULL;
34278         
34279 @@ -196,16 +239,23 @@
34280  #ifdef CONFIG_PCI
34281         if (chip->lbus.pdev)
34282                 parent = &chip->lbus.pdev->dev;
34283 -#endif         
34284 -       rdev = macio_add_one_device(chip, parent, chip->of_node, NULL);
34285 +#endif
34286 +       pnode = of_node_get(chip->of_node);
34287 +       if (pnode == NULL)
34288 +               return;
34289 +
34290 +       rdev = macio_add_one_device(chip, parent, pnode, NULL);
34291         if (rdev == NULL)
34292                 return;
34293  
34294         /* First scan 1st level */
34295 -       for (np = chip->of_node->child; np != NULL; np = np->sibling) {
34296 +       for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) {
34297                 if (!macio_skip_device(np)) {
34298 +                       of_node_get(np);
34299                         mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL);
34300 -                       if (strncmp(np->name, "media-bay", 9) == 0)
34301 +                       if (mdev == NULL)
34302 +                               of_node_put(np);
34303 +                       else if (strncmp(np->name, "media-bay", 9) == 0)
34304                                 mbdev = mdev;
34305                         else if (strncmp(np->name, "escc", 4) == 0)
34306                                 sdev = mdev;
34307 @@ -213,17 +263,21 @@
34308         }
34309  
34310         /* Add media bay devices if any */
34311 -       if (mbdev) {
34312 -               for (np = mbdev->ofdev.node->child; np != NULL; np = np->sibling)
34313 -                       if (!macio_skip_device(np))
34314 -                               macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev);
34315 -       }
34316 +       if (mbdev)
34317 +               for (np = NULL; (np = of_get_next_child(mbdev->ofdev.node, np)) != NULL;)
34318 +                       if (!macio_skip_device(np)) {
34319 +                               of_node_get(np);
34320 +                               if (macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev) == NULL)
34321 +                                       of_node_put(np);
34322 +                       }
34323         /* Add serial ports if any */
34324 -       if (sdev) {
34325 -               for (np = sdev->ofdev.node->child; np != NULL; np = np->sibling)
34326 -                       if (!macio_skip_device(np))
34327 -                               macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL);
34328 -       }
34329 +       if (sdev)
34330 +               for (np = NULL; (np = of_get_next_child(sdev->ofdev.node, np)) != NULL;)
34331 +                       if (!macio_skip_device(np)) {
34332 +                               of_node_get(np);
34333 +                               if (macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL) == NULL)
34334 +                                       of_node_put(np);
34335 +                       }
34336  }
34337  
34338  
34339 @@ -231,8 +285,7 @@
34340   * macio_register_driver - Registers a new MacIO device driver
34341   * @drv: pointer to the driver definition structure
34342   */
34343 -int
34344 -macio_register_driver(struct macio_driver *drv)
34345 +int macio_register_driver(struct macio_driver *drv)
34346  {
34347         int count = 0;
34348  
34349 @@ -240,8 +293,6 @@
34350         drv->driver.name = drv->name;
34351         drv->driver.bus = &macio_bus_type;
34352         drv->driver.probe = macio_device_probe;
34353 -       drv->driver.resume = macio_device_resume;
34354 -       drv->driver.suspend = macio_device_suspend;
34355         drv->driver.remove = macio_device_remove;
34356  
34357         /* register with core */
34358 @@ -253,16 +304,14 @@
34359   * macio_unregister_driver - Unregisters a new MacIO device driver
34360   * @drv: pointer to the driver definition structure
34361   */
34362 -void
34363 -macio_unregister_driver(struct macio_driver *drv)
34364 +void macio_unregister_driver(struct macio_driver *drv)
34365  {
34366         driver_unregister(&drv->driver);
34367  }
34368  
34369  #ifdef CONFIG_PCI
34370  
34371 -static int __devinit
34372 -macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
34373 +static int __devinit macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
34374  {
34375         struct device_node* np;
34376         struct macio_chip* chip;
34377 @@ -270,19 +319,27 @@
34378         if (ent->vendor != PCI_VENDOR_ID_APPLE)
34379                 return -ENODEV;
34380  
34381 +       /* Note regarding refcounting: We assume pci_device_to_OF_node() is ported
34382 +        * to new OF APIs and returns a node with refcount incremented. This isn't
34383 +        * the case today, but on the other hand ppc32 doesn't do refcounting. This
34384 +        * will have to be fixed when going to ppc64. --BenH.
34385 +        */
34386         np = pci_device_to_OF_node(pdev);
34387         if (np == NULL)
34388                 return -ENODEV;
34389  
34390 +       /* We also assume that pmac_feature will have done a get() on nodes stored
34391 +        * in the macio chips array
34392 +        */
34393         chip = macio_find(np, macio_unknown);
34394 +               of_node_put(np);
34395         if (chip == NULL)
34396                 return -ENODEV;
34397  
34398 -       /* XXX Need locking */
34399 +       /* XXX Need locking ??? */
34400         if (chip->lbus.pdev == NULL) {
34401                 chip->lbus.pdev = pdev;
34402                 chip->lbus.chip = chip;
34403 -//             INIT_LIST_HEAD(&chip->lbus.devices);
34404                 pci_set_drvdata(pdev, &chip->lbus);
34405                 pci_set_master(pdev);
34406         }
34407 @@ -290,13 +347,28 @@
34408         printk(KERN_INFO "MacIO PCI driver attached to %s chipset\n",
34409                 chip->name);
34410  
34411 +       /*
34412 +        * HACK ALERT: The WallStreet PowerBook and some OHare based machines
34413 +        * have 2 macio ASICs. I must probe the "main" one first or IDE ordering
34414 +        * will be incorrect. So I put on "hold" the second one since it seem to
34415 +        * appear first on PCI
34416 +        */
34417 +       if (chip->type == macio_gatwick || chip->type == macio_ohareII)
34418 +               if (macio_chips[0].lbus.pdev == NULL) {
34419 +                       macio_on_hold = chip;
34420 +                       return 0;
34421 +               }
34422 +
34423         macio_pci_add_devices(chip);
34424 +       if (macio_on_hold && macio_chips[0].lbus.pdev != NULL) {
34425 +               macio_pci_add_devices(macio_on_hold);
34426 +               macio_on_hold = NULL;
34427 +       }
34428  
34429         return 0;
34430  }
34431  
34432 -static void __devexit
34433 -macio_pci_remove(struct pci_dev* pdev)
34434 +static void __devexit macio_pci_remove(struct pci_dev* pdev)
34435  {
34436         panic("removing of macio-asic not supported !\n");
34437  }
34438 @@ -306,10 +378,10 @@
34439   * will then decide wether it applies or not
34440   */
34441  static const struct pci_device_id __devinitdata pci_ids [] = { {
34442 -       .vendor =       PCI_VENDOR_ID_APPLE,
34443 -       .device =       PCI_ANY_ID,
34444 -       .subvendor =    PCI_ANY_ID,
34445 -       .subdevice =    PCI_ANY_ID,
34446 +       .vendor         = PCI_VENDOR_ID_APPLE,
34447 +       .device         = PCI_ANY_ID,
34448 +       .subvendor      = PCI_ANY_ID,
34449 +       .subdevice      = PCI_ANY_ID,
34450  
34451         }, { /* end: all zeroes */ }
34452  };
34453 @@ -317,17 +389,16 @@
34454  
34455  /* pci driver glue; this is a "new style" PCI driver module */
34456  static struct pci_driver macio_pci_driver = {
34457 -       .name =         (char *) "macio",
34458 -       .id_table =     pci_ids,
34459 +       .name           = (char *) "macio",
34460 +       .id_table       = pci_ids,
34461  
34462 -       .probe =        macio_pci_probe,
34463 -       .remove =       macio_pci_remove,
34464 +       .probe          = macio_pci_probe,
34465 +       .remove         = macio_pci_remove,
34466  };
34467  
34468  #endif /* CONFIG_PCI */
34469  
34470 -static int __init
34471 -macio_module_init (void) 
34472 +static int __init macio_module_init (void) 
34473  {
34474  #ifdef CONFIG_PCI
34475         int rc;
34476 @@ -339,17 +410,9 @@
34477         return 0;
34478  }
34479  
34480 -/*
34481 -static void __exit
34482 -macio_module_cleanup (void) 
34483 -{      
34484 -#ifdef CONFIG_PCI
34485 -       pci_unregister_driver(&macio_pci_driver);
34486 -#endif
34487 -}
34488 -module_exit(macio_module_cleanup);
34489 -*/
34490  module_init(macio_module_init);
34491  
34492  EXPORT_SYMBOL(macio_register_driver);
34493  EXPORT_SYMBOL(macio_unregister_driver);
34494 +EXPORT_SYMBOL(macio_dev_get);
34495 +EXPORT_SYMBOL(macio_dev_put);
34496 diff -Nru a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
34497 --- a/drivers/macintosh/mediabay.c      Sat Mar 22 01:11:14 2003
34498 +++ b/drivers/macintosh/mediabay.c      Mon Aug 25 09:51:43 2003
34499 @@ -37,15 +37,7 @@
34500  #include <linux/adb.h>
34501  #include <linux/pmu.h>
34502  
34503 -#ifdef CONFIG_PMAC_PBOOK
34504 -static int mb_notify_sleep(struct pmu_sleep_notifier *self, int when);
34505 -static struct pmu_sleep_notifier mb_sleep_notifier = {
34506 -       mb_notify_sleep,
34507 -       SLEEP_LEVEL_MEDIABAY,
34508 -};
34509 -#endif
34510  
34511 -#undef MB_USE_INTERRUPTS
34512  #define MB_DEBUG
34513  #define MB_IGNORE_SIGNALS
34514  
34515 @@ -55,13 +47,6 @@
34516  #define MBDBG(fmt, arg...)     do { } while (0)
34517  #endif
34518  
34519 -/* Type of media bay */
34520 -enum {
34521 -       mb_ohare,
34522 -       mb_heathrow,
34523 -       mb_keylargo
34524 -};
34525 -
34526  #define MB_FCR32(bay, r)       ((bay)->base + ((r) >> 2))
34527  #define MB_FCR8(bay, r)                (((volatile u8*)((bay)->base)) + (r))
34528  
34529 @@ -76,11 +61,12 @@
34530  
34531  struct mb_ops {
34532         char*   name;
34533 -       u8      (*content)(struct media_bay_info* bay);
34534 -       void    (*power)(struct media_bay_info* bay, int on_off);
34535 -       int     (*setup_bus)(struct media_bay_info* bay, u8 device_id);
34536 -       void    (*un_reset)(struct media_bay_info* bay);
34537 -       void    (*un_reset_ide)(struct media_bay_info* bay);
34538 +       void    (*init)(struct media_bay_info *bay);
34539 +       u8      (*content)(struct media_bay_info *bay);
34540 +       void    (*power)(struct media_bay_info *bay, int on_off);
34541 +       int     (*setup_bus)(struct media_bay_info *bay, u8 device_id);
34542 +       void    (*un_reset)(struct media_bay_info *bay);
34543 +       void    (*un_reset_ide)(struct media_bay_info *bay);
34544  };
34545  
34546  struct media_bay_info {
34547 @@ -90,11 +76,12 @@
34548         int                             last_value;
34549         int                             value_count;
34550         int                             timer;
34551 -       struct device_node*             dev_node;
34552 -       int                             mb_type;
34553 +       struct macio_dev                *mdev;
34554         struct mb_ops*                  ops;
34555         int                             index;
34556         int                             cached_gpio;
34557 +       int                             sleeping;
34558 +       struct semaphore                lock;
34559  #ifdef CONFIG_BLK_DEV_IDE
34560         unsigned long                   cd_base;
34561         int                             cd_index;
34562 @@ -111,13 +98,13 @@
34563  #ifdef CONFIG_BLK_DEV_IDE
34564  /* check the busy bit in the media-bay ide interface
34565     (assumes the media-bay contains an ide device) */
34566 -#define MB_IDE_READY(i)        ((inb(media_bays[i].cd_base + 0x70) & 0x80) == 0)
34567 +#define MB_IDE_READY(i)        ((readb(media_bays[i].cd_base + 0x70) & 0x80) == 0)
34568  #endif
34569  
34570  /* Note: All delays are not in milliseconds and converted to HZ relative
34571   * values by the macro below
34572   */
34573 -#define MS_TO_HZ(ms)   ((ms * HZ) / 1000)
34574 +#define MS_TO_HZ(ms)   ((ms * HZ + 999) / 1000)
34575  
34576  /*
34577   * Consider the media-bay ID value stable if it is the same for
34578 @@ -352,38 +339,37 @@
34579         MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
34580  }
34581  
34582 -static void __pmac
34583 -heathrow_mb_un_reset(struct media_bay_info* bay)
34584 +static void __pmac keylargo_mb_init(struct media_bay_info *bay)
34585 +{
34586 +       MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
34587 +}
34588 +
34589 +static void __pmac heathrow_mb_un_reset(struct media_bay_info* bay)
34590  {
34591         MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
34592  }
34593  
34594 -static void __pmac
34595 -keylargo_mb_un_reset(struct media_bay_info* bay)
34596 +static void __pmac keylargo_mb_un_reset(struct media_bay_info* bay)
34597  {
34598         MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
34599  }
34600  
34601 -static void __pmac
34602 -ohare_mb_un_reset_ide(struct media_bay_info* bay)
34603 +static void __pmac ohare_mb_un_reset_ide(struct media_bay_info* bay)
34604  {
34605         MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
34606  }
34607  
34608 -static void __pmac
34609 -heathrow_mb_un_reset_ide(struct media_bay_info* bay)
34610 +static void __pmac heathrow_mb_un_reset_ide(struct media_bay_info* bay)
34611  {
34612         MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
34613  }
34614  
34615 -static void __pmac
34616 -keylargo_mb_un_reset_ide(struct media_bay_info* bay)
34617 +static void __pmac keylargo_mb_un_reset_ide(struct media_bay_info* bay)
34618  {
34619         MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
34620  }
34621  
34622 -static inline void __pmac
34623 -set_mb_power(struct media_bay_info* bay, int onoff)
34624 +static inline void __pmac set_mb_power(struct media_bay_info* bay, int onoff)
34625  {
34626         /* Power up up and assert the bay reset line */
34627         if (onoff) {
34628 @@ -399,8 +385,7 @@
34629         bay->timer = MS_TO_HZ(MB_POWER_DELAY);
34630  }
34631  
34632 -static void __pmac
34633 -poll_media_bay(struct media_bay_info* bay)
34634 +static void __pmac poll_media_bay(struct media_bay_info* bay)
34635  {
34636         int id = bay->ops->content(bay);
34637  
34638 @@ -429,15 +414,13 @@
34639         }
34640  }
34641  
34642 -int __pmac
34643 -check_media_bay(struct device_node *which_bay, int what)
34644 +int __pmac check_media_bay(struct device_node *which_bay, int what)
34645  {
34646  #ifdef CONFIG_BLK_DEV_IDE
34647         int     i;
34648  
34649         for (i=0; i<media_bay_count; i++)
34650 -               if (which_bay == media_bays[i].dev_node)
34651 -               {
34652 +               if (media_bays[i].mdev && which_bay == media_bays[i].mdev->ofdev.node) {
34653                         if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
34654                                 return 0;
34655                         media_bays[i].cd_index = -1;
34656 @@ -447,15 +430,13 @@
34657         return -ENODEV;
34658  }
34659  
34660 -int __pmac
34661 -check_media_bay_by_base(unsigned long base, int what)
34662 +int __pmac check_media_bay_by_base(unsigned long base, int what)
34663  {
34664  #ifdef CONFIG_BLK_DEV_IDE
34665         int     i;
34666  
34667         for (i=0; i<media_bay_count; i++)
34668 -               if (base == media_bays[i].cd_base)
34669 -               {
34670 +               if (media_bays[i].mdev && base == media_bays[i].cd_base) {
34671                         if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
34672                                 return 0;
34673                         media_bays[i].cd_index = -1;
34674 @@ -466,42 +447,47 @@
34675         return -ENODEV;
34676  }
34677  
34678 -int __pmac
34679 -media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
34680 +int __pmac media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
34681         int irq, int index)
34682  {
34683  #ifdef CONFIG_BLK_DEV_IDE
34684         int     i;
34685  
34686 -       for (i=0; i<media_bay_count; i++)
34687 -               if (which_bay == media_bays[i].dev_node)
34688 -               {
34689 +       for (i=0; i<media_bay_count; i++) {
34690 +               struct media_bay_info* bay = &media_bays[i];
34691 +
34692 +               if (bay->mdev && which_bay == bay->mdev->ofdev.node) {
34693                         int timeout = 5000;
34694                         
34695 -                       media_bays[i].cd_base   = base;
34696 -                       media_bays[i].cd_irq    = irq;
34697 +                       down(&bay->lock);
34698  
34699 -                       if ((MB_CD != media_bays[i].content_id) || media_bays[i].state != mb_up)
34700 -                               return 0;
34701 +                       bay->cd_base    = base;
34702 +                       bay->cd_irq     = irq;
34703  
34704 -                       printk(KERN_DEBUG "Registered ide %d for media bay %d\n", index, i);
34705 +                       if ((MB_CD != bay->content_id) || bay->state != mb_up) {
34706 +                               up(&bay->lock);
34707 +                               return 0;
34708 +                       }
34709 +                       printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i);
34710                         do {
34711                                 if (MB_IDE_READY(i)) {
34712 -                                       media_bays[i].cd_index  = index;
34713 +                                       bay->cd_index   = index;
34714 +                                       up(&bay->lock);
34715                                         return 0;
34716                                 }
34717                                 mdelay(1);
34718                         } while(--timeout);
34719                         printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i);
34720 +                       up(&bay->lock);
34721                         return -ENODEV;
34722                 }
34723 -#endif
34724 +       }
34725 +#endif /* CONFIG_BLK_DEV_IDE */
34726         
34727         return -ENODEV;
34728  }
34729  
34730 -static void __pmac
34731 -media_bay_step(int i)
34732 +static void __pmac media_bay_step(int i)
34733  {
34734         struct media_bay_info* bay = &media_bays[i];
34735  
34736 @@ -567,6 +553,7 @@
34737                         if (bay->cd_index < 0) {
34738                                 hw_regs_t hw;
34739  
34740 +                               printk("mediabay %d, registering IDE...\n", i);
34741                                 pmu_suspend();
34742                                 ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL);
34743                                 hw.irq = bay->cd_irq;
34744 @@ -580,13 +567,15 @@
34745                                 printk("IDE register error\n");
34746                                 set_mb_power(bay, 0);
34747                         } else {
34748 -                               printk(KERN_DEBUG "media-bay %d is ide %d\n", i, bay->cd_index);
34749 +                               printk(KERN_DEBUG "media-bay %d is ide%d\n", i, bay->cd_index);
34750                                 MBDBG("mediabay %d IDE ready\n", i);
34751                         }
34752                         break;
34753 -               }
34754 +               } else if (bay->timer > 0)
34755 +                       bay->timer--;
34756                 if (bay->timer == 0) {
34757 -                       printk("\nIDE Timeout in bay %d !\n", i);
34758 +                       printk("\nIDE Timeout in bay %d !, IDE state is: 0x%02x\n",
34759 +                              i, readb(bay->cd_base + 0x70));
34760                         MBDBG("mediabay%d: nIDE Timeout !\n", i);
34761                         set_mb_power(bay, 0);
34762                 }
34763 @@ -623,8 +612,7 @@
34764   * with the IDE driver.  It needs to be a thread because
34765   * ide_register can't be called from interrupt context.
34766   */
34767 -static int __pmac
34768 -media_bay_task(void *x)
34769 +static int __pmac media_bay_task(void *x)
34770  {
34771         int     i;
34772  
34773 @@ -634,75 +622,140 @@
34774  #endif
34775  
34776         for (;;) {
34777 -               for (i = 0; i < media_bay_count; ++i)
34778 -                       media_bay_step(i);
34779 +               for (i = 0; i < media_bay_count; ++i) {
34780 +                       down(&media_bays[i].lock);
34781 +                       if (!media_bays[i].sleeping)
34782 +                               media_bay_step(i);
34783 +                       up(&media_bays[i].lock);
34784 +               }
34785  
34786                 current->state = TASK_INTERRUPTIBLE;
34787 -               schedule_timeout(1);
34788 +               schedule_timeout(MS_TO_HZ(10));
34789                 if (signal_pending(current))
34790                         return 0;
34791         }
34792  }
34793  
34794 -#ifdef MB_USE_INTERRUPTS
34795 -static void __pmac
34796 -media_bay_intr(int irq, void *devid, struct pt_regs *regs)
34797 -{
34798 -}
34799 -#endif
34800 -
34801 -#ifdef CONFIG_PMAC_PBOOK
34802 -/*
34803 - * notify clients before sleep and reset bus afterwards
34804 - */
34805 -int __pmac
34806 -mb_notify_sleep(struct pmu_sleep_notifier *self, int when)
34807 +static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_match *match)
34808  {
34809         struct media_bay_info* bay;
34810 +       volatile u32 *regbase;
34811 +       struct device_node *ofnode;
34812         int i;
34813 +
34814 +       ofnode = mdev->ofdev.node;
34815 +
34816 +       if (!request_OF_resource(ofnode, 0, NULL))
34817 +               return -ENXIO;
34818 +
34819 +       /* Media bay registers are located at the beginning of the
34820 +         * mac-io chip, we get the parent address for now (hrm...)
34821 +         */
34822 +       if (ofnode->parent->n_addrs == 0)
34823 +               return -ENODEV;
34824 +       regbase = (volatile u32 *)ioremap(ofnode->parent->addrs[0].address, 0x100);
34825 +       if (regbase == NULL) {
34826 +               release_OF_resource(ofnode, 0);
34827 +               return -ENOMEM;
34828 +       }
34829         
34830 -       switch (when) {
34831 -       case PBOOK_SLEEP_REQUEST:
34832 -       case PBOOK_SLEEP_REJECT:
34833 -               break;
34834 -               
34835 -       case PBOOK_SLEEP_NOW:
34836 -               for (i=0; i<media_bay_count; i++) {
34837 -                       bay = &media_bays[i];
34838 -                       set_mb_power(bay, 0);
34839 -                       mdelay(10);
34840 -               }
34841 -               break;
34842 -       case PBOOK_WAKE:
34843 -               for (i=0; i<media_bay_count; i++) {
34844 -                       bay = &media_bays[i];
34845 -                       /* We re-enable the bay using it's previous content
34846 -                          only if it did not change. Note those bozo timings,
34847 -                          they seem to help the 3400 get it right.
34848 -                        */
34849 -                       /* Force MB power to 0 */
34850 -                       set_mb_power(bay, 0);
34851 -                       mdelay(MB_POWER_DELAY);
34852 -                       if (bay->ops->content(bay) != bay->content_id)
34853 -                               continue;
34854 -                       set_mb_power(bay, 1);
34855 -                       bay->last_value = bay->content_id;
34856 -                       bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
34857 -                       bay->timer = MS_TO_HZ(MB_POWER_DELAY);
34858 -#ifdef CONFIG_BLK_DEV_IDE
34859 -                       bay->cd_retry = 0;
34860 -#endif
34861 -                       do {
34862 -                               mdelay(1000/HZ);
34863 -                               media_bay_step(i);
34864 -                       } while((media_bays[i].state != mb_empty) &&
34865 -                               (media_bays[i].state != mb_up));
34866 -               }
34867 -               break;
34868 +       i = media_bay_count++;
34869 +       bay = &media_bays[i];
34870 +       bay->mdev = mdev;
34871 +       bay->base = regbase;
34872 +       bay->index = i;
34873 +       bay->ops = match->data;
34874 +       bay->sleeping = 0;
34875 +       init_MUTEX(&bay->lock);
34876 +
34877 +       /* Init HW probing */
34878 +       if (bay->ops->init)
34879 +               bay->ops->init(bay);
34880 +
34881 +       printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", i, bay->ops->name);
34882 +
34883 +       /* Force an immediate detect */
34884 +       set_mb_power(bay, 0);
34885 +       set_current_state(TASK_UNINTERRUPTIBLE);
34886 +       schedule_timeout(MS_TO_HZ(MB_POWER_DELAY));
34887 +       bay->content_id = MB_NO;
34888 +       bay->last_value = bay->ops->content(bay);
34889 +       bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
34890 +       bay->state = mb_empty;
34891 +       do {
34892 +               set_current_state(TASK_UNINTERRUPTIBLE);
34893 +               schedule_timeout(MS_TO_HZ(10));
34894 +               media_bay_step(i);
34895 +       } while((bay->state != mb_empty) &&
34896 +               (bay->state != mb_up));
34897 +
34898 +       /* Mark us ready by filling our mdev data */
34899 +       dev_set_drvdata(&mdev->ofdev.dev, bay);
34900 +
34901 +       /* Startup kernel thread */
34902 +       if (i == 0)
34903 +               kernel_thread(media_bay_task, NULL,
34904 +                             CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
34905 +
34906 +       return 0;
34907 +
34908 +}
34909 +
34910 +static int __pmac media_bay_suspend(struct macio_dev *mdev, u32 state)
34911 +{
34912 +       struct media_bay_info   *bay = dev_get_drvdata(&mdev->ofdev.dev);
34913 +
34914 +       if (state != mdev->ofdev.dev.power_state && state >= 2) {
34915 +               down(&bay->lock);
34916 +               bay->sleeping = 1;
34917 +               set_mb_power(bay, 0);
34918 +               up(&bay->lock);
34919 +               set_current_state(TASK_UNINTERRUPTIBLE);
34920 +               schedule_timeout(MS_TO_HZ(10));
34921 +               mdev->ofdev.dev.power_state = state;
34922         }
34923 -       return PBOOK_SLEEP_OK;
34924 +       return 0;
34925 +}
34926 +
34927 +static int __pmac media_bay_resume(struct macio_dev *mdev)
34928 +{
34929 +       struct media_bay_info   *bay = dev_get_drvdata(&mdev->ofdev.dev);
34930 +
34931 +       if (mdev->ofdev.dev.power_state != 0) {
34932 +               mdev->ofdev.dev.power_state = 0;
34933 +
34934 +               /* We re-enable the bay using it's previous content
34935 +                  only if it did not change. Note those bozo timings,
34936 +                  they seem to help the 3400 get it right.
34937 +                */
34938 +               /* Force MB power to 0 */
34939 +               down(&bay->lock);
34940 +               set_mb_power(bay, 0);
34941 +               set_current_state(TASK_UNINTERRUPTIBLE);
34942 +               schedule_timeout(MS_TO_HZ(MB_POWER_DELAY));
34943 +               if (bay->ops->content(bay) != bay->content_id) {
34944 +                       printk("mediabay%d: content changed during sleep...\n", bay->index);
34945 +                       up(&bay->lock);
34946 +                       return 0;
34947 +               }
34948 +               set_mb_power(bay, 1);
34949 +               bay->last_value = bay->content_id;
34950 +               bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
34951 +               bay->timer = MS_TO_HZ(MB_POWER_DELAY);
34952 +#ifdef CONFIG_BLK_DEV_IDE
34953 +               bay->cd_retry = 0;
34954 +#endif
34955 +               do {
34956 +                       set_current_state(TASK_UNINTERRUPTIBLE);
34957 +                       schedule_timeout(MS_TO_HZ(10));
34958 +                       media_bay_step(bay->index);
34959 +               } while((bay->state != mb_empty) &&
34960 +                       (bay->state != mb_up));
34961 +               bay->sleeping = 0;
34962 +               up(&bay->lock);
34963 +       }
34964 +       return 0;
34965  }
34966 -#endif /* CONFIG_PMAC_PBOOK */
34967  
34968  
34969  /* Definitions of "ops" structures.
34970 @@ -727,6 +780,7 @@
34971  
34972  static struct mb_ops keylargo_mb_ops __pmacdata = {
34973         .name           = "KeyLargo",
34974 +       .init           = keylargo_mb_init,
34975         .content        = keylargo_mb_content,
34976         .power          = keylargo_mb_power,
34977         .setup_bus      = keylargo_mb_setup_bus,
34978 @@ -743,12 +797,42 @@
34979   * Therefore we do it all by polling the media bay once each tick.
34980   */
34981  
34982 -static int __init
34983 -media_bay_init(void)
34984 +static struct of_match media_bay_match[] =
34985  {
34986 -       struct device_node *np;
34987 -       int             n,i;
34988 -       
34989 +       {
34990 +       .name           = "media-bay",
34991 +       .type           = OF_ANY_MATCH,
34992 +       .compatible     = "keylargo-media-bay",
34993 +       .data           = &keylargo_mb_ops,
34994 +       },
34995 +       {
34996 +       .name           = "media-bay",
34997 +       .type           = OF_ANY_MATCH,
34998 +       .compatible     = "heathrow-media-bay",
34999 +       .data           = &heathrow_mb_ops,
35000 +       },
35001 +       {
35002 +       .name           = "media-bay",
35003 +       .type           = OF_ANY_MATCH,
35004 +       .compatible     = "ohare-media-bay",
35005 +       .data           = &ohare_mb_ops,
35006 +       },
35007 +       {},
35008 +};
35009 +
35010 +static struct macio_driver media_bay_driver =
35011 +{
35012 +       .name           = "media-bay",
35013 +       .match_table    = media_bay_match,
35014 +       .probe          = media_bay_attach,
35015 +       .suspend        = media_bay_suspend,
35016 +       .resume         = media_bay_resume
35017 +};
35018 +
35019 +static int __init media_bay_init(void)
35020 +{
35021 +       int i;
35022 +
35023         for (i=0; i<MAX_BAYS; i++) {
35024                 memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info));
35025                 media_bays[i].content_id        = -1;
35026 @@ -756,84 +840,12 @@
35027                 media_bays[i].cd_index          = -1;
35028  #endif
35029         }
35030 -       
35031 -       np = find_devices("media-bay");
35032 -       n = 0;
35033 -       while(np && (n<MAX_BAYS)) {
35034 -               struct media_bay_info* bay = &media_bays[n];
35035 -               if (!np->parent || np->n_addrs == 0 || !request_OF_resource(np, 0, NULL)) {
35036 -                       np = np->next;
35037 -                       printk(KERN_ERR "media-bay: Can't request IO resource !\n");
35038 -                       continue;
35039 -               }
35040 -               bay->mb_type = mb_ohare;
35041 -
35042 -               if (device_is_compatible(np, "keylargo-media-bay")) {
35043 -                       bay->mb_type = mb_keylargo;
35044 -                       bay->ops = &keylargo_mb_ops;
35045 -               } else if (device_is_compatible(np, "heathrow-media-bay")) {
35046 -                       bay->mb_type = mb_heathrow;
35047 -                       bay->ops = &heathrow_mb_ops;
35048 -               } else if (device_is_compatible(np, "ohare-media-bay")) {
35049 -                       bay->mb_type = mb_ohare;
35050 -                       bay->ops = &ohare_mb_ops;
35051 -               } else {
35052 -                       printk(KERN_ERR "mediabay: Unknown bay type !\n");
35053 -                       np = np->next;
35054 -                       continue;
35055 -               }
35056 -               bay->base = (volatile u32*)ioremap(np->parent->addrs[0].address, 0x1000);
35057 -
35058 -               /* Enable probe logic on keylargo */
35059 -               if (bay->mb_type == mb_keylargo)
35060 -                       MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
35061 -#ifdef MB_USE_INTERRUPTS
35062 -               if (np->n_intrs == 0) {
35063 -                       printk(KERN_ERR "media bay %d has no irq\n",n);
35064 -                       np = np->next;
35065 -                       continue;
35066 -               }
35067 -
35068 -               if (request_irq(np->intrs[0].line, media_bay_intr, 0, "Media bay", (void *)n)) {
35069 -                       printk(KERN_ERR "Couldn't get IRQ %d for media bay %d\n",
35070 -                               np->intrs[0].line, n);
35071 -                       np = np->next;
35072 -                       continue;
35073 -               }
35074 -#endif 
35075 -               media_bay_count++;
35076 -       
35077 -               printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", n, bay->ops->name);
35078 -               bay->dev_node = np;
35079 -               bay->index = n;
35080 -
35081 -               /* Force an immediate detect */
35082 -               set_mb_power(bay, 0);
35083 -               mdelay(MB_POWER_DELAY);
35084 -               bay->content_id = MB_NO;
35085 -               bay->last_value = bay->ops->content(bay);
35086 -               bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
35087 -               bay->state = mb_empty;
35088 -               do {
35089 -                       mdelay(1000/HZ);
35090 -                       media_bay_step(n);
35091 -               } while((bay->state != mb_empty) &&
35092 -                       (bay->state != mb_up));
35093 -
35094 -               n++;
35095 -               np=np->next;
35096 -       }
35097 +       if (_machine != _MACH_Pmac)
35098 +               return -ENODEV;
35099  
35100 -       if (media_bay_count)
35101 -       {
35102 -#ifdef CONFIG_PMAC_PBOOK
35103 -               pmu_register_sleep_notifier(&mb_sleep_notifier);
35104 -#endif /* CONFIG_PMAC_PBOOK */
35105 +       macio_register_driver(&media_bay_driver);       
35106  
35107 -               kernel_thread(media_bay_task, NULL,
35108 -                             CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
35109 -       }
35110         return 0;
35111  }
35112  
35113 -subsys_initcall(media_bay_init);
35114 +device_initcall(media_bay_init);
35115 diff -Nru a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
35116 --- a/drivers/macintosh/via-pmu.c       Sat Jun  7 00:46:48 2003
35117 +++ b/drivers/macintosh/via-pmu.c       Wed Sep  3 09:25:59 2003
35118 @@ -11,6 +11,14 @@
35119   * Copyright (C) 1998 Paul Mackerras and Fabio Riccardi.
35120   * Copyright (C) 2001-2002 Benjamin Herrenschmidt
35121   *
35122 + * THIS DRIVER IS BECOMING A TOTAL MESS !
35123 + *  - Cleanup atomically disabling reply to PMU events after
35124 + *    a sleep or a freq. switch
35125 + *  - Move sleep code out of here to pmac_pm, merge into new
35126 + *    common PM infrastructure
35127 + *  - Move backlight code out as well
35128 + *  - Save/Restore PCI space properly
35129 + *
35130   */
35131  #include <stdarg.h>
35132  #include <linux/config.h>
35133 @@ -34,6 +42,8 @@
35134  #include <linux/proc_fs.h>
35135  #include <linux/init.h>
35136  #include <linux/interrupt.h>
35137 +#include <linux/device.h>
35138 +#include <linux/suspend.h>
35139  #include <asm/prom.h>
35140  #include <asm/machdep.h>
35141  #include <asm/io.h>
35142 @@ -47,6 +57,7 @@
35143  #include <asm/mmu_context.h>
35144  #include <asm/cputable.h>
35145  #include <asm/time.h>
35146 +#include <asm/xmon.h>
35147  #ifdef CONFIG_PMAC_BACKLIGHT
35148  #include <asm/backlight.h>
35149  #endif
35150 @@ -55,7 +66,6 @@
35151  #undef SUSPEND_USES_PMU
35152  #define DEBUG_SLEEP
35153  #undef HACKED_PCI_SAVE
35154 -#define NEW_OHARE_CODE
35155  
35156  /* Misc minor number allocated for /dev/pmu */
35157  #define PMU_MINOR              154
35158 @@ -63,6 +73,13 @@
35159  /* How many iterations between battery polls */
35160  #define BATTERY_POLLING_COUNT  2
35161  
35162 +/* Some debugging tools */
35163 +#ifdef CONFIG_XMON
35164 +//#define LIVE_DEBUG(req) ((req) && (req)->data[0] == 0x7d)
35165 +#define LIVE_DEBUG(req) (0)
35166 +static int whacky_debug;
35167 +#endif /* CONFIG_XMON */
35168 +
35169  static volatile unsigned char *via;
35170  
35171  /* VIA registers - spaced 0x200 bytes apart */
35172 @@ -106,6 +123,7 @@
35173         intack,
35174         reading,
35175         reading_intr,
35176 +       locked,
35177  } pmu_state;
35178  
35179  static volatile enum int_data_state {
35180 @@ -133,6 +151,7 @@
35181  static int pmu_has_adb;
35182  static unsigned char *gpio_reg = NULL;
35183  static int gpio_irq = -1;
35184 +static int gpio_irq_enabled = -1;
35185  static volatile int pmu_suspended = 0;
35186  static spinlock_t pmu_lock;
35187  static u8 pmu_intr_mask;
35188 @@ -143,9 +162,11 @@
35189  static int sleep_in_progress;
35190  static int can_sleep;
35191  #endif /* CONFIG_PMAC_PBOOK */
35192 +static unsigned int pmu_irq_stats[11];
35193  
35194  static struct proc_dir_entry *proc_pmu_root;
35195  static struct proc_dir_entry *proc_pmu_info;
35196 +static struct proc_dir_entry *proc_pmu_irqstats;
35197  static struct proc_dir_entry *proc_pmu_options;
35198  
35199  #ifdef CONFIG_PMAC_PBOOK
35200 @@ -184,6 +205,8 @@
35201  static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
35202  static int proc_get_info(char *page, char **start, off_t off,
35203                           int count, int *eof, void *data);
35204 +static int proc_get_irqstats(char *page, char **start, off_t off,
35205 +                         int count, int *eof, void *data);
35206  #ifdef CONFIG_PMAC_BACKLIGHT
35207  static int pmu_set_backlight_level(int level, void* data);
35208  static int pmu_set_backlight_enable(int on, int level, void* data);
35209 @@ -205,16 +228,12 @@
35210         pmu_init,
35211         pmu_send_request,
35212         pmu_adb_autopoll,
35213 -       pmu_poll,
35214 +       pmu_poll_adb,
35215         pmu_adb_reset_bus
35216  };
35217  #endif /* CONFIG_ADB */
35218  
35219  extern void low_sleep_handler(void);
35220 -extern void pmac_sleep_save_intrs(int);
35221 -extern void pmac_sleep_restore_intrs(void);
35222 -extern void openpic_sleep_save_intrs(void);
35223 -extern void openpic_sleep_restore_intrs(void);
35224  extern void enable_kernel_altivec(void);
35225  extern void enable_kernel_fp(void);
35226  
35227 @@ -223,14 +242,6 @@
35228  int pmu_wink(struct adb_request *req);
35229  #endif
35230  
35231 -#if defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM)
35232 -static int generic_notify_sleep(struct pmu_sleep_notifier *self, int when);
35233 -static struct pmu_sleep_notifier generic_sleep_notifier = {
35234 -       generic_notify_sleep,
35235 -       SLEEP_LEVEL_MISC,
35236 -};
35237 -#endif /* defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM) */
35238 -
35239  /*
35240   * This table indicates for each PMU opcode:
35241   * - the number of data bytes to be sent with the command, or -1
35242 @@ -361,11 +372,6 @@
35243                
35244         sys_ctrler = SYS_CTRLER_PMU;
35245         
35246 -#if defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM)
35247 -       pmu_register_sleep_notifier(&generic_sleep_notifier);
35248 -       pm_active = 1;
35249 -#endif 
35250 -
35251         return 1;
35252  }
35253  
35254 @@ -416,6 +422,7 @@
35255         if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) {
35256                 if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1/ADB", (void *)0))
35257                         printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq);
35258 +               gpio_irq_enabled = 1;
35259         }
35260  
35261         /* Enable interrupts */
35262 @@ -489,6 +496,8 @@
35263                 int i;
35264                 proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root,
35265                                         proc_get_info, NULL);
35266 +               proc_pmu_irqstats = create_proc_read_entry("interrupts", 0, proc_pmu_root,
35267 +                                       proc_get_irqstats, NULL);
35268  #ifdef CONFIG_PMAC_PBOOK
35269                 for (i=0; i<pmu_battery_count; i++) {
35270                         char title[16];
35271 @@ -552,15 +561,14 @@
35272  
35273         /* Read PMU version */
35274         pmu_request(&req, NULL, 1, PMU_GET_VERSION);
35275 -       while (!req.complete)
35276 -               pmu_poll();
35277 +       pmu_wait_complete(&req);
35278         if (req.reply_len > 0)
35279                 pmu_version = req.reply[0];
35280  
35281         return 1;
35282  }
35283  
35284 -int __pmac
35285 +int
35286  pmu_get_model(void)
35287  {
35288         return pmu_kind;
35289 @@ -774,6 +782,33 @@
35290         return p - page;
35291  }
35292  
35293 +static int __pmac
35294 +proc_get_irqstats(char *page, char **start, off_t off,
35295 +                 int count, int *eof, void *data)
35296 +{
35297 +       int i;
35298 +       char* p = page;
35299 +       static const char *irq_names[] = {
35300 +               "Total CB1 triggered events",
35301 +               "Total GPIO1 triggered events",
35302 +               "PC-Card eject button",
35303 +               "Sound/Brightness button",
35304 +               "ADB message",
35305 +               "Battery state change",
35306 +               "Environment interrupt",
35307 +               "Tick timer",
35308 +               "Ghost interrupt (zero len)",
35309 +               "Empty interrupt (empty mask)",
35310 +               "Max irqs in a row"
35311 +        };
35312 +
35313 +       for (i=0; i<11; i++) {
35314 +               p += sprintf(p, " %2u: %10u (%s)\n",
35315 +                            i, pmu_irq_stats[i], irq_names[i]);
35316 +       }
35317 +       return p - page;
35318 +}
35319 +
35320  #ifdef CONFIG_PMAC_PBOOK
35321  static int __pmac
35322  proc_get_batt(char *page, char **start, off_t off,
35323 @@ -982,8 +1017,7 @@
35324                 printk(KERN_ERR "pmu_adb_reset_bus: pmu_queue_request failed\n");
35325                 return -EIO;
35326         }
35327 -       while (!req.complete)
35328 -               pmu_poll();
35329 +       pmu_wait_complete(&req);
35330  
35331         if (save_autopoll != 0)
35332                 pmu_adb_autopoll(save_autopoll);
35333 @@ -1133,6 +1167,12 @@
35334         wait_for_ack();
35335         /* set the shift register to shift out and send a byte */
35336         send_byte(req->data[0]);
35337 +#ifdef CONFIG_XMON
35338 +       if (LIVE_DEBUG(req))
35339 +               xmon_printf("R");
35340 +       else
35341 +               whacky_debug = 0;
35342 +#endif /* CONFIG_XMON */
35343  }
35344  
35345  void __openfirmware
35346 @@ -1142,15 +1182,33 @@
35347                 return;
35348         if (disable_poll)
35349                 return;
35350 +       via_pmu_interrupt(0, 0, 0);
35351 +}
35352 +
35353 +void __openfirmware
35354 +pmu_poll_adb(void)
35355 +{
35356 +       if (!via)
35357 +               return;
35358 +       if (disable_poll)
35359 +               return;
35360         /* Kicks ADB read when PMU is suspended */
35361 -       if (pmu_suspended)
35362 -               adb_int_pending = 1;
35363 +       adb_int_pending = 1;
35364         do {
35365                 via_pmu_interrupt(0, 0, 0);
35366         } while (pmu_suspended && (adb_int_pending || pmu_state != idle
35367                 || req_awaiting_reply));
35368  }
35369  
35370 +void __openfirmware
35371 +pmu_wait_complete(struct adb_request *req)
35372 +{
35373 +       if (!via)
35374 +               return;
35375 +       while((pmu_state != idle && pmu_state != locked) || !req->complete)
35376 +               via_pmu_interrupt(0, 0, 0);
35377 +}
35378 +
35379  /* This function loops until the PMU is idle and prevents it from
35380   * anwsering to ADB interrupts. pmu_request can still be called.
35381   * This is done to avoid spurrious shutdowns when we know we'll have
35382 @@ -1175,6 +1233,8 @@
35383  
35384         do {
35385                 spin_unlock_irqrestore(&pmu_lock, flags);
35386 +               if (req_awaiting_reply)
35387 +                       adb_int_pending = 1;
35388                 via_pmu_interrupt(0, 0, 0);
35389                 spin_lock_irqsave(&pmu_lock, flags);
35390                 if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
35391 @@ -1185,7 +1245,7 @@
35392                                 pmu_poll();
35393  #else /* SUSPEND_USES_PMU */
35394                         if (gpio_irq >= 0)
35395 -                               disable_irq(gpio_irq);
35396 +                               disable_irq_nosync(gpio_irq);
35397                         out_8(&via[IER], CB1_INT | IER_CLR);
35398                         spin_unlock_irqrestore(&pmu_lock, flags);
35399  #endif /* SUSPEND_USES_PMU */
35400 @@ -1227,16 +1287,47 @@
35401  static void __pmac
35402  pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
35403  {
35404 +       unsigned char ints, pirq;
35405 +       int i = 0;
35406 +
35407         asleep = 0;
35408         if (drop_interrupts || len < 1) {
35409                 adb_int_pending = 0;
35410 +               pmu_irq_stats[8]++;
35411 +               return;
35412 +       }
35413 +
35414 +       /* Get PMU interrupt mask */
35415 +       ints = data[0];
35416 +
35417 +       /* Record zero interrupts for stats */
35418 +       if (ints == 0)
35419 +               pmu_irq_stats[9]++;
35420 +
35421 +       /* Hack to deal with ADB autopoll flag */
35422 +       if (ints & PMU_INT_ADB)
35423 +               ints &= ~(PMU_INT_ADB_AUTO | PMU_INT_AUTO_SRQ_POLL);
35424 +
35425 +next:
35426 +
35427 +       if (ints == 0) {
35428 +               if (i > pmu_irq_stats[10])
35429 +                       pmu_irq_stats[10] = i;
35430                 return;
35431         }
35432 +
35433 +       for (pirq = 0; pirq < 8; pirq++)
35434 +               if (ints & (1 << pirq))
35435 +                       break;
35436 +       pmu_irq_stats[pirq]++;
35437 +       i++;
35438 +       ints &= ~(1 << pirq);
35439 +
35440         /* Note: for some reason, we get an interrupt with len=1,
35441          * data[0]==0 after each normal ADB interrupt, at least
35442          * on the Pismo. Still investigating...  --BenH
35443          */
35444 -       if (data[0] & PMU_INT_ADB) {
35445 +       if ((1 << pirq) & PMU_INT_ADB) {
35446                 if ((data[0] & PMU_INT_ADB_AUTO) == 0) {
35447                         struct adb_request *req = req_awaiting_reply;
35448                         if (req == 0) {
35449 @@ -1274,29 +1365,37 @@
35450                                 adb_input(data+1, len-1, regs, 1);
35451  #endif /* CONFIG_ADB */                
35452                 }
35453 -       } else {
35454 -               /* Sound/brightness button pressed */
35455 -               if ((data[0] & PMU_INT_SNDBRT) && len == 3) {
35456 +       }
35457 +       /* Sound/brightness button pressed */
35458 +       else if ((1 << pirq) & PMU_INT_SNDBRT) {
35459  #ifdef CONFIG_PMAC_BACKLIGHT
35460 +               if (len == 3)
35461  #ifdef CONFIG_INPUT_ADBHID
35462                         if (!disable_kernel_backlight)
35463  #endif /* CONFIG_INPUT_ADBHID */
35464                                 set_backlight_level(data[1] >> 4);
35465  #endif /* CONFIG_PMAC_BACKLIGHT */
35466 -               }
35467 +       }
35468 +       /* Tick interrupt */
35469 +       else if ((1 << pirq) & PMU_INT_TICK) {
35470  #ifdef CONFIG_PMAC_PBOOK
35471                 /* Environement or tick interrupt, query batteries */
35472 -               if (pmu_battery_count && (data[0] & PMU_INT_TICK)) {
35473 +               if (pmu_battery_count) {
35474                         if ((--query_batt_timer) == 0) {
35475                                 query_battery_state();
35476                                 query_batt_timer = BATTERY_POLLING_COUNT;
35477                         }
35478 -               } else if (pmu_battery_count && (data[0] & PMU_INT_ENVIRONMENT))
35479 +               }
35480 +        }
35481 +       else if ((1 << pirq) & PMU_INT_ENVIRONMENT) {
35482 +               if (pmu_battery_count)
35483                         query_battery_state();
35484 -               if (data[0])
35485 -                       pmu_pass_intr(data, len);
35486 +               pmu_pass_intr(data, len);
35487 +       } else {
35488 +              pmu_pass_intr(data, len);
35489  #endif /* CONFIG_PMAC_PBOOK */
35490         }
35491 +       goto next;
35492  }
35493  
35494  static struct adb_request* __pmac
35495 @@ -1326,17 +1425,29 @@
35496         case sending:
35497                 req = current_req;
35498                 if (data_len < 0) {
35499 +#ifdef CONFIG_XMON
35500 +                       if (LIVE_DEBUG(req))
35501 +                               xmon_printf("s");
35502 +#endif /* CONFIG_XMON */
35503                         data_len = req->nbytes - 1;
35504                         send_byte(data_len);
35505                         break;
35506                 }
35507                 if (data_index <= data_len) {
35508 +#ifdef CONFIG_XMON
35509 +                       if (LIVE_DEBUG(req))
35510 +                               xmon_printf("S");
35511 +#endif /* CONFIG_XMON */
35512                         send_byte(req->data[data_index++]);
35513                         break;
35514                 }
35515                 req->sent = 1;
35516                 data_len = pmu_data_len[req->data[0]][1];
35517                 if (data_len == 0) {
35518 +#ifdef CONFIG_XMON
35519 +                       if (LIVE_DEBUG(req))
35520 +                               xmon_printf("D");
35521 +#endif /* CONFIG_XMON */
35522                         pmu_state = idle;
35523                         current_req = req->next;
35524                         if (req->reply_expected)
35525 @@ -1344,6 +1455,10 @@
35526                         else
35527                                 return req;
35528                 } else {
35529 +#ifdef CONFIG_XMON
35530 +                       if (LIVE_DEBUG(req))
35531 +                               xmon_printf("-");
35532 +#endif /* CONFIG_XMON */
35533                         pmu_state = reading;
35534                         data_index = 0;
35535                         reply_ptr = req->reply + req->reply_len;
35536 @@ -1357,15 +1472,27 @@
35537                 pmu_state = reading_intr;
35538                 reply_ptr = interrupt_data[int_data_last];
35539                 recv_byte();
35540 +               if (gpio_irq >= 0 && !gpio_irq_enabled) {
35541 +                       enable_irq(gpio_irq);
35542 +                       gpio_irq_enabled = 1;
35543 +               }
35544                 break;
35545  
35546         case reading:
35547         case reading_intr:
35548                 if (data_len == -1) {
35549 +#ifdef CONFIG_XMON
35550 +                       if (LIVE_DEBUG(current_req))
35551 +                               xmon_printf("r");
35552 +#endif /* CONFIG_XMON */
35553                         data_len = bite;
35554                         if (bite > 32)
35555                                 printk(KERN_ERR "PMU: bad reply len %d\n", bite);
35556                 } else if (data_index < 32) {
35557 +#ifdef CONFIG_XMON
35558 +                       if (LIVE_DEBUG(current_req))
35559 +                               xmon_printf("R");
35560 +#endif /* CONFIG_XMON */
35561                         reply_ptr[data_index++] = bite;
35562                 }
35563                 if (data_index < data_len) {
35564 @@ -1373,15 +1500,29 @@
35565                         break;
35566                 }
35567  
35568 +#ifdef CONFIG_XMON
35569 +               if (LIVE_DEBUG(current_req)) {
35570 +                       whacky_debug = 1;
35571 +                       xmon_printf("D");
35572 +               }
35573 +#endif /* CONFIG_XMON */
35574                 if (pmu_state == reading_intr) {
35575                         pmu_state = idle;
35576                         int_data_state[int_data_last] = int_data_ready;
35577                         interrupt_data_len[int_data_last] = data_len;
35578                 } else {
35579                         req = current_req;
35580 +                       /* 
35581 +                        * For PMU sleep and freq change requests, we lock the
35582 +                        * PMU until it's explicitely unlocked. This avoids any
35583 +                        * spurrious event polling getting in
35584 +                        */
35585                         current_req = req->next;
35586                         req->reply_len += data_index;
35587 -                       pmu_state = idle;
35588 +                       if (req->data[0] == PMU_SLEEP || req->data[0] == PMU_CPU_SPEED)
35589 +                               pmu_state = locked;
35590 +                       else
35591 +                               pmu_state = idle;
35592                         return req;
35593                 }
35594                 break;
35595 @@ -1411,6 +1552,10 @@
35596                 intr = in_8(&via[IFR]) & (SR_INT | CB1_INT);
35597                 if (intr == 0)
35598                         break;
35599 +#ifdef CONFIG_XMON
35600 +               if (whacky_debug)
35601 +                       xmon_printf("|%02x|", intr);
35602 +#endif /* CONFIG_XMON */
35603                 handled = 1;
35604                 if (++nloop > 1000) {
35605                         printk(KERN_DEBUG "PMU: stuck in intr loop, "
35606 @@ -1419,8 +1564,10 @@
35607                         break;
35608                 }
35609                 out_8(&via[IFR], intr);
35610 -               if (intr & CB1_INT)
35611 +               if (intr & CB1_INT) {
35612                         adb_int_pending = 1;
35613 +                       pmu_irq_stats[0]++;
35614 +               }
35615                 if (intr & SR_INT) {
35616                         req = pmu_sr_intr(regs);
35617                         if (req)
35618 @@ -1431,6 +1578,10 @@
35619  recheck:
35620         if (pmu_state == idle) {
35621                 if (adb_int_pending) {
35622 +#ifdef CONFIG_XMON
35623 +                       if (whacky_debug)
35624 +                               xmon_printf("!A!");
35625 +#endif /* CONFIG_XMON */
35626                         if (int_data_state[0] == int_data_empty)
35627                                 int_data_last = 0;
35628                         else if (int_data_state[1] == int_data_empty)
35629 @@ -1479,11 +1630,33 @@
35630         return IRQ_RETVAL(handled);
35631  }
35632  
35633 +void __pmac
35634 +pmu_unlock(void)
35635 +{
35636 +       unsigned long flags;
35637 +
35638 +       spin_lock_irqsave(&pmu_lock, flags);
35639 +       if (pmu_state == locked)
35640 +               pmu_state = idle;
35641 +       adb_int_pending = 1;
35642 +       spin_unlock_irqrestore(&pmu_lock, flags);
35643 +}
35644 +
35645 +
35646  static irqreturn_t __pmac
35647  gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
35648  {
35649 +       unsigned long flags;
35650 +
35651         if ((in_8(gpio_reg + 0x9) & 0x02) == 0) {
35652 +               spin_lock_irqsave(&pmu_lock, flags);
35653 +               if (gpio_irq_enabled > 0) {
35654 +                       disable_irq_nosync(gpio_irq);
35655 +                       gpio_irq_enabled = 0;
35656 +               }
35657 +               pmu_irq_stats[1]++;
35658                 adb_int_pending = 1;
35659 +               spin_unlock_irqrestore(&pmu_lock, flags);
35660                 via_pmu_interrupt(0, 0, 0);
35661                 return IRQ_HANDLED;
35662         }
35663 @@ -1507,13 +1680,11 @@
35664         if (on) {
35665                 pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT,
35666                             backlight_to_bright[level]);
35667 -               while (!req.complete)
35668 -                       pmu_poll();
35669 +               pmu_wait_complete(&req);
35670         }
35671         pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
35672                     PMU_POW_BACKLIGHT | (on ? PMU_POW_ON : PMU_POW_OFF));
35673 -       while (!req.complete)
35674 -               pmu_poll();
35675 +               pmu_wait_complete(&req);
35676  
35677         return 0;
35678  }
35679 @@ -1549,8 +1720,7 @@
35680  
35681         pmu_request(&req, NULL, 2, PMU_POWER_CTRL, PMU_POW_IRLED |
35682             (on ? PMU_POW_ON : PMU_POW_OFF));
35683 -       while (!req.complete)
35684 -               pmu_poll();
35685 +       pmu_wait_complete(&req);
35686  }
35687  
35688  void __pmac
35689 @@ -1570,8 +1740,7 @@
35690         }
35691  
35692         pmu_request(&req, NULL, 1, PMU_RESET);
35693 -       while(!req.complete || (pmu_state != idle))
35694 -               pmu_poll();
35695 +       pmu_wait_complete(&req);
35696         for (;;)
35697                 ;
35698  }
35699 @@ -1588,14 +1757,12 @@
35700         if (pmu_kind != PMU_KEYLARGO_BASED) {
35701                 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, PMU_INT_ADB |
35702                                                 PMU_INT_TICK );
35703 -               while(!req.complete)
35704 -                       pmu_poll();
35705 +               pmu_wait_complete(&req);
35706         }
35707  
35708         pmu_request(&req, NULL, 5, PMU_SHUTDOWN,
35709                     'M', 'A', 'T', 'T');
35710 -       while(!req.complete || (pmu_state != idle))
35711 -               pmu_poll();
35712 +       pmu_wait_complete(&req);
35713         for (;;)
35714                 ;
35715  }
35716 @@ -1606,25 +1773,261 @@
35717         return via != 0;
35718  }
35719  
35720 -#ifdef CONFIG_PMAC_PBOOK
35721 +struct pmu_i2c_hdr {
35722 +       u8      bus;
35723 +       u8      mode;
35724 +       u8      bus2;
35725 +       u8      address;
35726 +       u8      sub_addr;
35727 +       u8      comb_addr;
35728 +       u8      count;
35729 +};
35730  
35731 -static LIST_HEAD(sleep_notifiers);
35732 +int
35733 +pmu_i2c_combined_read(int bus, int addr, int subaddr,  u8* data, int len)
35734 +{
35735 +       struct adb_request      req;
35736 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
35737 +       int retry;
35738 +       int rc;
35739 +
35740 +       for (retry=0; retry<16; retry++) {
35741 +               memset(&req, 0, sizeof(req));
35742 +
35743 +               hdr->bus = bus;
35744 +               hdr->address = addr & 0xfe;
35745 +               hdr->mode = PMU_I2C_MODE_COMBINED;
35746 +               hdr->bus2 = 0;
35747 +               hdr->sub_addr = subaddr;
35748 +               hdr->comb_addr = addr | 1;
35749 +               hdr->count = len;
35750 +               
35751 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
35752 +               req.reply_expected = 0;
35753 +               req.reply_len = 0;
35754 +               req.data[0] = PMU_I2C_CMD;
35755 +               req.reply[0] = 0xff;
35756 +               rc = pmu_queue_request(&req);
35757 +               if (rc)
35758 +                       return rc;
35759 +               while(!req.complete)
35760 +                       pmu_poll();
35761 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
35762 +                       break;
35763 +               mdelay(15);
35764 +       }
35765 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
35766 +               return -1;
35767  
35768 -#ifdef CONFIG_PM
35769 -static int __pmac
35770 -generic_notify_sleep(struct pmu_sleep_notifier *self, int when)
35771 +       for (retry=0; retry<16; retry++) {
35772 +               memset(&req, 0, sizeof(req));
35773 +
35774 +               mdelay(15);
35775 +
35776 +               hdr->bus = PMU_I2C_BUS_STATUS;
35777 +               req.reply[0] = 0xff;
35778 +               
35779 +               req.nbytes = 2;
35780 +               req.reply_expected = 0;
35781 +               req.reply_len = 0;
35782 +               req.data[0] = PMU_I2C_CMD;
35783 +               rc = pmu_queue_request(&req);
35784 +               if (rc)
35785 +                       return rc;
35786 +               while(!req.complete)
35787 +                       pmu_poll();
35788 +               if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
35789 +                       memcpy(data, &req.reply[1], req.reply_len - 1);
35790 +                       return req.reply_len - 1;
35791 +               }
35792 +       }
35793 +       return -1;
35794 +}
35795 +
35796 +int
35797 +pmu_i2c_stdsub_write(int bus, int addr, int subaddr,  u8* data, int len)
35798 +{
35799 +       struct adb_request      req;
35800 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
35801 +       int retry;
35802 +       int rc;
35803 +
35804 +       for (retry=0; retry<16; retry++) {
35805 +               memset(&req, 0, sizeof(req));
35806 +
35807 +               hdr->bus = bus;
35808 +               hdr->address = addr & 0xfe;
35809 +               hdr->mode = PMU_I2C_MODE_STDSUB;
35810 +               hdr->bus2 = 0;
35811 +               hdr->sub_addr = subaddr;
35812 +               hdr->comb_addr = addr & 0xfe;
35813 +               hdr->count = len;
35814 +
35815 +               req.data[0] = PMU_I2C_CMD;
35816 +               memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
35817 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
35818 +               req.reply_expected = 0;
35819 +               req.reply_len = 0;
35820 +               req.reply[0] = 0xff;
35821 +               rc = pmu_queue_request(&req);
35822 +               if (rc)
35823 +                       return rc;
35824 +               while(!req.complete)
35825 +                       pmu_poll();
35826 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
35827 +                       break;
35828 +               mdelay(15);
35829 +       }
35830 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
35831 +               return -1;
35832 +
35833 +       for (retry=0; retry<16; retry++) {
35834 +               memset(&req, 0, sizeof(req));
35835 +
35836 +               mdelay(15);
35837 +
35838 +               hdr->bus = PMU_I2C_BUS_STATUS;
35839 +               req.reply[0] = 0xff;
35840 +               
35841 +               req.nbytes = 2;
35842 +               req.reply_expected = 0;
35843 +               req.reply_len = 0;
35844 +               req.data[0] = PMU_I2C_CMD;
35845 +               rc = pmu_queue_request(&req);
35846 +               if (rc)
35847 +                       return rc;
35848 +               while(!req.complete)
35849 +                       pmu_poll();
35850 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
35851 +                       return len;
35852 +       }
35853 +       return -1;
35854 +}
35855 +
35856 +int
35857 +pmu_i2c_simple_read(int bus, int addr,  u8* data, int len)
35858 +{
35859 +       struct adb_request      req;
35860 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
35861 +       int retry;
35862 +       int rc;
35863 +
35864 +       for (retry=0; retry<16; retry++) {
35865 +               memset(&req, 0, sizeof(req));
35866 +
35867 +               hdr->bus = bus;
35868 +               hdr->address = addr | 1;
35869 +               hdr->mode = PMU_I2C_MODE_SIMPLE;
35870 +               hdr->bus2 = 0;
35871 +               hdr->sub_addr = 0;
35872 +               hdr->comb_addr = 0;
35873 +               hdr->count = len;
35874 +
35875 +               req.data[0] = PMU_I2C_CMD;
35876 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
35877 +               req.reply_expected = 0;
35878 +               req.reply_len = 0;
35879 +               req.reply[0] = 0xff;
35880 +               rc = pmu_queue_request(&req);
35881 +               if (rc)
35882 +                       return rc;
35883 +               while(!req.complete)
35884 +                       pmu_poll();
35885 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
35886 +                       break;
35887 +               mdelay(15);
35888 +       }
35889 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
35890 +               return -1;
35891 +
35892 +       for (retry=0; retry<16; retry++) {
35893 +               memset(&req, 0, sizeof(req));
35894 +
35895 +               mdelay(15);
35896 +
35897 +               hdr->bus = PMU_I2C_BUS_STATUS;
35898 +               req.reply[0] = 0xff;
35899 +               
35900 +               req.nbytes = 2;
35901 +               req.reply_expected = 0;
35902 +               req.reply_len = 0;
35903 +               req.data[0] = PMU_I2C_CMD;
35904 +               rc = pmu_queue_request(&req);
35905 +               if (rc)
35906 +                       return rc;
35907 +               while(!req.complete)
35908 +                       pmu_poll();
35909 +               if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
35910 +                       memcpy(data, &req.reply[1], req.reply_len - 1);
35911 +                       return req.reply_len - 1;
35912 +               }
35913 +       }
35914 +       return -1;
35915 +}
35916 +
35917 +int
35918 +pmu_i2c_simple_write(int bus, int addr,  u8* data, int len)
35919  {
35920 -       switch (when) {
35921 -               case PBOOK_SLEEP_NOW:
35922 -                       if (pm_send_all(PM_SUSPEND, (void *)3))
35923 -                               return PBOOK_SLEEP_REJECT;
35924 +       struct adb_request      req;
35925 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
35926 +       int retry;
35927 +       int rc;
35928 +
35929 +       for (retry=0; retry<16; retry++) {
35930 +               memset(&req, 0, sizeof(req));
35931 +
35932 +               hdr->bus = bus;
35933 +               hdr->address = addr & 0xfe;
35934 +               hdr->mode = PMU_I2C_MODE_SIMPLE;
35935 +               hdr->bus2 = 0;
35936 +               hdr->sub_addr = 0;
35937 +               hdr->comb_addr = 0;
35938 +               hdr->count = len;
35939 +
35940 +               req.data[0] = PMU_I2C_CMD;
35941 +               memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
35942 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
35943 +               req.reply_expected = 0;
35944 +               req.reply_len = 0;
35945 +               req.reply[0] = 0xff;
35946 +               rc = pmu_queue_request(&req);
35947 +               if (rc)
35948 +                       return rc;
35949 +               while(!req.complete)
35950 +                       pmu_poll();
35951 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
35952                         break;
35953 -               case PBOOK_WAKE:
35954 -                       (void) pm_send_all(PM_RESUME, (void *)0);
35955 +               mdelay(15);
35956 +       }
35957 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
35958 +               return -1;
35959 +
35960 +       for (retry=0; retry<16; retry++) {
35961 +               memset(&req, 0, sizeof(req));
35962 +
35963 +               mdelay(15);
35964 +
35965 +               hdr->bus = PMU_I2C_BUS_STATUS;
35966 +               req.reply[0] = 0xff;
35967 +               
35968 +               req.nbytes = 2;
35969 +               req.reply_expected = 0;
35970 +               req.reply_len = 0;
35971 +               req.data[0] = PMU_I2C_CMD;
35972 +               rc = pmu_queue_request(&req);
35973 +               if (rc)
35974 +                       return rc;
35975 +               while(!req.complete)
35976 +                       pmu_poll();
35977 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
35978 +                       return len;
35979         }
35980 -       return PBOOK_SLEEP_OK;
35981 +       return -1;
35982  }
35983 -#endif /* CONFIG_PM */
35984 +
35985 +#ifdef CONFIG_PMAC_PBOOK
35986 +
35987 +static LIST_HEAD(sleep_notifiers);
35988  
35989  int
35990  pmu_register_sleep_notifier(struct pmu_sleep_notifier *n)
35991 @@ -1885,90 +2288,166 @@
35992  }
35993  
35994  extern long sys_sync(void);
35995 +extern void pm_prepare_console(void);
35996 +extern void pm_restore_console(void);
35997  
35998 -#define        GRACKLE_PM      (1<<7)
35999 -#define GRACKLE_DOZE   (1<<5)
36000 -#define        GRACKLE_NAP     (1<<4)
36001 -#define        GRACKLE_SLEEP   (1<<3)
36002 -
36003 -int __pmac
36004 -powerbook_sleep_G3(void)
36005 +static int __pmac
36006 +pmac_suspend_devices(void)
36007  {
36008 -       unsigned long save_l2cr;
36009 -       unsigned short pmcr1;
36010 -       struct adb_request req;
36011         int ret;
36012 -       struct pci_dev *grackle;
36013 -
36014 -       grackle = pci_find_slot(0, 0);
36015 -       if (!grackle)
36016 -               return -ENODEV;
36017 -
36018 -       /* Notify device drivers */
36019 +       
36020 +       pm_prepare_console();
36021 +       
36022 +       /* Notify old-style device drivers & userland */
36023         ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
36024         if (ret != PBOOK_SLEEP_OK) {
36025 -               printk("pmu: sleep rejected\n");
36026 +               printk(KERN_ERR "Sleep rejected by drivers\n");
36027                 return -EBUSY;
36028         }
36029  
36030         /* Sync the disks. */
36031         /* XXX It would be nice to have some way to ensure that
36032 -        * nobody is dirtying any new buffers while we wait.
36033 -        * BenH: Moved to _after_ sleep request and changed video
36034 -        * drivers to vmalloc() during sleep request. This way, all
36035 -        * vmalloc's are done before actual sleep of block drivers */
36036 +        * nobody is dirtying any new buffers while we wait. That
36037 +        * could be acheived using the refrigerator for processes
36038 +        * that swsusp uses
36039 +        */
36040         sys_sync();
36041  
36042         /* Sleep can fail now. May not be very robust but useful for debugging */
36043         ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
36044         if (ret != PBOOK_SLEEP_OK) {
36045 -               printk("pmu: sleep failed\n");
36046 +               printk(KERN_ERR "Driver sleep failed\n");
36047                 return -EBUSY;
36048         }
36049  
36050 -       /* Wait for completion of async backlight requests */
36051 -       while (!bright_req_1.complete || !bright_req_2.complete ||
36052 -               !bright_req_3.complete || !batt_req.complete)
36053 -               pmu_poll();
36054 +       /* Send suspend call to devices, hold the device core's dpm_sem */
36055 +       ret = device_suspend(PM_SUSPEND_MEM);
36056 +       if (ret) {
36057 +               printk(KERN_ERR "Driver sleep failed\n");
36058 +               broadcast_wake();
36059 +               return -EBUSY;
36060 +       }
36061         
36062 -       /* Turn off various things. Darwin does some retry tests here... */
36063 -       pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
36064 -       while (!req.complete)
36065 -               pmu_poll();
36066 -       pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
36067 -               PMU_POW_OFF|PMU_POW_BACKLIGHT|PMU_POW_IRLED|PMU_POW_MEDIABAY);
36068 -       while (!req.complete)
36069 -               pmu_poll();
36070 -
36071 -       /* Disable all interrupts */
36072 -       pmac_sleep_save_intrs(-1);
36073 -
36074 -       /* Make sure the PMU is idle */
36075 -       while (pmu_state != idle)
36076 -               pmu_poll();
36077 -
36078         /* Make sure the decrementer won't interrupt us */
36079         asm volatile("mtdec %0" : : "r" (0x7fffffff));
36080         /* Make sure any pending DEC interrupt occurring while we did
36081          * the above didn't re-enable the DEC */
36082         mb();
36083         asm volatile("mtdec %0" : : "r" (0x7fffffff));
36084 -       
36085 -       /* We can now disable MSR_EE */
36086 +
36087 +       /* We can now disable MSR_EE. This code of course works properly only
36088 +        * on UP machines... For SMP, if we ever implement sleep, we'll have to
36089 +        * stop the "other" CPUs way before we do all that stuff.
36090 +        */
36091         local_irq_disable();
36092  
36093 -       /* Giveup the FPU */
36094 +       /* Broadcast power down irq
36095 +        * This isn't that useful in most cases (only directly wired devices can
36096 +        * use this but still... This will take care of sysdev's as well, so
36097 +        * we exit from here with local irqs disabled and PIC off.
36098 +        */
36099 +       ret = device_power_down(PM_SUSPEND_MEM);
36100 +       if (ret) {
36101 +               wakeup_decrementer();
36102 +               local_irq_enable();
36103 +               device_resume();
36104 +               broadcast_wake();
36105 +               printk(KERN_ERR "Driver powerdown failed\n");
36106 +               return -EBUSY;
36107 +       }
36108 +
36109 +       /* Wait for completion of async backlight requests */
36110 +       while (!bright_req_1.complete || !bright_req_2.complete ||
36111 +               !bright_req_3.complete || !batt_req.complete)
36112 +               pmu_poll();
36113 +
36114 +       /* Giveup the lazy FPU & vec so we don't have to back them
36115 +        * up from the low level code
36116 +        */
36117         enable_kernel_fp();
36118  
36119 +#ifdef CONFIG_ALTIVEC
36120 +       if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
36121 +               enable_kernel_altivec();
36122 +#endif /* CONFIG_ALTIVEC */
36123 +
36124 +       return 0;
36125 +}
36126 +
36127 +static int __pmac
36128 +pmac_wakeup_devices(void)
36129 +{
36130 +       mdelay(100);
36131 +
36132 +       /* Power back up system devices (including the PIC) */
36133 +       device_power_up();
36134 +
36135 +       pmu_blink(1);
36136 +
36137 +       /* Force a poll of ADB interrupts */
36138 +       adb_int_pending = 1;
36139 +       via_pmu_interrupt(0, 0, 0);
36140 +
36141 +       /* Restart jiffies & scheduling */
36142 +       wakeup_decrementer();
36143 +
36144 +       /* Re-enable local CPU interrupts */
36145 +       local_irq_enable();
36146 +
36147 +       pmu_blink(1);
36148 +
36149 +       /* Resume devices */
36150 +       device_resume();
36151 +
36152 +       /* Notify old style drivers */
36153 +       broadcast_wake();
36154 +
36155 +       pm_restore_console();
36156 +
36157 +       return 0;
36158 +}
36159 +
36160 +#define        GRACKLE_PM      (1<<7)
36161 +#define GRACKLE_DOZE   (1<<5)
36162 +#define        GRACKLE_NAP     (1<<4)
36163 +#define        GRACKLE_SLEEP   (1<<3)
36164 +
36165 +int __pmac
36166 +powerbook_sleep_grackle(void)
36167 +{
36168 +       unsigned long save_l2cr;
36169 +       unsigned short pmcr1;
36170 +       struct adb_request req;
36171 +       int ret;
36172 +       struct pci_dev *grackle;
36173 +
36174 +       grackle = pci_find_slot(0, 0);
36175 +       if (!grackle)
36176 +               return -ENODEV;
36177 +
36178 +       ret = pmac_suspend_devices();
36179 +       if (ret) {
36180 +               printk(KERN_ERR "Sleep rejected by devices\n");
36181 +               return ret;
36182 +       }
36183 +       
36184 +       /* Turn off various things. Darwin does some retry tests here... */
36185 +       pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
36186 +       pmu_wait_complete(&req);
36187 +       pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
36188 +               PMU_POW_OFF|PMU_POW_BACKLIGHT|PMU_POW_IRLED|PMU_POW_MEDIABAY);
36189 +       pmu_wait_complete(&req);
36190 +
36191         /* For 750, save backside cache setting and disable it */
36192         save_l2cr = _get_L2CR();        /* (returns -1 if not available) */
36193         if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
36194                 _set_L2CR(save_l2cr & 0x7fffffff);
36195  
36196 -       /* Ask the PMU to put us to sleep */
36197 -       pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
36198 -       while (!req.complete)
36199 -               pmu_poll();
36200 +       if (!__fake_sleep) {
36201 +               /* Ask the PMU to put us to sleep */
36202 +               pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
36203 +               pmu_wait_complete(&req);
36204 +       }
36205  
36206         /* The VIA is supposed not to be restored correctly*/
36207         save_via_state();
36208 @@ -1982,7 +2461,10 @@
36209         pci_write_config_word(grackle, 0x70, pmcr1);
36210  
36211         /* Call low-level ASM sleep handler */
36212 -       low_sleep_handler();
36213 +       if (__fake_sleep)
36214 +               mdelay(5000);
36215 +       else
36216 +               low_sleep_handler();
36217  
36218         /* We're awake again, stop grackle PM */
36219         pci_read_config_word(grackle, 0x70, &pmcr1);
36220 @@ -2001,36 +2483,17 @@
36221         set_context(current->active_mm->context, current->active_mm->pgd);
36222  
36223         /* Power things up */
36224 -       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc);
36225 -       while (!req.complete)
36226 -               pmu_poll();
36227 +       pmu_unlock();
36228 +       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
36229 +       pmu_wait_complete(&req);
36230         pmu_request(&req, NULL, 2, PMU_POWER_CTRL0,
36231                         PMU_POW0_ON|PMU_POW0_HARD_DRIVE);
36232 -       while (!req.complete)
36233 -               pmu_poll();
36234 +       pmu_wait_complete(&req);
36235         pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
36236                         PMU_POW_ON|PMU_POW_BACKLIGHT|PMU_POW_CHARGER|PMU_POW_IRLED|PMU_POW_MEDIABAY);
36237 -       while (!req.complete)
36238 -               pmu_poll();
36239 -
36240 -       /* reenable interrupt controller */
36241 -       pmac_sleep_restore_intrs();
36242 +       pmu_wait_complete(&req);
36243  
36244 -       /* Leave some time for HW to settle down */
36245 -       mdelay(100);
36246 -
36247 -       /* Restart jiffies & scheduling */
36248 -       wakeup_decrementer();
36249 -
36250 -       /* Force a poll of ADB interrupts */
36251 -       adb_int_pending = 1;
36252 -       via_pmu_interrupt(0, 0, 0);
36253 -
36254 -       /* Re-enable local CPU interrupts */
36255 -       local_irq_enable();
36256 -
36257 -       /* Notify drivers */
36258 -       broadcast_wake();
36259 +       pmac_wakeup_devices();
36260  
36261         return 0;
36262  }
36263 @@ -2048,68 +2511,20 @@
36264                 return -ENOSYS;
36265         }
36266         
36267 -       /* Notify device drivers */
36268 -       ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
36269 -       if (ret != PBOOK_SLEEP_OK) {
36270 -               printk("pmu: sleep rejected\n");
36271 -               return -EBUSY;
36272 -       }
36273 -
36274 -       /* Sync the disks. */
36275 -       /* XXX It would be nice to have some way to ensure that
36276 -        * nobody is dirtying any new buffers while we wait.
36277 -        * BenH: Moved to _after_ sleep request and changed video
36278 -        * drivers to vmalloc() during sleep request. This way, all
36279 -        * vmalloc's are done before actual sleep of block drivers */
36280 -       sys_sync();
36281 -
36282 -       /* Sleep can fail now. May not be very robust but useful for debugging */
36283 -       ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
36284 -       if (ret != PBOOK_SLEEP_OK) {
36285 -               printk("pmu: sleep failed\n");
36286 -               return -EBUSY;
36287 +       ret = pmac_suspend_devices();
36288 +       if (ret) {
36289 +               printk(KERN_ERR "Sleep rejected by devices\n");
36290 +               return ret;
36291         }
36292 -       /* Wait for completion of async backlight requests */
36293 -       while (!bright_req_1.complete || !bright_req_2.complete ||
36294 -               !bright_req_3.complete || !batt_req.complete)
36295 -               pmu_poll();
36296 -
36297 +       
36298         /* Tell PMU what events will wake us up */
36299         pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_CLR_WAKEUP_EVENTS,
36300                 0xff, 0xff);
36301 -       while (!req.complete)
36302 -               pmu_poll();
36303 -
36304 +       pmu_wait_complete(&req);
36305         pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_SET_WAKEUP_EVENTS,
36306                 0, PMU_PWR_WAKEUP_KEY |
36307                 (option_lid_wakeup ? PMU_PWR_WAKEUP_LID_OPEN : 0));
36308 -       while (!req.complete)
36309 -               pmu_poll();
36310 -               
36311 -       /* Save & disable all interrupts */
36312 -       openpic_sleep_save_intrs();
36313 -
36314 -       /* Make sure the PMU is idle */
36315 -       while (pmu_state != idle)
36316 -               pmu_poll();
36317 -
36318 -       /* Make sure the decrementer won't interrupt us */
36319 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
36320 -       /* Make sure any pending DEC interrupt occurring while we did
36321 -        * the above didn't re-enable the DEC */
36322 -       mb();
36323 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
36324 -
36325 -       /* We can now disable MSR_EE */
36326 -       local_irq_disable();
36327 -
36328 -       /* Giveup the FPU & vec */
36329 -       enable_kernel_fp();
36330 -
36331 -#ifdef CONFIG_ALTIVEC
36332 -       if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
36333 -               enable_kernel_altivec();
36334 -#endif /* CONFIG_ALTIVEC */
36335 +       pmu_wait_complete(&req);
36336  
36337         /* Save & disable L2 and L3 caches*/
36338         save_l3cr = _get_L3CR();        /* (returns -1 if not available) */
36339 @@ -2125,13 +2540,9 @@
36340         if (!__fake_sleep) {
36341                 /* Ask the PMU to put us to sleep */
36342                 pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
36343 -               while (!req.complete && pmu_state != idle)
36344 -                       pmu_poll();
36345 +               pmu_wait_complete(&req);
36346         }
36347  
36348 -       out_8(&via[B], in_8(&via[B]) | TREQ);
36349 -       wait_for_ack();
36350 -
36351         /* The VIA is supposed not to be restored correctly*/
36352         save_via_state();
36353  
36354 @@ -2161,8 +2572,6 @@
36355         /* Don't restore PCI for now, it crashes. Maybe unnecessary on pbook */
36356         //pbook_pci_restore();
36357  
36358 -       pmu_blink(2);
36359 -               
36360         /* Restore L2 cache */
36361         if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
36362                 _set_L2CR(save_l2cr);
36363 @@ -2174,31 +2583,15 @@
36364         set_context(current->active_mm->context, current->active_mm->pgd);
36365  
36366         /* Tell PMU we are ready */
36367 +       pmu_unlock();
36368         pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2);
36369 -       while (!req.complete)
36370 -               pmu_poll();
36371 -       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc);
36372 -       while (!req.complete)
36373 -               pmu_poll();
36374 -               
36375 -       /* reenable interrupt controller */
36376 -       openpic_sleep_restore_intrs();
36377 -
36378 -       /* Leave some time for HW to settle down */
36379 -       mdelay(100);
36380 -
36381 -       /* Restart jiffies & scheduling */
36382 -       wakeup_decrementer();
36383 +       pmu_wait_complete(&req);
36384 +       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
36385 +       pmu_wait_complete(&req);
36386  
36387 -       /* Force a poll of ADB interrupts */
36388 -       adb_int_pending = 1;
36389 -       via_pmu_interrupt(0, 0, 0);
36390 +       pmu_blink(1);
36391  
36392 -       /* Re-enable local CPU interrupts */
36393 -       local_irq_enable();
36394 -
36395 -       /* Notify drivers */
36396 -       broadcast_wake();
36397 +       pmac_wakeup_devices();
36398  
36399         return 0;
36400  }
36401 @@ -2227,45 +2620,13 @@
36402         /* Allocate room for PCI save */
36403         pbook_alloc_pci_save();
36404  
36405 -       /* Notify device drivers */
36406 -       ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
36407 -       if (ret != PBOOK_SLEEP_OK) {
36408 -               pbook_free_pci_save();
36409 -               printk("pmu: sleep rejected\n");
36410 -               return -EBUSY;
36411 -       }
36412 -
36413 -       /* Sync the disks. */
36414 -       /* XXX It would be nice to have some way to ensure that
36415 -        * nobody is dirtying any new buffers while we wait.
36416 -        * BenH: Moved to _after_ sleep request and changed video
36417 -        * drivers to vmalloc() during sleep request. This way, all
36418 -        * vmalloc's are done before actual sleep of block drivers */
36419 -       sys_sync();
36420 -
36421 -       /* Sleep can fail now. May not be very robust but useful for debugging */
36422 -       ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
36423 -       if (ret != PBOOK_SLEEP_OK) {
36424 -               printk("pmu: sleep failed\n");
36425 +       ret = pmac_suspend_devices();
36426 +       if (ret) {
36427                 pbook_free_pci_save();
36428 -               return -EBUSY;
36429 +               printk(KERN_ERR "Sleep rejected by devices\n");
36430 +               return ret;
36431         }
36432  
36433 -       /* Wait for completion of async backlight requests */
36434 -       while (!bright_req_1.complete || !bright_req_2.complete ||
36435 -               !bright_req_3.complete || !batt_req.complete)
36436 -               pmu_poll();
36437 -
36438 -       /* Disable all interrupts except pmu */
36439 -       pmac_sleep_save_intrs(vias->intrs[0].line);
36440 -
36441 -       /* Make sure the decrementer won't interrupt us */
36442 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
36443 -       /* Make sure any pending DEC interrupt occurring while we did
36444 -        * the above didn't re-enable the DEC */
36445 -       mb();
36446 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
36447 -
36448         /* Save the state of PCI config space for some slots */
36449         pbook_pci_save();
36450  
36451 @@ -2303,25 +2664,13 @@
36452         out_be32(mem_ctrl_sleep, 0x3f);
36453         pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0);
36454         pbook_pci_restore();
36455 +       pmu_unlock();
36456  
36457         /* wait for the PMU interrupt sequence to complete */
36458         while (asleep)
36459                 mb();
36460  
36461 -       /* reenable interrupts */
36462 -       pmac_sleep_restore_intrs();
36463 -
36464 -       /* Leave some time for HW to settle down */
36465 -       mdelay(100);
36466 -
36467 -       /* Restart jiffies & scheduling */
36468 -       wakeup_decrementer();
36469 -
36470 -       /* Re-enable local CPU interrupts */
36471 -       local_irq_enable();
36472 -
36473 -       /* Notify drivers */
36474 -       broadcast_wake();
36475 +       pmac_wakeup_devices();
36476  
36477         pbook_free_pci_save();
36478         iounmap(mem_ctrl);
36479 @@ -2524,7 +2873,7 @@
36480                         break;
36481                 case PMU_HEATHROW_BASED:
36482                 case PMU_PADDINGTON_BASED:
36483 -                       error = powerbook_sleep_G3();
36484 +                       error = powerbook_sleep_grackle();
36485                         break;
36486                 case PMU_KEYLARGO_BASED:
36487                         error = powerbook_sleep_Core99();
36488 @@ -2676,8 +3025,15 @@
36489  
36490  EXPORT_SYMBOL(pmu_request);
36491  EXPORT_SYMBOL(pmu_poll);
36492 +EXPORT_SYMBOL(pmu_poll_adb);
36493 +EXPORT_SYMBOL(pmu_wait_complete);
36494  EXPORT_SYMBOL(pmu_suspend);
36495  EXPORT_SYMBOL(pmu_resume);
36496 +EXPORT_SYMBOL(pmu_unlock);
36497 +EXPORT_SYMBOL(pmu_i2c_combined_read);
36498 +EXPORT_SYMBOL(pmu_i2c_stdsub_write);
36499 +EXPORT_SYMBOL(pmu_i2c_simple_read);
36500 +EXPORT_SYMBOL(pmu_i2c_simple_write);
36501  #ifdef CONFIG_PMAC_PBOOK
36502  EXPORT_SYMBOL(pmu_register_sleep_notifier);
36503  EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
36504 diff -Nru a/drivers/md/md.c b/drivers/md/md.c
36505 --- a/drivers/md/md.c   Thu Aug  7 02:25:25 2003
36506 +++ b/drivers/md/md.c   Tue Aug 26 09:25:41 2003
36507 @@ -179,7 +179,6 @@
36508                 mddev_map[mdidx(mddev)] = NULL;
36509                 blk_put_queue(mddev->queue);
36510                 kfree(mddev);
36511 -               MOD_DEC_USE_COUNT;
36512         }
36513         spin_unlock(&all_mddevs_lock);
36514  }
36515 @@ -201,7 +200,6 @@
36516                 mddev_map[unit] = new;
36517                 list_add(&new->all_mddevs, &all_mddevs);
36518                 spin_unlock(&all_mddevs_lock);
36519 -               MOD_INC_USE_COUNT;
36520                 return new;
36521         }
36522         spin_unlock(&all_mddevs_lock);
36523 @@ -640,14 +638,13 @@
36524         /* make rdev->sb match mddev data..
36525          *
36526          * 1/ zero out disks
36527 -        * 2/ Add info for each disk, keeping track of highest desc_nr
36528 -        * 3/ any empty disks < highest become removed
36529 +        * 2/ Add info for each disk, keeping track of highest desc_nr (next_spare);
36530 +        * 3/ any empty disks < next_spare become removed
36531          *
36532          * disks[0] gets initialised to REMOVED because
36533          * we cannot be sure from other fields if it has
36534          * been initialised or not.
36535          */
36536 -       int highest = 0;
36537         int i;
36538         int active=0, working=0,failed=0,spare=0,nr_disks=0;
36539  
36540 @@ -718,17 +715,17 @@
36541                         spare++;
36542                         working++;
36543                 }
36544 -               if (rdev2->desc_nr > highest)
36545 -                       highest = rdev2->desc_nr;
36546         }
36547         
36548 -       /* now set the "removed" bit on any non-trailing holes */
36549 -       for (i=0; i<highest; i++) {
36550 +       /* now set the "removed" and "faulty" bits on any missing devices */
36551 +       for (i=0 ; i < mddev->raid_disks ; i++) {
36552                 mdp_disk_t *d = &sb->disks[i];
36553                 if (d->state == 0 && d->number == 0) {
36554                         d->number = i;
36555                         d->raid_disk = i;
36556                         d->state = (1<<MD_DISK_REMOVED);
36557 +                       d->state |= (1<<MD_DISK_FAULTY);
36558 +                       failed++;
36559                 }
36560         }
36561         sb->nr_disks = nr_disks;
36562 @@ -1612,12 +1609,6 @@
36563         spin_unlock(&pers_lock);
36564  
36565         blk_queue_make_request(mddev->queue, mddev->pers->make_request);
36566 -       printk("%s: setting max_sectors to %d, segment boundary to %d\n",
36567 -               disk->disk_name,
36568 -               chunk_size >> 9,
36569 -               (chunk_size>>1)-1);
36570 -       blk_queue_max_sectors(mddev->queue, chunk_size >> 9);
36571 -       blk_queue_segment_boundary(mddev->queue, (chunk_size>>1) - 1);
36572         mddev->queue->queuedata = mddev;
36573  
36574         err = mddev->pers->run(mddev);
36575 @@ -2366,17 +2357,14 @@
36576                         unsigned int cmd, unsigned long arg)
36577  {
36578         char b[BDEVNAME_SIZE];
36579 -       unsigned int minor;
36580 +       unsigned int minor = iminor(inode);
36581         int err = 0;
36582         struct hd_geometry *loc = (struct hd_geometry *) arg;
36583         mddev_t *mddev = NULL;
36584 -       kdev_t dev;
36585  
36586         if (!capable(CAP_SYS_ADMIN))
36587                 return -EACCES;
36588  
36589 -       dev = inode->i_rdev;
36590 -       minor = minor(dev);
36591         if (minor >= MAX_MD_DEVS) {
36592                 MD_BUG();
36593                 return -EINVAL;
36594 @@ -2615,7 +2603,7 @@
36595         /*
36596          * Succeed if we can find or allocate a mddev structure.
36597          */
36598 -       mddev_t *mddev = mddev_find(minor(inode->i_rdev));
36599 +       mddev_t *mddev = mddev_find(iminor(inode));
36600         int err = -ENOMEM;
36601  
36602         if (!mddev)
36603 @@ -3590,6 +3578,7 @@
36604                 if (!disks[i])
36605                         continue;
36606                 mddev = disk->private_data;
36607 +               export_array(mddev);
36608                 del_gendisk(disk);
36609                 put_disk(disk);
36610                 mddev_put(mddev);
36611 diff -Nru a/drivers/md/raid0.c b/drivers/md/raid0.c
36612 --- a/drivers/md/raid0.c        Thu Aug 14 18:16:17 2003
36613 +++ b/drivers/md/raid0.c        Sat Aug 23 15:07:18 2003
36614 @@ -231,6 +231,13 @@
36615         mdk_rdev_t *rdev;
36616         struct list_head *tmp;
36617  
36618 +       printk("md%d: setting max_sectors to %d, segment boundary to %d\n",
36619 +              mdidx(mddev),
36620 +              mddev->chunk_size >> 9,
36621 +              (mddev->chunk_size>>1)-1);
36622 +       blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9);
36623 +       blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1);
36624 +
36625         conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
36626         if (!conf)
36627                 goto out;
36628 diff -Nru a/drivers/md/raid5.c b/drivers/md/raid5.c
36629 --- a/drivers/md/raid5.c        Sun Aug 10 16:01:44 2003
36630 +++ b/drivers/md/raid5.c        Sat Aug 23 15:07:16 2003
36631 @@ -1326,7 +1326,7 @@
36632                         (unsigned long long)new_sector, 
36633                         (unsigned long long)logical_sector);
36634  
36635 -               sh = get_active_stripe(conf, new_sector, pd_idx, 0/*(bi->bi_rw&RWA_MASK)*/);
36636 +               sh = get_active_stripe(conf, new_sector, pd_idx, (bi->bi_rw&RWA_MASK));
36637                 if (sh) {
36638  
36639                         add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK));
36640 @@ -1334,7 +1334,12 @@
36641                         raid5_plug_device(conf);
36642                         handle_stripe(sh);
36643                         release_stripe(sh);
36644 +               } else {
36645 +                       /* cannot get stripe for read-ahead, just give-up */
36646 +                       clear_bit(BIO_UPTODATE, &bi->bi_flags);
36647 +                       break;
36648                 }
36649 +                       
36650         }
36651         spin_lock_irq(&conf->device_lock);
36652         if (--bi->bi_phys_segments == 0) {
36653 diff -Nru a/drivers/md/xor.c b/drivers/md/xor.c
36654 --- a/drivers/md/xor.c  Wed Jul 24 08:36:02 2002
36655 +++ b/drivers/md/xor.c  Sat Aug 23 15:07:12 2003
36656 @@ -134,7 +134,10 @@
36657         return 0;
36658  }
36659  
36660 +static __exit void xor_exit(void) { }
36661 +
36662  EXPORT_SYMBOL(xor_block);
36663  MODULE_LICENSE("GPL");
36664  
36665  module_init(calibrate_xor_block);
36666 +module_exit(xor_exit);
36667 diff -Nru a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
36668 --- a/drivers/media/common/saa7146_fops.c       Mon Jul  7 04:28:54 2003
36669 +++ b/drivers/media/common/saa7146_fops.c       Tue Aug 26 09:25:41 2003
36670 @@ -157,7 +157,7 @@
36671  
36672  static int fops_open(struct inode *inode, struct file *file)
36673  {
36674 -       unsigned int minor = minor(inode->i_rdev);
36675 +       unsigned int minor = iminor(inode);
36676         struct saa7146_dev *h = NULL, *dev = NULL;
36677         struct list_head *list;
36678         struct saa7146_fh *fh = NULL;
36679 diff -Nru a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
36680 --- a/drivers/media/common/saa7146_video.c      Thu Jul 31 16:47:19 2003
36681 +++ b/drivers/media/common/saa7146_video.c      Sun Aug 31 16:14:08 2003
36682 @@ -359,41 +359,41 @@
36683  
36684  static struct v4l2_queryctrl controls[] = {
36685         {
36686 -               id:            V4L2_CID_BRIGHTNESS,
36687 -               name:          "Brightness",
36688 -               minimum:       0,
36689 -               maximum:       255,
36690 -               step:          1,
36691 -               default_value: 128,
36692 -               type:          V4L2_CTRL_TYPE_INTEGER,
36693 +               .id            = V4L2_CID_BRIGHTNESS,
36694 +               .name          = "Brightness",
36695 +               .minimum       = 0,
36696 +               .maximum       = 255,
36697 +               .step          = 1,
36698 +               .default_value = 128,
36699 +               .type          = V4L2_CTRL_TYPE_INTEGER,
36700         },{
36701 -               id:            V4L2_CID_CONTRAST,
36702 -               name:          "Contrast",
36703 -               minimum:       0,
36704 -               maximum:       127,
36705 -               step:          1,
36706 -               default_value: 64,
36707 -               type:          V4L2_CTRL_TYPE_INTEGER,
36708 +               .id            = V4L2_CID_CONTRAST,
36709 +               .name          = "Contrast",
36710 +               .minimum       = 0,
36711 +               .maximum       = 127,
36712 +               .step          = 1,
36713 +               .default_value = 64,
36714 +               .type          = V4L2_CTRL_TYPE_INTEGER,
36715         },{
36716 -               id:            V4L2_CID_SATURATION,
36717 -               name:          "Saturation",
36718 -               minimum:       0,
36719 -               maximum:       127,
36720 -               step:          1,
36721 -               default_value: 64,
36722 -               type:          V4L2_CTRL_TYPE_INTEGER,
36723 +               .id            = V4L2_CID_SATURATION,
36724 +               .name          = "Saturation",
36725 +               .minimum       = 0,
36726 +               .maximum       = 127,
36727 +               .step          = 1,
36728 +               .default_value = 64,
36729 +               .type          = V4L2_CTRL_TYPE_INTEGER,
36730         },{
36731 -               id:            V4L2_CID_VFLIP,
36732 -               name:          "Vertical flip",
36733 -               minimum:       0,
36734 -               maximum:       1,
36735 -               type:          V4L2_CTRL_TYPE_BOOLEAN,
36736 +               .id            = V4L2_CID_VFLIP,
36737 +               .name          = "Vertical flip",
36738 +               .minimum       = 0,
36739 +               .maximum       = 1,
36740 +               .type          = V4L2_CTRL_TYPE_BOOLEAN,
36741         },{
36742 -               id:            V4L2_CID_HFLIP,
36743 -               name:          "Horizontal flip",
36744 -               minimum:       0,
36745 -               maximum:       1,
36746 -               type:          V4L2_CTRL_TYPE_BOOLEAN,
36747 +               .id            = V4L2_CID_HFLIP,
36748 +               .name          = "Horizontal flip",
36749 +               .minimum       = 0,
36750 +               .maximum       = 1,
36751 +               .type          = V4L2_CTRL_TYPE_BOOLEAN,
36752         },
36753  };
36754  static int NUM_CONTROLS = sizeof(controls)/sizeof(struct v4l2_queryctrl);
36755 diff -Nru a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
36756 --- a/drivers/media/dvb/dvb-core/dvbdev.c       Tue Aug 12 13:25:49 2003
36757 +++ b/drivers/media/dvb/dvb-core/dvbdev.c       Tue Aug 26 09:25:41 2003
36758 @@ -73,7 +73,7 @@
36759  {
36760         struct dvb_device *dvbdev;
36761         
36762 -       dvbdev = dvbdev_find_device (minor(inode->i_rdev));
36763 +       dvbdev = dvbdev_find_device (iminor(inode));
36764  
36765         if (dvbdev && dvbdev->fops) {
36766                 int err = 0;
36767 diff -Nru a/drivers/media/dvb/frontends/grundig_29504-401.c b/drivers/media/dvb/frontends/grundig_29504-401.c
36768 --- a/drivers/media/dvb/frontends/grundig_29504-401.c   Wed Jun 18 05:03:14 2003
36769 +++ b/drivers/media/dvb/frontends/grundig_29504-401.c   Sun Aug 31 16:14:08 2003
36770 @@ -37,15 +37,15 @@
36771  
36772  
36773  struct dvb_frontend_info grundig_29504_401_info = {
36774 -       name: "Grundig 29504-401",
36775 -       type: FE_OFDM,
36776 -/*     frequency_min: ???,*/
36777 -/*     frequency_max: ???,*/
36778 -       frequency_stepsize: 166666,
36779 -/*      frequency_tolerance: ???,*/
36780 -/*      symbol_rate_tolerance: ???,*/
36781 -       notifier_delay: 0,
36782 -       caps: FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 
36783 +       .name = "Grundig 29504-401",
36784 +       .type = FE_OFDM,
36785 +/*     .frequency_min = ???,*/
36786 +/*     .frequency_max = ???,*/
36787 +       .frequency_stepsize = 166666,
36788 +/*      .frequency_tolerance = ???,*/
36789 +/*      .symbol_rate_tolerance = ???,*/
36790 +       .notifier_delay = 0,
36791 +       .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
36792               FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
36793               FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
36794               FE_CAN_MUTE_TS /*| FE_CAN_CLEAN_SETUP*/
36795 diff -Nru a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
36796 --- a/drivers/media/dvb/frontends/ves1820.c     Thu Jun 19 23:48:36 2003
36797 +++ b/drivers/media/dvb/frontends/ves1820.c     Sun Aug 31 16:14:08 2003
36798 @@ -81,9 +81,9 @@
36799         .symbol_rate_min = (XIN/2)/64,     /* SACLK/64 == (XIN/2)/64 */
36800         .symbol_rate_max = (XIN/2)/4,      /* SACLK/4 */
36801  #if 0
36802 -       frequency_tolerance: ???,
36803 -       symbol_rate_tolerance: ???,  /* ppm */  /* == 8% (spec p. 5) */
36804 -       notifier_delay: ?,
36805 +       .frequency_tolerance = ???,
36806 +       .symbol_rate_tolerance = ???,  /* ppm */  /* == 8% (spec p. 5) */
36807 +       .notifier_delay = ?,
36808  #endif
36809         .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
36810                 FE_CAN_QAM_128 | FE_CAN_QAM_256 | 
36811 diff -Nru a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
36812 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c Mon Aug 11 07:56:25 2003
36813 +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c Sat Aug 23 12:49:46 2003
36814 @@ -1249,7 +1249,7 @@
36815         if ((err = usb_register(&ttusb_driver)) < 0) {
36816                 printk("%s: usb_register failed! Error number %d",
36817                        __FILE__, err);
36818 -               return -1;
36819 +               return err;
36820         }
36821  
36822         return 0;
36823 diff -Nru a/drivers/media/dvb/ttusb-dec/dec2000_frontend.c b/drivers/media/dvb/ttusb-dec/dec2000_frontend.c
36824 --- a/drivers/media/dvb/ttusb-dec/dec2000_frontend.c    Mon Jul 14 02:56:39 2003
36825 +++ b/drivers/media/dvb/ttusb-dec/dec2000_frontend.c    Sun Aug 31 16:14:08 2003
36826 @@ -30,12 +30,12 @@
36827  #define dprintk        if (debug) printk
36828  
36829  static struct dvb_frontend_info dec2000_frontend_info = {
36830 -       name:                   "TechnoTrend/Hauppauge DEC-2000-t Frontend",
36831 -       type:                   FE_OFDM,
36832 -       frequency_min:          51000000,
36833 -       frequency_max:          858000000,
36834 -       frequency_stepsize:     62500,
36835 -       caps:   FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
36836 +       .name                   = "TechnoTrend/Hauppauge DEC-2000-t Frontend",
36837 +       .type                   = FE_OFDM,
36838 +       .frequency_min          = 51000000,
36839 +       .frequency_max          = 858000000,
36840 +       .frequency_stepsize     = 62500,
36841 +       .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
36842                 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
36843                 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
36844                 FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
36845 diff -Nru a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
36846 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c   Sat Aug  9 06:43:04 2003
36847 +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c   Sun Aug 31 16:14:08 2003
36848 @@ -1003,10 +1003,10 @@
36849  };
36850  
36851  static struct usb_driver ttusb_dec_driver = {
36852 -      name:            DRIVER_NAME,
36853 -      probe:           ttusb_dec_probe,
36854 -      disconnect:      ttusb_dec_disconnect,
36855 -      id_table:                ttusb_dec_table,
36856 +      .name            = DRIVER_NAME,
36857 +      .probe           = ttusb_dec_probe,
36858 +      .disconnect      = ttusb_dec_disconnect,
36859 +      .id_table                = ttusb_dec_table,
36860  };
36861  
36862  static int __init ttusb_dec_init(void)
36863 diff -Nru a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
36864 --- a/drivers/media/video/Kconfig       Thu Aug 21 09:02:59 2003
36865 +++ b/drivers/media/video/Kconfig       Sun Aug 24 01:26:51 2003
36866 @@ -201,7 +201,7 @@
36867  
36868  config VIDEO_ZR36120
36869         tristate "Zoran ZR36120/36125 Video For Linux"
36870 -       depends on VIDEO_DEV && PCI && I2C
36871 +       depends on VIDEO_DEV && PCI && I2C && BROKEN
36872         help
36873           Support for ZR36120/ZR36125 based frame grabber/overlay boards.
36874           This includes the Victor II, WaveWatcher, Video Wonder, Maxi-TV,
36875 diff -Nru a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
36876 --- a/drivers/media/video/adv7170.c     Wed Aug 20 15:29:21 2003
36877 +++ b/drivers/media/video/adv7170.c     Sun Aug 31 16:14:05 2003
36878 @@ -104,6 +104,7 @@
36879                u8                 value)
36880  {
36881         struct adv7170 *encoder = i2c_get_clientdata(client);
36882 +
36883         encoder->reg[reg] = value;
36884         return i2c_smbus_write_byte_data(client, reg, value);
36885  }
36886 @@ -130,6 +131,7 @@
36887                 struct adv7170 *encoder = i2c_get_clientdata(client);
36888                 struct i2c_msg msg;
36889                 u8 block_data[32];
36890 +
36891                 msg.addr = client->addr;
36892                 msg.flags = client->flags;
36893                 while (len >= 2) {
36894 @@ -143,16 +145,16 @@
36895                                 data += 2;
36896                         } while (len >= 2 && data[0] == reg &&
36897                                  msg.len < 32);
36898 -                       if ((ret =
36899 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
36900 +                       if ((ret = i2c_transfer(client->adapter,
36901 +                                               &msg, 1)) < 0)
36902                                 break;
36903                 }
36904         } else {
36905                 /* do some slow I2C emulation kind of thing */
36906                 while (len >= 2) {
36907                         reg = *data++;
36908 -                       if ((ret =
36909 -                            adv7170_write(client, reg, *data++)) < 0)
36910 +                       if ((ret = adv7170_write(client, reg,
36911 +                                                *data++)) < 0)
36912                                 break;
36913                         len -= 2;
36914                 }
36915 @@ -442,6 +444,7 @@
36916                 dname = adv7171_name;
36917         } else {
36918                 /* We should never get here!!! */
36919 +               kfree(client);
36920                 return 0;
36921         }
36922         snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
36923 @@ -449,6 +452,7 @@
36924  
36925         encoder = kmalloc(sizeof(struct adv7170), GFP_KERNEL);
36926         if (encoder == NULL) {
36927 +               kfree(client);
36928                 return -ENOMEM;
36929         }
36930         memset(encoder, 0, sizeof(struct adv7170));
36931 diff -Nru a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
36932 --- a/drivers/media/video/adv7175.c     Wed Aug 20 15:29:21 2003
36933 +++ b/drivers/media/video/adv7175.c     Sun Aug 31 16:14:05 2003
36934 @@ -100,6 +100,7 @@
36935                u8                 value)
36936  {
36937         struct adv7175 *encoder = i2c_get_clientdata(client);
36938 +
36939         encoder->reg[reg] = value;
36940         return i2c_smbus_write_byte_data(client, reg, value);
36941  }
36942 @@ -126,6 +127,7 @@
36943                 struct adv7175 *encoder = i2c_get_clientdata(client);
36944                 struct i2c_msg msg;
36945                 u8 block_data[32];
36946 +
36947                 msg.addr = client->addr;
36948                 msg.flags = client->flags;
36949                 while (len >= 2) {
36950 @@ -139,16 +141,16 @@
36951                                 data += 2;
36952                         } while (len >= 2 && data[0] == reg &&
36953                                  msg.len < 32);
36954 -                       if ((ret =
36955 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
36956 +                       if ((ret = i2c_transfer(client->adapter,
36957 +                                               &msg, 1)) < 0)
36958                                 break;
36959                 }
36960         } else {
36961                 /* do some slow I2C emulation kind of thing */
36962                 while (len >= 2) {
36963                         reg = *data++;
36964 -                       if ((ret =
36965 -                            adv7175_write(client, reg, *data++)) < 0)
36966 +                       if ((ret = adv7175_write(client, reg,
36967 +                                                *data++)) < 0)
36968                                 break;
36969                         len -= 2;
36970                 }
36971 @@ -163,6 +165,7 @@
36972  {
36973         struct adv7175 *encoder = i2c_get_clientdata(client);
36974         int i, j;
36975 +
36976         printk(KERN_INFO "%s: registry dump\n", I2C_NAME(client));
36977         for (i = 0; i < 182 / 8; i++) {
36978                 printk("%s: 0x%02x -", I2C_NAME(client), i * 8);
36979 @@ -463,6 +466,7 @@
36980                 dname = adv7176_name;
36981         } else {
36982                 /* We should never get here!!! */
36983 +               kfree(client);
36984                 return 0;
36985         }
36986         snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
36987 @@ -470,6 +474,7 @@
36988  
36989         encoder = kmalloc(sizeof(struct adv7175), GFP_KERNEL);
36990         if (encoder == NULL) {
36991 +               kfree(client);
36992                 return -ENOMEM;
36993         }
36994         memset(encoder, 0, sizeof(struct adv7175));
36995 diff -Nru a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
36996 --- a/drivers/media/video/bt819.c       Wed Aug 20 15:29:21 2003
36997 +++ b/drivers/media/video/bt819.c       Sun Aug 31 16:14:05 2003
36998 @@ -113,6 +113,7 @@
36999              u8                 value)
37000  {
37001         struct bt819 *decoder = i2c_get_clientdata(client);
37002 +
37003         decoder->reg[reg] = value;
37004         return i2c_smbus_write_byte_data(client, reg, value);
37005  }
37006 @@ -124,6 +125,7 @@
37007               u8                 value)
37008  {
37009         struct bt819 *decoder = i2c_get_clientdata(client);
37010 +
37011         return bt819_write(client, reg,
37012                            (decoder->
37013                             reg[reg] & ~(1 << bit)) |
37014 @@ -145,6 +147,7 @@
37015                 struct bt819 *decoder = i2c_get_clientdata(client);
37016                 struct i2c_msg msg;
37017                 u8 block_data[32];
37018 +
37019                 msg.addr = client->addr;
37020                 msg.flags = client->flags;
37021                 while (len >= 2) {
37022 @@ -158,8 +161,8 @@
37023                                 data += 2;
37024                         } while (len >= 2 && data[0] == reg &&
37025                                  msg.len < 32);
37026 -                       if ((ret =
37027 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
37028 +                       if ((ret = i2c_transfer(client->adapter,
37029 +                                               &msg, 1)) < 0)
37030                                 break;
37031                 }
37032         } else {
37033 diff -Nru a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
37034 --- a/drivers/media/video/bt856.c       Wed Aug 20 15:29:21 2003
37035 +++ b/drivers/media/video/bt856.c       Sun Aug 31 16:14:05 2003
37036 @@ -98,6 +98,7 @@
37037              u8                 value)
37038  {
37039         struct bt856 *encoder = i2c_get_clientdata(client);
37040 +
37041         encoder->reg[reg - REG_OFFSET] = value;
37042         return i2c_smbus_write_byte_data(client, reg, value);
37043  }
37044 @@ -109,6 +110,7 @@
37045               u8                 value)
37046  {
37047         struct bt856 *encoder = i2c_get_clientdata(client);
37048 +
37049         return bt856_write(client, reg,
37050                            (encoder->
37051                             reg[reg - REG_OFFSET] & ~(1 << bit)) |
37052 @@ -120,6 +122,7 @@
37053  {
37054         int i;
37055         struct bt856 *encoder = i2c_get_clientdata(client);
37056 +
37057         printk(KERN_INFO "%s: register dump:", I2C_NAME(client));
37058         for (i = 0xd6; i <= 0xde; i += 2)
37059                 printk(" %02x", encoder->reg[i - REG_OFFSET]);
37060 @@ -341,6 +344,7 @@
37061  
37062         encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
37063         if (encoder == NULL) {
37064 +               kfree(client);
37065                 return -ENOMEM;
37066         }
37067         memset(encoder, 0, sizeof(struct bt856));
37068 diff -Nru a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
37069 --- a/drivers/media/video/bttv-driver.c Thu Aug  7 14:20:17 2003
37070 +++ b/drivers/media/video/bttv-driver.c Wed Sep  3 23:40:14 2003
37071 @@ -115,6 +115,7 @@
37072  MODULE_DESCRIPTION("bttv - v4l/v4l2 driver module for bt848/878 based cards");
37073  MODULE_AUTHOR("Ralph Metzler & Marcus Metzler & Gerd Knorr");
37074  MODULE_LICENSE("GPL");
37075 +MODULE_ALIAS_CHARDEV_MAJOR(VIDEO_MAJOR);
37076  
37077  /* kernel args */
37078  #ifndef MODULE
37079 @@ -2758,7 +2759,7 @@
37080  
37081  static int bttv_open(struct inode *inode, struct file *file)
37082  {
37083 -       int minor = minor(inode->i_rdev);
37084 +       int minor = iminor(inode);
37085         struct bttv *btv = NULL;
37086         struct bttv_fh *fh;
37087         enum v4l2_buf_type type = 0;
37088 @@ -2894,7 +2895,7 @@
37089  
37090  static int radio_open(struct inode *inode, struct file *file)
37091  {
37092 -       int minor = minor(inode->i_rdev);
37093 +       int minor = iminor(inode);
37094         struct bttv *btv = NULL;
37095         u32 v = 400*16;
37096         unsigned int i;
37097 diff -Nru a/drivers/media/video/meye.c b/drivers/media/video/meye.c
37098 --- a/drivers/media/video/meye.c        Thu Jul 31 08:59:04 2003
37099 +++ b/drivers/media/video/meye.c        Wed Aug 27 04:24:51 2003
37100 @@ -920,7 +920,7 @@
37101  
37102         case VIDIOCGCAP: {
37103                 struct video_capability *b = arg;
37104 -               strcpy(b->name,meye.video_dev.name);
37105 +               strcpy(b->name,meye.video_dev->name);
37106                 b->type = VID_TYPE_CAPTURE;
37107                 b->channels = 1;
37108                 b->audios = 0;
37109 @@ -1225,6 +1225,8 @@
37110         .type           = VID_TYPE_CAPTURE,
37111         .hardware       = VID_HARDWARE_MEYE,
37112         .fops           = &meye_fops,
37113 +       .release        = video_device_release,
37114 +       .minor          = -1,
37115  };
37116  
37117  #ifdef CONFIG_PM
37118 @@ -1275,10 +1277,17 @@
37119                 goto out1;
37120         }
37121  
37122 -       sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1);
37123 -
37124         meye.mchip_dev = pcidev;
37125 -       memcpy(&meye.video_dev, &meye_template, sizeof(meye_template));
37126 +       meye.video_dev = video_device_alloc();
37127 +       if (!meye.video_dev) {
37128 +               printk(KERN_ERR "meye: video_device_alloc() failed!\n");
37129 +               ret = -EBUSY;
37130 +               goto out1;
37131 +       }
37132 +       memcpy(meye.video_dev, &meye_template, sizeof(meye_template));
37133 +       meye.video_dev->dev = &meye.mchip_dev->dev;
37134 +
37135 +       sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1);
37136  
37137         if ((ret = pci_enable_device(meye.mchip_dev))) {
37138                 printk(KERN_ERR "meye: pci_enable_device failed\n");
37139 @@ -1335,7 +1344,7 @@
37140         wait_ms(1);
37141         mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK);
37142  
37143 -       if (video_register_device(&meye.video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
37144 +       if (video_register_device(meye.video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
37145  
37146                 printk(KERN_ERR "meye: video_register_device failed\n");
37147                 ret = -EIO;
37148 @@ -1383,6 +1392,9 @@
37149  out3:
37150         pci_disable_device(meye.mchip_dev);
37151  out2:
37152 +       video_device_release(meye.video_dev);
37153 +       meye.video_dev = NULL;
37154 +
37155         sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 0);
37156  out1:
37157         return ret;
37158 @@ -1390,7 +1402,7 @@
37159  
37160  static void __devexit meye_remove(struct pci_dev *pcidev) {
37161  
37162 -       video_unregister_device(&meye.video_dev);
37163 +       video_unregister_device(meye.video_dev);
37164  
37165         mchip_hic_stop();
37166  
37167 diff -Nru a/drivers/media/video/meye.h b/drivers/media/video/meye.h
37168 --- a/drivers/media/video/meye.h        Wed Apr 16 03:01:38 2003
37169 +++ b/drivers/media/video/meye.h        Tue Aug 26 09:48:06 2003
37170 @@ -312,7 +312,7 @@
37171  
37172         struct meye_queue grabq;        /* queue for buffers to be grabbed */
37173  
37174 -       struct video_device video_dev;  /* video device parameters */
37175 +       struct video_device *video_dev; /* video device parameters */
37176         struct video_picture picture;   /* video picture parameters */
37177         struct meye_params params;      /* additional parameters */
37178  #ifdef CONFIG_PM
37179 diff -Nru a/drivers/media/video/planb.c b/drivers/media/video/planb.c
37180 --- a/drivers/media/video/planb.c       Tue Aug 12 13:24:31 2003
37181 +++ b/drivers/media/video/planb.c       Mon Sep  1 08:41:30 2003
37182 @@ -2158,6 +2158,7 @@
37183         unsigned int            old_base, new_base;
37184         unsigned int            irq;
37185         struct pci_dev          *pdev;
37186 +       int rc;
37187  
37188         if (_machine != _MACH_Pmac)
37189                 return 0;
37190 @@ -2211,18 +2212,25 @@
37191  
37192         pdev = pci_find_slot (bus, dev_fn);
37193         if (!pdev) {
37194 -               printk(KERN_ERR "cannot find slot\n");
37195 -               /* XXX handle error */
37196 +               printk(KERN_ERR "planb: cannot find slot\n");
37197 +               goto err_out;
37198         }
37199  
37200         /* Enable response in memory space, bus mastering,
37201            use memory write and invalidate */
37202 -       pci_write_config_word (pdev, PCI_COMMAND,
37203 -               PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
37204 -               PCI_COMMAND_INVALIDATE);
37205 -       /* Set PCI Cache line size & latency timer */
37206 -       pci_write_config_byte (pdev, PCI_CACHE_LINE_SIZE, 0x8);
37207 -       pci_write_config_byte (pdev, PCI_LATENCY_TIMER, 0x40);
37208 +       rc = pci_enable_device(pdev);
37209 +       if (rc) {
37210 +               printk(KERN_ERR "planb: cannot enable PCI device %s\n",
37211 +                      pci_name(pdev));
37212 +               goto err_out;
37213 +       }
37214 +       rc = pci_set_mwi(pdev);
37215 +       if (rc) {
37216 +               printk(KERN_ERR "planb: cannot enable MWI on PCI device %s\n",
37217 +                      pci_name(pdev));
37218 +               goto err_out_disable;
37219 +       }
37220 +       pci_set_master(pdev);
37221  
37222         /* Set the new base address */
37223         pci_write_config_dword (pdev, confreg, new_base);
37224 @@ -2234,6 +2242,12 @@
37225         pb->irq = irq;
37226         
37227         return planb_num;
37228 +
37229 +err_out_disable:
37230 +       pci_disable_device(pdev);
37231 +err_out:
37232 +       /* FIXME handle error */   /* comment moved from pci_find_slot, above */
37233 +       return 0;
37234  }
37235  
37236  static void release_planb(void)
37237 diff -Nru a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
37238 --- a/drivers/media/video/saa7110.c     Wed Aug 20 15:29:21 2003
37239 +++ b/drivers/media/video/saa7110.c     Sun Aug 31 16:14:05 2003
37240 @@ -86,6 +86,7 @@
37241                u8                 value)
37242  {
37243         struct saa7110 *decoder = i2c_get_clientdata(client);
37244 +
37245         decoder->reg[reg] = value;
37246         return i2c_smbus_write_byte_data(client, reg, value);
37247  }
37248 @@ -97,6 +98,7 @@
37249  {
37250         int ret = -1;
37251         u8 reg = *data++;
37252 +
37253         len--;
37254  
37255         /* the saa7110 has an autoincrement function, use it if
37256 @@ -105,6 +107,7 @@
37257                 struct saa7110 *decoder = i2c_get_clientdata(client);
37258                 struct i2c_msg msg;
37259                 u8 block_data[54];
37260 +
37261                 msg.len = 0;
37262                 msg.buf = (char *) block_data;
37263                 msg.addr = client->addr;
37264 @@ -119,8 +122,8 @@
37265                 }
37266         } else {
37267                 while (len-- >= 1) {
37268 -                       if ((ret =
37269 -                            saa7110_write(client, reg++, *data++)) < 0)
37270 +                       if ((ret = saa7110_write(client, reg++,
37271 +                                                *data++)) < 0)
37272                                 break;
37273                 }
37274         }
37275 @@ -279,6 +282,7 @@
37276         case DECODER_GET_CAPABILITIES:
37277         {
37278                 struct video_decoder_capability *dc = arg;
37279 +
37280                 dc->flags =
37281                     VIDEO_DECODER_PAL | VIDEO_DECODER_NTSC |
37282                     VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO;
37283 diff -Nru a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
37284 --- a/drivers/media/video/saa7111.c     Thu Aug 21 10:13:46 2003
37285 +++ b/drivers/media/video/saa7111.c     Sun Aug 31 16:14:05 2003
37286 @@ -93,6 +93,7 @@
37287                u8                 value)
37288  {
37289         struct saa7111 *decoder = i2c_get_clientdata(client);
37290 +
37291         decoder->reg[reg] = value;
37292         return i2c_smbus_write_byte_data(client, reg, value);
37293  }
37294 @@ -112,6 +113,7 @@
37295                 struct saa7111 *decoder = i2c_get_clientdata(client);
37296                 struct i2c_msg msg;
37297                 u8 block_data[32];
37298 +
37299                 msg.addr = client->addr;
37300                 msg.flags = client->flags;
37301                 while (len >= 2) {
37302 @@ -125,16 +127,16 @@
37303                                 data += 2;
37304                         } while (len >= 2 && data[0] == reg &&
37305                                  msg.len < 32);
37306 -                       if ((ret =
37307 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
37308 +                       if ((ret = i2c_transfer(client->adapter,
37309 +                                               &msg, 1)) < 0)
37310                                 break;
37311                 }
37312         } else {
37313                 /* do some slow I2C emulation kind of thing */
37314                 while (len >= 2) {
37315                         reg = *data++;
37316 -                       if ((ret =
37317 -                            saa7111_write(client, reg, *data++)) < 0)
37318 +                       if ((ret = saa7111_write(client, reg,
37319 +                                                *data++)) < 0)
37320                                 break;
37321                         len -= 2;
37322                 }
37323 diff -Nru a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
37324 --- a/drivers/media/video/saa7114.c     Wed Aug 20 15:29:21 2003
37325 +++ b/drivers/media/video/saa7114.c     Sun Aug 31 16:14:05 2003
37326 @@ -144,6 +144,7 @@
37327                u8                 value)
37328  {
37329         /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
37330 +
37331         /*decoder->reg[reg] = value;*/
37332         return i2c_smbus_write_byte_data(client, reg, value);
37333  }
37334 @@ -163,6 +164,7 @@
37335                 /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
37336                 struct i2c_msg msg;
37337                 u8 block_data[32];
37338 +
37339                 msg.addr = client->addr;
37340                 msg.flags = client->flags;
37341                 while (len >= 2) {
37342 @@ -176,16 +178,16 @@
37343                                 data += 2;
37344                         } while (len >= 2 && data[0] == reg &&
37345                                  msg.len < 32);
37346 -                       if ((ret =
37347 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
37348 +                       if ((ret = i2c_transfer(client->adapter,
37349 +                                               &msg, 1)) < 0)
37350                                 break;
37351                 }
37352         } else {
37353                 /* do some slow I2C emulation kind of thing */
37354                 while (len >= 2) {
37355                         reg = *data++;
37356 -                       if ((ret =
37357 -                            saa7114_write(client, reg, *data++)) < 0)
37358 +                       if ((ret = saa7114_write(client, reg,
37359 +                                                *data++)) < 0)
37360                                 break;
37361                         len -= 2;
37362                 }
37363 @@ -995,6 +997,8 @@
37364                                 KERN_ERR
37365                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
37366                                 I2C_NAME(client), i, err[i]);
37367 +                       kfree(decoder);
37368 +                       kfree(client);
37369                         return 0;
37370                 }
37371         }
37372 @@ -1022,6 +1026,8 @@
37373                                 KERN_ERR
37374                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
37375                                 I2C_NAME(client), i, err[i]);
37376 +                       kfree(decoder);
37377 +                       kfree(client);
37378                         return 0;
37379                 }
37380         }
37381 @@ -1068,6 +1074,8 @@
37382                                 KERN_ERR
37383                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
37384                                 I2C_NAME(client), i, err[i]);
37385 +                       kfree(decoder);
37386 +                       kfree(client);
37387                         return 0;
37388                 }
37389         }
37390 @@ -1107,6 +1115,8 @@
37391                                 KERN_ERR
37392                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
37393                                 I2C_NAME(client), i, err[i]);
37394 +                       kfree(decoder);
37395 +                       kfree(client);
37396                         return 0;
37397                 }
37398         }
37399 @@ -1127,6 +1137,8 @@
37400                                 KERN_ERR
37401                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
37402                                 I2C_NAME(client), i, err[i]);
37403 +                       kfree(decoder);
37404 +                       kfree(client);
37405                         return 0;
37406                 }
37407         }
37408 diff -Nru a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
37409 --- a/drivers/media/video/saa7134/saa7134-oss.c Sun May 25 17:00:00 2003
37410 +++ b/drivers/media/video/saa7134/saa7134-oss.c Tue Aug 26 09:25:41 2003
37411 @@ -215,7 +215,7 @@
37412  
37413  static int dsp_open(struct inode *inode, struct file *file)
37414  {
37415 -       int minor = minor(inode->i_rdev);
37416 +       int minor = iminor(inode);
37417         struct saa7134_dev *h,*dev = NULL;
37418         struct list_head *list;
37419         int err;
37420 @@ -598,7 +598,7 @@
37421  
37422  static int mixer_open(struct inode *inode, struct file *file)
37423  {
37424 -       int minor = minor(inode->i_rdev);
37425 +       int minor = iminor(inode);
37426         struct saa7134_dev *h,*dev = NULL;
37427         struct list_head *list;
37428  
37429 diff -Nru a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
37430 --- a/drivers/media/video/saa7134/saa7134-ts.c  Thu Jul 31 16:47:19 2003
37431 +++ b/drivers/media/video/saa7134/saa7134-ts.c  Tue Aug 26 09:25:41 2003
37432 @@ -166,7 +166,7 @@
37433  
37434  static int ts_open(struct inode *inode, struct file *file)
37435  {
37436 -       int minor = minor(inode->i_rdev);
37437 +       int minor = iminor(inode);
37438         struct saa7134_dev *h,*dev = NULL;
37439         struct list_head *list;
37440         int err;
37441 diff -Nru a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
37442 --- a/drivers/media/video/saa7134/saa7134-video.c       Thu Jul 31 16:47:19 2003
37443 +++ b/drivers/media/video/saa7134/saa7134-video.c       Tue Aug 26 09:25:41 2003
37444 @@ -1131,7 +1131,7 @@
37445  
37446  static int video_open(struct inode *inode, struct file *file)
37447  {
37448 -       int minor = minor(inode->i_rdev);
37449 +       int minor = iminor(inode);
37450         struct saa7134_dev *h,*dev = NULL;
37451         struct saa7134_fh *fh;
37452         struct list_head *list;
37453 diff -Nru a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
37454 --- a/drivers/media/video/saa7185.c     Wed Aug 20 15:29:21 2003
37455 +++ b/drivers/media/video/saa7185.c     Sun Aug 31 16:14:05 2003
37456 @@ -98,6 +98,7 @@
37457                u8                 value)
37458  {
37459         struct saa7185 *encoder = i2c_get_clientdata(client);
37460 +
37461         dprintk(1, KERN_DEBUG "SAA7185: %02x set to %02x\n", reg, value);
37462         encoder->reg[reg] = value;
37463         return i2c_smbus_write_byte_data(client, reg, value);
37464 @@ -118,6 +119,7 @@
37465                 struct saa7185 *encoder = i2c_get_clientdata(client);
37466                 struct i2c_msg msg;
37467                 u8 block_data[32];
37468 +
37469                 msg.addr = client->addr;
37470                 msg.flags = client->flags;
37471                 while (len >= 2) {
37472 @@ -131,16 +133,16 @@
37473                                 data += 2;
37474                         } while (len >= 2 && data[0] == reg &&
37475                                  msg.len < 32);
37476 -                       if ((ret =
37477 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
37478 +                       if ((ret = i2c_transfer(client->adapter,
37479 +                                               &msg, 1)) < 0)
37480                                 break;
37481                 }
37482         } else {
37483                 /* do some slow I2C emulation kind of thing */
37484                 while (len >= 2) {
37485                         reg = *data++;
37486 -                       if ((ret =
37487 -                            saa7185_write(client, reg, *data++)) < 0)
37488 +                       if ((ret = saa7185_write(client, reg,
37489 +                                                *data++)) < 0)
37490                                 break;
37491                         len -= 2;
37492                 }
37493 @@ -434,6 +436,7 @@
37494  
37495         encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL);
37496         if (encoder == NULL) {
37497 +               kfree(client);
37498                 return -ENOMEM;
37499         }
37500         memset(encoder, 0, sizeof(struct saa7185));
37501 diff -Nru a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
37502 --- a/drivers/media/video/stradis.c     Thu Apr 24 03:35:23 2003
37503 +++ b/drivers/media/video/stradis.c     Tue Aug 26 09:25:41 2003
37504 @@ -1946,7 +1946,7 @@
37505  static int saa_open(struct inode *inode, struct file *file)
37506  {
37507         struct saa7146 *saa = NULL;
37508 -       unsigned int minor = minor(inode->i_rdev);
37509 +       unsigned int minor = iminor(inode);
37510         int i;
37511  
37512         for (i = 0; i < SAA7146_MAX; i++) {
37513 diff -Nru a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c
37514 --- a/drivers/media/video/tvmixer.c     Wed Aug 20 15:29:21 2003
37515 +++ b/drivers/media/video/tvmixer.c     Tue Aug 26 09:25:41 2003
37516 @@ -173,7 +173,7 @@
37517  
37518  static int tvmixer_open(struct inode *inode, struct file *file)
37519  {
37520 -        int i, minor = minor(inode->i_rdev);
37521 +        int i, minor = iminor(inode);
37522          struct TVMIXER *mix = NULL;
37523         struct i2c_client *client = NULL;
37524  
37525 diff -Nru a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
37526 --- a/drivers/media/video/videodev.c    Wed Aug  6 02:51:26 2003
37527 +++ b/drivers/media/video/videodev.c    Tue Sep  2 11:40:27 2003
37528 @@ -99,7 +99,7 @@
37529  
37530  struct video_device* video_devdata(struct file *file)
37531  {
37532 -       return video_device[minor(file->f_dentry->d_inode->i_rdev)];
37533 +       return video_device[iminor(file->f_dentry->d_inode)];
37534  }
37535  
37536  /*
37537 @@ -107,7 +107,7 @@
37538   */
37539  static int video_open(struct inode *inode, struct file *file)
37540  {
37541 -       unsigned int minor = minor(inode->i_rdev);
37542 +       unsigned int minor = iminor(inode);
37543         int err = 0;
37544         struct video_device *vfl;
37545         struct file_operations *old_fops;
37546 @@ -349,9 +349,9 @@
37547         if(video_device[vfd->minor]!=vfd)
37548                 panic("videodev: bad unregister");
37549  
37550 -       class_device_unregister(&vfd->class_dev);
37551         devfs_remove(vfd->devfs_name);
37552         video_device[vfd->minor]=NULL;
37553 +       class_device_unregister(&vfd->class_dev);
37554         up(&videodev_lock);
37555  }
37556  
37557 diff -Nru a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
37558 --- a/drivers/media/video/vpx3220.c     Wed Aug 20 15:29:21 2003
37559 +++ b/drivers/media/video/vpx3220.c     Sun Aug 31 16:14:05 2003
37560 @@ -76,6 +76,7 @@
37561                u8                 value)
37562  {
37563         struct vpx3220 *decoder = i2c_get_clientdata(client);
37564 +
37565         decoder->reg[reg] = value;
37566         return i2c_smbus_write_byte_data(client, reg, value);
37567  }
37568 @@ -294,6 +295,7 @@
37569  {
37570         int len = sizeof(init_common);
37571         const unsigned char *data = init_common;
37572 +
37573         while (len > 1) {
37574                 dprintk(1,
37575                         KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n",
37576 diff -Nru a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
37577 --- a/drivers/media/video/zoran.h       Wed Aug 20 15:29:21 2003
37578 +++ b/drivers/media/video/zoran.h       Sun Aug 31 16:14:06 2003
37579 @@ -146,7 +146,7 @@
37580  
37581  #define ZORAN_NAME    "ZORAN"  /* name of the device */
37582  
37583 -#define ZR_DEVNAME(zr) pci_name((zr)->pci_dev)
37584 +#define ZR_DEVNAME(zr) ((zr)->name)
37585  
37586  #define   BUZ_MAX_WIDTH   (zr->timing->Wa)
37587  #define   BUZ_MAX_HEIGHT  (zr->timing->Ha)
37588 @@ -383,7 +383,7 @@
37589  };
37590  
37591  struct zoran {
37592 -       struct video_device video_dev;
37593 +       struct video_device *video_dev;
37594  
37595         struct i2c_adapter i2c_adapter; /* */
37596         struct i2c_algo_bit_data i2c_algo;      /* */
37597 @@ -403,9 +403,7 @@
37598         struct tvnorm *timing;
37599  
37600         unsigned short id;      /* number of this device */
37601 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
37602         char name[32];          /* name of this device */
37603 -#endif
37604         struct pci_dev *pci_dev;        /* PCI device */
37605         unsigned char revision; /* revision of zr36057 */
37606         unsigned int zr36057_adr;       /* bus address of IO mem returned by PCI BIOS */
37607 diff -Nru a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
37608 --- a/drivers/media/video/zoran_card.c  Wed Aug 20 15:29:21 2003
37609 +++ b/drivers/media/video/zoran_card.c  Sun Aug 31 16:14:05 2003
37610 @@ -136,7 +136,8 @@
37611  MODULE_PARM_DESC(pass_through,
37612                  "Pass TV signal through to TV-out when idling");
37613  
37614 -int debug = 1;
37615 +static int debug = 1;
37616 +int *zr_debug = &debug;
37617  MODULE_PARM(debug, "i");
37618  MODULE_PARM_DESC(debug, "Debug level (0-4)");
37619  
37620 @@ -153,7 +154,7 @@
37621  
37622  #define dprintk(num, format, args...) \
37623         do { \
37624 -               if (debug >= num) \
37625 +               if (*zr_debug >= num) \
37626                         printk(format, ##args); \
37627         } while (0)
37628  
37629 @@ -623,6 +624,7 @@
37630  zoran_i2c_getsda (void *data)
37631  {
37632         struct zoran *zr = (struct zoran *) data;
37633 +
37634         return (btread(ZR36057_I2CBR) >> 1) & 1;
37635  }
37636  
37637 @@ -630,6 +632,7 @@
37638  zoran_i2c_getscl (void *data)
37639  {
37640         struct zoran *zr = (struct zoran *) data;
37641 +
37642         return btread(ZR36057_I2CBR) & 1;
37643  }
37644  
37645 @@ -638,6 +641,7 @@
37646                   int   state)
37647  {
37648         struct zoran *zr = (struct zoran *) data;
37649 +
37650         if (state)
37651                 zr->i2cbr |= 2;
37652         else
37653 @@ -650,6 +654,7 @@
37654                   int   state)
37655  {
37656         struct zoran *zr = (struct zoran *) data;
37657 +
37658         if (state)
37659                 zr->i2cbr |= 1;
37660         else
37661 @@ -766,6 +771,7 @@
37662                           struct zoran_jpg_settings *settings)
37663  {
37664         int err = 0, err0 = 0;
37665 +
37666         dprintk(4,
37667                 KERN_DEBUG
37668                 "%s: check_jpg_settings() - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
37669 @@ -977,7 +983,7 @@
37670         if (timeout) {
37671                 dprintk(1, ": time spent: %d\n", 1 * HZ - timeout);
37672         }
37673 -       if (debug > 1)
37674 +       if (*zr_debug > 1)
37675                 print_interrupts(zr);
37676         btwrite(icr, ZR36057_ICR);
37677  }
37678 @@ -986,6 +992,7 @@
37679  zr36057_init (struct zoran *zr)
37680  {
37681         unsigned long mem;
37682 +       void *vdev;
37683         unsigned mem_needed;
37684         int j;
37685         int two = 2;
37686 @@ -1040,11 +1047,16 @@
37687          * in case allocation fails */
37688         mem_needed = BUZ_NUM_STAT_COM * 4;
37689         mem = (unsigned long) kmalloc(mem_needed, GFP_KERNEL);
37690 -       if (!mem) {
37691 +       vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
37692 +       if (!mem || !vdev) {
37693                 dprintk(1,
37694                         KERN_ERR
37695                         "%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
37696                         ZR_DEVNAME(zr));
37697 +               if (vdev)
37698 +                       kfree(vdev);
37699 +               if (mem)
37700 +                       kfree((void *)mem);
37701                 return -ENOMEM;
37702         }
37703         memset((void *) mem, 0, mem_needed);
37704 @@ -1056,17 +1068,19 @@
37705         /*
37706          *   Now add the template and register the device unit.
37707          */
37708 -       memcpy(&zr->video_dev, &zoran_template, sizeof(zoran_template));
37709 -       strcpy(zr->video_dev.name, ZR_DEVNAME(zr));
37710 -       if (video_register_device
37711 -           (&zr->video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
37712 +       zr->video_dev = vdev;
37713 +       memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
37714 +       strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
37715 +       if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER,
37716 +                                 video_nr) < 0) {
37717                 zoran_unregister_i2c(zr);
37718                 kfree((void *) zr->stat_com);
37719 +               kfree(vdev);
37720                 return -1;
37721         }
37722  
37723         zoran_init_hardware(zr);
37724 -       if (debug > 2)
37725 +       if (*zr_debug > 2)
37726                 detect_guest_activity(zr);
37727         test_interrupts(zr);
37728         if (!pass_through) {
37729 @@ -1109,7 +1123,14 @@
37730         kfree((void *) zr->stat_com);
37731         zoran_proc_cleanup(zr);
37732         iounmap(zr->zr36057_mem);
37733 -       video_unregister_device(&zr->video_dev);
37734 +       pci_disable_device(zr->pci_dev);
37735 +       video_unregister_device(zr->video_dev);
37736 +}
37737 +
37738 +void
37739 +zoran_vdev_release (struct video_device *vdev)
37740 +{
37741 +       kfree(vdev);
37742  }
37743  
37744  static struct videocodec_master * __devinit
37745 @@ -1207,6 +1228,7 @@
37746                 } else {
37747                         int i;
37748                         unsigned short ss_vendor, ss_device;
37749 +
37750                         ss_vendor = zr->pci_dev->subsystem_vendor;
37751                         ss_device = zr->pci_dev->subsystem_device;
37752                         dprintk(1,
37753 @@ -1467,6 +1489,7 @@
37754  init_dc10_cards (void)
37755  {
37756         int i;
37757 +
37758         memset(zoran, 0, sizeof(zoran));
37759         printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n",
37760                MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION);
37761 @@ -1523,6 +1546,7 @@
37762         /* take care of Natoma chipset and a revision 1 zr36057 */
37763         for (i = 0; i < zoran_num; i++) {
37764                 struct zoran *zr = &zoran[i];
37765 +
37766                 if (pci_pci_problems & PCIPCI_NATOMA && zr->revision <= 1) {
37767                         zr->jpg_buffers.need_contiguous = 1;
37768                         dprintk(1,
37769 @@ -1546,6 +1570,7 @@
37770  unload_dc10_cards (void)
37771  {
37772         int i;
37773 +
37774         for (i = 0; i < zoran_num; i++)
37775                 zoran_release(&zoran[i]);
37776  }
37777 diff -Nru a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h
37778 --- a/drivers/media/video/zoran_card.h  Wed Aug 20 14:29:31 2003
37779 +++ b/drivers/media/video/zoran_card.h  Sun Aug 31 16:14:03 2003
37780 @@ -40,5 +40,6 @@
37781  extern int zoran_check_jpg_settings(struct zoran *zr,
37782                                     struct zoran_jpg_settings *settings);
37783  extern void zoran_open_init_params(struct zoran *zr);
37784 +extern void zoran_vdev_release(struct video_device *vdev);
37785  
37786  #endif                         /* __ZORAN_CARD_H__ */
37787 diff -Nru a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
37788 --- a/drivers/media/video/zoran_device.c        Wed Aug 20 14:29:31 2003
37789 +++ b/drivers/media/video/zoran_device.c        Sun Aug 31 16:14:05 2003
37790 @@ -58,11 +58,11 @@
37791  extern const struct zoran_format zoran_formats[];
37792  extern const int zoran_num_formats;
37793  
37794 -extern int debug;
37795 +extern int *zr_debug;
37796  
37797  #define dprintk(num, format, args...) \
37798         do { \
37799 -               if (debug >= num) \
37800 +               if (*zr_debug >= num) \
37801                         printk(format, ##args); \
37802         } while (0)
37803  
37804 @@ -170,7 +170,7 @@
37805  static void
37806  dump_guests (struct zoran *zr)
37807  {
37808 -       if (debug > 2) {
37809 +       if (*zr_debug > 2) {
37810                 int i, guest[8];
37811  
37812                 for (i = 1; i < 8; i++) {       // Don't read jpeg codec here
37813 @@ -190,6 +190,7 @@
37814  get_time (void)
37815  {
37816         struct timeval tv;
37817 +
37818         do_gettimeofday(&tv);
37819         return (1000000 * tv.tv_sec + tv.tv_usec);
37820  }
37821 @@ -868,8 +869,8 @@
37822  void
37823  print_interrupts (struct zoran *zr)
37824  {
37825 -       int res, noerr;
37826 -       noerr = 0;
37827 +       int res, noerr = 0;
37828 +
37829         printk(KERN_INFO "%s: interrupts received:", ZR_DEVNAME(zr));
37830         if ((res = zr->field_counter) < -1 || res > 1) {
37831                 printk(" FD:%d", res);
37832 @@ -931,6 +932,7 @@
37833  count_reset_interrupt (struct zoran *zr)
37834  {
37835         u32 isr;
37836 +
37837         if ((isr = btread(ZR36057_ISR) & 0x78000000)) {
37838                 if (isr & ZR36057_ISR_GIRQ1) {
37839                         btwrite(ZR36057_ISR_GIRQ1, ZR36057_ISR);
37840 @@ -961,6 +963,7 @@
37841  jpeg_start (struct zoran *zr)
37842  {
37843         int reg;
37844 +
37845         zr->frame_num = 0;
37846  
37847         /* deassert P_reset, disable code transfer, deassert Active */
37848 @@ -1272,7 +1275,7 @@
37849                 zr->num_errors++;
37850  
37851                 /* Report error */
37852 -               if (debug > 1 && zr->num_errors <= 8) {
37853 +               if (*zr_debug > 1 && zr->num_errors <= 8) {
37854                         long frame;
37855                         frame =
37856                             zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME];
37857 @@ -1453,38 +1456,23 @@
37858                                             0) {
37859                                                 /* it is finished, notify the user */
37860  
37861 -                                               zr->v4l_buffers.buffer[zr->
37862 -                                                                      v4l_grab_frame].
37863 -                                                   state = BUZ_STATE_DONE;
37864 -                                               zr->v4l_buffers.buffer[zr->
37865 -                                                                      v4l_grab_frame].
37866 -                                                   bs.seq =
37867 -                                                   zr->v4l_grab_seq;
37868 -                                               do_gettimeofday(&zr->
37869 -                                                               v4l_buffers.
37870 -                                                               buffer[zr->
37871 -                                                                      v4l_grab_frame].
37872 -                                                               bs.
37873 -                                                               timestamp);
37874 -                                               zr->v4l_grab_frame =
37875 -                                                   NO_GRAB_ACTIVE;
37876 +                                               zr->v4l_buffers.buffer[zr->v4l_grab_frame].state = BUZ_STATE_DONE;
37877 +                                               zr->v4l_buffers.buffer[zr->v4l_grab_frame].bs.seq = zr->v4l_grab_seq;
37878 +                                               do_gettimeofday(&zr->v4l_buffers.buffer[zr->v4l_grab_frame].bs.timestamp);
37879 +                                               zr->v4l_grab_frame = NO_GRAB_ACTIVE;
37880                                                 zr->v4l_pend_tail++;
37881                                         }
37882                                 }
37883  
37884                                 if (zr->v4l_grab_frame == NO_GRAB_ACTIVE)
37885 -                                       wake_up_interruptible(&zr->
37886 -                                                             v4l_capq);
37887 +                                       wake_up_interruptible(&zr->v4l_capq);
37888  
37889                                 /* Check if there is another grab queued */
37890  
37891                                 if (zr->v4l_grab_frame == NO_GRAB_ACTIVE &&
37892 -                                   zr->v4l_pend_tail !=
37893 -                                   zr->v4l_pend_head) {
37894 +                                   zr->v4l_pend_tail != zr->v4l_pend_head) {
37895  
37896 -                                       int frame =
37897 -                                           zr->v4l_pend[zr->
37898 -                                                        v4l_pend_tail &
37899 +                                       int frame = zr->v4l_pend[zr->v4l_pend_tail &
37900                                                          V4L_MASK_FRAME];
37901                                         u32 reg;
37902  
37903 @@ -1544,7 +1532,7 @@
37904  
37905                         if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS ||
37906                             zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
37907 -                               if (debug > 1 &&
37908 +                               if (*zr_debug > 1 &&
37909                                     (!zr->frame_num || zr->JPEG_error)) {
37910                                         printk(KERN_INFO
37911                                                "%s: first frame ready: state=0x%08x odd_even=%d field_per_buff=%d delay=%d\n",
37912 @@ -1559,11 +1547,8 @@
37913                                                 int i;
37914                                                 strcpy(sv, sc);
37915                                                 for (i = 0; i < 4; i++) {
37916 -                                                       if (zr->
37917 -                                                           stat_com[i] &
37918 -                                                           1)
37919 -                                                               sv[i] =
37920 -                                                                   '1';
37921 +                                                       if (zr->stat_com[i] & 1)
37922 +                                                               sv[i] = '1';
37923                                                 }
37924                                                 sv[4] = 0;
37925                                                 printk(KERN_INFO
37926 @@ -1584,7 +1569,7 @@
37927                                                     zr->JPEG_missed;
37928                                 }
37929  
37930 -                               if (debug > 2 && zr->frame_num < 6) {
37931 +                               if (*zr_debug > 2 && zr->frame_num < 6) {
37932                                         int i;
37933                                         printk("%s: seq=%ld stat_com:",
37934                                                ZR_DEVNAME(zr), zr->jpg_seq_num);
37935 @@ -1643,10 +1628,11 @@
37936  zoran_set_pci_master (struct zoran *zr,
37937                       int           set_master)
37938  {
37939 -       u16 command;
37940         if (set_master) {
37941                 pci_set_master(zr->pci_dev);
37942         } else {
37943 +               u16 command;
37944 +
37945                 pci_read_config_word(zr->pci_dev, PCI_COMMAND, &command);
37946                 command &= ~PCI_COMMAND_MASTER;
37947                 pci_write_config_word(zr->pci_dev, PCI_COMMAND, command);
37948 @@ -1657,6 +1643,7 @@
37949  zoran_init_hardware (struct zoran *zr)
37950  {
37951         int j, zero = 0;
37952 +
37953         /* Enable bus-mastering */
37954         zoran_set_pci_master(zr, 1);
37955  
37956 @@ -1718,6 +1705,7 @@
37957  zr36057_init_vfe (struct zoran *zr)
37958  {
37959         u32 reg;
37960 +
37961         reg = btread(ZR36057_VFESPFR);
37962         reg |= ZR36057_VFESPFR_LittleEndian;
37963         reg &= ~ZR36057_VFESPFR_VCLKPol;
37964 @@ -1748,6 +1736,7 @@
37965         if (zr->card.type == LML33 &&
37966             (cmd == DECODER_SET_NORM || DECODER_SET_INPUT)) {
37967                 int res;
37968 +
37969                 // Bt819 needs to reset its FIFO buffer using #FRST pin and
37970                 // LML33 card uses GPIO(7) for that.
37971                 GPIO(zr, 7, 0);
37972 diff -Nru a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
37973 --- a/drivers/media/video/zoran_driver.c        Wed Aug 20 14:29:31 2003
37974 +++ b/drivers/media/video/zoran_driver.c        Sun Aug 31 16:14:05 2003
37975 @@ -51,6 +51,7 @@
37976  #include <linux/delay.h>
37977  #include <linux/slab.h>
37978  #include <linux/pci.h>
37979 +#include <linux/vmalloc.h>
37980  
37981  #include <linux/interrupt.h>
37982  #include <linux/i2c.h>
37983 @@ -187,11 +188,11 @@
37984  #   include <linux/bigphysarea.h>
37985  #endif
37986  
37987 -extern int debug;
37988 +extern int *zr_debug;
37989  
37990  #define dprintk(num, format, args...) \
37991         do { \
37992 -               if (debug >= num) \
37993 +               if (*zr_debug >= num) \
37994                         printk(format, ##args); \
37995         } while (0)
37996  
37997 @@ -370,6 +371,7 @@
37998                         int n =
37999                             (fh->v4l_buffers.buffer_size + PAGE_SIZE -
38000                              1) / PAGE_SIZE;
38001 +
38002                         mem =
38003                             (unsigned char *) bigphysarea_alloc_pages(n, 0,
38004                                                                       GFP_KERNEL);
38005 @@ -412,6 +414,7 @@
38006                                 int size =
38007                                     fh->v4l_buffers.num_buffers *
38008                                     fh->v4l_buffers.buffer_size;
38009 +
38010                                 pmem = get_high_mem(size);
38011                                 if (pmem == 0) {
38012                                         dprintk(1,
38013 @@ -847,9 +850,10 @@
38014                 if (res)
38015                         return res;
38016         }
38017 -       if ((res =
38018 -            zoran_v4l_set_format(file, mp->width, mp->height,
38019 -                                 &zoran_formats[i])))
38020 +       if ((res = zoran_v4l_set_format(file,
38021 +                                       mp->width,
38022 +                                       mp->height,
38023 +                                       &zoran_formats[i])))
38024                 return res;
38025         zr->v4l_settings = fh->v4l_settings;
38026  
38027 @@ -1144,7 +1148,7 @@
38028                 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME];
38029  
38030         /* buffer should now be in BUZ_STATE_DONE */
38031 -       if (debug > 0)
38032 +       if (*zr_debug > 0)
38033                 if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE)
38034                         dprintk(2,
38035                                 KERN_ERR
38036 @@ -1268,7 +1272,7 @@
38037  
38038         /* find the device */
38039         for (i = 0; i < zoran_num; i++) {
38040 -               if (zoran[i].video_dev.minor == minor) {
38041 +               if (zoran[i].video_dev->minor == minor) {
38042                         zr = &zoran[i];
38043                         break;
38044                 }
38045 @@ -1424,7 +1428,7 @@
38046                 /* disable interrupts */
38047                 btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
38048  
38049 -               if (debug > 1)
38050 +               if (*zr_debug > 1)
38051                         print_interrupts(zr);
38052  
38053                 /* Overlay off */
38054 @@ -2032,6 +2036,7 @@
38055         case VIDIOCGCAP:
38056         {
38057                 struct video_capability *vcap = arg;
38058 +
38059                 dprintk(3, KERN_DEBUG "%s: VIDIOCGCAP\n", ZR_DEVNAME(zr));
38060  
38061                 memset(vcap, 0, sizeof(struct video_capability));
38062 @@ -2154,6 +2159,7 @@
38063  
38064                 for (i = 0; i < zoran_num_formats; i++) {
38065                         const struct zoran_format *fmt = &zoran_formats[i];
38066 +
38067                         if (fmt->palette != -1 &&
38068                             fmt->flags & ZORAN_FORMAT_OVERLAY &&
38069                             fmt->palette == vpict->palette &&
38070 @@ -2203,7 +2209,9 @@
38071         case VIDIOCGWIN:
38072         {
38073                 struct video_window *vwin = arg;
38074 +
38075                 dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr));
38076 +
38077                 memset(vwin, 0, sizeof(struct video_window));
38078                 down(&zr->resource_lock);
38079                 vwin->x = fh->overlay_settings.x;
38080 @@ -2241,7 +2249,9 @@
38081         case VIDIOCGFBUF:
38082         {
38083                 struct video_buffer *vbuf = arg;
38084 +
38085                 dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr));
38086 +
38087                 down(&zr->resource_lock);
38088                 *vbuf = zr->buffer;
38089                 up(&zr->resource_lock);
38090 @@ -2285,8 +2295,10 @@
38091         case VIDIOCSYNC:
38092         {
38093                 int *frame = arg, res;
38094 +
38095                 dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n",
38096                         ZR_DEVNAME(zr), *frame);
38097 +
38098                 down(&zr->resource_lock);
38099                 res = v4l_sync(file, *frame);
38100                 up(&zr->resource_lock);
38101 @@ -2300,11 +2312,13 @@
38102         {
38103                 struct video_mmap *vmap = arg;
38104                 int res;
38105 +
38106                 dprintk(3,
38107                         KERN_DEBUG
38108                         "%s: VIDIOCMCAPTURE - frame=%d, geom=%dx%d, fmt=%d\n",
38109                         ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height,
38110                         vmap->format);
38111 +
38112                 down(&zr->resource_lock);
38113                 res = v4l_grab(file, vmap);
38114                 up(&zr->resource_lock);
38115 @@ -2358,7 +2372,8 @@
38116                 struct video_unit *vunit = arg;
38117  
38118                 dprintk(3, KERN_DEBUG "%s: VIDIOCGUNIT\n", ZR_DEVNAME(zr));
38119 -               vunit->video = zr->video_dev.minor;
38120 +
38121 +               vunit->video = zr->video_dev->minor;
38122                 vunit->vbi = VIDEO_NO_UNIT;
38123                 vunit->radio = VIDEO_NO_UNIT;
38124                 vunit->audio = VIDEO_NO_UNIT;
38125 @@ -2393,6 +2408,7 @@
38126         case BUZIOC_G_PARAMS:
38127         {
38128                 struct zoran_params *bparams = arg;
38129 +
38130                 dprintk(3, KERN_DEBUG "%s: BUZIOC_G_PARAMS\n", ZR_DEVNAME(zr));
38131  
38132                 memset(bparams, 0, sizeof(struct zoran_params));
38133 @@ -2686,6 +2702,7 @@
38134                 struct v4l2_fmtdesc *fmt = arg;
38135                 int index = fmt->index, num = -1, i, flag = 0, type =
38136                     fmt->type;
38137 +
38138                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUM_FMT - index=%d\n",
38139                         ZR_DEVNAME(zr), fmt->index);
38140  
38141 @@ -3530,6 +3547,7 @@
38142         case VIDIOC_QUERYCTRL:
38143         {
38144                 struct v4l2_queryctrl *ctrl = arg;
38145 +
38146                 dprintk(3, KERN_DEBUG "%s: VIDIOC_QUERYCTRL - id=%d\n",
38147                         ZR_DEVNAME(zr), ctrl->id);
38148  
38149 @@ -3571,6 +3589,7 @@
38150         case VIDIOC_G_CTRL:
38151         {
38152                 struct v4l2_control *ctrl = arg;
38153 +
38154                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_CTRL - id=%d\n",
38155                         ZR_DEVNAME(zr), ctrl->id);
38156  
38157 @@ -3652,6 +3671,7 @@
38158         case VIDIOC_ENUMSTD:
38159         {
38160                 struct v4l2_standard *std = arg;
38161 +
38162                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUMSTD - index=%d\n",
38163                         ZR_DEVNAME(zr), std->index);
38164  
38165 @@ -3707,6 +3727,7 @@
38166         {
38167                 v4l2_std_id *std = arg;
38168                 int norm;
38169 +
38170                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr));
38171  
38172                 down(&zr->resource_lock);
38173 @@ -3804,6 +3825,7 @@
38174         case VIDIOC_G_INPUT:
38175         {
38176                 int *input = arg;
38177 +
38178                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr));
38179  
38180                 down(&zr->resource_lock);
38181 @@ -3817,6 +3839,7 @@
38182         case VIDIOC_S_INPUT:
38183         {
38184                 int *input = arg, res = 0;
38185 +
38186                 dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n",
38187                         ZR_DEVNAME(zr), *input);
38188  
38189 @@ -3835,6 +3858,7 @@
38190         case VIDIOC_ENUMOUTPUT:
38191         {
38192                 struct v4l2_output *outp = arg;
38193 +
38194                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUMOUTPUT - index=%d\n",
38195                         ZR_DEVNAME(zr), outp->index);
38196  
38197 @@ -4005,7 +4029,9 @@
38198         case VIDIOC_G_JPEGCOMP:
38199         {
38200                 struct v4l2_jpegcompression *params = arg;
38201 -               dprintk(3, KERN_DEBUG "%s: VIDIOC_G_JPEGCOMP\n", ZR_DEVNAME(zr));
38202 +
38203 +               dprintk(3, KERN_DEBUG "%s: VIDIOC_G_JPEGCOMP\n",
38204 +                       ZR_DEVNAME(zr));
38205  
38206                 memset(params, 0, sizeof(*params));
38207  
38208 @@ -4175,6 +4201,7 @@
38209                         } else if (fmt->type ==
38210                                    V4L2_BUF_TYPE_VIDEO_CAPTURE) {
38211                                 int i;
38212 +
38213                                 for (i = 0; i < zoran_num_formats; i++)
38214                                         if (zoran_formats[i].fourcc ==
38215                                             fmt->fmt.pix.pixelformat)
38216 @@ -4321,6 +4348,7 @@
38217  zoran_vm_open (struct vm_area_struct *vma)
38218  {
38219         struct zoran_mapping *map = vma->vm_private_data;
38220 +
38221         map->count++;
38222  }
38223  
38224 @@ -4665,5 +4693,6 @@
38225  #endif
38226         .hardware = ZORAN_HARDWARE,
38227         .fops = &zoran_fops,
38228 +       .release = &zoran_vdev_release,
38229         .minor = -1
38230  };
38231 diff -Nru a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c
38232 --- a/drivers/media/video/zoran_procfs.c        Wed Aug 20 15:38:07 2003
38233 +++ b/drivers/media/video/zoran_procfs.c        Sun Aug 31 16:14:05 2003
38234 @@ -49,11 +49,11 @@
38235  #include "zoran.h"
38236  #include "zoran_procfs.h"
38237  
38238 -extern int debug;
38239 +extern int *zr_debug;
38240  
38241  #define dprintk(num, format, args...) \
38242         do { \
38243 -               if (debug >= num) \
38244 +               if (*zr_debug >= num) \
38245                         printk(format, ##args); \
38246         } while (0)
38247  
38248 @@ -248,6 +248,7 @@
38249  {
38250  #ifdef CONFIG_PROC_FS
38251         char name[8];
38252 +
38253         snprintf(name, 7, "zoran%d", zr->id);
38254         if ((zr->zoran_proc = create_proc_entry(name, 0, 0))) {
38255                 zr->zoran_proc->read_proc = zoran_read_proc;
38256 @@ -272,6 +273,7 @@
38257  {
38258  #ifdef CONFIG_PROC_FS
38259         char name[8];
38260 +
38261         snprintf(name, 7, "zoran%d", zr->id);
38262         if (zr->zoran_proc) {
38263                 remove_proc_entry(name, 0);
38264 diff -Nru a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
38265 --- a/drivers/mtd/devices/Kconfig       Mon Aug 18 11:25:06 2003
38266 +++ b/drivers/mtd/devices/Kconfig       Sun Aug 24 03:43:25 2003
38267 @@ -102,7 +102,7 @@
38268  
38269  config MTD_BLKMTD
38270         tristate "MTD emulation using block device"
38271 -       depends on MTD && BROKEN
38272 +       depends on MTD
38273         help
38274           This driver allows a block device to appear as an MTD. It would
38275           generally be used in the following cases:
38276 diff -Nru a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c
38277 --- a/drivers/mtd/maps/ceiva.c  Wed May 28 08:01:03 2003
38278 +++ b/drivers/mtd/maps/ceiva.c  Sun Aug 31 16:14:08 2003
38279 @@ -64,23 +64,23 @@
38280  
38281  static struct mtd_partition ceiva_partitions[] = {
38282         {
38283 -               name: "Ceiva BOOT partition",
38284 -               size:   BOOT_PARTITION_SIZE_KiB*1024,
38285 -               offset: 0,
38286 +               .name = "Ceiva BOOT partition",
38287 +               .size   = BOOT_PARTITION_SIZE_KiB*1024,
38288 +               .offset = 0,
38289  
38290         },{
38291 -               name: "Ceiva parameters partition",
38292 -               size:   PARAMS_PARTITION_SIZE_KiB*1024,
38293 -               offset: (16 + 8) * 1024,
38294 +               .name = "Ceiva parameters partition",
38295 +               .size   = PARAMS_PARTITION_SIZE_KiB*1024,
38296 +               .offset = (16 + 8) * 1024,
38297         },{
38298 -               name: "Ceiva kernel partition",
38299 -               size: (KERNEL_PARTITION_SIZE_KiB)*1024,
38300 -               offset: 0x20000,
38301 +               .name = "Ceiva kernel partition",
38302 +               .size = (KERNEL_PARTITION_SIZE_KiB)*1024,
38303 +               .offset = 0x20000,
38304  
38305         },{
38306 -               name: "Ceiva root filesystem partition",
38307 -               offset: MTDPART_OFS_APPEND,
38308 -               size: (ROOT_PARTITION_SIZE_KiB)*1024,
38309 +               .name = "Ceiva root filesystem partition",
38310 +               .offset = MTDPART_OFS_APPEND,
38311 +               .size = (ROOT_PARTITION_SIZE_KiB)*1024,
38312         }
38313  };
38314  #endif
38315 diff -Nru a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
38316 --- a/drivers/mtd/maps/pcmciamtd.c      Wed Jun 25 03:30:03 2003
38317 +++ b/drivers/mtd/maps/pcmciamtd.c      Sat Aug 23 08:27:27 2003
38318 @@ -344,9 +344,8 @@
38319   * still open, this will be postponed until it is closed.
38320   */
38321  
38322 -static void pcmciamtd_release(u_long arg)
38323 +static void pcmciamtd_release(dev_link_t *link)
38324  {
38325 -       dev_link_t *link = (dev_link_t *)arg;
38326         struct pcmciamtd_dev *dev = link->priv;
38327  
38328         DEBUG(3, "link = 0x%p", link);
38329 @@ -564,7 +563,7 @@
38330  
38331         if(!dev->win_size) {
38332                 err("Cant allocate memory window");
38333 -               pcmciamtd_release((u_long)link);
38334 +               pcmciamtd_release(link);
38335                 return;
38336         }
38337         DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10);
38338 @@ -576,7 +575,7 @@
38339         dev->win_base = ioremap(req.Base, req.Size);
38340         if(!dev->win_base) {
38341                 err("ioremap(%lu, %u) failed", req.Base, req.Size);
38342 -               pcmciamtd_release((u_long)link);
38343 +               pcmciamtd_release(link);
38344                 return;
38345         }
38346         DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x",
38347 @@ -631,7 +630,7 @@
38348         
38349         if(!mtd) {
38350                 DEBUG(1, "Cant find an MTD");
38351 -               pcmciamtd_release((u_long)link);
38352 +               pcmciamtd_release(link);
38353                 return;
38354         }
38355  
38356 @@ -671,7 +670,7 @@
38357                 map_destroy(mtd);
38358                 dev->mtd_info = NULL;
38359                 err("Couldnt register MTD device");
38360 -               pcmciamtd_release((u_long)link);
38361 +               pcmciamtd_release(link);
38362                 return;
38363         }
38364         snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index);
38365 @@ -683,7 +682,7 @@
38366   cs_failed:
38367         cs_error(link->handle, last_fn, last_ret);
38368         err("CS Error, exiting");
38369 -       pcmciamtd_release((u_long)link);
38370 +       pcmciamtd_release(link);
38371         return;
38372  }
38373  
38374 @@ -710,7 +709,7 @@
38375                                 del_mtd_device(dev->mtd_info);
38376                                 info("mtd%d: Removed", dev->mtd_info->index);
38377                         }
38378 -                       mod_timer(&link->release, jiffies + HZ/20);
38379 +                       pcmciamtd_release(link);
38380                 }
38381                 break;
38382         case CS_EVENT_CARD_INSERTION:
38383 @@ -751,10 +750,8 @@
38384  {
38385         DEBUG(3, "link=0x%p", link);
38386  
38387 -       del_timer(&link->release);
38388 -
38389         if(link->state & DEV_CONFIG) {
38390 -               pcmciamtd_release((u_long)link);
38391 +               pcmciamtd_release(link);
38392         }
38393  
38394         if (link->handle) {
38395 @@ -789,10 +786,6 @@
38396         memset(dev, 0, sizeof(*dev));
38397         link = &dev->link;
38398         link->priv = dev;
38399 -
38400 -       init_timer(&link->release);
38401 -       link->release.function = &pcmciamtd_release;
38402 -       link->release.data = (u_long)link;
38403  
38404         link->conf.Attributes = 0;
38405         link->conf.IntType = INT_MEMORY;
38406 diff -Nru a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
38407 --- a/drivers/mtd/mtdchar.c     Wed May 28 08:01:05 2003
38408 +++ b/drivers/mtd/mtdchar.c     Tue Aug 26 09:25:41 2003
38409 @@ -59,7 +59,7 @@
38410  
38411  static int mtd_open(struct inode *inode, struct file *file)
38412  {
38413 -       int minor = minor(inode->i_rdev);
38414 +       int minor = iminor(inode);
38415         int devnum = minor >> 1;
38416         struct mtd_info *mtd;
38417  
38418 diff -Nru a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c
38419 --- a/drivers/mtd/nand/autcpu12.c       Mon Jun 23 05:34:08 2003
38420 +++ b/drivers/mtd/nand/autcpu12.c       Sun Aug 31 16:14:08 2003
38421 @@ -73,39 +73,39 @@
38422  extern struct nand_oobinfo jffs2_oobinfo;
38423  
38424  static struct mtd_partition partition_info16k[] = {
38425 -       { name: "AUTCPU12 flash partition 1",
38426 -         offset:  0,
38427 -         size:    8 * SZ_1M },
38428 -       { name: "AUTCPU12 flash partition 2",
38429 -         offset:  8 * SZ_1M,
38430 -         size:    8 * SZ_1M },
38431 +       { .name = "AUTCPU12 flash partition 1",
38432 +         .offset  = 0,
38433 +         .size =    8 * SZ_1M },
38434 +       { .name = "AUTCPU12 flash partition 2",
38435 +         .offset =  8 * SZ_1M,
38436 +         .size =    8 * SZ_1M },
38437  };
38438  
38439  static struct mtd_partition partition_info32k[] = {
38440 -       { name: "AUTCPU12 flash partition 1",
38441 -         offset:  0,
38442 -         size:    8 * SZ_1M },
38443 -       { name: "AUTCPU12 flash partition 2",
38444 -         offset:  8 * SZ_1M,
38445 -         size:   24 * SZ_1M },
38446 +       { .name = "AUTCPU12 flash partition 1",
38447 +         .offset  = 0,
38448 +         .size =    8 * SZ_1M },
38449 +       { .name = "AUTCPU12 flash partition 2",
38450 +         .offset =  8 * SZ_1M,
38451 +         .size =   24 * SZ_1M },
38452  };
38453  
38454  static struct mtd_partition partition_info64k[] = {
38455 -       { name: "AUTCPU12 flash partition 1",
38456 -         offset:  0,
38457 -         size:   16 * SZ_1M },
38458 -       { name: "AUTCPU12 flash partition 2",
38459 -         offset: 16 * SZ_1M,
38460 -         size:   48 * SZ_1M },
38461 +       { .name = "AUTCPU12 flash partition 1",
38462 +         .offset  = 0,
38463 +         .size =   16 * SZ_1M },
38464 +       { .name = "AUTCPU12 flash partition 2",
38465 +         .offset = 16 * SZ_1M,
38466 +         .size =   48 * SZ_1M },
38467  };
38468  
38469  static struct mtd_partition partition_info128k[] = {
38470 -       { name: "AUTCPU12 flash partition 1",
38471 -         offset:  0,
38472 -         size:   16 * SZ_1M },
38473 -       { name: "AUTCPU12 flash partition 2",
38474 -         offset: 16 * SZ_1M,
38475 -         size:   112 * SZ_1M },
38476 +       { .name = "AUTCPU12 flash partition 1",
38477 +         .offset  = 0,
38478 +         .size =   16 * SZ_1M },
38479 +       { .name = "AUTCPU12 flash partition 2",
38480 +         .offset = 16 * SZ_1M,
38481 +         .size =   112 * SZ_1M },
38482  };
38483  
38484  #define NUM_PARTITIONS16K 2
38485 diff -Nru a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
38486 --- a/drivers/mtd/nand/edb7312.c        Wed May 28 08:01:25 2003
38487 +++ b/drivers/mtd/nand/edb7312.c        Sun Aug 31 16:14:08 2003
38488 @@ -71,9 +71,9 @@
38489   * Define static partitions for flash device
38490   */
38491  static struct mtd_partition partition_info[] = {
38492 -       { name: "EP7312 Nand Flash",
38493 -                 offset: 0,
38494 -                 size: 8*1024*1024 }
38495 +       { .name = "EP7312 Nand Flash",
38496 +                 .offset = 0,
38497 +                 .size = 8*1024*1024 }
38498  };
38499  #define NUM_PARTITIONS 1
38500  
38501 diff -Nru a/drivers/net/3c501.c b/drivers/net/3c501.c
38502 --- a/drivers/net/3c501.c       Sun Apr 20 22:41:08 2003
38503 +++ b/drivers/net/3c501.c       Tue Aug 26 13:21:28 2003
38504 @@ -307,7 +307,7 @@
38505         dev->stop = &el1_close;
38506         dev->get_stats = &el1_get_stats;
38507         dev->set_multicast_list = &set_multicast_list;
38508 -       dev->do_ioctl = netdev_ioctl;
38509 +       dev->ethtool_ops = &netdev_ethtool_ops;
38510  
38511         /*
38512          *      Setup the generic properties
38513 @@ -857,86 +857,31 @@
38514         }
38515  }
38516  
38517 -/**
38518 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
38519 - * @dev: network interface on which out-of-band action is to be performed
38520 - * @useraddr: userspace address to which data is to be read and returned
38521 - *
38522 - * Process the various commands of the SIOCETHTOOL interface.
38523 - */
38524  
38525 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
38526 +static void netdev_get_drvinfo(struct net_device *dev,
38527 +                              struct ethtool_drvinfo *info)
38528  {
38529 -       u32 ethcmd;
38530 -
38531 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
38532 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
38533 -
38534 -       if (get_user(ethcmd, (u32 *)useraddr))
38535 -               return -EFAULT;
38536 -
38537 -       switch (ethcmd) {
38538 -
38539 -       case ETHTOOL_GDRVINFO: {
38540 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
38541 -               strcpy (info.driver, DRV_NAME);
38542 -               strcpy (info.version, DRV_VERSION);
38543 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
38544 -               if (copy_to_user (useraddr, &info, sizeof (info)))
38545 -                       return -EFAULT;
38546 -               return 0;
38547 -       }
38548 -
38549 -       /* get message-level */
38550 -       case ETHTOOL_GMSGLVL: {
38551 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
38552 -               edata.data = debug;
38553 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38554 -                       return -EFAULT;
38555 -               return 0;
38556 -       }
38557 -       /* set message-level */
38558 -       case ETHTOOL_SMSGLVL: {
38559 -               struct ethtool_value edata;
38560 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
38561 -                       return -EFAULT;
38562 -               debug = edata.data;
38563 -               return 0;
38564 -       }
38565 -
38566 -       default:
38567 -               break;
38568 -       }
38569 -
38570 -       return -EOPNOTSUPP;
38571 +       strcpy(info->driver, DRV_NAME);
38572 +       strcpy(info->version, DRV_VERSION);
38573 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
38574  }
38575  
38576 -/**
38577 - * netdev_ioctl: Handle network interface ioctls
38578 - * @dev: network interface on which out-of-band action is to be performed
38579 - * @rq: user request data
38580 - * @cmd: command issued by user
38581 - *
38582 - * Process the various out-of-band ioctls passed to this driver.
38583 - */
38584 +static u32 netdev_get_msglevel(struct net_device *dev)
38585 +{
38586 +       return debug;
38587 +}
38588  
38589 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
38590 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
38591  {
38592 -       int rc = 0;
38593 +       debug = level;
38594 +}
38595  
38596 -       switch (cmd) {
38597 -       case SIOCETHTOOL:
38598 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
38599 -               break;
38600 -
38601 -       default:
38602 -               rc = -EOPNOTSUPP;
38603 -               break;
38604 -       }
38605 +static struct ethtool_ops netdev_ethtool_ops = {
38606 +       .get_drvinfo            = netdev_get_drvinfo,
38607 +       .get_msglevel           = netdev_get_msglevel,
38608 +       .set_msglevel           = netdev_set_msglevel,
38609 +};
38610  
38611 -       return rc;
38612 -}
38613
38614  #ifdef MODULE
38615  
38616  static struct net_device dev_3c501 = {
38617 diff -Nru a/drivers/net/3c501.h b/drivers/net/3c501.h
38618 --- a/drivers/net/3c501.h       Sun Apr 20 22:41:08 2003
38619 +++ b/drivers/net/3c501.h       Tue Aug 26 13:21:28 2003
38620 @@ -14,7 +14,7 @@
38621  static int  el1_close(struct net_device *dev);
38622  static struct net_device_stats *el1_get_stats(struct net_device *dev);
38623  static void set_multicast_list(struct net_device *dev);
38624 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
38625 +static struct ethtool_ops netdev_ethtool_ops;
38626  
38627  #define EL1_IO_EXTENT  16
38628  
38629 diff -Nru a/drivers/net/3c503.c b/drivers/net/3c503.c
38630 --- a/drivers/net/3c503.c       Mon Feb 24 10:34:15 2003
38631 +++ b/drivers/net/3c503.c       Tue Aug 26 13:29:32 2003
38632 @@ -80,7 +80,7 @@
38633                            int ring_offset);
38634  static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
38635                          int ring_page);
38636 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
38637 +static struct ethtool_ops netdev_ethtool_ops;
38638  
38639  \f
38640  /* This routine probes for a memory-mapped 3c503 board by looking for
38641 @@ -308,7 +308,7 @@
38642  
38643      dev->open = &el2_open;
38644      dev->stop = &el2_close;
38645 -    dev->do_ioctl = &netdev_ioctl;
38646 +    dev->ethtool_ops = &netdev_ethtool_ops;
38647  
38648      if (dev->mem_start)
38649         printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
38650 @@ -617,69 +617,18 @@
38651      return;
38652  }
38653  
38654 -/**
38655 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
38656 - * @dev: network interface on which out-of-band action is to be performed
38657 - * @useraddr: userspace address to which data is to be read and returned
38658 - *
38659 - * Process the various commands of the SIOCETHTOOL interface.
38660 - */
38661  
38662 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
38663 +static void netdev_get_drvinfo(struct net_device *dev,
38664 +                              struct ethtool_drvinfo *info)
38665  {
38666 -       u32 ethcmd;
38667 -
38668 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
38669 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
38670 -
38671 -       if (get_user(ethcmd, (u32 *)useraddr))
38672 -               return -EFAULT;
38673 -
38674 -       switch (ethcmd) {
38675 -
38676 -       case ETHTOOL_GDRVINFO: {
38677 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
38678 -               strcpy (info.driver, DRV_NAME);
38679 -               strcpy (info.version, DRV_VERSION);
38680 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
38681 -               if (copy_to_user (useraddr, &info, sizeof (info)))
38682 -                       return -EFAULT;
38683 -               return 0;
38684 -       }
38685 -
38686 -       default:
38687 -               break;
38688 -       }
38689 -
38690 -       return -EOPNOTSUPP;
38691 +       strcpy(info->driver, DRV_NAME);
38692 +       strcpy(info->version, DRV_VERSION);
38693 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
38694  }
38695  
38696 -/**
38697 - * netdev_ioctl: Handle network interface ioctls
38698 - * @dev: network interface on which out-of-band action is to be performed
38699 - * @rq: user request data
38700 - * @cmd: command issued by user
38701 - *
38702 - * Process the various out-of-band ioctls passed to this driver.
38703 - */
38704 -
38705 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
38706 -{
38707 -       int rc = 0;
38708 -
38709 -       switch (cmd) {
38710 -       case SIOCETHTOOL:
38711 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
38712 -               break;
38713 -
38714 -       default:
38715 -               rc = -EOPNOTSUPP;
38716 -               break;
38717 -       }
38718 -
38719 -       return rc;
38720 -}
38721
38722 +static struct ethtool_ops netdev_ethtool_ops = {
38723 +       .get_drvinfo            = netdev_get_drvinfo,
38724 +};
38725  
38726  #ifdef MODULE
38727  #define MAX_EL2_CARDS  4       /* Max number of EL2 cards per module */
38728 diff -Nru a/drivers/net/3c505.c b/drivers/net/3c505.c
38729 --- a/drivers/net/3c505.c       Wed Jun  4 06:07:40 2003
38730 +++ b/drivers/net/3c505.c       Tue Aug 26 13:29:32 2003
38731 @@ -1163,86 +1163,30 @@
38732         return &adapter->stats;
38733  }
38734  
38735 -/**
38736 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
38737 - * @dev: network interface on which out-of-band action is to be performed
38738 - * @useraddr: userspace address to which data is to be read and returned
38739 - *
38740 - * Process the various commands of the SIOCETHTOOL interface.
38741 - */
38742 -
38743 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
38744 -{
38745 -       u32 ethcmd;
38746 -
38747 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
38748 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
38749 -
38750 -       if (get_user(ethcmd, (u32 *)useraddr))
38751 -               return -EFAULT;
38752 -
38753 -       switch (ethcmd) {
38754 -
38755 -       case ETHTOOL_GDRVINFO: {
38756 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
38757 -               strcpy (info.driver, DRV_NAME);
38758 -               strcpy (info.version, DRV_VERSION);
38759 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
38760 -               if (copy_to_user (useraddr, &info, sizeof (info)))
38761 -                       return -EFAULT;
38762 -               return 0;
38763 -       }
38764 -
38765 -       /* get message-level */
38766 -       case ETHTOOL_GMSGLVL: {
38767 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
38768 -               edata.data = debug;
38769 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38770 -                       return -EFAULT;
38771 -               return 0;
38772 -       }
38773 -       /* set message-level */
38774 -       case ETHTOOL_SMSGLVL: {
38775 -               struct ethtool_value edata;
38776 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
38777 -                       return -EFAULT;
38778 -               debug = edata.data;
38779 -               return 0;
38780 -       }
38781 -
38782 -       default:
38783 -               break;
38784 -       }
38785  
38786 -       return -EOPNOTSUPP;
38787 +static void netdev_get_drvinfo(struct net_device *dev,
38788 +                              struct ethtool_drvinfo *info)
38789 +{
38790 +       strcpy(info->driver, DRV_NAME);
38791 +       strcpy(info->version, DRV_VERSION);
38792 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
38793  }
38794  
38795 -/**
38796 - * netdev_ioctl: Handle network interface ioctls
38797 - * @dev: network interface on which out-of-band action is to be performed
38798 - * @rq: user request data
38799 - * @cmd: command issued by user
38800 - *
38801 - * Process the various out-of-band ioctls passed to this driver.
38802 - */
38803 -
38804 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
38805 -{
38806 -       int rc = 0;
38807 -
38808 -       switch (cmd) {
38809 -       case SIOCETHTOOL:
38810 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
38811 -               break;
38812 -
38813 -       default:
38814 -               rc = -EOPNOTSUPP;
38815 -               break;
38816 -       }
38817 +static u32 netdev_get_msglevel(struct net_device *dev)
38818 +{
38819 +       return debug;
38820 +}
38821  
38822 -       return rc;
38823 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
38824 +{
38825 +       debug = level;
38826  }
38827
38828 +
38829 +static struct ethtool_ops netdev_ethtool_ops = {
38830 +       .get_drvinfo            = netdev_get_drvinfo,
38831 +       .get_msglevel           = netdev_get_msglevel,
38832 +       .set_msglevel           = netdev_set_msglevel,
38833 +};
38834  
38835  /******************************************************
38836   *
38837 @@ -1373,7 +1317,7 @@
38838         dev->tx_timeout = elp_timeout;                  /* local */
38839         dev->watchdog_timeo = 10*HZ;
38840         dev->set_multicast_list = elp_set_mc_list;      /* local */
38841 -       dev->do_ioctl = netdev_ioctl;                   /* local */
38842 +       dev->ethtool_ops = &netdev_ethtool_ops;         /* local */
38843  
38844         /* Setup the generic properties */
38845         ether_setup(dev);
38846 diff -Nru a/drivers/net/3c507.c b/drivers/net/3c507.c
38847 --- a/drivers/net/3c507.c       Sun Apr 20 22:41:08 2003
38848 +++ b/drivers/net/3c507.c       Tue Aug 26 13:29:32 2003
38849 @@ -299,7 +299,7 @@
38850  
38851  static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad);
38852  static void init_82586_mem(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  
38856  \f
38857  /* Check for a network adaptor of this type, and return '0' iff one exists.
38858 @@ -431,7 +431,7 @@
38859         dev->get_stats  = el16_get_stats;
38860         dev->tx_timeout = el16_tx_timeout;
38861         dev->watchdog_timeo = TX_TIMEOUT;
38862 -       dev->do_ioctl = netdev_ioctl;
38863 +       dev->ethtool_ops = &netdev_ethtool_ops;
38864  
38865         ether_setup(dev);       /* Generic ethernet behaviour */
38866  
38867 @@ -874,86 +874,29 @@
38868         lp->rx_tail = rx_tail;
38869  }
38870  
38871 -/**
38872 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
38873 - * @dev: network interface on which out-of-band action is to be performed
38874 - * @useraddr: userspace address to which data is to be read and returned
38875 - *
38876 - * Process the various commands of the SIOCETHTOOL interface.
38877 - */
38878 -
38879 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
38880 -{
38881 -       u32 ethcmd;
38882 -
38883 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
38884 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
38885 -
38886 -       if (get_user(ethcmd, (u32 *)useraddr))
38887 -               return -EFAULT;
38888 -
38889 -       switch (ethcmd) {
38890 -
38891 -       case ETHTOOL_GDRVINFO: {
38892 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
38893 -               strcpy (info.driver, DRV_NAME);
38894 -               strcpy (info.version, DRV_VERSION);
38895 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
38896 -               if (copy_to_user (useraddr, &info, sizeof (info)))
38897 -                       return -EFAULT;
38898 -               return 0;
38899 -       }
38900 -
38901 -       /* get message-level */
38902 -       case ETHTOOL_GMSGLVL: {
38903 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
38904 -               edata.data = debug;
38905 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38906 -                       return -EFAULT;
38907 -               return 0;
38908 -       }
38909 -       /* set message-level */
38910 -       case ETHTOOL_SMSGLVL: {
38911 -               struct ethtool_value edata;
38912 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
38913 -                       return -EFAULT;
38914 -               debug = edata.data;
38915 -               return 0;
38916 -       }
38917 -
38918 -       default:
38919 -               break;
38920 -       }
38921 -
38922 -       return -EOPNOTSUPP;
38923 +static void netdev_get_drvinfo(struct net_device *dev,
38924 +                              struct ethtool_drvinfo *info)
38925 +{
38926 +       strcpy(info->driver, DRV_NAME);
38927 +       strcpy(info->version, DRV_VERSION);
38928 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
38929  }
38930  
38931 -/**
38932 - * netdev_ioctl: Handle network interface ioctls
38933 - * @dev: network interface on which out-of-band action is to be performed
38934 - * @rq: user request data
38935 - * @cmd: command issued by user
38936 - *
38937 - * Process the various out-of-band ioctls passed to this driver.
38938 - */
38939 -
38940 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
38941 +static u32 netdev_get_msglevel(struct net_device *dev)
38942  {
38943 -       int rc = 0;
38944 -
38945 -       switch (cmd) {
38946 -       case SIOCETHTOOL:
38947 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
38948 -               break;
38949 -
38950 -       default:
38951 -               rc = -EOPNOTSUPP;
38952 -               break;
38953 -       }
38954 +       return debug;
38955 +}
38956  
38957 -       return rc;
38958 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
38959 +{
38960 +       debug = level;
38961  }
38962
38963 +
38964 +static struct ethtool_ops netdev_ethtool_ops = {
38965 +       .get_drvinfo            = netdev_get_drvinfo,
38966 +       .get_msglevel           = netdev_get_msglevel,
38967 +       .set_msglevel           = netdev_set_msglevel,
38968 +};
38969  
38970  #ifdef MODULE
38971  static struct net_device dev_3c507;
38972 diff -Nru a/drivers/net/3c509.c b/drivers/net/3c509.c
38973 --- a/drivers/net/3c509.c       Tue Aug 19 20:53:14 2003
38974 +++ b/drivers/net/3c509.c       Sun Aug 31 22:52:48 2003
38975 @@ -300,10 +300,11 @@
38976   *
38977   * Both call el3_common_init/el3_common_remove. */
38978  
38979 -static void __init el3_common_init(struct net_device *dev)
38980 +static int __init el3_common_init(struct net_device *dev)
38981  {
38982         struct el3_private *lp = dev->priv;
38983         short i;
38984 +       int err;
38985  
38986         spin_lock_init(&lp->lock);
38987  
38988 @@ -314,10 +315,29 @@
38989                 dev->if_port |= (dev->mem_start & 0x08);
38990         }
38991  
38992 +       /* The EL3-specific entries in the device structure. */
38993 +       dev->open = &el3_open;
38994 +       dev->hard_start_xmit = &el3_start_xmit;
38995 +       dev->stop = &el3_close;
38996 +       dev->get_stats = &el3_get_stats;
38997 +       dev->set_multicast_list = &set_multicast_list;
38998 +       dev->tx_timeout = el3_tx_timeout;
38999 +       dev->watchdog_timeo = TX_TIMEOUT;
39000 +       dev->do_ioctl = netdev_ioctl;
39001 +
39002 +       err = register_netdev(dev);
39003 +       if (err) {
39004 +               printk(KERN_ERR "Failed to register 3c5x9 at %#3.3lx, IRQ %d.\n",
39005 +                       dev->base_addr, dev->irq);
39006 +               release_region(dev->base_addr, EL3_IO_EXTENT);
39007 +               return err;
39008 +       }
39009 +
39010         {
39011                 const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
39012 -               printk("%s: 3c5x9 at %#3.3lx, %s port, address ",
39013 -                       dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)]);
39014 +               printk("%s: 3c5x9 found at %#3.3lx, %s port, address ",
39015 +                       dev->name, dev->base_addr, 
39016 +                       if_names[(dev->if_port & 0x03)]);
39017         }
39018  
39019         /* Read in the station address. */
39020 @@ -327,16 +347,8 @@
39021  
39022         if (el3_debug > 0)
39023                 printk(KERN_INFO "%s" KERN_INFO "%s", versionA, versionB);
39024 +       return 0;
39025  
39026 -       /* The EL3-specific entries in the device structure. */
39027 -       dev->open = &el3_open;
39028 -       dev->hard_start_xmit = &el3_start_xmit;
39029 -       dev->stop = &el3_close;
39030 -       dev->get_stats = &el3_get_stats;
39031 -       dev->set_multicast_list = &set_multicast_list;
39032 -       dev->tx_timeout = el3_tx_timeout;
39033 -       dev->watchdog_timeo = TX_TIMEOUT;
39034 -       dev->do_ioctl = netdev_ioctl;
39035  }
39036  
39037  static void el3_common_remove (struct net_device *dev)
39038 @@ -564,9 +576,8 @@
39039  #if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
39040         lp->dev = &idev->dev;
39041  #endif
39042 -       el3_common_init(dev);
39043 +       err = el3_common_init(dev);
39044  
39045 -       err = register_netdev(dev);
39046         if (err)
39047                 goto out1;
39048  
39049 @@ -588,7 +599,6 @@
39050         return 0;
39051  
39052  out1:
39053 -       release_region(ioaddr, EL3_IO_EXTENT);
39054  #if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
39055         if (idev)
39056                 pnp_device_detach(idev);
39057 @@ -629,8 +639,8 @@
39058                            el3_mca_adapter_names[mdev->index], slot + 1);
39059  
39060                 /* claim the slot */
39061 -               strncpy(device->name, el3_mca_adapter_names[mdev->index],
39062 -                               sizeof(device->name));
39063 +               strncpy(mdev->name, el3_mca_adapter_names[mdev->index],
39064 +                               sizeof(mdev->name));
39065                 mca_device_set_claim(mdev, 1);
39066  
39067                 if_port = pos4 & 0x03;
39068 @@ -662,11 +672,9 @@
39069                 lp->dev = device;
39070                 lp->type = EL3_MCA;
39071                 device->driver_data = dev;
39072 -               el3_common_init(dev);
39073 +               err = el3_common_init(dev);
39074  
39075 -               err = register_netdev(dev);
39076                 if (err) {
39077 -                       release_region(ioaddr, EL3_IO_EXTENT);
39078                         return -ENOMEM;
39079                 }
39080  
39081 @@ -723,11 +731,9 @@
39082         lp->dev = device;
39083         lp->type = EL3_EISA;
39084         eisa_set_drvdata (edev, dev);
39085 -       el3_common_init(dev);
39086 +       err = el3_common_init(dev);
39087  
39088 -       err = register_netdev(dev);
39089         if (err) {
39090 -               release_region(ioaddr, EL3_IO_EXTENT);
39091                 return err;
39092         }
39093  
39094 diff -Nru a/drivers/net/3c515.c b/drivers/net/3c515.c
39095 --- a/drivers/net/3c515.c       Tue Aug 19 20:53:14 2003
39096 +++ b/drivers/net/3c515.c       Tue Sep  2 06:44:18 2003
39097 @@ -392,7 +392,7 @@
39098  static void update_stats(int addr, struct net_device *dev);
39099  static struct net_device_stats *corkscrew_get_stats(struct net_device *dev);
39100  static void set_rx_mode(struct net_device *dev);
39101 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
39102 +static struct ethtool_ops netdev_ethtool_ops;
39103  \f
39104  
39105  /* 
39106 @@ -718,7 +718,7 @@
39107         dev->stop = &corkscrew_close;
39108         dev->get_stats = &corkscrew_get_stats;
39109         dev->set_multicast_list = &set_rx_mode;
39110 -       dev->do_ioctl = netdev_ioctl;
39111 +       dev->ethtool_ops = &netdev_ethtool_ops;
39112  
39113         return 0;
39114  }
39115 @@ -1580,86 +1580,30 @@
39116         outw(new_mode, ioaddr + EL3_CMD);
39117  }
39118  
39119 -/**
39120 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
39121 - * @dev: network interface on which out-of-band action is to be performed
39122 - * @useraddr: userspace address to which data is to be read and returned
39123 - *
39124 - * Process the various commands of the SIOCETHTOOL interface.
39125 - */
39126 -
39127 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
39128 +static void netdev_get_drvinfo(struct net_device *dev,
39129 +                              struct ethtool_drvinfo *info)
39130  {
39131 -       u32 ethcmd;
39132 -
39133 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
39134 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
39135 -
39136 -       if (get_user(ethcmd, (u32 *)useraddr))
39137 -               return -EFAULT;
39138 -
39139 -       switch (ethcmd) {
39140 -
39141 -       case ETHTOOL_GDRVINFO: {
39142 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
39143 -               strcpy (info.driver, DRV_NAME);
39144 -               strcpy (info.version, DRV_VERSION);
39145 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
39146 -               if (copy_to_user (useraddr, &info, sizeof (info)))
39147 -                       return -EFAULT;
39148 -               return 0;
39149 -       }
39150 -
39151 -       /* get message-level */
39152 -       case ETHTOOL_GMSGLVL: {
39153 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
39154 -               edata.data = corkscrew_debug;
39155 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
39156 -                       return -EFAULT;
39157 -               return 0;
39158 -       }
39159 -       /* set message-level */
39160 -       case ETHTOOL_SMSGLVL: {
39161 -               struct ethtool_value edata;
39162 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
39163 -                       return -EFAULT;
39164 -               corkscrew_debug = edata.data;
39165 -               return 0;
39166 -       }
39167 -
39168 -       default:
39169 -               break;
39170 -       }
39171 -
39172 -       return -EOPNOTSUPP;
39173 +       strcpy(info->driver, DRV_NAME);
39174 +       strcpy(info->version, DRV_VERSION);
39175 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
39176  }
39177  
39178 -/**
39179 - * netdev_ioctl: Handle network interface ioctls
39180 - * @dev: network interface on which out-of-band action is to be performed
39181 - * @rq: user request data
39182 - * @cmd: command issued by user
39183 - *
39184 - * Process the various out-of-band ioctls passed to this driver.
39185 - */
39186 -
39187 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
39188 +static u32 netdev_get_msglevel(struct net_device *dev)
39189  {
39190 -       int rc = 0;
39191 +       return corkscrew_debug;
39192 +}
39193  
39194 -       switch (cmd) {
39195 -       case SIOCETHTOOL:
39196 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
39197 -               break;
39198 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
39199 +{
39200 +       corkscrew_debug = level;
39201 +}
39202  
39203 -       default:
39204 -               rc = -EOPNOTSUPP;
39205 -               break;
39206 -       }
39207 +static struct ethtool_ops netdev_ethtool_ops = {
39208 +       .get_drvinfo            = netdev_get_drvinfo,
39209 +       .get_msglevel           = netdev_get_msglevel,
39210 +       .set_msglevel           = netdev_set_msglevel,
39211 +};
39212  
39213 -       return rc;
39214 -}
39215
39216  \f
39217  #ifdef MODULE
39218  void cleanup_module(void)
39219 diff -Nru a/drivers/net/3c523.c b/drivers/net/3c523.c
39220 --- a/drivers/net/3c523.c       Sun Apr 27 20:36:18 2003
39221 +++ b/drivers/net/3c523.c       Tue Aug 26 13:42:22 2003
39222 @@ -188,7 +188,7 @@
39223  #ifdef ELMC_MULTICAST
39224  static void set_multicast_list(struct net_device *dev);
39225  #endif
39226 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
39227 +static struct ethtool_ops netdev_ethtool_ops;
39228  
39229  /* helper-functions */
39230  static int init586(struct net_device *dev);
39231 @@ -571,7 +571,7 @@
39232  #else
39233         dev->set_multicast_list = NULL;
39234  #endif
39235 -       dev->do_ioctl = netdev_ioctl;
39236 +       dev->ethtool_ops = &netdev_ethtool_ops;
39237         
39238         ether_setup(dev);
39239  
39240 @@ -1228,70 +1228,17 @@
39241  }
39242  #endif
39243  
39244 -/**
39245 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
39246 - * @dev: network interface on which out-of-band action is to be performed
39247 - * @useraddr: userspace address to which data is to be read and returned
39248 - *
39249 - * Process the various commands of the SIOCETHTOOL interface.
39250 - */
39251 -
39252 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
39253 +static void netdev_get_drvinfo(struct net_device *dev,
39254 +                              struct ethtool_drvinfo *info)
39255  {
39256 -       u32 ethcmd;
39257 -
39258 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
39259 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
39260 -
39261 -       if (get_user(ethcmd, (u32 *)useraddr))
39262 -               return -EFAULT;
39263 -
39264 -       switch (ethcmd) {
39265 -
39266 -       case ETHTOOL_GDRVINFO: {
39267 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
39268 -               strcpy (info.driver, DRV_NAME);
39269 -               strcpy (info.version, DRV_VERSION);
39270 -               sprintf(info.bus_info, "MCA 0x%lx", dev->base_addr);
39271 -               if (copy_to_user (useraddr, &info, sizeof (info)))
39272 -                       return -EFAULT;
39273 -               return 0;
39274 -       }
39275 -
39276 -       default:
39277 -               break;
39278 -       }
39279 -
39280 -       return -EOPNOTSUPP;
39281 +       strcpy(info->driver, DRV_NAME);
39282 +       strcpy(info->version, DRV_VERSION);
39283 +       sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr);
39284  }
39285  
39286 -/**
39287 - * netdev_ioctl: Handle network interface ioctls
39288 - * @dev: network interface on which out-of-band action is to be performed
39289 - * @rq: user request data
39290 - * @cmd: command issued by user
39291 - *
39292 - * Process the various out-of-band ioctls passed to this driver.
39293 - */
39294 -
39295 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
39296 -{
39297 -       int rc = 0;
39298 -
39299 -       switch (cmd) {
39300 -       case SIOCETHTOOL:
39301 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
39302 -               break;
39303 -
39304 -       default:
39305 -               rc = -EOPNOTSUPP;
39306 -               break;
39307 -       }
39308 -
39309 -       return rc;
39310 -}
39311
39312 -/*************************************************************************/
39313 +static struct ethtool_ops netdev_ethtool_ops = {
39314 +       .get_drvinfo            = netdev_get_drvinfo,
39315 +};
39316  
39317  #ifdef MODULE
39318  
39319 diff -Nru a/drivers/net/3c527.c b/drivers/net/3c527.c
39320 --- a/drivers/net/3c527.c       Sun Apr 27 20:36:18 2003
39321 +++ b/drivers/net/3c527.c       Sun Aug 31 06:34:16 2003
39322 @@ -218,7 +218,7 @@
39323  static struct  net_device_stats *mc32_get_stats(struct net_device *dev);
39324  static void    mc32_set_multicast_list(struct net_device *dev);
39325  static void    mc32_reset_multicast_list(struct net_device *dev);
39326 -static int     netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
39327 +static struct ethtool_ops netdev_ethtool_ops;
39328  
39329  /**
39330   * mc32_probe  -       Search for supported boards
39331 @@ -508,7 +508,7 @@
39332         dev->set_multicast_list = mc32_set_multicast_list;
39333         dev->tx_timeout         = mc32_timeout;
39334         dev->watchdog_timeo     = HZ*5; /* Board does all the work */
39335 -       dev->do_ioctl           = netdev_ioctl;
39336 +       dev->ethtool_ops        = &netdev_ethtool_ops;
39337         
39338         lp->xceiver_state = HALTED; 
39339         
39340 @@ -1081,14 +1081,15 @@
39341         /* NP is the buffer we will be loading */
39342         np=lp->tx_ring[lp->tx_ring_head].p; 
39343  
39344 -       /* We will need this to flush the buffer out */
39345 -       lp->tx_ring[lp->tx_ring_head].skb=skb;
39346 -          
39347         if (skb->len < ETH_ZLEN) {
39348                 skb = skb_padto(skb, ETH_ZLEN);
39349                 if (skb == NULL)
39350                         goto out;
39351         }
39352 +
39353 +       /* We will need this to flush the buffer out */
39354 +       lp->tx_ring[lp->tx_ring_head].skb = skb;
39355 +          
39356         np->length = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len; 
39357                         
39358         np->data        = isa_virt_to_bus(skb->data);
39359 @@ -1655,86 +1656,30 @@
39360         do_mc32_set_multicast_list(dev,1);
39361  }
39362  
39363 -/**
39364 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
39365 - * @dev: network interface on which out-of-band action is to be performed
39366 - * @useraddr: userspace address to which data is to be read and returned
39367 - *
39368 - * Process the various commands of the SIOCETHTOOL interface.
39369 - */
39370 -
39371 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
39372 +static void netdev_get_drvinfo(struct net_device *dev,
39373 +                              struct ethtool_drvinfo *info)
39374  {
39375 -       u32 ethcmd;
39376 -
39377 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
39378 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
39379 -
39380 -       if (get_user(ethcmd, (u32 *)useraddr))
39381 -               return -EFAULT;
39382 -
39383 -       switch (ethcmd) {
39384 -
39385 -       case ETHTOOL_GDRVINFO: {
39386 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
39387 -               strcpy (info.driver, DRV_NAME);
39388 -               strcpy (info.version, DRV_VERSION);
39389 -               sprintf(info.bus_info, "MCA 0x%lx", dev->base_addr);
39390 -               if (copy_to_user (useraddr, &info, sizeof (info)))
39391 -                       return -EFAULT;
39392 -               return 0;
39393 -       }
39394 -
39395 -       /* get message-level */
39396 -       case ETHTOOL_GMSGLVL: {
39397 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
39398 -               edata.data = mc32_debug;
39399 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
39400 -                       return -EFAULT;
39401 -               return 0;
39402 -       }
39403 -       /* set message-level */
39404 -       case ETHTOOL_SMSGLVL: {
39405 -               struct ethtool_value edata;
39406 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
39407 -                       return -EFAULT;
39408 -               mc32_debug = edata.data;
39409 -               return 0;
39410 -       }
39411 -
39412 -       default:
39413 -               break;
39414 -       }
39415 -
39416 -       return -EOPNOTSUPP;
39417 +       strcpy(info->driver, DRV_NAME);
39418 +       strcpy(info->version, DRV_VERSION);
39419 +       sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr);
39420  }
39421  
39422 -/**
39423 - * netdev_ioctl: Handle network interface ioctls
39424 - * @dev: network interface on which out-of-band action is to be performed
39425 - * @rq: user request data
39426 - * @cmd: command issued by user
39427 - *
39428 - * Process the various out-of-band ioctls passed to this driver.
39429 - */
39430 +static u32 netdev_get_msglevel(struct net_device *dev)
39431 +{
39432 +       return mc32_debug;
39433 +}
39434  
39435 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
39436 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
39437  {
39438 -       int rc = 0;
39439 +       mc32_debug = level;
39440 +}
39441  
39442 -       switch (cmd) {
39443 -       case SIOCETHTOOL:
39444 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
39445 -               break;
39446 +static struct ethtool_ops netdev_ethtool_ops = {
39447 +       .get_drvinfo            = netdev_get_drvinfo,
39448 +       .get_msglevel           = netdev_get_msglevel,
39449 +       .set_msglevel           = netdev_set_msglevel,
39450 +};
39451  
39452 -       default:
39453 -               rc = -EOPNOTSUPP;
39454 -               break;
39455 -       }
39456 -
39457 -       return rc;
39458 -}
39459
39460  #ifdef MODULE
39461  
39462  static struct net_device this_device;
39463 diff -Nru a/drivers/net/3c59x.c b/drivers/net/3c59x.c
39464 --- a/drivers/net/3c59x.c       Tue Aug 19 20:53:15 2003
39465 +++ b/drivers/net/3c59x.c       Tue Aug 26 11:23:22 2003
39466 @@ -900,6 +900,7 @@
39467  static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
39468  static void vortex_tx_timeout(struct net_device *dev);
39469  static void acpi_set_WOL(struct net_device *dev);
39470 +static struct ethtool_ops vortex_ethtool_ops;
39471  \f
39472  /* This driver uses 'options' to pass the media type, full-duplex flag, etc. */
39473  /* Option count limit only -- unlimited interfaces are supported. */
39474 @@ -1445,6 +1446,7 @@
39475         dev->stop = vortex_close;
39476         dev->get_stats = vortex_get_stats;
39477         dev->do_ioctl = vortex_ioctl;
39478 +       dev->ethtool_ops = &vortex_ethtool_ops;
39479         dev->set_multicast_list = set_rx_mode;
39480         dev->tx_timeout = vortex_tx_timeout;
39481         dev->watchdog_timeo = (watchdog * HZ) / 1000;
39482 @@ -2816,38 +2818,28 @@
39483  }
39484  
39485  
39486 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
39487 +static void vortex_get_drvinfo(struct net_device *dev,
39488 +                                       struct ethtool_drvinfo *info)
39489  {
39490         struct vortex_private *vp = dev->priv;
39491 -       u32 ethcmd;
39492 -               
39493 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
39494 -               return -EFAULT;
39495  
39496 -        switch (ethcmd) {
39497 -        case ETHTOOL_GDRVINFO: {
39498 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
39499 -               strcpy(info.driver, DRV_NAME);
39500 -               strcpy(info.version, DRV_VERSION);
39501 -               if (VORTEX_PCI(vp))
39502 -                       strcpy(info.bus_info, pci_name(VORTEX_PCI(vp)));
39503 -               else {
39504 -                       if (VORTEX_EISA(vp))
39505 -                               sprintf (info.bus_info, vp->gendev->bus_id);
39506 -                       else
39507 -                               sprintf(info.bus_info, "EISA 0x%lx %d",
39508 -                                               dev->base_addr, dev->irq);
39509 -               }
39510 -               if (copy_to_user(useraddr, &info, sizeof(info)))
39511 -                       return -EFAULT;
39512 -               return 0;
39513 +       strcpy(info->driver, DRV_NAME);
39514 +       strcpy(info->version, DRV_VERSION);
39515 +       if (VORTEX_PCI(vp)) {
39516 +               strcpy(info->bus_info, pci_name(VORTEX_PCI(vp)));
39517 +       } else {
39518 +               if (VORTEX_EISA(vp))
39519 +                       sprintf(info->bus_info, vp->gendev->bus_id);
39520 +               else
39521 +                       sprintf(info->bus_info, "EISA 0x%lx %d",
39522 +                                       dev->base_addr, dev->irq);
39523         }
39524 -
39525 -        }
39526 -       
39527 -       return -EOPNOTSUPP;
39528  }
39529  
39530 +static struct ethtool_ops vortex_ethtool_ops = {
39531 +       .get_drvinfo =          vortex_get_drvinfo,
39532 +};
39533 +
39534  static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39535  {
39536         struct vortex_private *vp = (struct vortex_private *)dev->priv;
39537 @@ -2857,9 +2849,6 @@
39538         int retval;
39539  
39540         switch(cmd) {
39541 -       case SIOCETHTOOL:
39542 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
39543 -
39544         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
39545                 data->phy_id = phy;
39546  
39547 diff -Nru a/drivers/net/8139cp.c b/drivers/net/8139cp.c
39548 --- a/drivers/net/8139cp.c      Tue Aug 19 20:13:55 2003
39549 +++ b/drivers/net/8139cp.c      Mon Sep  1 17:25:54 2003
39550 @@ -24,15 +24,13 @@
39551                 PCI suspend/resume  - Felipe Damasio <felipewd@terra.com.br>
39552                 LinkChg interrupt   - Felipe Damasio <felipewd@terra.com.br>
39553                         
39554 -       TODO, in rough priority order:
39555 +       TODO:
39556         * Test Tx checksumming thoroughly
39557 -       * dev->tx_timeout
39558 -       * Constants (module parms?) for Rx work limit
39559 +       * Implement dev->tx_timeout
39560 +
39561 +       Low priority TODO:
39562         * Complete reset on PciErr
39563         * Consider Rx interrupt mitigation using TimerIntr
39564 -       * Implement 8139C+ statistics dump; maybe not...
39565 -         h/w stats can be reset only by software reset
39566 -       * Handle netif_rx return value
39567         * Investigate using skb->priority with h/w VLAN priority
39568         * Investigate using High Priority Tx Queue with skb->priority
39569         * Adjust Rx FIFO threshold and Max Rx DMA burst on Rx FIFO error
39570 @@ -41,14 +39,17 @@
39571           Tx descriptor bit
39572         * The real minimum of CP_MIN_MTU is 4 bytes.  However,
39573           for this to be supported, one must(?) turn on packet padding.
39574 -       * Support 8169 GMII
39575 -       * Support external MII transceivers
39576 +       * Support external MII transceivers (patch available)
39577 +
39578 +       NOTES:
39579 +       * TX checksumming is considered experimental.  It is off by
39580 +         default, use ethtool to turn it on.
39581  
39582   */
39583  
39584  #define DRV_NAME               "8139cp"
39585 -#define DRV_VERSION            "0.3.0"
39586 -#define DRV_RELDATE            "Sep 29, 2002"
39587 +#define DRV_VERSION            "1.1"
39588 +#define DRV_RELDATE            "Aug 30, 2003"
39589  
39590  
39591  #include <linux/config.h>
39592 @@ -71,9 +72,6 @@
39593  #include <asm/io.h>
39594  #include <asm/uaccess.h>
39595  
39596 -/* experimental TX checksumming feature enable/disable */
39597 -#undef CP_TX_CHECKSUM
39598 -
39599  /* VLAN tagging feature enable/disable */
39600  #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
39601  #define CP_VLAN_TAG_USED 1
39602 @@ -86,7 +84,7 @@
39603  #endif
39604  
39605  /* These identify the driver base version and may not be removed. */
39606 -static char version[] __devinitdata =
39607 +static char version[] =
39608  KERN_INFO DRV_NAME ": 10/100 PCI Ethernet driver v" DRV_VERSION " (" DRV_RELDATE ")\n";
39609  
39610  MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>");
39611 @@ -160,6 +158,7 @@
39612         TxConfig        = 0x40, /* Tx configuration */
39613         ChipVersion     = 0x43, /* 8-bit chip version, inside TxConfig */
39614         RxConfig        = 0x44, /* Rx configuration */
39615 +       RxMissed        = 0x4C, /* 24 bits valid, write clears */
39616         Cfg9346         = 0x50, /* EEPROM select/control; Cfg reg [un]lock */
39617         Config1         = 0x52, /* Config1 */
39618         Config3         = 0x59, /* Config3 */
39619 @@ -292,12 +291,11 @@
39620         UWF             = (1 << 4),  /* Accept Unicast wakeup frame */
39621         LANWake         = (1 << 1),  /* Enable LANWake signal */
39622         PMEStatus       = (1 << 0),  /* PME status can be reset by PCI RST# */
39623 -};
39624  
39625 -static const unsigned int cp_intr_mask =
39626 -       PciErr | LinkChg |
39627 -       RxOK | RxErr | RxEmpty | RxFIFOOvr |
39628 -       TxOK | TxErr | TxEmpty;
39629 +       cp_norx_intr_mask = PciErr | LinkChg | TxOK | TxErr | TxEmpty,
39630 +       cp_rx_intr_mask = RxOK | RxErr | RxEmpty | RxFIFOOvr,
39631 +       cp_intr_mask = cp_rx_intr_mask | cp_norx_intr_mask,
39632 +};
39633  
39634  static const unsigned int cp_rx_config =
39635           (RX_FIFO_THRESH << RxCfgFIFOShift) |
39636 @@ -364,11 +362,7 @@
39637  
39638         struct pci_dev          *pdev;
39639         u32                     rx_config;
39640 -
39641 -       struct sk_buff          *frag_skb;
39642 -       unsigned                dropping_frag : 1;
39643 -       unsigned                pci_using_dac : 1;
39644 -       unsigned int            board_type;
39645 +       u16                     cpcmd;
39646  
39647         unsigned int            wol_enabled : 1; /* Is Wake-on-LAN enabled? */
39648         u32                     power_state[16];
39649 @@ -400,28 +394,9 @@
39650  static void cp_tx (struct cp_private *cp);
39651  static void cp_clean_rings (struct cp_private *cp);
39652  
39653 -enum board_type {
39654 -       RTL8139Cp,
39655 -       RTL8169,
39656 -};
39657 -
39658 -static struct cp_board_info {
39659 -       const char *name;
39660 -} cp_board_tbl[] __devinitdata = {
39661 -       /* RTL8139Cp */
39662 -       { "RTL-8139C+" },
39663 -
39664 -       /* RTL8169 */
39665 -       { "RTL-8169" },
39666 -};
39667 -
39668  static struct pci_device_id cp_pci_tbl[] = {
39669         { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
39670 -         PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139Cp },
39671 -#if 0
39672 -       { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8169,
39673 -         PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8169 },
39674 -#endif
39675 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
39676         { },
39677  };
39678  MODULE_DEVICE_TABLE(pci, cp_pci_tbl);
39679 @@ -446,6 +421,31 @@
39680  };
39681  
39682  
39683 +#if CP_VLAN_TAG_USED
39684 +static void cp_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
39685 +{
39686 +       struct cp_private *cp = dev->priv;
39687 +
39688 +       spin_lock_irq(&cp->lock);
39689 +       cp->vlgrp = grp;
39690 +       cp->cpcmd |= RxVlanOn;
39691 +       cpw16(CpCmd, cp->cpcmd);
39692 +       spin_unlock_irq(&cp->lock);
39693 +}
39694 +
39695 +static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
39696 +{
39697 +       struct cp_private *cp = dev->priv;
39698 +
39699 +       spin_lock_irq(&cp->lock);
39700 +       cp->cpcmd &= ~RxVlanOn;
39701 +       cpw16(CpCmd, cp->cpcmd);
39702 +       if (cp->vlgrp)
39703 +               cp->vlgrp->vlan_devices[vid] = NULL;
39704 +       spin_unlock_irq(&cp->lock);
39705 +}
39706 +#endif /* CP_VLAN_TAG_USED */
39707 +
39708  static inline void cp_set_rxbufsize (struct cp_private *cp)
39709  {
39710         unsigned int mtu = cp->dev->mtu;
39711 @@ -468,10 +468,11 @@
39712  
39713  #if CP_VLAN_TAG_USED
39714         if (cp->vlgrp && (desc->opts2 & RxVlanTagged)) {
39715 -               vlan_hwaccel_rx(skb, cp->vlgrp, be16_to_cpu(desc->opts2 & 0xffff));
39716 +               vlan_hwaccel_receive_skb(skb, cp->vlgrp,
39717 +                                        be16_to_cpu(desc->opts2 & 0xffff));
39718         } else
39719  #endif
39720 -               netif_rx(skb);
39721 +               netif_receive_skb(skb);
39722  }
39723  
39724  static void cp_rx_err_acct (struct cp_private *cp, unsigned rx_tail,
39725 @@ -486,81 +487,14 @@
39726                 cp->net_stats.rx_frame_errors++;
39727         if (status & RxErrCRC)
39728                 cp->net_stats.rx_crc_errors++;
39729 -       if (status & RxErrRunt)
39730 +       if ((status & RxErrRunt) || (status & RxErrLong))
39731                 cp->net_stats.rx_length_errors++;
39732 -       if (status & RxErrLong)
39733 +       if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag))
39734                 cp->net_stats.rx_length_errors++;
39735         if (status & RxErrFIFO)
39736                 cp->net_stats.rx_fifo_errors++;
39737  }
39738  
39739 -static void cp_rx_frag (struct cp_private *cp, unsigned rx_tail,
39740 -                       struct sk_buff *skb, u32 status, u32 len)
39741 -{
39742 -       struct sk_buff *copy_skb, *frag_skb = cp->frag_skb;
39743 -       unsigned orig_len = frag_skb ? frag_skb->len : 0;
39744 -       unsigned target_len = orig_len + len;
39745 -       unsigned first_frag = status & FirstFrag;
39746 -       unsigned last_frag = status & LastFrag;
39747 -
39748 -       if (netif_msg_rx_status (cp))
39749 -               printk (KERN_DEBUG "%s: rx %s%sfrag, slot %d status 0x%x len %d\n",
39750 -                       cp->dev->name,
39751 -                       cp->dropping_frag ? "dropping " : "",
39752 -                       first_frag ? "first " :
39753 -                       last_frag ? "last " : "",
39754 -                       rx_tail, status, len);
39755 -
39756 -       cp->cp_stats.rx_frags++;
39757 -
39758 -       if (!frag_skb && !first_frag)
39759 -               cp->dropping_frag = 1;
39760 -       if (cp->dropping_frag)
39761 -               goto drop_frag;
39762 -
39763 -       copy_skb = dev_alloc_skb (target_len + RX_OFFSET);
39764 -       if (!copy_skb) {
39765 -               printk(KERN_WARNING "%s: rx slot %d alloc failed\n",
39766 -                      cp->dev->name, rx_tail);
39767 -
39768 -               cp->dropping_frag = 1;
39769 -drop_frag:
39770 -               if (frag_skb) {
39771 -                       dev_kfree_skb_irq(frag_skb);
39772 -                       cp->frag_skb = NULL;
39773 -               }
39774 -               if (last_frag) {
39775 -                       cp->net_stats.rx_dropped++;
39776 -                       cp->dropping_frag = 0;
39777 -               }
39778 -               return;
39779 -       }
39780 -
39781 -       copy_skb->dev = cp->dev;
39782 -       skb_reserve(copy_skb, RX_OFFSET);
39783 -       skb_put(copy_skb, target_len);
39784 -       if (frag_skb) {
39785 -               memcpy(copy_skb->data, frag_skb->data, orig_len);
39786 -               dev_kfree_skb_irq(frag_skb);
39787 -       }
39788 -       pci_dma_sync_single(cp->pdev, cp->rx_skb[rx_tail].mapping,
39789 -                           len, PCI_DMA_FROMDEVICE);
39790 -       memcpy(copy_skb->data + orig_len, skb->data, len);
39791 -
39792 -       copy_skb->ip_summed = CHECKSUM_NONE;
39793 -
39794 -       if (last_frag) {
39795 -               if (status & (RxError | RxErrFIFO)) {
39796 -                       cp_rx_err_acct(cp, rx_tail, status, len);
39797 -                       dev_kfree_skb_irq(copy_skb);
39798 -               } else
39799 -                       cp_rx_skb(cp, copy_skb, &cp->rx_ring[rx_tail]);
39800 -               cp->frag_skb = NULL;
39801 -       } else {
39802 -               cp->frag_skb = copy_skb;
39803 -       }
39804 -}
39805 -
39806  static inline unsigned int cp_rx_csum_ok (u32 status)
39807  {
39808         unsigned int protocol = (status >> 16) & 0x3;
39809 @@ -574,12 +508,18 @@
39810         return 0;
39811  }
39812  
39813 -static void cp_rx (struct cp_private *cp)
39814 +static int cp_rx_poll (struct net_device *dev, int *budget)
39815  {
39816 +       struct cp_private *cp = dev->priv;
39817         unsigned rx_tail = cp->rx_tail;
39818 -       unsigned rx_work = 100;
39819 +       unsigned rx_work = dev->quota;
39820 +       unsigned rx;
39821 +
39822 +rx_status_loop:
39823 +       rx = 0;
39824 +       cpw16(IntrStatus, cp_rx_intr_mask);
39825  
39826 -       while (rx_work--) {
39827 +       while (1) {
39828                 u32 status, len;
39829                 dma_addr_t mapping;
39830                 struct sk_buff *skb, *new_skb;
39831 @@ -599,7 +539,14 @@
39832                 mapping = cp->rx_skb[rx_tail].mapping;
39833  
39834                 if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag)) {
39835 -                       cp_rx_frag(cp, rx_tail, skb, status, len);
39836 +                       /* we don't support incoming fragmented frames.
39837 +                        * instead, we attempt to ensure that the
39838 +                        * pre-allocated RX skbs are properly sized such
39839 +                        * that RX fragments are never encountered
39840 +                        */
39841 +                       cp_rx_err_acct(cp, rx_tail, status, len);
39842 +                       cp->net_stats.rx_dropped++;
39843 +                       cp->cp_stats.rx_frags++;
39844                         goto rx_next;
39845                 }
39846  
39847 @@ -640,6 +587,7 @@
39848                 cp->rx_skb[rx_tail].skb = new_skb;
39849  
39850                 cp_rx_skb(cp, skb, desc);
39851 +               rx++;
39852  
39853  rx_next:
39854                 cp->rx_ring[rx_tail].opts2 = 0;
39855 @@ -650,12 +598,30 @@
39856                 else
39857                         desc->opts1 = cpu_to_le32(DescOwn | cp->rx_buf_sz);
39858                 rx_tail = NEXT_RX(rx_tail);
39859 -       }
39860  
39861 -       if (!rx_work)
39862 -               printk(KERN_WARNING "%s: rx work limit reached\n", cp->dev->name);
39863 +               if (!rx_work--)
39864 +                       break;
39865 +       }
39866  
39867         cp->rx_tail = rx_tail;
39868 +
39869 +       dev->quota -= rx;
39870 +       *budget -= rx;
39871 +
39872 +       /* if we did not reach work limit, then we're done with
39873 +        * this round of polling
39874 +        */
39875 +       if (rx_work) {
39876 +               if (cpr16(IntrStatus) & cp_rx_intr_mask)
39877 +                       goto rx_status_loop;
39878 +
39879 +               cpw16_f(IntrMask, cp_intr_mask);
39880 +               netif_rx_complete(dev);
39881 +
39882 +               return 0;       /* done */
39883 +       }
39884 +
39885 +       return 1;               /* not done */
39886  }
39887  
39888  static irqreturn_t
39889 @@ -673,12 +639,16 @@
39890                 printk(KERN_DEBUG "%s: intr, status %04x cmd %02x cpcmd %04x\n",
39891                         dev->name, status, cpr8(Cmd), cpr16(CpCmd));
39892  
39893 -       cpw16_f(IntrStatus, status);
39894 +       cpw16(IntrStatus, status & ~cp_rx_intr_mask);
39895  
39896         spin_lock(&cp->lock);
39897  
39898 -       if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr))
39899 -               cp_rx(cp);
39900 +       if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr)) {
39901 +               if (netif_rx_schedule_prep(dev)) {
39902 +                       cpw16_f(IntrMask, cp_norx_intr_mask);
39903 +                       __netif_rx_schedule(dev);
39904 +               }
39905 +       }
39906         if (status & (TxOK | TxErr | TxEmpty | SWInt))
39907                 cp_tx(cp);
39908         if (status & LinkChg)
39909 @@ -691,6 +661,8 @@
39910                 pci_write_config_word(cp->pdev, PCI_STATUS, pci_status);
39911                 printk(KERN_ERR "%s: PCI bus error, status=%04x, PCI status=%04x\n",
39912                        dev->name, status, pci_status);
39913 +
39914 +               /* TODO: reset hardware */
39915         }
39916  
39917         spin_unlock(&cp->lock);
39918 @@ -750,7 +722,7 @@
39919  
39920         cp->tx_tail = tx_tail;
39921  
39922 -       if (netif_queue_stopped(cp->dev) && (TX_BUFFS_AVAIL(cp) > (MAX_SKB_FRAGS + 1)))
39923 +       if (TX_BUFFS_AVAIL(cp) > (MAX_SKB_FRAGS + 1))
39924                 netif_wake_queue(cp->dev);
39925  }
39926  
39927 @@ -792,7 +764,6 @@
39928                 txd->addr = cpu_to_le64(mapping);
39929                 wmb();
39930  
39931 -#ifdef CP_TX_CHECKSUM
39932                 if (skb->ip_summed == CHECKSUM_HW) {
39933                         const struct iphdr *ip = skb->nh.iph;
39934                         if (ip->protocol == IPPROTO_TCP)
39935 @@ -806,7 +777,6 @@
39936                         else
39937                                 BUG();
39938                 } else
39939 -#endif
39940                         txd->opts1 = cpu_to_le32(eor | len | DescOwn |
39941                                                  FirstFrag | LastFrag);
39942                 wmb();
39943 @@ -820,9 +790,7 @@
39944                 u32 first_len, first_eor;
39945                 dma_addr_t first_mapping;
39946                 int frag, first_entry = entry;
39947 -#ifdef CP_TX_CHECKSUM
39948                 const struct iphdr *ip = skb->nh.iph;
39949 -#endif
39950  
39951                 /* We must give this initial chunk to the device last.
39952                  * Otherwise we could race with the device.
39953 @@ -848,7 +816,7 @@
39954                                                   this_frag->page_offset),
39955                                                  len, PCI_DMA_TODEVICE);
39956                         eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
39957 -#ifdef CP_TX_CHECKSUM
39958 +
39959                         if (skb->ip_summed == CHECKSUM_HW) {
39960                                 ctrl = eor | len | DescOwn | IPCS;
39961                                 if (ip->protocol == IPPROTO_TCP)
39962 @@ -858,7 +826,6 @@
39963                                 else
39964                                         BUG();
39965                         } else
39966 -#endif
39967                                 ctrl = eor | len | DescOwn;
39968  
39969                         if (frag == skb_shinfo(skb)->nr_frags - 1)
39970 @@ -883,7 +850,6 @@
39971                 txd->addr = cpu_to_le64(first_mapping);
39972                 wmb();
39973  
39974 -#ifdef CP_TX_CHECKSUM
39975                 if (skb->ip_summed == CHECKSUM_HW) {
39976                         if (ip->protocol == IPPROTO_TCP)
39977                                 txd->opts1 = cpu_to_le32(first_eor | first_len |
39978 @@ -896,7 +862,6 @@
39979                         else
39980                                 BUG();
39981                 } else
39982 -#endif
39983                         txd->opts1 = cpu_to_le32(first_eor | first_len |
39984                                                  FirstFrag | DescOwn);
39985                 wmb();
39986 @@ -975,7 +940,9 @@
39987  
39988  static void __cp_get_stats(struct cp_private *cp)
39989  {
39990 -       /* XXX implement */
39991 +       /* only lower 24 bits valid; write any value to clear */
39992 +       cp->net_stats.rx_missed_errors += (cpr32 (RxMissed) & 0xffffff);
39993 +       cpw32 (RxMissed, 0);
39994  }
39995  
39996  static struct net_device_stats *cp_get_stats(struct net_device *dev)
39997 @@ -995,11 +962,10 @@
39998  {
39999         struct net_device *dev = cp->dev;
40000  
40001 -       cpw16(IntrMask, 0);
40002 -       cpr16(IntrMask);
40003 +       cpw16(IntrStatus, ~(cpr16(IntrStatus)));
40004 +       cpw16_f(IntrMask, 0);
40005         cpw8(Cmd, 0);
40006 -       cpw16(CpCmd, 0);
40007 -       cpr16(CpCmd);
40008 +       cpw16_f(CpCmd, 0);
40009         cpw16(IntrStatus, ~(cpr16(IntrStatus)));
40010         synchronize_irq(dev->irq);
40011         udelay(10);
40012 @@ -1031,11 +997,7 @@
40013  
40014  static inline void cp_start_hw (struct cp_private *cp)
40015  {
40016 -       u16 pci_dac = cp->pci_using_dac ? PCIDAC : 0;
40017 -       if (cp->board_type == RTL8169)
40018 -               cpw16(CpCmd, pci_dac | PCIMulRW | RxChkSum);
40019 -       else
40020 -               cpw16(CpCmd, pci_dac | PCIMulRW | RxChkSum | CpRxOn | CpTxOn);
40021 +       cpw16(CpCmd, cp->cpcmd);
40022         cpw8(Cmd, RxOn | TxOn);
40023  }
40024  
40025 @@ -1059,13 +1021,10 @@
40026  
40027         cpw8(Config1, cpr8(Config1) | DriverLoaded | PMEnable);
40028         /* Disable Wake-on-LAN. Can be turned on with ETHTOOL_SWOL */
40029 -       if (cp->board_type == RTL8139Cp) {
40030 -               cpw8(Config3, PARMEnable);
40031 -               cp->wol_enabled = 0;
40032 -       }
40033 +       cpw8(Config3, PARMEnable);
40034 +       cp->wol_enabled = 0;
40035 +
40036         cpw8(Config5, cpr8(Config5) & PMEStatus); 
40037 -       if (cp->board_type == RTL8169)
40038 -               cpw16(RxMaxSize, cp->rx_buf_sz);
40039  
40040         cpw32_f(HiTxRingAddr, 0);
40041         cpw32_f(HiTxRingAddr + 4, 0);
40042 @@ -1258,8 +1217,6 @@
40043  
40044         dev->mtu = new_mtu;
40045         cp_set_rxbufsize(cp);           /* set new rx buf size */
40046 -       if (cp->board_type == RTL8169)
40047 -               cpw16(RxMaxSize, cp->rx_buf_sz);
40048  
40049         rc = cp_init_rings(cp);         /* realloc and restart h/w */
40050         cp_start_hw(cp);
40051 @@ -1304,8 +1261,8 @@
40052  }
40053  
40054  /* Set the ethtool Wake-on-LAN settings */
40055 -static void netdev_set_wol (struct cp_private *cp,
40056 -                     const struct ethtool_wolinfo *wol)
40057 +static int netdev_set_wol (struct cp_private *cp,
40058 +                          const struct ethtool_wolinfo *wol)
40059  {
40060         u8 options;
40061  
40062 @@ -1332,6 +1289,8 @@
40063         cpw8 (Config5, options);
40064  
40065         cp->wol_enabled = (wol->wolopts) ? 1 : 0;
40066 +
40067 +       return 0;
40068  }
40069  
40070  /* Get the ethtool Wake-on-LAN settings */
40071 @@ -1357,308 +1316,205 @@
40072         if (options & MWF)           wol->wolopts |= WAKE_MCAST;
40073  }
40074  
40075 -static int cp_ethtool_ioctl (struct cp_private *cp, void *useraddr)
40076 +static void cp_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
40077  {
40078 -       u32 ethcmd;
40079 +       struct cp_private *cp = dev->priv;
40080  
40081 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
40082 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
40083 +       strcpy (info->driver, DRV_NAME);
40084 +       strcpy (info->version, DRV_VERSION);
40085 +       strcpy (info->bus_info, pci_name(cp->pdev));
40086 +}
40087  
40088 -       if (get_user(ethcmd, (u32 *)useraddr))
40089 -               return -EFAULT;
40090 -
40091 -       switch (ethcmd) {
40092 -
40093 -       case ETHTOOL_GDRVINFO: {
40094 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
40095 -               strcpy (info.driver, DRV_NAME);
40096 -               strcpy (info.version, DRV_VERSION);
40097 -               strcpy (info.bus_info, pci_name(cp->pdev));
40098 -               info.regdump_len = CP_REGS_SIZE;
40099 -               info.n_stats = CP_NUM_STATS;
40100 -               if (copy_to_user (useraddr, &info, sizeof (info)))
40101 -                       return -EFAULT;
40102 -               return 0;
40103 -       }
40104 +static int cp_get_regs_len(struct net_device *dev)
40105 +{
40106 +       return CP_REGS_SIZE;
40107 +}
40108  
40109 -       /* get settings */
40110 -       case ETHTOOL_GSET: {
40111 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
40112 -               spin_lock_irq(&cp->lock);
40113 -               mii_ethtool_gset(&cp->mii_if, &ecmd);
40114 -               spin_unlock_irq(&cp->lock);
40115 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
40116 -                       return -EFAULT;
40117 -               return 0;
40118 -       }
40119 -       /* set settings */
40120 -       case ETHTOOL_SSET: {
40121 -               int r;
40122 -               struct ethtool_cmd ecmd;
40123 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
40124 -                       return -EFAULT;
40125 -               spin_lock_irq(&cp->lock);
40126 -               r = mii_ethtool_sset(&cp->mii_if, &ecmd);
40127 -               spin_unlock_irq(&cp->lock);
40128 -               return r;
40129 -       }
40130 -       /* restart autonegotiation */
40131 -       case ETHTOOL_NWAY_RST: {
40132 -               return mii_nway_restart(&cp->mii_if);
40133 -       }
40134 -       /* get link status */
40135 -       case ETHTOOL_GLINK: {
40136 -               struct ethtool_value edata = {ETHTOOL_GLINK};
40137 -               edata.data = mii_link_ok(&cp->mii_if);
40138 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
40139 -                       return -EFAULT;
40140 -               return 0;
40141 -       }
40142 +static int cp_get_stats_count (struct net_device *dev)
40143 +{
40144 +       return CP_NUM_STATS;
40145 +}
40146  
40147 -       /* get message-level */
40148 -       case ETHTOOL_GMSGLVL: {
40149 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
40150 -               edata.data = cp->msg_enable;
40151 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
40152 -                       return -EFAULT;
40153 -               return 0;
40154 -       }
40155 -       /* set message-level */
40156 -       case ETHTOOL_SMSGLVL: {
40157 -               struct ethtool_value edata;
40158 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
40159 -                       return -EFAULT;
40160 -               cp->msg_enable = edata.data;
40161 -               return 0;
40162 -       }
40163 +static int cp_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
40164 +{
40165 +       struct cp_private *cp = dev->priv;
40166 +       int rc;
40167  
40168 -       /* NIC register dump */
40169 -       case ETHTOOL_GREGS: {
40170 -                struct ethtool_regs regs;
40171 -                u8 *regbuf = kmalloc(CP_REGS_SIZE, GFP_KERNEL);
40172 -                int rc;
40173 -
40174 -               if (!regbuf)
40175 -                       return -ENOMEM;
40176 -               memset(regbuf, 0, CP_REGS_SIZE);
40177 +       spin_lock_irq(&cp->lock);
40178 +       rc = mii_ethtool_gset(&cp->mii_if, cmd);
40179 +       spin_unlock_irq(&cp->lock);
40180  
40181 -                rc = copy_from_user(&regs, useraddr, sizeof(regs));
40182 -               if (rc) {
40183 -                       rc = -EFAULT;
40184 -                       goto err_out_gregs;
40185 -               }
40186 -                
40187 -                if (regs.len > CP_REGS_SIZE)
40188 -                        regs.len = CP_REGS_SIZE;
40189 -                if (regs.len < CP_REGS_SIZE) {
40190 -                       rc = -EINVAL;
40191 -                       goto err_out_gregs;
40192 -               }
40193 +       return rc;
40194 +}
40195  
40196 -                regs.version = CP_REGS_VER;
40197 -                rc = copy_to_user(useraddr, &regs, sizeof(regs));
40198 -               if (rc) {
40199 -                       rc = -EFAULT;
40200 -                       goto err_out_gregs;
40201 -               }
40202 +static int cp_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
40203 +{
40204 +       struct cp_private *cp = dev->priv;
40205 +       int rc;
40206  
40207 -                useraddr += offsetof(struct ethtool_regs, data);
40208 +       spin_lock_irq(&cp->lock);
40209 +       rc = mii_ethtool_sset(&cp->mii_if, cmd);
40210 +       spin_unlock_irq(&cp->lock);
40211  
40212 -                spin_lock_irq(&cp->lock);
40213 -                memcpy_fromio(regbuf, cp->regs, CP_REGS_SIZE);
40214 -                spin_unlock_irq(&cp->lock);
40215 +       return rc;
40216 +}
40217  
40218 -                if (copy_to_user(useraddr, regbuf, regs.len))
40219 -                        rc = -EFAULT;
40220 +static int cp_nway_reset(struct net_device *dev)
40221 +{
40222 +       struct cp_private *cp = dev->priv;
40223 +       return mii_nway_restart(&cp->mii_if);
40224 +}
40225  
40226 -err_out_gregs:
40227 -               kfree(regbuf);
40228 -               return rc;
40229 -       }
40230 +static u32 cp_get_msglevel(struct net_device *dev)
40231 +{
40232 +       struct cp_private *cp = dev->priv;
40233 +       return cp->msg_enable;
40234 +}
40235  
40236 -       /* get/set RX checksumming */
40237 -       case ETHTOOL_GRXCSUM: {
40238 -               struct ethtool_value edata = { ETHTOOL_GRXCSUM };
40239 -               u16 cmd = cpr16(CpCmd) & RxChkSum;
40240 -
40241 -               edata.data = cmd ? 1 : 0;
40242 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
40243 -                       return -EFAULT;
40244 -               return 0;
40245 -       }
40246 -       case ETHTOOL_SRXCSUM: {
40247 -               struct ethtool_value edata;
40248 -               u16 cmd = cpr16(CpCmd), newcmd;
40249 +static void cp_set_msglevel(struct net_device *dev, u32 value)
40250 +{
40251 +       struct cp_private *cp = dev->priv;
40252 +       cp->msg_enable = value;
40253 +}
40254  
40255 -               newcmd = cmd;
40256 +static u32 cp_get_rx_csum(struct net_device *dev)
40257 +{
40258 +       struct cp_private *cp = dev->priv;
40259 +       return (cpr16(CpCmd) & RxChkSum) ? 1 : 0;
40260 +}
40261  
40262 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
40263 -                       return -EFAULT;
40264 +static int cp_set_rx_csum(struct net_device *dev, u32 data)
40265 +{
40266 +       struct cp_private *cp = dev->priv;
40267 +       u16 cmd = cp->cpcmd, newcmd;
40268  
40269 -               if (edata.data)
40270 -                       newcmd |= RxChkSum;
40271 -               else
40272 -                       newcmd &= ~RxChkSum;
40273 +       newcmd = cmd;
40274  
40275 -               if (newcmd == cmd)
40276 -                       return 0;
40277 +       if (data)
40278 +               newcmd |= RxChkSum;
40279 +       else
40280 +               newcmd &= ~RxChkSum;
40281  
40282 +       if (newcmd != cmd) {
40283                 spin_lock_irq(&cp->lock);
40284 +               cp->cpcmd = newcmd;
40285                 cpw16_f(CpCmd, newcmd);
40286                 spin_unlock_irq(&cp->lock);
40287         }
40288  
40289 -       /* get/set TX checksumming */
40290 -       case ETHTOOL_GTXCSUM: {
40291 -               struct ethtool_value edata = { ETHTOOL_GTXCSUM };
40292 -
40293 -               edata.data = (cp->dev->features & NETIF_F_IP_CSUM) != 0;
40294 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
40295 -                       return -EFAULT;
40296 -               return 0;
40297 -       }
40298 -       case ETHTOOL_STXCSUM: {
40299 -               struct ethtool_value edata;
40300 -
40301 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
40302 -                       return -EFAULT;
40303 -
40304 -               if (edata.data)
40305 -                       cp->dev->features |= NETIF_F_IP_CSUM;
40306 -               else
40307 -                       cp->dev->features &= ~NETIF_F_IP_CSUM;
40308 -
40309 -               return 0;
40310 -       }
40311 +       return 0;
40312 +}
40313  
40314 -       /* get/set scatter-gather */
40315 -       case ETHTOOL_GSG: {
40316 -               struct ethtool_value edata = { ETHTOOL_GSG };
40317 -
40318 -               edata.data = (cp->dev->features & NETIF_F_SG) != 0;
40319 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
40320 -                       return -EFAULT;
40321 -               return 0;
40322 -       }
40323 -       case ETHTOOL_SSG: {
40324 -               struct ethtool_value edata;
40325 +static void cp_get_regs(struct net_device *dev, struct ethtool_regs *regs,
40326 +                       void *p)
40327 +{
40328 +       struct cp_private *cp = dev->priv;
40329  
40330 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
40331 -                       return -EFAULT;
40332 +       if (regs->len < CP_REGS_SIZE)
40333 +               return /* -EINVAL */;
40334  
40335 -               if (edata.data)
40336 -                       cp->dev->features |= NETIF_F_SG;
40337 -               else
40338 -                       cp->dev->features &= ~NETIF_F_SG;
40339 +       regs->version = CP_REGS_VER;
40340  
40341 -               return 0;
40342 -       }
40343 +       spin_lock_irq(&cp->lock);
40344 +       memcpy_fromio(p, cp->regs, CP_REGS_SIZE);
40345 +       spin_unlock_irq(&cp->lock);
40346 +}
40347  
40348 -       /* get string list(s) */
40349 -       case ETHTOOL_GSTRINGS: {
40350 -               struct ethtool_gstrings estr = { ETHTOOL_GSTRINGS };
40351 -
40352 -               if (copy_from_user(&estr, useraddr, sizeof(estr)))
40353 -                       return -EFAULT;
40354 -               if (estr.string_set != ETH_SS_STATS)
40355 -                       return -EINVAL;
40356 -
40357 -               estr.len = CP_NUM_STATS;
40358 -               if (copy_to_user(useraddr, &estr, sizeof(estr)))
40359 -                       return -EFAULT;
40360 -               if (copy_to_user(useraddr + sizeof(estr),
40361 -                                &ethtool_stats_keys,
40362 -                                sizeof(ethtool_stats_keys)))
40363 -                       return -EFAULT;
40364 -               return 0;
40365 -       }
40366 +static void cp_get_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
40367 +{
40368 +       struct cp_private *cp = dev->priv;
40369  
40370 -       /* get NIC-specific statistics */
40371 -       case ETHTOOL_GSTATS: {
40372 -               struct ethtool_stats estats = { ETHTOOL_GSTATS };
40373 -               u64 *tmp_stats;
40374 -               unsigned int work = 100;
40375 -               const unsigned int sz = sizeof(u64) * CP_NUM_STATS;
40376 -               int i;
40377 -
40378 -               /* begin NIC statistics dump */
40379 -               cpw32(StatsAddr + 4, 0); /* FIXME: 64-bit PCI */
40380 -               cpw32(StatsAddr, cp->nic_stats_dma | DumpStats);
40381 -               cpr32(StatsAddr);
40382 -
40383 -               estats.n_stats = CP_NUM_STATS;
40384 -               if (copy_to_user(useraddr, &estats, sizeof(estats)))
40385 -                       return -EFAULT;
40386 -
40387 -               while (work-- > 0) {
40388 -                       if ((cpr32(StatsAddr) & DumpStats) == 0)
40389 -                               break;
40390 -                       cpu_relax();
40391 -               }
40392 +       spin_lock_irq (&cp->lock);
40393 +       netdev_get_wol (cp, wol);
40394 +       spin_unlock_irq (&cp->lock);
40395 +}
40396  
40397 -               if (cpr32(StatsAddr) & DumpStats)
40398 -                       return -EIO;
40399 +static int cp_set_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
40400 +{
40401 +       struct cp_private *cp = dev->priv;
40402 +       int rc;
40403  
40404 -               tmp_stats = kmalloc(sz, GFP_KERNEL);
40405 -               if (!tmp_stats)
40406 -                       return -ENOMEM;
40407 -               memset(tmp_stats, 0, sz);
40408 -
40409 -               i = 0;
40410 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);
40411 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok);
40412 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_err);
40413 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_err);
40414 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->rx_fifo);
40415 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->frame_align);
40416 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_1col);
40417 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_mcol);
40418 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_phys);
40419 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_bcast);
40420 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_ok_mcast);
40421 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_abort);
40422 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_underrun);
40423 -               tmp_stats[i++] = cp->cp_stats.rx_frags;
40424 -               if (i != CP_NUM_STATS)
40425 -                       BUG();
40426 +       spin_lock_irq (&cp->lock);
40427 +       rc = netdev_set_wol (cp, wol);
40428 +       spin_unlock_irq (&cp->lock);
40429  
40430 -               i = copy_to_user(useraddr + sizeof(estats),
40431 -                                tmp_stats, sz);
40432 -               kfree(tmp_stats);
40433 +       return rc;
40434 +}
40435  
40436 -               if (i)
40437 -                       return -EFAULT;
40438 -               return 0;
40439 +static void cp_get_strings (struct net_device *dev, u32 stringset, u8 *buf)
40440 +{
40441 +       switch (stringset) {
40442 +       case ETH_SS_STATS:
40443 +               memcpy(buf, &ethtool_stats_keys, sizeof(ethtool_stats_keys));
40444 +               break;
40445 +       default:
40446 +               BUG();
40447 +               break;
40448         }
40449 +}
40450  
40451 -       /* get/set Wake-on-LAN settings */
40452 -       case ETHTOOL_GWOL: {
40453 -               struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
40454 -               
40455 -               spin_lock_irq (&cp->lock);
40456 -               netdev_get_wol (cp, &wol);
40457 -               spin_unlock_irq (&cp->lock);
40458 -               return ((copy_to_user (useraddr, &wol, sizeof (wol)))? -EFAULT : 0);
40459 -       }
40460 -       
40461 -       case ETHTOOL_SWOL: {
40462 -               struct ethtool_wolinfo wol;
40463 +static void cp_get_ethtool_stats (struct net_device *dev,
40464 +                                 struct ethtool_stats *estats, u64 *tmp_stats)
40465 +{
40466 +       struct cp_private *cp = dev->priv;
40467 +       unsigned int work = 100;
40468 +       int i;
40469  
40470 -               if (copy_from_user (&wol, useraddr, sizeof (wol)))
40471 -                       return -EFAULT;
40472 -               spin_lock_irq (&cp->lock);
40473 -               netdev_set_wol (cp, &wol);
40474 -               spin_unlock_irq (&cp->lock);
40475 -               return 0;
40476 -       }
40477 +       /* begin NIC statistics dump */
40478 +       cpw32(StatsAddr + 4, 0); /* FIXME: 64-bit PCI */
40479 +       cpw32(StatsAddr, cp->nic_stats_dma | DumpStats);
40480 +       cpr32(StatsAddr);
40481  
40482 -       default:
40483 -               break;
40484 +       while (work-- > 0) {
40485 +               if ((cpr32(StatsAddr) & DumpStats) == 0)
40486 +                       break;
40487 +               cpu_relax();
40488         }
40489  
40490 -       return -EOPNOTSUPP;
40491 +       if (cpr32(StatsAddr) & DumpStats)
40492 +               return /* -EIO */;
40493 +
40494 +       i = 0;
40495 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);
40496 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok);
40497 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_err);
40498 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_err);
40499 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->rx_fifo);
40500 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->frame_align);
40501 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_1col);
40502 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_mcol);
40503 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_phys);
40504 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_bcast);
40505 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_ok_mcast);
40506 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_abort);
40507 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_underrun);
40508 +       tmp_stats[i++] = cp->cp_stats.rx_frags;
40509 +       if (i != CP_NUM_STATS)
40510 +               BUG();
40511  }
40512  
40513 +static struct ethtool_ops cp_ethtool_ops = {
40514 +       .get_drvinfo            = cp_get_drvinfo,
40515 +       .get_regs_len           = cp_get_regs_len,
40516 +       .get_stats_count        = cp_get_stats_count,
40517 +       .get_settings           = cp_get_settings,
40518 +       .set_settings           = cp_set_settings,
40519 +       .nway_reset             = cp_nway_reset,
40520 +       .get_link               = ethtool_op_get_link,
40521 +       .get_msglevel           = cp_get_msglevel,
40522 +       .set_msglevel           = cp_set_msglevel,
40523 +       .get_rx_csum            = cp_get_rx_csum,
40524 +       .set_rx_csum            = cp_set_rx_csum,
40525 +       .get_tx_csum            = ethtool_op_get_tx_csum,
40526 +       .set_tx_csum            = ethtool_op_set_tx_csum, /* local! */
40527 +       .get_sg                 = ethtool_op_get_sg,
40528 +       .set_sg                 = ethtool_op_set_sg,
40529 +       .get_regs               = cp_get_regs,
40530 +       .get_wol                = cp_get_wol,
40531 +       .set_wol                = cp_set_wol,
40532 +       .get_strings            = cp_get_strings,
40533 +       .get_ethtool_stats      = cp_get_ethtool_stats,
40534 +};
40535  
40536  static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
40537  {
40538 @@ -1669,38 +1525,12 @@
40539         if (!netif_running(dev))
40540                 return -EINVAL;
40541  
40542 -       if (cmd == SIOCETHTOOL)
40543 -               return cp_ethtool_ioctl(cp, (void *) rq->ifr_data);
40544 -
40545         spin_lock_irq(&cp->lock);
40546         rc = generic_mii_ioctl(&cp->mii_if, mii, cmd, NULL);
40547         spin_unlock_irq(&cp->lock);
40548         return rc;
40549  }
40550  
40551 -#if CP_VLAN_TAG_USED
40552 -static void cp_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
40553 -{
40554 -       struct cp_private *cp = dev->priv;
40555 -
40556 -       spin_lock_irq(&cp->lock);
40557 -       cp->vlgrp = grp;
40558 -       cpw16(CpCmd, cpr16(CpCmd) | RxVlanOn);
40559 -       spin_unlock_irq(&cp->lock);
40560 -}
40561 -
40562 -static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
40563 -{
40564 -       struct cp_private *cp = dev->priv;
40565 -
40566 -       spin_lock_irq(&cp->lock);
40567 -       cpw16(CpCmd, cpr16(CpCmd) & ~RxVlanOn);
40568 -       if (cp->vlgrp)
40569 -               cp->vlgrp->vlan_devices[vid] = NULL;
40570 -       spin_unlock_irq(&cp->lock);
40571 -}
40572 -#endif
40573 -
40574  /* Serial EEPROM section. */
40575  
40576  /*  EEPROM_Ctrl bits. */
40577 @@ -1723,7 +1553,7 @@
40578  #define EE_READ_CMD            (6)
40579  #define EE_ERASE_CMD   (7)
40580  
40581 -static int __devinit read_eeprom (void *ioaddr, int location, int addr_len)
40582 +static int read_eeprom (void *ioaddr, int location, int addr_len)
40583  {
40584         int i;
40585         unsigned retval = 0;
40586 @@ -1769,17 +1599,15 @@
40587         pci_set_power_state (cp->pdev, 3);
40588  }
40589  
40590 -static int __devinit cp_init_one (struct pci_dev *pdev,
40591 -                                 const struct pci_device_id *ent)
40592 +static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40593  {
40594         struct net_device *dev;
40595         struct cp_private *cp;
40596         int rc;
40597         void *regs;
40598         long pciaddr;
40599 -       unsigned int addr_len, i;
40600 -       u8 pci_rev, cache_size;
40601 -       unsigned int board_type = (unsigned int) ent->driver_data;
40602 +       unsigned int addr_len, i, pci_using_dac;
40603 +       u8 pci_rev;
40604  
40605  #ifndef MODULE
40606         static int version_printed;
40607 @@ -1805,7 +1633,6 @@
40608  
40609         cp = dev->priv;
40610         cp->pdev = pdev;
40611 -       cp->board_type = board_type;
40612         cp->dev = dev;
40613         cp->msg_enable = (debug < 0 ? CP_DEF_MSG_ENABLE : debug);
40614         spin_lock_init (&cp->lock);
40615 @@ -1821,10 +1648,14 @@
40616         if (rc)
40617                 goto err_out_free;
40618  
40619 -       rc = pci_request_regions(pdev, DRV_NAME);
40620 +       rc = pci_set_mwi(pdev);
40621         if (rc)
40622                 goto err_out_disable;
40623  
40624 +       rc = pci_request_regions(pdev, DRV_NAME);
40625 +       if (rc)
40626 +               goto err_out_mwi;
40627 +
40628         if (pdev->irq < 2) {
40629                 rc = -EIO;
40630                 printk(KERN_ERR PFX "invalid irq (%d) for pci dev %s\n",
40631 @@ -1846,18 +1677,22 @@
40632         }
40633  
40634         /* Configure DMA attributes. */
40635 -       if (!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) {
40636 -               cp->pci_using_dac = 1;
40637 +       if ((sizeof(dma_addr_t) > 32) &&
40638 +           !pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) {
40639 +               pci_using_dac = 1;
40640         } else {
40641 -               rc = pci_set_dma_mask(pdev, (u64) 0xffffffff);
40642 +               rc = pci_set_dma_mask(pdev, 0xffffffffULL);
40643                 if (rc) {
40644                         printk(KERN_ERR PFX "No usable DMA configuration, "
40645                                "aborting.\n");
40646                         goto err_out_res;
40647                 }
40648 -               cp->pci_using_dac = 0;
40649 +               pci_using_dac = 0;
40650         }
40651  
40652 +       cp->cpcmd = (pci_using_dac ? PCIDAC : 0) |
40653 +                   PCIMulRW | RxChkSum | CpRxOn | CpTxOn;
40654 +
40655         regs = ioremap_nocache(pciaddr, CP_REGS_SIZE);
40656         if (!regs) {
40657                 rc = -EIO;
40658 @@ -1882,16 +1717,17 @@
40659         dev->hard_start_xmit = cp_start_xmit;
40660         dev->get_stats = cp_get_stats;
40661         dev->do_ioctl = cp_ioctl;
40662 +       dev->poll = cp_rx_poll;
40663 +       dev->weight = 16;       /* arbitrary? from NAPI_HOWTO.txt. */
40664  #ifdef BROKEN
40665         dev->change_mtu = cp_change_mtu;
40666  #endif
40667 +       dev->ethtool_ops = &cp_ethtool_ops;
40668  #if 0
40669         dev->tx_timeout = cp_tx_timeout;
40670         dev->watchdog_timeo = TX_TIMEOUT;
40671  #endif
40672 -#ifdef CP_TX_CHECKSUM
40673 -       dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
40674 -#endif
40675 +
40676  #if CP_VLAN_TAG_USED
40677         dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
40678         dev->vlan_rx_register = cp_vlan_rx_register;
40679 @@ -1904,11 +1740,10 @@
40680         if (rc)
40681                 goto err_out_iomap;
40682  
40683 -       printk (KERN_INFO "%s: %s at 0x%lx, "
40684 +       printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, "
40685                 "%02x:%02x:%02x:%02x:%02x:%02x, "
40686                 "IRQ %d\n",
40687                 dev->name,
40688 -               cp_board_tbl[board_type].name,
40689                 dev->base_addr,
40690                 dev->dev_addr[0], dev->dev_addr[1],
40691                 dev->dev_addr[2], dev->dev_addr[3],
40692 @@ -1917,29 +1752,8 @@
40693  
40694         pci_set_drvdata(pdev, dev);
40695  
40696 -       /*
40697 -        * Looks like this is necessary to deal with on all architectures,
40698 -        * even this %$#%$# N440BX Intel based thing doesn't get it right.
40699 -        * Ie. having two NICs in the machine, one will have the cache
40700 -        * line set at boot time, the other will not.
40701 -        */
40702 -       pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache_size);
40703 -       cache_size <<= 2;
40704 -       if (cache_size != SMP_CACHE_BYTES) {
40705 -               printk(KERN_INFO "%s: PCI cache line size set incorrectly "
40706 -                      "(%i bytes) by BIOS/FW, ", dev->name, cache_size);
40707 -               if (cache_size > SMP_CACHE_BYTES)
40708 -                       printk("expecting %i\n", SMP_CACHE_BYTES);
40709 -               else {
40710 -                       printk("correcting to %i\n", SMP_CACHE_BYTES);
40711 -                       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
40712 -                                             SMP_CACHE_BYTES >> 2);
40713 -               }
40714 -       }
40715 -
40716         /* enable busmastering and memory-write-invalidate */
40717         pci_set_master(pdev);
40718 -       pci_set_mwi(pdev);
40719  
40720         if (cp->wol_enabled) cp_set_d3_state (cp);
40721  
40722 @@ -1949,6 +1763,8 @@
40723         iounmap(regs);
40724  err_out_res:
40725         pci_release_regions(pdev);
40726 +err_out_mwi:
40727 +       pci_clear_mwi(pdev);
40728  err_out_disable:
40729         pci_disable_device(pdev);
40730  err_out_free:
40731 @@ -1956,7 +1772,7 @@
40732         return rc;
40733  }
40734  
40735 -static void __devexit cp_remove_one (struct pci_dev *pdev)
40736 +static void cp_remove_one (struct pci_dev *pdev)
40737  {
40738         struct net_device *dev = pci_get_drvdata(pdev);
40739         struct cp_private *cp = dev->priv;
40740 @@ -1967,6 +1783,7 @@
40741         iounmap(cp->regs);
40742         if (cp->wol_enabled) pci_set_power_state (pdev, 0);
40743         pci_release_regions(pdev);
40744 +       pci_clear_mwi(pdev);
40745         pci_disable_device(pdev);
40746         pci_set_drvdata(pdev, NULL);
40747         free_netdev(dev);
40748 @@ -2029,7 +1846,7 @@
40749         .name         = DRV_NAME,
40750         .id_table     = cp_pci_tbl,
40751         .probe        = cp_init_one,
40752 -       .remove       = __devexit_p(cp_remove_one),
40753 +       .remove       = cp_remove_one,
40754  #ifdef CONFIG_PM
40755         .resume       = cp_resume,
40756         .suspend      = cp_suspend,
40757 diff -Nru a/drivers/net/8139too.c b/drivers/net/8139too.c
40758 --- a/drivers/net/8139too.c     Tue Aug 19 20:13:55 2003
40759 +++ b/drivers/net/8139too.c     Sun Aug 31 12:38:16 2003
40760 @@ -123,6 +123,11 @@
40761  #define USE_IO_OPS 1
40762  #endif
40763  
40764 +/* use a 16K rx ring buffer instead of the default 32K */
40765 +#ifdef CONFIG_SH_DREAMCAST
40766 +#define USE_BUF16K 1
40767 +#endif
40768 +
40769  /* define to 1 to enable copious debugging info */
40770  #undef RTL8139_DEBUG
40771  
40772 @@ -165,7 +170,11 @@
40773  static int debug = -1;
40774  
40775  /* Size of the in-memory receive ring. */
40776 +#ifdef USE_BUF16K
40777 +#define RX_BUF_LEN_IDX 1       /* 0==8K, 1==16K, 2==32K, 3==64K */
40778 +#else
40779  #define RX_BUF_LEN_IDX 2       /* 0==8K, 1==16K, 2==32K, 3==64K */
40780 +#endif
40781  #define RX_BUF_LEN     (8192 << RX_BUF_LEN_IDX)
40782  #define RX_BUF_PAD     16
40783  #define RX_BUF_WRAP_PAD 2048 /* spare padding to handle lack of packet wrap */
40784 @@ -212,18 +221,7 @@
40785  
40786  typedef enum {
40787         RTL8139 = 0,
40788 -       RTL8139_CB,
40789 -       SMC1211TX,
40790 -       /*MPX5030,*/
40791 -       DELTA8139,
40792 -       ADDTRON8139,
40793 -       DFE538TX,
40794 -       DFE690TXD,
40795 -       FE2000VX,
40796 -       ALLIED8139,
40797         RTL8129,
40798 -       FNW3603TX,
40799 -       FNW3800TX,
40800  } board_t;
40801  
40802  
40803 @@ -232,36 +230,29 @@
40804         const char *name;
40805         u32 hw_flags;
40806  } board_info[] __devinitdata = {
40807 -       { "RealTek RTL8139 Fast Ethernet", RTL8139_CAPS },
40808 -       { "RealTek RTL8139B PCI/CardBus", RTL8139_CAPS },
40809 -       { "SMC1211TX EZCard 10/100 (RealTek RTL8139)", RTL8139_CAPS },
40810 -/*     { MPX5030, "Accton MPX5030 (RealTek RTL8139)", RTL8139_CAPS },*/
40811 -       { "Delta Electronics 8139 10/100BaseTX", RTL8139_CAPS },
40812 -       { "Addtron Technolgy 8139 10/100BaseTX", RTL8139_CAPS },
40813 -       { "D-Link DFE-538TX (RealTek RTL8139)", RTL8139_CAPS },
40814 -       { "D-Link DFE-690TXD (RealTek RTL8139)", RTL8139_CAPS },
40815 -       { "AboCom FE2000VX (RealTek RTL8139)", RTL8139_CAPS },
40816 -       { "Allied Telesyn 8139 CardBus", RTL8139_CAPS },
40817 +       { "RealTek RTL8139", RTL8139_CAPS },
40818         { "RealTek RTL8129", RTL8129_CAPS },
40819 -       { "Planex FNW-3603-TX 10/100 CardBus", RTL8139_CAPS },
40820 -       { "Planex FNW-3800-TX 10/100 CardBus", RTL8139_CAPS },
40821  };
40822  
40823  
40824  static struct pci_device_id rtl8139_pci_tbl[] = {
40825         {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40826 -       {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139_CB },
40827 -       {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SMC1211TX },
40828 -/*     {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MPX5030 },*/
40829 -       {0x1500, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DELTA8139 },
40830 -       {0x4033, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ADDTRON8139 },
40831 -       {0x1186, 0x1300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DFE538TX },
40832 -       {0x1186, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DFE690TXD },
40833 -       {0x13d1, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FE2000VX },
40834 -       {0x1259, 0xa117, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ALLIED8139 },
40835 -       {0x14ea, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FNW3603TX },
40836 -       {0x14ea, 0xab07, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FNW3800TX },
40837 -
40838 +       {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40839 +       {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40840 +       {0x1500, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40841 +       {0x4033, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40842 +       {0x1186, 0x1300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40843 +       {0x1186, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40844 +       {0x13d1, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40845 +       {0x1259, 0xa117, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40846 +       {0x14ea, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40847 +       {0x14ea, 0xab07, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40848 +       {0x11db, 0x1234, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40849 +
40850 +#ifdef CONFIG_SH_SECUREEDGE5410
40851 +       /* Bogus 8139 silicon reports 8129 without external PROM :-( */
40852 +       {0x10ec, 0x8129, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
40853 +#endif
40854  #ifdef CONFIG_8139TOO_8129
40855         {0x10ec, 0x8129, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8129 },
40856  #endif
40857 @@ -271,8 +262,8 @@
40858          * so we simply don't match on the main vendor id.
40859          */
40860         {PCI_ANY_ID, 0x8139, 0x10ec, 0x8139, 0, 0, RTL8139 },
40861 -       {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, DFE538TX },
40862 -       {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, FE2000VX },
40863 +       {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, RTL8139 },
40864 +       {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, RTL8139 },
40865  
40866         {0,}
40867  };
40868 @@ -302,7 +293,6 @@
40869         IntrMask = 0x3C,
40870         IntrStatus = 0x3E,
40871         TxConfig = 0x40,
40872 -       ChipVersion = 0x43,
40873         RxConfig = 0x44,
40874         Timer = 0x48,           /* A general-purpose counter. */
40875         RxMissed = 0x4C,        /* 24 bits valid, write clears. */
40876 @@ -461,7 +451,6 @@
40877         RxNoWrap = (1 << 7),
40878  };
40879  
40880 -
40881  /* Twister tuning parameters from RealTek.
40882     Completely undocumented, but required to tune bad links on some boards. */
40883  enum CSCRBits {
40884 @@ -472,36 +461,22 @@
40885         CSCR_LinkDownCmd = 0x0f3c0,
40886  };
40887  
40888 -
40889  enum Cfg9346Bits {
40890         Cfg9346_Lock = 0x00,
40891         Cfg9346_Unlock = 0xC0,
40892  };
40893  
40894 -#ifdef CONFIG_8139TOO_TUNE_TWISTER
40895 -
40896 -enum TwisterParamVals {
40897 -       PARA78_default  = 0x78fa8388,
40898 -       PARA7c_default  = 0xcb38de43,   /* param[0][3] */
40899 -       PARA7c_xxx      = 0xcb38de43,
40900 -};
40901 -
40902 -static const unsigned long param[4][4] = {
40903 -       {0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43},
40904 -       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
40905 -       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
40906 -       {0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83}
40907 -};
40908 -
40909 -#endif /* CONFIG_8139TOO_TUNE_TWISTER */
40910 -
40911  typedef enum {
40912         CH_8139 = 0,
40913         CH_8139_K,
40914         CH_8139A,
40915 +       CH_8139A_G,
40916         CH_8139B,
40917         CH_8130,
40918         CH_8139C,
40919 +       CH_8100,
40920 +       CH_8100B_8139D,
40921 +       CH_8101,
40922  } chip_t;
40923  
40924  enum chip_flags {
40925 @@ -509,50 +484,65 @@
40926         HasLWake = (1 << 1),
40927  };
40928  
40929 +#define HW_REVID(b30, b29, b28, b27, b26, b23, b22) \
40930 +       (b30<<30 | b29<<29 | b28<<28 | b27<<27 | b26<<26 | b23<<23 | b22<<22)
40931 +#define HW_REVID_MASK  HW_REVID(1, 1, 1, 1, 1, 1, 1)
40932  
40933  /* directly indexed by chip_t, above */
40934  const static struct {
40935         const char *name;
40936 -       u8 version; /* from RTL8139C docs */
40937 -       u32 RxConfigMask; /* should clear the bits supported by this chip */
40938 +       u32 version; /* from RTL8139C/RTL8139D docs */
40939         u32 flags;
40940  } rtl_chip_info[] = {
40941         { "RTL-8139",
40942 -         0x40,
40943 -         0xf0fe0040, /* XXX copied from RTL8139A, verify */
40944 +         HW_REVID(1, 0, 0, 0, 0, 0, 0),
40945           HasHltClk,
40946         },
40947  
40948         { "RTL-8139 rev K",
40949 -         0x60,
40950 -         0xf0fe0040,
40951 +         HW_REVID(1, 1, 0, 0, 0, 0, 0),
40952           HasHltClk,
40953         },
40954  
40955         { "RTL-8139A",
40956 -         0x70,
40957 -         0xf0fe0040,
40958 +         HW_REVID(1, 1, 1, 0, 0, 0, 0),
40959 +         HasHltClk, /* XXX undocumented? */
40960 +       },
40961 +
40962 +       { "RTL-8139A rev G",
40963 +         HW_REVID(1, 1, 1, 0, 0, 1, 0),
40964           HasHltClk, /* XXX undocumented? */
40965         },
40966  
40967         { "RTL-8139B",
40968 -         0x78,
40969 -         0xf0fc0040,
40970 +         HW_REVID(1, 1, 1, 1, 0, 0, 0),
40971           HasLWake,
40972         },
40973  
40974         { "RTL-8130",
40975 -         0x7C,
40976 -         0xf0fe0040, /* XXX copied from RTL8139A, verify */
40977 +         HW_REVID(1, 1, 1, 1, 1, 0, 0),
40978           HasLWake,
40979         },
40980  
40981         { "RTL-8139C",
40982 -         0x74,
40983 -         0xf0fc0040, /* XXX copied from RTL8139B, verify */
40984 +         HW_REVID(1, 1, 1, 0, 1, 0, 0),
40985           HasLWake,
40986         },
40987  
40988 +       { "RTL-8100",
40989 +         HW_REVID(1, 1, 1, 1, 0, 1, 0),
40990 +         HasLWake,
40991 +       },
40992 +
40993 +       { "RTL-8100B/8139D",
40994 +         HW_REVID(1, 1, 1, 0, 1, 0, 1),
40995 +         HasLWake,
40996 +       },
40997 +
40998 +       { "RTL-8101",
40999 +         HW_REVID(1, 1, 1, 0, 1, 1, 1),
41000 +         HasLWake,
41001 +       },
41002  };
41003  
41004  struct rtl_extra_stats {
41005 @@ -612,7 +602,7 @@
41006  static int mdio_read (struct net_device *dev, int phy_id, int location);
41007  static void mdio_write (struct net_device *dev, int phy_id, int location,
41008                         int val);
41009 -static int rtl8139_thread (void *data);
41010 +static inline void rtl8139_start_thread(struct net_device *dev);
41011  static void rtl8139_tx_timeout (struct net_device *dev);
41012  static void rtl8139_init_ring (struct net_device *dev);
41013  static int rtl8139_start_xmit (struct sk_buff *skb,
41014 @@ -625,6 +615,7 @@
41015  static void rtl8139_set_rx_mode (struct net_device *dev);
41016  static void __set_rx_mode (struct net_device *dev);
41017  static void rtl8139_hw_start (struct net_device *dev);
41018 +static struct ethtool_ops rtl8139_ethtool_ops;
41019  
41020  #ifdef USE_IO_OPS
41021  
41022 @@ -688,10 +679,17 @@
41023         PCIErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver |
41024         TxErr | TxOK | RxErr | RxOK;
41025  
41026 +#ifdef USE_BUF16K 
41027 +static const unsigned int rtl8139_rx_config =
41028 +       RxCfgRcv16K | RxNoWrap |
41029 +       (RX_FIFO_THRESH << RxCfgFIFOShift) |
41030 +       (RX_DMA_BURST << RxCfgDMAShift);
41031 +#else
41032  static const unsigned int rtl8139_rx_config =
41033         RxCfgRcv32K | RxNoWrap |
41034         (RX_FIFO_THRESH << RxCfgFIFOShift) |
41035         (RX_DMA_BURST << RxCfgDMAShift);
41036 +#endif
41037  
41038  static const unsigned int rtl8139_tx_config =
41039         (TX_DMA_BURST << TxDMAShift) | (TX_RETRY << TxRetryShift);
41040 @@ -716,13 +714,6 @@
41041         /* it's ok to call this even if we have no regions to free */
41042         pci_release_regions (pdev);
41043  
41044 -#ifndef RTL8139_NDEBUG
41045 -       /* poison memory before freeing */
41046 -       memset (dev, 0xBC,
41047 -               sizeof (struct net_device) +
41048 -               sizeof (struct rtl8139_private));
41049 -#endif /* RTL8139_NDEBUG */
41050 -
41051         free_netdev(dev);
41052  
41053         pci_set_drvdata (pdev, NULL);
41054 @@ -757,7 +748,7 @@
41055         unsigned int i;
41056         u32 pio_start, pio_end, pio_flags, pio_len;
41057         unsigned long mmio_start, mmio_end, mmio_flags, mmio_len;
41058 -       u32 tmp;
41059 +       u32 version;
41060  
41061         assert (pdev != NULL);
41062  
41063 @@ -859,9 +850,9 @@
41064         }
41065  
41066         /* identify chip attached to board */
41067 -       tmp = RTL_R8 (ChipVersion);
41068 +       version = RTL_R32 (TxConfig) & HW_REVID_MASK;
41069         for (i = 0; i < ARRAY_SIZE (rtl_chip_info); i++)
41070 -               if (tmp == rtl_chip_info[i].version) {
41071 +               if (version == rtl_chip_info[i].version) {
41072                         tp->chipset = i;
41073                         goto match;
41074                 }
41075 @@ -892,8 +883,11 @@
41076                 }
41077                 if (rtl_chip_info[tp->chipset].flags & HasLWake) {
41078                         tmp8 = RTL_R8 (Config4);
41079 -                       if (tmp8 & LWPTN)
41080 +                       if (tmp8 & LWPTN) {
41081 +                               RTL_W8 (Cfg9346, Cfg9346_Unlock);
41082                                 RTL_W8 (Config4, tmp8 & ~LWPTN);
41083 +                               RTL_W8 (Cfg9346, Cfg9346_Lock);
41084 +                       }
41085                 }
41086         } else {
41087                 DPRINTK("Old chip wakeup\n");
41088 @@ -971,6 +965,7 @@
41089         dev->get_stats = rtl8139_get_stats;
41090         dev->set_multicast_list = rtl8139_set_rx_mode;
41091         dev->do_ioctl = netdev_ioctl;
41092 +       dev->ethtool_ops = &rtl8139_ethtool_ops;
41093         dev->tx_timeout = rtl8139_tx_timeout;
41094         dev->watchdog_timeo = TX_TIMEOUT;
41095  
41096 @@ -1318,8 +1313,6 @@
41097  
41098         tp->mii.full_duplex = tp->mii.force_media;
41099         tp->tx_flag = (TX_FIFO_THRESH << 11) & 0x003f0000;
41100 -       tp->twistie = (tp->chipset == CH_8139_K) ? 1 : 0;
41101 -       tp->time_to_die = 0;
41102  
41103         rtl8139_init_ring (dev);
41104         rtl8139_hw_start (dev);
41105 @@ -1330,32 +1323,18 @@
41106                         dev->irq, RTL_R8 (MediaStatus),
41107                         tp->mii.full_duplex ? "full" : "half");
41108  
41109 -       tp->thr_pid = kernel_thread (rtl8139_thread, dev, CLONE_FS | CLONE_FILES);
41110 -       if (tp->thr_pid < 0)
41111 -               printk (KERN_WARNING "%s: unable to start kernel thread\n",
41112 -                       dev->name);
41113 +       rtl8139_start_thread(dev);
41114  
41115         return 0;
41116  }
41117  
41118  
41119 -static void rtl_check_media (struct net_device *dev)
41120 +static void rtl_check_media (struct net_device *dev, unsigned int init_media)
41121  {
41122         struct rtl8139_private *tp = dev->priv;
41123  
41124         if (tp->phys[0] >= 0) {
41125 -               u16 mii_lpa = mdio_read(dev, tp->phys[0], MII_LPA);
41126 -               if (mii_lpa == 0xffff)
41127 -                       ;                                       /* Not there */
41128 -               else if ((mii_lpa & LPA_100FULL) == LPA_100FULL
41129 -                                || (mii_lpa & 0x00C0) == LPA_10FULL)
41130 -                       tp->mii.full_duplex = 1;
41131 -
41132 -               printk (KERN_INFO"%s: Setting %s%s-duplex based on"
41133 -                               " auto-negotiated partner ability %4.4x.\n",
41134 -                       dev->name, mii_lpa == 0 ? "" :
41135 -                               (mii_lpa & 0x0180) ? "100mbps " : "10mbps ",
41136 -                       tp->mii.full_duplex ? "full" : "half", mii_lpa);
41137 +               mii_check_media(&tp->mii, 1, init_media);
41138         }
41139  }
41140  
41141 @@ -1390,7 +1369,7 @@
41142  
41143         tp->cur_rx = 0;
41144  
41145 -       rtl_check_media (dev);
41146 +       rtl_check_media (dev, 1);
41147  
41148         if (tp->chipset >= CH_8139B) {
41149                 /* Disable magic packet scanning, which is enabled
41150 @@ -1452,6 +1431,19 @@
41151  static inline void rtl8139_tune_twister (struct net_device *dev,
41152                                   struct rtl8139_private *tp) {}
41153  #else
41154 +enum TwisterParamVals {
41155 +       PARA78_default  = 0x78fa8388,
41156 +       PARA7c_default  = 0xcb38de43,   /* param[0][3] */
41157 +       PARA7c_xxx      = 0xcb38de43,
41158 +};
41159 +
41160 +static const unsigned long param[4][4] = {
41161 +       {0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43},
41162 +       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
41163 +       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
41164 +       {0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83}
41165 +};
41166 +
41167  static void rtl8139_tune_twister (struct net_device *dev,
41168                                   struct rtl8139_private *tp)
41169  {
41170 @@ -1538,7 +1530,6 @@
41171  }
41172  #endif /* CONFIG_8139TOO_TUNE_TWISTER */
41173  
41174 -
41175  static inline void rtl8139_thread_iter (struct net_device *dev,
41176                                  struct rtl8139_private *tp,
41177                                  void *ioaddr)
41178 @@ -1585,7 +1576,6 @@
41179                  RTL_R8 (Config1));
41180  }
41181  
41182 -
41183  static int rtl8139_thread (void *data)
41184  {
41185         struct net_device *dev = data;
41186 @@ -1619,6 +1609,24 @@
41187         complete_and_exit (&tp->thr_exited, 0);
41188  }
41189  
41190 +static inline void rtl8139_start_thread(struct net_device *dev)
41191 +{
41192 +       struct rtl8139_private *tp = dev->priv;
41193 +
41194 +       tp->thr_pid = -1;
41195 +       tp->twistie = 0;
41196 +       tp->time_to_die = 0;
41197 +       if (tp->chipset == CH_8139_K)
41198 +               tp->twistie = 1;
41199 +       else if (tp->drv_flags & HAS_LNK_CHNG)
41200 +               return;
41201 +
41202 +       tp->thr_pid = kernel_thread(rtl8139_thread, dev, CLONE_FS|CLONE_FILES);
41203 +       if (tp->thr_pid < 0) {
41204 +               printk (KERN_WARNING "%s: unable to start kernel thread\n",
41205 +                       dev->name);
41206 +       }
41207 +}
41208  
41209  static void rtl8139_tx_clear (struct rtl8139_private *tp)
41210  {
41211 @@ -1999,18 +2007,7 @@
41212  
41213         if ((status & RxUnderrun) && link_changed &&
41214             (tp->drv_flags & HAS_LNK_CHNG)) {
41215 -               /* Really link-change on new chips. */
41216 -               int lpar = RTL_R16 (NWayLPAR);
41217 -               int duplex = (lpar & LPA_100FULL) || (lpar & 0x01C0) == 0x0040
41218 -                               || tp->mii.force_media;
41219 -               if (tp->mii.full_duplex != duplex) {
41220 -                       tp->mii.full_duplex = duplex;
41221 -#if 0
41222 -                       RTL_W8 (Cfg9346, Cfg9346_Unlock);
41223 -                       RTL_W8 (Config1, tp->mii.full_duplex ? 0x60 : 0x20);
41224 -                       RTL_W8 (Cfg9346, Cfg9346_Lock);
41225 -#endif
41226 -               }
41227 +               rtl_check_media(dev, 0);
41228                 status &= ~RxUnderrun;
41229         }
41230  
41231 @@ -2173,11 +2170,12 @@
41232  /* Get the ethtool Wake-on-LAN settings.  Assumes that wol points to
41233     kernel memory, *wol has been initialized as {ETHTOOL_GWOL}, and
41234     other threads or interrupts aren't messing with the 8139.  */
41235 -static void netdev_get_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
41236 +static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
41237  {
41238         struct rtl8139_private *np = dev->priv;
41239         void *ioaddr = np->mmio_addr;
41240  
41241 +       spin_lock_irq(&np->lock);
41242         if (rtl_chip_info[np->chipset].flags & HasLWake) {
41243                 u8 cfg3 = RTL_R8 (Config3);
41244                 u8 cfg5 = RTL_R8 (Config5);
41245 @@ -2199,14 +2197,14 @@
41246                 if (cfg5 & Cfg5_BWF)
41247                         wol->wolopts |= WAKE_BCAST;
41248         }
41249 +       spin_unlock_irq(&np->lock);
41250  }
41251  
41252  
41253  /* Set the ethtool Wake-on-LAN settings.  Return 0 or -errno.  Assumes
41254     that wol points to kernel memory and other threads or interrupts
41255     aren't messing with the 8139.  */
41256 -static int netdev_set_wol (struct net_device *dev,
41257 -                          const struct ethtool_wolinfo *wol)
41258 +static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
41259  {
41260         struct rtl8139_private *np = dev->priv;
41261         void *ioaddr = np->mmio_addr;
41262 @@ -2220,6 +2218,7 @@
41263         if (wol->wolopts & ~support)
41264                 return -EINVAL;
41265  
41266 +       spin_lock_irq(&np->lock);
41267         cfg3 = RTL_R8 (Config3) & ~(Cfg3_LinkUp | Cfg3_Magic);
41268         if (wol->wolopts & WAKE_PHY)
41269                 cfg3 |= Cfg3_LinkUp;
41270 @@ -2240,213 +2239,120 @@
41271         if (wol->wolopts & WAKE_BCAST)
41272                 cfg5 |= Cfg5_BWF;
41273         RTL_W8 (Config5, cfg5); /* need not unlock via Cfg9346 */
41274 +       spin_unlock_irq(&np->lock);
41275  
41276         return 0;
41277  }
41278  
41279 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
41280 +static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
41281  {
41282         struct rtl8139_private *np = dev->priv;
41283 -       u32 ethcmd;
41284 -
41285 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
41286 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
41287 +       strcpy(info->driver, DRV_NAME);
41288 +       strcpy(info->version, DRV_VERSION);
41289 +       strcpy(info->bus_info, pci_name(np->pci_dev));
41290 +       info->regdump_len = np->regs_len;
41291 +}
41292  
41293 -       if (get_user(ethcmd, (u32 *)useraddr))
41294 -               return -EFAULT;
41295 +static int rtl8139_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
41296 +{
41297 +       struct rtl8139_private *np = dev->priv;
41298 +       spin_lock_irq(&np->lock);
41299 +       mii_ethtool_gset(&np->mii, cmd);
41300 +       spin_unlock_irq(&np->lock);
41301 +       return 0;
41302 +}
41303  
41304 -       switch (ethcmd) {
41305 -
41306 -       case ETHTOOL_GDRVINFO: {
41307 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
41308 -               strcpy (info.driver, DRV_NAME);
41309 -               strcpy (info.version, DRV_VERSION);
41310 -               strcpy (info.bus_info, pci_name(np->pci_dev));
41311 -               info.regdump_len = np->regs_len;
41312 -               if (copy_to_user (useraddr, &info, sizeof (info)))
41313 -                       return -EFAULT;
41314 -               return 0;
41315 -       }
41316 +static int rtl8139_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
41317 +{
41318 +       struct rtl8139_private *np = dev->priv;
41319 +       int rc;
41320 +       spin_lock_irq(&np->lock);
41321 +       rc = mii_ethtool_sset(&np->mii, cmd);
41322 +       spin_unlock_irq(&np->lock);
41323 +       return rc;
41324 +}
41325  
41326 -       /* get settings */
41327 -       case ETHTOOL_GSET: {
41328 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
41329 -               spin_lock_irq(&np->lock);
41330 -               mii_ethtool_gset(&np->mii, &ecmd);
41331 -               spin_unlock_irq(&np->lock);
41332 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
41333 -                       return -EFAULT;
41334 -               return 0;
41335 -       }
41336 -       /* set settings */
41337 -       case ETHTOOL_SSET: {
41338 -               int r;
41339 -               struct ethtool_cmd ecmd;
41340 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
41341 -                       return -EFAULT;
41342 -               spin_lock_irq(&np->lock);
41343 -               r = mii_ethtool_sset(&np->mii, &ecmd);
41344 -               spin_unlock_irq(&np->lock);
41345 -               return r;
41346 -       }
41347 -       /* restart autonegotiation */
41348 -       case ETHTOOL_NWAY_RST: {
41349 -               return mii_nway_restart(&np->mii);
41350 -       }
41351 -       /* get link status */
41352 -       case ETHTOOL_GLINK: {
41353 -               struct ethtool_value edata = {ETHTOOL_GLINK};
41354 -               edata.data = mii_link_ok(&np->mii);
41355 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
41356 -                       return -EFAULT;
41357 -               return 0;
41358 -       }
41359 +static int rtl8139_nway_reset(struct net_device *dev)
41360 +{
41361 +       struct rtl8139_private *np = dev->priv;
41362 +       return mii_nway_restart(&np->mii);
41363 +}
41364  
41365 -       /* get message-level */
41366 -       case ETHTOOL_GMSGLVL: {
41367 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
41368 -               edata.data = debug;
41369 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
41370 -                       return -EFAULT;
41371 -               return 0;
41372 -       }
41373 -       /* set message-level */
41374 -       case ETHTOOL_SMSGLVL: {
41375 -               struct ethtool_value edata;
41376 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
41377 -                       return -EFAULT;
41378 -               debug = edata.data;
41379 -               return 0;
41380 -       }
41381 +static u32 rtl8139_get_link(struct net_device *dev)
41382 +{
41383 +       struct rtl8139_private *np = dev->priv;
41384 +       return mii_link_ok(&np->mii);
41385 +}
41386  
41387 -       case ETHTOOL_GWOL:
41388 -               {
41389 -                       struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
41390 -                       spin_lock_irq (&np->lock);
41391 -                       netdev_get_wol (dev, &wol);
41392 -                       spin_unlock_irq (&np->lock);
41393 -                       if (copy_to_user (useraddr, &wol, sizeof (wol)))
41394 -                               return -EFAULT;
41395 -                       return 0;
41396 -               }
41397 +static u32 rtl8139_get_msglevel(struct net_device *dev)
41398 +{
41399 +       return debug;
41400 +}
41401  
41402 -       case ETHTOOL_SWOL:
41403 -               {
41404 -                       struct ethtool_wolinfo wol;
41405 -                       int rc;
41406 -                       if (copy_from_user (&wol, useraddr, sizeof (wol)))
41407 -                               return -EFAULT;
41408 -                       spin_lock_irq (&np->lock);
41409 -                       rc = netdev_set_wol (dev, &wol);
41410 -                       spin_unlock_irq (&np->lock);
41411 -                       return rc;
41412 -               }
41413 +static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
41414 +{
41415 +       debug = datum;
41416 +}
41417  
41418  /* TODO: we are too slack to do reg dumping for pio, for now */
41419 -#ifndef CONFIG_8139TOO_PIO
41420 -       /* NIC register dump */
41421 -       case ETHTOOL_GREGS: {
41422 -                struct ethtool_regs regs;
41423 -               unsigned int regs_len = np->regs_len;
41424 -                u8 *regbuf = kmalloc(regs_len, GFP_KERNEL);
41425 -                int rc;
41426 -
41427 -               if (!regbuf)
41428 -                       return -ENOMEM;
41429 -               memset(regbuf, 0, regs_len);
41430 -
41431 -                rc = copy_from_user(&regs, useraddr, sizeof(regs));
41432 -               if (rc) {
41433 -                       rc = -EFAULT;
41434 -                       goto err_out_gregs;
41435 -               }
41436 -                
41437 -                if (regs.len > regs_len)
41438 -                        regs.len = regs_len;
41439 -                if (regs.len < regs_len) {
41440 -                       rc = -EINVAL;
41441 -                       goto err_out_gregs;
41442 -               }
41443 -
41444 -                regs.version = RTL_REGS_VER;
41445 -                rc = copy_to_user(useraddr, &regs, sizeof(regs));
41446 -               if (rc) {
41447 -                       rc = -EFAULT;
41448 -                       goto err_out_gregs;
41449 -               }
41450 -
41451 -                useraddr += offsetof(struct ethtool_regs, data);
41452 -
41453 -                spin_lock_irq(&np->lock);
41454 -                memcpy_fromio(regbuf, np->mmio_addr, regs_len);
41455 -                spin_unlock_irq(&np->lock);
41456 -
41457 -                if (copy_to_user(useraddr, regbuf, regs_len))
41458 -                        rc = -EFAULT;
41459 -
41460 -err_out_gregs:
41461 -               kfree(regbuf);
41462 -               return rc;
41463 -       }
41464 -#endif /* CONFIG_8139TOO_PIO */
41465 -
41466 -       /* get string list(s) */
41467 -       case ETHTOOL_GSTRINGS: {
41468 -               struct ethtool_gstrings estr = { ETHTOOL_GSTRINGS };
41469 -
41470 -               if (copy_from_user(&estr, useraddr, sizeof(estr)))
41471 -                       return -EFAULT;
41472 -               if (estr.string_set != ETH_SS_STATS)
41473 -                       return -EINVAL;
41474 -
41475 -               estr.len = RTL_NUM_STATS;
41476 -               if (copy_to_user(useraddr, &estr, sizeof(estr)))
41477 -                       return -EFAULT;
41478 -               if (copy_to_user(useraddr + sizeof(estr),
41479 -                                &ethtool_stats_keys,
41480 -                                sizeof(ethtool_stats_keys)))
41481 -                       return -EFAULT;
41482 -               return 0;
41483 -       }
41484 +#ifdef CONFIG_8139TOO_PIO
41485 +#define rtl8139_get_regs_len   NULL
41486 +#define rtl8139_get_regs       NULL
41487 +#else
41488 +static int rtl8139_get_regs_len(struct net_device *dev)
41489 +{
41490 +       struct rtl8139_private *np = dev->priv;
41491 +       return np->regs_len;
41492 +}
41493  
41494 -       /* get NIC-specific statistics */
41495 -       case ETHTOOL_GSTATS: {
41496 -               struct ethtool_stats estats = { ETHTOOL_GSTATS };
41497 -               u64 *tmp_stats;
41498 -               const unsigned int sz = sizeof(u64) * RTL_NUM_STATS;
41499 -               int i;
41500 -
41501 -               estats.n_stats = RTL_NUM_STATS;
41502 -               if (copy_to_user(useraddr, &estats, sizeof(estats)))
41503 -                       return -EFAULT;
41504 -
41505 -               tmp_stats = kmalloc(sz, GFP_KERNEL);
41506 -               if (!tmp_stats)
41507 -                       return -ENOMEM;
41508 -               memset(tmp_stats, 0, sz);
41509 -
41510 -               i = 0;
41511 -               tmp_stats[i++] = np->xstats.early_rx;
41512 -               tmp_stats[i++] = np->xstats.tx_buf_mapped;
41513 -               tmp_stats[i++] = np->xstats.tx_timeouts;
41514 -               tmp_stats[i++] = np->xstats.rx_lost_in_ring;
41515 -               if (i != RTL_NUM_STATS)
41516 -                       BUG();
41517 +static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
41518 +{
41519 +       struct rtl8139_private *np = dev->priv;
41520  
41521 -               i = copy_to_user(useraddr + sizeof(estats), tmp_stats, sz);
41522 -               kfree(tmp_stats);
41523 +       regs->version = RTL_REGS_VER;
41524  
41525 -               if (i)
41526 -                       return -EFAULT;
41527 -               return 0;
41528 -       }
41529 -       default:
41530 -               break;
41531 -       }
41532 +       spin_lock_irq(&np->lock);
41533 +       memcpy_fromio(regbuf, np->mmio_addr, regs->len);
41534 +       spin_unlock_irq(&np->lock);
41535 +}
41536 +#endif /* CONFIG_8139TOO_MMIO */
41537  
41538 -       return -EOPNOTSUPP;
41539 +static int rtl8139_get_stats_count(struct net_device *dev)
41540 +{
41541 +       return RTL_NUM_STATS;
41542  }
41543  
41544 +static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
41545 +{
41546 +       struct rtl8139_private *np = dev->priv;
41547 +
41548 +       data[0] = np->xstats.early_rx;
41549 +       data[1] = np->xstats.tx_buf_mapped;
41550 +       data[2] = np->xstats.tx_timeouts;
41551 +       data[3] = np->xstats.rx_lost_in_ring;
41552 +}
41553 +
41554 +static void rtl8139_get_strings(struct net_device *dev, u32 stringset, u8 *data)
41555 +{
41556 +       memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
41557 +}
41558 +
41559 +static struct ethtool_ops rtl8139_ethtool_ops = {
41560 +       .get_drvinfo            = rtl8139_get_drvinfo,
41561 +       .get_settings           = rtl8139_get_settings,
41562 +       .set_settings           = rtl8139_set_settings,
41563 +       .get_regs_len           = rtl8139_get_regs_len,
41564 +       .get_regs               = rtl8139_get_regs,
41565 +       .nway_reset             = rtl8139_nway_reset,
41566 +       .get_link               = rtl8139_get_link,
41567 +       .get_msglevel           = rtl8139_get_msglevel,
41568 +       .set_msglevel           = rtl8139_set_msglevel,
41569 +       .get_wol                = rtl8139_get_wol,
41570 +       .set_wol                = rtl8139_set_wol,
41571 +       .get_strings            = rtl8139_get_strings,
41572 +       .get_stats_count        = rtl8139_get_stats_count,
41573 +       .get_ethtool_stats      = rtl8139_get_ethtool_stats,
41574 +};
41575  
41576  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
41577  {
41578 @@ -2457,14 +2363,9 @@
41579         if (!netif_running(dev))
41580                 return -EINVAL;
41581  
41582 -       if (cmd == SIOCETHTOOL)
41583 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
41584 -
41585 -       else {
41586 -               spin_lock_irq(&np->lock);
41587 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
41588 -               spin_unlock_irq(&np->lock);
41589 -       }
41590 +       spin_lock_irq(&np->lock);
41591 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
41592 +       spin_unlock_irq(&np->lock);
41593  
41594         return rc;
41595  }
41596 diff -Nru a/drivers/net/8390.c b/drivers/net/8390.c
41597 --- a/drivers/net/8390.c        Sun Apr 20 21:26:41 2003
41598 +++ b/drivers/net/8390.c        Mon Sep  1 09:50:20 2003
41599 @@ -997,6 +997,11 @@
41600         spin_unlock_irqrestore(&ei_local->page_lock, flags);
41601  }      
41602  
41603 +static inline void ei_device_init(struct ei_device *ei_local)
41604 +{
41605 +       spin_lock_init(&ei_local->page_lock);
41606 +}
41607 +
41608  /**
41609   * ethdev_init - init rest of 8390 device struct
41610   * @dev: network device structure to init
41611 @@ -1012,14 +1017,11 @@
41612      
41613         if (dev->priv == NULL) 
41614         {
41615 -               struct ei_device *ei_local;
41616 -               
41617                 dev->priv = kmalloc(sizeof(struct ei_device), GFP_KERNEL);
41618                 if (dev->priv == NULL)
41619                         return -ENOMEM;
41620                 memset(dev->priv, 0, sizeof(struct ei_device));
41621 -               ei_local = (struct ei_device *)dev->priv;
41622 -               spin_lock_init(&ei_local->page_lock);
41623 +               ei_device_init(dev->priv);
41624         }
41625      
41626         dev->hard_start_xmit = &ei_start_xmit;
41627 @@ -1030,6 +1032,29 @@
41628          
41629         return 0;
41630  }
41631 +
41632 +/* wrapper to make alloc_netdev happy; probably should just cast... */
41633 +static void __ethdev_init(struct net_device *dev)
41634 +{
41635 +       ethdev_init(dev);
41636 +}
41637 +
41638 +/**
41639 + * alloc_ei_netdev - alloc_etherdev counterpart for 8390
41640 + *
41641 + * Allocate 8390-specific net_device.
41642 + */
41643 +struct net_device *alloc_ei_netdev(void)
41644 +{
41645 +       struct net_device *dev;
41646 +       
41647 +       dev = alloc_netdev(sizeof(struct ei_device), "eth%d", __ethdev_init);
41648 +       if (dev)
41649 +               ei_device_init(dev->priv);
41650 +
41651 +       return dev;
41652 +}
41653 +
41654  \f
41655  
41656  
41657 @@ -1133,6 +1158,7 @@
41658  EXPORT_SYMBOL(ei_tx_timeout);
41659  EXPORT_SYMBOL(ethdev_init);
41660  EXPORT_SYMBOL(NS8390_init);
41661 +EXPORT_SYMBOL(alloc_ei_netdev);
41662  
41663  #if defined(MODULE)
41664  
41665 diff -Nru a/drivers/net/8390.h b/drivers/net/8390.h
41666 --- a/drivers/net/8390.h        Sat Jun 28 10:57:01 2003
41667 +++ b/drivers/net/8390.h        Mon Sep  1 09:50:20 2003
41668 @@ -44,6 +44,7 @@
41669  extern int ei_open(struct net_device *dev);
41670  extern int ei_close(struct net_device *dev);
41671  extern irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs *regs);
41672 +extern struct net_device *alloc_ei_netdev(void);
41673  
41674  /* You have one of these per-board */
41675  struct ei_device {
41676 diff -Nru a/drivers/net/Kconfig b/drivers/net/Kconfig
41677 --- a/drivers/net/Kconfig       Mon Aug 18 20:59:59 2003
41678 +++ b/drivers/net/Kconfig       Tue Sep  2 15:05:18 2003
41679 @@ -132,8 +132,8 @@
41680           If you don't know what to use this for, you don't need it.
41681  
41682  config ETHERTAP
41683 -       tristate "Ethertap network tap (OBSOLETE)"
41684 -       depends on NETDEVICES && EXPERIMENTAL
41685 +       tristate "Ethertap network tap"
41686 +       depends on NETDEVICES && EXPERIMENTAL && NETLINK_DEV
41687         ---help---
41688           If you say Y here (and have said Y to "Kernel/User network link
41689           driver", above) and create a character special file /dev/tap0 with
41690 @@ -502,7 +502,7 @@
41691  
41692  config SGI_IOC3_ETH
41693         bool "SGI IOC3 Ethernet"
41694 -       depends on NET_ETHERNET && (IA64_SGI_SN1 || SGI_IP27)
41695 +       depends on NET_ETHERNET && SGI_IP27
41696         help
41697           If you have a network (Ethernet) card of this type, say Y and read
41698           the Ethernet-HOWTO, available from
41699 @@ -704,7 +704,7 @@
41700  
41701  config ELMC_II
41702         tristate "3c527 \"EtherLink/MC 32\" support (EXPERIMENTAL)"
41703 -       depends on NET_VENDOR_3COM && MCA && EXPERIMENTAL
41704 +       depends on NET_VENDOR_3COM && MCA && EXPERIMENTAL && BROKEN_ON_SMP
41705         help
41706           If you have a network (Ethernet) card of this type, say Y and read
41707           the Ethernet-HOWTO, available from
41708 @@ -882,7 +882,7 @@
41709  
41710  config NI5010
41711         tristate "NI5010 support (EXPERIMENTAL)"
41712 -       depends on NET_VENDOR_RACAL && ISA && EXPERIMENTAL
41713 +       depends on NET_VENDOR_RACAL && ISA && EXPERIMENTAL && BROKEN_ON_SMP
41714         ---help---
41715           If you have a network (Ethernet) card of this type, say Y and read
41716           the Ethernet-HOWTO, available from
41717 @@ -1221,7 +1221,7 @@
41718  
41719  config SKMC
41720         tristate "SKnet MCA support"
41721 -       depends on NET_ETHERNET && MCA
41722 +       depends on NET_ETHERNET && MCA && BROKEN
41723         ---help---
41724           These are Micro Channel Ethernet adapters. You need to say Y to "MCA
41725           support" in order to use this driver.  Supported cards are the SKnet
41726 @@ -2670,7 +2670,7 @@
41727  
41728  config IPHASE5526
41729         tristate "Interphase 5526 Tachyon chipset based adapter support"
41730 -       depends on NET_FC && SCSI && PCI
41731 +       depends on NET_FC && SCSI && PCI && BROKEN
41732         help
41733           Say Y here if you have a Fibre Channel adaptor of this kind.
41734  
41735 diff -Nru a/drivers/net/Makefile.lib b/drivers/net/Makefile.lib
41736 --- a/drivers/net/Makefile.lib  Sun Aug 17 09:55:22 2003
41737 +++ b/drivers/net/Makefile.lib  Wed Sep  3 10:43:37 2003
41738 @@ -5,6 +5,7 @@
41739  obj-$(CONFIG_ARM_AM79C961A)    += crc32.o
41740  obj-$(CONFIG_AT1700)           += crc32.o
41741  obj-$(CONFIG_ATP)              += crc32.o
41742 +obj-$(CONFIG_BMAC)             += crc32.o
41743  obj-$(CONFIG_DE2104X)          += crc32.o
41744  obj-$(CONFIG_DE4X5)            += crc32.o
41745  obj-$(CONFIG_DECLANCE)         += crc32.o
41746 diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
41747 --- a/drivers/net/Space.c       Wed Jun 25 14:00:07 2003
41748 +++ b/drivers/net/Space.c       Wed Sep  3 10:39:23 2003
41749 @@ -62,7 +62,6 @@
41750  extern int depca_probe(struct net_device *);
41751  extern int i82596_probe(struct net_device *);
41752  extern int ewrk3_probe(struct net_device *);
41753 -extern int de4x5_probe(struct net_device *);
41754  extern int el1_probe(struct net_device *);
41755  extern int wavelan_probe(struct net_device *);
41756  extern int arlan_probe(struct net_device *);
41757 @@ -89,7 +88,6 @@
41758  extern int bionet_probe(struct net_device *);
41759  extern int pamsnet_probe(struct net_device *);
41760  extern int cs89x0_probe(struct net_device *dev);
41761 -extern int ethertap_probe(struct net_device *dev);
41762  extern int hplance_probe(struct net_device *dev);
41763  extern int bagetlance_probe(struct net_device *);
41764  extern int mvme147lance_probe(struct net_device *dev);
41765 @@ -153,12 +151,9 @@
41766   * This is a bit of an artificial separation as there are PCI drivers
41767   * that also probe for EISA cards (in the PCI group) and there are ISA
41768   * drivers that probe for EISA cards (in the ISA group).  These are the
41769 - * EISA only driver probes, and also the legacy PCI probes
41770 + * legacy EISA only driver probes, and also the legacy PCI probes
41771   */
41772  static struct devprobe eisa_probes[] __initdata = {
41773 -#ifdef CONFIG_DE4X5             /* DEC DE425, DE434, DE435 adapters */
41774 -       {de4x5_probe, 0},
41775 -#endif
41776  #ifdef CONFIG_ULTRA32 
41777         {ultra32_probe, 0},     
41778  #endif
41779 @@ -386,17 +381,6 @@
41780                 return 0;
41781         return -ENODEV;
41782  }
41783 -
41784 -#ifdef CONFIG_ETHERTAP
41785 -static struct net_device tap0_dev = {
41786 -       .name           = "tap0",
41787 -       .base_addr      = NETLINK_TAPBASE,
41788 -       .next           = NEXT_DEV,
41789 -       .init           = ethertap_probe,
41790 -};
41791 -#undef NEXT_DEV
41792 -#define NEXT_DEV       (&tap0_dev)
41793 -#endif
41794  
41795  #ifdef CONFIG_SDLA
41796  extern int sdla_init(struct net_device *);
41797 diff -Nru a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
41798 --- a/drivers/net/arcnet/arcnet.c       Mon Jul 21 05:31:03 2003
41799 +++ b/drivers/net/arcnet/arcnet.c       Sun Aug 31 16:14:40 2003
41800 @@ -135,7 +135,7 @@
41801                 arc_proto_map[count] = arc_proto_default;
41802  
41803         BUGLVL(D_DURING)
41804 -           printk("arcnet: struct sizes: %d %d %d %d %d\n",
41805 +           printk("arcnet: struct sizes: %Zd %Zd %Zd %Zd %Zd\n",
41806                  sizeof(struct arc_hardware), sizeof(struct arc_rfc1201),
41807                 sizeof(struct arc_rfc1051), sizeof(struct arc_eth_encap),
41808                    sizeof(struct archdr));
41809 diff -Nru a/drivers/net/arm/ether00.c b/drivers/net/arm/ether00.c
41810 --- a/drivers/net/arm/ether00.c Tue Aug 19 20:53:15 2003
41811 +++ b/drivers/net/arm/ether00.c Sun Aug 31 16:14:08 2003
41812 @@ -991,9 +991,9 @@
41813  }
41814  
41815  static struct pld_hotswap_ops ether00_pldhs_ops={
41816 -       name: ETHER00_NAME,
41817 -       add_device: ether00_add_device,
41818 -       remove_devices: ether00_remove_devices,
41819 +       .name = ETHER00_NAME,
41820 +       .add_device = ether00_add_device,
41821 +       .remove_devices = ether00_remove_devices,
41822  };
41823  
41824  
41825 diff -Nru a/drivers/net/dummy.c b/drivers/net/dummy.c
41826 --- a/drivers/net/dummy.c       Tue Aug 19 20:53:15 2003
41827 +++ b/drivers/net/dummy.c       Sun Aug 24 04:54:46 2003
41828 @@ -28,8 +28,6 @@
41829                         Alan Cox, 30th May 1994
41830  */
41831  
41832 -/* To have statistics (just packets sent) define this */
41833 -
41834  #include <linux/config.h>
41835  #include <linux/module.h>
41836  #include <linux/kernel.h>
41837 diff -Nru a/drivers/net/epic100.c b/drivers/net/epic100.c
41838 --- a/drivers/net/epic100.c     Tue Aug 19 20:53:15 2003
41839 +++ b/drivers/net/epic100.c     Mon Sep  1 14:05:11 2003
41840 @@ -362,6 +362,7 @@
41841  static int epic_rx(struct net_device *dev);
41842  static irqreturn_t epic_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
41843  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
41844 +static struct ethtool_ops netdev_ethtool_ops;
41845  static int epic_close(struct net_device *dev);
41846  static struct net_device_stats *epic_get_stats(struct net_device *dev);
41847  static void set_rx_mode(struct net_device *dev);
41848 @@ -539,6 +540,7 @@
41849         dev->get_stats = &epic_get_stats;
41850         dev->set_multicast_list = &set_rx_mode;
41851         dev->do_ioctl = &netdev_ioctl;
41852 +       dev->ethtool_ops = &netdev_ethtool_ops;
41853         dev->watchdog_timeo = TX_TIMEOUT;
41854         dev->tx_timeout = &epic_tx_timeout;
41855  
41856 @@ -1361,82 +1363,73 @@
41857         return;
41858  }
41859  
41860 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
41861 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
41862  {
41863         struct epic_private *np = dev->priv;
41864 -       u32 ethcmd;
41865  
41866 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
41867 -               return -EFAULT;
41868 +       strcpy (info->driver, DRV_NAME);
41869 +       strcpy (info->version, DRV_VERSION);
41870 +       strcpy (info->bus_info, pci_name(np->pci_dev));
41871 +}
41872  
41873 -       switch (ethcmd) {
41874 -       case ETHTOOL_GDRVINFO: {
41875 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
41876 -               strcpy (info.driver, DRV_NAME);
41877 -               strcpy (info.version, DRV_VERSION);
41878 -               strcpy (info.bus_info, pci_name(np->pci_dev));
41879 -               if (copy_to_user (useraddr, &info, sizeof (info)))
41880 -                       return -EFAULT;
41881 -               return 0;
41882 -       }
41883 -
41884 -       /* get settings */
41885 -       case ETHTOOL_GSET: {
41886 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
41887 -               spin_lock_irq(&np->lock);
41888 -               mii_ethtool_gset(&np->mii, &ecmd);
41889 -               spin_unlock_irq(&np->lock);
41890 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
41891 -                       return -EFAULT;
41892 -               return 0;
41893 -       }
41894 -       /* set settings */
41895 -       case ETHTOOL_SSET: {
41896 -               int r;
41897 -               struct ethtool_cmd ecmd;
41898 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
41899 -                       return -EFAULT;
41900 -               spin_lock_irq(&np->lock);
41901 -               r = mii_ethtool_sset(&np->mii, &ecmd);
41902 -               spin_unlock_irq(&np->lock);
41903 -               return r;
41904 -       }
41905 -       /* restart autonegotiation */
41906 -       case ETHTOOL_NWAY_RST: {
41907 -               return mii_nway_restart(&np->mii);
41908 -       }
41909 -       /* get link status */
41910 -       case ETHTOOL_GLINK: {
41911 -               struct ethtool_value edata = {ETHTOOL_GLINK};
41912 -               edata.data = mii_link_ok(&np->mii);
41913 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
41914 -                       return -EFAULT;
41915 -               return 0;
41916 -       }
41917 -
41918 -       /* get message-level */
41919 -       case ETHTOOL_GMSGLVL: {
41920 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
41921 -               edata.data = debug;
41922 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
41923 -                       return -EFAULT;
41924 -               return 0;
41925 -       }
41926 -       /* set message-level */
41927 -       case ETHTOOL_SMSGLVL: {
41928 -               struct ethtool_value edata;
41929 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
41930 -                       return -EFAULT;
41931 -               debug = edata.data;
41932 -               return 0;
41933 -       }
41934 -       default:
41935 -               break;
41936 -       }
41937 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
41938 +{
41939 +       struct epic_private *np = dev->priv;
41940 +       int rc;
41941 +
41942 +       spin_lock_irq(&np->lock);
41943 +       rc = mii_ethtool_gset(&np->mii, cmd);
41944 +       spin_unlock_irq(&np->lock);
41945 +
41946 +       return rc;
41947 +}
41948 +
41949 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
41950 +{
41951 +       struct epic_private *np = dev->priv;
41952 +       int rc;
41953 +
41954 +       spin_lock_irq(&np->lock);
41955 +       rc = mii_ethtool_sset(&np->mii, cmd);
41956 +       spin_unlock_irq(&np->lock);
41957 +
41958 +       return rc;
41959 +}
41960 +
41961 +static int netdev_nway_reset(struct net_device *dev)
41962 +{
41963 +       struct epic_private *np = dev->priv;
41964 +       return mii_nway_restart(&np->mii);
41965 +}
41966  
41967 -       return -EOPNOTSUPP;
41968 +static u32 netdev_get_link(struct net_device *dev)
41969 +{
41970 +       struct epic_private *np = dev->priv;
41971 +       return mii_link_ok(&np->mii);
41972  }
41973  
41974 +static u32 netdev_get_msglevel(struct net_device *dev)
41975 +{
41976 +       return debug;
41977 +}
41978 +
41979 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
41980 +{
41981 +       debug = value;
41982 +}
41983 +
41984 +static struct ethtool_ops netdev_ethtool_ops = {
41985 +       .get_drvinfo            = netdev_get_drvinfo,
41986 +       .get_settings           = netdev_get_settings,
41987 +       .set_settings           = netdev_set_settings,
41988 +       .nway_reset             = netdev_nway_reset,
41989 +       .get_link               = netdev_get_link,
41990 +       .get_msglevel           = netdev_get_msglevel,
41991 +       .set_msglevel           = netdev_set_msglevel,
41992 +       .get_sg                 = ethtool_op_get_sg,
41993 +       .get_tx_csum            = ethtool_op_get_tx_csum,
41994 +};
41995 +
41996  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
41997  {
41998         struct epic_private *np = dev->priv;
41999 @@ -1450,16 +1443,10 @@
42000                 outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL);
42001         }
42002  
42003 -       /* ethtool commands */
42004 -       if (cmd == SIOCETHTOOL)
42005 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
42006 -
42007 -       /* all other ioctls (the SIOC[GS]MIIxxx ioctls) */
42008 -       else {
42009 -               spin_lock_irq(&np->lock);
42010 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
42011 -               spin_unlock_irq(&np->lock);
42012 -       }
42013 +       /* all non-ethtool ioctls (the SIOC[GS]MIIxxx ioctls) */
42014 +       spin_lock_irq(&np->lock);
42015 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
42016 +       spin_unlock_irq(&np->lock);
42017  
42018         /* power-down, if interface is down */
42019         if (! netif_running(dev)) {
42020 diff -Nru a/drivers/net/eth16i.c b/drivers/net/eth16i.c
42021 --- a/drivers/net/eth16i.c      Sun Apr 27 20:36:19 2003
42022 +++ b/drivers/net/eth16i.c      Sun Aug 31 06:34:16 2003
42023 @@ -1053,7 +1053,7 @@
42024         int ioaddr = dev->base_addr;
42025         int status = 0;
42026         ushort length = skb->len;
42027 -       unsigned char *buf = skb->data;
42028 +       unsigned char *buf;
42029         unsigned long flags;
42030  
42031         if (length < ETH_ZLEN) {
42032 @@ -1062,6 +1062,7 @@
42033                         return 0;
42034                 length = ETH_ZLEN;
42035         }
42036 +       buf = skb->data;
42037  
42038         netif_stop_queue(dev);
42039                 
42040 diff -Nru a/drivers/net/ethertap.c b/drivers/net/ethertap.c
42041 --- a/drivers/net/ethertap.c    Sat Jun  7 14:14:59 2003
42042 +++ b/drivers/net/ethertap.c    Tue Sep  2 13:28:19 2003
42043 @@ -33,7 +33,6 @@
42044   *     Index to functions.
42045   */
42046  
42047 -int        ethertap_probe(struct net_device *dev);
42048  static int  ethertap_open(struct net_device *dev);
42049  static int  ethertap_start_xmit(struct sk_buff *skb, struct net_device *dev);
42050  static int  ethertap_close(struct net_device *dev);
42051 @@ -45,7 +44,11 @@
42052  
42053  static int ethertap_debug;
42054  
42055 -static struct net_device *tap_map[32]; /* Returns the tap device for a given netlink */
42056 +static int max_taps = 1;
42057 +MODULE_PARM(max_taps, "i");
42058 +MODULE_PARM_DESC(max_taps,"Max number of ethernet tap devices");
42059 +
42060 +static struct net_device **tap_map;    /* Returns the tap device for a given netlink */
42061  
42062  /*
42063   *     Board-specific info in dev->priv.
42064 @@ -64,25 +67,29 @@
42065   *     To call this a probe is a bit misleading, however for real
42066   *     hardware it would have to check what was present.
42067   */
42068
42069 -int __init ethertap_probe(struct net_device *dev)
42070 +static int  __init ethertap_probe(int unit)
42071  {
42072 +       struct net_device *dev;
42073 +       int err = -ENOMEM;
42074 +
42075 +       dev = alloc_netdev(sizeof(struct net_local), "tap%d",
42076 +                          ether_setup);
42077 +
42078 +       if (!dev)
42079 +               goto out;
42080 +
42081         SET_MODULE_OWNER(dev);
42082  
42083 +       sprintf(dev->name, "tap%d", unit);
42084 +       dev->base_addr = unit + NETLINK_TAPBASE;
42085 +
42086 +       netdev_boot_setup_check(dev);
42087 +
42088         memcpy(dev->dev_addr, "\xFE\xFD\x00\x00\x00\x00", 6);
42089         if (dev->mem_start & 0xf)
42090                 ethertap_debug = dev->mem_start & 0x7;
42091  
42092         /*
42093 -        *      Initialize the device structure.
42094 -        */
42095 -
42096 -       dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
42097 -       if (dev->priv == NULL)
42098 -               return -ENOMEM;
42099 -       memset(dev->priv, 0, sizeof(struct net_local));
42100 -
42101 -       /*
42102          *      The tap specific entries in the device structure.
42103          */
42104  
42105 @@ -94,17 +101,19 @@
42106         dev->set_multicast_list = set_multicast_list;
42107  #endif
42108  
42109 -       /*
42110 -        *      Setup the generic properties
42111 -        */
42112 -
42113 -       ether_setup(dev);
42114 -
42115         dev->tx_queue_len = 0;
42116         dev->flags|=IFF_NOARP;
42117 -       tap_map[dev->base_addr]=dev;
42118  
42119 +       err = register_netdev(dev);
42120 +       if (err)
42121 +               goto out_free;
42122 +
42123 +       tap_map[unit]=dev;
42124         return 0;
42125 +out_free:
42126 +       free_netdev(dev);
42127 +out:
42128 +       return err;
42129  }
42130  
42131  /*
42132 @@ -116,11 +125,12 @@
42133         struct net_local *lp = (struct net_local*)dev->priv;
42134  
42135         if (ethertap_debug > 2)
42136 -               printk("%s: Doing ethertap_open()...", dev->name);
42137 +               printk(KERN_DEBUG "%s: Doing ethertap_open()...", dev->name);
42138  
42139         lp->nl = netlink_kernel_create(dev->base_addr, ethertap_rx);
42140         if (lp->nl == NULL)
42141                 return -ENOBUFS;
42142 +
42143         netif_start_queue(dev);
42144         return 0;
42145  }
42146 @@ -302,7 +312,7 @@
42147         }
42148  
42149         if (ethertap_debug > 3)
42150 -               printk("%s: ethertap_rx()\n", dev->name);
42151 +               printk(KERN_DEBUG "%s: ethertap_rx()\n", dev->name);
42152  
42153         while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL)
42154                 ethertap_rx_skb(skb, dev);
42155 @@ -314,7 +324,7 @@
42156         struct sock *sk = lp->nl;
42157  
42158         if (ethertap_debug > 2)
42159 -               printk("%s: Shutting down.\n", dev->name);
42160 +               printk(KERN_DEBUG "%s: Shutting down.\n", dev->name);
42161  
42162         netif_stop_queue(dev);
42163  
42164 @@ -332,45 +342,49 @@
42165         return &lp->stats;
42166  }
42167  
42168 -#ifdef MODULE
42169 -
42170 -static int unit;
42171 -MODULE_PARM(unit,"i");
42172 -MODULE_PARM_DESC(unit,"Ethertap device number");
42173  
42174 -static struct net_device dev_ethertap =
42175 +int __init ethertap_init(void)
42176  {
42177 -       .name           =       " ",
42178 -       .init           =        ethertap_probe
42179 -};
42180 +       int i, err = 0;
42181  
42182 -int init_module(void)
42183 -{
42184 -       dev_ethertap.base_addr=unit+NETLINK_TAPBASE;
42185 -       sprintf(dev_ethertap.name,"tap%d",unit);
42186 -       if (dev_get(dev_ethertap.name))
42187 -       {
42188 -               printk(KERN_INFO "%s already loaded.\n", dev_ethertap.name);
42189 -               return -EBUSY;
42190 -       }
42191 -       if (register_netdev(&dev_ethertap) != 0)
42192 -               return -EIO;
42193 -       return 0;
42194 -}
42195 -
42196 -void cleanup_module(void)
42197 -{
42198 -       tap_map[dev_ethertap.base_addr]=NULL;
42199 -       unregister_netdev(&dev_ethertap);
42200 +       /* netlink can only hande 16 entries unless modified */
42201 +       if (max_taps > MAX_LINKS - NETLINK_TAPBASE)
42202 +               return -E2BIG;
42203  
42204 -       /*
42205 -        *      Free up the private structure.
42206 -        */
42207 +       tap_map = kmalloc(sizeof(struct net_device *)*max_taps, GFP_KERNEL);
42208 +       if (!tap_map)
42209 +               return -ENOMEM;
42210  
42211 -       kfree(dev_ethertap.priv);
42212 -       dev_ethertap.priv = NULL;       /* gets re-allocated by ethertap_probe */
42213 +       for (i = 0; i < max_taps; i++) {
42214 +               err = ethertap_probe(i);
42215 +               if (err) {
42216 +                       while (--i > 0) {
42217 +                               unregister_netdev(tap_map[i]);
42218 +                               free_netdev(tap_map[i]);
42219 +                       }
42220 +                       break;
42221 +               }
42222 +       }
42223 +       if (err)
42224 +               kfree(tap_map);
42225 +       return err;
42226 +}
42227 +module_init(ethertap_init);
42228 +
42229 +void __exit ethertap_cleanup(void)
42230 +{
42231 +       int i;
42232 +
42233 +       for (i = 0; i < max_taps; i++) {
42234 +               struct net_device *dev = tap_map[i];
42235 +               if (dev) {
42236 +                       tap_map[i] = NULL;
42237 +                       unregister_netdev(dev);
42238 +                       free_netdev(dev);
42239 +               }
42240 +       }
42241 +       kfree(tap_map);
42242  }
42243 +module_exit(ethertap_cleanup);
42244  
42245 -#endif /* MODULE */
42246  MODULE_LICENSE("GPL");
42247 -
42248 diff -Nru a/drivers/net/fealnx.c b/drivers/net/fealnx.c
42249 --- a/drivers/net/fealnx.c      Tue Aug 19 20:53:16 2003
42250 +++ b/drivers/net/fealnx.c      Mon Sep  1 14:18:01 2003
42251 @@ -443,6 +443,7 @@
42252  static void set_rx_mode(struct net_device *dev);
42253  static struct net_device_stats *get_stats(struct net_device *dev);
42254  static int mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
42255 +static struct ethtool_ops netdev_ethtool_ops;
42256  static int netdev_close(struct net_device *dev);
42257  static void reset_rx_descriptors(struct net_device *dev);
42258  
42259 @@ -667,6 +668,7 @@
42260         dev->get_stats = &get_stats;
42261         dev->set_multicast_list = &set_rx_mode;
42262         dev->do_ioctl = &mii_ioctl;
42263 +       dev->ethtool_ops = &netdev_ethtool_ops;
42264         dev->tx_timeout = tx_timeout;
42265         dev->watchdog_timeo = TX_TIMEOUT;
42266         
42267 @@ -938,7 +940,7 @@
42268  // 89/9/1 modify,
42269  //   np->bcrvalue=0x38;
42270         np->bcrvalue = 0x10;
42271 -       np->cralue = 0xe00;     /* rx 128 burst length */
42272 +       np->crvalue = 0xe00;    /* rx 128 burst length */
42273  #warning Processor architecture undefined!
42274  #endif
42275  // 89/12/29 add,
42276 @@ -1760,82 +1762,72 @@
42277         writel(np->crvalue, ioaddr + TCRRCR);
42278  }
42279  
42280 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
42281 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
42282  {
42283         struct netdev_private *np = dev->priv;
42284 -       u32 ethcmd;
42285  
42286 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
42287 -               return -EFAULT;
42288 +       strcpy (info->driver, DRV_NAME);
42289 +       strcpy (info->version, DRV_VERSION);
42290 +       strcpy (info->bus_info, pci_name(np->pci_dev));
42291 +}
42292  
42293 -       switch (ethcmd) {
42294 -       case ETHTOOL_GDRVINFO: {
42295 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
42296 -               strcpy (info.driver, DRV_NAME);
42297 -               strcpy (info.version, DRV_VERSION);
42298 -               strcpy (info.bus_info, pci_name(np->pci_dev));
42299 -               if (copy_to_user (useraddr, &info, sizeof (info)))
42300 -                       return -EFAULT;
42301 -               return 0;
42302 -       }
42303 -
42304 -       /* get settings */
42305 -       case ETHTOOL_GSET: {
42306 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
42307 -               spin_lock_irq(&np->lock);
42308 -               mii_ethtool_gset(&np->mii, &ecmd);
42309 -               spin_unlock_irq(&np->lock);
42310 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
42311 -                       return -EFAULT;
42312 -               return 0;
42313 -       }
42314 -       /* set settings */
42315 -       case ETHTOOL_SSET: {
42316 -               int r;
42317 -               struct ethtool_cmd ecmd;
42318 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
42319 -                       return -EFAULT;
42320 -               spin_lock_irq(&np->lock);
42321 -               r = mii_ethtool_sset(&np->mii, &ecmd);
42322 -               spin_unlock_irq(&np->lock);
42323 -               return r;
42324 -       }
42325 -       /* restart autonegotiation */
42326 -       case ETHTOOL_NWAY_RST: {
42327 -               return mii_nway_restart(&np->mii);
42328 -       }
42329 -       /* get link status */
42330 -       case ETHTOOL_GLINK: {
42331 -               struct ethtool_value edata = {ETHTOOL_GLINK};
42332 -               edata.data = mii_link_ok(&np->mii);
42333 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
42334 -                       return -EFAULT;
42335 -               return 0;
42336 -       }
42337 -
42338 -       /* get message-level */
42339 -       case ETHTOOL_GMSGLVL: {
42340 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
42341 -               edata.data = debug;
42342 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
42343 -                       return -EFAULT;
42344 -               return 0;
42345 -       }
42346 -       /* set message-level */
42347 -       case ETHTOOL_SMSGLVL: {
42348 -               struct ethtool_value edata;
42349 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
42350 -                       return -EFAULT;
42351 -               debug = edata.data;
42352 -               return 0;
42353 -       }
42354 -       default:
42355 -               break;
42356 -       }
42357 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
42358 +{
42359 +       struct netdev_private *np = dev->priv;
42360 +       int rc;
42361 +
42362 +       spin_lock_irq(&np->lock);
42363 +       rc = mii_ethtool_gset(&np->mii, cmd);
42364 +       spin_unlock_irq(&np->lock);
42365 +
42366 +       return rc;
42367 +}
42368 +
42369 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
42370 +{
42371 +       struct netdev_private *np = dev->priv;
42372 +       int rc;
42373 +
42374 +       spin_lock_irq(&np->lock);
42375 +       rc = mii_ethtool_sset(&np->mii, cmd);
42376 +       spin_unlock_irq(&np->lock);
42377 +
42378 +       return rc;
42379 +}
42380 +
42381 +static int netdev_nway_reset(struct net_device *dev)
42382 +{
42383 +       struct netdev_private *np = dev->priv;
42384 +       return mii_nway_restart(&np->mii);
42385 +}
42386 +
42387 +static u32 netdev_get_link(struct net_device *dev)
42388 +{
42389 +       struct netdev_private *np = dev->priv;
42390 +       return mii_link_ok(&np->mii);
42391 +}
42392 +
42393 +static u32 netdev_get_msglevel(struct net_device *dev)
42394 +{
42395 +       return debug;
42396 +}
42397  
42398 -       return -EOPNOTSUPP;
42399 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
42400 +{
42401 +       debug = value;
42402  }
42403  
42404 +static struct ethtool_ops netdev_ethtool_ops = {
42405 +       .get_drvinfo            = netdev_get_drvinfo,
42406 +       .get_settings           = netdev_get_settings,
42407 +       .set_settings           = netdev_set_settings,
42408 +       .nway_reset             = netdev_nway_reset,
42409 +       .get_link               = netdev_get_link,
42410 +       .get_msglevel           = netdev_get_msglevel,
42411 +       .set_msglevel           = netdev_set_msglevel,
42412 +       .get_sg                 = ethtool_op_get_sg,
42413 +       .get_tx_csum            = ethtool_op_get_tx_csum,
42414 +};
42415  
42416  static int mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
42417  {
42418 @@ -1846,14 +1838,9 @@
42419         if (!netif_running(dev))
42420                 return -EINVAL;
42421  
42422 -       if (cmd == SIOCETHTOOL)
42423 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
42424 -
42425 -       else {
42426 -               spin_lock_irq(&np->lock);
42427 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
42428 -               spin_unlock_irq(&np->lock);
42429 -       }
42430 +       spin_lock_irq(&np->lock);
42431 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
42432 +       spin_unlock_irq(&np->lock);
42433  
42434         return rc;
42435  }
42436 diff -Nru a/drivers/net/fmv18x.c b/drivers/net/fmv18x.c
42437 --- a/drivers/net/fmv18x.c      Sun May 11 19:48:01 2003
42438 +++ b/drivers/net/fmv18x.c      Sun Aug 31 06:34:16 2003
42439 @@ -367,7 +367,7 @@
42440         struct net_local *lp = dev->priv;
42441         int ioaddr = dev->base_addr;
42442         short length = skb->len;
42443 -       unsigned char *buf = skb->data;
42444 +       unsigned char *buf;
42445         unsigned long flags;
42446  
42447         /* Block a transmit from overlapping.  */
42448 @@ -385,6 +385,7 @@
42449                         return 0;
42450                 length = ETH_ZLEN;
42451         }
42452 +       buf = skb->data;
42453         
42454         if (net_debug > 4)
42455                 printk("%s: Transmitting a packet of length %lu.\n", dev->name,
42456 diff -Nru a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
42457 --- a/drivers/net/hamradio/6pack.c      Fri Aug  1 03:02:07 2003
42458 +++ b/drivers/net/hamradio/6pack.c      Wed Sep  3 23:40:16 2003
42459 @@ -1064,6 +1064,7 @@
42460  MODULE_AUTHOR("Andreas Könsgen <ajk@ccac.rwth-aachen.de>");
42461  MODULE_DESCRIPTION("6pack driver for AX.25");
42462  MODULE_LICENSE("GPL");
42463 +MODULE_ALIAS_LDISC(N_6PACK);
42464  
42465  module_init(sixpack_init_driver);
42466  module_exit(sixpack_exit_driver);
42467 diff -Nru a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
42468 --- a/drivers/net/hamradio/Kconfig      Sun Apr 20 12:56:51 2003
42469 +++ b/drivers/net/hamradio/Kconfig      Mon Aug 25 05:52:13 2003
42470 @@ -1,6 +1,6 @@
42471  config MKISS
42472         tristate "Serial port KISS driver"
42473 -       depends on AX25
42474 +       depends on AX25 && BROKEN_ON_SMP
42475         ---help---
42476           KISS is a protocol used for the exchange of data between a computer
42477           and a Terminal Node Controller (a small embedded system commonly
42478 @@ -19,7 +19,7 @@
42479  
42480  config 6PACK
42481         tristate "Serial port 6PACK driver"
42482 -       depends on AX25
42483 +       depends on AX25 && BROKEN_ON_SMP
42484         ---help---
42485           6pack is a transmission protocol for the data exchange between your
42486           PC and your TNC (the Terminal Node Controller acts as a kind of
42487 @@ -49,7 +49,7 @@
42488  
42489  config DMASCC
42490         tristate "High-speed (DMA) SCC driver for AX.25"
42491 -       depends on ISA && AX25
42492 +       depends on ISA && AX25 && BROKEN_ON_SMP
42493         ---help---
42494           This is a driver for high-speed SCC boards, i.e. those supporting
42495           DMA on one port. You usually use those boards to connect your
42496 diff -Nru a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
42497 --- a/drivers/net/hamradio/bpqether.c   Tue Aug 19 20:58:55 2003
42498 +++ b/drivers/net/hamradio/bpqether.c   Wed Aug 27 23:48:03 2003
42499 @@ -605,6 +605,7 @@
42500  
42501         printk(banner);
42502  
42503 +#ifdef CONFIG_PROC_FS
42504         if (!proc_net_fops_create("bpqether", S_IRUGO, &bpq_info_fops)) {
42505                 printk(KERN_ERR
42506                         "bpq: cannot create /proc/net/bpqether entry.\n");
42507 @@ -612,6 +613,7 @@
42508                 dev_remove_pack(&bpq_packet_type);
42509                 return -ENOENT;
42510         }
42511 +#endif  /* CONFIG_PROC_FS */
42512  
42513         rtnl_lock();
42514         for (dev = dev_base; dev != NULL; dev = dev->next) {
42515 diff -Nru a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
42516 --- a/drivers/net/hamradio/mkiss.c      Mon Jul  7 12:55:58 2003
42517 +++ b/drivers/net/hamradio/mkiss.c      Wed Sep  3 23:40:16 2003
42518 @@ -935,7 +935,7 @@
42519  MODULE_PARM(ax25_maxdev, "i");
42520  MODULE_PARM_DESC(ax25_maxdev, "number of MKISS devices");
42521  MODULE_LICENSE("GPL");
42522 -
42523 +MODULE_ALIAS_LDISC(N_AX25);
42524  module_init(mkiss_init_driver);
42525  module_exit(mkiss_exit_driver);
42526  
42527 diff -Nru a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
42528 --- a/drivers/net/hamradio/yam.c        Tue Aug 19 20:53:16 2003
42529 +++ b/drivers/net/hamradio/yam.c        Thu Aug 28 01:23:35 2003
42530 @@ -807,7 +807,7 @@
42531         seq_printf(seq, "  RxInt    %u\n", yp->nb_rxint);
42532         seq_printf(seq, "  RxOver   %lu\n", yp->stats.rx_fifo_errors);
42533         seq_printf(seq, "\n");
42534 -
42535 +       return 0;
42536  }
42537  
42538  static struct seq_operations yam_seqops = {
42539 diff -Nru a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
42540 --- a/drivers/net/irda/Kconfig  Tue Aug 19 21:06:58 2003
42541 +++ b/drivers/net/irda/Kconfig  Mon Aug 25 05:53:24 2003
42542 @@ -256,7 +256,7 @@
42543  
42544  config TOSHIBA_OLD
42545         tristate "Toshiba Type-O IR Port (old driver)"
42546 -       depends on IRDA
42547 +       depends on IRDA && BROKEN_ON_SMP
42548         help
42549           Say Y here if you want to build support for the Toshiba Type-O IR
42550           chipset.  This chipset is used by the Toshiba Libretto 100CT, and
42551 @@ -319,7 +319,7 @@
42552  
42553  config VLSI_FIR
42554         tristate "VLSI 82C147 SIR/MIR/FIR (EXPERIMENTAL)"
42555 -       depends on EXPERIMENTAL && IRDA
42556 +       depends on EXPERIMENTAL && IRDA && PCI
42557         help
42558           Say Y here if you want to build support for the VLSI 82C147
42559           PCI-IrDA Controller. This controller is used by the HP OmniBook 800
42560 diff -Nru a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
42561 --- a/drivers/net/irda/irtty-sir.c      Tue May 27 01:52:33 2003
42562 +++ b/drivers/net/irda/irtty-sir.c      Wed Sep  3 23:40:16 2003
42563 @@ -651,5 +651,6 @@
42564  
42565  MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
42566  MODULE_DESCRIPTION("IrDA TTY device driver");
42567 +MODULE_ALIAS_LDISC(N_IRDA);
42568  MODULE_LICENSE("GPL");
42569  
42570 diff -Nru a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
42571 --- a/drivers/net/irda/via-ircc.c       Fri Aug  8 18:15:54 2003
42572 +++ b/drivers/net/irda/via-ircc.c       Sun Aug 31 16:14:08 2003
42573 @@ -134,10 +134,10 @@
42574  
42575  
42576  static struct pci_driver via_driver = {
42577 -       name:           VIA_MODULE_NAME,
42578 -       id_table:       via_pci_tbl,
42579 -       probe:          via_init_one,
42580 -       remove:         via_remove_one,
42581 +       .name           = VIA_MODULE_NAME,
42582 +       .id_table       = via_pci_tbl,
42583 +       .probe          = via_init_one,
42584 +       .remove         = via_remove_one,
42585  };
42586  
42587  
42588 diff -Nru a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
42589 --- a/drivers/net/irda/vlsi_ir.c        Wed Aug 20 15:31:21 2003
42590 +++ b/drivers/net/irda/vlsi_ir.c        Sun Aug 24 04:45:26 2003
42591 @@ -21,18 +21,20 @@
42592   *
42593   ********************************************************************/
42594  
42595 +#include <linux/config.h>
42596  #include <linux/module.h>
42597   
42598 -MODULE_DESCRIPTION("IrDA SIR/MIR/FIR driver for VLSI 82C147");
42599 -MODULE_AUTHOR("Martin Diehl <info@mdiehl.de>");
42600 -MODULE_LICENSE("GPL");
42601 +#define DRIVER_NAME            "vlsi_ir"
42602 +#define DRIVER_VERSION         "v0.5"
42603 +#define DRIVER_DESCRIPTION     "IrDA SIR/MIR/FIR driver for VLSI 82C147"
42604 +#define DRIVER_AUTHOR          "Martin Diehl <info@mdiehl.de>"
42605  
42606 -#define DRIVER_NAME "vlsi_ir"
42607 -#define DRIVER_VERSION "v0.4a"
42608 +MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
42609 +MODULE_AUTHOR(DRIVER_AUTHOR);
42610 +MODULE_LICENSE("GPL");
42611  
42612  /********************************************************/
42613  
42614 -#include <linux/config.h>
42615  #include <linux/kernel.h>
42616  #include <linux/init.h>
42617  #include <linux/pci.h>
42618 @@ -44,10 +46,12 @@
42619  #include <linux/proc_fs.h>
42620  #include <linux/smp_lock.h>
42621  #include <asm/uaccess.h>
42622 +#include <asm/byteorder.h>
42623  
42624  #include <net/irda/irda.h>
42625  #include <net/irda/irda_device.h>
42626  #include <net/irda/wrapper.h>
42627 +#include <net/irda/crc.h>
42628  
42629  #include <net/irda/vlsi_ir.h>
42630  
42631 @@ -55,14 +59,16 @@
42632  
42633  static /* const */ char drivername[] = DRIVER_NAME;
42634  
42635 -#define PCI_CLASS_WIRELESS_IRDA 0x0d00
42636 -
42637 -static struct pci_device_id vlsi_irda_table [] = { {
42638 -
42639 -       .class =        PCI_CLASS_WIRELESS_IRDA << 8,
42640 -       .vendor =       PCI_VENDOR_ID_VLSI,
42641 -       .device =       PCI_DEVICE_ID_VLSI_82C147,
42642 -       }, { /* all zeroes */ }
42643 +static struct pci_device_id vlsi_irda_table [] = {
42644 +       {
42645 +               .class =        PCI_CLASS_WIRELESS_IRDA << 8,
42646 +               .class_mask =   PCI_CLASS_SUBCLASS_MASK << 8, 
42647 +               .vendor =       PCI_VENDOR_ID_VLSI,
42648 +               .device =       PCI_DEVICE_ID_VLSI_82C147,
42649 +               .subvendor =    PCI_ANY_ID,
42650 +               .subdevice =    PCI_ANY_ID,
42651 +       },
42652 +       { /* all zeroes */ }
42653  };
42654  
42655  MODULE_DEVICE_TABLE(pci, vlsi_irda_table);
42656 @@ -114,7 +120,7 @@
42657  
42658  MODULE_PARM(qos_mtt_bits, "i");
42659  MODULE_PARM_DESC(qos_mtt_bits, "IrLAP bitfield representing min-turn-time");
42660 -static int qos_mtt_bits = 0x04;                /* default is 1 ms */
42661 +static int qos_mtt_bits = 0x07;                /* default is 1 ms or more */
42662  
42663  /********************************************************/
42664  
42665 @@ -164,7 +170,7 @@
42666                 return 0;
42667  
42668         out += sprintf(out, "\n%s (vid/did: %04x/%04x)\n",
42669 -                       pci_name(pdev), (int)pdev->vendor, (int)pdev->device);
42670 +                       PCIDEV_NAME(pdev), (int)pdev->vendor, (int)pdev->device);
42671         out += sprintf(out, "pci-power-state: %u\n", (unsigned) pdev->current_state);
42672         out += sprintf(out, "resources: irq=%u / io=0x%04x / dma_mask=0x%016Lx\n",
42673                         pdev->irq, (unsigned)pci_resource_start(pdev, 0), (u64)pdev->dma_mask);
42674 @@ -198,13 +204,13 @@
42675  
42676         out += sprintf(out, "\nhw-state:\n");
42677         pci_read_config_byte(idev->pdev, VLSI_PCI_IRMISC, &byte);
42678 -       out += sprintf(out, "IRMISC:%s%s%s UART%s",
42679 +       out += sprintf(out, "IRMISC:%s%s%s uart%s",
42680                 (byte&IRMISC_IRRAIL) ? " irrail" : "",
42681                 (byte&IRMISC_IRPD) ? " irpd" : "",
42682                 (byte&IRMISC_UARTTST) ? " uarttest" : "",
42683 -               (byte&IRMISC_UARTEN) ? "" : " disabled\n");
42684 +               (byte&IRMISC_UARTEN) ? "@" : " disabled\n");
42685         if (byte&IRMISC_UARTEN) {
42686 -               out += sprintf(out, "@0x%s\n",
42687 +               out += sprintf(out, "0x%s\n",
42688                         (byte&2) ? ((byte&1) ? "3e8" : "2e8")
42689                                  : ((byte&1) ? "3f8" : "2f8"));
42690         }
42691 @@ -254,7 +260,7 @@
42692                 (word&IRCFG_RXPOL) ? " RXPOL" : "");
42693         word = inw(iobase+VLSI_PIO_IRENABLE);
42694         out += sprintf(out, "IRENABLE:%s%s%s%s%s%s%s%s\n",
42695 -               (word&IRENABLE_IREN) ? " IRENABLE" : "",
42696 +               (word&IRENABLE_PHYANDCLOCK) ? " PHYANDCLOCK" : "",
42697                 (word&IRENABLE_CFGER) ? " CFGERR" : "",
42698                 (word&IRENABLE_FIR_ON) ? " FIR_ON" : "",
42699                 (word&IRENABLE_MIR_ON) ? " MIR_ON" : "",
42700 @@ -358,7 +364,7 @@
42701         char *out = buf;
42702  
42703         if (!ndev || !ndev->priv) {
42704 -               printk(KERN_ERR "%s: invalid ptr!\n", __FUNCTION__);
42705 +               ERROR("%s: invalid ptr!\n", __FUNCTION__);
42706                 return 0;
42707         }
42708  
42709 @@ -539,7 +545,14 @@
42710                 memset(rd, 0, sizeof(*rd));
42711                 rd->hw = hwmap + i;
42712                 rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA);
42713 -               if (rd->buf == NULL) {
42714 +               if (rd->buf == NULL
42715 +                   ||  !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) {
42716 +                       if (rd->buf) {
42717 +                               ERROR("%s: failed to create PCI-MAP for %p",
42718 +                                       __FUNCTION__, rd->buf);
42719 +                               kfree(rd->buf);
42720 +                               rd->buf = NULL;
42721 +                       }
42722                         for (j = 0; j < i; j++) {
42723                                 rd = r->rd + j;
42724                                 busaddr = rd_get_addr(rd);
42725 @@ -552,12 +565,6 @@
42726                         kfree(r);
42727                         return NULL;
42728                 }
42729 -               busaddr = pci_map_single(pdev, rd->buf, len, dir);
42730 -               if (!busaddr) {
42731 -                       printk(KERN_ERR "%s: failed to create PCI-MAP for %p",
42732 -                               __FUNCTION__, rd->buf);
42733 -                       BUG();
42734 -               }
42735                 rd_set_addr_status(rd, busaddr, 0);
42736                 pci_dma_sync_single(pdev, busaddr, len, dir);
42737                 /* initially, the dma buffer is owned by the CPU */
42738 @@ -597,8 +604,7 @@
42739  
42740         ringarea = pci_alloc_consistent(idev->pdev, HW_RING_AREA_SIZE, &idev->busaddr);
42741         if (!ringarea) {
42742 -               printk(KERN_ERR "%s: insufficient memory for descriptor rings\n",
42743 -                       __FUNCTION__);
42744 +               ERROR("%s: insufficient memory for descriptor rings\n", __FUNCTION__);
42745                 goto out;
42746         }
42747         memset(ringarea, 0, HW_RING_AREA_SIZE);
42748 @@ -666,33 +672,52 @@
42749                         ret |= VLSI_RX_FRAME;
42750                 if (status & RD_RX_CRCERR)  
42751                         ret |= VLSI_RX_CRC;
42752 +               goto done;
42753         }
42754 -       else {
42755 -               len = rd_get_count(rd);
42756 -               crclen = (idev->mode==IFF_FIR) ? sizeof(u32) : sizeof(u16);
42757 -               len -= crclen;          /* remove trailing CRC */
42758 -               if (len <= 0) {
42759 -                       printk(KERN_ERR "%s: strange frame (len=%d)\n",
42760 -                               __FUNCTION__, len);
42761 -                       ret |= VLSI_RX_DROP;
42762 -               }
42763 -               else if (!rd->skb) {
42764 -                       printk(KERN_ERR "%s: rx packet dropped\n", __FUNCTION__);
42765 -                       ret |= VLSI_RX_DROP;
42766 -               }
42767 -               else {
42768 -                       skb = rd->skb;
42769 -                       rd->skb = NULL;
42770 -                       skb->dev = ndev;
42771 -                       memcpy(skb_put(skb,len), rd->buf, len);
42772 -                       skb->mac.raw = skb->data;
42773 -                       if (in_interrupt())
42774 -                               netif_rx(skb);
42775 -                       else
42776 -                               netif_rx_ni(skb);
42777 -                       ndev->last_rx = jiffies;
42778 +
42779 +       len = rd_get_count(rd);
42780 +       crclen = (idev->mode==IFF_FIR) ? sizeof(u32) : sizeof(u16);
42781 +       len -= crclen;          /* remove trailing CRC */
42782 +       if (len <= 0) {
42783 +               IRDA_DEBUG(0, "%s: strange frame (len=%d)\n", __FUNCTION__, len);
42784 +               ret |= VLSI_RX_DROP;
42785 +               goto done;
42786 +       }
42787 +
42788 +       if (idev->mode == IFF_SIR) {    /* hw checks CRC in MIR, FIR mode */
42789 +
42790 +               /* rd->buf is a streaming PCI_DMA_FROMDEVICE map. Doing the
42791 +                * endian-adjustment there just in place will dirty a cache line
42792 +                * which belongs to the map and thus we must be sure it will
42793 +                * get flushed before giving the buffer back to hardware.
42794 +                * vlsi_fill_rx() will do this anyway - but here we rely on.
42795 +                */
42796 +               le16_to_cpus(rd->buf+len);
42797 +               if (irda_calc_crc16(INIT_FCS,rd->buf,len+crclen) != GOOD_FCS) {
42798 +                       IRDA_DEBUG(0, "%s: crc error\n", __FUNCTION__);
42799 +                       ret |= VLSI_RX_CRC;
42800 +                       goto done;
42801                 }
42802         }
42803 +
42804 +       if (!rd->skb) {
42805 +               WARNING("%s: rx packet lost\n", __FUNCTION__);
42806 +               ret |= VLSI_RX_DROP;
42807 +               goto done;
42808 +       }
42809 +
42810 +       skb = rd->skb;
42811 +       rd->skb = NULL;
42812 +       skb->dev = ndev;
42813 +       memcpy(skb_put(skb,len), rd->buf, len);
42814 +       skb->mac.raw = skb->data;
42815 +       if (in_interrupt())
42816 +               netif_rx(skb);
42817 +       else
42818 +               netif_rx_ni(skb);
42819 +       ndev->last_rx = jiffies;
42820 +
42821 +done:
42822         rd_set_status(rd, 0);
42823         rd_set_count(rd, 0);
42824         /* buffer still owned by CPU */
42825 @@ -706,7 +731,9 @@
42826  
42827         for (rd = ring_last(r); rd != NULL; rd = ring_put(r)) {
42828                 if (rd_is_active(rd)) {
42829 -                       BUG();
42830 +                       WARNING("%s: driver bug: rx descr race with hw\n",
42831 +                               __FUNCTION__);
42832 +                       vlsi_ring_debug(r);
42833                         break;
42834                 }
42835                 if (!rd->skb) {
42836 @@ -764,7 +791,7 @@
42837  
42838         if (ring_first(r) == NULL) {
42839                 /* we are in big trouble, if this should ever happen */
42840 -               printk(KERN_ERR "%s: rx ring exhausted!\n", __FUNCTION__);
42841 +               ERROR("%s: rx ring exhausted!\n", __FUNCTION__);
42842                 vlsi_ring_debug(r);
42843         }
42844         else
42845 @@ -785,7 +812,7 @@
42846                 if (rd_is_active(rd)) {
42847                         rd_set_status(rd, 0);
42848                         if (rd_get_count(rd)) {
42849 -                               printk(KERN_INFO "%s - dropping rx packet\n", __FUNCTION__);
42850 +                               IRDA_DEBUG(0, "%s - dropping rx packet\n", __FUNCTION__);
42851                                 ret = -VLSI_RX_DROP;
42852                         }
42853                         rd_set_count(rd, 0);
42854 @@ -850,24 +877,17 @@
42855         return (ret) ? -ret : len;
42856  }
42857  
42858 -static int vlsi_set_baud(struct net_device *ndev, int dolock)
42859 +static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
42860  {
42861 -       vlsi_irda_dev_t *idev = ndev->priv;
42862 -       unsigned long flags;
42863         u16 nphyctl;
42864 -       unsigned iobase; 
42865         u16 config;
42866         unsigned mode;
42867 -       unsigned idle_retry;
42868         int     ret;
42869         int     baudrate;
42870 -       int     fifocnt = 0;    /* Keep compiler happy */
42871 +       int     fifocnt;
42872  
42873         baudrate = idev->new_baud;
42874 -       iobase = ndev->base_addr;
42875 -#if 0
42876 -       printk(KERN_DEBUG "%s: %d -> %d\n", __FUNCTION__, idev->baud, idev->new_baud);
42877 -#endif
42878 +       IRDA_DEBUG(2, "%s: %d -> %d\n", __FUNCTION__, idev->baud, idev->new_baud);
42879         if (baudrate == 4000000) {
42880                 mode = IFF_FIR;
42881                 config = IRCFG_FIR;
42882 @@ -883,7 +903,7 @@
42883                 config = IRCFG_SIR | IRCFG_SIRFILT  | IRCFG_RXANY;
42884                 switch(baudrate) {
42885                         default:
42886 -                               printk(KERN_ERR "%s: undefined baudrate %d - fallback to 9600!\n",
42887 +                               WARNING("%s: undefined baudrate %d - fallback to 9600!\n",
42888                                         __FUNCTION__, baudrate);
42889                                 baudrate = 9600;
42890                                 /* fallthru */
42891 @@ -897,40 +917,18 @@
42892                                 break;
42893                 }
42894         }
42895 +       config |= IRCFG_MSTR | IRCFG_ENRX;
42896  
42897 -       if (dolock)
42898 -               spin_lock_irqsave(&idev->lock, flags);
42899 -       else
42900 -               flags = 0xdead; /* prevent bogus warning about possible uninitialized use */
42901 -
42902 -       for (idle_retry=0; idle_retry < 100; idle_retry++) {
42903 -               fifocnt = inw(ndev->base_addr+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
42904 -               if (fifocnt == 0)
42905 -                       break;
42906 -               if (!idle_retry)
42907 -                       printk(KERN_WARNING "%s: waiting for rx fifo to become empty(%d)\n",
42908 -                               __FUNCTION__, fifocnt);
42909 -               if (dolock) {
42910 -                       spin_unlock_irqrestore(&idev->lock, flags);
42911 -                       udelay(100);
42912 -                       spin_lock_irqsave(&idev->lock, flags);
42913 -               }
42914 -               else
42915 -                       udelay(100);
42916 +       fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
42917 +       if (fifocnt != 0) {
42918 +               IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
42919         }
42920 -       if (fifocnt != 0)
42921 -               printk(KERN_ERR "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
42922  
42923         outw(0, iobase+VLSI_PIO_IRENABLE);
42924 -       wmb();
42925 -
42926 -       config |= IRCFG_MSTR | IRCFG_ENRX;
42927 -
42928         outw(config, iobase+VLSI_PIO_IRCFG);
42929 -
42930         outw(nphyctl, iobase+VLSI_PIO_NPHYCTL);
42931         wmb();
42932 -       outw(IRENABLE_IREN, iobase+VLSI_PIO_IRENABLE);
42933 +       outw(IRENABLE_PHYANDCLOCK, iobase+VLSI_PIO_IRENABLE);
42934         mb();
42935  
42936         udelay(1);      /* chip applies IRCFG on next rising edge of its 8MHz clock */
42937 @@ -946,14 +944,14 @@
42938         else
42939                 config ^= IRENABLE_SIR_ON;
42940  
42941 -       if (config != (IRENABLE_IREN|IRENABLE_ENRXST)) {
42942 -               printk(KERN_ERR "%s: failed to set %s mode!\n", __FUNCTION__,
42943 +       if (config != (IRENABLE_PHYANDCLOCK|IRENABLE_ENRXST)) {
42944 +               WARNING("%s: failed to set %s mode!\n", __FUNCTION__,
42945                         (mode==IFF_SIR)?"SIR":((mode==IFF_MIR)?"MIR":"FIR"));
42946                 ret = -1;
42947         }
42948         else {
42949                 if (inw(iobase+VLSI_PIO_PHYCTL) != nphyctl) {
42950 -                       printk(KERN_ERR "%s: failed to apply baudrate %d\n",
42951 +                       WARNING("%s: failed to apply baudrate %d\n",
42952                                 __FUNCTION__, baudrate);
42953                         ret = -1;
42954                 }
42955 @@ -964,8 +962,6 @@
42956                         ret = 0;
42957                 }
42958         }
42959 -       if (dolock)
42960 -               spin_unlock_irqrestore(&idev->lock, flags);
42961  
42962         if (ret)
42963                 vlsi_reg_debug(iobase,__FUNCTION__);
42964 @@ -973,16 +969,6 @@
42965         return ret;
42966  }
42967  
42968 -static inline int vlsi_set_baud_lock(struct net_device *ndev)
42969 -{
42970 -       return vlsi_set_baud(ndev, 1);
42971 -}
42972 -
42973 -static inline int vlsi_set_baud_nolock(struct net_device *ndev)
42974 -{
42975 -       return vlsi_set_baud(ndev, 0);
42976 -}
42977 -
42978  static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
42979  {
42980         vlsi_irda_dev_t *idev = ndev->priv;
42981 @@ -995,79 +981,100 @@
42982         int mtt;
42983         int len, speed;
42984         struct timeval  now, ready;
42985 +       char *msg = NULL;
42986  
42987         speed = irda_get_next_speed(skb);
42988 +       spin_lock_irqsave(&idev->lock, flags);
42989         if (speed != -1  &&  speed != idev->baud) {
42990                 netif_stop_queue(ndev);
42991                 idev->new_baud = speed;
42992 -               if (!skb->len) {
42993 -                       dev_kfree_skb_any(skb);
42994 -
42995 -                       /* due to the completely asynch tx operation we might have
42996 -                        * IrLAP racing with the hardware here, f.e. if the controller
42997 -                        * is just sending the last packet with current speed while
42998 -                        * the LAP is already switching the speed using synchronous
42999 -                        * len=0 packet. Immediate execution would lead to hw lockup
43000 -                        * requiring a powercycle to reset. Good candidate to trigger
43001 -                        * this is the final UA:RSP packet after receiving a DISC:CMD
43002 -                        * when getting the LAP down.
43003 -                        * Note that we are not protected by the queue_stop approach
43004 -                        * because the final UA:RSP arrives _without_ request to apply
43005 -                        * new-speed-after-this-packet - hence the driver doesn't know
43006 -                        * this was the last packet and doesn't stop the queue. So the
43007 -                        * forced switch to default speed from LAP gets through as fast
43008 -                        * as only some 10 usec later while the UA:RSP is still processed
43009 -                        * by the hardware and we would get screwed.
43010 -                        * Note: no locking required since we (netdev->xmit) are the only
43011 -                        * supplier for tx and the network layer provides serialization
43012 -                        */
43013 -                       spin_lock_irqsave(&idev->lock, flags);
43014 -                       if (ring_first(idev->tx_ring) == NULL) {
43015 -                               /* no race - tx-ring already empty */
43016 -                               vlsi_set_baud_nolock(ndev);
43017 -                               netif_wake_queue(ndev);
43018 -                       }
43019 -                       else
43020 -                               ; /* keep the speed change pending like it would
43021 -                                  * for any len>0 packet. tx completion interrupt
43022 -                                  * will apply it when the tx ring becomes empty.
43023 -                                  */
43024 -                       spin_unlock_irqrestore(&idev->lock, flags);
43025 -                       return 0;
43026 -               }
43027                 status = RD_TX_CLRENTX;  /* stop tx-ring after this frame */
43028         }
43029         else
43030                 status = 0;
43031  
43032         if (skb->len == 0) {
43033 -               printk(KERN_ERR "%s: dropping len=0 packet\n", __FUNCTION__);
43034 -               goto drop;
43035 +               /* handle zero packets - should be speed change */
43036 +               if (status == 0) {
43037 +                       msg = "bogus zero-length packet";
43038 +                       goto drop_unlock;
43039 +               }
43040 +
43041 +               /* due to the completely asynch tx operation we might have
43042 +                * IrLAP racing with the hardware here, f.e. if the controller
43043 +                * is just sending the last packet with current speed while
43044 +                * the LAP is already switching the speed using synchronous
43045 +                * len=0 packet. Immediate execution would lead to hw lockup
43046 +                * requiring a powercycle to reset. Good candidate to trigger
43047 +                * this is the final UA:RSP packet after receiving a DISC:CMD
43048 +                * when getting the LAP down.
43049 +                * Note that we are not protected by the queue_stop approach
43050 +                * because the final UA:RSP arrives _without_ request to apply
43051 +                * new-speed-after-this-packet - hence the driver doesn't know
43052 +                * this was the last packet and doesn't stop the queue. So the
43053 +                * forced switch to default speed from LAP gets through as fast
43054 +                * as only some 10 usec later while the UA:RSP is still processed
43055 +                * by the hardware and we would get screwed.
43056 +                */
43057 +
43058 +               if (ring_first(idev->tx_ring) == NULL) {
43059 +                       /* no race - tx-ring already empty */
43060 +                       vlsi_set_baud(idev, iobase);
43061 +                       netif_wake_queue(ndev);
43062 +               }
43063 +               else
43064 +                       ;
43065 +                       /* keep the speed change pending like it would
43066 +                        * for any len>0 packet. tx completion interrupt
43067 +                        * will apply it when the tx ring becomes empty.
43068 +                        */
43069 +               spin_unlock_irqrestore(&idev->lock, flags);
43070 +               dev_kfree_skb_any(skb);
43071 +               return 0;
43072         }
43073  
43074 -       /* sanity checks - should never happen!
43075 -        * simply BUGging the violation and dropping the packet
43076 -        */
43077 +       /* sanity checks - simply drop the packet */
43078  
43079         rd = ring_last(r);
43080 -       if (!rd) {                              /* ring full - queue should have been stopped! */
43081 -               BUG();
43082 -               goto drop;
43083 +       if (!rd) {
43084 +               msg = "ring full, but queue wasn't stopped";
43085 +               goto drop_unlock;
43086         }
43087  
43088 -       if (rd_is_active(rd)) {                 /* entry still owned by hw! */
43089 -               BUG();
43090 -               goto drop;
43091 +       if (rd_is_active(rd)) {
43092 +               msg = "entry still owned by hw";
43093 +               goto drop_unlock;
43094         }
43095  
43096 -       if (!rd->buf) {                         /* no memory for this tx entry - weird! */
43097 -               BUG();
43098 -               goto drop;
43099 +       if (!rd->buf) {
43100 +               msg = "tx ring entry without pci buffer";
43101 +               goto drop_unlock;
43102         }
43103  
43104 -       if (rd->skb) {                          /* hm, associated old skb still there */
43105 -               BUG();
43106 -               goto drop;
43107 +       if (rd->skb) {
43108 +               msg = "ring entry with old skb still attached";
43109 +               goto drop_unlock;
43110 +       }
43111 +
43112 +       /* no need for serialization or interrupt disable during mtt */
43113 +       spin_unlock_irqrestore(&idev->lock, flags);
43114 +
43115 +       if ((mtt = irda_get_mtt(skb)) > 0) {
43116 +       
43117 +               ready.tv_usec = idev->last_rx.tv_usec + mtt;
43118 +               ready.tv_sec = idev->last_rx.tv_sec;
43119 +               if (ready.tv_usec >= 1000000) {
43120 +                       ready.tv_usec -= 1000000;
43121 +                       ready.tv_sec++;         /* IrLAP 1.1: mtt always < 1 sec */
43122 +               }
43123 +               for(;;) {
43124 +                       do_gettimeofday(&now);
43125 +                       if (now.tv_sec > ready.tv_sec
43126 +                           ||  (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
43127 +                               break;
43128 +                       udelay(100);
43129 +                       /* must not sleep here - we are called under xmit_lock! */
43130 +               }
43131         }
43132  
43133         /* tx buffer already owned by CPU due to pci_dma_sync_single() either
43134 @@ -1089,7 +1096,7 @@
43135                  */
43136  
43137                 if (len >= r->len-5)
43138 -                        printk(KERN_WARNING "%s: possible buffer overflow with SIR wrapping!\n",
43139 +                        WARNING("%s: possible buffer overflow with SIR wrapping!\n",
43140                                 __FUNCTION__);
43141         }
43142         else {
43143 @@ -1097,34 +1104,13 @@
43144                 status |= RD_TX_PULSE;          /* send 2 us highspeed indication pulse */
43145                 len = skb->len;
43146                 if (len > r->len) {
43147 -                       printk(KERN_ERR "%s: no space - skb too big (%d)\n",
43148 -                               __FUNCTION__, skb->len);
43149 +                       msg = "frame exceeds tx buffer length";
43150                         goto drop;
43151                 }
43152                 else
43153                         memcpy(rd->buf, skb->data, len);
43154         }
43155  
43156 -       /* do mtt delay before we need to disable interrupts! */
43157 -
43158 -       if ((mtt = irda_get_mtt(skb)) > 0) {
43159 -       
43160 -               ready.tv_usec = idev->last_rx.tv_usec + mtt;
43161 -               ready.tv_sec = idev->last_rx.tv_sec;
43162 -               if (ready.tv_usec >= 1000000) {
43163 -                       ready.tv_usec -= 1000000;
43164 -                       ready.tv_sec++;         /* IrLAP 1.1: mtt always < 1 sec */
43165 -               }
43166 -               for(;;) {
43167 -                       do_gettimeofday(&now);
43168 -                       if (now.tv_sec > ready.tv_sec
43169 -                           ||  (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
43170 -                               break;
43171 -                       udelay(100);
43172 -                       /* must not sleep here - we are called under xmit_lock! */
43173 -               }
43174 -       }
43175 -
43176         rd->skb = skb;                  /* remember skb for tx-complete stats */
43177  
43178         rd_set_count(rd, len);
43179 @@ -1136,10 +1122,7 @@
43180  
43181         pci_dma_prep_single(r->pdev, rd_get_addr(rd), r->len, r->dir);
43182  
43183 -/*
43184 - *     We need to disable IR output in order to switch to TX mode.
43185 - *     Better not do this blindly anytime we want to transmit something
43186 - *     because TX may already run. However we are racing with the controller
43187 +/*     Switching to TX mode here races with the controller
43188   *     which may stop TX at any time when fetching an inactive descriptor
43189   *     or one with CLR_ENTX set. So we switch on TX only, if TX was not running
43190   *     _after_ the new descriptor was activated on the ring. This ensures
43191 @@ -1158,31 +1141,39 @@
43192                 int fifocnt;
43193  
43194                 fifocnt = inw(ndev->base_addr+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
43195 -               if (fifocnt != 0)
43196 -                       printk(KERN_WARNING "%s: rx fifo not empty(%d)\n",
43197 -                               __FUNCTION__, fifocnt);
43198 +               if (fifocnt != 0) {
43199 +                       IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
43200 +               }
43201  
43202                 config = inw(iobase+VLSI_PIO_IRCFG);
43203 -               rmb();
43204 -               outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
43205                 mb();
43206 +               outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
43207 +               wmb();
43208                 outw(0, iobase+VLSI_PIO_PROMPT);
43209         }
43210         ndev->trans_start = jiffies;
43211  
43212         if (ring_put(r) == NULL) {
43213                 netif_stop_queue(ndev);
43214 -               printk(KERN_DEBUG "%s: tx ring full - queue stopped\n", __FUNCTION__);
43215 +               IRDA_DEBUG(3, "%s: tx ring full - queue stopped\n", __FUNCTION__);
43216         }
43217         spin_unlock_irqrestore(&idev->lock, flags);
43218  
43219         return 0;
43220  
43221 +drop_unlock:
43222 +       spin_unlock_irqrestore(&idev->lock, flags);
43223  drop:
43224 +       WARNING("%s: dropping packet - %s\n", __FUNCTION__, msg);
43225         dev_kfree_skb_any(skb);
43226         idev->stats.tx_errors++;
43227         idev->stats.tx_dropped++;
43228 -       return 1;
43229 +       /* Don't even think about returning NET_XMIT_DROP (=1) here!
43230 +        * In fact any retval!=0 causes the packet scheduler to requeue the
43231 +        * packet for later retry of transmission - which isn't exactly
43232 +        * what we want after we've just called dev_kfree_skb_any ;-)
43233 +        */
43234 +       return 0;
43235  }
43236  
43237  static void vlsi_tx_interrupt(struct net_device *ndev)
43238 @@ -1215,12 +1206,12 @@
43239                 }
43240         }
43241  
43242 +       iobase = ndev->base_addr;
43243 +
43244         if (idev->new_baud  &&  rd == NULL)     /* tx ring empty and speed change pending */
43245 -               vlsi_set_baud_lock(ndev);
43246 +               vlsi_set_baud(idev, iobase);
43247  
43248 -       iobase = ndev->base_addr;
43249         config = inw(iobase+VLSI_PIO_IRCFG);
43250 -
43251         if (rd == NULL)                 /* tx ring empty: re-enable rx */
43252                 outw((config & ~IRCFG_ENTX) | IRCFG_ENRX, iobase+VLSI_PIO_IRCFG);
43253  
43254 @@ -1228,9 +1219,10 @@
43255                 int fifocnt;
43256  
43257                 fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
43258 -               if (fifocnt != 0)
43259 -                       printk(KERN_WARNING "%s: rx fifo not empty(%d)\n",
43260 +               if (fifocnt != 0) {
43261 +                       IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n",
43262                                 __FUNCTION__, fifocnt);
43263 +               }
43264                 outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
43265         }
43266  
43267 @@ -1238,7 +1230,7 @@
43268  
43269         if (netif_queue_stopped(ndev)  &&  !idev->new_baud) {
43270                 netif_wake_queue(ndev);
43271 -               printk(KERN_DEBUG "%s: queue awoken\n", __FUNCTION__);
43272 +               IRDA_DEBUG(3, "%s: queue awoken\n", __FUNCTION__);
43273         }
43274  }
43275  
43276 @@ -1261,7 +1253,7 @@
43277                                 dev_kfree_skb_any(rd->skb);
43278                                 rd->skb = NULL;
43279                         }
43280 -                       printk(KERN_INFO "%s - dropping tx packet\n", __FUNCTION__);
43281 +                       IRDA_DEBUG(0, "%s - dropping tx packet\n", __FUNCTION__);
43282                         ret = -VLSI_TX_DROP;
43283                 }
43284                 else
43285 @@ -1310,8 +1302,7 @@
43286                 }
43287                 if (count < 3) {
43288                         if (clksrc == 1) { /* explicitly asked for PLL hence bail out */
43289 -                               printk(KERN_ERR "%s: no PLL or failed to lock!\n",
43290 -                                       __FUNCTION__);
43291 +                               ERROR("%s: no PLL or failed to lock!\n", __FUNCTION__);
43292                                 clkctl = CLKCTL_CLKSTP;
43293                                 pci_write_config_byte(pdev, VLSI_PCI_CLKCTL, clkctl);
43294                                 return -1;
43295 @@ -1319,7 +1310,7 @@
43296                         else                    /* was: clksrc=0(auto) */
43297                                 clksrc = 3;     /* fallback to 40MHz XCLK (OB800) */
43298  
43299 -                       printk(KERN_INFO "%s: PLL not locked, fallback to clksrc=%d\n",
43300 +                       IRDA_DEBUG(0, "%s: PLL not locked, fallback to clksrc=%d\n",
43301                                 __FUNCTION__, clksrc);
43302                 }
43303                 else
43304 @@ -1392,9 +1383,7 @@
43305         /* start the clock and clean the registers */
43306  
43307         if (vlsi_start_clock(pdev)) {
43308 -               printk(KERN_ERR "%s: no valid clock source\n",
43309 -                       __FUNCTION__);
43310 -               pci_disable_device(pdev);
43311 +               ERROR("%s: no valid clock source\n", __FUNCTION__);
43312                 return -1;
43313         }
43314         iobase = ndev->base_addr;
43315 @@ -1422,7 +1411,7 @@
43316         atomic_set(&idev->tx_ring->head, RINGPTR_GET_TX(ptr));
43317         atomic_set(&idev->tx_ring->tail, RINGPTR_GET_TX(ptr));
43318  
43319 -       vlsi_set_baud_lock(ndev);       /* idev->new_baud used as provided by caller */
43320 +       vlsi_set_baud(idev, iobase);    /* idev->new_baud used as provided by caller */
43321  
43322         outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);  /* just in case - w/c pending IRQ's */
43323         wmb();
43324 @@ -1455,7 +1444,10 @@
43325         pci_write_config_byte(pdev, VLSI_PCI_MSTRPAGE, MSTRPAGE_VALUE);
43326         pci_set_master(pdev);
43327  
43328 -       vlsi_init_chip(pdev);
43329 +       if (vlsi_init_chip(pdev) < 0) {
43330 +               pci_disable_device(pdev);
43331 +               return -1;
43332 +       }
43333  
43334         vlsi_fill_rx(idev->rx_ring);
43335  
43336 @@ -1476,10 +1468,11 @@
43337         spin_lock_irqsave(&idev->lock,flags);
43338         outw(0, iobase+VLSI_PIO_IRENABLE);
43339         outw(0, iobase+VLSI_PIO_IRCFG);                 /* disable everything */
43340 -       wmb();
43341  
43342 -       outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);  /* w/c pending + disable further IRQ */
43343 -       mb();
43344 +       /* disable and w/c irqs */
43345 +       outb(0, iobase+VLSI_PIO_IRINTR);
43346 +       wmb();
43347 +       outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);
43348         spin_unlock_irqrestore(&idev->lock,flags);
43349  
43350         vlsi_unarm_tx(idev);
43351 @@ -1521,8 +1514,8 @@
43352                 idev->new_baud = idev->baud;            /* keep current baudrate */
43353  
43354         if (vlsi_start_hw(idev))
43355 -               printk(KERN_CRIT "%s: failed to restart hw - %s(%s) unusable!\n",
43356 -                       __FUNCTION__, pci_name(idev->pdev), ndev->name);
43357 +               ERROR("%s: failed to restart hw - %s(%s) unusable!\n",
43358 +                       __FUNCTION__, PCIDEV_NAME(idev->pdev), ndev->name);
43359         else
43360                 netif_start_queue(ndev);
43361  }
43362 @@ -1547,7 +1540,7 @@
43363                          * if the stack tries to change speed concurrently - which would be
43364                          * pretty strange anyway with the userland having full control...
43365                          */
43366 -                       vlsi_set_baud_nolock(ndev);
43367 +                       vlsi_set_baud(idev, ndev->base_addr);
43368                         spin_unlock_irqrestore(&idev->lock, flags);
43369                         break;
43370                 case SIOCSMEDIABUSY:
43371 @@ -1566,8 +1559,7 @@
43372                         irq->ifr_receiving = (fifocnt!=0) ? 1 : 0;
43373                         break;
43374                 default:
43375 -                       printk(KERN_ERR "%s: notsupp - cmd=%04x\n",
43376 -                               __FUNCTION__, cmd);
43377 +                       WARNING("%s: notsupp - cmd=%04x\n", __FUNCTION__, cmd);
43378                         ret = -EOPNOTSUPP;
43379         }       
43380         
43381 @@ -1583,41 +1575,36 @@
43382         vlsi_irda_dev_t *idev = ndev->priv;
43383         unsigned        iobase;
43384         u8              irintr;
43385 -       int             boguscount = 32;
43386 -       unsigned        got_act;
43387 +       int             boguscount = 5;
43388         unsigned long   flags;
43389         int             handled = 0;
43390  
43391 -       got_act = 0;
43392         iobase = ndev->base_addr;
43393 +       spin_lock_irqsave(&idev->lock,flags);
43394         do {
43395 -               spin_lock_irqsave(&idev->lock,flags);
43396                 irintr = inb(iobase+VLSI_PIO_IRINTR);
43397 -               rmb();
43398 -               outb(irintr, iobase+VLSI_PIO_IRINTR); /* acknowledge asap */
43399 -               spin_unlock_irqrestore(&idev->lock,flags);
43400 +               mb();
43401 +               outb(irintr, iobase+VLSI_PIO_IRINTR);   /* acknowledge asap */
43402  
43403                 if (!(irintr&=IRINTR_INT_MASK))         /* not our INT - probably shared */
43404                         break;
43405 +
43406                 handled = 1;
43407 +
43408 +               if (unlikely(!(irintr & ~IRINTR_ACTIVITY)))
43409 +                       break;                          /* nothing todo if only activity */
43410 +
43411                 if (irintr&IRINTR_RPKTINT)
43412                         vlsi_rx_interrupt(ndev);
43413  
43414                 if (irintr&IRINTR_TPKTINT)
43415                         vlsi_tx_interrupt(ndev);
43416  
43417 -               if (!(irintr & ~IRINTR_ACTIVITY))
43418 -                       break;          /* done if only activity remaining */
43419 -       
43420 -               if (irintr & ~(IRINTR_RPKTINT|IRINTR_TPKTINT|IRINTR_ACTIVITY)) {
43421 -                       printk(KERN_DEBUG "%s: IRINTR = %02x\n",
43422 -                               __FUNCTION__, (unsigned)irintr);
43423 -                       vlsi_reg_debug(iobase,__FUNCTION__);
43424 -               }                       
43425         } while (--boguscount > 0);
43426 +       spin_unlock_irqrestore(&idev->lock,flags);
43427  
43428         if (boguscount <= 0)
43429 -               printk(KERN_WARNING "%s: too much work in interrupt!\n", __FUNCTION__);
43430 +               MESSAGE("%s: too much work in interrupt!\n", __FUNCTION__);
43431         return IRQ_RETVAL(handled);
43432  }
43433  
43434 @@ -1630,7 +1617,7 @@
43435         char    hwname[32];
43436  
43437         if (pci_request_regions(idev->pdev, drivername)) {
43438 -               printk(KERN_ERR "%s: io resource busy\n", __FUNCTION__);
43439 +               WARNING("%s: io resource busy\n", __FUNCTION__);
43440                 goto errout;
43441         }
43442         ndev->base_addr = pci_resource_start(idev->pdev,0);
43443 @@ -1644,8 +1631,7 @@
43444  
43445         if (request_irq(ndev->irq, vlsi_interrupt, SA_SHIRQ,
43446                         drivername, ndev)) {
43447 -               printk(KERN_ERR "%s: couldn't get IRQ: %d\n",
43448 -                       __FUNCTION__, ndev->irq);
43449 +               WARNING("%s: couldn't get IRQ: %d\n", __FUNCTION__, ndev->irq);
43450                 goto errout_io;
43451         }
43452  
43453 @@ -1666,7 +1652,7 @@
43454  
43455         netif_start_queue(ndev);
43456  
43457 -       printk(KERN_INFO "%s: device %s operational\n", __FUNCTION__, ndev->name);
43458 +       MESSAGE("%s: device %s operational\n", __FUNCTION__, ndev->name);
43459  
43460         return 0;
43461  
43462 @@ -1700,7 +1686,7 @@
43463  
43464         pci_release_regions(idev->pdev);
43465  
43466 -       printk(KERN_INFO "%s: device %s stopped\n", __FUNCTION__, ndev->name);
43467 +       MESSAGE("%s: device %s stopped\n", __FUNCTION__, ndev->name);
43468  
43469         return 0;
43470  }
43471 @@ -1721,8 +1707,7 @@
43472  
43473         if (pci_set_dma_mask(pdev,DMA_MASK_USED_BY_HW)
43474             || pci_set_dma_mask(pdev,DMA_MASK_MSTRPAGE)) {
43475 -               printk(KERN_ERR "%s: aborting due to PCI BM-DMA address limitations\n",
43476 -                       __FUNCTION__);
43477 +               ERROR("%s: aborting due to PCI BM-DMA address limitations\n", __FUNCTION__);
43478                 return -1;
43479         }
43480  
43481 @@ -1771,12 +1756,12 @@
43482         else
43483                 pdev->current_state = 0; /* hw must be running now */
43484  
43485 -       printk(KERN_INFO "%s: IrDA PCI controller %s detected\n",
43486 -               drivername, pci_name(pdev));
43487 +       MESSAGE("%s: IrDA PCI controller %s detected\n",
43488 +               drivername, PCIDEV_NAME(pdev));
43489  
43490         if ( !pci_resource_start(pdev,0)
43491              || !(pci_resource_flags(pdev,0) & IORESOURCE_IO) ) {
43492 -               printk(KERN_ERR "%s: bar 0 invalid", __FUNCTION__);
43493 +               ERROR("%s: bar 0 invalid", __FUNCTION__);
43494                 goto out_disable;
43495         }
43496  
43497 @@ -1784,8 +1769,7 @@
43498  
43499         ndev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL);
43500         if (ndev==NULL) {
43501 -               printk(KERN_ERR "%s: Unable to allocate device memory.\n",
43502 -                       __FUNCTION__);
43503 +               ERROR("%s: Unable to allocate device memory.\n", __FUNCTION__);
43504                 goto out_disable;
43505         }
43506  
43507 @@ -1801,37 +1785,33 @@
43508         ndev->init = vlsi_irda_init;
43509         strcpy(ndev->name,"irda%d");
43510         if (register_netdev(ndev)) {
43511 -               printk(KERN_ERR "%s: register_netdev failed\n",
43512 -                       __FUNCTION__);
43513 +               ERROR("%s: register_netdev failed\n", __FUNCTION__);
43514                 goto out_freedev;
43515         }
43516  
43517 +       idev->proc_entry = NULL;
43518         if (vlsi_proc_root != NULL) {
43519                 struct proc_dir_entry *ent;
43520  
43521                 ent = create_proc_entry(ndev->name, S_IFREG|S_IRUGO, vlsi_proc_root);
43522                 if (!ent) {
43523 -                       printk(KERN_ERR "%s: failed to create proc entry\n", __FUNCTION__);
43524 -                       goto out_unregister;
43525 +                       WARNING("%s: failed to create proc entry\n", __FUNCTION__);
43526 +                       idev->proc_entry = NULL;
43527                 }
43528 -               ent->data = ndev;
43529 -               ent->proc_fops = VLSI_PROC_FOPS;
43530 -               ent->size = 0;
43531 -               idev->proc_entry = ent;
43532 -       } else
43533 -               idev->proc_entry = NULL;
43534 -
43535 -       printk(KERN_INFO "%s: registered device %s\n", drivername, ndev->name);
43536 +               else {
43537 +                       ent->data = ndev;
43538 +                       ent->proc_fops = VLSI_PROC_FOPS;
43539 +                       ent->size = 0;
43540 +                       idev->proc_entry = ent;
43541 +               }
43542 +       }
43543 +       MESSAGE("%s: registered device %s\n", drivername, ndev->name);
43544  
43545         pci_set_drvdata(pdev, ndev);
43546         up(&idev->sem);
43547  
43548         return 0;
43549  
43550 -out_unregister:
43551 -       up(&idev->sem);
43552 -       unregister_netdev(ndev);
43553 -       goto out_disable;
43554  out_freedev:
43555         up(&idev->sem);
43556         kfree(ndev);
43557 @@ -1848,14 +1828,12 @@
43558         vlsi_irda_dev_t *idev;
43559  
43560         if (!ndev) {
43561 -               printk(KERN_CRIT "%s: lost netdevice?\n", drivername);
43562 +               ERROR("%s: lost netdevice?\n", drivername);
43563                 return;
43564         }
43565  
43566         idev = ndev->priv;
43567         down(&idev->sem);
43568 -       pci_set_drvdata(pdev, NULL);
43569 -       pci_disable_device(pdev);
43570         if (idev->proc_entry) {
43571                 remove_proc_entry(ndev->name, vlsi_proc_root);
43572                 idev->proc_entry = NULL;
43573 @@ -1867,7 +1845,9 @@
43574          * ndev->destructor called (if present) when going to free
43575          */
43576  
43577 -       printk(KERN_INFO "%s: %s removed\n", drivername, pci_name(pdev));
43578 +       pci_set_drvdata(pdev, NULL);
43579 +
43580 +       MESSAGE("%s: %s removed\n", drivername, PCIDEV_NAME(pdev));
43581  }
43582  
43583  #ifdef CONFIG_PM
43584 @@ -1882,8 +1862,8 @@
43585  static int vlsi_irda_save_state(struct pci_dev *pdev, u32 state)
43586  {
43587         if (state < 1 || state > 3 ) {
43588 -               printk( KERN_ERR "%s - %s: invalid pm state request: %u\n",
43589 -                       __FUNCTION__, pci_name(pdev), state);
43590 +               ERROR("%s - %s: invalid pm state request: %u\n",
43591 +                       __FUNCTION__, PCIDEV_NAME(pdev), state);
43592                 return -1;
43593         }
43594         return 0;
43595 @@ -1895,12 +1875,12 @@
43596         vlsi_irda_dev_t *idev;
43597  
43598         if (state < 1 || state > 3 ) {
43599 -               printk( KERN_ERR "%s - %s: invalid pm state request: %u\n",
43600 -                       __FUNCTION__, pci_name(pdev), state);
43601 +               ERROR("%s - %s: invalid pm state request: %u\n",
43602 +                       __FUNCTION__, PCIDEV_NAME(pdev), state);
43603                 return 0;
43604         }
43605         if (!ndev) {
43606 -               printk(KERN_ERR "%s - %s: no netdevice \n", __FUNCTION__, pci_name(pdev));
43607 +               ERROR("%s - %s: no netdevice \n", __FUNCTION__, PCIDEV_NAME(pdev));
43608                 return 0;
43609         }
43610         idev = ndev->priv;      
43611 @@ -1911,8 +1891,8 @@
43612                         pdev->current_state = state;
43613                 }
43614                 else
43615 -                       printk(KERN_ERR "%s - %s: invalid suspend request %u -> %u\n",
43616 -                               __FUNCTION__, pci_name(pdev), pdev->current_state, state);
43617 +                       ERROR("%s - %s: invalid suspend request %u -> %u\n",
43618 +                               __FUNCTION__, PCIDEV_NAME(pdev), pdev->current_state, state);
43619                 up(&idev->sem);
43620                 return 0;
43621         }
43622 @@ -1939,14 +1919,14 @@
43623         vlsi_irda_dev_t *idev;
43624  
43625         if (!ndev) {
43626 -               printk(KERN_ERR "%s - %s: no netdevice \n", __FUNCTION__, pci_name(pdev));
43627 +               ERROR("%s - %s: no netdevice \n", __FUNCTION__, PCIDEV_NAME(pdev));
43628                 return 0;
43629         }
43630         idev = ndev->priv;      
43631         down(&idev->sem);
43632         if (pdev->current_state == 0) {
43633                 up(&idev->sem);
43634 -               printk(KERN_ERR "%s - %s: already resumed\n", __FUNCTION__, pci_name(pdev));
43635 +               WARNING("%s - %s: already resumed\n", __FUNCTION__, PCIDEV_NAME(pdev));
43636                 return 0;
43637         }
43638         
43639 @@ -1965,7 +1945,7 @@
43640                  * now we explicitly set pdev->current_state = 0 after enabling the
43641                  * device and independently resume_ok should catch any garbage config.
43642                  */
43643 -               printk(KERN_ERR "%s - hm, nothing to resume?\n", __FUNCTION__);
43644 +               WARNING("%s - hm, nothing to resume?\n", __FUNCTION__);
43645                 up(&idev->sem);
43646                 return 0;
43647         }
43648 @@ -2003,7 +1983,7 @@
43649         int     i, ret;
43650  
43651         if (clksrc < 0  ||  clksrc > 3) {
43652 -               printk(KERN_ERR "%s: invalid clksrc=%d\n", drivername, clksrc);
43653 +               ERROR("%s: invalid clksrc=%d\n", drivername, clksrc);
43654                 return -1;
43655         }
43656  
43657 @@ -2016,9 +1996,8 @@
43658                         case 64:
43659                                 break;
43660                         default:
43661 -                               printk(KERN_WARNING "%s: invalid %s ringsize %d",
43662 +                               WARNING("%s: invalid %s ringsize %d, using default=8",
43663                                         drivername, (i)?"rx":"tx", ringsize[i]);
43664 -                               printk(", using default=8\n");
43665                                 ringsize[i] = 8;
43666                                 break;
43667                 }
43668 diff -Nru a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
43669 --- a/drivers/net/ixgb/ixgb_main.c      Tue Aug 19 20:53:16 2003
43670 +++ b/drivers/net/ixgb/ixgb_main.c      Sun Aug 31 08:08:53 2003
43671 @@ -1914,10 +1914,8 @@
43672                 skb->protocol = eth_type_trans(skb, netdev);
43673                 if (adapter->vlgrp
43674                     && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
43675 -                       vlan_hwaccel_rx(skb, adapter->vlgrp,
43676 -                                       (rx_desc->
43677 -                                        special &
43678 -                                        IXGB_RX_DESC_SPECIAL_VLAN_MASK));
43679 +                       vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
43680 +                               (rx_desc-> special & IXGB_RX_DESC_SPECIAL_VLAN_MASK));
43681                 } else {
43682                         netif_receive_skb(skb);
43683                 }
43684 diff -Nru a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
43685 --- a/drivers/net/ne2k-pci.c    Tue Aug 19 20:53:16 2003
43686 +++ b/drivers/net/ne2k-pci.c    Mon Sep  1 10:03:04 2003
43687 @@ -174,7 +174,7 @@
43688                           struct sk_buff *skb, int ring_offset);
43689  static void ne2k_pci_block_output(struct net_device *dev, const int count,
43690                 const unsigned char *buf, const int start_page);
43691 -static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
43692 +static struct ethtool_ops ne2k_pci_ethtool_ops;
43693  
43694  \f
43695  
43696 @@ -259,7 +259,8 @@
43697                 }
43698         }
43699  
43700 -       dev = alloc_etherdev(0);
43701 +       /* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */
43702 +       dev = alloc_ei_netdev();
43703         if (!dev) {
43704                 printk (KERN_ERR PFX "cannot allocate ethernet device\n");
43705                 goto err_out_free_res;
43706 @@ -331,13 +332,6 @@
43707         dev->base_addr = ioaddr;
43708         pci_set_drvdata(pdev, dev);
43709  
43710 -       /* Allocate dev->priv and fill in 8390 specific dev fields. */
43711 -       if (ethdev_init(dev)) {
43712 -               printk (KERN_ERR "ne2kpci(%s): unable to get memory for dev->priv.\n",
43713 -                       pci_name(pdev));
43714 -               goto err_out_free_netdev;
43715 -       }
43716 -
43717         ei_status.name = pci_clone_list[chip_idx].name;
43718         ei_status.tx_start_page = start_page;
43719         ei_status.stop_page = stop_page;
43720 @@ -361,12 +355,12 @@
43721         ei_status.priv = (unsigned long) pdev;
43722         dev->open = &ne2k_pci_open;
43723         dev->stop = &ne2k_pci_close;
43724 -       dev->do_ioctl = &netdev_ioctl;
43725 +       dev->ethtool_ops = &ne2k_pci_ethtool_ops;
43726         NS8390_init(dev, 0);
43727  
43728         i = register_netdev(dev);
43729         if (i)
43730 -               goto err_out_free_8390;
43731 +               goto err_out_free_netdev;
43732  
43733         printk("%s: %s found at %#lx, IRQ %d, ",
43734                    dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq);
43735 @@ -377,10 +371,8 @@
43736  
43737         return 0;
43738  
43739 -err_out_free_8390:
43740 -       kfree(dev->priv);
43741  err_out_free_netdev:
43742 -       kfree (dev);
43743 +       free_netdev (dev);
43744  err_out_free_res:
43745         release_region (ioaddr, NE_IO_EXTENT);
43746         pci_set_drvdata (pdev, NULL);
43747 @@ -591,41 +583,23 @@
43748         return;
43749  }
43750  
43751 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
43752 +static void ne2k_pci_get_drvinfo(struct net_device *dev,
43753 +                                struct ethtool_drvinfo *info)
43754  {
43755         struct ei_device *ei = dev->priv;
43756         struct pci_dev *pci_dev = (struct pci_dev *) ei->priv;
43757 -       u32 ethcmd;
43758 -               
43759 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
43760 -               return -EFAULT;
43761 -
43762 -        switch (ethcmd) {
43763 -        case ETHTOOL_GDRVINFO: {
43764 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
43765 -               strcpy(info.driver, DRV_NAME);
43766 -               strcpy(info.version, DRV_VERSION);
43767 -               strcpy(info.bus_info, pci_name(pci_dev));
43768 -               if (copy_to_user(useraddr, &info, sizeof(info)))
43769 -                       return -EFAULT;
43770 -               return 0;
43771 -       }
43772 -
43773 -        }
43774 -       
43775 -       return -EOPNOTSUPP;
43776 -}
43777  
43778 -static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43779 -{
43780 -       switch(cmd) {
43781 -       case SIOCETHTOOL:
43782 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
43783 -       default:
43784 -               return -EOPNOTSUPP;
43785 -       }
43786 +       strcpy(info->driver, DRV_NAME);
43787 +       strcpy(info->version, DRV_VERSION);
43788 +       strcpy(info->bus_info, pci_name(pci_dev));
43789  }
43790  
43791 +static struct ethtool_ops ne2k_pci_ethtool_ops = {
43792 +       .get_drvinfo            = ne2k_pci_get_drvinfo,
43793 +       .get_tx_csum            = ethtool_op_get_tx_csum,
43794 +       .get_sg                 = ethtool_op_get_sg,
43795 +};
43796 +
43797  static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
43798  {
43799         struct net_device *dev = pci_get_drvdata(pdev);
43800 @@ -635,8 +609,8 @@
43801  
43802         unregister_netdev(dev);
43803         release_region(dev->base_addr, NE_IO_EXTENT);
43804 -       kfree(dev->priv);
43805         free_netdev(dev);
43806 +       pci_disable_device(pdev);
43807         pci_set_drvdata(pdev, NULL);
43808  }
43809  
43810 diff -Nru a/drivers/net/ni5010.c b/drivers/net/ni5010.c
43811 --- a/drivers/net/ni5010.c      Sun Apr 20 23:00:41 2003
43812 +++ b/drivers/net/ni5010.c      Sun Aug 31 16:14:15 2003
43813 @@ -96,6 +96,7 @@
43814         struct net_device_stats stats;
43815         int o_pkt_size;
43816         int i_pkt_size;
43817 +       spinlock_t lock;
43818  };
43819  
43820  /* Index to functions, as function prototypes. */
43821 @@ -280,11 +281,16 @@
43822         /* DMA is not supported (yet?), so no use detecting it */
43823  
43824         if (dev->priv == NULL) {
43825 +               struct ni5010_local* lp;
43826 +
43827                 dev->priv = kmalloc(sizeof(struct ni5010_local), GFP_KERNEL|GFP_DMA);
43828                 if (dev->priv == NULL) {
43829                         printk(KERN_WARNING "%s: Failed to allocate private memory\n", dev->name);
43830                         return -ENOMEM;
43831                 }
43832 +
43833 +               lp = (struct ni5010_local*)dev->priv;
43834 +               spin_lock_init(&lp->lock);
43835         }
43836  
43837         PRINTK2((KERN_DEBUG "%s: I/O #10 passed!\n", dev->name));
43838 @@ -463,6 +469,7 @@
43839         ioaddr = dev->base_addr;
43840         lp = (struct ni5010_local *)dev->priv;
43841         
43842 +       spin_lock(&lp->lock);
43843         status = inb(IE_ISTAT); 
43844         PRINTK3((KERN_DEBUG "%s: IE_ISTAT = %#02x\n", dev->name, status));
43845                 
43846 @@ -479,6 +486,7 @@
43847  
43848         if (!xmit_was_error) 
43849                 reset_receiver(dev); 
43850 +       spin_unlock(&lp->lock);
43851         return IRQ_HANDLED;
43852  }
43853  
43854 @@ -693,8 +701,7 @@
43855          buf_offs = NI5010_BUFSIZE - length - pad;
43856          lp->o_pkt_size = length + pad;
43857  
43858 -       save_flags(flags);      
43859 -       cli();
43860 +       spin_lock_irqsave(&lp->lock, flags);
43861  
43862         outb(0, EDLC_RMASK);    /* Mask all receive interrupts */
43863         outb(0, IE_MMODE);      /* Put Xmit buffer on system bus */
43864 @@ -712,7 +719,7 @@
43865         outb(MM_EN_XMT | MM_MUX, IE_MMODE); /* Begin transmission */
43866         outb(XM_ALL, EDLC_XMASK); /* Cause interrupt after completion or fail */
43867  
43868 -       restore_flags(flags);
43869 +       spin_unlock_irqrestore(&lp->lock, flags);
43870  
43871         netif_wake_queue(dev);
43872         
43873 diff -Nru a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
43874 --- a/drivers/net/pcmcia/3c574_cs.c     Tue Aug 19 20:55:09 2003
43875 +++ b/drivers/net/pcmcia/3c574_cs.c     Sun Aug 31 05:20:57 2003
43876 @@ -253,6 +253,7 @@
43877  static int el3_close(struct net_device *dev);
43878  static void el3_tx_timeout(struct net_device *dev);
43879  static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
43880 +static struct ethtool_ops netdev_ethtool_ops;
43881  static void set_rx_mode(struct net_device *dev);
43882  
43883  static dev_info_t dev_info = "3c574_cs";
43884 @@ -319,6 +320,7 @@
43885         dev->hard_start_xmit = &el3_start_xmit;
43886         dev->get_stats = &el3_get_stats;
43887         dev->do_ioctl = &el3_ioctl;
43888 +       SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
43889         dev->set_multicast_list = &set_rx_mode;
43890         dev->open = &el3_open;
43891         dev->stop = &el3_close;
43892 @@ -1202,26 +1204,16 @@
43893         return worklimit;
43894  }
43895  
43896 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
43897 +static void netdev_get_drvinfo(struct net_device *dev,
43898 +                              struct ethtool_drvinfo *info)
43899  {
43900 -       u32 ethcmd;
43901 -               
43902 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
43903 -               return -EFAULT;
43904 -       
43905 -       switch (ethcmd) {
43906 -       case ETHTOOL_GDRVINFO: {
43907 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
43908 -               strncpy(info.driver, "3c574_cs", sizeof(info.driver)-1);
43909 -               if (copy_to_user(useraddr, &info, sizeof(info)))
43910 -                       return -EFAULT;
43911 -               return 0;
43912 -       }
43913 -       }
43914 -       
43915 -       return -EOPNOTSUPP;
43916 +       strcpy(info->driver, "3c574_cs");
43917  }
43918  
43919 +static struct ethtool_ops netdev_ethtool_ops = {
43920 +       .get_drvinfo            = netdev_get_drvinfo,
43921 +};
43922 +
43923  /* Provide ioctl() calls to examine the MII xcvr state. */
43924  static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43925  {
43926 @@ -1235,11 +1227,9 @@
43927                   data[0], data[1], data[2], data[3]);
43928  
43929         switch(cmd) {
43930 -       case SIOCETHTOOL:
43931 -               return netdev_ethtool_ioctl(dev, (void *)rq->ifr_data);
43932 -       case SIOCDEVPRIVATE:            /* Get the address of the PHY in use. */
43933 +       case SIOCGMIIPHY:               /* Get the address of the PHY in use. */
43934                 data[0] = phy;
43935 -       case SIOCDEVPRIVATE+1:          /* Read the specified MII register. */
43936 +       case SIOCGMIIREG:               /* Read the specified MII register. */
43937                 {
43938                         int saved_window;
43939                         unsigned long flags;
43940 @@ -1252,7 +1242,7 @@
43941                         spin_unlock_irqrestore(&lp->window_lock, flags);
43942                         return 0;
43943                 }
43944 -       case SIOCDEVPRIVATE+2:          /* Write the specified MII register */
43945 +       case SIOCSMIIREG:               /* Write the specified MII register */
43946                 {
43947                         int saved_window;
43948                         unsigned long flags;
43949 diff -Nru a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
43950 --- a/drivers/net/pcmcia/3c589_cs.c     Tue Aug 19 20:55:09 2003
43951 +++ b/drivers/net/pcmcia/3c589_cs.c     Tue Aug 26 14:27:07 2003
43952 @@ -165,7 +165,7 @@
43953  static int el3_close(struct net_device *dev);
43954  static void el3_tx_timeout(struct net_device *dev);
43955  static void set_multicast_list(struct net_device *dev);
43956 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
43957 +static struct ethtool_ops netdev_ethtool_ops;
43958  
43959  static dev_info_t dev_info = "3c589_cs";
43960  
43961 @@ -249,7 +249,7 @@
43962      dev->tx_timeout = el3_tx_timeout;
43963      dev->watchdog_timeo = TX_TIMEOUT;
43964  #endif
43965 -    dev->do_ioctl = netdev_ioctl;
43966 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
43967  
43968      /* Register with Card Services */
43969      link->next = dev_list;
43970 @@ -639,70 +639,33 @@
43971          | AdapterFailure, ioaddr + EL3_CMD);
43972  }
43973  
43974 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
43975 +static void netdev_get_drvinfo(struct net_device *dev,
43976 +                              struct ethtool_drvinfo *info)
43977  {
43978 -       u32 ethcmd;
43979 -
43980 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
43981 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
43982 -
43983 -       if (get_user(ethcmd, (u32 *)useraddr))
43984 -               return -EFAULT;
43985 -
43986 -       switch (ethcmd) {
43987 -
43988 -       case ETHTOOL_GDRVINFO: {
43989 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
43990 -               strcpy (info.driver, DRV_NAME);
43991 -               strcpy (info.version, DRV_VERSION);
43992 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
43993 -               if (copy_to_user (useraddr, &info, sizeof (info)))
43994 -                       return -EFAULT;
43995 -               return 0;
43996 -       }
43997 +       strcpy(info->driver, DRV_NAME);
43998 +       strcpy(info->version, DRV_VERSION);
43999 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
44000 +}
44001  
44002  #ifdef PCMCIA_DEBUG
44003 -       /* get message-level */
44004 -       case ETHTOOL_GMSGLVL: {
44005 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
44006 -               edata.data = pc_debug;
44007 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
44008 -                       return -EFAULT;
44009 -               return 0;
44010 -       }
44011 -       /* set message-level */
44012 -       case ETHTOOL_SMSGLVL: {
44013 -               struct ethtool_value edata;
44014 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
44015 -                       return -EFAULT;
44016 -               pc_debug = edata.data;
44017 -               return 0;
44018 -       }
44019 -#endif
44020 -
44021 -       default:
44022 -               break;
44023 -       }
44024 -
44025 -       return -EOPNOTSUPP;
44026 +static u32 netdev_get_msglevel(struct net_device *dev)
44027 +{
44028 +       return pc_debug;
44029  }
44030  
44031 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
44032 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
44033  {
44034 -       int rc;
44035 -
44036 -       switch (cmd) {
44037 -       case SIOCETHTOOL:
44038 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
44039 -               break;
44040 -
44041 -       default:
44042 -               rc = -EOPNOTSUPP;
44043 -               break;
44044 -       }
44045 -
44046 -       return rc;
44047 +       pc_debug = level;
44048  }
44049 +#endif /* PCMCIA_DEBUG */
44050 +
44051 +static struct ethtool_ops netdev_ethtool_ops = {
44052 +       .get_drvinfo            = netdev_get_drvinfo,
44053 +#ifdef PCMCIA_DEBUG
44054 +       .get_msglevel           = netdev_get_msglevel,
44055 +       .set_msglevel           = netdev_set_msglevel,
44056 +#endif /* PCMCIA_DEBUG */
44057 +};
44058  
44059  static int el3_config(struct net_device *dev, struct ifmap *map)
44060  {
44061 diff -Nru a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
44062 --- a/drivers/net/pcmcia/axnet_cs.c     Tue Aug 19 20:55:09 2003
44063 +++ b/drivers/net/pcmcia/axnet_cs.c     Sun Aug 31 05:20:58 2003
44064 @@ -98,6 +98,7 @@
44065  static int axnet_open(struct net_device *dev);
44066  static int axnet_close(struct net_device *dev);
44067  static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
44068 +static struct ethtool_ops netdev_ethtool_ops;
44069  static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
44070  static void ei_watchdog(u_long arg);
44071  static void axnet_reset_8390(struct net_device *dev);
44072 @@ -209,6 +210,7 @@
44073      dev->open = &axnet_open;
44074      dev->stop = &axnet_close;
44075      dev->do_ioctl = &axnet_ioctl;
44076 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
44077  
44078      /* Register with Card Services */
44079      link->next = dev_list;
44080 @@ -807,26 +809,16 @@
44081      add_timer(&info->watchdog);
44082  }
44083  
44084 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
44085 +static void netdev_get_drvinfo(struct net_device *dev,
44086 +                              struct ethtool_drvinfo *info)
44087  {
44088 -       u32 ethcmd;
44089 -               
44090 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
44091 -               return -EFAULT;
44092 -       
44093 -       switch (ethcmd) {
44094 -       case ETHTOOL_GDRVINFO: {
44095 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
44096 -               strncpy(info.driver, "axnet_cs", sizeof(info.driver)-1);
44097 -               if (copy_to_user(useraddr, &info, sizeof(info)))
44098 -                       return -EFAULT;
44099 -               return 0;
44100 -       }
44101 -       }
44102 -       
44103 -       return -EOPNOTSUPP;
44104 +       strcpy(info->driver, "axnet_cs");
44105  }
44106  
44107 +static struct ethtool_ops netdev_ethtool_ops = {
44108 +       .get_drvinfo            = netdev_get_drvinfo,
44109 +};
44110 +
44111  /*====================================================================*/
44112  
44113  static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44114 @@ -835,14 +827,12 @@
44115      u16 *data = (u16 *)&rq->ifr_data;
44116      ioaddr_t mii_addr = dev->base_addr + AXNET_MII_EEP;
44117      switch (cmd) {
44118 -    case SIOCETHTOOL:
44119 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
44120 -    case SIOCDEVPRIVATE:
44121 +    case SIOCGMIIPHY:
44122         data[0] = info->phy_id;
44123 -    case SIOCDEVPRIVATE+1:
44124 +    case SIOCGMIIREG:          /* Read MII PHY register. */
44125         data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
44126         return 0;
44127 -    case SIOCDEVPRIVATE+2:
44128 +    case SIOCSMIIREG:          /* Write MII PHY register. */
44129         if (!capable(CAP_NET_ADMIN))
44130             return -EPERM;
44131         mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
44132 diff -Nru a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
44133 --- a/drivers/net/pcmcia/fmvj18x_cs.c   Tue Aug 19 20:55:09 2003
44134 +++ b/drivers/net/pcmcia/fmvj18x_cs.c   Tue Aug 26 14:51:25 2003
44135 @@ -113,7 +113,7 @@
44136  static struct net_device_stats *fjn_get_stats(struct net_device *dev);
44137  static void set_rx_mode(struct net_device *dev);
44138  static void fjn_tx_timeout(struct net_device *dev);
44139 -static int fjn_ioctl(struct net_device *, struct ifreq *, int);
44140 +static struct ethtool_ops netdev_ethtool_ops;
44141  
44142  static dev_info_t dev_info = "fmvj18x_cs";
44143  static dev_link_t *dev_list;
44144 @@ -312,7 +312,7 @@
44145      dev->tx_timeout = fjn_tx_timeout;
44146      dev->watchdog_timeo = TX_TIMEOUT;
44147  #endif
44148 -    dev->do_ioctl = fjn_ioctl;
44149 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
44150      
44151      /* Register with Card Services */
44152      link->next = dev_list;
44153 @@ -1186,64 +1186,33 @@
44154  
44155  /*====================================================================*/
44156  
44157 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
44158 +static void netdev_get_drvinfo(struct net_device *dev,
44159 +                              struct ethtool_drvinfo *info)
44160  {
44161 -       u32 ethcmd;
44162 -
44163 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
44164 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
44165 -
44166 -       if (get_user(ethcmd, (u32 *)useraddr))
44167 -               return -EFAULT;
44168 -
44169 -       switch (ethcmd) {
44170 -
44171 -       case ETHTOOL_GDRVINFO: {
44172 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
44173 -               strcpy (info.driver, DRV_NAME);
44174 -               strcpy (info.version, DRV_VERSION);
44175 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
44176 -               if (copy_to_user (useraddr, &info, sizeof (info)))
44177 -                       return -EFAULT;
44178 -               return 0;
44179 -       }
44180 +       strcpy(info->driver, DRV_NAME);
44181 +       strcpy(info->version, DRV_VERSION);
44182 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
44183 +}
44184  
44185  #ifdef PCMCIA_DEBUG
44186 -       /* get message-level */
44187 -       case ETHTOOL_GMSGLVL: {
44188 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
44189 -               edata.data = pc_debug;
44190 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
44191 -                       return -EFAULT;
44192 -               return 0;
44193 -       }
44194 -       /* set message-level */
44195 -       case ETHTOOL_SMSGLVL: {
44196 -               struct ethtool_value edata;
44197 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
44198 -                       return -EFAULT;
44199 -               pc_debug = edata.data;
44200 -               return 0;
44201 -       }
44202 -#endif
44203 -
44204 -       default:
44205 -               break;
44206 -       }
44207 -
44208 -       return -EOPNOTSUPP;
44209 +static u32 netdev_get_msglevel(struct net_device *dev)
44210 +{
44211 +       return pc_debug;
44212  }
44213  
44214 -static int fjn_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44215 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
44216  {
44217 -       switch (cmd) {
44218 -       case SIOCETHTOOL:
44219 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
44220 -
44221 -       default:
44222 -               return -EOPNOTSUPP;
44223 -       }
44224 +       pc_debug = level;
44225  }
44226 +#endif /* PCMCIA_DEBUG */
44227 +
44228 +static struct ethtool_ops netdev_ethtool_ops = {
44229 +       .get_drvinfo            = netdev_get_drvinfo,
44230 +#ifdef PCMCIA_DEBUG
44231 +       .get_msglevel           = netdev_get_msglevel,
44232 +       .set_msglevel           = netdev_set_msglevel,
44233 +#endif /* PCMCIA_DEBUG */
44234 +};
44235  
44236  static int fjn_config(struct net_device *dev, struct ifmap *map){
44237      return 0;
44238 diff -Nru a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
44239 --- a/drivers/net/pcmcia/ibmtr_cs.c     Tue Aug 19 20:55:09 2003
44240 +++ b/drivers/net/pcmcia/ibmtr_cs.c     Tue Aug 26 14:51:25 2003
44241 @@ -157,36 +157,15 @@
44242      }
44243  }
44244  
44245 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
44246 +static void netdev_get_drvinfo(struct net_device *dev,
44247 +                              struct ethtool_drvinfo *info)
44248  {
44249 -       u32 ethcmd;
44250 -               
44251 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
44252 -               return -EFAULT;
44253 -       
44254 -       switch (ethcmd) {
44255 -       case ETHTOOL_GDRVINFO: {
44256 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
44257 -               strncpy(info.driver, "ibmtr_cs", sizeof(info.driver)-1);
44258 -               if (copy_to_user(useraddr, &info, sizeof(info)))
44259 -                       return -EFAULT;
44260 -               return 0;
44261 -       }
44262 -       }
44263 -       
44264 -       return -EOPNOTSUPP;
44265 +       strcpy(info->driver, "ibmtr_cs");
44266  }
44267  
44268 -static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44269 -{
44270 -
44271 -       switch(cmd) {
44272 -       case SIOCETHTOOL:
44273 -              return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
44274 -       default:
44275 -           return -EOPNOTSUPP;
44276 -       }
44277 -}
44278 +static struct ethtool_ops netdev_ethtool_ops = {
44279 +       .get_drvinfo            = netdev_get_drvinfo,
44280 +};
44281  
44282  /*======================================================================
44283  
44284 @@ -235,7 +214,7 @@
44285      link->irq.Instance = info->dev = dev;
44286      
44287      dev->init = &ibmtr_probe;
44288 -    dev->do_ioctl = &private_ioctl;
44289 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
44290  
44291      /* Register with Card Services */
44292      link->next = dev_list;
44293 diff -Nru a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
44294 --- a/drivers/net/pcmcia/nmclan_cs.c    Tue Aug 19 20:55:09 2003
44295 +++ b/drivers/net/pcmcia/nmclan_cs.c    Tue Aug 26 14:51:25 2003
44296 @@ -442,7 +442,8 @@
44297  static int mace_rx(struct net_device *dev, unsigned char RxCnt);
44298  static void restore_multicast_list(struct net_device *dev);
44299  static void set_multicast_list(struct net_device *dev);
44300 -static int mace_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
44301 +static struct ethtool_ops netdev_ethtool_ops;
44302 +
44303  
44304  static dev_link_t *nmclan_attach(void);
44305  static void nmclan_detach(dev_link_t *);
44306 @@ -515,7 +516,7 @@
44307      dev->set_config = &mace_config;
44308      dev->get_stats = &mace_get_stats;
44309      dev->set_multicast_list = &set_multicast_list;
44310 -    dev->do_ioctl = &mace_ioctl;
44311 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
44312      dev->open = &mace_open;
44313      dev->stop = &mace_close;
44314  #ifdef HAVE_TX_TIMEOUT
44315 @@ -1014,65 +1015,33 @@
44316    return 0;
44317  } /* mace_close */
44318  
44319 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
44320 +static void netdev_get_drvinfo(struct net_device *dev,
44321 +                              struct ethtool_drvinfo *info)
44322  {
44323 -       u32 ethcmd;
44324 -
44325 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
44326 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
44327 -
44328 -       if (get_user(ethcmd, (u32 *)useraddr))
44329 -               return -EFAULT;
44330 -
44331 -       switch (ethcmd) {
44332 -
44333 -       case ETHTOOL_GDRVINFO: {
44334 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
44335 -               strcpy (info.driver, DRV_NAME);
44336 -               strcpy (info.version, DRV_VERSION);
44337 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
44338 -               if (copy_to_user (useraddr, &info, sizeof (info)))
44339 -                       return -EFAULT;
44340 -               return 0;
44341 -       }
44342 +       strcpy(info->driver, DRV_NAME);
44343 +       strcpy(info->version, DRV_VERSION);
44344 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
44345 +}
44346  
44347  #ifdef PCMCIA_DEBUG
44348 -       /* get message-level */
44349 -       case ETHTOOL_GMSGLVL: {
44350 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
44351 -               edata.data = pc_debug;
44352 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
44353 -                       return -EFAULT;
44354 -               return 0;
44355 -       }
44356 -       /* set message-level */
44357 -       case ETHTOOL_SMSGLVL: {
44358 -               struct ethtool_value edata;
44359 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
44360 -                       return -EFAULT;
44361 -               pc_debug = edata.data;
44362 -               return 0;
44363 -       }
44364 -#endif
44365 -
44366 -       default:
44367 -               break;
44368 -       }
44369 -
44370 -       return -EOPNOTSUPP;
44371 +static u32 netdev_get_msglevel(struct net_device *dev)
44372 +{
44373 +       return pc_debug;
44374  }
44375  
44376 -static int mace_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44377 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
44378  {
44379 -       switch (cmd) {
44380 -       case SIOCETHTOOL:
44381 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
44382 -
44383 -       default:
44384 -               return -EOPNOTSUPP;
44385 -       }
44386 -       return 0;
44387 +       pc_debug = level;
44388  }
44389 +#endif /* PCMCIA_DEBUG */
44390 +
44391 +static struct ethtool_ops netdev_ethtool_ops = {
44392 +       .get_drvinfo            = netdev_get_drvinfo,
44393 +#ifdef PCMCIA_DEBUG
44394 +       .get_msglevel           = netdev_get_msglevel,
44395 +       .set_msglevel           = netdev_set_msglevel,
44396 +#endif /* PCMCIA_DEBUG */
44397 +};
44398  
44399  /* ----------------------------------------------------------------------------
44400  mace_start_xmit
44401 diff -Nru a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
44402 --- a/drivers/net/pcmcia/pcnet_cs.c     Tue Aug 19 20:55:09 2003
44403 +++ b/drivers/net/pcmcia/pcnet_cs.c     Sun Aug 31 05:20:58 2003
44404 @@ -116,7 +116,7 @@
44405  static int pcnet_open(struct net_device *dev);
44406  static int pcnet_close(struct net_device *dev);
44407  static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
44408 -static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd);
44409 +static struct ethtool_ops netdev_ethtool_ops;
44410  static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
44411  static void ei_watchdog(u_long arg);
44412  static void pcnet_reset_8390(struct net_device *dev);
44413 @@ -756,6 +756,7 @@
44414  
44415      strcpy(info->node.dev_name, dev->name);
44416      link->dev = &info->node;
44417 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
44418  
44419      if (info->flags & (IS_DL10019|IS_DL10022)) {
44420         u_char id = inb(dev->base_addr + 0x1a);
44421 @@ -769,7 +770,6 @@
44422             printk("PNA, ");
44423      } else {
44424         printk(KERN_INFO "%s: NE2000 Compatible: ", dev->name);
44425 -       dev->do_ioctl = &do_ioctl_light;        
44426      }
44427      printk("io %#3lx, irq %d,", dev->base_addr, dev->irq);
44428      if (info->flags & USE_SHMEM)
44429 @@ -1205,26 +1205,16 @@
44430  
44431  /*====================================================================*/
44432  
44433 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
44434 +static void netdev_get_drvinfo(struct net_device *dev,
44435 +                              struct ethtool_drvinfo *info)
44436  {
44437 -       u32 ethcmd;
44438 -       
44439 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
44440 -               return -EFAULT;
44441 -       
44442 -       switch (ethcmd) {
44443 -       case ETHTOOL_GDRVINFO: {
44444 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
44445 -               strncpy(info.driver, "pcnet_cs", sizeof(info.driver)-1);
44446 -               if (copy_to_user(useraddr, &info, sizeof(info)))
44447 -                       return -EFAULT;
44448 -               return 0;
44449 -       }
44450 -       }
44451 -       
44452 -       return -EOPNOTSUPP;
44453 +       strcpy(info->driver, "pcnet_cs");
44454  }
44455  
44456 +static struct ethtool_ops netdev_ethtool_ops = {
44457 +       .get_drvinfo            = netdev_get_drvinfo,
44458 +};
44459 +
44460  /*====================================================================*/
44461  
44462  
44463 @@ -1234,31 +1224,18 @@
44464      u16 *data = (u16 *)&rq->ifr_data;
44465      ioaddr_t mii_addr = dev->base_addr + DLINK_GPIO;
44466      switch (cmd) {
44467 -    case SIOCETHTOOL:
44468 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
44469 -    case SIOCDEVPRIVATE:
44470 +    case SIOCGMIIPHY:
44471         data[0] = info->phy_id;
44472 -    case SIOCDEVPRIVATE+1:
44473 +    case SIOCGMIIREG:          /* Read MII PHY register. */
44474         data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
44475         return 0;
44476 -    case SIOCDEVPRIVATE+2:
44477 +    case SIOCSMIIREG:          /* Write MII PHY register. */
44478         if (!capable(CAP_NET_ADMIN))
44479             return -EPERM;
44480         mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
44481         return 0;
44482      }
44483      return -EOPNOTSUPP;
44484 -}
44485 -
44486 -/*====================================================================*/
44487 -
44488 -static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd)
44489 -{
44490 -    switch (cmd) {
44491 -        case SIOCETHTOOL:
44492 -            return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
44493 -    }      
44494 -    return -EOPNOTSUPP;    
44495  }
44496  
44497  /*====================================================================*/
44498 diff -Nru a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
44499 --- a/drivers/net/pcmcia/xirc2ps_cs.c   Tue Aug 19 20:55:09 2003
44500 +++ b/drivers/net/pcmcia/xirc2ps_cs.c   Sun Aug 31 05:20:58 2003
44501 @@ -382,6 +382,7 @@
44502  static int do_config(struct net_device *dev, struct ifmap *map);
44503  static int do_open(struct net_device *dev);
44504  static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
44505 +static struct ethtool_ops netdev_ethtool_ops;
44506  static void hardreset(struct net_device *dev);
44507  static void do_reset(struct net_device *dev, int full);
44508  static int init_mii(struct net_device *dev);
44509 @@ -626,6 +627,7 @@
44510      dev->set_config = &do_config;
44511      dev->get_stats = &do_get_stats;
44512      dev->do_ioctl = &do_ioctl;
44513 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
44514      dev->set_multicast_list = &set_multicast_list;
44515      dev->open = &do_open;
44516      dev->stop = &do_stop;
44517 @@ -1699,26 +1701,16 @@
44518      return 0;
44519  }
44520  
44521 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
44522 +static void netdev_get_drvinfo(struct net_device *dev,
44523 +                              struct ethtool_drvinfo *info)
44524  {
44525 -       u32 ethcmd;
44526 -               
44527 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
44528 -               return -EFAULT;
44529 -       
44530 -       switch (ethcmd) {
44531 -       case ETHTOOL_GDRVINFO: {
44532 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
44533 -               strncpy(info.driver, "xirc2ps_cs", sizeof(info.driver)-1);
44534 -               if (copy_to_user(useraddr, &info, sizeof(info)))
44535 -                       return -EFAULT;
44536 -               return 0;
44537 -       }
44538 -       }
44539 -       
44540 -       return -EOPNOTSUPP;
44541 +       strcpy(info->driver, "xirc2ps_cs");
44542  }
44543  
44544 +static struct ethtool_ops netdev_ethtool_ops = {
44545 +       .get_drvinfo            = netdev_get_drvinfo,
44546 +};
44547 +
44548  static int
44549  do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44550  {
44551 @@ -1734,15 +1726,13 @@
44552         return -EOPNOTSUPP;
44553  
44554      switch(cmd) {
44555 -      case SIOCETHTOOL:
44556 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
44557 -      case SIOCDEVPRIVATE:     /* Get the address of the PHY in use. */
44558 +      case SIOCGMIIPHY:                /* Get the address of the PHY in use. */
44559         data[0] = 0;            /* we have only this address */
44560         /* fall trough */
44561 -      case SIOCDEVPRIVATE+1:   /* Read the specified MII register. */
44562 +      case SIOCGMIIREG:                /* Read the specified MII register. */
44563         data[3] = mii_rd(ioaddr, data[0] & 0x1f, data[1] & 0x1f);
44564         break;
44565 -      case SIOCDEVPRIVATE+2:   /* Write the specified MII register */
44566 +      case SIOCSMIIREG:                /* Write the specified MII register */
44567         if (!capable(CAP_NET_ADMIN))
44568             return -EPERM;
44569         mii_wr(ioaddr, data[0] & 0x1f, data[1] & 0x1f, data[2], 16);
44570 diff -Nru a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
44571 --- a/drivers/net/pcnet32.c     Tue Aug 19 20:53:16 2003
44572 +++ b/drivers/net/pcnet32.c     Sun Aug 31 16:14:08 2003
44573 @@ -1726,6 +1726,7 @@
44574  /* An additional parameter that may be passed in... */
44575  static int debug = -1;
44576  static int tx_start_pt = -1;
44577 +static int pcnet32_have_pci;
44578  
44579  static int __init pcnet32_init_module(void)
44580  {
44581 @@ -1738,7 +1739,8 @@
44582         tx_start = tx_start_pt;
44583  
44584      /* find the PCI devices */
44585 -    pci_module_init(&pcnet32_driver);
44586 +    if (!pci_module_init(&pcnet32_driver))
44587 +       pcnet32_have_pci = 1;
44588  
44589      /* should we find any remaining VLbus devices ? */
44590      if (pcnet32vlb)
44591 @@ -1747,7 +1749,7 @@
44592      if (cards_found)
44593         printk(KERN_INFO PFX "%d cards_found.\n", cards_found);
44594      
44595 -    return cards_found ? 0 : -ENODEV;
44596 +    return (pcnet32_have_pci + cards_found) ? 0 : -ENODEV;
44597  }
44598  
44599  static void __exit pcnet32_cleanup_module(void)
44600 @@ -1765,6 +1767,9 @@
44601         free_netdev(pcnet32_dev);
44602         pcnet32_dev = next_dev;
44603      }
44604 +
44605 +    if (pcnet32_have_pci)
44606 +       pci_unregister_driver(&pcnet32_driver);
44607  }
44608  
44609  module_init(pcnet32_init_module);
44610 diff -Nru a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
44611 --- a/drivers/net/ppp_async.c   Tue Jul 29 22:37:31 2003
44612 +++ b/drivers/net/ppp_async.c   Wed Sep  3 23:40:16 2003
44613 @@ -84,7 +84,7 @@
44614  MODULE_PARM(flag_time, "i");
44615  MODULE_PARM_DESC(flag_time, "ppp_async: interval between flagged packets (in clock ticks)");
44616  MODULE_LICENSE("GPL");
44617 -
44618 +MODULE_ALIAS_LDISC(N_PPP);
44619  
44620  /*
44621   * Prototypes.
44622 diff -Nru a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
44623 --- a/drivers/net/ppp_generic.c Tue Aug 19 20:58:55 2003
44624 +++ b/drivers/net/ppp_generic.c Wed Sep  3 23:40:14 2003
44625 @@ -2670,3 +2670,4 @@
44626  EXPORT_SYMBOL(all_ppp_units); /* for debugging */
44627  EXPORT_SYMBOL(all_channels); /* for debugging */
44628  MODULE_LICENSE("GPL");
44629 +MODULE_ALIAS_CHARDEV_MAJOR(PPP_MAJOR);
44630 diff -Nru a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
44631 --- a/drivers/net/ppp_synctty.c Sun Apr 27 00:58:13 2003
44632 +++ b/drivers/net/ppp_synctty.c Wed Sep  3 23:40:16 2003
44633 @@ -759,3 +759,4 @@
44634  module_init(ppp_sync_init);
44635  module_exit(ppp_sync_cleanup);
44636  MODULE_LICENSE("GPL");
44637 +MODULE_ALIAS_LDISC(N_SYNC_PPP);
44638 diff -Nru a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
44639 --- a/drivers/net/seeq8005.c    Thu Aug 21 00:05:02 2003
44640 +++ b/drivers/net/seeq8005.c    Sun Aug 31 06:34:16 2003
44641 @@ -378,7 +378,7 @@
44642  {
44643         struct net_local *lp = (struct net_local *)dev->priv;
44644         short length = skb->len;
44645 -       unsigned char *buf = skb->data;
44646 +       unsigned char *buf;
44647  
44648         if (length < ETH_ZLEN) {
44649                 skb = skb_padto(skb, ETH_ZLEN);
44650 @@ -386,6 +386,8 @@
44651                         return 0;
44652                 length = ETH_ZLEN;
44653         }
44654 +       buf = skb->data;
44655 +
44656         /* Block a timer-based transmit from overlapping */
44657         netif_stop_queue(dev);
44658         
44659 diff -Nru a/drivers/net/sis190.c b/drivers/net/sis190.c
44660 --- a/drivers/net/sis190.c      Tue Aug 19 20:53:16 2003
44661 +++ b/drivers/net/sis190.c      Sun Aug 31 14:10:18 2003
44662 @@ -76,6 +76,8 @@
44663  
44664  #define NUM_TX_DESC    64      /* Number of Tx descriptor registers */
44665  #define NUM_RX_DESC    64      /* Number of Rx descriptor registers */
44666 +#define TX_DESC_TOTAL_SIZE     (NUM_TX_DESC * sizeof (struct TxDesc))
44667 +#define RX_DESC_TOTAL_SIZE     (NUM_RX_DESC * sizeof (struct RxDesc))
44668  #define RX_BUF_SIZE    1536    /* Rx Buffer size */
44669  
44670  #define SiS190_MIN_IO_SIZE 0x80
44671 @@ -311,12 +313,8 @@
44672         unsigned long cur_rx;   /* Index into the Rx descriptor buffer of next Rx pkt. */
44673         unsigned long cur_tx;   /* Index into the Tx descriptor buffer of next Rx pkt. */
44674         unsigned long dirty_tx;
44675 -       void *tx_desc_raw;              /* Tx descriptor buffer */
44676 -       dma_addr_t tx_dma_raw;
44677 -       dma_addr_t tx_dma_aligned;
44678 -       void *rx_desc_raw;              /* Rx descriptor buffer */
44679 -       dma_addr_t rx_dma_raw;
44680 -       dma_addr_t rx_dma_aligned;
44681 +       dma_addr_t tx_dma;
44682 +       dma_addr_t rx_dma;
44683         struct TxDesc *TxDescArray;     /* Index of 256-alignment Tx Descriptor buffer */
44684         struct RxDesc *RxDescArray;     /* Index of 256-alignment Rx Descriptor buffer */
44685         unsigned char *RxBufferRings;   /* Index of Rx Buffer  */
44686 @@ -470,6 +468,10 @@
44687         if (rc)
44688                 goto err_out;
44689  
44690 +       rc = pci_set_dma_mask(pdev, 0xffffffffULL);
44691 +       if (rc)
44692 +               goto err_out;
44693 +
44694         mmio_start = pci_resource_start(pdev, 0);
44695         mmio_end = pci_resource_end(pdev, 0);
44696         mmio_flags = pci_resource_flags(pdev, 0);
44697 @@ -521,7 +523,6 @@
44698  
44699  err_out:
44700         pci_disable_device(pdev);
44701 -       unregister_netdev(dev);
44702         kfree(dev);
44703         return rc;
44704  }
44705 @@ -536,6 +537,7 @@
44706         static int printed_version = 0;
44707         int i, rc;
44708         u16 reg31;
44709 +       int val;
44710  
44711         assert(pdev != NULL);
44712         assert(ent != NULL);
44713 @@ -620,7 +622,7 @@
44714                dev->dev_addr[2], dev->dev_addr[3],
44715                dev->dev_addr[4], dev->dev_addr[5], dev->irq);
44716  
44717 -       int val = smdio_read(ioaddr, PHY_AUTO_NEGO_REG);
44718 +       val = smdio_read(ioaddr, PHY_AUTO_NEGO_REG);
44719  
44720         printk(KERN_INFO "%s: Auto-negotiation Enabled.\n", dev->name);
44721  
44722 @@ -714,54 +716,50 @@
44723  SiS190_open(struct net_device *dev)
44724  {
44725         struct sis190_private *tp = dev->priv;
44726 -       int retval;
44727 -       u8 diff;
44728         int rc;
44729  
44730 -       retval =
44731 -           request_irq(dev->irq, SiS190_interrupt, SA_SHIRQ, dev->name, dev);
44732 -       if (retval) {
44733 -               return retval;
44734 -       }
44735 +       rc = request_irq(dev->irq, SiS190_interrupt, SA_SHIRQ, dev->name, dev);
44736 +       if (rc)
44737 +               goto out;
44738  
44739 -       tp->tx_desc_raw = pci_alloc_consistent(tp->pci_dev,
44740 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
44741 -               &tp->tx_dma_raw);
44742 -       if (!tp->tx_desc_raw) {
44743 +       /*
44744 +        * Rx and Tx descriptors need 256 bytes alignment.
44745 +        * pci_alloc_consistent() guarantees a stronger alignment.
44746 +        */
44747 +       tp->TxDescArray = pci_alloc_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE,
44748 +               &tp->tx_dma);
44749 +       if (!tp->TxDescArray) {
44750                 rc = -ENOMEM;
44751                 goto err_out;
44752         }
44753 -       // Tx Desscriptor needs 256 bytes alignment;
44754 -       diff = 256 - (tp->tx_dma_raw - ((tp->tx_dma_raw >> 8) << 8));
44755 -       tp->tx_dma_aligned = tp->tx_dma_raw + diff;
44756 -       tp->TxDescArray = (struct TxDesc *) (tp->tx_desc_raw + diff);
44757 -
44758 -       tp->rx_desc_raw = pci_alloc_consistent(tp->pci_dev,
44759 -               (NUM_RX_DESC * sizeof (struct RxDesc)) + 256,
44760 -               &tp->rx_dma_raw);
44761 -       if (!tp->rx_desc_raw) {
44762 +
44763 +       tp->RxDescArray = pci_alloc_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE,
44764 +               &tp->rx_dma);
44765 +       if (!tp->RxDescArray) {
44766                 rc = -ENOMEM;
44767                 goto err_out_free_tx;
44768         }
44769 -       // Rx Desscriptor needs 256 bytes alignment;
44770 -       diff = 256 - (tp->rx_dma_raw - ((tp->rx_dma_raw >> 8) << 8));
44771 -       tp->rx_dma_aligned = tp->rx_dma_raw + diff;
44772 -       tp->RxDescArray = (struct RxDesc *) (tp->rx_desc_raw + diff);
44773  
44774         tp->RxBufferRings = kmalloc(RX_BUF_SIZE * NUM_RX_DESC, GFP_KERNEL);
44775         if (tp->RxBufferRings == NULL) {
44776 -               printk(KERN_INFO "Allocate RxBufferRing failed\n");
44777 +               printk(KERN_INFO "%s: allocate RxBufferRing failed\n",
44778 +                       dev->name);
44779 +               rc = -ENOMEM;
44780 +               goto err_out_free_rx;
44781         }
44782  
44783         SiS190_init_ring(dev);
44784         SiS190_hw_start(dev);
44785  
44786 -       return 0;
44787 +out:
44788 +       return rc;
44789  
44790 +err_out_free_rx:
44791 +       pci_free_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE, tp->RxDescArray,
44792 +               tp->rx_dma);
44793  err_out_free_tx:
44794 -       pci_free_consistent(tp->pci_dev,
44795 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
44796 -               tp->tx_desc_raw, tp->tx_dma_raw);
44797 +       pci_free_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE, tp->TxDescArray,
44798 +               tp->tx_dma);
44799  err_out:
44800         free_irq(dev->irq, dev);
44801         return rc;
44802 @@ -780,10 +778,10 @@
44803         SiS_W32(IntrControl, 0x0);
44804  
44805         SiS_W32(0x0, 0x01a00);
44806 -       SiS_W32(0x4, tp->tx_dma_aligned);
44807 +       SiS_W32(0x4, tp->tx_dma);
44808  
44809         SiS_W32(0x10, 0x1a00);
44810 -       SiS_W32(0x14, tp->rx_dma_aligned);
44811 +       SiS_W32(0x14, tp->rx_dma);
44812  
44813         SiS_W32(0x20, 0xffffffff);
44814         SiS_W32(0x24, 0x0);
44815 @@ -830,19 +828,19 @@
44816                 tp->Tx_skbuff[i] = NULL;
44817         }
44818         for (i = 0; i < NUM_RX_DESC; i++) {
44819 +               struct RxDesc *desc = tp->RxDescArray + i;
44820  
44821 -               tp->RxDescArray[i].PSize = 0x0;
44822 +               desc->PSize = 0x0;
44823  
44824                 if (i == (NUM_RX_DESC - 1))
44825 -                       tp->RxDescArray[i].buf_Len = BIT_31 + RX_BUF_SIZE;      //bit 31 is End bit
44826 +                       desc->buf_Len = BIT_31 + RX_BUF_SIZE;   //bit 31 is End bit
44827                 else
44828 -                       tp->RxDescArray[i].buf_Len = RX_BUF_SIZE;
44829 -
44830 -#warning Replace virt_to_bus with DMA mapping
44831 -               tp->RxBufferRing[i] = &(tp->RxBufferRings[i * RX_BUF_SIZE]);
44832 -               tp->RxDescArray[i].buf_addr = virt_to_bus(tp->RxBufferRing[i]);
44833 -               tp->RxDescArray[i].status = OWNbit | INTbit;
44834 +                       desc->buf_Len = RX_BUF_SIZE;
44835  
44836 +               tp->RxBufferRing[i] = tp->RxBufferRings + i * RX_BUF_SIZE;
44837 +               desc->buf_addr = pci_map_single(tp->pci_dev,
44838 +                       tp->RxBufferRing[i], RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
44839 +               desc->status = OWNbit | INTbit;
44840         }
44841  
44842  }
44843 @@ -855,7 +853,14 @@
44844         tp->cur_tx = 0;
44845         for (i = 0; i < NUM_TX_DESC; i++) {
44846                 if (tp->Tx_skbuff[i] != NULL) {
44847 -                       dev_kfree_skb(tp->Tx_skbuff[i]);
44848 +                       struct sk_buff *skb;
44849 +
44850 +                       skb = tp->Tx_skbuff[i];
44851 +                       pci_unmap_single(tp->pci_dev,
44852 +                               le32_to_cpu(tp->TxDescArray[i].buf_addr),
44853 +                               skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len,
44854 +                               PCI_DMA_TODEVICE);
44855 +                       dev_kfree_skb(skb);
44856                         tp->Tx_skbuff[i] = NULL;
44857                         tp->stats.tx_dropped++;
44858                 }
44859 @@ -894,46 +899,58 @@
44860         struct sis190_private *tp = dev->priv;
44861         void *ioaddr = tp->mmio_addr;
44862         int entry = tp->cur_tx % NUM_TX_DESC;
44863 +       u32 len;
44864  
44865 -       if (skb->len < ETH_ZLEN) {
44866 +       if (unlikely(skb->len < ETH_ZLEN)) {
44867                 skb = skb_padto(skb, ETH_ZLEN);
44868                 if (skb == NULL)
44869 -                       return 0;
44870 +                       goto drop_tx;
44871 +               len = ETH_ZLEN;
44872 +       } else {
44873 +               len = skb->len;
44874         }
44875  
44876         spin_lock_irq(&tp->lock);
44877  
44878 -       if ((tp->TxDescArray[entry].status & OWNbit) == 0) {
44879 -#warning Replace virt_to_bus with DMA mapping
44880 +       if ((le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit) == 0) {
44881 +               dma_addr_t mapping;
44882 +
44883 +               mapping = pci_map_single(tp->pci_dev, skb->data, len,
44884 +                                        PCI_DMA_TODEVICE);
44885 +
44886                 tp->Tx_skbuff[entry] = skb;
44887 -               tp->TxDescArray[entry].buf_addr = virt_to_bus(skb->data);
44888 -               tp->TxDescArray[entry].PSize =
44889 -                   ((skb->len > ETH_ZLEN) ? skb->len : ETH_ZLEN);
44890 +               tp->TxDescArray[entry].buf_addr = cpu_to_le32(mapping);
44891 +               tp->TxDescArray[entry].PSize = cpu_to_le32(len);
44892  
44893 -               if (entry != (NUM_TX_DESC - 1)) {
44894 -                       tp->TxDescArray[entry].buf_Len =
44895 -                           tp->TxDescArray[entry].PSize;
44896 -               } else {
44897 +               if (entry != (NUM_TX_DESC - 1))
44898 +                       tp->TxDescArray[entry].buf_Len = cpu_to_le32(len);
44899 +               else
44900                         tp->TxDescArray[entry].buf_Len =
44901 -                           tp->TxDescArray[entry].PSize | ENDbit;
44902 -               }
44903 +                               cpu_to_le32(len | ENDbit);
44904  
44905                 tp->TxDescArray[entry].status |=
44906 -                   (OWNbit | INTbit | DEFbit | CRCbit | PADbit);
44907 +                   cpu_to_le32(OWNbit | INTbit | DEFbit | CRCbit | PADbit);
44908  
44909                 SiS_W32(TxControl, 0x1a11);     //Start Send
44910  
44911                 dev->trans_start = jiffies;
44912  
44913                 tp->cur_tx++;
44914 +       } else {
44915 +               spin_unlock_irq(&tp->lock);
44916 +               goto drop_tx;
44917         }
44918  
44919 +       if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
44920 +               netif_stop_queue(dev);
44921 +
44922         spin_unlock_irq(&tp->lock);
44923  
44924 -       if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx) {
44925 -               netif_stop_queue(dev);
44926 -       }
44927 +       return 0;
44928  
44929 +drop_tx:
44930 +       tp->stats.tx_dropped++;
44931 +       dev_kfree_skb(skb);
44932         return 0;
44933  }
44934  
44935 @@ -952,10 +969,18 @@
44936         tx_left = tp->cur_tx - dirty_tx;
44937  
44938         while (tx_left > 0) {
44939 -               if ((tp->TxDescArray[entry].status & OWNbit) == 0) {
44940 -                       dev_kfree_skb_irq(tp->
44941 -                                         Tx_skbuff[dirty_tx % NUM_TX_DESC]);
44942 -                       tp->Tx_skbuff[dirty_tx % NUM_TX_DESC] = NULL;
44943 +               if ((le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit) == 0) {
44944 +                       struct sk_buff *skb;
44945 +
44946 +                       skb = tp->Tx_skbuff[entry];
44947 +
44948 +                       pci_unmap_single(tp->pci_dev,
44949 +                               le32_to_cpu(tp->TxDescArray[entry].buf_addr),
44950 +                               skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len,
44951 +                               PCI_DMA_TODEVICE);
44952 +
44953 +                       dev_kfree_skb_irq(skb);
44954 +                       tp->Tx_skbuff[entry] = NULL;
44955                         tp->stats.tx_packets++;
44956                         dirty_tx++;
44957                         tx_left--;
44958 @@ -965,8 +990,7 @@
44959  
44960         if (tp->dirty_tx != dirty_tx) {
44961                 tp->dirty_tx = dirty_tx;
44962 -               if (netif_queue_stopped(dev))
44963 -                       netif_wake_queue(dev);
44964 +               netif_wake_queue(dev);
44965         }
44966  }
44967  
44968 @@ -974,29 +998,30 @@
44969  SiS190_rx_interrupt(struct net_device *dev, struct sis190_private *tp,
44970                     void *ioaddr)
44971  {
44972 -       int cur_rx;
44973 -       struct sk_buff *skb;
44974 -       int pkt_size = 0;
44975 +       int cur_rx = tp->cur_rx;
44976 +       struct RxDesc *desc = tp->RxDescArray + cur_rx;
44977  
44978         assert(dev != NULL);
44979         assert(tp != NULL);
44980         assert(ioaddr != NULL);
44981  
44982 -       cur_rx = tp->cur_rx;
44983 -       while ((tp->RxDescArray[cur_rx].status & OWNbit) == 0) {
44984 +       while ((desc->status & OWNbit) == 0) {
44985  
44986 -               if (tp->RxDescArray[cur_rx].PSize & 0x0080000) {
44987 +               if (desc->PSize & 0x0080000) {
44988                         printk(KERN_INFO "%s: Rx ERROR!!!\n", dev->name);
44989                         tp->stats.rx_errors++;
44990                         tp->stats.rx_length_errors++;
44991 -               } else if (!(tp->RxDescArray[cur_rx].PSize & 0x0010000)) {
44992 +               } else if (!(desc->PSize & 0x0010000)) {
44993                         printk(KERN_INFO "%s: Rx ERROR!!!\n", dev->name);
44994                         tp->stats.rx_errors++;
44995                         tp->stats.rx_crc_errors++;
44996                 } else {
44997 -                       pkt_size =
44998 -                           (int) (tp->RxDescArray[cur_rx].
44999 -                                  PSize & 0x0000FFFF) - 4;
45000 +                       struct sk_buff *skb;
45001 +                       int pkt_size;
45002 +
45003 +                       pkt_size = (int) (desc->PSize & 0x0000FFFF) - 4;
45004 +                       pci_dma_sync_single(tp->pci_dev, desc->buf_addr,
45005 +                               RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
45006                         skb = dev_alloc_skb(pkt_size + 2);
45007                         if (skb != NULL) {
45008                                 skb->dev = dev;
45009 @@ -1007,24 +1032,18 @@
45010                                 skb->protocol = eth_type_trans(skb, dev);
45011                                 netif_rx(skb);
45012  
45013 -                               tp->RxDescArray[cur_rx].PSize = 0x0;
45014 +                               desc->PSize = 0x0;
45015  
45016                                 if (cur_rx == (NUM_RX_DESC - 1))
45017 -                                       tp->RxDescArray[cur_rx].buf_Len =
45018 -                                           ENDbit + RX_BUF_SIZE;
45019 +                                       desc->buf_Len = ENDbit + RX_BUF_SIZE;
45020                                 else
45021 -                                       tp->RxDescArray[cur_rx].buf_Len =
45022 -                                           RX_BUF_SIZE;
45023 +                                       desc->buf_Len = RX_BUF_SIZE;
45024  
45025 -#warning Replace virt_to_bus with DMA mapping
45026 -                               tp->RxDescArray[cur_rx].buf_addr =
45027 -                                   virt_to_bus(tp->RxBufferRing[cur_rx]);
45028                                 dev->last_rx = jiffies;
45029                                 tp->stats.rx_bytes += pkt_size;
45030                                 tp->stats.rx_packets++;
45031  
45032 -                               tp->RxDescArray[cur_rx].status =
45033 -                                   OWNbit | INTbit;
45034 +                               desc->status = OWNbit | INTbit;
45035                         } else {
45036                                 printk(KERN_WARNING
45037                                        "%s: Memory squeeze, deferring packet.\n",
45038 @@ -1036,7 +1055,7 @@
45039                 }
45040  
45041                 cur_rx = (cur_rx + 1) % NUM_RX_DESC;
45042 -
45043 +               desc = tp->RxDescArray + cur_rx;
45044         }
45045  
45046         tp->cur_rx = cur_rx;
45047 @@ -1111,22 +1130,22 @@
45048  
45049         spin_unlock_irq(&tp->lock);
45050  
45051 -       synchronize_irq();
45052 +       synchronize_irq(dev->irq);
45053         free_irq(dev->irq, dev);
45054  
45055         SiS190_tx_clear(tp);
45056 -       pci_free_consistent(tp->pci_dev,
45057 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
45058 -               tp->tx_desc_raw, tp->tx_dma_raw);
45059 -       pci_free_consistent(tp->pci_dev,
45060 -               (NUM_RX_DESC * sizeof (struct RxDesc)) + 256,
45061 -               tp->rx_desc_raw, tp->rx_dma_raw);
45062 +       pci_free_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE, tp->TxDescArray,
45063 +               tp->tx_dma);
45064 +       pci_free_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE, tp->RxDescArray,
45065 +               tp->rx_dma);
45066         tp->TxDescArray = NULL;
45067 -       tp->RxDescArray = NULL;
45068 -       kfree(tp->RxBufferRings);
45069         for (i = 0; i < NUM_RX_DESC; i++) {
45070 +               pci_unmap_single(tp->pci_dev, tp->RxDescArray[i].buf_addr,
45071 +                       RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
45072                 tp->RxBufferRing[i] = NULL;
45073         }
45074 +       tp->RxDescArray = NULL;
45075 +       kfree(tp->RxBufferRings);
45076  
45077         return 0;
45078  }
45079 diff -Nru a/drivers/net/sis900.c b/drivers/net/sis900.c
45080 --- a/drivers/net/sis900.c      Tue Aug 19 20:53:16 2003
45081 +++ b/drivers/net/sis900.c      Tue Aug 26 16:37:16 2003
45082 @@ -169,6 +169,7 @@
45083         dma_addr_t rx_ring_dma;
45084  
45085         unsigned int tx_full;                   /* The Tx queue is full.    */
45086 +       u8 host_bridge_rev;
45087  };
45088  
45089  MODULE_AUTHOR("Jim Huang <cmhuang@sis.com.tw>, Ollie Lho <ollie@sis.com.tw>");
45090 @@ -210,6 +211,7 @@
45091  static u16 sis900_reset_phy(struct net_device *net_dev, int phy_addr);
45092  static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr);
45093  static void sis900_set_mode (long ioaddr, int speed, int duplex);
45094 +static struct ethtool_ops sis900_ethtool_ops;
45095  
45096  /**
45097   *     sis900_get_mac_addr - Get MAC address for stand alone SiS900 model
45098 @@ -367,6 +369,7 @@
45099  {
45100         struct sis900_private *sis_priv;
45101         struct net_device *net_dev;
45102 +       struct pci_dev *dev;
45103         dma_addr_t ring_dma;
45104         void *ring_space;
45105         long ioaddr;
45106 @@ -440,6 +443,7 @@
45107         net_dev->do_ioctl = &mii_ioctl;
45108         net_dev->tx_timeout = sis900_tx_timeout;
45109         net_dev->watchdog_timeo = TX_TIMEOUT;
45110 +       net_dev->ethtool_ops = &sis900_ethtool_ops;
45111         
45112         ret = register_netdev(net_dev);
45113         if (ret)
45114 @@ -473,6 +477,11 @@
45115                 goto err_out_unregister;
45116         }
45117  
45118 +       /* save our host bridge revision */
45119 +       dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
45120 +       if (dev)
45121 +               pci_read_config_byte(dev, PCI_CLASS_REVISION, &sis_priv->host_bridge_rev);
45122 +
45123         /* print some information about our NIC */
45124         printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ", net_dev->name,
45125                card_name, ioaddr, net_dev->irq);
45126 @@ -1108,18 +1117,12 @@
45127  {
45128         struct sis900_private *sis_priv = net_dev->priv;
45129         u16 reg14h, eq_value=0, max_value=0, min_value=0;
45130 -       u8 host_bridge_rev;
45131         int i, maxcount=10;
45132 -       struct pci_dev *dev=NULL;
45133  
45134         if ( !(revision == SIS630E_900_REV || revision == SIS630EA1_900_REV ||
45135                revision == SIS630A_900_REV || revision ==  SIS630ET_900_REV) )
45136                 return;
45137  
45138 -       dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, dev);
45139 -       if (dev)
45140 -               pci_read_config_byte(dev, PCI_CLASS_REVISION, &host_bridge_rev);
45141 -
45142         if (netif_carrier_ok(net_dev)) {
45143                 reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
45144                 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (0x2200 | reg14h) & 0xBFFF);
45145 @@ -1142,7 +1145,8 @@
45146                 }
45147                 /* 630B0&B1 rule to determine the equalizer value */
45148                 if (revision == SIS630A_900_REV && 
45149 -                   (host_bridge_rev == SIS630B0 || host_bridge_rev == SIS630B1)) {
45150 +                   (sis_priv->host_bridge_rev == SIS630B0 || 
45151 +                    sis_priv->host_bridge_rev == SIS630B1)) {
45152                         if (max_value == 0)
45153                                 eq_value=3;
45154                         else
45155 @@ -1157,7 +1161,8 @@
45156         else {
45157                 reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
45158                 if (revision == SIS630A_900_REV && 
45159 -                   (host_bridge_rev == SIS630B0 || host_bridge_rev == SIS630B1)) 
45160 +                   (sis_priv->host_bridge_rev == SIS630B0 || 
45161 +                    sis_priv->host_bridge_rev == SIS630B1)) 
45162                         mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (reg14h | 0x2200) & 0xBFFF);
45163                 else
45164                         mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (reg14h | 0x2000) & 0xBFFF);
45165 @@ -1853,39 +1858,27 @@
45166  }
45167  
45168  /**
45169 - *     netdev_ethtool_ioctl - For the basic support of ethtool
45170 - *     @net_dev: the net device to command for
45171 - *     @useraddr: start address of interface request
45172 + *     sis900_get_drvinfo - Return information about driver
45173 + *     @net_dev: the net device to probe
45174 + *     @info: container for info returned
45175   *
45176   *     Process ethtool command such as "ehtool -i" to show information
45177   */
45178 -
45179 -static int netdev_ethtool_ioctl (struct net_device *net_dev, void *useraddr)
45180
45181 +static void sis900_get_drvinfo(struct net_device *net_dev,
45182 +                              struct ethtool_drvinfo *info)
45183  {
45184         struct sis900_private *sis_priv = net_dev->priv;
45185 -       u32 ethcmd;
45186  
45187 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
45188 -               return -EFAULT;
45189 -       
45190 -       switch (ethcmd) {
45191 -       case ETHTOOL_GDRVINFO:
45192 -               {
45193 -                       struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
45194 -                       strcpy (info.driver, SIS900_MODULE_NAME);
45195 -                       strcpy (info.version, SIS900_DRV_VERSION);
45196 -                       strcpy (info.bus_info, pci_name(sis_priv->pci_dev));
45197 -                       if (copy_to_user (useraddr, &info, sizeof (info)))
45198 -                               return -EFAULT;
45199 -                       return 0;
45200 -               }
45201 -       default:
45202 -               break;
45203 -       }
45204 -
45205 -       return -EOPNOTSUPP;
45206 +       strcpy (info->driver, SIS900_MODULE_NAME);
45207 +       strcpy (info->version, SIS900_DRV_VERSION);
45208 +       strcpy (info->bus_info, pci_name(sis_priv->pci_dev));
45209  }
45210  
45211 +static struct ethtool_ops sis900_ethtool_ops = {
45212 +       .get_drvinfo =          sis900_get_drvinfo,
45213 +};
45214 +
45215  /**
45216   *     mii_ioctl - process MII i/o control command 
45217   *     @net_dev: the net device to command for
45218 @@ -1901,9 +1894,6 @@
45219         struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
45220  
45221         switch(cmd) {
45222 -       case SIOCETHTOOL:
45223 -               return netdev_ethtool_ioctl(net_dev, (void *) rq->ifr_data);
45224 -
45225         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
45226                 data->phy_id = sis_priv->mii->phy_addr;
45227                 /* Fall Through */
45228 diff -Nru a/drivers/net/sk_mca.c b/drivers/net/sk_mca.c
45229 --- a/drivers/net/sk_mca.c      Fri Jul 25 17:15:35 2003
45230 +++ b/drivers/net/sk_mca.c      Sun Aug 31 22:50:10 2003
45231 @@ -124,7 +124,7 @@
45232  /* dump parts of shared memory - only needed during debugging */
45233  
45234  #ifdef DEBUG
45235 -static void dumpmem(struct SKMCA_NETDEV *dev, u32 start, u32 len)
45236 +static void dumpmem(struct net_device *dev, u32 start, u32 len)
45237  {
45238         int z;
45239  
45240 @@ -217,7 +217,7 @@
45241  
45242  /* reset the whole board */
45243  
45244 -static void ResetBoard(struct SKMCA_NETDEV *dev)
45245 +static void ResetBoard(struct net_device *dev)
45246  {
45247         skmca_priv *priv = (skmca_priv *) dev->priv;
45248  
45249 @@ -228,7 +228,7 @@
45250  
45251  /* wait for LANCE interface to become not busy */
45252  
45253 -static int WaitLANCE(struct SKMCA_NETDEV *dev)
45254 +static int WaitLANCE(struct net_device *dev)
45255  {
45256         skmca_priv *priv = (skmca_priv *) dev->priv;
45257         int t = 0;
45258 @@ -247,7 +247,7 @@
45259  
45260  /* set LANCE register - must be atomic */
45261  
45262 -static void SetLANCE(struct SKMCA_NETDEV *dev, u16 addr, u16 value)
45263 +static void SetLANCE(struct net_device *dev, u16 addr, u16 value)
45264  {
45265         skmca_priv *priv = (skmca_priv *) dev->priv;
45266         unsigned long flags;
45267 @@ -280,12 +280,12 @@
45268  
45269         /* reenable interrupts */
45270  
45271 -       spin_lock_irqrestore(&priv->lock, flags);
45272 +       spin_unlock_irqrestore(&priv->lock, flags);
45273  }
45274  
45275  /* get LANCE register */
45276  
45277 -static u16 GetLANCE(struct SKMCA_NETDEV *dev, u16 addr)
45278 +static u16 GetLANCE(struct net_device *dev, u16 addr)
45279  {
45280         skmca_priv *priv = (skmca_priv *) dev->priv;
45281         unsigned long flags;
45282 @@ -319,14 +319,14 @@
45283  
45284         /* reenable interrupts */
45285  
45286 -       spin_lock_irqrestore(&priv->lock, flags);
45287 +       spin_unlock_irqrestore(&priv->lock, flags);
45288  
45289         return res;
45290  }
45291  
45292  /* build up descriptors in shared RAM */
45293  
45294 -static void InitDscrs(struct SKMCA_NETDEV *dev)
45295 +static void InitDscrs(struct net_device *dev)
45296  {
45297         u32 bufaddr;
45298  
45299 @@ -422,7 +422,7 @@
45300  
45301  /* feed ready-built initialization block into LANCE */
45302  
45303 -static void InitLANCE(struct SKMCA_NETDEV *dev)
45304 +static void InitLANCE(struct net_device *dev)
45305  {
45306         skmca_priv *priv = (skmca_priv *) dev->priv;
45307  
45308 @@ -452,11 +452,7 @@
45309  
45310         /* we don't get ready until the LANCE has read the init block */
45311  
45312 -#if (LINUX_VERSION_CODE >= 0x02032a)
45313         netif_stop_queue(dev);
45314 -#else
45315 -       dev->tbusy = 1;
45316 -#endif
45317  
45318         /* let LANCE read the initialization block.  LANCE is ready
45319            when we receive the corresponding interrupt. */
45320 @@ -466,15 +462,11 @@
45321  
45322  /* stop the LANCE so we can reinitialize it */
45323  
45324 -static void StopLANCE(struct SKMCA_NETDEV *dev)
45325 +static void StopLANCE(struct net_device *dev)
45326  {
45327         /* can't take frames any more */
45328  
45329 -#if (LINUX_VERSION_CODE >= 0x02032a)
45330         netif_stop_queue(dev);
45331 -#else
45332 -       dev->tbusy = 1;
45333 -#endif
45334  
45335         /* disable interrupts, stop it */
45336  
45337 @@ -483,7 +475,7 @@
45338  
45339  /* initialize card and LANCE for proper operation */
45340  
45341 -static void InitBoard(struct SKMCA_NETDEV *dev)
45342 +static void InitBoard(struct net_device *dev)
45343  {
45344         LANCE_InitBlock block;
45345  
45346 @@ -508,7 +500,7 @@
45347  
45348  /* deinitialize card and LANCE */
45349  
45350 -static void DeinitBoard(struct SKMCA_NETDEV *dev)
45351 +static void DeinitBoard(struct net_device *dev)
45352  {
45353         /* stop LANCE */
45354  
45355 @@ -521,7 +513,7 @@
45356  
45357  /* probe for device's irq */
45358  
45359 -static int __init ProbeIRQ(struct SKMCA_NETDEV *dev)
45360 +static int __init ProbeIRQ(struct net_device *dev)
45361  {
45362         unsigned long imaskval, njiffies, irq;
45363         u16 csr0val;
45364 @@ -563,15 +555,11 @@
45365  
45366  /* LANCE has read initialization block -> start it */
45367  
45368 -static u16 irqstart_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
45369 +static u16 irqstart_handler(struct net_device *dev, u16 oldcsr0)
45370  {
45371         /* now we're ready to transmit */
45372  
45373 -#if (LINUX_VERSION_CODE >= 0x02032a)
45374         netif_wake_queue(dev);
45375 -#else
45376 -       dev->tbusy = 0;
45377 -#endif
45378  
45379         /* reset IDON bit, start LANCE */
45380  
45381 @@ -581,7 +569,7 @@
45382  
45383  /* did we lose blocks due to a FIFO overrun ? */
45384  
45385 -static u16 irqmiss_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
45386 +static u16 irqmiss_handler(struct net_device *dev, u16 oldcsr0)
45387  {
45388         skmca_priv *priv = (skmca_priv *) dev->priv;
45389  
45390 @@ -597,7 +585,7 @@
45391  
45392  /* receive interrupt */
45393  
45394 -static u16 irqrx_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
45395 +static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0)
45396  {
45397         skmca_priv *priv = (skmca_priv *) dev->priv;
45398         LANCE_RxDescr descr;
45399 @@ -678,7 +666,7 @@
45400  
45401  /* transmit interrupt */
45402  
45403 -static u16 irqtx_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
45404 +static u16 irqtx_handler(struct net_device *dev, u16 oldcsr0)
45405  {
45406         skmca_priv *priv = (skmca_priv *) dev->priv;
45407         LANCE_TxDescr descr;
45408 @@ -740,12 +728,7 @@
45409            a new one */
45410         /* inform upper layers we're in business again */
45411  
45412 -#if (LINUX_VERSION_CODE >= 0x02032a)
45413         netif_wake_queue(dev);
45414 -#else
45415 -       dev->tbusy = 0;
45416 -       mark_bh(NET_BH);
45417 -#endif
45418  
45419         return oldcsr0;
45420  }
45421 @@ -754,7 +737,7 @@
45422  
45423  static irqreturn_t irq_handler(int irq, void *device, struct pt_regs *regs)
45424  {
45425 -       struct SKMCA_NETDEV *dev = (struct SKMCA_NETDEV *) device;
45426 +       struct net_device *dev = (struct net_device *) device;
45427         u16 csr0val;
45428  
45429         /* read CSR0 to get interrupt cause */
45430 @@ -766,13 +749,9 @@
45431         if ((csr0val & CSR0_INTR) == 0)
45432                 return IRQ_NONE;
45433  
45434 -#if (LINUX_VERSION_CODE >= 0x02032a)
45435  #if 0
45436         set_bit(LINK_STATE_RXSEM, &dev->state);
45437  #endif
45438 -#else
45439 -       dev->interrupt = 1;
45440 -#endif
45441  
45442         /* loop through the interrupt bits until everything is clear */
45443  
45444 @@ -796,13 +775,9 @@
45445         }
45446         while ((csr0val & CSR0_INTR) != 0);
45447  
45448 -#if (LINUX_VERSION_CODE >= 0x02032a)
45449  #if 0
45450         clear_bit(LINK_STATE_RXSEM, &dev->state);
45451  #endif
45452 -#else
45453 -       dev->interrupt = 0;
45454 -#endif
45455         return IRQ_HANDLED;
45456  }
45457  
45458 @@ -815,7 +790,7 @@
45459  static int skmca_getinfo(char *buf, int slot, void *d)
45460  {
45461         int len = 0, i;
45462 -       struct SKMCA_NETDEV *dev = (struct SKMCA_NETDEV *) d;
45463 +       struct net_device *dev = (struct net_device *) d;
45464         skmca_priv *priv;
45465  
45466         /* can't say anything about an uninitialized device... */
45467 @@ -846,7 +821,7 @@
45468  
45469  /* open driver.  Means also initialization and start of LANCE */
45470  
45471 -static int skmca_open(struct SKMCA_NETDEV *dev)
45472 +static int skmca_open(struct net_device *dev)
45473  {
45474         int result;
45475         skmca_priv *priv = (skmca_priv *) dev->priv;
45476 @@ -868,21 +843,14 @@
45477  
45478         /* set up flags */
45479  
45480 -#if (LINUX_VERSION_CODE >= 0x02032a)
45481         netif_start_queue(dev);
45482 -#else
45483 -       dev->interrupt = 0;
45484 -       dev->tbusy = 0;
45485 -       dev->start = 0;
45486 -       MOD_INC_USE_COUNT;
45487 -#endif
45488  
45489         return 0;
45490  }
45491  
45492  /* close driver.  Shut down board and free allocated resources */
45493  
45494 -static int skmca_close(struct SKMCA_NETDEV *dev)
45495 +static int skmca_close(struct net_device *dev)
45496  {
45497         /* turn off board */
45498         DeinitBoard(dev);
45499 @@ -892,16 +860,12 @@
45500                 free_irq(dev->irq, dev);
45501         dev->irq = 0;
45502  
45503 -#if (LINUX_VERSION_CODE < 0x02032a)
45504 -       MOD_DEC_USE_COUNT;
45505 -#endif
45506 -
45507         return 0;
45508  }
45509  
45510  /* transmit a block. */
45511  
45512 -static int skmca_tx(struct sk_buff *skb, struct SKMCA_NETDEV *dev)
45513 +static int skmca_tx(struct sk_buff *skb, struct net_device *dev)
45514  {
45515         skmca_priv *priv = (skmca_priv *) dev->priv;
45516         LANCE_TxDescr descr;
45517 @@ -977,11 +941,7 @@
45518         /* are we saturated ? */
45519  
45520         if (priv->txbusy >= TXCOUNT)
45521 -#if (LINUX_VERSION_CODE >= 0x02032a)
45522                 netif_stop_queue(dev);
45523 -#else
45524 -               dev->tbusy = 1;
45525 -#endif
45526  
45527         /* write descriptor back to RAM */
45528         SKMCA_TOIO(dev->mem_start + address, &descr,
45529 @@ -993,7 +953,7 @@
45530         if (priv->txbusy == 0)
45531                 SetLANCE(dev, LANCE_CSR0, CSR0_INEA | CSR0_TDMD);
45532  
45533 -       spin_lock_irqrestore(&priv->lock, flags);
45534 +       spin_unlock_irqrestore(&priv->lock, flags);
45535  
45536        tx_done:
45537  
45538 @@ -1004,7 +964,7 @@
45539  
45540  /* return pointer to Ethernet statistics */
45541  
45542 -static struct net_device_stats *skmca_stats(struct SKMCA_NETDEV *dev)
45543 +static struct net_device_stats *skmca_stats(struct net_device *dev)
45544  {
45545         skmca_priv *priv = (skmca_priv *) dev->priv;
45546  
45547 @@ -1014,7 +974,7 @@
45548  /* we don't support runtime reconfiguration, since an MCA card can
45549     be unambigously identified by its POS registers. */
45550  
45551 -static int skmca_config(struct SKMCA_NETDEV *dev, struct ifmap *map)
45552 +static int skmca_config(struct net_device *dev, struct ifmap *map)
45553  {
45554         return 0;
45555  }
45556 @@ -1022,7 +982,7 @@
45557  /* switch receiver mode.  We use the LANCE's multicast filter to prefilter
45558     multicast addresses. */
45559  
45560 -static void skmca_set_multicast_list(struct SKMCA_NETDEV *dev)
45561 +static void skmca_set_multicast_list(struct net_device *dev)
45562  {
45563         LANCE_InitBlock block;
45564  
45565 @@ -1062,7 +1022,7 @@
45566  
45567  static int startslot;          /* counts through slots when probing multiple devices */
45568  
45569 -int __init skmca_probe(struct SKMCA_NETDEV *dev)
45570 +int __init skmca_probe(struct net_device *dev)
45571  {
45572         int force_detect = 0;
45573         int junior, slot, i;
45574 @@ -1095,14 +1055,12 @@
45575  
45576                 getaddrs(slot, junior, &base, &irq, &medium);
45577  
45578 -#if LINUX_VERSION_CODE >= 0x020300
45579                 /* slot already in use ? */
45580  
45581                 if (mca_is_adapter_used(slot)) {
45582                         slot = dofind(&junior, slot + 1);
45583                         continue;
45584                 }
45585 -#endif
45586  
45587                 /* were we looking for something different ? */
45588  
45589 @@ -1221,24 +1179,13 @@
45590  
45591  #define DEVMAX 5
45592  
45593 -#if (LINUX_VERSION_CODE >= 0x020369)
45594 -static struct SKMCA_NETDEV moddevs[DEVMAX] =
45595 -    { {"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
45596 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
45597 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
45598 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
45599 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe}
45600 -};
45601 -#else
45602 -static char NameSpace[8 * DEVMAX];
45603 -static struct SKMCA_NETDEV moddevs[DEVMAX] =
45604 -    { {NameSpace + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
45605 -{NameSpace + 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
45606 -{NameSpace + 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
45607 -{NameSpace + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
45608 -{NameSpace + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe}
45609 +static struct net_device moddevs[DEVMAX] = {
45610 +       { .name = "    ", .init = skmca_probe },
45611 +       { .name = "    ", .init = skmca_probe },
45612 +       { .name = "    ", .init = skmca_probe },
45613 +       { .name = "    ", .init = skmca_probe },
45614 +       { .name = "    ", .init = skmca_probe }
45615  };
45616 -#endif
45617  
45618  int irq;
45619  int io;
45620 @@ -1260,7 +1207,7 @@
45621  
45622  void cleanup_module(void)
45623  {
45624 -       struct SKMCA_NETDEV *dev;
45625 +       struct net_device *dev;
45626         skmca_priv *priv;
45627         int z;
45628  
45629 diff -Nru a/drivers/net/sk_mca.h b/drivers/net/sk_mca.h
45630 --- a/drivers/net/sk_mca.h      Tue Jul 15 08:10:44 2003
45631 +++ b/drivers/net/sk_mca.h      Sun Aug 31 08:29:49 2003
45632 @@ -5,7 +5,6 @@
45633  
45634  /* version-dependent functions/structures */
45635  
45636 -#if LINUX_VERSION_CODE >= 0x020318
45637  #define SKMCA_READB(addr) isa_readb(addr)
45638  #define SKMCA_READW(addr) isa_readw(addr)
45639  #define SKMCA_WRITEB(data, addr) isa_writeb(data, addr)
45640 @@ -13,17 +12,6 @@
45641  #define SKMCA_TOIO(dest, src, len) isa_memcpy_toio(dest, src, len)
45642  #define SKMCA_FROMIO(dest, src, len) isa_memcpy_fromio(dest, src, len)
45643  #define SKMCA_SETIO(dest, val, len) isa_memset_io(dest, val, len)
45644 -#define SKMCA_NETDEV net_device
45645 -#else
45646 -#define SKMCA_READB(addr) readb(addr)
45647 -#define SKMCA_READW(addr) readw(addr)
45648 -#define SKMCA_WRITEB(data, addr) writeb(data, addr)
45649 -#define SKMCA_WRITEW(data, addr) writew(data, addr)
45650 -#define SKMCA_TOIO(dest, src, len) memcpy_toio(dest, src, len)
45651 -#define SKMCA_FROMIO(dest, src, len) memcpy_fromio(dest, src, len)
45652 -#define SKMCA_SETIO(dest, val, len) memset_io(dest, val, len)
45653 -#define SKMCA_NETDEV device
45654 -#endif
45655  
45656  /* Adapter ID's */
45657  #define SKNET_MCA_ID 0x6afd
45658 @@ -188,7 +176,7 @@
45659  
45660  #endif                         /* _SK_MCA_DRIVER_ */
45661  
45662 -extern int skmca_probe(struct SKMCA_NETDEV *);
45663 +extern int skmca_probe(struct net_device *);
45664  
45665  
45666  #endif /* _SK_MCA_INCLUDE_ */
45667 diff -Nru a/drivers/net/slip.c b/drivers/net/slip.c
45668 --- a/drivers/net/slip.c        Tue Aug 19 20:58:55 2003
45669 +++ b/drivers/net/slip.c        Wed Sep  3 23:40:16 2003
45670 @@ -1513,3 +1513,4 @@
45671  
45672  #endif
45673  MODULE_LICENSE("GPL");
45674 +MODULE_ALIAS_LDISC(N_SLIP);
45675 diff -Nru a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
45676 --- a/drivers/net/sunbmac.c     Tue Aug 19 20:53:16 2003
45677 +++ b/drivers/net/sunbmac.c     Sun Aug 24 05:58:18 2003
45678 @@ -1,7 +1,7 @@
45679  /* $Id$
45680   * sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters.
45681   *
45682 - * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com)
45683 + * Copyright (C) 1997, 1998, 1999, 2003 David S. Miller (davem@redhat.com)
45684   */
45685  
45686  #include <linux/module.h>
45687 @@ -18,6 +18,7 @@
45688  #include <linux/init.h>
45689  #include <linux/crc32.h>
45690  #include <linux/errno.h>
45691 +#include <linux/ethtool.h>
45692  #include <linux/netdevice.h>
45693  #include <linux/etherdevice.h>
45694  #include <linux/skbuff.h>
45695 @@ -37,7 +38,7 @@
45696  #include "sunbmac.h"
45697  
45698  static char version[] __initdata =
45699 -        "sunbmac.c:v1.9 11/Sep/99 David S. Miller (davem@redhat.com)\n";
45700 +        "sunbmac.c:v2.0 24/Nov/03 David S. Miller (davem@redhat.com)\n";
45701  
45702  #undef DEBUG_PROBE
45703  #undef DEBUG_TX
45704 @@ -1035,6 +1036,33 @@
45705         sbus_writel(tmp, bregs + BMAC_RXCFG);
45706  }
45707  
45708 +/* Ethtool support... */
45709 +static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
45710 +{
45711 +       struct bigmac *bp = dev->priv;
45712 +
45713 +       strcpy(info->driver, "sunbmac");
45714 +       strcpy(info->version, "2.0");
45715 +       sprintf(info->bus_info, "SBUS:%d",
45716 +               bp->qec_sdev->slot);
45717 +}
45718 +
45719 +static u32 bigmac_get_link(struct net_device *dev)
45720 +{
45721 +       struct bigmac *bp = dev->priv;
45722 +
45723 +       spin_lock_irq(&bp->lock);
45724 +       bp->sw_bmsr = bigmac_tcvr_read(bp, bp->tregs, BIGMAC_BMSR);
45725 +       spin_unlock_irq(&bp->lock);
45726 +
45727 +       return (bp->sw_bmsr & BMSR_LSTATUS);
45728 +}
45729 +
45730 +static struct ethtool_ops bigmac_ethtool_ops = {
45731 +       .get_drvinfo            = bigmac_get_drvinfo,
45732 +       .get_link               = bigmac_get_link,
45733 +};
45734 +
45735  static int __init bigmac_ether_init(struct sbus_dev *qec_sdev)
45736  {
45737         struct net_device *dev;
45738 @@ -1169,6 +1197,7 @@
45739         dev->open = &bigmac_open;
45740         dev->stop = &bigmac_close;
45741         dev->hard_start_xmit = &bigmac_start_xmit;
45742 +       dev->ethtool_ops = &bigmac_ethtool_ops;
45743  
45744         /* Set links to BigMAC statistic and multi-cast loading code. */
45745         dev->get_stats = &bigmac_get_stats;
45746 diff -Nru a/drivers/net/sungem.c b/drivers/net/sungem.c
45747 --- a/drivers/net/sungem.c      Tue Aug 19 20:53:16 2003
45748 +++ b/drivers/net/sungem.c      Sun Aug 24 05:58:18 2003
45749 @@ -1,7 +1,7 @@
45750  /* $Id$
45751   * sungem.c: Sun GEM ethernet driver.
45752   *
45753 - * Copyright (C) 2000, 2001, 2002 David S. Miller (davem@redhat.com)
45754 + * Copyright (C) 2000, 2001, 2002, 2003 David S. Miller (davem@redhat.com)
45755   * 
45756   * Support for Apple GMAC and assorted PHYs by
45757   * Benjamin Herrenscmidt (benh@kernel.crashing.org)
45758 @@ -70,8 +70,8 @@
45759                          SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full)
45760  
45761  #define DRV_NAME       "sungem"
45762 -#define DRV_VERSION    "0.97"
45763 -#define DRV_RELDATE    "3/20/02"
45764 +#define DRV_VERSION    "0.98"
45765 +#define DRV_RELDATE    "8/24/03"
45766  #define DRV_AUTHOR     "David S. Miller (davem@redhat.com)"
45767  
45768  static char version[] __devinitdata =
45769 @@ -2317,177 +2317,134 @@
45770         spin_unlock_irq(&gp->lock);
45771  }
45772  
45773 -/* Eventually add support for changing the advertisement
45774 - * on autoneg.
45775 - */
45776 -static int gem_ethtool_ioctl(struct net_device *dev, void *ep_user)
45777 +static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
45778 +{
45779 +       struct gem *gp = dev->priv;
45780 +  
45781 +       strcpy(info->driver, DRV_NAME);
45782 +       strcpy(info->version, DRV_VERSION);
45783 +       strcpy(info->bus_info, pci_name(gp->pdev));
45784 +}
45785 +  
45786 +static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
45787  {
45788         struct gem *gp = dev->priv;
45789 -       struct ethtool_cmd ecmd;
45790 -
45791 -       if (copy_from_user(&ecmd, ep_user, sizeof(ecmd)))
45792 -               return -EFAULT;
45793 -               
45794 -       switch(ecmd.cmd) {
45795 -        case ETHTOOL_GDRVINFO: {
45796 -               struct ethtool_drvinfo info = { .cmd = ETHTOOL_GDRVINFO };
45797 -
45798 -               strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN);
45799 -               strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN);
45800 -               info.fw_version[0] = '\0';
45801 -               strncpy(info.bus_info, pci_name(gp->pdev), ETHTOOL_BUSINFO_LEN);
45802 -               info.regdump_len = 0; /*SUNGEM_NREGS;*/
45803  
45804 -               if (copy_to_user(ep_user, &info, sizeof(info)))
45805 -                       return -EFAULT;
45806 +       if (gp->phy_type == phy_mii_mdio0 ||
45807 +           gp->phy_type == phy_mii_mdio1) {
45808 +               if (gp->phy_mii.def)
45809 +                       cmd->supported = gp->phy_mii.def->features;
45810 +               else
45811 +                       cmd->supported = (SUPPORTED_10baseT_Half |
45812 +                                         SUPPORTED_10baseT_Full);
45813  
45814 -               return 0;
45815 -       }
45816 +               /* XXX hardcoded stuff for now */
45817 +               cmd->port = PORT_MII;
45818 +               cmd->transceiver = XCVR_EXTERNAL;
45819 +               cmd->phy_address = 0; /* XXX fixed PHYAD */
45820  
45821 -       case ETHTOOL_GSET:
45822 -               if (gp->phy_type == phy_mii_mdio0 ||
45823 -                   gp->phy_type == phy_mii_mdio1) {
45824 -                       if (gp->phy_mii.def)
45825 -                               ecmd.supported = gp->phy_mii.def->features;
45826 -                       else
45827 -                               ecmd.supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full;
45828 -
45829 -                       /* XXX hardcoded stuff for now */
45830 -                       ecmd.port = PORT_MII;
45831 -                       ecmd.transceiver = XCVR_EXTERNAL;
45832 -                       ecmd.phy_address = 0; /* XXX fixed PHYAD */
45833 -
45834 -                       /* Return current PHY settings */
45835 -                       spin_lock_irq(&gp->lock);
45836 -                       ecmd.autoneg = gp->want_autoneg;
45837 -                       ecmd.speed = gp->phy_mii.speed;
45838 -                       ecmd.duplex = gp->phy_mii.duplex;                       
45839 -                       ecmd.advertising = gp->phy_mii.advertising;
45840 -                       /* If we started with a forced mode, we don't have a default
45841 -                        * advertise set, we need to return something sensible so
45842 -                        * userland can re-enable autoneg properly */
45843 -                       if (ecmd.advertising == 0)
45844 -                               ecmd.advertising = ecmd.supported;
45845 -                       spin_unlock_irq(&gp->lock);
45846 -               } else { // XXX PCS ?
45847 -                   ecmd.supported =
45848 +               /* Return current PHY settings */
45849 +               spin_lock_irq(&gp->lock);
45850 +               cmd->autoneg = gp->want_autoneg;
45851 +               cmd->speed = gp->phy_mii.speed;
45852 +               cmd->duplex = gp->phy_mii.duplex;                       
45853 +               cmd->advertising = gp->phy_mii.advertising;
45854 +
45855 +               /* If we started with a forced mode, we don't have a default
45856 +                * advertise set, we need to return something sensible so
45857 +                * userland can re-enable autoneg properly.
45858 +                */
45859 +               if (cmd->advertising == 0)
45860 +                       cmd->advertising = cmd->supported;
45861 +               spin_unlock_irq(&gp->lock);
45862 +       } else { // XXX PCS ?
45863 +               cmd->supported =
45864                         (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
45865                          SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
45866                          SUPPORTED_Autoneg);
45867 -                   ecmd.advertising = ecmd.supported;
45868 -               }
45869 -               if (copy_to_user(ep_user, &ecmd, sizeof(ecmd)))
45870 -                       return -EFAULT;
45871 -               return 0;
45872 +               cmd->advertising = cmd->supported;
45873 +               cmd->speed = 0;
45874 +               cmd->duplex = cmd->port = cmd->phy_address =
45875 +                       cmd->transceiver = cmd->autoneg = 0;
45876 +       }
45877 +       cmd->maxtxpkt = cmd->maxrxpkt = 0;
45878  
45879 -       case ETHTOOL_SSET:
45880 -               /* Verify the settings we care about. */
45881 -               if (ecmd.autoneg != AUTONEG_ENABLE &&
45882 -                   ecmd.autoneg != AUTONEG_DISABLE)
45883 -                       return -EINVAL;
45884 -
45885 -               if (ecmd.autoneg == AUTONEG_ENABLE &&
45886 -                   ecmd.advertising == 0)
45887 -                       return -EINVAL;
45888 -
45889 -               if (ecmd.autoneg == AUTONEG_DISABLE &&
45890 -                   ((ecmd.speed != SPEED_1000 &&
45891 -                     ecmd.speed != SPEED_100 &&
45892 -                     ecmd.speed != SPEED_10) ||
45893 -                    (ecmd.duplex != DUPLEX_HALF &&
45894 -                     ecmd.duplex != DUPLEX_FULL)))
45895 -                       return -EINVAL;
45896 -             
45897 -               /* Apply settings and restart link process. */
45898 -               spin_lock_irq(&gp->lock);
45899 -               gem_begin_auto_negotiation(gp, &ecmd);
45900 -               spin_unlock_irq(&gp->lock);
45901 +       return 0;
45902 +}
45903  
45904 -               return 0;
45905 +static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
45906 +{
45907 +       struct gem *gp = dev->priv;
45908  
45909 -       case ETHTOOL_NWAY_RST:
45910 -               if (!gp->want_autoneg)
45911 -                       return -EINVAL;
45912 +       /* Verify the settings we care about. */
45913 +       if (cmd->autoneg != AUTONEG_ENABLE &&
45914 +           cmd->autoneg != AUTONEG_DISABLE)
45915 +               return -EINVAL;
45916  
45917 -               /* Restart link process. */
45918 -               spin_lock_irq(&gp->lock);
45919 -               gem_begin_auto_negotiation(gp, NULL);
45920 -               spin_unlock_irq(&gp->lock);
45921 +       if (cmd->autoneg == AUTONEG_ENABLE &&
45922 +           cmd->advertising == 0)
45923 +               return -EINVAL;
45924  
45925 -               return 0;
45926 +       if (cmd->autoneg == AUTONEG_DISABLE &&
45927 +           ((cmd->speed != SPEED_1000 &&
45928 +             cmd->speed != SPEED_100 &&
45929 +             cmd->speed != SPEED_10) ||
45930 +            (cmd->duplex != DUPLEX_HALF &&
45931 +             cmd->duplex != DUPLEX_FULL)))
45932 +               return -EINVAL;
45933 +             
45934 +       /* Apply settings and restart link process. */
45935 +       spin_lock_irq(&gp->lock);
45936 +       gem_begin_auto_negotiation(gp, cmd);
45937 +       spin_unlock_irq(&gp->lock);
45938  
45939 -       case ETHTOOL_GWOL:
45940 -       case ETHTOOL_SWOL:
45941 -               break; /* todo */
45942 -
45943 -       /* get link status */
45944 -       case ETHTOOL_GLINK: {
45945 -               struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
45946 -
45947 -               edata.data = (gp->lstate == link_up);
45948 -               if (copy_to_user(ep_user, &edata, sizeof(edata)))
45949 -                       return -EFAULT;
45950 -               return 0;
45951 -       }
45952 +       return 0;
45953 +}
45954  
45955 -       /* get message-level */
45956 -       case ETHTOOL_GMSGLVL: {
45957 -               struct ethtool_value edata = { .cmd = ETHTOOL_GMSGLVL };
45958 -
45959 -               edata.data = gp->msg_enable;
45960 -               if (copy_to_user(ep_user, &edata, sizeof(edata)))
45961 -                       return -EFAULT;
45962 -               return 0;
45963 -       }
45964 +static int gem_nway_reset(struct net_device *dev)
45965 +{
45966 +       struct gem *gp = dev->priv;
45967  
45968 -       /* set message-level */
45969 -       case ETHTOOL_SMSGLVL: {
45970 -               struct ethtool_value edata;
45971 -
45972 -               if (copy_from_user(&edata, ep_user, sizeof(edata)))
45973 -                       return -EFAULT;
45974 -               gp->msg_enable = edata.data;
45975 -               return 0;
45976 -       }
45977 +       if (!gp->want_autoneg)
45978 +               return -EINVAL;
45979  
45980 -#if 0
45981 -       case ETHTOOL_GREGS: {
45982 -               struct ethtool_regs regs;
45983 -               u32 *regbuf;
45984 -               int r = 0;
45985 +       /* Restart link process. */
45986 +       spin_lock_irq(&gp->lock);
45987 +       gem_begin_auto_negotiation(gp, NULL);
45988 +       spin_unlock_irq(&gp->lock);
45989  
45990 -               if (copy_from_user(&regs, useraddr, sizeof(regs)))
45991 -                       return -EFAULT;
45992 -               
45993 -               if (regs.len > SUNGEM_NREGS) {
45994 -                       regs.len = SUNGEM_NREGS;
45995 -               }
45996 -               regs.version = 0;
45997 -               if (copy_to_user(useraddr, &regs, sizeof(regs)))
45998 -                       return -EFAULT;
45999 +       return 0;
46000 +}
46001  
46002 -               if (!gp->hw_running)
46003 -                       return -ENODEV;
46004 -               useraddr += offsetof(struct ethtool_regs, data);
46005 +static u32 gem_get_link(struct net_device *dev)
46006 +{
46007 +       struct gem *gp = dev->priv;
46008  
46009 -               /* Use kmalloc to avoid bloating the stack */
46010 -               regbuf = kmalloc(4 * SUNGEM_NREGS, GFP_KERNEL);
46011 -               if (!regbuf)
46012 -                       return -ENOMEM;
46013 -               spin_lock_irq(&np->lock);
46014 -               gem_get_regs(gp, regbuf);
46015 -               spin_unlock_irq(&np->lock);
46016 -
46017 -               if (copy_to_user(useraddr, regbuf, regs.len*sizeof(u32)))
46018 -                       r = -EFAULT;
46019 -               kfree(regbuf);
46020 -               return r;
46021 -       }
46022 -#endif 
46023 -       };
46024 +       return (gp->lstate == link_up);
46025 +}
46026  
46027 -       return -EOPNOTSUPP;
46028 +static u32 gem_get_msglevel(struct net_device *dev)
46029 +{
46030 +       struct gem *gp = dev->priv;
46031 +       return gp->msg_enable;
46032 +}
46033 +  
46034 +static void gem_set_msglevel(struct net_device *dev, u32 value)
46035 +{
46036 +       struct gem *gp = dev->priv;
46037 +       gp->msg_enable = value;
46038  }
46039 +  
46040 +static struct ethtool_ops gem_ethtool_ops = {
46041 +       .get_drvinfo            = gem_get_drvinfo,
46042 +       .get_link               = ethtool_op_get_link,
46043 +       .get_settings           = gem_get_settings,
46044 +       .set_settings           = gem_set_settings,
46045 +       .nway_reset             = gem_nway_reset,
46046 +       .get_link               = gem_get_link,
46047 +       .get_msglevel           = gem_get_msglevel,
46048 +       .set_msglevel           = gem_set_msglevel,
46049 +};
46050  
46051  static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
46052  {
46053 @@ -2501,10 +2458,6 @@
46054         down(&gp->pm_sem);
46055         
46056         switch (cmd) {
46057 -       case SIOCETHTOOL:
46058 -               rc = gem_ethtool_ioctl(dev, ifr->ifr_data);
46059 -               break;
46060 -
46061         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
46062                 data->phy_id = gp->mii_phy_addr;
46063                 /* Fallthrough... */
46064 @@ -2812,6 +2765,7 @@
46065         dev->get_stats = gem_get_stats;
46066         dev->set_multicast_list = gem_set_multicast;
46067         dev->do_ioctl = gem_ioctl;
46068 +       dev->ethtool_ops = &gem_ethtool_ops;
46069         dev->tx_timeout = gem_tx_timeout;
46070         dev->watchdog_timeo = 5 * HZ;
46071         dev->change_mtu = gem_change_mtu;
46072 diff -Nru a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
46073 --- a/drivers/net/sungem_phy.c  Mon May 19 23:38:25 2003
46074 +++ b/drivers/net/sungem_phy.c  Sun Aug 31 16:14:08 2003
46075 @@ -634,116 +634,116 @@
46076  
46077  /* Broadcom BCM 5201 */
46078  static struct mii_phy_ops bcm5201_phy_ops = {
46079 -       init:           bcm5201_init,
46080 -       suspend:        bcm5201_suspend,
46081 -       setup_aneg:     genmii_setup_aneg,
46082 -       setup_forced:   genmii_setup_forced,
46083 -       poll_link:      genmii_poll_link,
46084 -       read_link:      genmii_read_link,
46085 +       .init           = bcm5201_init,
46086 +       .suspend        = bcm5201_suspend,
46087 +       .setup_aneg     = genmii_setup_aneg,
46088 +       .setup_forced   = genmii_setup_forced,
46089 +       .poll_link      = genmii_poll_link,
46090 +       .read_link      = genmii_read_link,
46091  };
46092  
46093  static struct mii_phy_def bcm5201_phy_def = {
46094 -       phy_id:         0x00406210,
46095 -       phy_id_mask:    0xfffffff0,
46096 -       name:           "BCM5201",
46097 -       features:       MII_BASIC_FEATURES,
46098 -       magic_aneg:     0,
46099 -       ops:            &bcm5201_phy_ops
46100 +       .phy_id         = 0x00406210,
46101 +       .phy_id_mask    = 0xfffffff0,
46102 +       .name           = "BCM5201",
46103 +       .features       = MII_BASIC_FEATURES,
46104 +       .magic_aneg     = 0,
46105 +       .ops            = &bcm5201_phy_ops
46106  };
46107  
46108  /* Broadcom BCM 5221 */
46109  static struct mii_phy_ops bcm5221_phy_ops = {
46110 -       suspend:        bcm5201_suspend,
46111 -       init:           bcm5221_init,
46112 -       setup_aneg:     genmii_setup_aneg,
46113 -       setup_forced:   genmii_setup_forced,
46114 -       poll_link:      genmii_poll_link,
46115 -       read_link:      genmii_read_link,
46116 +       .suspend        = bcm5201_suspend,
46117 +       .init           = bcm5221_init,
46118 +       .setup_aneg     = genmii_setup_aneg,
46119 +       .setup_forced   = genmii_setup_forced,
46120 +       .poll_link      = genmii_poll_link,
46121 +       .read_link      = genmii_read_link,
46122  };
46123  
46124  static struct mii_phy_def bcm5221_phy_def = {
46125 -       phy_id:         0x004061e0,
46126 -       phy_id_mask:    0xfffffff0,
46127 -       name:           "BCM5221",
46128 -       features:       MII_BASIC_FEATURES,
46129 -       magic_aneg:     0,
46130 -       ops:            &bcm5221_phy_ops
46131 +       .phy_id         = 0x004061e0,
46132 +       .phy_id_mask    = 0xfffffff0,
46133 +       .name           = "BCM5221",
46134 +       .features       = MII_BASIC_FEATURES,
46135 +       .magic_aneg     = 0,
46136 +       .ops            = &bcm5221_phy_ops
46137  };
46138  
46139  /* Broadcom BCM 5400 */
46140  static struct mii_phy_ops bcm5400_phy_ops = {
46141 -       init:           bcm5400_init,
46142 -       suspend:        bcm5400_suspend,
46143 -       setup_aneg:     bcm54xx_setup_aneg,
46144 -       setup_forced:   bcm54xx_setup_forced,
46145 -       poll_link:      genmii_poll_link,
46146 -       read_link:      bcm54xx_read_link,
46147 +       .init           = bcm5400_init,
46148 +       .suspend        = bcm5400_suspend,
46149 +       .setup_aneg     = bcm54xx_setup_aneg,
46150 +       .setup_forced   = bcm54xx_setup_forced,
46151 +       .poll_link      = genmii_poll_link,
46152 +       .read_link      = bcm54xx_read_link,
46153  };
46154  
46155  static struct mii_phy_def bcm5400_phy_def = {
46156 -       phy_id:         0x00206040,
46157 -       phy_id_mask:    0xfffffff0,
46158 -       name:           "BCM5400",
46159 -       features:       MII_GBIT_FEATURES,
46160 -       magic_aneg:     1,
46161 -       ops:            &bcm5400_phy_ops
46162 +       .phy_id         = 0x00206040,
46163 +       .phy_id_mask    = 0xfffffff0,
46164 +       .name           = "BCM5400",
46165 +       .features       = MII_GBIT_FEATURES,
46166 +       .magic_aneg     = 1,
46167 +       .ops            = &bcm5400_phy_ops
46168  };
46169  
46170  /* Broadcom BCM 5401 */
46171  static struct mii_phy_ops bcm5401_phy_ops = {
46172 -       init:           bcm5401_init,
46173 -       suspend:        bcm5401_suspend,
46174 -       setup_aneg:     bcm54xx_setup_aneg,
46175 -       setup_forced:   bcm54xx_setup_forced,
46176 -       poll_link:      genmii_poll_link,
46177 -       read_link:      bcm54xx_read_link,
46178 +       .init           = bcm5401_init,
46179 +       .suspend        = bcm5401_suspend,
46180 +       .setup_aneg     = bcm54xx_setup_aneg,
46181 +       .setup_forced   = bcm54xx_setup_forced,
46182 +       .poll_link      = genmii_poll_link,
46183 +       .read_link      = bcm54xx_read_link,
46184  };
46185  
46186  static struct mii_phy_def bcm5401_phy_def = {
46187 -       phy_id:         0x00206050,
46188 -       phy_id_mask:    0xfffffff0,
46189 -       name:           "BCM5401",
46190 -       features:       MII_GBIT_FEATURES,
46191 -       magic_aneg:     1,
46192 -       ops:            &bcm5401_phy_ops
46193 +       .phy_id         = 0x00206050,
46194 +       .phy_id_mask    = 0xfffffff0,
46195 +       .name           = "BCM5401",
46196 +       .features       = MII_GBIT_FEATURES,
46197 +       .magic_aneg     = 1,
46198 +       .ops            = &bcm5401_phy_ops
46199  };
46200  
46201  /* Broadcom BCM 5411 */
46202  static struct mii_phy_ops bcm5411_phy_ops = {
46203 -       init:           bcm5411_init,
46204 -       suspend:        bcm5411_suspend,
46205 -       setup_aneg:     bcm54xx_setup_aneg,
46206 -       setup_forced:   bcm54xx_setup_forced,
46207 -       poll_link:      genmii_poll_link,
46208 -       read_link:      bcm54xx_read_link,
46209 +       .init           = bcm5411_init,
46210 +       .suspend        = bcm5411_suspend,
46211 +       .setup_aneg     = bcm54xx_setup_aneg,
46212 +       .setup_forced   = bcm54xx_setup_forced,
46213 +       .poll_link      = genmii_poll_link,
46214 +       .read_link      = bcm54xx_read_link,
46215  };
46216  
46217  static struct mii_phy_def bcm5411_phy_def = {
46218 -       phy_id:         0x00206070,
46219 -       phy_id_mask:    0xfffffff0,
46220 -       name:           "BCM5411",
46221 -       features:       MII_GBIT_FEATURES,
46222 -       magic_aneg:     1,
46223 -       ops:            &bcm5411_phy_ops
46224 +       .phy_id         = 0x00206070,
46225 +       .phy_id_mask    = 0xfffffff0,
46226 +       .name           = "BCM5411",
46227 +       .features       = MII_GBIT_FEATURES,
46228 +       .magic_aneg     = 1,
46229 +       .ops            = &bcm5411_phy_ops
46230  };
46231  
46232  /* Broadcom BCM 5421 */
46233  static struct mii_phy_ops bcm5421_phy_ops = {
46234 -       init:           bcm5421_init,
46235 -       suspend:        bcm5411_suspend,
46236 -       setup_aneg:     bcm54xx_setup_aneg,
46237 -       setup_forced:   bcm54xx_setup_forced,
46238 -       poll_link:      genmii_poll_link,
46239 -       read_link:      bcm54xx_read_link,
46240 +       .init           = bcm5421_init,
46241 +       .suspend        = bcm5411_suspend,
46242 +       .setup_aneg     = bcm54xx_setup_aneg,
46243 +       .setup_forced   = bcm54xx_setup_forced,
46244 +       .poll_link      = genmii_poll_link,
46245 +       .read_link      = bcm54xx_read_link,
46246  };
46247  
46248  static struct mii_phy_def bcm5421_phy_def = {
46249 -       phy_id:         0x002060e0,
46250 -       phy_id_mask:    0xfffffff0,
46251 -       name:           "BCM5421",
46252 -       features:       MII_GBIT_FEATURES,
46253 -       magic_aneg:     1,
46254 -       ops:            &bcm5421_phy_ops
46255 +       .phy_id         = 0x002060e0,
46256 +       .phy_id_mask    = 0xfffffff0,
46257 +       .name           = "BCM5421",
46258 +       .features       = MII_GBIT_FEATURES,
46259 +       .magic_aneg     = 1,
46260 +       .ops            = &bcm5421_phy_ops
46261  };
46262  
46263  /* Marvell 88E1101 (Apple seem to deal with 2 different revs,
46264 @@ -751,36 +751,36 @@
46265   * would be useful here) --BenH.
46266   */
46267  static struct mii_phy_ops marvell_phy_ops = {
46268 -       setup_aneg:     marvell_setup_aneg,
46269 -       setup_forced:   marvell_setup_forced,
46270 -       poll_link:      genmii_poll_link,
46271 -       read_link:      marvell_read_link
46272 +       .setup_aneg     = marvell_setup_aneg,
46273 +       .setup_forced   = marvell_setup_forced,
46274 +       .poll_link      = genmii_poll_link,
46275 +       .read_link      = marvell_read_link
46276  };
46277  
46278  static struct mii_phy_def marvell_phy_def = {
46279 -       phy_id:         0x01410c00,
46280 -       phy_id_mask:    0xffffff00,
46281 -       name:           "Marvell 88E1101",
46282 -       features:       MII_GBIT_FEATURES,
46283 -       magic_aneg:     1,
46284 -       ops:            &marvell_phy_ops
46285 +       .phy_id         = 0x01410c00,
46286 +       .phy_id_mask    = 0xffffff00,
46287 +       .name           = "Marvell 88E1101",
46288 +       .features       = MII_GBIT_FEATURES,
46289 +       .magic_aneg     = 1,
46290 +       .ops            = &marvell_phy_ops
46291  };
46292  
46293  /* Generic implementation for most 10/100 PHYs */
46294  static struct mii_phy_ops generic_phy_ops = {
46295 -       setup_aneg:     genmii_setup_aneg,
46296 -       setup_forced:   genmii_setup_forced,
46297 -       poll_link:      genmii_poll_link,
46298 -       read_link:      genmii_read_link
46299 +       .setup_aneg     = genmii_setup_aneg,
46300 +       .setup_forced   = genmii_setup_forced,
46301 +       .poll_link      = genmii_poll_link,
46302 +       .read_link      = genmii_read_link
46303  };
46304  
46305  static struct mii_phy_def genmii_phy_def = {
46306 -       phy_id:         0x00000000,
46307 -       phy_id_mask:    0x00000000,
46308 -       name:           "Generic MII",
46309 -       features:       MII_BASIC_FEATURES,
46310 -       magic_aneg:     0,
46311 -       ops:            &generic_phy_ops
46312 +       .phy_id         = 0x00000000,
46313 +       .phy_id_mask    = 0x00000000,
46314 +       .name           = "Generic MII",
46315 +       .features       = MII_BASIC_FEATURES,
46316 +       .magic_aneg     = 0,
46317 +       .ops            = &generic_phy_ops
46318  };
46319  
46320  static struct mii_phy_def* mii_phy_table[] = {
46321 diff -Nru a/drivers/net/sunhme.c b/drivers/net/sunhme.c
46322 --- a/drivers/net/sunhme.c      Tue Aug 19 20:53:16 2003
46323 +++ b/drivers/net/sunhme.c      Tue Sep  2 04:22:42 2003
46324 @@ -3,7 +3,7 @@
46325   *           auto carrier detecting ethernet driver.  Also known as the
46326   *           "Happy Meal Ethernet" found on SunSwift SBUS cards.
46327   *
46328 - * Copyright (C) 1996, 1998, 1999, 2002 David S. Miller (davem@redhat.com)
46329 + * Copyright (C) 1996, 1998, 1999, 2002, 2003 David S. Miller (davem@redhat.com)
46330   *
46331   * Changes :
46332   * 2000/11/11 Willy Tarreau <willy AT meta-x.org>
46333 @@ -14,10 +14,10 @@
46334   */
46335  
46336  static char version[] =
46337 -        "sunhme.c:v2.01 26/Mar/2002 David S. Miller (davem@redhat.com)\n";
46338 +        "sunhme.c:v2.02 24/Aug/2003 David S. Miller (davem@redhat.com)\n";
46339  
46340 -#include <linux/module.h>
46341  #include <linux/config.h>
46342 +#include <linux/module.h>
46343  #include <linux/kernel.h>
46344  #include <linux/types.h>
46345  #include <linux/fcntl.h>
46346 @@ -2426,85 +2426,112 @@
46347  }
46348  
46349  /* Ethtool support... */
46350 -static int happy_meal_ioctl(struct net_device *dev,
46351 -                           struct ifreq *rq, int cmd)
46352 +static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
46353  {
46354         struct happy_meal *hp = dev->priv;
46355 -       struct ethtool_cmd *ep_user = (struct ethtool_cmd *) rq->ifr_data;
46356 -       struct ethtool_cmd ecmd;
46357  
46358 -       if (cmd != SIOCETHTOOL)
46359 -               return -EOPNOTSUPP;
46360 -       if (copy_from_user(&ecmd, ep_user, sizeof(ecmd)))
46361 -               return -EFAULT;
46362 -
46363 -       if (ecmd.cmd == ETHTOOL_GSET) {
46364 -               ecmd.supported =
46365 -                       (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
46366 -                        SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
46367 -                        SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
46368 -
46369 -               /* XXX hardcoded stuff for now */
46370 -               ecmd.port = PORT_TP; /* XXX no MII support */
46371 -               ecmd.transceiver = XCVR_INTERNAL; /* XXX no external xcvr support */
46372 -               ecmd.phy_address = 0; /* XXX fixed PHYAD */
46373 -
46374 -               /* Record PHY settings. */
46375 -               spin_lock_irq(&hp->happy_lock);
46376 -               hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
46377 -               hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA);
46378 -               spin_unlock_irq(&hp->happy_lock);
46379 +       cmd->supported =
46380 +               (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
46381 +                SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
46382 +                SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
46383 +
46384 +       /* XXX hardcoded stuff for now */
46385 +       cmd->port = PORT_TP; /* XXX no MII support */
46386 +       cmd->transceiver = XCVR_INTERNAL; /* XXX no external xcvr support */
46387 +       cmd->phy_address = 0; /* XXX fixed PHYAD */
46388  
46389 -               if (hp->sw_bmcr & BMCR_ANENABLE) {
46390 -                       ecmd.autoneg = AUTONEG_ENABLE;
46391 -                       ecmd.speed =
46392 -                               (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
46393 -                               SPEED_100 : SPEED_10;
46394 -                       if (ecmd.speed == SPEED_100)
46395 -                               ecmd.duplex =
46396 -                                       (hp->sw_lpa & (LPA_100FULL)) ?
46397 -                                       DUPLEX_FULL : DUPLEX_HALF;
46398 -                       else
46399 -                               ecmd.duplex =
46400 -                                       (hp->sw_lpa & (LPA_10FULL)) ?
46401 -                                       DUPLEX_FULL : DUPLEX_HALF;
46402 -               } else {
46403 -                       ecmd.autoneg = AUTONEG_DISABLE;
46404 -                       ecmd.speed =
46405 -                               (hp->sw_bmcr & BMCR_SPEED100) ?
46406 -                               SPEED_100 : SPEED_10;
46407 -                       ecmd.duplex =
46408 -                               (hp->sw_bmcr & BMCR_FULLDPLX) ?
46409 +       /* Record PHY settings. */
46410 +       spin_lock_irq(&hp->happy_lock);
46411 +       hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
46412 +       hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA);
46413 +       spin_unlock_irq(&hp->happy_lock);
46414 +
46415 +       if (hp->sw_bmcr & BMCR_ANENABLE) {
46416 +               cmd->autoneg = AUTONEG_ENABLE;
46417 +               cmd->speed =
46418 +                       (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
46419 +                       SPEED_100 : SPEED_10;
46420 +               if (cmd->speed == SPEED_100)
46421 +                       cmd->duplex =
46422 +                               (hp->sw_lpa & (LPA_100FULL)) ?
46423                                 DUPLEX_FULL : DUPLEX_HALF;
46424 -               }
46425 -               if (copy_to_user(ep_user, &ecmd, sizeof(ecmd)))
46426 -                       return -EFAULT;
46427 -               return 0;
46428 -       } else if (ecmd.cmd == ETHTOOL_SSET) {
46429 -               /* Verify the settings we care about. */
46430 -               if (ecmd.autoneg != AUTONEG_ENABLE &&
46431 -                   ecmd.autoneg != AUTONEG_DISABLE)
46432 -                       return -EINVAL;
46433 -               if (ecmd.autoneg == AUTONEG_DISABLE &&
46434 -                   ((ecmd.speed != SPEED_100 &&
46435 -                     ecmd.speed != SPEED_10) ||
46436 -                    (ecmd.duplex != DUPLEX_HALF &&
46437 -                     ecmd.duplex != DUPLEX_FULL)))
46438 -                       return -EINVAL;
46439 -
46440 -               /* Ok, do it to it. */
46441 -               spin_lock_irq(&hp->happy_lock);
46442 -               del_timer(&hp->happy_timer);
46443 -               happy_meal_begin_auto_negotiation(hp,
46444 -                                                 hp->tcvregs,
46445 -                                                 &ecmd);
46446 -               spin_unlock_irq(&hp->happy_lock);
46447 +               else
46448 +                       cmd->duplex =
46449 +                               (hp->sw_lpa & (LPA_10FULL)) ?
46450 +                               DUPLEX_FULL : DUPLEX_HALF;
46451 +       } else {
46452 +               cmd->autoneg = AUTONEG_DISABLE;
46453 +               cmd->speed =
46454 +                       (hp->sw_bmcr & BMCR_SPEED100) ?
46455 +                       SPEED_100 : SPEED_10;
46456 +               cmd->duplex =
46457 +                       (hp->sw_bmcr & BMCR_FULLDPLX) ?
46458 +                       DUPLEX_FULL : DUPLEX_HALF;
46459 +       }
46460 +       return 0;
46461 +}
46462  
46463 -               return 0;
46464 -       } else
46465 -               return -EOPNOTSUPP;
46466 +static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
46467 +{
46468 +       struct happy_meal *hp = dev->priv;
46469 +
46470 +       /* Verify the settings we care about. */
46471 +       if (cmd->autoneg != AUTONEG_ENABLE &&
46472 +           cmd->autoneg != AUTONEG_DISABLE)
46473 +               return -EINVAL;
46474 +       if (cmd->autoneg == AUTONEG_DISABLE &&
46475 +           ((cmd->speed != SPEED_100 &&
46476 +             cmd->speed != SPEED_10) ||
46477 +            (cmd->duplex != DUPLEX_HALF &&
46478 +             cmd->duplex != DUPLEX_FULL)))
46479 +               return -EINVAL;
46480 +
46481 +       /* Ok, do it to it. */
46482 +       spin_lock_irq(&hp->happy_lock);
46483 +       del_timer(&hp->happy_timer);
46484 +       happy_meal_begin_auto_negotiation(hp, hp->tcvregs, cmd);
46485 +       spin_unlock_irq(&hp->happy_lock);
46486 +
46487 +       return 0;
46488  }
46489  
46490 +static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
46491 +{
46492 +       struct happy_meal *hp = dev->priv;
46493 +
46494 +       strcpy(info->driver, "sunhme");
46495 +       strcpy(info->version, "2.02");
46496 +       if (hp->happy_flags & HFLAG_PCI) {
46497 +               struct pci_dev *pdev = hp->happy_dev;
46498 +               strcpy(info->bus_info, pci_name(pdev));
46499 +       }
46500 +#ifdef CONFIG_SBUS
46501 +       else {
46502 +               struct sbus_dev *sdev = hp->happy_dev;
46503 +               sprintf(info->bus_info, "SBUS:%d",
46504 +                       sdev->slot);
46505 +       }
46506 +#endif
46507 +}
46508 +
46509 +static u32 hme_get_link(struct net_device *dev)
46510 +{
46511 +       struct happy_meal *hp = dev->priv;
46512 +
46513 +       spin_lock_irq(&hp->happy_lock);
46514 +       hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
46515 +       spin_unlock_irq(&hp->happy_lock);
46516 +
46517 +       return (hp->sw_bmsr & BMSR_LSTATUS);
46518 +}
46519 +
46520 +static struct ethtool_ops hme_ethtool_ops = {
46521 +       .get_settings           = hme_get_settings,
46522 +       .set_settings           = hme_set_settings,
46523 +       .get_drvinfo            = hme_get_drvinfo,
46524 +       .get_link               = hme_get_link,
46525 +};
46526 +
46527  static int hme_version_printed;
46528  
46529  #ifdef CONFIG_SBUS
46530 @@ -2797,7 +2824,7 @@
46531         dev->set_multicast_list = &happy_meal_set_multicast;
46532         dev->tx_timeout = &happy_meal_tx_timeout;
46533         dev->watchdog_timeo = 5*HZ;
46534 -       dev->do_ioctl = &happy_meal_ioctl;
46535 +       dev->ethtool_ops = &hme_ethtool_ops;
46536  
46537         /* Happy Meal can do it all... except VLAN. */
46538         dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_VLAN_CHALLENGED;
46539 @@ -3141,7 +3168,7 @@
46540         dev->set_multicast_list = &happy_meal_set_multicast;
46541         dev->tx_timeout = &happy_meal_tx_timeout;
46542         dev->watchdog_timeo = 5*HZ;
46543 -       dev->do_ioctl = &happy_meal_ioctl;
46544 +       dev->ethtool_ops = &hme_ethtool_ops;
46545         dev->irq = pdev->irq;
46546         dev->dma = 0;
46547  
46548 diff -Nru a/drivers/net/sunlance.c b/drivers/net/sunlance.c
46549 --- a/drivers/net/sunlance.c    Tue Aug 19 20:53:17 2003
46550 +++ b/drivers/net/sunlance.c    Sun Aug 24 05:58:18 2003
46551 @@ -70,7 +70,7 @@
46552  #undef DEBUG_DRIVER
46553  
46554  static char version[] =
46555 -       "sunlance.c:v2.01 08/Nov/01 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
46556 +       "sunlance.c:v2.02 24/Aug/03 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
46557  
46558  static char lancestr[] = "LANCE";
46559  
46560 @@ -93,6 +93,7 @@
46561  #include <linux/netdevice.h>
46562  #include <linux/etherdevice.h>
46563  #include <linux/skbuff.h>
46564 +#include <linux/ethtool.h>
46565  
46566  #include <asm/system.h>
46567  #include <asm/bitops.h>
46568 @@ -1287,6 +1288,30 @@
46569         }
46570  }
46571  
46572 +/* Ethtool support... */
46573 +static void sparc_lance_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
46574 +{
46575 +       struct lance_private *lp = dev->priv;
46576 +
46577 +       strcpy(info->driver, "sunlance");
46578 +       strcpy(info->version, "2.02");
46579 +       sprintf(info->bus_info, "SBUS:%d",
46580 +               lp->sdev->slot);
46581 +}
46582 +
46583 +static u32 sparc_lance_get_link(struct net_device *dev)
46584 +{
46585 +       /* We really do not keep track of this, but this
46586 +        * is better than not reporting anything at all.
46587 +        */
46588 +       return 1;
46589 +}
46590 +
46591 +static struct ethtool_ops sparc_lance_ethtool_ops = {
46592 +       .get_drvinfo            = sparc_lance_get_drvinfo,
46593 +       .get_link               = sparc_lance_get_link,
46594 +};
46595 +
46596  static int __init sparc_lance_init(struct net_device *dev,
46597                                    struct sbus_dev *sdev,
46598                                    struct sbus_dma *ledma,
46599 @@ -1456,6 +1481,7 @@
46600         dev->watchdog_timeo = 5*HZ;
46601         dev->get_stats = &lance_get_stats;
46602         dev->set_multicast_list = &lance_set_multicast;
46603 +       dev->ethtool_ops = &sparc_lance_ethtool_ops;
46604  
46605         dev->irq = sdev->irqs[0];
46606  
46607 diff -Nru a/drivers/net/sunqe.c b/drivers/net/sunqe.c
46608 --- a/drivers/net/sunqe.c       Tue Aug 19 20:53:17 2003
46609 +++ b/drivers/net/sunqe.c       Sun Aug 24 05:58:18 2003
46610 @@ -4,11 +4,11 @@
46611   *          controller out there can be most efficiently programmed
46612   *          if you make it look like a LANCE.
46613   *
46614 - * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com)
46615 + * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com)
46616   */
46617  
46618  static char version[] =
46619 -        "sunqe.c:v2.9 9/11/99 David S. Miller (davem@redhat.com)\n";
46620 +        "sunqe.c:v3.0 8/24/03 David S. Miller (davem@redhat.com)\n";
46621  
46622  #include <linux/module.h>
46623  #include <linux/kernel.h>
46624 @@ -26,6 +26,7 @@
46625  #include <linux/netdevice.h>
46626  #include <linux/etherdevice.h>
46627  #include <linux/skbuff.h>
46628 +#include <linux/ethtool.h>
46629  
46630  #include <asm/system.h>
46631  #include <asm/bitops.h>
46632 @@ -684,6 +685,35 @@
46633         netif_wake_queue(dev);
46634  }
46635  
46636 +/* Ethtool support... */
46637 +static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
46638 +{
46639 +       struct sunqe *qep = dev->priv;
46640 +
46641 +       strcpy(info->driver, "sunqe");
46642 +       strcpy(info->version, "3.0");
46643 +       sprintf(info->bus_info, "SBUS:%d",
46644 +               qep->qe_sdev->slot);
46645 +}
46646 +
46647 +static u32 qe_get_link(struct net_device *dev)
46648 +{
46649 +       struct sunqe *qep = dev->priv;
46650 +       unsigned long mregs = qep->mregs;
46651 +       u8 phyconfig;
46652 +
46653 +       spin_lock_irq(&qep->lock);
46654 +       phyconfig = sbus_readb(mregs + MREGS_PHYCONFIG);
46655 +       spin_unlock_irq(&qep->lock);
46656 +
46657 +       return (phyconfig & MREGS_PHYCONFIG_LSTAT);
46658 +}
46659 +
46660 +static struct ethtool_ops qe_ethtool_ops = {
46661 +       .get_drvinfo            = qe_get_drvinfo,
46662 +       .get_link               = qe_get_link,
46663 +};
46664 +
46665  /* This is only called once at boot time for each card probed. */
46666  static inline void qec_init_once(struct sunqec *qecp, struct sbus_dev *qsdev)
46667  {
46668 @@ -850,6 +880,7 @@
46669                 qe_devs[i]->watchdog_timeo = 5*HZ;
46670                 qe_devs[i]->irq = sdev->irqs[0];
46671                 qe_devs[i]->dma = 0;
46672 +               qe_devs[i]->ethtool_ops = &qe_ethtool_ops;
46673         }
46674  
46675         /* QEC receives interrupts from each QE, then it sends the actual
46676 diff -Nru a/drivers/net/tg3.c b/drivers/net/tg3.c
46677 --- a/drivers/net/tg3.c Tue Aug 19 20:53:17 2003
46678 +++ b/drivers/net/tg3.c Mon Sep  1 12:14:20 2003
46679 @@ -2,7 +2,7 @@
46680   * tg3.c: Broadcom Tigon3 ethernet driver.
46681   *
46682   * Copyright (C) 2001, 2002, 2003 David S. Miller (davem@redhat.com)
46683 - * Copyright (C) 2001, 2002 Jeff Garzik (jgarzik@pobox.com)
46684 + * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com)
46685   */
46686  
46687  #include <linux/config.h>
46688 @@ -27,6 +27,8 @@
46689  #include <linux/tcp.h>
46690  #include <linux/workqueue.h>
46691  
46692 +#include <net/checksum.h>
46693 +
46694  #include <asm/system.h>
46695  #include <asm/io.h>
46696  #include <asm/byteorder.h>
46697 @@ -45,20 +47,17 @@
46698  #endif
46699  
46700  #ifdef NETIF_F_TSO
46701 -/* XXX Works but still disabled, decreases TCP performance to 7MB/sec even
46702 - * XXX over gigabit.
46703 - */
46704 -#define TG3_DO_TSO     0
46705 +#define TG3_TSO_SUPPORT        1
46706  #else
46707 -#define TG3_DO_TSO     0
46708 +#define TG3_TSO_SUPPORT        0
46709  #endif
46710  
46711  #include "tg3.h"
46712  
46713  #define DRV_MODULE_NAME                "tg3"
46714  #define PFX DRV_MODULE_NAME    ": "
46715 -#define DRV_MODULE_VERSION     "1.9"
46716 -#define DRV_MODULE_RELDATE     "August 3, 2003"
46717 +#define DRV_MODULE_VERSION     "2.2"
46718 +#define DRV_MODULE_RELDATE     "August 24, 2003"
46719  
46720  #define TG3_DEF_MAC_MODE       0
46721  #define TG3_DEF_RX_MODE                0
46722 @@ -80,7 +79,8 @@
46723  
46724  /* hardware minimum and maximum for a single frame's data payload */
46725  #define TG3_MIN_MTU                    60
46726 -#define TG3_MAX_MTU                    9000
46727 +#define TG3_MAX_MTU(tp)        \
46728 +       (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 ? 9000 : 1500)
46729  
46730  /* These numbers seem to be hard coded in the NIC firmware somehow.
46731   * You can't change the ring sizes, but you can change where you place
46732 @@ -90,7 +90,17 @@
46733  #define TG3_DEF_RX_RING_PENDING                200
46734  #define TG3_RX_JUMBO_RING_SIZE         256
46735  #define TG3_DEF_RX_JUMBO_RING_PENDING  100
46736 -#define TG3_RX_RCB_RING_SIZE           1024
46737 +
46738 +/* Do not place this n-ring entries value into the tp struct itself,
46739 + * we really want to expose these constants to GCC so that modulo et
46740 + * al.  operations are done with shifts and masks instead of with
46741 + * hw multiply/modulo instructions.  Another solution would be to
46742 + * replace things like '% foo' with '& (foo - 1)'.
46743 + */
46744 +#define TG3_RX_RCB_RING_SIZE(tp)       \
46745 +       (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ? \
46746 +        512 : 1024)
46747 +
46748  #define TG3_TX_RING_SIZE               512
46749  #define TG3_DEF_TX_RING_PENDING                (TG3_TX_RING_SIZE - 1)
46750  
46751 @@ -98,8 +108,8 @@
46752                                  TG3_RX_RING_SIZE)
46753  #define TG3_RX_JUMBO_RING_BYTES        (sizeof(struct tg3_rx_buffer_desc) * \
46754                                  TG3_RX_JUMBO_RING_SIZE)
46755 -#define TG3_RX_RCB_RING_BYTES  (sizeof(struct tg3_rx_buffer_desc) * \
46756 -                                TG3_RX_RCB_RING_SIZE)
46757 +#define TG3_RX_RCB_RING_BYTES(tp) (sizeof(struct tg3_rx_buffer_desc) * \
46758 +                                  TG3_RX_RCB_RING_SIZE(tp))
46759  #define TG3_TX_RING_BYTES      (sizeof(struct tg3_tx_buffer_desc) * \
46760                                  TG3_TX_RING_SIZE)
46761  #define TX_RING_GAP(TP)        \
46762 @@ -140,6 +150,14 @@
46763           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46764         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5702FE,
46765           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46766 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705,
46767 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46768 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705_2,
46769 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46770 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705M,
46771 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46772 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705M_2,
46773 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46774         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5702X,
46775           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46776         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5703X,
46777 @@ -150,12 +168,24 @@
46778           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46779         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5703A3,
46780           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46781 -       { PCI_VENDOR_ID_SYSKONNECT, 0x4400,
46782 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5782,
46783 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46784 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5788,
46785 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46786 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5901,
46787 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46788 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5901_2,
46789 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46790 +       { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX,
46791 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46792 +       { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9MXX,
46793           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46794         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1000,
46795           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46796         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1001,
46797           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46798 +       { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1003,
46799 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46800         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC9100,
46801           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
46802         { 0, }
46803 @@ -237,38 +267,6 @@
46804         tg3_cond_int(tp);
46805  }
46806  
46807 -/* these netif_xxx funcs should be moved into generic net layer */
46808 -static void netif_poll_disable(struct net_device *dev)
46809 -{
46810 -       while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
46811 -               current->state = TASK_INTERRUPTIBLE;
46812 -               schedule_timeout(1);
46813 -       }
46814 -}
46815 -
46816 -static inline void netif_poll_enable(struct net_device *dev)
46817 -{
46818 -       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
46819 -}
46820 -
46821 -/* same as netif_rx_complete, except that local_irq_save(flags)
46822 - * has already been issued
46823 - */
46824 -static inline void __netif_rx_complete(struct net_device *dev)
46825 -{
46826 -       if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
46827 -       list_del(&dev->poll_list);
46828 -       smp_mb__before_clear_bit();
46829 -       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
46830 -}
46831 -
46832 -static inline void netif_tx_disable(struct net_device *dev)
46833 -{
46834 -       spin_lock_bh(&dev->xmit_lock);
46835 -       netif_stop_queue(dev);
46836 -       spin_unlock_bh(&dev->xmit_lock);
46837 -}
46838 -
46839  static inline void tg3_netif_stop(struct tg3 *tp)
46840  {
46841         netif_poll_disable(tp->dev);
46842 @@ -288,17 +286,28 @@
46843  
46844  static void tg3_switch_clocks(struct tg3 *tp)
46845  {
46846 -       if (tr32(TG3PCI_CLOCK_CTRL) & CLOCK_CTRL_44MHZ_CORE) {
46847 +       u32 clock_ctrl = tr32(TG3PCI_CLOCK_CTRL);
46848 +       u32 orig_clock_ctrl;
46849 +
46850 +       orig_clock_ctrl = clock_ctrl;
46851 +       clock_ctrl &= (CLOCK_CTRL_FORCE_CLKRUN |
46852 +                      CLOCK_CTRL_CLKRUN_OENABLE |
46853 +                      0x1f);
46854 +       tp->pci_clock_ctrl = clock_ctrl;
46855 +
46856 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
46857 +           (orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) {
46858                 tw32(TG3PCI_CLOCK_CTRL,
46859 +                    clock_ctrl |
46860                      (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK));
46861                 tr32(TG3PCI_CLOCK_CTRL);
46862                 udelay(40);
46863                 tw32(TG3PCI_CLOCK_CTRL,
46864 -                    (CLOCK_CTRL_ALTCLK));
46865 +                    clock_ctrl | (CLOCK_CTRL_ALTCLK));
46866                 tr32(TG3PCI_CLOCK_CTRL);
46867                 udelay(40);
46868         }
46869 -       tw32(TG3PCI_CLOCK_CTRL, 0);
46870 +       tw32(TG3PCI_CLOCK_CTRL, clock_ctrl);
46871         tr32(TG3PCI_CLOCK_CTRL);
46872         udelay(40);
46873  }
46874 @@ -401,24 +410,22 @@
46875         return ret;
46876  }
46877  
46878 -/* This will reset the tigon3 PHY if there is no valid
46879 - * link unless the FORCE argument is non-zero.
46880 - */
46881 -static int tg3_phy_reset(struct tg3 *tp, int force)
46882 +static void tg3_phy_set_wirespeed(struct tg3 *tp)
46883  {
46884 -       u32 phy_status, phy_control;
46885 -       int err, limit;
46886 +       u32 val;
46887  
46888 -       err  = tg3_readphy(tp, MII_BMSR, &phy_status);
46889 -       err |= tg3_readphy(tp, MII_BMSR, &phy_status);
46890 -       if (err != 0)
46891 -               return -EBUSY;
46892 +       if (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED)
46893 +               return;
46894  
46895 -       /* If we have link, and not forcing a reset, then nothing
46896 -        * to do.
46897 -        */
46898 -       if ((phy_status & BMSR_LSTATUS) != 0 && (force == 0))
46899 -               return 0;
46900 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007);
46901 +       tg3_readphy(tp, MII_TG3_AUX_CTRL, &val);
46902 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, (val | (1 << 15) | (1 << 4)));
46903 +}
46904 +
46905 +static int tg3_bmcr_reset(struct tg3 *tp)
46906 +{
46907 +       u32 phy_control;
46908 +       int limit, err;
46909  
46910         /* OK, reset it, and poll the BMCR_RESET bit until it
46911          * clears or we time out.
46912 @@ -436,12 +443,303 @@
46913  
46914                 if ((phy_control & BMCR_RESET) == 0) {
46915                         udelay(40);
46916 -                       return 0;
46917 +                       break;
46918                 }
46919                 udelay(10);
46920         }
46921 +       if (limit <= 0)
46922 +               return -EBUSY;
46923 +
46924 +       return 0;
46925 +}
46926 +
46927 +static int tg3_wait_macro_done(struct tg3 *tp)
46928 +{
46929 +       int limit = 100;
46930 +
46931 +       while (limit--) {
46932 +               u32 tmp32;
46933 +
46934 +               tg3_readphy(tp, 0x16, &tmp32);
46935 +               if ((tmp32 & 0x1000) == 0)
46936 +                       break;
46937 +       }
46938 +       if (limit <= 0)
46939 +               return -EBUSY;
46940 +
46941 +       return 0;
46942 +}
46943 +
46944 +static int tg3_phy_write_and_check_testpat(struct tg3 *tp, int *resetp)
46945 +{
46946 +       static const u32 test_pat[4][6] = {
46947 +       { 0x00005555, 0x00000005, 0x00002aaa, 0x0000000a, 0x00003456, 0x00000003 },
46948 +       { 0x00002aaa, 0x0000000a, 0x00003333, 0x00000003, 0x0000789a, 0x00000005 },
46949 +       { 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
46950 +       { 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
46951 +       };
46952 +       int chan;
46953 +
46954 +       for (chan = 0; chan < 4; chan++) {
46955 +               int i;
46956 +
46957 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
46958 +                            (chan * 0x2000) | 0x0200);
46959 +               tg3_writephy(tp, 0x16, 0x0002);
46960 +
46961 +               for (i = 0; i < 6; i++)
46962 +                       tg3_writephy(tp, MII_TG3_DSP_RW_PORT,
46963 +                                    test_pat[chan][i]);
46964 +
46965 +               tg3_writephy(tp, 0x16, 0x0202);
46966 +               if (tg3_wait_macro_done(tp)) {
46967 +                       *resetp = 1;
46968 +                       return -EBUSY;
46969 +               }
46970 +
46971 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
46972 +                            (chan * 0x2000) | 0x0200);
46973 +               tg3_writephy(tp, 0x16, 0x0082);
46974 +               if (tg3_wait_macro_done(tp)) {
46975 +                       *resetp = 1;
46976 +                       return -EBUSY;
46977 +               }
46978 +
46979 +               tg3_writephy(tp, 0x16, 0x0802);
46980 +               if (tg3_wait_macro_done(tp)) {
46981 +                       *resetp = 1;
46982 +                       return -EBUSY;
46983 +               }
46984 +
46985 +               for (i = 0; i < 6; i += 2) {
46986 +                       u32 low, high;
46987 +
46988 +                       tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &low);
46989 +                       tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &high);
46990 +                       if (tg3_wait_macro_done(tp)) {
46991 +                               *resetp = 1;
46992 +                               return -EBUSY;
46993 +                       }
46994 +                       low &= 0x7fff;
46995 +                       high &= 0x000f;
46996 +                       if (low != test_pat[chan][i] ||
46997 +                           high != test_pat[chan][i+1]) {
46998 +                               tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
46999 +                               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
47000 +                               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);
47001 +
47002 +                               return -EBUSY;
47003 +                       }
47004 +               }
47005 +       }
47006  
47007 -       return -EBUSY;
47008 +       return 0;
47009 +}
47010 +
47011 +static int tg3_phy_reset_chanpat(struct tg3 *tp)
47012 +{
47013 +       int chan;
47014 +
47015 +       for (chan = 0; chan < 4; chan++) {
47016 +               int i;
47017 +
47018 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
47019 +                            (chan * 0x2000) | 0x0200);
47020 +               tg3_writephy(tp, 0x16, 0x0002);
47021 +               for (i = 0; i < 6; i++)
47022 +                       tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x000);
47023 +               tg3_writephy(tp, 0x16, 0x0202);
47024 +               if (tg3_wait_macro_done(tp))
47025 +                       return -EBUSY;
47026 +       }
47027 +
47028 +       return 0;
47029 +}
47030 +
47031 +static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
47032 +{
47033 +       u32 reg32, phy9_orig;
47034 +       int retries, do_phy_reset, err;
47035 +
47036 +       retries = 10;
47037 +       do_phy_reset = 1;
47038 +       do {
47039 +               if (do_phy_reset) {
47040 +                       err = tg3_bmcr_reset(tp);
47041 +                       if (err)
47042 +                               return err;
47043 +                       do_phy_reset = 0;
47044 +               }
47045 +
47046 +               /* Disable transmitter and interrupt.  */
47047 +               tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
47048 +               reg32 |= 0x3000;
47049 +               tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
47050 +
47051 +               /* Set full-duplex, 1000 mbps.  */
47052 +               tg3_writephy(tp, MII_BMCR,
47053 +                            BMCR_FULLDPLX | TG3_BMCR_SPEED1000);
47054 +
47055 +               /* Set to master mode.  */
47056 +               tg3_readphy(tp, MII_TG3_CTRL, &phy9_orig);
47057 +               tg3_writephy(tp, MII_TG3_CTRL,
47058 +                            (MII_TG3_CTRL_AS_MASTER |
47059 +                             MII_TG3_CTRL_ENABLE_AS_MASTER));
47060 +
47061 +               /* Enable SM_DSP_CLOCK and 6dB.  */
47062 +               tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
47063 +
47064 +               /* Block the PHY control access.  */
47065 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
47066 +               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0800);
47067 +
47068 +               err = tg3_phy_write_and_check_testpat(tp, &do_phy_reset);
47069 +               if (!err)
47070 +                       break;
47071 +       } while (--retries);
47072 +
47073 +       err = tg3_phy_reset_chanpat(tp);
47074 +       if (err)
47075 +               return err;
47076 +
47077 +       tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
47078 +       tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0000);
47079 +
47080 +       tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200);
47081 +       tg3_writephy(tp, 0x16, 0x0000);
47082 +
47083 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400);
47084 +
47085 +       tg3_writephy(tp, MII_TG3_CTRL, phy9_orig);
47086 +
47087 +       tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
47088 +       reg32 &= ~0x3000;
47089 +       tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
47090 +
47091 +       return err;
47092 +}
47093 +
47094 +/* This will reset the tigon3 PHY if there is no valid
47095 + * link unless the FORCE argument is non-zero.
47096 + */
47097 +static int tg3_phy_reset(struct tg3 *tp, int force)
47098 +{
47099 +       u32 phy_status;
47100 +       int err;
47101 +
47102 +       err  = tg3_readphy(tp, MII_BMSR, &phy_status);
47103 +       err |= tg3_readphy(tp, MII_BMSR, &phy_status);
47104 +       if (err != 0)
47105 +               return -EBUSY;
47106 +
47107 +       /* If we have link, and not forcing a reset, then nothing
47108 +        * to do.
47109 +        */
47110 +       if ((phy_status & BMSR_LSTATUS) != 0 && (force == 0))
47111 +               return 0;
47112 +
47113 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
47114 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
47115 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
47116 +               err = tg3_phy_reset_5703_4_5(tp);
47117 +               if (err)
47118 +                       return err;
47119 +               goto out;
47120 +       }
47121 +
47122 +       err = tg3_bmcr_reset(tp);
47123 +       if (err)
47124 +               return err;
47125 +
47126 +out:
47127 +       tg3_phy_set_wirespeed(tp);
47128 +       return 0;
47129 +}
47130 +
47131 +static void tg3_frob_aux_power(struct tg3 *tp)
47132 +{
47133 +       struct tg3 *tp_peer = tp;
47134 +
47135 +       if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0)
47136 +               return;
47137 +
47138 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
47139 +               tp_peer = pci_get_drvdata(tp->pdev_peer);
47140 +               if (!tp_peer)
47141 +                       BUG();
47142 +       }
47143 +
47144 +
47145 +       if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
47146 +           (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0) {
47147 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
47148 +                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
47149 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
47150 +                            (GRC_LCLCTRL_GPIO_OE0 |
47151 +                             GRC_LCLCTRL_GPIO_OE1 |
47152 +                             GRC_LCLCTRL_GPIO_OE2 |
47153 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
47154 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
47155 +                       tr32(GRC_LOCAL_CTRL);
47156 +                       udelay(100);
47157 +               } else {
47158 +                       if (tp_peer != tp &&
47159 +                           (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
47160 +                               return;
47161 +
47162 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
47163 +                            (GRC_LCLCTRL_GPIO_OE0 |
47164 +                             GRC_LCLCTRL_GPIO_OE1 |
47165 +                             GRC_LCLCTRL_GPIO_OE2 |
47166 +                             GRC_LCLCTRL_GPIO_OUTPUT1 |
47167 +                             GRC_LCLCTRL_GPIO_OUTPUT2));
47168 +                       tr32(GRC_LOCAL_CTRL);
47169 +                       udelay(100);
47170 +
47171 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
47172 +                            (GRC_LCLCTRL_GPIO_OE0 |
47173 +                             GRC_LCLCTRL_GPIO_OE1 |
47174 +                             GRC_LCLCTRL_GPIO_OE2 |
47175 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
47176 +                             GRC_LCLCTRL_GPIO_OUTPUT1 |
47177 +                             GRC_LCLCTRL_GPIO_OUTPUT2));
47178 +                       tr32(GRC_LOCAL_CTRL);
47179 +                       udelay(100);
47180 +
47181 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
47182 +                            (GRC_LCLCTRL_GPIO_OE0 |
47183 +                             GRC_LCLCTRL_GPIO_OE1 |
47184 +                             GRC_LCLCTRL_GPIO_OE2 |
47185 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
47186 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
47187 +                       tr32(GRC_LOCAL_CTRL);
47188 +                       udelay(100);
47189 +               }
47190 +       } else {
47191 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
47192 +                   GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
47193 +                       if (tp_peer != tp &&
47194 +                           (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
47195 +                               return;
47196 +
47197 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
47198 +                            (GRC_LCLCTRL_GPIO_OE1 |
47199 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
47200 +                       tr32(GRC_LOCAL_CTRL);
47201 +                       udelay(100);
47202 +
47203 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
47204 +                            (GRC_LCLCTRL_GPIO_OE1));
47205 +                       tr32(GRC_LOCAL_CTRL);
47206 +                       udelay(100);
47207 +
47208 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
47209 +                            (GRC_LCLCTRL_GPIO_OE1 |
47210 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
47211 +                       tr32(GRC_LOCAL_CTRL);
47212 +                       udelay(100);
47213 +               }
47214 +       }
47215  }
47216  
47217  static int tg3_setup_phy(struct tg3 *);
47218 @@ -547,89 +845,65 @@
47219                 udelay(10);
47220         }
47221  
47222 -       if (tp->tg3_flags & TG3_FLAG_WOL_SPEED_100MB) {
47223 +       if (!(tp->tg3_flags & TG3_FLAG_WOL_SPEED_100MB) &&
47224 +           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
47225 +            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) {
47226                 u32 base_val;
47227  
47228 -               base_val = 0;
47229 -               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
47230 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)
47231 -                       base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
47232 -                                    CLOCK_CTRL_TXCLK_DISABLE);
47233 -
47234 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
47235 -                    CLOCK_CTRL_ALTCLK);
47236 -               tr32(TG3PCI_CLOCK_CTRL);
47237 -               udelay(40);
47238 +               base_val = tp->pci_clock_ctrl;
47239 +               base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
47240 +                            CLOCK_CTRL_TXCLK_DISABLE);
47241  
47242                 tw32(TG3PCI_CLOCK_CTRL, base_val |
47243                      CLOCK_CTRL_ALTCLK |
47244 -                    CLOCK_CTRL_44MHZ_CORE);
47245 -               tr32(TG3PCI_CLOCK_CTRL);
47246 -               udelay(40);
47247 -
47248 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
47249 -                    CLOCK_CTRL_44MHZ_CORE);
47250 +                    CLOCK_CTRL_PWRDOWN_PLL133);
47251                 tr32(TG3PCI_CLOCK_CTRL);
47252                 udelay(40);
47253         } else {
47254 -               u32 base_val;
47255 +               u32 newbits1, newbits2;
47256  
47257 -               base_val = 0;
47258                 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
47259 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)
47260 -                       base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
47261 -                                    CLOCK_CTRL_TXCLK_DISABLE);
47262 +                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
47263 +                       newbits1 = (CLOCK_CTRL_RXCLK_DISABLE |
47264 +                                   CLOCK_CTRL_TXCLK_DISABLE |
47265 +                                   CLOCK_CTRL_ALTCLK);
47266 +                       newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
47267 +               } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
47268 +                       newbits1 = CLOCK_CTRL_625_CORE;
47269 +                       newbits2 = newbits1 | CLOCK_CTRL_ALTCLK;
47270 +               } else {
47271 +                       newbits1 = CLOCK_CTRL_ALTCLK;
47272 +                       newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
47273 +               }
47274  
47275 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
47276 -                    CLOCK_CTRL_ALTCLK |
47277 -                    CLOCK_CTRL_PWRDOWN_PLL133);
47278 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1);
47279                 tr32(TG3PCI_CLOCK_CTRL);
47280                 udelay(40);
47281 -       }
47282  
47283 -       if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) &&
47284 -           (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)) {
47285 -               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
47286 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
47287 -                       tw32(GRC_LOCAL_CTRL,
47288 -                            (GRC_LCLCTRL_GPIO_OE0 |
47289 -                             GRC_LCLCTRL_GPIO_OE1 |
47290 -                             GRC_LCLCTRL_GPIO_OE2 |
47291 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
47292 -                             GRC_LCLCTRL_GPIO_OUTPUT1));
47293 -                       tr32(GRC_LOCAL_CTRL);
47294 -                       udelay(100);
47295 -               } else {
47296 -                       tw32(GRC_LOCAL_CTRL,
47297 -                            (GRC_LCLCTRL_GPIO_OE0 |
47298 -                             GRC_LCLCTRL_GPIO_OE1 |
47299 -                             GRC_LCLCTRL_GPIO_OE2 |
47300 -                             GRC_LCLCTRL_GPIO_OUTPUT1 |
47301 -                             GRC_LCLCTRL_GPIO_OUTPUT2));
47302 -                       tr32(GRC_LOCAL_CTRL);
47303 -                       udelay(100);
47304 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2);
47305 +               tr32(TG3PCI_CLOCK_CTRL);
47306 +               udelay(40);
47307  
47308 -                       tw32(GRC_LOCAL_CTRL,
47309 -                            (GRC_LCLCTRL_GPIO_OE0 |
47310 -                             GRC_LCLCTRL_GPIO_OE1 |
47311 -                             GRC_LCLCTRL_GPIO_OE2 |
47312 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
47313 -                             GRC_LCLCTRL_GPIO_OUTPUT1 |
47314 -                             GRC_LCLCTRL_GPIO_OUTPUT2));
47315 -                       tr32(GRC_LOCAL_CTRL);
47316 -                       udelay(100);
47317 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
47318 +                       u32 newbits3;
47319  
47320 -                       tw32(GRC_LOCAL_CTRL,
47321 -                            (GRC_LCLCTRL_GPIO_OE0 |
47322 -                             GRC_LCLCTRL_GPIO_OE1 |
47323 -                             GRC_LCLCTRL_GPIO_OE2 |
47324 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
47325 -                             GRC_LCLCTRL_GPIO_OUTPUT1));
47326 -                       tr32(GRC_LOCAL_CTRL);
47327 -                       udelay(100);
47328 +                       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
47329 +                           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
47330 +                               newbits3 = (CLOCK_CTRL_RXCLK_DISABLE |
47331 +                                           CLOCK_CTRL_TXCLK_DISABLE |
47332 +                                           CLOCK_CTRL_44MHZ_CORE);
47333 +                       } else {
47334 +                               newbits3 = CLOCK_CTRL_44MHZ_CORE;
47335 +                       }
47336 +
47337 +                       tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits3);
47338 +                       tr32(TG3PCI_CLOCK_CTRL);
47339 +                       udelay(40);
47340                 }
47341         }
47342  
47343 +       tg3_frob_aux_power(tp);
47344 +
47345         /* Finally, set the new power state. */
47346         pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
47347  
47348 @@ -948,11 +1222,10 @@
47349  
47350         /* Some third-party PHYs need to be reset on link going
47351          * down.
47352 -        *
47353 -        * XXX 5705 note: This workaround also applies to 5705_a0
47354          */
47355         if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
47356 -            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) &&
47357 +            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
47358 +            tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) &&
47359             netif_carrier_ok(tp->dev)) {
47360                 tg3_readphy(tp, MII_BMSR, &bmsr);
47361                 tg3_readphy(tp, MII_BMSR, &bmsr);
47362 @@ -1942,7 +2215,7 @@
47363         int received;
47364  
47365         hw_idx = tp->hw_status->idx[0].rx_producer;
47366 -       sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE;
47367 +       sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
47368         work_mask = 0;
47369         received = 0;
47370         while (sw_idx != hw_idx && budget > 0) {
47371 @@ -2043,13 +2316,13 @@
47372                 (*post_ptr)++;
47373  next_pkt_nopost:
47374                 rx_rcb_ptr++;
47375 -               sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE;
47376 +               sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
47377         }
47378  
47379         /* ACK the status ring. */
47380         tp->rx_rcb_ptr = rx_rcb_ptr;
47381         tw32_mailbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW,
47382 -                    (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE));
47383 +                    (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp)));
47384         if (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)
47385                 tr32(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW);
47386  
47387 @@ -2388,19 +2661,34 @@
47388         base_flags = 0;
47389         if (skb->ip_summed == CHECKSUM_HW)
47390                 base_flags |= TXD_FLAG_TCPUDP_CSUM;
47391 -#if TG3_DO_TSO != 0
47392 -       if ((mss = skb_shinfo(skb)->tso_size) != 0) {
47393 -               static int times = 0;
47394 +#if TG3_TSO_SUPPORT != 0
47395 +       mss = 0;
47396 +       if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
47397 +           (mss = skb_shinfo(skb)->tso_size) != 0) {
47398 +               int tcp_opt_len, ip_tcp_len;
47399 +
47400 +               tcp_opt_len = ((skb->h.th->doff - 5) * 4);
47401 +               ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
47402  
47403 -               mss += ((skb->h.th->doff * 4) - 20);
47404                 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
47405                                TXD_FLAG_CPU_POST_DMA);
47406  
47407 -               if (times++ < 5) {
47408 -                       printk("tg3_xmit: tso_size[%u] tso_segs[%u] len[%u]\n",
47409 -                              (unsigned int) skb_shinfo(skb)->tso_size,
47410 -                              (unsigned int) skb_shinfo(skb)->tso_segs,
47411 -                              skb->len);
47412 +               skb->nh.iph->check = 0;
47413 +               skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len);
47414 +               skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
47415 +                                                     skb->nh.iph->daddr,
47416 +                                                     0, IPPROTO_TCP, 0);
47417 +
47418 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
47419 +                       if (tcp_opt_len || skb->nh.iph->ihl > 5) {
47420 +                               int tsflags;
47421 +
47422 +                               tsflags = ((skb->nh.iph->ihl - 5) +
47423 +                                          (tcp_opt_len >> 2));
47424 +                               mss |= (tsflags << 11);
47425 +                       }
47426 +               } else {
47427 +                       mss += tcp_opt_len;
47428                 }
47429         }
47430  #else
47431 @@ -2580,23 +2868,34 @@
47432         base_flags = 0;
47433         if (skb->ip_summed == CHECKSUM_HW)
47434                 base_flags |= TXD_FLAG_TCPUDP_CSUM;
47435 -#if TG3_DO_TSO != 0
47436 -       if ((mss = skb_shinfo(skb)->tso_size) != 0) {
47437 -               static int times = 0;
47438 +#if TG3_TSO_SUPPORT != 0
47439 +       mss = 0;
47440 +       if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
47441 +           (mss = skb_shinfo(skb)->tso_size) != 0) {
47442 +               int tcp_opt_len, ip_tcp_len;
47443  
47444 -               /* TSO firmware wants TCP options included in
47445 -                * tx descriptor MSS value.
47446 -                */
47447 -               mss += ((skb->h.th->doff * 4) - 20);
47448 +               tcp_opt_len = ((skb->h.th->doff - 5) * 4);
47449 +               ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
47450  
47451                 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
47452                                TXD_FLAG_CPU_POST_DMA);
47453  
47454 -               if (times++ < 5) {
47455 -                       printk("tg3_xmit: tso_size[%u] tso_segs[%u] len[%u]\n",
47456 -                              (unsigned int) skb_shinfo(skb)->tso_size,
47457 -                              (unsigned int) skb_shinfo(skb)->tso_segs,
47458 -                              skb->len);
47459 +               skb->nh.iph->check = 0;
47460 +               skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len);
47461 +               skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
47462 +                                                     skb->nh.iph->daddr,
47463 +                                                     0, IPPROTO_TCP, 0);
47464 +
47465 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
47466 +                       if (tcp_opt_len || skb->nh.iph->ihl > 5) {
47467 +                               int tsflags;
47468 +
47469 +                               tsflags = ((skb->nh.iph->ihl - 5) +
47470 +                                          (tcp_opt_len >> 2));
47471 +                               mss |= (tsflags << 11);
47472 +                       }
47473 +               } else {
47474 +                       mss += tcp_opt_len;
47475                 }
47476         }
47477  #else
47478 @@ -2698,7 +2997,7 @@
47479  {
47480         struct tg3 *tp = dev->priv;
47481  
47482 -       if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU)
47483 +       if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU(tp))
47484                 return -EINVAL;
47485  
47486         if (!netif_running(dev)) {
47487 @@ -2816,7 +3115,7 @@
47488         /* Zero out all descriptors. */
47489         memset(tp->rx_std, 0, TG3_RX_RING_BYTES);
47490         memset(tp->rx_jumbo, 0, TG3_RX_JUMBO_RING_BYTES);
47491 -       memset(tp->rx_rcb, 0, TG3_RX_RCB_RING_BYTES);
47492 +       memset(tp->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp));
47493  
47494         if (tp->tg3_flags & TG3_FLAG_HOST_TXDS) {
47495                 memset(tp->tx_ring, 0, TG3_TX_RING_BYTES);
47496 @@ -2899,7 +3198,7 @@
47497                 tp->rx_jumbo = NULL;
47498         }
47499         if (tp->rx_rcb) {
47500 -               pci_free_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES,
47501 +               pci_free_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp),
47502                                     tp->rx_rcb, tp->rx_rcb_mapping);
47503                 tp->rx_rcb = NULL;
47504         }
47505 @@ -2957,7 +3256,7 @@
47506         if (!tp->rx_jumbo)
47507                 goto err_out;
47508  
47509 -       tp->rx_rcb = pci_alloc_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES,
47510 +       tp->rx_rcb = pci_alloc_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp),
47511                                           &tp->rx_rcb_mapping);
47512         if (!tp->rx_rcb)
47513                 goto err_out;
47514 @@ -3004,6 +3303,23 @@
47515         unsigned int i;
47516         u32 val;
47517  
47518 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
47519 +               switch (ofs) {
47520 +               case RCVLSC_MODE:
47521 +               case DMAC_MODE:
47522 +               case MBFREE_MODE:
47523 +               case BUFMGR_MODE:
47524 +               case MEMARB_MODE:
47525 +                       /* We can't enable/disable these bits of the
47526 +                        * 5705, just say success.
47527 +                        */
47528 +                       return 0;
47529 +
47530 +               default:
47531 +                       break;
47532 +               };
47533 +       }
47534 +
47535         val = tr32(ofs);
47536         val &= ~enable_bit;
47537         tw32(ofs, val);
47538 @@ -3127,7 +3443,10 @@
47539         tp->tg3_flags &= ~TG3_FLAG_5701_REG_WRITE_BUG;
47540  
47541         /* do the reset */
47542 -       tw32(GRC_MISC_CFG, GRC_MISC_CFG_CORECLK_RESET);
47543 +       val = GRC_MISC_CFG_CORECLK_RESET;
47544 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
47545 +               val |= GRC_MISC_CFG_KEEP_GPHY_POWER;
47546 +       tw32(GRC_MISC_CFG, val);
47547  
47548         /* restore 5701 hardware bug workaround flag */
47549         tp->tg3_flags = flags_save;
47550 @@ -3163,6 +3482,13 @@
47551  
47552         tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
47553  
47554 +       if ((tp->nic_sram_data_cfg & NIC_SRAM_DATA_CFG_MINI_PCI) != 0 &&
47555 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
47556 +               tp->pci_clock_ctrl |=
47557 +                       (CLOCK_CTRL_FORCE_CLKRUN | CLOCK_CTRL_CLKRUN_OENABLE);
47558 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
47559 +       }
47560 +
47561         tw32(TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl);
47562  }
47563  
47564 @@ -3358,28 +3684,32 @@
47565  #define TX_CPU_SCRATCH_SIZE    0x04000
47566  
47567  /* tp->lock is held. */
47568 -static int tg3_reset_cpu(struct tg3 *tp, u32 offset)
47569 +static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
47570  {
47571         int i;
47572  
47573 -       tw32(offset + CPU_STATE, 0xffffffff);
47574 -       tw32(offset + CPU_MODE,  CPU_MODE_RESET);
47575 +       if (offset == TX_CPU_BASE &&
47576 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
47577 +               BUG();
47578 +
47579         if (offset == RX_CPU_BASE) {
47580 -               for (i = 0; i < 10000; i++)
47581 -                       if (!(tr32(offset + CPU_MODE) & CPU_MODE_RESET))
47582 +               for (i = 0; i < 10000; i++) {
47583 +                       tw32(offset + CPU_STATE, 0xffffffff);
47584 +                       tw32(offset + CPU_MODE,  CPU_MODE_HALT);
47585 +                       if (tr32(offset + CPU_MODE) & CPU_MODE_HALT)
47586                                 break;
47587 +               }
47588 +
47589                 tw32(offset + CPU_STATE, 0xffffffff);
47590 -               tw32(offset + CPU_MODE,  CPU_MODE_RESET);
47591 +               tw32(offset + CPU_MODE,  CPU_MODE_HALT);
47592                 tr32(offset + CPU_MODE);
47593                 udelay(10);
47594         } else {
47595                 for (i = 0; i < 10000; i++) {
47596 -                       if (!(tr32(offset + CPU_MODE) & CPU_MODE_RESET))
47597 -                               break;
47598                         tw32(offset + CPU_STATE, 0xffffffff);
47599 -                       tw32(offset + CPU_MODE,  CPU_MODE_RESET);
47600 -                       tr32(offset + CPU_MODE);
47601 -                       udelay(10);
47602 +                       tw32(offset + CPU_MODE,  CPU_MODE_HALT);
47603 +                       if (tr32(offset + CPU_MODE) & CPU_MODE_HALT)
47604 +                               break;
47605                 }
47606         }
47607  
47608 @@ -3411,38 +3741,52 @@
47609  {
47610         int err, i;
47611         u32 orig_tg3_flags = tp->tg3_flags;
47612 +       void (*write_op)(struct tg3 *, u32, u32);
47613 +
47614 +       if (cpu_base == TX_CPU_BASE &&
47615 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
47616 +               printk(KERN_ERR PFX "tg3_load_firmware_cpu: Trying to load "
47617 +                      "TX cpu firmware on %s which is 5705.\n",
47618 +                      tp->dev->name);
47619 +               return -EINVAL;
47620 +       }
47621 +
47622 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
47623 +               write_op = tg3_write_mem;
47624 +       else
47625 +               write_op = tg3_write_indirect_reg32;
47626  
47627         /* Force use of PCI config space for indirect register
47628          * write calls.
47629          */
47630         tp->tg3_flags |= TG3_FLAG_PCIX_TARGET_HWBUG;
47631  
47632 -       err = tg3_reset_cpu(tp, cpu_base);
47633 +       err = tg3_halt_cpu(tp, cpu_base);
47634         if (err)
47635                 goto out;
47636  
47637         for (i = 0; i < cpu_scratch_size; i += sizeof(u32))
47638 -               tg3_write_indirect_reg32(tp, cpu_scratch_base + i, 0);
47639 +               write_op(tp, cpu_scratch_base + i, 0);
47640         tw32(cpu_base + CPU_STATE, 0xffffffff);
47641         tw32(cpu_base + CPU_MODE, tr32(cpu_base+CPU_MODE)|CPU_MODE_HALT);
47642         for (i = 0; i < (info->text_len / sizeof(u32)); i++)
47643 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
47644 -                                             (info->text_base & 0xffff) +
47645 -                                             (i * sizeof(u32))),
47646 -                                        (info->text_data ?
47647 -                                         info->text_data[i] : 0));
47648 +               write_op(tp, (cpu_scratch_base +
47649 +                             (info->text_base & 0xffff) +
47650 +                             (i * sizeof(u32))),
47651 +                        (info->text_data ?
47652 +                         info->text_data[i] : 0));
47653         for (i = 0; i < (info->rodata_len / sizeof(u32)); i++)
47654 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
47655 -                                             (info->rodata_base & 0xffff) +
47656 -                                             (i * sizeof(u32))),
47657 -                                        (info->rodata_data ?
47658 -                                         info->rodata_data[i] : 0));
47659 +               write_op(tp, (cpu_scratch_base +
47660 +                             (info->rodata_base & 0xffff) +
47661 +                             (i * sizeof(u32))),
47662 +                        (info->rodata_data ?
47663 +                         info->rodata_data[i] : 0));
47664         for (i = 0; i < (info->data_len / sizeof(u32)); i++)
47665 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
47666 -                                             (info->data_base & 0xffff) +
47667 -                                             (i * sizeof(u32))),
47668 -                                        (info->data_data ?
47669 -                                         info->data_data[i] : 0));
47670 +               write_op(tp, (cpu_scratch_base +
47671 +                             (info->data_base & 0xffff) +
47672 +                             (i * sizeof(u32))),
47673 +                        (info->data_data ?
47674 +                         info->data_data[i] : 0));
47675  
47676         err = 0;
47677  
47678 @@ -3513,269 +3857,318 @@
47679         return 0;
47680  }
47681  
47682 -#if TG3_DO_TSO != 0
47683 +#if TG3_TSO_SUPPORT != 0
47684  
47685  #define TG3_TSO_FW_RELEASE_MAJOR       0x1
47686 -#define TG3_TSO_FW_RELASE_MINOR                0x8
47687 +#define TG3_TSO_FW_RELASE_MINOR                0x3
47688  #define TG3_TSO_FW_RELEASE_FIX         0x0
47689  #define TG3_TSO_FW_START_ADDR          0x08000000
47690  #define TG3_TSO_FW_TEXT_ADDR           0x08000000
47691 -#define TG3_TSO_FW_TEXT_LEN            0x1650
47692 +#define TG3_TSO_FW_TEXT_LEN            0x1ac0
47693  #define TG3_TSO_FW_RODATA_ADDR         0x08001650
47694 -#define TG3_TSO_FW_RODATA_LEN          0x30
47695 +#define TG3_TSO_FW_RODATA_LEN          0x60
47696  #define TG3_TSO_FW_DATA_ADDR           0x080016a0
47697  #define TG3_TSO_FW_DATA_LEN            0x20
47698  #define TG3_TSO_FW_SBSS_ADDR           0x080016c0
47699 -#define TG3_TSO_FW_SBSS_LEN            0x14
47700 +#define TG3_TSO_FW_SBSS_LEN            0x2c
47701  #define TG3_TSO_FW_BSS_ADDR            0x080016e0
47702 -#define TG3_TSO_FW_BSS_LEN             0x8fc
47703 +#define TG3_TSO_FW_BSS_LEN             0x890
47704  
47705  static u32 tg3TsoFwText[] = {
47706         0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c1d0800,
47707         0x37bd4000, 0x03a0f021, 0x3c100800, 0x26100000, 0x0e000010, 0x00000000,
47708 -       0x0000000d, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0x3c1bc000,
47709 -       0xafbf0018, 0x0e000058, 0xaf60680c, 0x3c040800, 0x24841650, 0x03602821,
47710 -       0x24060001, 0x24070004, 0xafa00010, 0x0e00006c, 0xafa00014, 0x8f625c50,
47711 -       0x34420001, 0xaf625c50, 0x8f625c90, 0x34420001, 0xaf625c90, 0x2402ffff,
47712 -       0x0e000098, 0xaf625404, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x00000000,
47713 -       0x00000000, 0x00000000, 0x24030b60, 0x24050fff, 0xac000b50, 0x00002021,
47714 -       0xac640000, 0x24630004, 0x0065102b, 0x1440fffc, 0x24840001, 0x24030b60,
47715 -       0x0065102b, 0x10400011, 0x00002021, 0x24090b54, 0x3c06dead, 0x34c6beef,
47716 -       0x24080b58, 0x24070b5c, 0x8c620000, 0x50440006, 0x24630004, 0xad260000,
47717 -       0x8c620000, 0xace40000, 0xad020000, 0x24630004, 0x0065102b, 0x1440fff6,
47718 -       0x24840001, 0x03e00008, 0x00000000, 0x27bdfff8, 0x18800009, 0x00002821,
47719 -       0x8f63680c, 0x8f62680c, 0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a,
47720 -       0x1440fff9, 0x00000000, 0x03e00008, 0x27bd0008, 0x3c020800, 0x34423000,
47721 -       0x3c030800, 0x34633000, 0x3c040800, 0x348437ff, 0x3c010800, 0xac2216c4,
47722 -       0x24020040, 0x3c010800, 0xac2216c8, 0x3c010800, 0xac2016c0, 0xac600000,
47723 -       0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
47724 -       0x00804821, 0x8faa0010, 0x3c020800, 0x8c4216c0, 0x3c040800, 0x8c8416c8,
47725 -       0x8fab0014, 0x24430001, 0x0044102b, 0x3c010800, 0xac2316c0, 0x14400003,
47726 -       0x00004021, 0x3c010800, 0xac2016c0, 0x3c020800, 0x8c4216c0, 0x3c030800,
47727 -       0x8c6316c4, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
47728 -       0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020800, 0x8c4216c0,
47729 -       0x3c030800, 0x8c6316c4, 0x8f64680c, 0x00021140, 0x00431021, 0xac440008,
47730 -       0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
47731 -       0x00000000, 0x00000000, 0x27bdffe0, 0xafbf0018, 0xafb10014, 0x0e0000b6,
47732 -       0xafb00010, 0x24110001, 0x8f706820, 0x32020100, 0x10400003, 0x00000000,
47733 -       0x0e000127, 0x00000000, 0x8f706820, 0x32022000, 0x10400004, 0x32020001,
47734 -       0x0e00025a, 0x24040001, 0x32020001, 0x10400003, 0x00000000, 0x0e0000e6,
47735 -       0x00000000, 0x0a00009e, 0xaf715028, 0x8fbf0018, 0x8fb10014, 0x8fb00010,
47736 -       0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x24841660, 0x00002821,
47737 -       0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00006c, 0xafa00014,
47738 -       0x3c010800, 0xa4201fb8, 0x3c010800, 0xa02016f8, 0x3c010800, 0xac2016fc,
47739 -       0x3c010800, 0xac201700, 0x3c010800, 0xac201704, 0x3c010800, 0xac20170c,
47740 -       0x3c010800, 0xac201718, 0x3c010800, 0xac20171c, 0x8f624434, 0x3c010800,
47741 -       0xac2216e8, 0x8f624438, 0x3c010800, 0xac2216ec, 0x8f624410, 0x3c010800,
47742 -       0xac2016e0, 0x3c010800, 0xac2016e4, 0x3c010800, 0xac201fc0, 0x3c010800,
47743 -       0xac201f68, 0x3c010800, 0xac201f6c, 0x3c010800, 0xac2216f0, 0x8fbf0018,
47744 -       0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x2484166c, 0x00002821,
47745 -       0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00006c, 0xafa00014,
47746 -       0x3c040800, 0x24841660, 0x00002821, 0x00003021, 0x00003821, 0xafa00010,
47747 -       0x0e00006c, 0xafa00014, 0x3c010800, 0xa4201fb8, 0x3c010800, 0xa02016f8,
47748 -       0x3c010800, 0xac2016fc, 0x3c010800, 0xac201700, 0x3c010800, 0xac201704,
47749 -       0x3c010800, 0xac20170c, 0x3c010800, 0xac201718, 0x3c010800, 0xac20171c,
47750 -       0x8f624434, 0x3c010800, 0xac2216e8, 0x8f624438, 0x3c010800, 0xac2216ec,
47751 -       0x8f624410, 0x3c010800, 0xac2016e0, 0x3c010800, 0xac2016e4, 0x3c010800,
47752 -       0xac201fc0, 0x3c010800, 0xac201f68, 0x3c010800, 0xac201f6c, 0x3c010800,
47753 -       0xac2216f0, 0x0e000120, 0x00002021, 0x8fbf0018, 0x03e00008, 0x27bd0020,
47754 -       0x24020001, 0x8f636820, 0x00821004, 0x00021027, 0x00621824, 0x03e00008,
47755 -       0xaf636820, 0x27bdffd0, 0x3c0300ff, 0xafbf002c, 0xafb60028, 0xafb50024,
47756 -       0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x8f665c5c,
47757 -       0x3c040800, 0x2484171c, 0x8c820000, 0x3463fff8, 0x14460005, 0x00c38824,
47758 -       0x3c020800, 0x904216f8, 0x14400115, 0x00000000, 0x00111902, 0x306300ff,
47759 -       0x30c20003, 0x000211c0, 0x00623825, 0x00e02821, 0x00061602, 0xac860000,
47760 -       0x3c030800, 0x906316f8, 0x3044000f, 0x1460002b, 0x00804021, 0x24020001,
47761 -       0x3c010800, 0xa02216f8, 0x00071100, 0x00821025, 0x3c010800, 0xac2016fc,
47762 -       0x3c010800, 0xac201700, 0x3c010800, 0xac201704, 0x3c010800, 0xac20170c,
47763 -       0x3c010800, 0xac201718, 0x3c010800, 0xac201710, 0x3c010800, 0xac201714,
47764 -       0x3c010800, 0xa4221fb8, 0x9623000c, 0x30628000, 0x10400008, 0x30627fff,
47765 -       0x2442003e, 0x3c010800, 0xa42216f6, 0x24020001, 0x3c010800, 0x0a00016e,
47766 -       0xac221fd4, 0x24620036, 0x3c010800, 0xa42216f6, 0x3c010800, 0xac201fd4,
47767 -       0x3c010800, 0xac201fd0, 0x3c010800, 0x0a000176, 0xac201fd8, 0x9622000c,
47768 -       0x3c010800, 0xa4221fcc, 0x3c040800, 0x248416fc, 0x8c820000, 0x00021100,
47769 -       0x3c010800, 0x00220821, 0xac311728, 0x8c820000, 0x00021100, 0x3c010800,
47770 -       0x00220821, 0xac26172c, 0x8c820000, 0x24a30001, 0x306701ff, 0x00021100,
47771 -       0x3c010800, 0x00220821, 0xac271730, 0x8c820000, 0x00021100, 0x3c010800,
47772 -       0x00220821, 0xac281734, 0x96230008, 0x3c020800, 0x8c42170c, 0x00432821,
47773 -       0x3c010800, 0xac25170c, 0x9622000a, 0x30420004, 0x14400019, 0x00071100,
47774 -       0x3c02c000, 0x00c21825, 0xaf635c5c, 0x8f625c50, 0x30420002, 0x1440fffc,
47775 -       0x00000000, 0x8f630c14, 0x3063000f, 0x2c620002, 0x1440001e, 0x00000000,
47776 -       0x8f630c14, 0x3c020800, 0x8c4216b4, 0x3063000f, 0x24420001, 0x3c010800,
47777 -       0xac2216b4, 0x2c620002, 0x1040fff7, 0x00000000, 0x0a0001c1, 0x00000000,
47778 -       0x3c030800, 0x8c6316e0, 0x3c040800, 0x948416f4, 0x01021025, 0x3c010800,
47779 -       0xa4221fba, 0x24020001, 0x3c010800, 0xac221718, 0x24630001, 0x0085202a,
47780 -       0x3c010800, 0x10800003, 0xac2316e0, 0x3c010800, 0xa42516f4, 0x3c030800,
47781 -       0x246316fc, 0x8c620000, 0x24420001, 0xac620000, 0x28420080, 0x14400005,
47782 -       0x24020001, 0x0e0002df, 0x24040002, 0x0a000250, 0x00000000, 0x3c030800,
47783 -       0x906316f8, 0x1462007c, 0x24020003, 0x3c160800, 0x96d616f6, 0x3c050800,
47784 -       0x8ca5170c, 0x32c4ffff, 0x00a4102a, 0x14400078, 0x00000000, 0x3c020800,
47785 -       0x8c421718, 0x10400005, 0x32c2ffff, 0x14a40003, 0x00000000, 0x3c010800,
47786 -       0xac231fd0, 0x10400062, 0x00009021, 0x0040a021, 0x3c150800, 0x26b51700,
47787 -       0x26b30010, 0x8ea20000, 0x00028100, 0x3c110800, 0x02308821, 0x0e0002e1,
47788 -       0x8e311728, 0x00403021, 0x10c00059, 0x00000000, 0x9628000a, 0x31020040,
47789 -       0x10400004, 0x2407180c, 0x8e22000c, 0x2407188c, 0xacc20018, 0x31021000,
47790 -       0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825, 0x3c030800,
47791 -       0x00701821, 0x8c631730, 0x3c020800, 0x00501021, 0x8c421734, 0x00031d00,
47792 -       0x00021400, 0x00621825, 0xacc30014, 0x8ea30004, 0x96220008, 0x00432023,
47793 -       0x3242ffff, 0x3083ffff, 0x00431021, 0x0282102a, 0x14400002, 0x02d22823,
47794 -       0x00802821, 0x8e620000, 0x30a4ffff, 0x00441021, 0xae620000, 0x8e220000,
47795 -       0xacc20000, 0x8e220004, 0x8e63fff4, 0x00431021, 0xacc20004, 0xa4c5000e,
47796 -       0x8e62fff4, 0x00441021, 0xae62fff4, 0x96230008, 0x0043102a, 0x14400005,
47797 -       0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001, 0xae62fff0, 0xacc00008,
47798 -       0x3242ffff, 0x14540008, 0x24020305, 0x31020080, 0x54400001, 0x34e70010,
47799 -       0x24020905, 0xa4c2000c, 0x0a000233, 0x34e70020, 0xa4c2000c, 0x30e2ffff,
47800 -       0xacc20010, 0x3c020800, 0x8c421fd0, 0x10400003, 0x3c024b65, 0x0a00023d,
47801 -       0x34427654, 0x3c02b49a, 0x344289ab, 0xacc2001c, 0x0e000560, 0x00c02021,
47802 -       0x3242ffff, 0x0054102b, 0x1440ffa4, 0x00000000, 0x24020002, 0x3c010800,
47803 -       0x0a000250, 0xa02216f8, 0x8ea208bc, 0x24420001, 0x0a000250, 0xaea208bc,
47804 -       0x14620003, 0x00000000, 0x0e000450, 0x00000000, 0x8fbf002c, 0x8fb60028,
47805 -       0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
47806 -       0x03e00008, 0x27bd0030, 0x27bdffd8, 0xafb3001c, 0x00809821, 0xafbf0020,
47807 -       0xafb20018, 0xafb10014, 0xafb00010, 0x8f725c9c, 0x3c0200ff, 0x3442fff8,
47808 -       0x3c040800, 0x24841714, 0x02428824, 0x9623000e, 0x8c820000, 0x00431021,
47809 -       0xac820000, 0x8e220010, 0x30420020, 0x14400011, 0x00000000, 0x0e0002f7,
47810 +       0x0000000d, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0x3c04fefe,
47811 +       0xafbf0018, 0x0e0005e0, 0x34840002, 0x0e000670, 0x00000000, 0x3c030800,
47812 +       0x90631b78, 0x24020002, 0x3c040800, 0x24841acc, 0x14620003, 0x24050001,
47813 +       0x3c040800, 0x24841ac0, 0x24060002, 0x00003821, 0xafa00010, 0x0e000684,
47814 +       0xafa00014, 0x8f625c50, 0x34420001, 0xaf625c50, 0x8f625c90, 0x34420001,
47815 +       0xaf625c90, 0x2402ffff, 0x0e000034, 0xaf625404, 0x8fbf0018, 0x03e00008,
47816 +       0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0xafbf0018,
47817 +       0xafb10014, 0x0e000052, 0xafb00010, 0x24110001, 0x8f706820, 0x32020100,
47818 +       0x10400003, 0x00000000, 0x0e0000b2, 0x00000000, 0x8f706820, 0x32022000,
47819 +       0x10400004, 0x32020001, 0x0e0001e3, 0x24040001, 0x32020001, 0x10400003,
47820 +       0x00000000, 0x0e00009a, 0x00000000, 0x0a00003a, 0xaf715028, 0x8fbf0018,
47821 +       0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800,
47822 +       0x24841ae0, 0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
47823 +       0x0e000684, 0xafa00014, 0x3c040800, 0x248423e8, 0xa4800000, 0x3c010800,
47824 +       0xa0201ba8, 0x3c010800, 0xac201bac, 0x3c010800, 0xac201bb0, 0x3c010800,
47825 +       0xac201bb4, 0x3c010800, 0xac201bbc, 0x3c010800, 0xac201bc8, 0x3c010800,
47826 +       0xac201bcc, 0x8f624434, 0x3c010800, 0xac221b98, 0x8f624438, 0x3c010800,
47827 +       0xac221b9c, 0x8f624410, 0xac80f7a8, 0x3c010800, 0xac201b94, 0x3c010800,
47828 +       0xac2023f0, 0x3c010800, 0xac2023d8, 0x3c010800, 0xac2023dc, 0x3c010800,
47829 +       0xac202410, 0x3c010800, 0xac221ba0, 0x8f620068, 0x24030007, 0x00021702,
47830 +       0x10430005, 0x00000000, 0x8f620068, 0x00021702, 0x14400004, 0x24020001,
47831 +       0x3c010800, 0x0a00008e, 0xac20241c, 0xac820034, 0x3c040800, 0x24841aec,
47832 +       0x3c050800, 0x8ca5241c, 0x00003021, 0x00003821, 0xafa00010, 0x0e000684,
47833 +       0xafa00014, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800,
47834 +       0x24841af8, 0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
47835 +       0x0e000684, 0xafa00014, 0x0e000052, 0x00000000, 0x0e0000ab, 0x00002021,
47836 +       0x8fbf0018, 0x03e00008, 0x27bd0020, 0x24020001, 0x8f636820, 0x00821004,
47837 +       0x00021027, 0x00621824, 0x03e00008, 0xaf636820, 0x27bdffd0, 0xafbf002c,
47838 +       0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014,
47839 +       0xafb00010, 0x8f665c5c, 0x3c030800, 0x24631bcc, 0x8c620000, 0x14460005,
47840 +       0x3c0200ff, 0x3c020800, 0x90421ba8, 0x14400115, 0x3c0200ff, 0x3442fff8,
47841 +       0x00c28824, 0xac660000, 0x00111902, 0x306300ff, 0x30c20003, 0x000211c0,
47842 +       0x00623825, 0x00e02821, 0x00061602, 0x3c030800, 0x90631ba8, 0x3044000f,
47843 +       0x1460002b, 0x00804021, 0x24020001, 0x3c010800, 0xa0221ba8, 0x00071100,
47844 +       0x00821025, 0x3c010800, 0xac201bac, 0x3c010800, 0xac201bb0, 0x3c010800,
47845 +       0xac201bb4, 0x3c010800, 0xac201bbc, 0x3c010800, 0xac201bc8, 0x3c010800,
47846 +       0xac201bc0, 0x3c010800, 0xac201bc4, 0x3c010800, 0xa42223e8, 0x9623000c,
47847 +       0x30628000, 0x10400008, 0x30627fff, 0x2442003e, 0x3c010800, 0xa4221ba6,
47848 +       0x24020001, 0x3c010800, 0x0a0000f9, 0xac222404, 0x24620036, 0x3c010800,
47849 +       0xa4221ba6, 0x3c010800, 0xac202404, 0x3c010800, 0xac202400, 0x3c010800,
47850 +       0x0a000101, 0xac202408, 0x9622000c, 0x3c010800, 0xa42223fc, 0x3c040800,
47851 +       0x24841bac, 0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac311bd8,
47852 +       0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac261bdc, 0x8c820000,
47853 +       0x24a30001, 0x306701ff, 0x00021100, 0x3c010800, 0x00220821, 0xac271be0,
47854 +       0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac281be4, 0x96230008,
47855 +       0x3c020800, 0x8c421bbc, 0x00432821, 0x3c010800, 0xac251bbc, 0x9622000a,
47856 +       0x30420004, 0x14400018, 0x00071100, 0x8f630c14, 0x3063000f, 0x2c620002,
47857 +       0x1440000b, 0x3c02c000, 0x8f630c14, 0x3c020800, 0x8c421b50, 0x3063000f,
47858 +       0x24420001, 0x3c010800, 0xac221b50, 0x2c620002, 0x1040fff7, 0x3c02c000,
47859 +       0x00c21825, 0xaf635c5c, 0x8f625c50, 0x30420002, 0x10400014, 0x00000000,
47860 +       0x0a000133, 0x00000000, 0x3c030800, 0x8c631b90, 0x3c040800, 0x94841ba4,
47861 +       0x01021025, 0x3c010800, 0xa42223ea, 0x24020001, 0x3c010800, 0xac221bc8,
47862 +       0x24630001, 0x0085202a, 0x3c010800, 0x10800003, 0xac231b90, 0x3c010800,
47863 +       0xa4251ba4, 0x3c060800, 0x24c61bac, 0x8cc20000, 0x24420001, 0xacc20000,
47864 +       0x28420080, 0x14400005, 0x00000000, 0x0e00065e, 0x24040002, 0x0a0001d9,
47865 +       0x00000000, 0x3c020800, 0x8c421bc8, 0x1040007f, 0x24020001, 0x3c040800,
47866 +       0x90841ba8, 0x14820077, 0x24020003, 0x3c150800, 0x96b51ba6, 0x3c050800,
47867 +       0x8ca51bbc, 0x32a3ffff, 0x00a3102a, 0x14400073, 0x00000000, 0x14a30003,
47868 +       0x00000000, 0x3c010800, 0xac242400, 0x10600061, 0x00009021, 0x24d60004,
47869 +       0x0060a021, 0x24d30014, 0x8ec20000, 0x00028100, 0x3c110800, 0x02308821,
47870 +       0x0e00062d, 0x8e311bd8, 0x00403021, 0x10c00059, 0x00000000, 0x9628000a,
47871 +       0x31020040, 0x10400004, 0x2407180c, 0x8e22000c, 0x2407188c, 0xacc20018,
47872 +       0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825,
47873 +       0x3c030800, 0x00701821, 0x8c631be0, 0x3c020800, 0x00501021, 0x8c421be4,
47874 +       0x00031d00, 0x00021400, 0x00621825, 0xacc30014, 0x8ec30004, 0x96220008,
47875 +       0x00432023, 0x3242ffff, 0x3083ffff, 0x00431021, 0x0282102a, 0x14400002,
47876 +       0x02b22823, 0x00802821, 0x8e620000, 0x30a4ffff, 0x00441021, 0xae620000,
47877 +       0x8e220000, 0xacc20000, 0x8e220004, 0x8e63fff4, 0x00431021, 0xacc20004,
47878 +       0xa4c5000e, 0x8e62fff4, 0x00441021, 0xae62fff4, 0x96230008, 0x0043102a,
47879 +       0x14400005, 0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001, 0xae62fff0,
47880 +       0xacc00008, 0x3242ffff, 0x14540008, 0x24020305, 0x31020080, 0x54400001,
47881 +       0x34e70010, 0x24020905, 0xa4c2000c, 0x0a0001bc, 0x34e70020, 0xa4c2000c,
47882 +       0x3c020800, 0x8c422400, 0x10400003, 0x3c024b65, 0x0a0001c4, 0x34427654,
47883 +       0x3c02b49a, 0x344289ab, 0xacc2001c, 0x30e2ffff, 0xacc20010, 0x0e0005aa,
47884 +       0x00c02021, 0x3242ffff, 0x0054102b, 0x1440ffa4, 0x00000000, 0x24020002,
47885 +       0x3c010800, 0x0a0001d9, 0xa0221ba8, 0x8ec2083c, 0x24420001, 0x0a0001d9,
47886 +       0xaec2083c, 0x14820003, 0x00000000, 0x0e0004b9, 0x00000000, 0x8fbf002c,
47887 +       0x8fb60028, 0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
47888 +       0x8fb00010, 0x03e00008, 0x27bd0030, 0x27bdffd0, 0xafbf0028, 0xafb30024,
47889 +       0xafb20020, 0xafb1001c, 0xafb00018, 0x8f725c9c, 0x3c0200ff, 0x3442fff8,
47890 +       0x3c060800, 0x24c61bc4, 0x02428824, 0x9623000e, 0x8cc20000, 0x00431021,
47891 +       0xacc20000, 0x8e220010, 0x30420020, 0x14400011, 0x00809821, 0x0e000643,
47892         0x02202021, 0x3c02c000, 0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002,
47893 -       0x10400061, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1040005c,
47894 -       0x00000000, 0x0a000278, 0x00000000, 0x8e220008, 0x00021c02, 0x000321c0,
47895 -       0x3042ffff, 0x3c030800, 0x906316f8, 0x000229c0, 0x24020002, 0x14620003,
47896 -       0x3c034b65, 0x0a000290, 0x00008021, 0x8e22001c, 0x34637654, 0x10430002,
47897 -       0x24100002, 0x24100001, 0x0e000300, 0x02003021, 0x24020003, 0x3c010800,
47898 -       0xa02216f8, 0x24020002, 0x1202000a, 0x24020001, 0x3c030800, 0x8c631fd0,
47899 -       0x10620006, 0x00000000, 0x3c020800, 0x94421fb8, 0x00021400, 0x0a0002cd,
47900 -       0xae220014, 0x3c040800, 0x24841fba, 0x94820000, 0x00021400, 0xae220014,
47901 -       0x3c020800, 0x8c42171c, 0x3c03c000, 0x3c010800, 0xa02016f8, 0x00431025,
47902 -       0xaf625c5c, 0x8f625c50, 0x30420002, 0x10400009, 0x00000000, 0x2484f762,
47903 +       0x10400121, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1040011c,
47904 +       0x00000000, 0x0a000200, 0x00000000, 0x8e240008, 0x8e230014, 0x00041402,
47905 +       0x000241c0, 0x00031502, 0x304201ff, 0x2442ffff, 0x3042007f, 0x00031942,
47906 +       0x30637800, 0x00021100, 0x24424000, 0x00625021, 0x9542000a, 0x3084ffff,
47907 +       0x30420008, 0x104000b3, 0x000429c0, 0x3c020800, 0x8c422410, 0x1440002d,
47908 +       0x25050008, 0x95020014, 0x3c010800, 0xa42223e0, 0x8d070010, 0x00071402,
47909 +       0x3c010800, 0xa42223e2, 0x3c010800, 0xa42723e4, 0x9502000e, 0x30e3ffff,
47910 +       0x00431023, 0x3c010800, 0xac222418, 0x8f626800, 0x3c030010, 0x00431024,
47911 +       0x10400005, 0x00000000, 0x9503001a, 0x9502001c, 0x0a000235, 0x00431021,
47912 +       0x9502001a, 0x3c010800, 0xac22240c, 0x3c02c000, 0x02421825, 0x3c010800,
47913 +       0xac282410, 0x3c010800, 0xac322414, 0xaf635c9c, 0x8f625c90, 0x30420002,
47914 +       0x104000df, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x104000da,
47915 +       0x00000000, 0x0a000242, 0x00000000, 0x9502000e, 0x3c030800, 0x946323e4,
47916 +       0x00434823, 0x3123ffff, 0x2c620008, 0x1040001c, 0x00000000, 0x95020014,
47917 +       0x24420028, 0x00a22821, 0x00031042, 0x1840000b, 0x00002021, 0x24c60848,
47918 +       0x00403821, 0x94a30000, 0x8cc20000, 0x24840001, 0x00431021, 0xacc20000,
47919 +       0x0087102a, 0x1440fff9, 0x24a50002, 0x31220001, 0x1040001f, 0x3c024000,
47920 +       0x3c040800, 0x2484240c, 0xa0a00001, 0x94a30000, 0x8c820000, 0x00431021,
47921 +       0x0a000281, 0xac820000, 0x8f626800, 0x3c030010, 0x00431024, 0x10400009,
47922 +       0x00000000, 0x9502001a, 0x3c030800, 0x8c63240c, 0x00431021, 0x3c010800,
47923 +       0xac22240c, 0x0a000282, 0x3c024000, 0x9502001a, 0x9504001c, 0x3c030800,
47924 +       0x8c63240c, 0x00441023, 0x00621821, 0x3c010800, 0xac23240c, 0x3c024000,
47925 +       0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1440fffc, 0x00000000,
47926 +       0x9542000a, 0x30420010, 0x10400095, 0x00000000, 0x3c060800, 0x24c62410,
47927 +       0x3c020800, 0x944223e4, 0x8cc50000, 0x3c040800, 0x8c842418, 0x24420030,
47928 +       0x00a22821, 0x94a20004, 0x3c030800, 0x8c63240c, 0x00441023, 0x00621821,
47929 +       0x00603821, 0x00032402, 0x30e2ffff, 0x00823821, 0x00071402, 0x00e23821,
47930 +       0x00071027, 0x3c010800, 0xac23240c, 0xa4a20006, 0x3c030800, 0x8c632414,
47931 +       0x3c0200ff, 0x3442fff8, 0x00628824, 0x96220008, 0x24040001, 0x24034000,
47932 +       0x000241c0, 0x00e01021, 0xa502001a, 0xa500001c, 0xacc00000, 0x3c010800,
47933 +       0xac241b70, 0xaf635cb8, 0x8f625cb0, 0x30420002, 0x10400003, 0x00000000,
47934 +       0x3c010800, 0xac201b70, 0x8e220008, 0xaf625cb8, 0x8f625cb0, 0x30420002,
47935 +       0x10400003, 0x00000000, 0x3c010800, 0xac201b70, 0x3c020800, 0x8c421b70,
47936 +       0x1040ffec, 0x00000000, 0x3c040800, 0x0e000643, 0x8c842414, 0x0a000320,
47937 +       0x00000000, 0x3c030800, 0x90631ba8, 0x24020002, 0x14620003, 0x3c034b65,
47938 +       0x0a0002d7, 0x00008021, 0x8e22001c, 0x34637654, 0x10430002, 0x24100002,
47939 +       0x24100001, 0x01002021, 0x0e000346, 0x02003021, 0x24020003, 0x3c010800,
47940 +       0xa0221ba8, 0x24020002, 0x1202000a, 0x24020001, 0x3c030800, 0x8c632400,
47941 +       0x10620006, 0x00000000, 0x3c020800, 0x944223e8, 0x00021400, 0x0a000315,
47942 +       0xae220014, 0x3c040800, 0x248423ea, 0x94820000, 0x00021400, 0xae220014,
47943 +       0x3c020800, 0x8c421bcc, 0x3c03c000, 0x3c010800, 0xa0201ba8, 0x00431025,
47944 +       0xaf625c5c, 0x8f625c50, 0x30420002, 0x10400009, 0x00000000, 0x2484f7e2,
47945         0x8c820000, 0x00431025, 0xaf625c5c, 0x8f625c50, 0x30420002, 0x1440fffa,
47946 -       0x00000000, 0x3c020800, 0x244216e4, 0x8c430000, 0x24630001, 0xac430000,
47947 -       0x8f630c14, 0x3063000f, 0x2c620002, 0x1440000b, 0x00009821, 0x8f630c14,
47948 -       0x3c020800, 0x8c4216b4, 0x3063000f, 0x24420001, 0x3c010800, 0xac2216b4,
47949 -       0x2c620002, 0x1040fff7, 0x00009821, 0x3c024000, 0x02421825, 0xaf635c9c,
47950 +       0x00000000, 0x3c020800, 0x24421b94, 0x8c430000, 0x24630001, 0xac430000,
47951 +       0x8f630c14, 0x3063000f, 0x2c620002, 0x1440000c, 0x3c024000, 0x8f630c14,
47952 +       0x3c020800, 0x8c421b50, 0x3063000f, 0x24420001, 0x3c010800, 0xac221b50,
47953 +       0x2c620002, 0x1040fff7, 0x00000000, 0x3c024000, 0x02421825, 0xaf635c9c,
47954         0x8f625c90, 0x30420002, 0x1440fffc, 0x00000000, 0x12600003, 0x00000000,
47955 -       0x0e000450, 0x00000000, 0x8fbf0020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
47956 -       0x8fb00010, 0x03e00008, 0x27bd0028, 0x0a0002df, 0x00000000, 0x8f634450,
47957 -       0x3c040800, 0x248416e8, 0x8c820000, 0x00031c02, 0x0043102b, 0x14400007,
47958 -       0x3c038000, 0x8c840004, 0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc,
47959 -       0x3c038000, 0xaf634444, 0x8f624444, 0x00431024, 0x1440fffd, 0x00000000,
47960 -       0x8f624448, 0x03e00008, 0x3042ffff, 0x3c024000, 0x00822025, 0xaf645c38,
47961 -       0x8f625c30, 0x30420002, 0x1440fffc, 0x00000000, 0x03e00008, 0x00000000,
47962 -       0x27bdffe0, 0x00805021, 0x14c00017, 0x254c0008, 0x3c020800, 0x8c421fd4,
47963 -       0x1040000a, 0x2402003e, 0x3c010800, 0xa4221fb0, 0x24020016, 0x3c010800,
47964 -       0xa4221fb2, 0x2402002a, 0x3c010800, 0x0a00031a, 0xa4221fb4, 0x95420014,
47965 -       0x3c010800, 0xa4221fb0, 0x8d430010, 0x00031402, 0x3c010800, 0xa4221fb2,
47966 -       0x3c010800, 0xa4231fb4, 0x3c040800, 0x94841fb4, 0x3c030800, 0x94631fb2,
47967 -       0x958d0006, 0x3c020800, 0x94421fb0, 0x00832023, 0x01a27023, 0x3065ffff,
47968 -       0x24a20028, 0x01824021, 0x3082ffff, 0x14c0001a, 0x01025821, 0x9562000c,
47969 -       0x3042003f, 0x3c010800, 0xa4221fb6, 0x95620004, 0x95630006, 0x3c010800,
47970 -       0xac201fc4, 0x3c010800, 0xac201fc8, 0x00021400, 0x00431025, 0x3c010800,
47971 -       0xac221720, 0x95020004, 0x3c010800, 0xa4221724, 0x95030002, 0x01a51023,
47972 -       0x0043102a, 0x10400010, 0x24020001, 0x3c010800, 0x0a00034e, 0xac221fd8,
47973 -       0x3c030800, 0x8c631fc8, 0x3c020800, 0x94421724, 0x00431021, 0xa5020004,
47974 -       0x3c020800, 0x94421720, 0xa5620004, 0x3c020800, 0x8c421720, 0xa5620006,
47975 -       0x3c020800, 0x8c421fd0, 0x3c070800, 0x8ce71fc4, 0x3c050800, 0x144000c7,
47976 -       0x8ca51fc8, 0x3c020800, 0x94421724, 0x00451821, 0x3063ffff, 0x0062182b,
47977 -       0x24020002, 0x10c2000d, 0x00a32823, 0x3c020800, 0x94421fb6, 0x30420009,
47978 -       0x10400008, 0x00000000, 0x9562000c, 0x3042fff6, 0xa562000c, 0x3c020800,
47979 -       0x94421fb6, 0x30420009, 0x00e23823, 0x3c020800, 0x8c421fd8, 0x1040004b,
47980 -       0x24020002, 0x01003021, 0x3c020800, 0x94421fb2, 0x00003821, 0xa500000a,
47981 -       0x01a21023, 0xa5020002, 0x3082ffff, 0x00021042, 0x18400008, 0x00002821,
47982 -       0x00401821, 0x94c20000, 0x24e70001, 0x00a22821, 0x00e3102a, 0x1440fffb,
47983 -       0x24c60002, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
47984 -       0x00a04821, 0x00051027, 0xa502000a, 0x00002821, 0x2506000c, 0x00003821,
47985 -       0x94c20000, 0x24e70001, 0x00a22821, 0x2ce20004, 0x1440fffb, 0x24c60002,
47986 -       0x95020002, 0x00003821, 0x91030009, 0x00442023, 0x01603021, 0x3082ffff,
47987 -       0xa4c00010, 0x00621821, 0x00021042, 0x18400010, 0x00a32821, 0x00404021,
47988 -       0x94c20000, 0x24c60002, 0x00a22821, 0x30c2007f, 0x14400006, 0x24e70001,
47989 -       0x8d430000, 0x3c02007f, 0x3442ff80, 0x00625024, 0x25460008, 0x00e8102a,
47990 -       0x1440fff3, 0x00000000, 0x30820001, 0x10400005, 0x00051c02, 0xa0c00001,
47991 -       0x94c20000, 0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
47992 -       0x00a22821, 0x0a000415, 0x30a5ffff, 0x14c20063, 0x00000000, 0x3c090800,
47993 -       0x95291fb2, 0x95030002, 0x01a91023, 0x1062005d, 0x01003021, 0x00003821,
47994 -       0x00002821, 0x01a91023, 0xa5020002, 0x3082ffff, 0x00021042, 0x18400008,
47995 -       0xa500000a, 0x00401821, 0x94c20000, 0x24e70001, 0x00a22821, 0x00e3102a,
47996 -       0x1440fffb, 0x24c60002, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
47997 -       0x00a22821, 0x00a04821, 0x00051027, 0xa502000a, 0x00002821, 0x2506000c,
47998 -       0x00003821, 0x94c20000, 0x24e70001, 0x00a22821, 0x2ce20004, 0x1440fffb,
47999 -       0x24c60002, 0x95020002, 0x00003821, 0x91030009, 0x00442023, 0x01603021,
48000 -       0x3082ffff, 0xa4c00010, 0x3c040800, 0x94841fb4, 0x00621821, 0x00a32821,
48001 -       0x00051c02, 0x30a2ffff, 0x00622821, 0x00051c02, 0x3c020800, 0x94421fb0,
48002 -       0x00a34021, 0x00441023, 0x00021fc2, 0x00431021, 0x00021043, 0x18400010,
48003 -       0x00002821, 0x00402021, 0x94c20000, 0x24c60002, 0x00a22821, 0x30c2007f,
48004 -       0x14400006, 0x24e70001, 0x8d430000, 0x3c02007f, 0x3442ff80, 0x00625024,
48005 -       0x25460008, 0x00e4102a, 0x1440fff3, 0x00000000, 0x3c020800, 0x94421fcc,
48006 -       0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
48007 -       0x3102ffff, 0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
48008 -       0x00a22821, 0x00a02021, 0x00051027, 0xa5620010, 0xad800014, 0x0a000435,
48009 -       0xad800000, 0x8d830010, 0x00602021, 0x10a00007, 0x00034c02, 0x01252821,
48010 -       0x00051402, 0x30a3ffff, 0x00432821, 0x00051402, 0x00a24821, 0x00091027,
48011 -       0xa502000a, 0x3c030800, 0x94631fb4, 0x3082ffff, 0x01a21021, 0x00432823,
48012 -       0x00a72821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
48013 -       0x00a02021, 0x00051027, 0xa5620010, 0x3082ffff, 0x00091c00, 0x00431025,
48014 -       0xad820010, 0x3c020800, 0x8c421fd4, 0x10400002, 0x25a2fff2, 0xa5820034,
48015 -       0x3c020800, 0x8c421fc8, 0x3c030800, 0x8c631720, 0x24420001, 0x3c010800,
48016 -       0xac221fc8, 0x3c020800, 0x8c421fc4, 0x31c4ffff, 0x00641821, 0x3c010800,
48017 -       0xac231720, 0x00441021, 0x3c010800, 0xac221fc4, 0x03e00008, 0x27bd0020,
48018 -       0x27bdffc8, 0x3c040800, 0x248416f8, 0xafbf0034, 0xafbe0030, 0xafb7002c,
48019 -       0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014,
48020 -       0xafb00010, 0x90830000, 0x24020003, 0x146200f4, 0x00000000, 0x3c020800,
48021 -       0x8c421710, 0x3c030800, 0x8c63170c, 0x3c1e0800, 0x97de16f6, 0x0043102a,
48022 -       0x104000eb, 0x3c168000, 0x249708c4, 0x33d5ffff, 0x24920018, 0x3c020800,
48023 -       0x8c421718, 0x104000e4, 0x00000000, 0x3c140800, 0x96941fb0, 0x3282ffff,
48024 -       0x104000d6, 0x00008021, 0x00409821, 0x00008821, 0x8f634450, 0x3c020800,
48025 -       0x8c4216e8, 0x00031c02, 0x0043102b, 0x14400008, 0x00000000, 0x3c040800,
48026 -       0x8c8416ec, 0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x00000000,
48027 -       0xaf764444, 0x8f624444, 0x00561024, 0x10400006, 0x00000000, 0x3c038000,
48028 -       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x3046ffff,
48029 -       0x10c0005f, 0x00000000, 0x3c090800, 0x01314821, 0x8d291728, 0x9528000a,
48030 -       0x31020040, 0x10400004, 0x2407180c, 0x8d22000c, 0x2407188c, 0xacc20018,
48031 -       0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825,
48032 -       0x31020080, 0x54400001, 0x34e70010, 0x3c020800, 0x00511021, 0x8c421730,
48033 -       0x3c030800, 0x00711821, 0x8c631734, 0x00021500, 0x00031c00, 0x00431025,
48034 -       0xacc20014, 0x95240008, 0x3202ffff, 0x00821021, 0x0262102a, 0x14400002,
48035 -       0x02902823, 0x00802821, 0x8d220000, 0x02058021, 0xacc20000, 0x8d220004,
48036 -       0x00c02021, 0x26310010, 0xac820004, 0x30e2ffff, 0xac800008, 0xa485000e,
48037 -       0xac820010, 0x24020305, 0x0e000560, 0xa482000c, 0x3202ffff, 0x0053102b,
48038 -       0x1440ffaf, 0x3202ffff, 0x0a00054c, 0x00000000, 0x8e420000, 0x8e43fffc,
48039 -       0x0043102a, 0x10400084, 0x00000000, 0x8e45fff0, 0x8f644450, 0x3c030800,
48040 -       0x8c6316e8, 0x00051100, 0x3c090800, 0x01224821, 0x8d291728, 0x00041402,
48041 -       0x0062182b, 0x14600008, 0x00000000, 0x3c030800, 0x8c6316ec, 0x8f624450,
48042 -       0x00021402, 0x0062102b, 0x1040fffc, 0x00000000, 0xaf764444, 0x8f624444,
48043 -       0x00561024, 0x10400006, 0x00000000, 0x3c038000, 0x8f624444, 0x00431024,
48044 -       0x1440fffd, 0x00000000, 0x8f624448, 0x3046ffff, 0x14c00005, 0x00000000,
48045 -       0x8ee20000, 0x24420001, 0x0a000554, 0xaee20000, 0x9528000a, 0x31020040,
48046 -       0x10400004, 0x2407180c, 0x8d22000c, 0x2407188c, 0xacc20018, 0x31021000,
48047 -       0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825, 0x00051900,
48048 -       0x3c020800, 0x00431021, 0x8c421730, 0x3c010800, 0x00230821, 0x8c231734,
48049 -       0x00021500, 0x00031c00, 0x00431025, 0xacc20014, 0x3c030800, 0x8c631704,
48050 -       0x95220008, 0x00432023, 0x3202ffff, 0x3083ffff, 0x00431021, 0x02a2102a,
48051 -       0x14400002, 0x03d02823, 0x00802821, 0x8e420000, 0x30a4ffff, 0x00441021,
48052 -       0xae420000, 0xa4c5000e, 0x8d220000, 0xacc20000, 0x8d220004, 0x8e43fff4,
48053 -       0x00431021, 0xacc20004, 0x8e43fff4, 0x95220008, 0x00641821, 0x0062102a,
48054 -       0x14400006, 0x02058021, 0x8e42fff0, 0xae40fff4, 0x24420001, 0x0a000530,
48055 -       0xae42fff0, 0xae43fff4, 0xacc00008, 0x3202ffff, 0x10550003, 0x31020004,
48056 -       0x10400006, 0x24020305, 0x31020080, 0x54400001, 0x34e70010, 0x34e70020,
48057 -       0x24020905, 0xa4c2000c, 0x30e2ffff, 0xacc20010, 0x3c030800, 0x8c63170c,
48058 -       0x3c020800, 0x8c421710, 0x54620004, 0x3c02b49a, 0x3c024b65, 0x0a000548,
48059 -       0x34427654, 0x344289ab, 0xacc2001c, 0x0e000560, 0x00c02021, 0x3202ffff,
48060 -       0x0055102b, 0x1440ff7e, 0x00000000, 0x8e420000, 0x8e43fffc, 0x0043102a,
48061 -       0x1440ff1a, 0x00000000, 0x8fbf0034, 0x8fbe0030, 0x8fb7002c, 0x8fb60028,
48062 -       0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
48063 -       0x03e00008, 0x27bd0038, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f624450,
48064 -       0x8f634410, 0x0a00056f, 0x00808021, 0x8f626820, 0x30422000, 0x10400003,
48065 -       0x00000000, 0x0e00025a, 0x00002021, 0x8f624450, 0x8f634410, 0x3042ffff,
48066 -       0x0043102b, 0x1440fff5, 0x00000000, 0x8f630c14, 0x3063000f, 0x2c620002,
48067 -       0x1440000b, 0x00000000, 0x8f630c14, 0x3c020800, 0x8c4216b4, 0x3063000f,
48068 -       0x24420001, 0x3c010800, 0xac2216b4, 0x2c620002, 0x1040fff7, 0x00000000,
48069 -       0xaf705c18, 0x8f625c10, 0x30420002, 0x10400009, 0x00000000, 0x8f626820,
48070 -       0x30422000, 0x1040fff8, 0x00000000, 0x0e00025a, 0x00002021, 0x0a000582,
48071 -       0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x00000000,
48072 -       0x00000000
48073 +       0x0e0004b9, 0x00000000, 0x8fbf0028, 0x8fb30024, 0x8fb20020, 0x8fb1001c,
48074 +       0x8fb00018, 0x03e00008, 0x27bd0030, 0x8f634450, 0x3c040800, 0x24841b98,
48075 +       0x8c820000, 0x00031c02, 0x0043102b, 0x14400007, 0x3c038000, 0x8c840004,
48076 +       0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444,
48077 +       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008,
48078 +       0x3042ffff, 0x3c024000, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002,
48079 +       0x1440fffc, 0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00805821,
48080 +       0x14c00017, 0x256e0008, 0x3c020800, 0x8c422404, 0x1040000a, 0x2402003e,
48081 +       0x3c010800, 0xa42223e0, 0x24020016, 0x3c010800, 0xa42223e2, 0x2402002a,
48082 +       0x3c010800, 0x0a000360, 0xa42223e4, 0x95620014, 0x3c010800, 0xa42223e0,
48083 +       0x8d670010, 0x00071402, 0x3c010800, 0xa42223e2, 0x3c010800, 0xa42723e4,
48084 +       0x3c040800, 0x948423e4, 0x3c030800, 0x946323e2, 0x95cf0006, 0x3c020800,
48085 +       0x944223e0, 0x00832023, 0x01e2c023, 0x3065ffff, 0x24a20028, 0x01c24821,
48086 +       0x3082ffff, 0x14c0001a, 0x01226021, 0x9582000c, 0x3042003f, 0x3c010800,
48087 +       0xa42223e6, 0x95820004, 0x95830006, 0x3c010800, 0xac2023f4, 0x3c010800,
48088 +       0xac2023f8, 0x00021400, 0x00431025, 0x3c010800, 0xac221bd0, 0x95220004,
48089 +       0x3c010800, 0xa4221bd4, 0x95230002, 0x01e51023, 0x0043102a, 0x10400010,
48090 +       0x24020001, 0x3c010800, 0x0a000394, 0xac222408, 0x3c030800, 0x8c6323f8,
48091 +       0x3c020800, 0x94421bd4, 0x00431021, 0xa5220004, 0x3c020800, 0x94421bd0,
48092 +       0xa5820004, 0x3c020800, 0x8c421bd0, 0xa5820006, 0x3c020800, 0x8c422400,
48093 +       0x3c0d0800, 0x8dad23f4, 0x3c0a0800, 0x144000e5, 0x8d4a23f8, 0x3c020800,
48094 +       0x94421bd4, 0x004a1821, 0x3063ffff, 0x0062182b, 0x24020002, 0x10c2000d,
48095 +       0x01435023, 0x3c020800, 0x944223e6, 0x30420009, 0x10400008, 0x00000000,
48096 +       0x9582000c, 0x3042fff6, 0xa582000c, 0x3c020800, 0x944223e6, 0x30420009,
48097 +       0x01a26823, 0x3c020800, 0x8c422408, 0x1040004a, 0x01203821, 0x3c020800,
48098 +       0x944223e2, 0x00004021, 0xa520000a, 0x01e21023, 0xa5220002, 0x3082ffff,
48099 +       0x00021042, 0x18400008, 0x00003021, 0x00401821, 0x94e20000, 0x25080001,
48100 +       0x00c23021, 0x0103102a, 0x1440fffb, 0x24e70002, 0x00061c02, 0x30c2ffff,
48101 +       0x00623021, 0x00061402, 0x00c23021, 0x00c02821, 0x00061027, 0xa522000a,
48102 +       0x00003021, 0x2527000c, 0x00004021, 0x94e20000, 0x25080001, 0x00c23021,
48103 +       0x2d020004, 0x1440fffb, 0x24e70002, 0x95220002, 0x00004021, 0x91230009,
48104 +       0x00442023, 0x01803821, 0x3082ffff, 0xa4e00010, 0x00621821, 0x00021042,
48105 +       0x18400010, 0x00c33021, 0x00404821, 0x94e20000, 0x24e70002, 0x00c23021,
48106 +       0x30e2007f, 0x14400006, 0x25080001, 0x8d630000, 0x3c02007f, 0x3442ff80,
48107 +       0x00625824, 0x25670008, 0x0109102a, 0x1440fff3, 0x00000000, 0x30820001,
48108 +       0x10400005, 0x00061c02, 0xa0e00001, 0x94e20000, 0x00c23021, 0x00061c02,
48109 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x0a000479, 0x30c6ffff,
48110 +       0x24020002, 0x14c20081, 0x00000000, 0x3c020800, 0x8c42241c, 0x14400007,
48111 +       0x00000000, 0x3c020800, 0x944223e2, 0x95230002, 0x01e21023, 0x10620077,
48112 +       0x00000000, 0x3c020800, 0x944223e2, 0x01e21023, 0xa5220002, 0x3c020800,
48113 +       0x8c42241c, 0x1040001a, 0x31e3ffff, 0x8dc70010, 0x3c020800, 0x94421ba6,
48114 +       0x00e04021, 0x00072c02, 0x00aa2021, 0x00431023, 0x00823823, 0x00072402,
48115 +       0x30e2ffff, 0x00823821, 0x00071027, 0xa522000a, 0x3102ffff, 0x3c040800,
48116 +       0x948423e4, 0x00453023, 0x00e02821, 0x00641823, 0x006d1821, 0x00c33021,
48117 +       0x00061c02, 0x30c2ffff, 0x0a000479, 0x00623021, 0x01203821, 0x00004021,
48118 +       0x3082ffff, 0x00021042, 0x18400008, 0x00003021, 0x00401821, 0x94e20000,
48119 +       0x25080001, 0x00c23021, 0x0103102a, 0x1440fffb, 0x24e70002, 0x00061c02,
48120 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c02821, 0x00061027,
48121 +       0xa522000a, 0x00003021, 0x2527000c, 0x00004021, 0x94e20000, 0x25080001,
48122 +       0x00c23021, 0x2d020004, 0x1440fffb, 0x24e70002, 0x95220002, 0x00004021,
48123 +       0x91230009, 0x00442023, 0x01803821, 0x3082ffff, 0xa4e00010, 0x3c040800,
48124 +       0x948423e4, 0x00621821, 0x00c33021, 0x00061c02, 0x30c2ffff, 0x00623021,
48125 +       0x00061c02, 0x3c020800, 0x944223e0, 0x00c34821, 0x00441023, 0x00021fc2,
48126 +       0x00431021, 0x00021043, 0x18400010, 0x00003021, 0x00402021, 0x94e20000,
48127 +       0x24e70002, 0x00c23021, 0x30e2007f, 0x14400006, 0x25080001, 0x8d630000,
48128 +       0x3c02007f, 0x3442ff80, 0x00625824, 0x25670008, 0x0104102a, 0x1440fff3,
48129 +       0x00000000, 0x3c020800, 0x944223fc, 0x00c23021, 0x3122ffff, 0x00c23021,
48130 +       0x00061c02, 0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c04021,
48131 +       0x00061027, 0xa5820010, 0xadc00014, 0x0a000499, 0xadc00000, 0x8dc70010,
48132 +       0x00e04021, 0x11400007, 0x00072c02, 0x00aa3021, 0x00061402, 0x30c3ffff,
48133 +       0x00433021, 0x00061402, 0x00c22821, 0x00051027, 0xa522000a, 0x3c030800,
48134 +       0x946323e4, 0x3102ffff, 0x01e21021, 0x00433023, 0x00cd3021, 0x00061c02,
48135 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c04021, 0x00061027,
48136 +       0xa5820010, 0x3102ffff, 0x00051c00, 0x00431025, 0xadc20010, 0x3c020800,
48137 +       0x8c422404, 0x10400002, 0x25e2fff2, 0xa5c20034, 0x3c020800, 0x8c4223f8,
48138 +       0x3c040800, 0x8c8423f4, 0x24420001, 0x3c010800, 0xac2223f8, 0x3c020800,
48139 +       0x8c421bd0, 0x3303ffff, 0x00832021, 0x3c010800, 0xac2423f4, 0x00431821,
48140 +       0x0062102b, 0x10400003, 0x2482ffff, 0x3c010800, 0xac2223f4, 0x3c010800,
48141 +       0xac231bd0, 0x03e00008, 0x27bd0020, 0x27bdffb8, 0x3c050800, 0x24a51ba8,
48142 +       0xafbf0044, 0xafbe0040, 0xafb7003c, 0xafb60038, 0xafb50034, 0xafb40030,
48143 +       0xafb3002c, 0xafb20028, 0xafb10024, 0xafb00020, 0x90a30000, 0x24020003,
48144 +       0x146200d5, 0x00000000, 0x3c090800, 0x95291ba6, 0x3c020800, 0x944223e0,
48145 +       0x3c030800, 0x8c631bc0, 0x3c040800, 0x8c841bbc, 0x01221023, 0x0064182a,
48146 +       0xa7a9001e, 0x106000c8, 0xa7a20016, 0x24be0020, 0x97b6001e, 0x24b30018,
48147 +       0x24b70014, 0x8fc20000, 0x14400008, 0x00000000, 0x8fc2fff8, 0x97a30016,
48148 +       0x8fc4fff4, 0x00431021, 0x0082202a, 0x148000ba, 0x00000000, 0x97d50818,
48149 +       0x32a2ffff, 0x104000ad, 0x00009021, 0x0040a021, 0x00008821, 0x0e00062d,
48150 +       0x00000000, 0x00403021, 0x14c00007, 0x00000000, 0x3c020800, 0x8c4223ec,
48151 +       0x24420001, 0x3c010800, 0x0a00059e, 0xac2223ec, 0x3c100800, 0x02118021,
48152 +       0x8e101bd8, 0x9608000a, 0x31020040, 0x10400004, 0x2407180c, 0x8e02000c,
48153 +       0x2407188c, 0xacc20018, 0x31021000, 0x10400004, 0x34e32000, 0x00081040,
48154 +       0x3042c000, 0x00623825, 0x31020080, 0x54400001, 0x34e70010, 0x3c020800,
48155 +       0x00511021, 0x8c421be0, 0x3c030800, 0x00711821, 0x8c631be4, 0x00021500,
48156 +       0x00031c00, 0x00431025, 0xacc20014, 0x96040008, 0x3242ffff, 0x00821021,
48157 +       0x0282102a, 0x14400002, 0x02b22823, 0x00802821, 0x8e020000, 0x02459021,
48158 +       0xacc20000, 0x8e020004, 0x00c02021, 0x26310010, 0xac820004, 0x30e2ffff,
48159 +       0xac800008, 0xa485000e, 0xac820010, 0x24020305, 0x0e0005aa, 0xa482000c,
48160 +       0x3242ffff, 0x0054102b, 0x1440ffc0, 0x3242ffff, 0x0a000596, 0x00000000,
48161 +       0x8e620000, 0x8e63fffc, 0x0043102a, 0x1040006c, 0x00000000, 0x8e62fff0,
48162 +       0x00028900, 0x3c100800, 0x02118021, 0x0e00062d, 0x8e101bd8, 0x00403021,
48163 +       0x14c00005, 0x00000000, 0x8e62082c, 0x24420001, 0x0a00059e, 0xae62082c,
48164 +       0x9608000a, 0x31020040, 0x10400004, 0x2407180c, 0x8e02000c, 0x2407188c,
48165 +       0xacc20018, 0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000,
48166 +       0x00623825, 0x3c020800, 0x00511021, 0x8c421be0, 0x3c030800, 0x00711821,
48167 +       0x8c631be4, 0x00021500, 0x00031c00, 0x00431025, 0xacc20014, 0x8e63fff4,
48168 +       0x96020008, 0x00432023, 0x3242ffff, 0x3083ffff, 0x00431021, 0x02c2102a,
48169 +       0x10400003, 0x00802821, 0x97a9001e, 0x01322823, 0x8e620000, 0x30a4ffff,
48170 +       0x00441021, 0xae620000, 0xa4c5000e, 0x8e020000, 0xacc20000, 0x8e020004,
48171 +       0x8e63fff4, 0x00431021, 0xacc20004, 0x8e63fff4, 0x96020008, 0x00641821,
48172 +       0x0062102a, 0x14400006, 0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001,
48173 +       0x0a000579, 0xae62fff0, 0xae63fff4, 0xacc00008, 0x3242ffff, 0x10560003,
48174 +       0x31020004, 0x10400006, 0x24020305, 0x31020080, 0x54400001, 0x34e70010,
48175 +       0x34e70020, 0x24020905, 0xa4c2000c, 0x8ee30000, 0x8ee20004, 0x14620007,
48176 +       0x3c02b49a, 0x8ee20860, 0x54400001, 0x34e70400, 0x3c024b65, 0x0a000590,
48177 +       0x34427654, 0x344289ab, 0xacc2001c, 0x30e2ffff, 0xacc20010, 0x0e0005aa,
48178 +       0x00c02021, 0x3242ffff, 0x0056102b, 0x1440ff96, 0x00000000, 0x8e620000,
48179 +       0x8e63fffc, 0x0043102a, 0x1440ff3e, 0x00000000, 0x8fbf0044, 0x8fbe0040,
48180 +       0x8fb7003c, 0x8fb60038, 0x8fb50034, 0x8fb40030, 0x8fb3002c, 0x8fb20028,
48181 +       0x8fb10024, 0x8fb00020, 0x03e00008, 0x27bd0048, 0x27bdffe8, 0xafbf0014,
48182 +       0xafb00010, 0x8f624450, 0x8f634410, 0x0a0005b9, 0x00808021, 0x8f626820,
48183 +       0x30422000, 0x10400003, 0x00000000, 0x0e0001e3, 0x00002021, 0x8f624450,
48184 +       0x8f634410, 0x3042ffff, 0x0043102b, 0x1440fff5, 0x00000000, 0x8f630c14,
48185 +       0x3063000f, 0x2c620002, 0x1440000b, 0x00000000, 0x8f630c14, 0x3c020800,
48186 +       0x8c421b50, 0x3063000f, 0x24420001, 0x3c010800, 0xac221b50, 0x2c620002,
48187 +       0x1040fff7, 0x00000000, 0xaf705c18, 0x8f625c10, 0x30420002, 0x10400009,
48188 +       0x00000000, 0x8f626820, 0x30422000, 0x1040fff8, 0x00000000, 0x0e0001e3,
48189 +       0x00002021, 0x0a0005cc, 0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008,
48190 +       0x27bd0018, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe8, 0x3c1bc000,
48191 +       0xafbf0014, 0xafb00010, 0xaf60680c, 0x8f626804, 0x34420082, 0xaf626804,
48192 +       0x8f634000, 0x24020b50, 0x3c010800, 0xac221b64, 0x24020b78, 0x3c010800,
48193 +       0xac221b74, 0x34630002, 0xaf634000, 0x0e00060d, 0x00808021, 0x3c010800,
48194 +       0xa0221b78, 0x304200ff, 0x24030002, 0x14430005, 0x00000000, 0x3c020800,
48195 +       0x8c421b64, 0x0a000600, 0xac5000c0, 0x3c020800, 0x8c421b64, 0xac5000bc,
48196 +       0x8f624434, 0x8f634438, 0x8f644410, 0x3c010800, 0xac221b6c, 0x3c010800,
48197 +       0xac231b7c, 0x3c010800, 0xac241b68, 0x8fbf0014, 0x8fb00010, 0x03e00008,
48198 +       0x27bd0018, 0x3c040800, 0x8c870000, 0x3c03aa55, 0x3463aa55, 0x3c06c003,
48199 +       0xac830000, 0x8cc20000, 0x14430007, 0x24050002, 0x3c0355aa, 0x346355aa,
48200 +       0xac830000, 0x8cc20000, 0x50430001, 0x24050001, 0x3c020800, 0xac470000,
48201 +       0x03e00008, 0x00a01021, 0x27bdfff8, 0x18800009, 0x00002821, 0x8f63680c,
48202 +       0x8f62680c, 0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a, 0x1440fff9,
48203 +       0x00000000, 0x03e00008, 0x27bd0008, 0x8f634450, 0x3c020800, 0x8c421b6c,
48204 +       0x00031c02, 0x0043102b, 0x14400008, 0x3c038000, 0x3c040800, 0x8c841b7c,
48205 +       0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444,
48206 +       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008,
48207 +       0x3042ffff, 0x3082ffff, 0x2442e000, 0x2c422001, 0x14400003, 0x3c024000,
48208 +       0x0a000650, 0x2402ffff, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002,
48209 +       0x1440fffc, 0x00001021, 0x03e00008, 0x00000000, 0x8f624450, 0x3c030800,
48210 +       0x8c631b68, 0x0a000659, 0x3042ffff, 0x8f624450, 0x3042ffff, 0x0043102b,
48211 +       0x1440fffc, 0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00802821,
48212 +       0x3c040800, 0x24841b10, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
48213 +       0x0e000684, 0xafa00014, 0x0a000668, 0x00000000, 0x8fbf0018, 0x03e00008,
48214 +       0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x3c020800, 0x34423000,
48215 +       0x3c030800, 0x34633000, 0x3c040800, 0x348437ff, 0x3c010800, 0xac221b84,
48216 +       0x24020040, 0x3c010800, 0xac221b88, 0x3c010800, 0xac201b80, 0xac600000,
48217 +       0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
48218 +       0x00804821, 0x8faa0010, 0x3c020800, 0x8c421b80, 0x3c040800, 0x8c841b88,
48219 +       0x8fab0014, 0x24430001, 0x0044102b, 0x3c010800, 0xac231b80, 0x14400003,
48220 +       0x00004021, 0x3c010800, 0xac201b80, 0x3c020800, 0x8c421b80, 0x3c030800,
48221 +       0x8c631b84, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
48222 +       0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020800, 0x8c421b80,
48223 +       0x3c030800, 0x8c631b84, 0x8f64680c, 0x00021140, 0x00431021, 0xac440008,
48224 +       0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
48225 +       0x00000000, 0x00000000,
48226  };
48227  
48228  u32 tg3TsoFwRodata[] = {
48229 -       0x4d61696e, 0x43707542, 0x00000000, 0x00000000, 0x74637073, 0x6567496e,
48230 -       0x00000000, 0x53774576, 0x656e7430, 0x00000000, 0x00000000, 0x00000000,
48231 -       0x00000000
48232 +       0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541,
48233 +       0x00000000, 0x00000000, 0x00000000, 0x73746b6f, 0x66666c64,
48234 +       0x496e0000, 0x73746b6f, 0x66662a2a, 0x00000000, 0x53774576,
48235 +       0x656e7430, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
48236 +       0x66617461, 0x6c457272, 0x00000000, 0x00000000, 0x00000000
48237  };
48238  
48239  #if 0 /* All zeros, don't eat up space with it. */
48240 @@ -3785,63 +4178,274 @@
48241  };
48242  #endif
48243  
48244 +/* 5705 needs a special version of the TSO firmware.  */
48245 +#define TG3_TSO5_FW_RELEASE_MAJOR      0x1
48246 +#define TG3_TSO5_FW_RELASE_MINOR       0x1
48247 +#define TG3_TSO5_FW_RELEASE_FIX                0x0
48248 +#define TG3_TSO5_FW_START_ADDR         0x00010000
48249 +#define TG3_TSO5_FW_TEXT_ADDR          0x00010000
48250 +#define TG3_TSO5_FW_TEXT_LEN           0xeb0
48251 +#define TG3_TSO5_FW_RODATA_ADDR                0x00010eb0
48252 +#define TG3_TSO5_FW_RODATA_LEN         0x50
48253 +#define TG3_TSO5_FW_DATA_ADDR          0x00010f20
48254 +#define TG3_TSO5_FW_DATA_LEN           0x20
48255 +#define TG3_TSO5_FW_SBSS_ADDR          0x00010f40
48256 +#define TG3_TSO5_FW_SBSS_LEN           0x28
48257 +#define TG3_TSO5_FW_BSS_ADDR           0x00010f70
48258 +#define TG3_TSO5_FW_BSS_LEN            0x88
48259 +
48260 +static u32 tg3Tso5FwText[] = {
48261 +       0x0c004003, 0x00000000, 0x00010f30, 0x00000000, 0x10000003, 0x00000000,
48262 +       0x0000000d, 0x0000000d, 0x3c1d0001, 0x37bde000, 0x03a0f021, 0x3c100001,
48263 +       0x26100000, 0x0c004010, 0x00000000, 0x0000000d, 0x27bdffe0, 0x3c04fefe,
48264 +       0xafbf0018, 0x0c0042f0, 0x34840002, 0x0c00436c, 0x00000000, 0x3c030001,
48265 +       0x90630f54, 0x24020002, 0x3c040001, 0x24840ebc, 0x14620003, 0x24050001,
48266 +       0x3c040001, 0x24840eb0, 0x24060001, 0x00003821, 0xafa00010, 0x0c004380,
48267 +       0xafa00014, 0x0c00402c, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020,
48268 +       0x00000000, 0x00000000, 0x27bdffe0, 0xafbf001c, 0xafb20018, 0xafb10014,
48269 +       0x0c0042d3, 0xafb00010, 0x3c128000, 0x24110001, 0x8f706810, 0x32020400,
48270 +       0x10400007, 0x00000000, 0x8f641008, 0x00921024, 0x14400003, 0x00000000,
48271 +       0x0c004064, 0x00000000, 0x3c020001, 0x90420f76, 0x10510003, 0x32020200,
48272 +       0x1040fff1, 0x00000000, 0x0c0041b4, 0x00000000, 0x08004034, 0x00000000,
48273 +       0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
48274 +       0x27bdffe0, 0x3c040001, 0x24840ed0, 0x00002821, 0x00003021, 0x00003821,
48275 +       0xafbf0018, 0xafa00010, 0x0c004380, 0xafa00014, 0x0000d021, 0x24020130,
48276 +       0xaf625000, 0x3c010001, 0xa4200f70, 0x3c010001, 0xa0200f77, 0x8fbf0018,
48277 +       0x03e00008, 0x27bd0020, 0x00000000, 0x00000000, 0x3c030001, 0x24630f80,
48278 +       0x90620000, 0x27bdfff0, 0x14400003, 0x0080c021, 0x08004073, 0x00004821,
48279 +       0x3c022000, 0x03021024, 0x10400003, 0x24090002, 0x08004073, 0xa0600000,
48280 +       0x24090001, 0x00181040, 0x30431f80, 0x346f8008, 0x1520004b, 0x25eb0028,
48281 +       0x3c040001, 0x00832021, 0x8c848010, 0x3c050001, 0x24a50f9a, 0x00041402,
48282 +       0xa0a20000, 0x3c010001, 0xa0240f9b, 0x3c020001, 0x00431021, 0x94428014,
48283 +       0x3c010001, 0xa0220f9c, 0x3c0c0001, 0x01836021, 0x8d8c8018, 0x304200ff,
48284 +       0x24420008, 0x000220c3, 0x24020001, 0x3c010001, 0xa0220f80, 0x0124102b,
48285 +       0x1040000c, 0x00003821, 0x24a6000e, 0x01602821, 0x8ca20000, 0x8ca30004,
48286 +       0x24a50008, 0x24e70001, 0xacc20000, 0xacc30004, 0x00e4102b, 0x1440fff8,
48287 +       0x24c60008, 0x00003821, 0x3c080001, 0x25080f9b, 0x91060000, 0x3c020001,
48288 +       0x90420f9c, 0x2503000d, 0x00c32821, 0x00461023, 0x00021fc2, 0x00431021,
48289 +       0x00021043, 0x1840000c, 0x00002021, 0x91020001, 0x00461023, 0x00021fc2,
48290 +       0x00431021, 0x00021843, 0x94a20000, 0x24e70001, 0x00822021, 0x00e3102a,
48291 +       0x1440fffb, 0x24a50002, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
48292 +       0x00822021, 0x3c02ffff, 0x01821024, 0x3083ffff, 0x00431025, 0x3c010001,
48293 +       0x080040fa, 0xac220fa0, 0x3c050001, 0x24a50f9c, 0x90a20000, 0x3c0c0001,
48294 +       0x01836021, 0x8d8c8018, 0x000220c2, 0x1080000e, 0x00003821, 0x01603021,
48295 +       0x24a5000c, 0x8ca20000, 0x8ca30004, 0x24a50008, 0x24e70001, 0xacc20000,
48296 +       0xacc30004, 0x00e4102b, 0x1440fff8, 0x24c60008, 0x3c050001, 0x24a50f9c,
48297 +       0x90a20000, 0x30430007, 0x24020004, 0x10620011, 0x28620005, 0x10400005,
48298 +       0x24020002, 0x10620008, 0x000710c0, 0x080040fa, 0x00000000, 0x24020006,
48299 +       0x1062000e, 0x000710c0, 0x080040fa, 0x00000000, 0x00a21821, 0x9463000c,
48300 +       0x004b1021, 0x080040fa, 0xa4430000, 0x000710c0, 0x00a21821, 0x8c63000c,
48301 +       0x004b1021, 0x080040fa, 0xac430000, 0x00a21821, 0x8c63000c, 0x004b2021,
48302 +       0x00a21021, 0xac830000, 0x94420010, 0xa4820004, 0x95e70006, 0x3c020001,
48303 +       0x90420f9c, 0x3c030001, 0x90630f9a, 0x00e2c823, 0x3c020001, 0x90420f9b,
48304 +       0x24630028, 0x01e34021, 0x24420028, 0x15200012, 0x01e23021, 0x94c2000c,
48305 +       0x3c010001, 0xa4220f98, 0x94c20004, 0x94c30006, 0x3c010001, 0xa4200f96,
48306 +       0x3c010001, 0xa4200f92, 0x00021400, 0x00431025, 0x3c010001, 0xac220f8c,
48307 +       0x95020004, 0x3c010001, 0x08004124, 0xa4220f90, 0x3c020001, 0x94420f90,
48308 +       0x3c030001, 0x94630f92, 0x00431021, 0xa5020004, 0x3c020001, 0x94420f8c,
48309 +       0xa4c20004, 0x3c020001, 0x8c420f8c, 0xa4c20006, 0x3c040001, 0x94840f92,
48310 +       0x3c020001, 0x94420f90, 0x3c0a0001, 0x954a0f96, 0x00441821, 0x3063ffff,
48311 +       0x0062182a, 0x24020002, 0x1122000b, 0x00832023, 0x3c030001, 0x94630f98,
48312 +       0x30620009, 0x10400006, 0x3062fff6, 0xa4c2000c, 0x3c020001, 0x94420f98,
48313 +       0x30420009, 0x01425023, 0x24020001, 0x1122001b, 0x29220002, 0x50400005,
48314 +       0x24020002, 0x11200007, 0x31a2ffff, 0x08004197, 0x00000000, 0x1122001d,
48315 +       0x24020016, 0x08004197, 0x31a2ffff, 0x3c0e0001, 0x95ce0fa0, 0x10800005,
48316 +       0x01806821, 0x01c42021, 0x00041c02, 0x3082ffff, 0x00627021, 0x000e1027,
48317 +       0xa502000a, 0x3c030001, 0x90630f9b, 0x31a2ffff, 0x00e21021, 0x0800418d,
48318 +       0x00432023, 0x3c020001, 0x94420fa0, 0x00442021, 0x00041c02, 0x3082ffff,
48319 +       0x00622021, 0x00807021, 0x00041027, 0x08004185, 0xa502000a, 0x3c050001,
48320 +       0x24a50f9a, 0x90a30000, 0x14620002, 0x24e2fff2, 0xa5e20034, 0x90a20000,
48321 +       0x00e21023, 0xa5020002, 0x3c030001, 0x94630fa0, 0x3c020001, 0x94420f7a,
48322 +       0x30e5ffff, 0x00641821, 0x00451023, 0x00622023, 0x00041c02, 0x3082ffff,
48323 +       0x00622021, 0x00041027, 0xa502000a, 0x3c030001, 0x90630f9c, 0x24620001,
48324 +       0x14a20005, 0x00807021, 0x01631021, 0x90420000, 0x08004185, 0x00026200,
48325 +       0x24620002, 0x14a20003, 0x306200fe, 0x004b1021, 0x944c0000, 0x3c020001,
48326 +       0x94420fa2, 0x3183ffff, 0x3c040001, 0x90840f9b, 0x00431021, 0x00e21021,
48327 +       0x00442023, 0x008a2021, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
48328 +       0x00822021, 0x00806821, 0x00041027, 0xa4c20010, 0x31a2ffff, 0x000e1c00,
48329 +       0x00431025, 0x3c040001, 0x24840f92, 0xade20010, 0x94820000, 0x3c050001,
48330 +       0x94a50f96, 0x3c030001, 0x8c630f8c, 0x24420001, 0x00b92821, 0xa4820000,
48331 +       0x3322ffff, 0x00622021, 0x0083182b, 0x3c010001, 0xa4250f96, 0x10600003,
48332 +       0x24a2ffff, 0x3c010001, 0xa4220f96, 0x3c024000, 0x03021025, 0x3c010001,
48333 +       0xac240f8c, 0xaf621008, 0x03e00008, 0x27bd0010, 0x3c030001, 0x90630f76,
48334 +       0x27bdffe8, 0x24020001, 0xafbf0014, 0x10620026, 0xafb00010, 0x8f620cf4,
48335 +       0x2442ffff, 0x3042007f, 0x00021100, 0x8c434000, 0x3c010001, 0xac230f84,
48336 +       0x8c434008, 0x24444000, 0x8c5c4004, 0x30620040, 0x14400002, 0x24020088,
48337 +       0x24020008, 0x3c010001, 0xa4220f88, 0x30620004, 0x10400005, 0x24020001,
48338 +       0x3c010001, 0xa0220f77, 0x080041d5, 0x00031402, 0x3c010001, 0xa0200f77,
48339 +       0x00031402, 0x3c010001, 0xa4220f74, 0x9483000c, 0x24020001, 0x3c010001,
48340 +       0xa4200f70, 0x3c010001, 0xa0220f76, 0x3c010001, 0xa4230f82, 0x24020001,
48341 +       0x1342001e, 0x00000000, 0x13400005, 0x24020003, 0x13420067, 0x00000000,
48342 +       0x080042cf, 0x00000000, 0x3c020001, 0x94420f82, 0x241a0001, 0x3c010001,
48343 +       0xa4200f7e, 0x3c010001, 0xa4200f72, 0x304407ff, 0x00021bc2, 0x00031823,
48344 +       0x3063003e, 0x34630036, 0x00021242, 0x3042003c, 0x00621821, 0x3c010001,
48345 +       0xa4240f78, 0x00832021, 0x24630030, 0x3c010001, 0xa4240f7a, 0x3c010001,
48346 +       0xa4230f7c, 0x3c060001, 0x24c60f72, 0x94c50000, 0x94c30002, 0x3c040001,
48347 +       0x94840f7a, 0x00651021, 0x0044102a, 0x10400013, 0x3c108000, 0x00a31021,
48348 +       0xa4c20000, 0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f76, 0x8f641008,
48349 +       0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4,
48350 +       0x00501024, 0x104000b7, 0x00000000, 0x0800420f, 0x00000000, 0x3c030001,
48351 +       0x94630f70, 0x00851023, 0xa4c40000, 0x00621821, 0x3042ffff, 0x3c010001,
48352 +       0xa4230f70, 0xaf620ce8, 0x3c020001, 0x94420f88, 0x34420024, 0xaf620cec,
48353 +       0x94c30002, 0x3c020001, 0x94420f70, 0x14620012, 0x3c028000, 0x3c108000,
48354 +       0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f76, 0x8f641008, 0x00901024,
48355 +       0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024,
48356 +       0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003, 0xaf620cf4, 0x3c108000,
48357 +       0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000,
48358 +       0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003,
48359 +       0x3c070001, 0x24e70f70, 0x94e20000, 0x03821021, 0xaf620ce0, 0x3c020001,
48360 +       0x8c420f84, 0xaf620ce4, 0x3c050001, 0x94a50f74, 0x94e30000, 0x3c040001,
48361 +       0x94840f78, 0x3c020001, 0x94420f7e, 0x00a32823, 0x00822023, 0x30a6ffff,
48362 +       0x3083ffff, 0x00c3102b, 0x14400043, 0x00000000, 0x3c020001, 0x94420f7c,
48363 +       0x00021400, 0x00621025, 0xaf620ce8, 0x94e20000, 0x3c030001, 0x94630f74,
48364 +       0x00441021, 0xa4e20000, 0x3042ffff, 0x14430021, 0x3c020008, 0x3c020001,
48365 +       0x90420f77, 0x10400006, 0x3c03000c, 0x3c020001, 0x94420f88, 0x34630624,
48366 +       0x0800427c, 0x0000d021, 0x3c020001, 0x94420f88, 0x3c030008, 0x34630624,
48367 +       0x00431025, 0xaf620cec, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
48368 +       0xa0200f76, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
48369 +       0x00000000, 0x8f620cf4, 0x00501024, 0x10400015, 0x00000000, 0x08004283,
48370 +       0x00000000, 0x3c030001, 0x94630f88, 0x34420624, 0x3c108000, 0x00621825,
48371 +       0x3c028000, 0xaf630cec, 0xaf620cf4, 0x8f641008, 0x00901024, 0x14400003,
48372 +       0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7,
48373 +       0x00000000, 0x3c010001, 0x080042cf, 0xa4200f7e, 0x3c020001, 0x94420f7c,
48374 +       0x00021400, 0x00c21025, 0xaf620ce8, 0x3c020001, 0x90420f77, 0x10400009,
48375 +       0x3c03000c, 0x3c020001, 0x94420f88, 0x34630624, 0x0000d021, 0x00431025,
48376 +       0xaf620cec, 0x080042c1, 0x3c108000, 0x3c020001, 0x94420f88, 0x3c030008,
48377 +       0x34630604, 0x00431025, 0xaf620cec, 0x3c020001, 0x94420f7e, 0x00451021,
48378 +       0x3c010001, 0xa4220f7e, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
48379 +       0xa0200f76, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
48380 +       0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x8fbf0014,
48381 +       0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe0, 0x3c040001, 0x24840ee0,
48382 +       0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0c004380,
48383 +       0xafa00014, 0x0000d021, 0x24020130, 0xaf625000, 0x3c010001, 0xa4200f70,
48384 +       0x3c010001, 0xa0200f77, 0x8f636804, 0x3c020001, 0x3442e000, 0x00621824,
48385 +       0x3c020001, 0x14620003, 0x00000000, 0x080042eb, 0x00000000, 0x8fbf0018,
48386 +       0x03e00008, 0x27bd0020, 0x27bdffe8, 0x3c1bc000, 0xafbf0014, 0xafb00010,
48387 +       0xaf60680c, 0x8f626804, 0x34420082, 0xaf626804, 0x8f634000, 0x24020b50,
48388 +       0x3c010001, 0xac220f40, 0x24020b78, 0x3c010001, 0xac220f50, 0x34630002,
48389 +       0xaf634000, 0x0c00431d, 0x00808021, 0x3c010001, 0xa0220f54, 0x304200ff,
48390 +       0x24030002, 0x14430005, 0x00000000, 0x3c020001, 0x8c420f40, 0x08004310,
48391 +       0xac5000c0, 0x3c020001, 0x8c420f40, 0xac5000bc, 0x8f624434, 0x8f634438,
48392 +       0x8f644410, 0x3c010001, 0xac220f48, 0x3c010001, 0xac230f58, 0x3c010001,
48393 +       0xac240f44, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x03e00008,
48394 +       0x24020001, 0x27bdfff8, 0x18800009, 0x00002821, 0x8f63680c, 0x8f62680c,
48395 +       0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a, 0x1440fff9, 0x00000000,
48396 +       0x03e00008, 0x27bd0008, 0x8f634450, 0x3c020001, 0x8c420f48, 0x00031c02,
48397 +       0x0043102b, 0x14400008, 0x3c038000, 0x3c040001, 0x8c840f58, 0x8f624450,
48398 +       0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444,
48399 +       0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff,
48400 +       0x3082ffff, 0x2442e000, 0x2c422001, 0x14400003, 0x3c024000, 0x0800434f,
48401 +       0x2402ffff, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc,
48402 +       0x00001021, 0x03e00008, 0x00000000, 0x8f624450, 0x3c030001, 0x8c630f44,
48403 +       0x08004358, 0x3042ffff, 0x8f624450, 0x3042ffff, 0x0043102b, 0x1440fffc,
48404 +       0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00802821, 0x3c040001,
48405 +       0x24840ef0, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0c004380,
48406 +       0xafa00014, 0x08004367, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020,
48407 +       0x3c020001, 0x3442d600, 0x3c030001, 0x3463d600, 0x3c040001, 0x3484ddff,
48408 +       0x3c010001, 0xac220f60, 0x24020040, 0x3c010001, 0xac220f64, 0x3c010001,
48409 +       0xac200f5c, 0xac600000, 0x24630004, 0x0083102b, 0x5040fffd, 0xac600000,
48410 +       0x03e00008, 0x00000000, 0x00804821, 0x8faa0010, 0x3c020001, 0x8c420f5c,
48411 +       0x3c040001, 0x8c840f64, 0x8fab0014, 0x24430001, 0x0044102b, 0x3c010001,
48412 +       0xac230f5c, 0x14400003, 0x00004021, 0x3c010001, 0xac200f5c, 0x3c020001,
48413 +       0x8c420f5c, 0x3c030001, 0x8c630f60, 0x91240000, 0x00021140, 0x00431021,
48414 +       0x00481021, 0x25080001, 0xa0440000, 0x29020008, 0x1440fff4, 0x25290001,
48415 +       0x3c020001, 0x8c420f5c, 0x3c030001, 0x8c630f60, 0x8f64680c, 0x00021140,
48416 +       0x00431021, 0xac440008, 0xac45000c, 0xac460010, 0xac470014, 0xac4a0018,
48417 +       0x03e00008, 0xac4b001c, 0x00000000, 0x00000000,
48418 +};
48419 +
48420 +u32 tg3Tso5FwRodata[] = {
48421 +       0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
48422 +       0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x00000000, 0x00000000,
48423 +       0x73746b6f, 0x66666c64, 0x00000000, 0x00000000, 0x66617461, 0x6c457272,
48424 +       0x00000000, 0x00000000, 0x00000000
48425 +};
48426 +
48427 +u32 tg3Tso5FwData[] = {
48428 +       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x73746b6f, 
48429 +       0x66666c64, 0x5f76312e, 0x312e3000, 0x00000000
48430 +};
48431 +
48432  /* tp->lock is held. */
48433  static int tg3_load_tso_firmware(struct tg3 *tp)
48434  {
48435         struct fw_info info;
48436 +       unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
48437         int err, i;
48438  
48439 -       info.text_base = TG3_TSO_FW_TEXT_ADDR;
48440 -       info.text_len = TG3_TSO_FW_TEXT_LEN;
48441 -       info.text_data = &tg3TsoFwText[0];
48442 -       info.rodata_base = TG3_TSO_FW_RODATA_ADDR;
48443 -       info.rodata_len = TG3_TSO_FW_RODATA_LEN;
48444 -       info.rodata_data = &tg3TsoFwRodata[0];
48445 -       info.data_base = TG3_TSO_FW_DATA_ADDR;
48446 -       info.data_len = TG3_TSO_FW_DATA_LEN;
48447 -       info.data_data = NULL;
48448 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
48449 +               info.text_base = TG3_TSO5_FW_TEXT_ADDR;
48450 +               info.text_len = TG3_TSO5_FW_TEXT_LEN;
48451 +               info.text_data = &tg3Tso5FwText[0];
48452 +               info.rodata_base = TG3_TSO5_FW_RODATA_ADDR;
48453 +               info.rodata_len = TG3_TSO5_FW_RODATA_LEN;
48454 +               info.rodata_data = &tg3Tso5FwRodata[0];
48455 +               info.data_base = TG3_TSO5_FW_DATA_ADDR;
48456 +               info.data_len = TG3_TSO5_FW_DATA_LEN;
48457 +               info.data_data = &tg3Tso5FwData[0];
48458 +               cpu_base = RX_CPU_BASE;
48459 +               cpu_scratch_base = NIC_SRAM_MBUF_POOL_BASE5705;
48460 +               cpu_scratch_size = (info.text_len +
48461 +                                   info.rodata_len +
48462 +                                   info.data_len +
48463 +                                   TG3_TSO5_FW_SBSS_LEN +
48464 +                                   TG3_TSO5_FW_BSS_LEN);
48465 +       } else {
48466 +               info.text_base = TG3_TSO_FW_TEXT_ADDR;
48467 +               info.text_len = TG3_TSO_FW_TEXT_LEN;
48468 +               info.text_data = &tg3TsoFwText[0];
48469 +               info.rodata_base = TG3_TSO_FW_RODATA_ADDR;
48470 +               info.rodata_len = TG3_TSO_FW_RODATA_LEN;
48471 +               info.rodata_data = &tg3TsoFwRodata[0];
48472 +               info.data_base = TG3_TSO_FW_DATA_ADDR;
48473 +               info.data_len = TG3_TSO_FW_DATA_LEN;
48474 +               info.data_data = NULL;
48475 +               cpu_base = TX_CPU_BASE;
48476 +               cpu_scratch_base = TX_CPU_SCRATCH_BASE;
48477 +               cpu_scratch_size = TX_CPU_SCRATCH_SIZE;
48478 +       }
48479  
48480 -       err = tg3_load_firmware_cpu(tp, TX_CPU_BASE,
48481 -                                   TX_CPU_SCRATCH_BASE, TX_CPU_SCRATCH_SIZE,
48482 +       err = tg3_load_firmware_cpu(tp, cpu_base,
48483 +                                   cpu_scratch_base, cpu_scratch_size,
48484                                     &info);
48485         if (err)
48486                 return err;
48487  
48488 -       /* Now startup only the TX cpu. */
48489 -       tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
48490 -       tw32(TX_CPU_BASE + CPU_PC,    TG3_TSO_FW_TEXT_ADDR);
48491 +       /* Now startup the cpu. */
48492 +       tw32(cpu_base + CPU_STATE, 0xffffffff);
48493 +       tw32(cpu_base + CPU_PC,    info.text_base);
48494  
48495         /* Flush posted writes. */
48496 -       tr32(TX_CPU_BASE + CPU_PC);
48497 +       tr32(cpu_base + CPU_PC);
48498         for (i = 0; i < 5; i++) {
48499 -               if (tr32(TX_CPU_BASE + CPU_PC) == TG3_TSO_FW_TEXT_ADDR)
48500 +               if (tr32(cpu_base + CPU_PC) == info.text_base)
48501                         break;
48502 -               tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
48503 -               tw32(TX_CPU_BASE + CPU_MODE,  CPU_MODE_HALT);
48504 -               tw32(TX_CPU_BASE + CPU_PC,    TG3_TSO_FW_TEXT_ADDR);
48505 +               tw32(cpu_base + CPU_STATE, 0xffffffff);
48506 +               tw32(cpu_base + CPU_MODE,  CPU_MODE_HALT);
48507 +               tw32(cpu_base + CPU_PC,    info.text_base);
48508  
48509                 /* Flush posted writes. */
48510 -               tr32(TX_CPU_BASE + CPU_PC);
48511 +               tr32(cpu_base + CPU_PC);
48512  
48513                 udelay(1000);
48514         }
48515         if (i >= 5) {
48516                 printk(KERN_ERR PFX "tg3_load_tso_firmware fails for %s "
48517 -                      "to set TX CPU PC, is %08x should be %08x\n",
48518 -                      tp->dev->name, tr32(TX_CPU_BASE + CPU_PC),
48519 -                      TG3_TSO_FW_TEXT_ADDR);
48520 +                      "to set CPU PC, is %08x should be %08x\n",
48521 +                      tp->dev->name, tr32(cpu_base + CPU_PC),
48522 +                      info.text_base);
48523                 return -ENODEV;
48524         }
48525 -       tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
48526 -       tw32(TX_CPU_BASE + CPU_MODE,  0x00000000);
48527 +       tw32(cpu_base + CPU_STATE, 0xffffffff);
48528 +       tw32(cpu_base + CPU_MODE,  0x00000000);
48529  
48530         /* Flush posted writes. */
48531 -       tr32(TX_CPU_BASE + CPU_MODE);
48532 +       tr32(cpu_base + CPU_MODE);
48533  
48534         return 0;
48535  }
48536  
48537 -#endif /* TG3_DO_TSO != 0 */
48538 +#endif /* TG3_TSO_SUPPORT != 0 */
48539  
48540  /* tp->lock is held. */
48541  static void __tg3_set_mac_addr(struct tg3 *tp)
48542 @@ -3860,6 +4464,15 @@
48543                 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
48544         }
48545  
48546 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
48547 +           GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701 &&
48548 +           GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
48549 +               for (i = 0; i < 12; i++) {
48550 +                       tw32(MAC_EXTADDR_0_HIGH + (i * 8), addr_high);
48551 +                       tw32(MAC_EXTADDR_0_LOW + (i * 8), addr_low);
48552 +               }
48553 +       }
48554 +
48555         addr_high = (tp->dev->dev_addr[0] +
48556                      tp->dev->dev_addr[1] +
48557                      tp->dev->dev_addr[2] +
48558 @@ -3893,23 +4506,19 @@
48559                            u32 nic_addr)
48560  {
48561         tg3_write_mem(tp,
48562 -                     (bdinfo_addr +
48563 -                      TG3_BDINFO_HOST_ADDR +
48564 -                      TG3_64BIT_REG_HIGH),
48565 +                     (bdinfo_addr + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH),
48566                       ((u64) mapping >> 32));
48567         tg3_write_mem(tp,
48568 -                     (bdinfo_addr +
48569 -                      TG3_BDINFO_HOST_ADDR +
48570 -                      TG3_64BIT_REG_LOW),
48571 +                     (bdinfo_addr + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW),
48572                       ((u64) mapping & 0xffffffff));
48573         tg3_write_mem(tp,
48574 -                     (bdinfo_addr +
48575 -                      TG3_BDINFO_MAXLEN_FLAGS),
48576 +                     (bdinfo_addr + TG3_BDINFO_MAXLEN_FLAGS),
48577                        maxlen_flags);
48578 -       tg3_write_mem(tp,
48579 -                     (bdinfo_addr +
48580 -                      TG3_BDINFO_NIC_ADDR),
48581 -                     nic_addr);
48582 +
48583 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
48584 +               tg3_write_mem(tp,
48585 +                             (bdinfo_addr + TG3_BDINFO_NIC_ADDR),
48586 +                             nic_addr);
48587  }
48588  
48589  static void __tg3_set_rx_mode(struct net_device *);
48590 @@ -3917,8 +4526,8 @@
48591  /* tp->lock is held. */
48592  static int tg3_reset_hw(struct tg3 *tp)
48593  {
48594 -       u32 val;
48595 -       int i, err;
48596 +       u32 val, rdmac_mode;
48597 +       int i, err, limit;
48598  
48599         tg3_disable_ints(tp);
48600  
48601 @@ -3970,9 +4579,8 @@
48602          * B3 tigon3 silicon.  This bit has no effect on any
48603          * other revision.
48604          */
48605 -       val = tr32(TG3PCI_CLOCK_CTRL);
48606 -       val |= CLOCK_CTRL_DELAY_PCI_GRANT;
48607 -       tw32(TG3PCI_CLOCK_CTRL, val);
48608 +       tp->pci_clock_ctrl |= CLOCK_CTRL_DELAY_PCI_GRANT;
48609 +       tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
48610         tr32(TG3PCI_CLOCK_CTRL);
48611  
48612         if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0 &&
48613 @@ -3990,11 +4598,13 @@
48614         tg3_init_rings(tp);
48615  
48616         /* Clear statistics/status block in chip, and status block in ram. */
48617 -       for (i = NIC_SRAM_STATS_BLK;
48618 -            i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE;
48619 -            i += sizeof(u32)) {
48620 -               tg3_write_mem(tp, i, 0);
48621 -               udelay(40);
48622 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
48623 +               for (i = NIC_SRAM_STATS_BLK;
48624 +                    i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE;
48625 +                    i += sizeof(u32)) {
48626 +                       tg3_write_mem(tp, i, 0);
48627 +                       udelay(40);
48628 +               }
48629         }
48630         memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
48631  
48632 @@ -4025,13 +4635,31 @@
48633              (65 << GRC_MISC_CFG_PRESCALAR_SHIFT));
48634  
48635         /* Initialize MBUF/DESC pool. */
48636 -       tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
48637 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
48638 -               tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE64);
48639 -       else
48640 -               tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
48641 -       tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
48642 -       tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
48643 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
48644 +               tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
48645 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
48646 +                       tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE64);
48647 +               else
48648 +                       tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
48649 +               tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
48650 +               tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
48651 +       }
48652 +#if TG3_TSO_SUPPORT != 0
48653 +       else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
48654 +               int fw_len;
48655 +
48656 +               fw_len = (TG3_TSO5_FW_TEXT_LEN +
48657 +                         TG3_TSO5_FW_RODATA_LEN +
48658 +                         TG3_TSO5_FW_DATA_LEN +
48659 +                         TG3_TSO5_FW_SBSS_LEN +
48660 +                         TG3_TSO5_FW_BSS_LEN);
48661 +               fw_len = (fw_len + (0x80 - 1)) & ~(0x80 - 1);
48662 +               tw32(BUFMGR_MB_POOL_ADDR,
48663 +                    NIC_SRAM_MBUF_POOL_BASE5705 + fw_len);
48664 +               tw32(BUFMGR_MB_POOL_SIZE,
48665 +                    NIC_SRAM_MBUF_POOL_SIZE5705 - fw_len - 0xa00);
48666 +       }
48667 +#endif
48668  
48669         if (!(tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE)) {
48670                 tw32(BUFMGR_MB_RDMA_LOW_WATER,
48671 @@ -4078,6 +4706,9 @@
48672                 return -ENODEV;
48673         }
48674  
48675 +       /* Setup replenish threshold. */
48676 +       tw32(RCVBDI_STD_THRESH, tp->rx_pending / 8);
48677 +
48678         /* Initialize TG3_BDINFO's at:
48679          *  RCVDBDI_STD_BD:     standard eth size rx ring
48680          *  RCVDBDI_JUMBO_BD:   jumbo frame rx ring
48681 @@ -4099,35 +4730,50 @@
48682              ((u64) tp->rx_std_mapping >> 32));
48683         tw32(RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
48684              ((u64) tp->rx_std_mapping & 0xffffffff));
48685 -       tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
48686 -            RX_STD_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
48687         tw32(RCVDBDI_STD_BD + TG3_BDINFO_NIC_ADDR,
48688              NIC_SRAM_RX_BUFFER_DESC);
48689  
48690 -       tw32(RCVDBDI_MINI_BD + TG3_BDINFO_MAXLEN_FLAGS,
48691 -            BDINFO_FLAGS_DISABLED);
48692 -
48693 -       if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) {
48694 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH,
48695 -                    ((u64) tp->rx_jumbo_mapping >> 32));
48696 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
48697 -                    ((u64) tp->rx_jumbo_mapping & 0xffffffff));
48698 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
48699 -                    RX_JUMBO_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
48700 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_NIC_ADDR,
48701 -                    NIC_SRAM_RX_JUMBO_BUFFER_DESC);
48702 +       /* Don't even try to program the JUMBO/MINI buffer descriptor
48703 +        * configs on 5705.
48704 +        */
48705 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
48706 +               tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
48707 +                    RX_STD_MAX_SIZE_5705 << BDINFO_FLAGS_MAXLEN_SHIFT);
48708         } else {
48709 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
48710 +               tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
48711 +                    RX_STD_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
48712 +
48713 +               tw32(RCVDBDI_MINI_BD + TG3_BDINFO_MAXLEN_FLAGS,
48714                      BDINFO_FLAGS_DISABLED);
48715 -       }
48716  
48717 -       /* Setup replenish thresholds. */
48718 -       tw32(RCVBDI_STD_THRESH, tp->rx_pending / 8);
48719 -       tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8);
48720 +               /* Setup replenish threshold. */
48721 +               tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8);
48722  
48723 -       /* Clear out send RCB ring in SRAM. */
48724 -       for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
48725 -               tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED);
48726 +               if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) {
48727 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH,
48728 +                            ((u64) tp->rx_jumbo_mapping >> 32));
48729 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
48730 +                            ((u64) tp->rx_jumbo_mapping & 0xffffffff));
48731 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
48732 +                            RX_JUMBO_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
48733 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_NIC_ADDR,
48734 +                            NIC_SRAM_RX_JUMBO_BUFFER_DESC);
48735 +               } else {
48736 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
48737 +                            BDINFO_FLAGS_DISABLED);
48738 +               }
48739 +
48740 +       }
48741 +
48742 +       /* There is only one send ring on 5705, no need to explicitly
48743 +        * disable the others.
48744 +        */
48745 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
48746 +               /* Clear out send RCB ring in SRAM. */
48747 +               for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
48748 +                       tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
48749 +                                     BDINFO_FLAGS_DISABLED);
48750 +       }
48751  
48752         tp->tx_prod = 0;
48753         tp->tx_cons = 0;
48754 @@ -4149,9 +4795,15 @@
48755                                NIC_SRAM_TX_BUFFER_DESC);
48756         }
48757  
48758 -       for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK; i += TG3_BDINFO_SIZE) {
48759 -               tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
48760 -                             BDINFO_FLAGS_DISABLED);
48761 +       /* There is only one receive return ring on 5705, no need to explicitly
48762 +        * disable the others.
48763 +        */
48764 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
48765 +               for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK;
48766 +                    i += TG3_BDINFO_SIZE) {
48767 +                       tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
48768 +                                     BDINFO_FLAGS_DISABLED);
48769 +               }
48770         }
48771  
48772         tp->rx_rcb_ptr = 0;
48773 @@ -4161,7 +4813,7 @@
48774  
48775         tg3_set_bdinfo(tp, NIC_SRAM_RCV_RET_RCB,
48776                        tp->rx_rcb_mapping,
48777 -                      (TG3_RX_RCB_RING_SIZE <<
48778 +                      (TG3_RX_RCB_RING_SIZE(tp) <<
48779                         BDINFO_FLAGS_MAXLEN_SHIFT),
48780                        0);
48781  
48782 @@ -4198,8 +4850,36 @@
48783         tw32(MAC_RCV_RULE_CFG, RCV_RULE_CFG_DEFAULT_CLASS);
48784         tw32(RCVLPC_CONFIG, 0x0181);
48785  
48786 +       /* Calculate RDMAC_MODE setting early, we need it to determine
48787 +        * the RCVLPC_STATE_ENABLE mask.
48788 +        */
48789 +       rdmac_mode = (RDMAC_MODE_ENABLE | RDMAC_MODE_TGTABORT_ENAB |
48790 +                     RDMAC_MODE_MSTABORT_ENAB | RDMAC_MODE_PARITYERR_ENAB |
48791 +                     RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
48792 +                     RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
48793 +                     RDMAC_MODE_LNGREAD_ENAB);
48794 +       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
48795 +               rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
48796 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
48797 +               if (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) {
48798 +                       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
48799 +                               rdmac_mode |= RDMAC_MODE_FIFO_SIZE_128;
48800 +                       } else if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) &&
48801 +                                  !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
48802 +                               rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST;
48803 +                       }
48804 +               }
48805 +       }
48806 +
48807         /* Receive/send statistics. */
48808 -       tw32(RCVLPC_STATS_ENABLE, 0xffffff);
48809 +       if ((rdmac_mode & RDMAC_MODE_FIFO_SIZE_128) &&
48810 +           (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) {
48811 +               val = tr32(RCVLPC_STATS_ENABLE);
48812 +               val &= ~RCVLPC_STATSENAB_LNGBRST_RFIX;
48813 +               tw32(RCVLPC_STATS_ENABLE, val);
48814 +       } else {
48815 +               tw32(RCVLPC_STATS_ENABLE, 0xffffff);
48816 +       }
48817         tw32(RCVLPC_STATSCTRL, RCVLPC_STATSCTRL_ENABLE);
48818         tw32(SNDDATAI_STATSENAB, 0xffffff);
48819         tw32(SNDDATAI_STATSCTRL,
48820 @@ -4215,33 +4895,43 @@
48821         }
48822  
48823         tw32(HOSTCC_RXCOL_TICKS, 0);
48824 -       tw32(HOSTCC_RXMAX_FRAMES, 1);
48825 -       tw32(HOSTCC_RXCOAL_TICK_INT, 0);
48826 -       tw32(HOSTCC_RXCOAL_MAXF_INT, 1);
48827         tw32(HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS);
48828 +       tw32(HOSTCC_RXMAX_FRAMES, 1);
48829         tw32(HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES);
48830 -       tw32(HOSTCC_TXCOAL_TICK_INT, 0);
48831 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
48832 +               tw32(HOSTCC_RXCOAL_TICK_INT, 0);
48833 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
48834 +               tw32(HOSTCC_TXCOAL_TICK_INT, 0);
48835 +       tw32(HOSTCC_RXCOAL_MAXF_INT, 1);
48836         tw32(HOSTCC_TXCOAL_MAXF_INT, 0);
48837 -       tw32(HOSTCC_STAT_COAL_TICKS,
48838 -            DEFAULT_STAT_COAL_TICKS);
48839  
48840 -       /* Status/statistics block address. */
48841 -       tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
48842 -            ((u64) tp->stats_mapping >> 32));
48843 -       tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
48844 -            ((u64) tp->stats_mapping & 0xffffffff));
48845 +       /* set status block DMA address */
48846         tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
48847              ((u64) tp->status_mapping >> 32));
48848         tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
48849              ((u64) tp->status_mapping & 0xffffffff));
48850 -       tw32(HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK);
48851 -       tw32(HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK);
48852 +
48853 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
48854 +               /* Status/statistics block address.  See tg3_timer,
48855 +                * the tg3_periodic_fetch_stats call there, and
48856 +                * tg3_get_stats to see how this works for 5705 chips.
48857 +                */
48858 +               tw32(HOSTCC_STAT_COAL_TICKS,
48859 +                    DEFAULT_STAT_COAL_TICKS);
48860 +               tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
48861 +                    ((u64) tp->stats_mapping >> 32));
48862 +               tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
48863 +                    ((u64) tp->stats_mapping & 0xffffffff));
48864 +               tw32(HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK);
48865 +               tw32(HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK);
48866 +       }
48867  
48868         tw32(HOSTCC_MODE, HOSTCC_MODE_ENABLE | tp->coalesce_mode);
48869  
48870         tw32(RCVCC_MODE, RCVCC_MODE_ENABLE | RCVCC_MODE_ATTN_ENABLE);
48871         tw32(RCVLPC_MODE, RCVLPC_MODE_ENABLE);
48872 -       tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE);
48873 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
48874 +               tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE);
48875  
48876         tp->mac_mode = MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE |
48877                 MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE;
48878 @@ -4260,42 +4950,47 @@
48879         tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);
48880         tr32(MAILBOX_INTERRUPT_0);
48881  
48882 -       tw32(DMAC_MODE, DMAC_MODE_ENABLE);
48883 -       tr32(DMAC_MODE);
48884 -       udelay(40);
48885 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
48886 +               tw32(DMAC_MODE, DMAC_MODE_ENABLE);
48887 +               tr32(DMAC_MODE);
48888 +               udelay(40);
48889 +       }
48890  
48891 -       tw32(WDMAC_MODE, (WDMAC_MODE_ENABLE | WDMAC_MODE_TGTABORT_ENAB |
48892 -                         WDMAC_MODE_MSTABORT_ENAB | WDMAC_MODE_PARITYERR_ENAB |
48893 -                         WDMAC_MODE_ADDROFLOW_ENAB | WDMAC_MODE_FIFOOFLOW_ENAB |
48894 -                         WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
48895 -                         WDMAC_MODE_LNGREAD_ENAB));
48896 +       val = (WDMAC_MODE_ENABLE | WDMAC_MODE_TGTABORT_ENAB |
48897 +              WDMAC_MODE_MSTABORT_ENAB | WDMAC_MODE_PARITYERR_ENAB |
48898 +              WDMAC_MODE_ADDROFLOW_ENAB | WDMAC_MODE_FIFOOFLOW_ENAB |
48899 +              WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
48900 +              WDMAC_MODE_LNGREAD_ENAB);
48901 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
48902 +           (tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) != 0 &&
48903 +           !(tp->tg3_flags2 & TG3_FLG2_IS_5788))
48904 +               val |= WDMAC_MODE_RX_ACCEL;
48905 +       tw32(WDMAC_MODE, val);
48906         tr32(WDMAC_MODE);
48907         udelay(40);
48908  
48909 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 &&
48910 -           (tp->tg3_flags & TG3_FLAG_PCIX_MODE)) {
48911 +       if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
48912                 val = tr32(TG3PCI_X_CAPS);
48913 -               val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
48914 -               val |= (PCIX_CAPS_MAX_BURST_5704 << PCIX_CAPS_BURST_SHIFT);
48915 -               if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
48916 -                       val |= (tp->split_mode_max_reqs <<
48917 -                               PCIX_CAPS_SPLIT_SHIFT);
48918 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) {
48919 +                       val &= ~PCIX_CAPS_BURST_MASK;
48920 +                       val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
48921 +               } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
48922 +                       val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
48923 +                       val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
48924 +                       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
48925 +                               val |= (tp->split_mode_max_reqs <<
48926 +                                       PCIX_CAPS_SPLIT_SHIFT);
48927 +               }
48928                 tw32(TG3PCI_X_CAPS, val);
48929         }
48930  
48931 -       val = (RDMAC_MODE_ENABLE | RDMAC_MODE_TGTABORT_ENAB |
48932 -              RDMAC_MODE_MSTABORT_ENAB | RDMAC_MODE_PARITYERR_ENAB |
48933 -              RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
48934 -              RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
48935 -              RDMAC_MODE_LNGREAD_ENAB);
48936 -       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
48937 -               val |= RDMAC_MODE_SPLIT_ENABLE;
48938 -       tw32(RDMAC_MODE, val);
48939 +       tw32(RDMAC_MODE, rdmac_mode);
48940         tr32(RDMAC_MODE);
48941         udelay(40);
48942  
48943         tw32(RCVDCC_MODE, RCVDCC_MODE_ENABLE | RCVDCC_MODE_ATTN_ENABLE);
48944 -       tw32(MBFREE_MODE, MBFREE_MODE_ENABLE);
48945 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
48946 +               tw32(MBFREE_MODE, MBFREE_MODE_ENABLE);
48947         tw32(SNDDATAC_MODE, SNDDATAC_MODE_ENABLE);
48948         tw32(SNDBDC_MODE, SNDBDC_MODE_ENABLE | SNDBDC_MODE_ATTN_ENABLE);
48949         tw32(RCVBDI_MODE, RCVBDI_MODE_ENABLE | RCVBDI_MODE_RCB_ATTN_ENAB);
48950 @@ -4310,8 +5005,8 @@
48951                         return err;
48952         }
48953  
48954 -#if TG3_DO_TSO != 0
48955 -       if (tp->dev->features & NETIF_F_TSO) {
48956 +#if TG3_TSO_SUPPORT != 0
48957 +       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
48958                 err = tg3_load_tso_firmware(tp);
48959                 if (err)
48960                         return err;
48961 @@ -4342,9 +5037,11 @@
48962  
48963         tw32(MAC_LED_CTRL, 0);
48964         tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
48965 -       tw32(MAC_RX_MODE, RX_MODE_RESET);
48966 -       tr32(MAC_RX_MODE);
48967 -       udelay(10);
48968 +       if (tp->phy_id == PHY_ID_SERDES) {
48969 +               tw32(MAC_RX_MODE, RX_MODE_RESET);
48970 +               tr32(MAC_RX_MODE);
48971 +               udelay(10);
48972 +       }
48973         tw32(MAC_RX_MODE, tp->rx_mode);
48974         tr32(MAC_RX_MODE);
48975         udelay(10);
48976 @@ -4378,22 +5075,48 @@
48977         tw32(MAC_RCV_VALUE_0, 0xffffffff & RCV_RULE_DISABLE_MASK);
48978         tw32(MAC_RCV_RULE_1,  0x86000004 & RCV_RULE_DISABLE_MASK);
48979         tw32(MAC_RCV_VALUE_1, 0xffffffff & RCV_RULE_DISABLE_MASK);
48980 -#if 0
48981 -       tw32(MAC_RCV_RULE_2,  0); tw32(MAC_RCV_VALUE_2,  0);
48982 -       tw32(MAC_RCV_RULE_3,  0); tw32(MAC_RCV_VALUE_3,  0);
48983 -#endif
48984 -       tw32(MAC_RCV_RULE_4,  0); tw32(MAC_RCV_VALUE_4,  0);
48985 -       tw32(MAC_RCV_RULE_5,  0); tw32(MAC_RCV_VALUE_5,  0);
48986 -       tw32(MAC_RCV_RULE_6,  0); tw32(MAC_RCV_VALUE_6,  0);
48987 -       tw32(MAC_RCV_RULE_7,  0); tw32(MAC_RCV_VALUE_7,  0);
48988 -       tw32(MAC_RCV_RULE_8,  0); tw32(MAC_RCV_VALUE_8,  0);
48989 -       tw32(MAC_RCV_RULE_9,  0); tw32(MAC_RCV_VALUE_9,  0);
48990 -       tw32(MAC_RCV_RULE_10,  0); tw32(MAC_RCV_VALUE_10,  0);
48991 -       tw32(MAC_RCV_RULE_11,  0); tw32(MAC_RCV_VALUE_11,  0);
48992 -       tw32(MAC_RCV_RULE_12,  0); tw32(MAC_RCV_VALUE_12,  0);
48993 -       tw32(MAC_RCV_RULE_13,  0); tw32(MAC_RCV_VALUE_13,  0);
48994 -       tw32(MAC_RCV_RULE_14,  0); tw32(MAC_RCV_VALUE_14,  0);
48995 -       tw32(MAC_RCV_RULE_15,  0); tw32(MAC_RCV_VALUE_15,  0);
48996 +
48997 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
48998 +               limit = 8;
48999 +       else
49000 +               limit = 16;
49001 +       if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF)
49002 +               limit -= 4;
49003 +       switch (limit) {
49004 +       case 16:
49005 +               tw32(MAC_RCV_RULE_15,  0); tw32(MAC_RCV_VALUE_15,  0);
49006 +       case 15:
49007 +               tw32(MAC_RCV_RULE_14,  0); tw32(MAC_RCV_VALUE_14,  0);
49008 +       case 14:
49009 +               tw32(MAC_RCV_RULE_13,  0); tw32(MAC_RCV_VALUE_13,  0);
49010 +       case 13:
49011 +               tw32(MAC_RCV_RULE_12,  0); tw32(MAC_RCV_VALUE_12,  0);
49012 +       case 12:
49013 +               tw32(MAC_RCV_RULE_11,  0); tw32(MAC_RCV_VALUE_11,  0);
49014 +       case 11:
49015 +               tw32(MAC_RCV_RULE_10,  0); tw32(MAC_RCV_VALUE_10,  0);
49016 +       case 10:
49017 +               tw32(MAC_RCV_RULE_9,  0); tw32(MAC_RCV_VALUE_9,  0);
49018 +       case 9:
49019 +               tw32(MAC_RCV_RULE_8,  0); tw32(MAC_RCV_VALUE_8,  0);
49020 +       case 8:
49021 +               tw32(MAC_RCV_RULE_7,  0); tw32(MAC_RCV_VALUE_7,  0);
49022 +       case 7:
49023 +               tw32(MAC_RCV_RULE_6,  0); tw32(MAC_RCV_VALUE_6,  0);
49024 +       case 6:
49025 +               tw32(MAC_RCV_RULE_5,  0); tw32(MAC_RCV_VALUE_5,  0);
49026 +       case 5:
49027 +               tw32(MAC_RCV_RULE_4,  0); tw32(MAC_RCV_VALUE_4,  0);
49028 +       case 4:
49029 +               /* tw32(MAC_RCV_RULE_3,  0); tw32(MAC_RCV_VALUE_3,  0); */
49030 +       case 3:
49031 +               /* tw32(MAC_RCV_RULE_2,  0); tw32(MAC_RCV_VALUE_2,  0); */
49032 +       case 2:
49033 +       case 1:
49034 +
49035 +       default:
49036 +               break;
49037 +       };
49038  
49039         if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE)
49040                 tg3_enable_ints(tp);
49041 @@ -4423,6 +5146,50 @@
49042         return err;
49043  }
49044  
49045 +#define TG3_STAT_ADD32(PSTAT, REG) \
49046 +do {   u32 __val = tr32(REG); \
49047 +       (PSTAT)->low += __val; \
49048 +       if ((PSTAT)->low < __val) \
49049 +               (PSTAT)->high += 1; \
49050 +} while (0)
49051 +
49052 +static void tg3_periodic_fetch_stats(struct tg3 *tp)
49053 +{
49054 +       struct tg3_hw_stats *sp = tp->hw_stats;
49055 +
49056 +       if (!netif_carrier_ok(tp->dev))
49057 +               return;
49058 +
49059 +       TG3_STAT_ADD32(&sp->tx_octets, MAC_TX_STATS_OCTETS);
49060 +       TG3_STAT_ADD32(&sp->tx_collisions, MAC_TX_STATS_COLLISIONS);
49061 +       TG3_STAT_ADD32(&sp->tx_xon_sent, MAC_TX_STATS_XON_SENT);
49062 +       TG3_STAT_ADD32(&sp->tx_xoff_sent, MAC_TX_STATS_XOFF_SENT);
49063 +       TG3_STAT_ADD32(&sp->tx_mac_errors, MAC_TX_STATS_MAC_ERRORS);
49064 +       TG3_STAT_ADD32(&sp->tx_single_collisions, MAC_TX_STATS_SINGLE_COLLISIONS);
49065 +       TG3_STAT_ADD32(&sp->tx_mult_collisions, MAC_TX_STATS_MULT_COLLISIONS);
49066 +       TG3_STAT_ADD32(&sp->tx_deferred, MAC_TX_STATS_DEFERRED);
49067 +       TG3_STAT_ADD32(&sp->tx_excessive_collisions, MAC_TX_STATS_EXCESSIVE_COL);
49068 +       TG3_STAT_ADD32(&sp->tx_late_collisions, MAC_TX_STATS_LATE_COL);
49069 +       TG3_STAT_ADD32(&sp->tx_ucast_packets, MAC_TX_STATS_UCAST);
49070 +       TG3_STAT_ADD32(&sp->tx_mcast_packets, MAC_TX_STATS_MCAST);
49071 +       TG3_STAT_ADD32(&sp->tx_bcast_packets, MAC_TX_STATS_BCAST);
49072 +
49073 +       TG3_STAT_ADD32(&sp->rx_octets, MAC_RX_STATS_OCTETS);
49074 +       TG3_STAT_ADD32(&sp->rx_fragments, MAC_RX_STATS_FRAGMENTS);
49075 +       TG3_STAT_ADD32(&sp->rx_ucast_packets, MAC_RX_STATS_UCAST);
49076 +       TG3_STAT_ADD32(&sp->rx_mcast_packets, MAC_RX_STATS_MCAST);
49077 +       TG3_STAT_ADD32(&sp->rx_bcast_packets, MAC_RX_STATS_BCAST);
49078 +       TG3_STAT_ADD32(&sp->rx_fcs_errors, MAC_RX_STATS_FCS_ERRORS);
49079 +       TG3_STAT_ADD32(&sp->rx_align_errors, MAC_RX_STATS_ALIGN_ERRORS);
49080 +       TG3_STAT_ADD32(&sp->rx_xon_pause_rcvd, MAC_RX_STATS_XON_PAUSE_RECVD);
49081 +       TG3_STAT_ADD32(&sp->rx_xoff_pause_rcvd, MAC_RX_STATS_XOFF_PAUSE_RECVD);
49082 +       TG3_STAT_ADD32(&sp->rx_mac_ctrl_rcvd, MAC_RX_STATS_MAC_CTRL_RECVD);
49083 +       TG3_STAT_ADD32(&sp->rx_xoff_entered, MAC_RX_STATS_XOFF_ENTERED);
49084 +       TG3_STAT_ADD32(&sp->rx_frame_too_long_errors, MAC_RX_STATS_FRAME_TOO_LONG);
49085 +       TG3_STAT_ADD32(&sp->rx_jabbers, MAC_RX_STATS_JABBERS);
49086 +       TG3_STAT_ADD32(&sp->rx_undersize_packets, MAC_RX_STATS_UNDERSIZE);
49087 +}
49088 +
49089  static void tg3_timer(unsigned long __opaque)
49090  {
49091         struct tg3 *tp = (struct tg3 *) __opaque;
49092 @@ -4451,6 +5218,9 @@
49093                 return;
49094         }
49095  
49096 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
49097 +               tg3_periodic_fetch_stats(tp);
49098 +
49099         /* This part only runs once per second. */
49100         if (!--tp->timer_counter) {
49101                 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) {
49102 @@ -4908,7 +5678,9 @@
49103                 get_stat64(&hw_stats->rx_bcast_packets);
49104                 
49105         stats->tx_packets = old_stats->tx_packets +
49106 -               get_stat64(&hw_stats->COS_out_packets[0]);
49107 +               get_stat64(&hw_stats->tx_ucast_packets) +
49108 +               get_stat64(&hw_stats->tx_mcast_packets) +
49109 +               get_stat64(&hw_stats->tx_bcast_packets);
49110  
49111         stats->rx_bytes = old_stats->rx_bytes +
49112                 get_stat64(&hw_stats->rx_octets);
49113 @@ -5232,6 +6004,20 @@
49114         tp->msg_enable = value;
49115  }
49116    
49117 +#if TG3_TSO_SUPPORT != 0
49118 +static int tg3_set_tso(struct net_device *dev, u32 value)
49119 +{
49120 +       struct tg3 *tp = dev->priv;
49121 +
49122 +       if (!(tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) {
49123 +               if (value)
49124 +                       return -EINVAL;
49125 +               return 0;
49126 +       }
49127 +       return ethtool_op_set_tso(dev, value);
49128 +}
49129 +#endif
49130 +  
49131  static int tg3_nway_reset(struct net_device *dev)
49132  {
49133         struct tg3 *tp = dev->priv;
49134 @@ -5279,11 +6065,14 @@
49135         spin_lock(&tp->tx_lock);
49136    
49137         tp->rx_pending = ering->rx_pending;
49138 +
49139 +       if ((tp->tg3_flags2 & TG3_FLG2_MAX_RXPEND_64) &&
49140 +           tp->rx_pending > 64)
49141 +               tp->rx_pending = 64;
49142         tp->rx_jumbo_pending = ering->rx_jumbo_pending;
49143         tp->tx_pending = ering->tx_pending;
49144  
49145         tg3_halt(tp);
49146 -       tg3_init_rings(tp);
49147         tg3_init_hw(tp);
49148         netif_wake_queue(tp->dev);
49149         spin_unlock(&tp->tx_lock);
49150 @@ -5322,7 +6111,6 @@
49151         else
49152                 tp->tg3_flags &= ~TG3_FLAG_PAUSE_TX;
49153         tg3_halt(tp);
49154 -       tg3_init_rings(tp);
49155         tg3_init_hw(tp);
49156         spin_unlock(&tp->tx_lock);
49157         spin_unlock_irq(&tp->lock);
49158 @@ -5467,6 +6255,10 @@
49159         .set_tx_csum            = tg3_set_tx_csum,
49160         .get_sg                 = ethtool_op_get_sg,
49161         .set_sg                 = ethtool_op_set_sg,
49162 +#if TG3_TSO_SUPPORT != 0
49163 +       .get_tso                = ethtool_op_get_tso,
49164 +       .set_tso                = tg3_set_tso,
49165 +#endif
49166  };
49167  
49168  /* Chips other than 5700/5701 use the NVRAM for fetching info. */
49169 @@ -5669,6 +6461,7 @@
49170                 u32 nic_cfg;
49171  
49172                 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
49173 +               tp->nic_sram_data_cfg = nic_cfg;
49174  
49175                 eeprom_signature_found = 1;
49176  
49177 @@ -5702,8 +6495,10 @@
49178                         eeprom_led_mode = led_mode_auto;
49179                         break;
49180                 };
49181 -               if ((tp->pci_chip_rev_id == CHIPREV_ID_5703_A1 ||
49182 -                    tp->pci_chip_rev_id == CHIPREV_ID_5703_A2) &&
49183 +
49184 +               if (((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
49185 +                    (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
49186 +                    (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) &&
49187                     (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP))
49188                         tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
49189  
49190 @@ -5785,9 +6580,7 @@
49191         }
49192  
49193         /* Enable Ethernet@WireSpeed */
49194 -       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007);
49195 -       tg3_readphy(tp, MII_TG3_AUX_CTRL, &val);
49196 -       tg3_writephy(tp, MII_TG3_AUX_CTRL, (val | (1 << 15) | (1 << 4)));
49197 +       tg3_phy_set_wirespeed(tp);
49198  
49199         if (!err && ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401)) {
49200                 err = tg3_init_5401phy_dsp(tp);
49201 @@ -5927,7 +6720,7 @@
49202                 tp->tg3_flags2 |= TG3_FLG2_SUN_5704;
49203  #endif
49204  
49205 -       /* If we have an AMD 762 or Intel ICH/ICH0 chipset, write
49206 +       /* If we have an AMD 762 or Intel ICH/ICH0/ICH2 chipset, write
49207          * reordering to the mailbox registers done by the host
49208          * controller can cause major troubles.  We read back from
49209          * every mailbox register write to force the writes to be
49210 @@ -5937,6 +6730,10 @@
49211                             PCI_DEVICE_ID_INTEL_82801AA_8, NULL) ||
49212             pci_find_device(PCI_VENDOR_ID_INTEL,
49213                             PCI_DEVICE_ID_INTEL_82801AB_8, NULL) ||
49214 +           pci_find_device(PCI_VENDOR_ID_INTEL,
49215 +                           PCI_DEVICE_ID_INTEL_82801BA_11, NULL) ||
49216 +           pci_find_device(PCI_VENDOR_ID_INTEL,
49217 +                           PCI_DEVICE_ID_INTEL_82801BA_6, NULL) ||
49218             pci_find_device(PCI_VENDOR_ID_AMD,
49219                             PCI_DEVICE_ID_AMD_FE_GATE_700C, NULL))
49220                 tp->tg3_flags |= TG3_FLAG_MBOX_WRITE_REORDER;
49221 @@ -6085,7 +6882,15 @@
49222                 tp->tg3_flags |= TG3_FLAG_WOL_SPEED_100MB;
49223         }
49224  
49225 +       /* A few boards don't want Ethernet@WireSpeed phy feature */
49226 +       if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
49227 +           ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
49228 +            (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) &&
49229 +            (tp->pci_chip_rev_id != CHIPREV_ID_5705_A1)))
49230 +               tp->tg3_flags2 |= TG3_FLG2_NO_ETH_WIRE_SPEED;
49231 +
49232         /* Only 5701 and later support tagged irq status mode.
49233 +        * Also, 5788 chips cannot use tagged irq status.
49234          *
49235          * However, since we are using NAPI avoid tagged irq status
49236          * because the interrupt condition is more difficult to
49237 @@ -6142,7 +6947,8 @@
49238         /* Determine if TX descriptors will reside in
49239          * main memory or in the chip SRAM.
49240          */
49241 -       if (tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG)
49242 +       if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) != 0 ||
49243 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
49244                 tp->tg3_flags |= TG3_FLAG_HOST_TXDS;
49245  
49246         grc_misc_cfg = tr32(GRC_MISC_CFG);
49247 @@ -6154,8 +6960,18 @@
49248                 tp->split_mode_max_reqs = SPLIT_MODE_5704_MAX_REQ;
49249         }
49250  
49251 -       /* this one is limited to 10/100 only */
49252 -       if (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5702FE)
49253 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
49254 +           (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 ||
49255 +            grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M))
49256 +               tp->tg3_flags2 |= TG3_FLG2_IS_5788;
49257 +
49258 +       /* these are limited to 10/100 only */
49259 +       if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 &&
49260 +            (grc_misc_cfg == 0x8000 || grc_misc_cfg == 0x4000)) ||
49261 +           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
49262 +            tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM &&
49263 +            (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5901 ||
49264 +             tp->pdev->device == PCI_DEVICE_ID_TIGON3_5901_2)))
49265                 tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
49266  
49267         err = tg3_phy_probe(tp);
49268 @@ -6414,8 +7230,6 @@
49269                 goto out_nofree;
49270         }
49271  
49272 -       tw32(TG3PCI_CLOCK_CTRL, 0);
49273 -
49274         if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) == 0) {
49275                 tp->dma_rwctrl =
49276                         (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
49277 @@ -6423,7 +7237,9 @@
49278                         (0x7 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
49279                         (0x7 << DMA_RWCTRL_READ_WATER_SHIFT) |
49280                         (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT);
49281 -               /* XXX 5705 note: set MIN_DMA to zero here */
49282 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
49283 +                       tp->dma_rwctrl &= ~(DMA_RWCTRL_MIN_DMA
49284 +                                           << DMA_RWCTRL_MIN_DMA_SHIFT);
49285         } else {
49286                 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
49287                         tp->dma_rwctrl =
49288 @@ -6524,8 +7340,15 @@
49289                 tp->dma_rwctrl |= DMA_RWCTRL_USE_MEM_READ_MULT;
49290         }
49291  
49292 +       tp->dma_rwctrl |= DMA_RWCTRL_ASSERT_ALL_BE;
49293 +
49294         tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
49295  
49296 +#if 0
49297 +       /* Unneeded, already done by tg3_get_invariants.  */
49298 +       tg3_switch_clocks(tp);
49299 +#endif
49300 +
49301         ret = 0;
49302         if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
49303             GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701)
49304 @@ -6630,12 +7453,35 @@
49305         case PHY_ID_BCM5701:    return "5701";
49306         case PHY_ID_BCM5703:    return "5703";
49307         case PHY_ID_BCM5704:    return "5704";
49308 +       case PHY_ID_BCM5705:    return "5705";
49309         case PHY_ID_BCM8002:    return "8002";
49310         case PHY_ID_SERDES:     return "serdes";
49311         default:                return "unknown";
49312         };
49313  }
49314  
49315 +static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
49316 +{
49317 +       struct pci_dev *peer = NULL;
49318 +       unsigned int func;
49319 +
49320 +       for (func = 0; func < 7; func++) {
49321 +               unsigned int devfn = tp->pdev->devfn;
49322 +
49323 +               devfn &= ~7;
49324 +               devfn |= func;
49325 +
49326 +               if (devfn == tp->pdev->devfn)
49327 +                       continue;
49328 +               peer = pci_find_slot(tp->pdev->bus->number, devfn);
49329 +               if (peer)
49330 +                       break;
49331 +       }
49332 +       if (!peer || peer == tp->pdev)
49333 +               BUG();
49334 +       return peer;
49335 +}
49336 +
49337  static int __devinit tg3_init_one(struct pci_dev *pdev,
49338                                   const struct pci_device_id *ent)
49339  {
49340 @@ -6688,7 +7534,7 @@
49341                         goto err_out_free_res;
49342                 }
49343         } else {
49344 -               err = pci_set_dma_mask(pdev, (u64) 0xffffffff);
49345 +               err = pci_set_dma_mask(pdev, 0xffffffffULL);
49346                 if (err) {
49347                         printk(KERN_ERR PFX "No usable DMA configuration, "
49348                                "aborting.\n");
49349 @@ -6794,6 +7640,44 @@
49350                 goto err_out_iounmap;
49351         }
49352  
49353 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
49354 +               tp->bufmgr_config.mbuf_read_dma_low_water =
49355 +                       DEFAULT_MB_RDMA_LOW_WATER_5705;
49356 +               tp->bufmgr_config.mbuf_mac_rx_low_water =
49357 +                       DEFAULT_MB_MACRX_LOW_WATER_5705;
49358 +               tp->bufmgr_config.mbuf_high_water =
49359 +                       DEFAULT_MB_HIGH_WATER_5705;
49360 +       }
49361 +
49362 +#if TG3_TSO_SUPPORT != 0
49363 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
49364 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
49365 +           tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 ||
49366 +           (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0 ||
49367 +           (tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
49368 +               tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE;
49369 +       } else {
49370 +               tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE;
49371 +       }
49372 +
49373 +       /* TSO is off by default, user can enable using ethtool.  */
49374 +#if 0
49375 +       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)
49376 +               dev->features |= NETIF_F_TSO;
49377 +#endif
49378 +
49379 +#endif
49380 +
49381 +       if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A1 &&
49382 +           !(tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) &&
49383 +           !(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH)) {
49384 +               tp->tg3_flags2 |= TG3_FLG2_MAX_RXPEND_64;
49385 +               tp->rx_pending = 64;
49386 +       }
49387 +
49388 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
49389 +               tp->pdev_peer = tg3_find_5704_peer(tp);
49390 +
49391         err = tg3_get_device_address(tp);
49392         if (err) {
49393                 printk(KERN_ERR PFX "Could not obtain valid ethernet address, "
49394 @@ -6816,16 +7700,8 @@
49395         } else
49396                 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS;
49397  
49398 -#if TG3_DO_TSO != 0
49399 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
49400 -           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
49401 -            tp->pci_chip_rev_id <= CHIPREV_ID_5701_B2)) {
49402 -               /* Not TSO capable. */
49403 -               dev->features &= ~NETIF_F_TSO;
49404 -       } else {
49405 -               dev->features |= NETIF_F_TSO;
49406 -       }
49407 -#endif
49408 +       if (tp->tg3_flags2 & TG3_FLG2_IS_5788)
49409 +               dev->features &= ~NETIF_F_HIGHDMA;
49410  
49411         err = register_netdev(dev);
49412         if (err) {
49413 diff -Nru a/drivers/net/tg3.h b/drivers/net/tg3.h
49414 --- a/drivers/net/tg3.h Sat Aug  2 18:24:21 2003
49415 +++ b/drivers/net/tg3.h Sat Aug 23 21:07:46 2003
49416 @@ -24,6 +24,7 @@
49417  #define RX_COPY_THRESHOLD              256
49418  
49419  #define RX_STD_MAX_SIZE                        1536
49420 +#define RX_STD_MAX_SIZE_5705           512
49421  #define RX_JUMBO_MAX_SIZE              0xdeadbeef /* XXX */
49422  
49423  /* First 256 bytes are a mirror of PCI config space. */
49424 @@ -59,7 +60,7 @@
49425  #define  PCIX_CAPS_SPLIT_SHIFT          20
49426  #define  PCIX_CAPS_BURST_MASK           0x000c0000
49427  #define  PCIX_CAPS_BURST_SHIFT          18
49428 -#define  PCIX_CAPS_MAX_BURST_5704       2
49429 +#define  PCIX_CAPS_MAX_BURST_CPIOB      2
49430  #define TG3PCI_PM_CAP_PTR              0x00000041
49431  #define TG3PCI_X_COMMAND               0x00000042
49432  #define TG3PCI_X_STATUS                        0x00000044
49433 @@ -115,11 +116,14 @@
49434  #define  CHIPREV_ID_5704_A0             0x2000
49435  #define  CHIPREV_ID_5704_A1             0x2001
49436  #define  CHIPREV_ID_5704_A2             0x2002
49437 +#define  CHIPREV_ID_5705_A0             0x3000
49438 +#define  CHIPREV_ID_5705_A1             0x3001
49439  #define  GET_ASIC_REV(CHIP_REV_ID)     ((CHIP_REV_ID) >> 12)
49440  #define   ASIC_REV_5700                         0x07
49441  #define   ASIC_REV_5701                         0x00
49442  #define   ASIC_REV_5703                         0x01
49443  #define   ASIC_REV_5704                         0x02
49444 +#define   ASIC_REV_5705                         0x03
49445  #define  GET_CHIP_REV(CHIP_REV_ID)     ((CHIP_REV_ID) >> 8)
49446  #define   CHIPREV_5700_AX               0x70
49447  #define   CHIPREV_5700_BX               0x71
49448 @@ -180,6 +184,9 @@
49449  #define  CLOCK_CTRL_ALTCLK              0x00001000
49450  #define  CLOCK_CTRL_PWRDOWN_PLL133      0x00008000
49451  #define  CLOCK_CTRL_44MHZ_CORE          0x00040000
49452 +#define  CLOCK_CTRL_625_CORE            0x00100000
49453 +#define  CLOCK_CTRL_FORCE_CLKRUN        0x00200000
49454 +#define  CLOCK_CTRL_CLKRUN_OENABLE      0x00400000
49455  #define  CLOCK_CTRL_DELAY_PCI_GRANT     0x80000000
49456  #define TG3PCI_REG_BASE_ADDR           0x00000078
49457  #define TG3PCI_MEM_WIN_BASE_ADDR       0x0000007c
49458 @@ -457,17 +464,89 @@
49459  #define MAC_RCV_RULE_CFG               0x00000500
49460  #define  RCV_RULE_CFG_DEFAULT_CLASS    0x00000008
49461  #define MAC_LOW_WMARK_MAX_RX_FRAME     0x00000504
49462 -/* 0x504 --> 0x590 unused */
49463 +/* 0x508 --> 0x520 unused */
49464 +#define MAC_HASHREGU_0                 0x00000520
49465 +#define MAC_HASHREGU_1                 0x00000524
49466 +#define MAC_HASHREGU_2                 0x00000528
49467 +#define MAC_HASHREGU_3                 0x0000052c
49468 +#define MAC_EXTADDR_0_HIGH             0x00000530
49469 +#define MAC_EXTADDR_0_LOW              0x00000534
49470 +#define MAC_EXTADDR_1_HIGH             0x00000538
49471 +#define MAC_EXTADDR_1_LOW              0x0000053c
49472 +#define MAC_EXTADDR_2_HIGH             0x00000540
49473 +#define MAC_EXTADDR_2_LOW              0x00000544
49474 +#define MAC_EXTADDR_3_HIGH             0x00000548
49475 +#define MAC_EXTADDR_3_LOW              0x0000054c
49476 +#define MAC_EXTADDR_4_HIGH             0x00000550
49477 +#define MAC_EXTADDR_4_LOW              0x00000554
49478 +#define MAC_EXTADDR_5_HIGH             0x00000558
49479 +#define MAC_EXTADDR_5_LOW              0x0000055c
49480 +#define MAC_EXTADDR_6_HIGH             0x00000560
49481 +#define MAC_EXTADDR_6_LOW              0x00000564
49482 +#define MAC_EXTADDR_7_HIGH             0x00000568
49483 +#define MAC_EXTADDR_7_LOW              0x0000056c
49484 +#define MAC_EXTADDR_8_HIGH             0x00000570
49485 +#define MAC_EXTADDR_8_LOW              0x00000574
49486 +#define MAC_EXTADDR_9_HIGH             0x00000578
49487 +#define MAC_EXTADDR_9_LOW              0x0000057c
49488 +#define MAC_EXTADDR_10_HIGH            0x00000580
49489 +#define MAC_EXTADDR_10_LOW             0x00000584
49490 +#define MAC_EXTADDR_11_HIGH            0x00000588
49491 +#define MAC_EXTADDR_11_LOW             0x0000058c
49492  #define MAC_SERDES_CFG                 0x00000590
49493  #define MAC_SERDES_STAT                        0x00000594
49494  /* 0x598 --> 0x600 unused */
49495  #define MAC_TX_MAC_STATE_BASE          0x00000600 /* 16 bytes */
49496  #define MAC_RX_MAC_STATE_BASE          0x00000610 /* 20 bytes */
49497  /* 0x624 --> 0x800 unused */
49498 -#define MAC_RX_STATS_BASE              0x00000800 /* 26 32-bit words */
49499 -/* 0x868 --> 0x880 unused */
49500 -#define MAC_TX_STATS_BASE              0x00000880 /* 28 32-bit words */
49501 -/* 0x8f0 --> 0xc00 unused */
49502 +#define MAC_TX_STATS_OCTETS            0x00000800
49503 +#define MAC_TX_STATS_RESV1             0x00000804
49504 +#define MAC_TX_STATS_COLLISIONS                0x00000808
49505 +#define MAC_TX_STATS_XON_SENT          0x0000080c
49506 +#define MAC_TX_STATS_XOFF_SENT         0x00000810
49507 +#define MAC_TX_STATS_RESV2             0x00000814
49508 +#define MAC_TX_STATS_MAC_ERRORS                0x00000818
49509 +#define MAC_TX_STATS_SINGLE_COLLISIONS 0x0000081c
49510 +#define MAC_TX_STATS_MULT_COLLISIONS   0x00000820
49511 +#define MAC_TX_STATS_DEFERRED          0x00000824
49512 +#define MAC_TX_STATS_RESV3             0x00000828
49513 +#define MAC_TX_STATS_EXCESSIVE_COL     0x0000082c
49514 +#define MAC_TX_STATS_LATE_COL          0x00000830
49515 +#define MAC_TX_STATS_RESV4_1           0x00000834
49516 +#define MAC_TX_STATS_RESV4_2           0x00000838
49517 +#define MAC_TX_STATS_RESV4_3           0x0000083c
49518 +#define MAC_TX_STATS_RESV4_4           0x00000840
49519 +#define MAC_TX_STATS_RESV4_5           0x00000844
49520 +#define MAC_TX_STATS_RESV4_6           0x00000848
49521 +#define MAC_TX_STATS_RESV4_7           0x0000084c
49522 +#define MAC_TX_STATS_RESV4_8           0x00000850
49523 +#define MAC_TX_STATS_RESV4_9           0x00000854
49524 +#define MAC_TX_STATS_RESV4_10          0x00000858
49525 +#define MAC_TX_STATS_RESV4_11          0x0000085c
49526 +#define MAC_TX_STATS_RESV4_12          0x00000860
49527 +#define MAC_TX_STATS_RESV4_13          0x00000864
49528 +#define MAC_TX_STATS_RESV4_14          0x00000868
49529 +#define MAC_TX_STATS_UCAST             0x0000086c
49530 +#define MAC_TX_STATS_MCAST             0x00000870
49531 +#define MAC_TX_STATS_BCAST             0x00000874
49532 +#define MAC_TX_STATS_RESV5_1           0x00000878
49533 +#define MAC_TX_STATS_RESV5_2           0x0000087c
49534 +#define MAC_RX_STATS_OCTETS            0x00000880
49535 +#define MAC_RX_STATS_RESV1             0x00000884
49536 +#define MAC_RX_STATS_FRAGMENTS         0x00000888
49537 +#define MAC_RX_STATS_UCAST             0x0000088c
49538 +#define MAC_RX_STATS_MCAST             0x00000890
49539 +#define MAC_RX_STATS_BCAST             0x00000894
49540 +#define MAC_RX_STATS_FCS_ERRORS                0x00000898
49541 +#define MAC_RX_STATS_ALIGN_ERRORS      0x0000089c
49542 +#define MAC_RX_STATS_XON_PAUSE_RECVD   0x000008a0
49543 +#define MAC_RX_STATS_XOFF_PAUSE_RECVD  0x000008a4
49544 +#define MAC_RX_STATS_MAC_CTRL_RECVD    0x000008a8
49545 +#define MAC_RX_STATS_XOFF_ENTERED      0x000008ac
49546 +#define MAC_RX_STATS_FRAME_TOO_LONG    0x000008b0
49547 +#define MAC_RX_STATS_JABBERS           0x000008b4
49548 +#define MAC_RX_STATS_UNDERSIZE         0x000008b8
49549 +/* 0x8bc --> 0xc00 unused */
49550  
49551  /* Send data initiator control registers */
49552  #define SNDDATAI_MODE                  0x00000c00
49553 @@ -599,6 +678,7 @@
49554  #define  RCVLPC_STATSCTRL_ENABLE        0x00000001
49555  #define  RCVLPC_STATSCTRL_FASTUPD       0x00000002
49556  #define RCVLPC_STATS_ENABLE            0x00002018
49557 +#define  RCVLPC_STATSENAB_LNGBRST_RFIX  0x00400000
49558  #define RCVLPC_STATS_INCMASK           0x0000201c
49559  /* 0x2020 --> 0x2100 unused */
49560  #define RCVLPC_SELLST_BASE             0x00002100 /* 16 16-byte entries */
49561 @@ -812,13 +892,16 @@
49562  #define BUFMGR_MB_POOL_ADDR            0x00004408
49563  #define BUFMGR_MB_POOL_SIZE            0x0000440c
49564  #define BUFMGR_MB_RDMA_LOW_WATER       0x00004410
49565 -#define  DEFAULT_MB_RDMA_LOW_WATER      0x00000040
49566 +#define  DEFAULT_MB_RDMA_LOW_WATER      0x00000050
49567 +#define  DEFAULT_MB_RDMA_LOW_WATER_5705         0x00000000
49568  #define  DEFAULT_MB_RDMA_LOW_WATER_JUMBO 0x00000130
49569  #define BUFMGR_MB_MACRX_LOW_WATER      0x00004414
49570  #define  DEFAULT_MB_MACRX_LOW_WATER      0x00000020
49571 +#define  DEFAULT_MB_MACRX_LOW_WATER_5705  0x00000010
49572  #define  DEFAULT_MB_MACRX_LOW_WATER_JUMBO 0x00000098
49573  #define BUFMGR_MB_HIGH_WATER           0x00004418
49574  #define  DEFAULT_MB_HIGH_WATER          0x00000060
49575 +#define  DEFAULT_MB_HIGH_WATER_5705     0x00000060
49576  #define  DEFAULT_MB_HIGH_WATER_JUMBO    0x0000017c
49577  #define BUFMGR_RX_MB_ALLOC_REQ         0x0000441c
49578  #define  BUFMGR_MB_ALLOC_BIT            0x10000000
49579 @@ -854,6 +937,8 @@
49580  #define  RDMAC_MODE_LNGREAD_ENAB        0x00000200
49581  #define  RDMAC_MODE_SPLIT_ENABLE        0x00000800
49582  #define  RDMAC_MODE_SPLIT_RESET                 0x00001000
49583 +#define  RDMAC_MODE_FIFO_SIZE_128       0x00020000
49584 +#define  RDMAC_MODE_FIFO_LONG_BURST     0x00030000
49585  #define RDMAC_STATUS                   0x00004804
49586  #define  RDMAC_STATUS_TGTABORT          0x00000004
49587  #define  RDMAC_STATUS_MSTABORT          0x00000008
49588 @@ -877,6 +962,7 @@
49589  #define  WDMAC_MODE_FIFOURUN_ENAB       0x00000080
49590  #define  WDMAC_MODE_FIFOOREAD_ENAB      0x00000100
49591  #define  WDMAC_MODE_LNGREAD_ENAB        0x00000200
49592 +#define  WDMAC_MODE_RX_ACCEL            0x00000400
49593  #define WDMAC_STATUS                   0x00004c04
49594  #define  WDMAC_STATUS_TGTABORT          0x00000004
49595  #define  WDMAC_STATUS_MSTABORT          0x00000008
49596 @@ -1140,7 +1226,10 @@
49597  #define  GRC_MISC_CFG_BOARD_ID_5704    0x00000000
49598  #define  GRC_MISC_CFG_BOARD_ID_5704CIOBE 0x00004000
49599  #define  GRC_MISC_CFG_BOARD_ID_5704_A2 0x00008000
49600 +#define  GRC_MISC_CFG_BOARD_ID_5788    0x00010000
49601 +#define  GRC_MISC_CFG_BOARD_ID_5788M   0x00018000
49602  #define  GRC_MISC_CFG_BOARD_ID_AC91002A1 0x00018000
49603 +#define  GRC_MISC_CFG_KEEP_GPHY_POWER  0x04000000
49604  #define GRC_LOCAL_CTRL                 0x00006808
49605  #define  GRC_LCLCTRL_INT_ACTIVE                0x00000001
49606  #define  GRC_LCLCTRL_CLEARINT          0x00000002
49607 @@ -1275,6 +1364,7 @@
49608  #define  NIC_SRAM_DATA_CFG_WOL_ENABLE           0x00000040
49609  #define  NIC_SRAM_DATA_CFG_ASF_ENABLE           0x00000080
49610  #define  NIC_SRAM_DATA_CFG_EEPROM_WP            0x00000100
49611 +#define  NIC_SRAM_DATA_CFG_MINI_PCI             0x00001000
49612  #define  NIC_SRAM_DATA_CFG_FIBER_WOL            0x00004000
49613  
49614  #define NIC_SRAM_DATA_PHY_ID           0x00000b74
49615 @@ -1312,6 +1402,8 @@
49616  #define NIC_SRAM_MBUF_POOL_BASE                0x00008000
49617  #define  NIC_SRAM_MBUF_POOL_SIZE96      0x00018000
49618  #define  NIC_SRAM_MBUF_POOL_SIZE64      0x00010000
49619 +#define  NIC_SRAM_MBUF_POOL_BASE5705   0x00010000
49620 +#define  NIC_SRAM_MBUF_POOL_SIZE5705   0x0000e000
49621  
49622  /* Currently this is fixed. */
49623  #define PHY_ADDR               0x01
49624 @@ -1824,6 +1916,10 @@
49625         u32                             tg3_flags2;
49626  #define TG3_FLG2_RESTART_TIMER         0x00000001
49627  #define TG3_FLG2_SUN_5704              0x00000002
49628 +#define TG3_FLG2_NO_ETH_WIRE_SPEED     0x00000004
49629 +#define TG3_FLG2_IS_5788               0x00000008
49630 +#define TG3_FLG2_MAX_RXPEND_64         0x00000010
49631 +#define TG3_FLG2_TSO_CAPABLE           0x00000020
49632  
49633         u32                             split_mode_max_reqs;
49634  #define SPLIT_MODE_5704_MAX_REQ                3
49635 @@ -1868,6 +1964,7 @@
49636  #define PHY_ID_BCM5701                 0x60008110
49637  #define PHY_ID_BCM5703                 0x60008160
49638  #define PHY_ID_BCM5704                 0x60008190
49639 +#define PHY_ID_BCM5705                 0x600081a0
49640  #define PHY_ID_BCM8002                 0x60010140
49641  #define PHY_ID_SERDES                  0xfeedbee0
49642  #define PHY_ID_INVALID                 0xffffffff
49643 @@ -1880,6 +1977,9 @@
49644         enum phy_led_mode               led_mode;
49645  
49646         char                            board_part_number[24];
49647 +       u32                             nic_sram_data_cfg;
49648 +       u32                             pci_clock_ctrl;
49649 +       struct pci_dev                  *pdev_peer;
49650  
49651         /* This macro assumes the passed PHY ID is already masked
49652          * with PHY_ID_MASK.
49653 @@ -1888,6 +1988,7 @@
49654         ((X) == PHY_ID_BCM5400 || (X) == PHY_ID_BCM5401 || \
49655          (X) == PHY_ID_BCM5411 || (X) == PHY_ID_BCM5701 || \
49656          (X) == PHY_ID_BCM5703 || (X) == PHY_ID_BCM5704 || \
49657 +        (X) == PHY_ID_BCM5705 || \
49658          (X) == PHY_ID_BCM8002 || (X) == PHY_ID_SERDES)
49659  
49660         struct tg3_hw_stats             *hw_stats;
49661 diff -Nru a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
49662 --- a/drivers/net/tokenring/lanstreamer.c       Tue Aug 19 20:54:17 2003
49663 +++ b/drivers/net/tokenring/lanstreamer.c       Mon Sep  1 08:30:59 2003
49664 @@ -228,7 +228,6 @@
49665         int rc = 0;
49666         static int card_no=-1;
49667         u16 pcr;
49668 -       u8 cls = 0;
49669  
49670  #if STREAMER_DEBUG
49671         printk("lanstreamer::streamer_init_one, entry pdev %p\n",pdev);
49672 @@ -254,14 +253,16 @@
49673  #endif
49674  #endif
49675  
49676 -       if (pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
49677 +       rc = pci_set_dma_mask(pdev, 0xFFFFFFFFULL);
49678 +       if (rc) {
49679                 printk(KERN_ERR "%s: No suitable PCI mapping available.\n",
49680                                 dev->name);
49681                 rc = -ENODEV;
49682                 goto err_out;
49683         }
49684  
49685 -       if (pci_enable_device(pdev)) {
49686 +       rc = pci_enable_device(pdev);
49687 +       if (rc) {
49688                 printk(KERN_ERR "lanstreamer: unable to enable pci device\n");
49689                 rc=-EIO;
49690                 goto err_out;
49691 @@ -269,6 +270,12 @@
49692  
49693         pci_set_master(pdev);
49694  
49695 +       rc = pci_set_mwi(pdev);
49696 +       if (rc) {
49697 +               printk(KERN_ERR "lanstreamer: unable to enable MWI on pci device\n");
49698 +               goto err_out_disable;
49699 +       }
49700 +
49701         pio_start = pci_resource_start(pdev, 0);
49702         pio_end = pci_resource_end(pdev, 0);
49703         pio_flags = pci_resource_flags(pdev, 0);
49704 @@ -290,7 +297,7 @@
49705                 printk(KERN_ERR "lanstreamer: unable to get pci io addr %lx\n",
49706                         pio_start);
49707                 rc= -EBUSY;
49708 -               goto err_out;
49709 +               goto err_out_mwi;
49710         }
49711  
49712         if (!request_mem_region(mmio_start, mmio_len, "lanstreamer")) {
49713 @@ -341,26 +348,9 @@
49714  
49715         spin_lock_init(&streamer_priv->streamer_lock);
49716  
49717 -       pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cls);
49718 -       cls <<= 2;
49719 -       if (cls != SMP_CACHE_BYTES) {
49720 -               printk(KERN_INFO "  PCI cache line size set incorrectly "
49721 -                               "(%i bytes) by BIOS/FW, ", cls);
49722 -               if (cls > SMP_CACHE_BYTES)
49723 -                       printk("expecting %i\n", SMP_CACHE_BYTES);
49724 -               else {
49725 -                       printk("correcting to %i\n", SMP_CACHE_BYTES);
49726 -                       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
49727 -                                                       SMP_CACHE_BYTES >> 2);
49728 -               }
49729 -       }
49730 -
49731         pci_read_config_word (pdev, PCI_COMMAND, &pcr);
49732 -
49733 -       pcr |= (PCI_COMMAND_INVALIDATE | PCI_COMMAND_SERR);
49734 -
49735 +       pcr |= PCI_COMMAND_SERR;
49736         pci_write_config_word (pdev, PCI_COMMAND, pcr);
49737 -       pci_read_config_word (pdev, PCI_COMMAND, &pcr);
49738  
49739         printk("%s \n", version);
49740         printk("%s: %s. I/O at %hx, MMIO at %p, using irq %d\n",dev->name,
49741 @@ -383,8 +373,12 @@
49742         release_mem_region(mmio_start, mmio_len);
49743  err_out_free_pio:
49744         release_region(pio_start, pio_len);
49745 +err_out_mwi:
49746 +       pci_clear_mwi(pdev);
49747 +err_out_disable:
49748 +       pci_disable_device(pdev);
49749  err_out:
49750 -       kfree(dev);
49751 +       free_netdev(dev);
49752  #if STREAMER_DEBUG
49753         printk("lanstreamer: Exit error %x\n",rc);
49754  #endif
49755 @@ -430,9 +424,11 @@
49756  #endif
49757  
49758         unregister_netdev(dev);
49759 -       /* shouldn't we do iounmap here? */
49760 -       release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0));
49761 +       iounmap(streamer_priv->streamer_mmio);
49762         release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev,1));
49763 +       release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0));
49764 +       pci_clear_mwi(pdev);
49765 +       pci_disable_device(pdev);
49766         free_netdev(dev);
49767         pci_set_drvdata(pdev, NULL);
49768  }
49769 diff -Nru a/drivers/net/tulip/Kconfig b/drivers/net/tulip/Kconfig
49770 --- a/drivers/net/tulip/Kconfig Mon Aug 18 21:08:08 2003
49771 +++ b/drivers/net/tulip/Kconfig Mon Aug 25 05:54:02 2003
49772 @@ -129,7 +129,7 @@
49773  
49774  config PCMCIA_XIRTULIP
49775         tristate "Xircom Tulip-like CardBus support (old driver)"
49776 -       depends on NET_TULIP && CARDBUS
49777 +       depends on NET_TULIP && CARDBUS && BROKEN_ON_SMP
49778         ---help---
49779           This driver is for the Digital "Tulip" Ethernet CardBus adapters.
49780           It should work with most DEC 21*4*-based chips/ethercards, as well
49781 diff -Nru a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
49782 --- a/drivers/net/tulip/de2104x.c       Tue Aug 19 20:53:17 2003
49783 +++ b/drivers/net/tulip/de2104x.c       Mon Sep  1 08:05:06 2003
49784 @@ -1,6 +1,6 @@
49785  /* de2104x.c: A Linux PCI Ethernet driver for Intel/Digital 21040/1 chips. */
49786  /*
49787 -       Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
49788 +       Copyright 2001,2003 Jeff Garzik <jgarzik@pobox.com>
49789  
49790         Copyright 1994, 1995 Digital Equipment Corporation.         [de4x5.c]
49791         Written/copyright 1994-2001 by Donald Becker.               [tulip.c]
49792 @@ -28,8 +28,8 @@
49793   */
49794  
49795  #define DRV_NAME               "de2104x"
49796 -#define DRV_VERSION            "0.5.4"
49797 -#define DRV_RELDATE            "Jan 1, 2002"
49798 +#define DRV_VERSION            "0.6"
49799 +#define DRV_RELDATE            "Sep 1, 2003"
49800  
49801  #include <linux/config.h>
49802  #include <linux/module.h>
49803 @@ -1464,7 +1464,7 @@
49804         netif_wake_queue(dev);
49805  }
49806  
49807 -static int de_get_regs(struct de_private *de, u8 *buf)
49808 +static void __de_get_regs(struct de_private *de, u8 *buf)
49809  {
49810         int i;
49811         u32 *rbuf = (u32 *)buf;
49812 @@ -1475,11 +1475,9 @@
49813  
49814         /* handle self-clearing RxMissed counter, CSR8 */
49815         de_rx_missed(de, rbuf[8]);
49816 -
49817 -       return 0;
49818  }
49819  
49820 -static int de_ethtool_gset(struct de_private *de, struct ethtool_cmd *ecmd)
49821 +static int __de_get_settings(struct de_private *de, struct ethtool_cmd *ecmd)
49822  {
49823         ecmd->supported = de->media_supported;
49824         ecmd->transceiver = XCVR_INTERNAL;
49825 @@ -1516,7 +1514,7 @@
49826         return 0;
49827  }
49828  
49829 -static int de_ethtool_sset(struct de_private *de, struct ethtool_cmd *ecmd)
49830 +static int __de_set_settings(struct de_private *de, struct ethtool_cmd *ecmd)
49831  {
49832         u32 new_media;
49833         unsigned int media_lock;
49834 @@ -1584,169 +1582,121 @@
49835         return 0;
49836  }
49837  
49838 -static int de_ethtool_ioctl (struct de_private *de, void *useraddr)
49839 +static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info)
49840  {
49841 -       u32 ethcmd;
49842 +       struct de_private *de = dev->priv;
49843  
49844 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
49845 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
49846 +       strcpy (info->driver, DRV_NAME);
49847 +       strcpy (info->version, DRV_VERSION);
49848 +       strcpy (info->bus_info, pci_name(de->pdev));
49849 +       info->eedump_len = DE_EEPROM_SIZE;
49850 +}
49851  
49852 -       if (get_user(ethcmd, (u32 *)useraddr))
49853 -               return -EFAULT;
49854 -
49855 -       switch (ethcmd) {
49856 -
49857 -       case ETHTOOL_GDRVINFO: {
49858 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
49859 -               strcpy (info.driver, DRV_NAME);
49860 -               strcpy (info.version, DRV_VERSION);
49861 -               strcpy (info.bus_info, pci_name(de->pdev));
49862 -               info.eedump_len = DE_EEPROM_SIZE;
49863 -               info.regdump_len = DE_REGS_SIZE;
49864 -               if (copy_to_user (useraddr, &info, sizeof (info)))
49865 -                       return -EFAULT;
49866 -               return 0;
49867 -       }
49868 -
49869 -       /* get settings */
49870 -       case ETHTOOL_GSET: {
49871 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
49872 -               spin_lock_irq(&de->lock);
49873 -               de_ethtool_gset(de, &ecmd);
49874 -               spin_unlock_irq(&de->lock);
49875 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
49876 -                       return -EFAULT;
49877 -               return 0;
49878 -       }
49879 -       /* set settings */
49880 -       case ETHTOOL_SSET: {
49881 -               struct ethtool_cmd ecmd;
49882 -               int r;
49883 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
49884 -                       return -EFAULT;
49885 -               spin_lock_irq(&de->lock);
49886 -               r = de_ethtool_sset(de, &ecmd);
49887 -               spin_unlock_irq(&de->lock);
49888 -               return r;
49889 -       }
49890 +static int de_get_regs_len(struct net_device *dev)
49891 +{
49892 +       return DE_REGS_SIZE;
49893 +}
49894  
49895 -       /* restart autonegotiation */
49896 -       case ETHTOOL_NWAY_RST: {
49897 -               u32 status;
49898 +static int de_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
49899 +{
49900 +       struct de_private *de = dev->priv;
49901 +       int rc;
49902  
49903 -               if (de->media_type != DE_MEDIA_TP_AUTO)
49904 -                       return -EINVAL;
49905 -               if (netif_carrier_ok(de->dev))
49906 -                       de_link_down(de);
49907 +       spin_lock_irq(&de->lock);
49908 +       rc = __de_get_settings(de, ecmd);
49909 +       spin_unlock_irq(&de->lock);
49910  
49911 -               status = dr32(SIAStatus);
49912 -               dw32(SIAStatus, (status & ~NWayState) | NWayRestart);
49913 -               if (netif_msg_link(de))
49914 -                       printk(KERN_INFO "%s: link nway restart, status %x,%x\n",
49915 -                              de->dev->name, status, dr32(SIAStatus));
49916 -               return 0;
49917 -       }
49918 -
49919 -       /* get link status */
49920 -       case ETHTOOL_GLINK: {
49921 -               struct ethtool_value edata = {ETHTOOL_GLINK};
49922 -               edata.data = (netif_carrier_ok(de->dev)) ? 1 : 0;
49923 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
49924 -                       return -EFAULT;
49925 -               return 0;
49926 -       }
49927 -
49928 -       /* get message-level */
49929 -       case ETHTOOL_GMSGLVL: {
49930 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
49931 -               edata.data = de->msg_enable;
49932 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
49933 -                       return -EFAULT;
49934 -               return 0;
49935 -       }
49936 -       /* set message-level */
49937 -       case ETHTOOL_SMSGLVL: {
49938 -               struct ethtool_value edata;
49939 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
49940 -                       return -EFAULT;
49941 -               de->msg_enable = edata.data;
49942 -               return 0;
49943 -       }
49944 -
49945 -       /* get registers */
49946 -       case ETHTOOL_GREGS: {
49947 -               struct ethtool_regs regs;
49948 -               u8 regbuf[DE_REGS_SIZE];
49949 -               int r;
49950 +       return rc;
49951 +}
49952  
49953 -               if (copy_from_user(&regs, useraddr, sizeof(regs)))
49954 -                       return -EFAULT;
49955 -               
49956 -               if (regs.len > DE_REGS_SIZE) {
49957 -                       regs.len = DE_REGS_SIZE;
49958 -               }
49959 -               regs.version = (DE_REGS_VER << 2) | de->de21040;
49960 -               if (copy_to_user(useraddr, &regs, sizeof(regs)))
49961 -                       return -EFAULT;
49962 +static int de_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
49963 +{
49964 +       struct de_private *de = dev->priv;
49965 +       int rc;
49966  
49967 -               useraddr += offsetof(struct ethtool_regs, data);
49968 +       spin_lock_irq(&de->lock);
49969 +       rc = __de_set_settings(de, ecmd);
49970 +       spin_unlock_irq(&de->lock);
49971  
49972 -               spin_lock_irq(&de->lock);
49973 -               r = de_get_regs(de, regbuf);
49974 -               spin_unlock_irq(&de->lock);
49975 +       return rc;
49976 +}
49977  
49978 -               if (r)
49979 -                       return r;
49980 -               if (copy_to_user(useraddr, regbuf, regs.len))
49981 -                       return -EFAULT;
49982 -               return 0;
49983 -       }
49984 +static u32 de_get_msglevel(struct net_device *dev)
49985 +{
49986 +       struct de_private *de = dev->priv;
49987  
49988 -       /* get SROM dump */
49989 -       case ETHTOOL_GEEPROM: {
49990 -               struct ethtool_eeprom eeprom;
49991 +       return de->msg_enable;
49992 +}
49993  
49994 -               if (!de->ee_data)
49995 -                       break;
49996 -               if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
49997 -                       return -EFAULT;
49998 -               if ((eeprom.offset != 0) || (eeprom.magic != 0) ||
49999 -                   (eeprom.len != DE_EEPROM_SIZE))
50000 -                       return -EINVAL;
50001 +static void de_set_msglevel(struct net_device *dev, u32 msglvl)
50002 +{
50003 +       struct de_private *de = dev->priv;
50004  
50005 -               useraddr += offsetof(struct ethtool_regs, data);
50006 -               if (copy_to_user(useraddr, de->ee_data, DE_EEPROM_SIZE))
50007 -                       return -EFAULT;
50008 -       }
50009 +       de->msg_enable = msglvl;
50010 +}
50011  
50012 -       default:
50013 -               break;
50014 -       }
50015 +static int de_get_eeprom(struct net_device *dev,
50016 +                        struct ethtool_eeprom *eeprom, u8 *data)
50017 +{
50018 +       struct de_private *de = dev->priv;
50019  
50020 -       return -EOPNOTSUPP;
50021 -}
50022 +       if (!de->ee_data)
50023 +               return -EOPNOTSUPP;
50024 +       if ((eeprom->offset != 0) || (eeprom->magic != 0) ||
50025 +           (eeprom->len != DE_EEPROM_SIZE))
50026 +               return -EINVAL;
50027 +       memcpy(data, de->ee_data, eeprom->len);
50028  
50029 +       return 0;
50030 +}
50031  
50032 -static int de_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
50033 +static int de_nway_reset(struct net_device *dev)
50034  {
50035         struct de_private *de = dev->priv;
50036 -       int rc = 0;
50037 +       u32 status;
50038  
50039 -       if (!netif_running(dev))
50040 +       if (de->media_type != DE_MEDIA_TP_AUTO)
50041                 return -EINVAL;
50042 -               
50043 -       switch (cmd) {
50044 -       case SIOCETHTOOL:
50045 -               return de_ethtool_ioctl(de, (void *) rq->ifr_data);
50046 +       if (netif_carrier_ok(de->dev))
50047 +               de_link_down(de);
50048  
50049 -       default:
50050 -               rc = -EOPNOTSUPP;
50051 -               break;
50052 -       }
50053 +       status = dr32(SIAStatus);
50054 +       dw32(SIAStatus, (status & ~NWayState) | NWayRestart);
50055 +       if (netif_msg_link(de))
50056 +               printk(KERN_INFO "%s: link nway restart, status %x,%x\n",
50057 +                      de->dev->name, status, dr32(SIAStatus));
50058 +       return 0;
50059 +}
50060  
50061 -       return rc;
50062 +static void de_get_regs(struct net_device *dev, struct ethtool_regs *regs,
50063 +                       void *data)
50064 +{
50065 +       struct de_private *de = dev->priv;
50066 +
50067 +       if (regs->len > DE_REGS_SIZE)
50068 +               regs->len = DE_REGS_SIZE;
50069 +       regs->version = (DE_REGS_VER << 2) | de->de21040;
50070 +
50071 +       spin_lock_irq(&de->lock);
50072 +       __de_get_regs(de, data);
50073 +       spin_unlock_irq(&de->lock);
50074  }
50075  
50076 +static struct ethtool_ops de_ethtool_ops = {
50077 +       .get_link               = ethtool_op_get_link,
50078 +       .get_tx_csum            = ethtool_op_get_tx_csum,
50079 +       .get_sg                 = ethtool_op_get_sg,
50080 +       .get_drvinfo            = de_get_drvinfo,
50081 +       .get_regs_len           = de_get_regs_len,
50082 +       .get_settings           = de_get_settings,
50083 +       .set_settings           = de_set_settings,
50084 +       .get_msglevel           = de_get_msglevel,
50085 +       .set_msglevel           = de_set_msglevel,
50086 +       .get_eeprom             = de_get_eeprom,
50087 +       .nway_reset             = de_nway_reset,
50088 +       .get_regs               = de_get_regs,
50089 +};
50090 +
50091  static void __init de21040_get_mac_address (struct de_private *de)
50092  {
50093         unsigned i;
50094 @@ -2011,7 +1961,7 @@
50095         dev->set_multicast_list = de_set_rx_mode;
50096         dev->hard_start_xmit = de_start_xmit;
50097         dev->get_stats = de_get_stats;
50098 -       dev->do_ioctl = de_ioctl;
50099 +       dev->ethtool_ops = &de_ethtool_ops;
50100         dev->tx_timeout = de_tx_timeout;
50101         dev->watchdog_timeo = TX_TIMEOUT;
50102  
50103 diff -Nru a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
50104 --- a/drivers/net/tulip/de4x5.c Tue Aug 19 20:53:17 2003
50105 +++ b/drivers/net/tulip/de4x5.c Wed Sep  3 10:39:23 2003
50106 @@ -437,6 +437,9 @@
50107                             present. 
50108                             <france@handhelds.org>  
50109        0.547  08-Nov-01    Use library crc32 functions by <Matt_Domsch@dell.com>
50110 +      0.548  30-Aug-03    Big 2.6 cleanup. Ported to PCI/EISA probing and
50111 +                           generic DMA APIs. Fixed DE425 support on Alpha.
50112 +                          <maz@wild-wind.fr.eu.org>
50113      =========================================================================
50114  */
50115  
50116 @@ -450,6 +453,7 @@
50117  #include <linux/ioport.h>
50118  #include <linux/slab.h>
50119  #include <linux/pci.h>
50120 +#include <linux/eisa.h>
50121  #include <linux/delay.h>
50122  #include <linux/init.h>
50123  #include <linux/spinlock.h>
50124 @@ -461,6 +465,8 @@
50125  #include <linux/types.h>
50126  #include <linux/unistd.h>
50127  #include <linux/ctype.h>
50128 +#include <linux/dma-mapping.h>
50129 +#include <linux/moduleparam.h>
50130  
50131  #include <asm/bitops.h>
50132  #include <asm/io.h>
50133 @@ -625,13 +631,13 @@
50134  #define DE4X5_EISA_IO_PORTS   0x0c00    /* I/O port base address, slot 0 */
50135  #define DE4X5_EISA_TOTAL_SIZE 0x100     /* I/O address extent */
50136  
50137 -#define MAX_EISA_SLOTS 16
50138 -#define EISA_SLOT_INC 0x1000
50139  #define EISA_ALLOWED_IRQ_LIST  {5, 9, 10, 11}
50140  
50141  #define DE4X5_SIGNATURE {"DE425","DE434","DE435","DE450","DE500"}
50142  #define DE4X5_NAME_LENGTH 8
50143  
50144 +static c_char *de4x5_signatures[] = DE4X5_SIGNATURE;
50145 +
50146  /*
50147  ** Ethernet PROM defines for DC21040
50148  */
50149 @@ -644,7 +650,6 @@
50150  #define PCI_MAX_BUS_NUM      8
50151  #define DE4X5_PCI_TOTAL_SIZE 0x80       /* I/O address extent */
50152  #define DE4X5_CLASS_CODE     0x00020000 /* Network controller, Ethernet */
50153 -#define NO_MORE_PCI          -2         /* PCI bus search all done */
50154  
50155  /*
50156  ** Memory Alignment. Each descriptor is 4 longwords long. To force a
50157 @@ -819,7 +824,6 @@
50158      struct timer_list timer;                /* Timer info for kernel        */
50159      int tmp;                                /* Temporary global per card    */
50160      struct {
50161 -       void *priv;                         /* Original kmalloc'd mem addr  */
50162         u_long lock;                        /* Lock the cache accesses      */
50163         s32 csr0;                           /* Saved Bus Mode Register      */
50164         s32 csr6;                           /* Saved Operating Mode Reg.    */
50165 @@ -833,7 +837,7 @@
50166         struct sk_buff *skb;                /* Save the (re-ordered) skb's  */
50167      } cache;
50168      struct de4x5_srom srom;                 /* A copy of the SROM           */
50169 -    struct net_device *next_module;             /* Link to the next module      */
50170 +    int cfrv;                              /* Card CFRV copy */
50171      int rx_ovf;                             /* Check for 'RX overflow' tag  */
50172      int useSROM;                            /* For non-DEC card use SROM    */
50173      int useMII;                             /* Infoblock using the MII      */
50174 @@ -850,29 +854,13 @@
50175      u_char *rst;                            /* Pointer to Type 5 reset info */
50176      u_char  ibn;                            /* Infoblock number             */
50177      struct parameters params;               /* Command line/ #defined params */
50178 -    struct pci_dev *pdev;                  /* Device cookie for DMA alloc  */
50179 +    struct device *gendev;                 /* Generic device */
50180      dma_addr_t dma_rings;                  /* DMA handle for rings         */
50181      int dma_size;                          /* Size of the DMA area         */
50182      char *rx_bufs;                         /* rx bufs on alpha, sparc, ... */
50183  };
50184  
50185  /*
50186 -** Kludge to get around the fact that the CSR addresses have different
50187 -** offsets in the PCI and EISA boards. Also note that the ethernet address
50188 -** PROM is accessed differently.
50189 -*/
50190 -static struct de4x5_bus_type {
50191 -    int bus;
50192 -    int bus_num;
50193 -    int device;
50194 -    int chipset;
50195 -    struct de4x5_srom srom;
50196 -    int autosense;
50197 -    int useSROM;
50198 -    struct pci_dev *pdev;
50199 -} bus;
50200 -
50201 -/*
50202  ** To get around certain poxy cards that don't provide an SROM
50203  ** for the second and more DECchip, I have to key off the first
50204  ** chip's address. I'll assume there's not a bad SROM iff:
50205 @@ -919,7 +907,7 @@
50206  /*
50207  ** Private functions
50208  */
50209 -static int     de4x5_hw_init(struct net_device *dev, u_long iobase, struct pci_dev *pdev);
50210 +static int     de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev);
50211  static int     de4x5_init(struct net_device *dev);
50212  static int     de4x5_sw_reset(struct net_device *dev);
50213  static int     de4x5_rx(struct net_device *dev);
50214 @@ -962,11 +950,11 @@
50215  static void    reset_init_sia(struct net_device *dev, s32 sicr, s32 strr, s32 sigr);
50216  static int     test_ans(struct net_device *dev, s32 irqs, s32 irq_mask, s32 msec);
50217  static int     test_tp(struct net_device *dev, s32 msec);
50218 -static int     EISA_signature(char *name, s32 eisa_id);
50219 -static int     PCI_signature(char *name, struct de4x5_bus_type *lp);
50220 -static void    DevicePresent(u_long iobase);
50221 +static int     EISA_signature(char *name, struct device *device);
50222 +static int     PCI_signature(char *name, struct de4x5_private *lp);
50223 +static void    DevicePresent(struct net_device *dev, u_long iobase);
50224  static void    enet_addr_rst(u_long aprom_addr);
50225 -static int     de4x5_bad_srom(struct de4x5_bus_type *lp);
50226 +static int     de4x5_bad_srom(struct de4x5_private *lp);
50227  static short   srom_rd(u_long address, u_char offset);
50228  static void    srom_latch(u_int command, u_long address);
50229  static void    srom_command(u_int command, u_long address);
50230 @@ -994,12 +982,7 @@
50231  static int     get_hw_addr(struct net_device *dev);
50232  static void    srom_repair(struct net_device *dev, int card);
50233  static int     test_bad_enet(struct net_device *dev, int status);
50234 -static int     an_exception(struct de4x5_bus_type *lp);
50235 -#if !defined(__sparc_v9__) && !defined(__powerpc__) && !defined(__alpha__)
50236 -static void    eisa_probe(struct net_device *dev, u_long iobase);
50237 -#endif
50238 -static void    pci_probe(struct net_device *dev, u_long iobase);
50239 -static void    srom_search(struct pci_dev *pdev);
50240 +static int     an_exception(struct de4x5_private *lp);
50241  static char    *build_setup_frame(struct net_device *dev, int mode);
50242  static void    disable_ast(struct net_device *dev);
50243  static void    enable_ast(struct net_device *dev, u32 time_out);
50244 @@ -1008,7 +991,6 @@
50245  static void    gep_wr(s32 data, struct net_device *dev);
50246  static void    timeout(struct net_device *dev, void (*fn)(u_long data), u_long data, u_long msec);
50247  static void    yawn(struct net_device *dev, int state);
50248 -static void    link_modules(struct net_device *dev, struct net_device *tmp);
50249  static void    de4x5_parse_params(struct net_device *dev);
50250  static void    de4x5_dbg_open(struct net_device *dev);
50251  static void    de4x5_dbg_mii(struct net_device *dev, int k);
50252 @@ -1028,40 +1010,25 @@
50253  static int     type5_infoblock(struct net_device *dev, u_char count, u_char *p);
50254  static int     compact_infoblock(struct net_device *dev, u_char count, u_char *p);
50255  
50256 -#ifdef MODULE
50257 -static struct net_device *unlink_modules(struct net_device *p);
50258 -static struct net_device *insert_device(struct net_device *dev, u_long iobase,
50259 -                                    int (*init)(struct net_device *));
50260 -static int count_adapters(void);
50261 -static int loading_module = 1;
50262 -MODULE_PARM(de4x5_debug, "i");
50263 -MODULE_PARM(dec_only, "i");
50264 -MODULE_PARM(args, "s");
50265 +/*
50266 +** Note now that module autoprobing is allowed under EISA and PCI. The
50267 +** IRQ lines will not be auto-detected; instead I'll rely on the BIOSes
50268 +** to "do the right thing".
50269 +*/
50270 +
50271 +static int io=0x0;/* EDIT THIS LINE FOR YOUR CONFIGURATION IF NEEDED        */
50272 +
50273 +module_param(io, int, 0);
50274 +module_param(de4x5_debug, int, 0);
50275 +module_param(dec_only, int, 0);
50276 +module_param(args, charp, 0);
50277 +
50278 +MODULE_PARM_DESC(io, "de4x5 I/O base address");
50279  MODULE_PARM_DESC(de4x5_debug, "de4x5 debug mask");
50280  MODULE_PARM_DESC(dec_only, "de4x5 probe only for Digital boards (0-1)");
50281  MODULE_PARM_DESC(args, "de4x5 full duplex and media type settings; see de4x5.c for details");
50282  MODULE_LICENSE("GPL");
50283  
50284 -# else
50285 -static int loading_module;
50286 -#endif /* MODULE */
50287 -
50288 -static char name[DE4X5_NAME_LENGTH + 1];
50289 -#if !defined(__sparc_v9__) && !defined(__powerpc__) && !defined(__alpha__)
50290 -static u_char de4x5_irq[] = EISA_ALLOWED_IRQ_LIST;
50291 -static int lastEISA;
50292 -#  ifdef DE4X5_FORCE_EISA                 /* Force an EISA bus probe or not */
50293 -static int forceEISA = 1;
50294 -#  else
50295 -static int forceEISA;
50296 -#  endif
50297 -#endif
50298 -static int num_de4x5s;
50299 -static int cfrv, useSROM;
50300 -static int lastPCI = -1;
50301 -static struct net_device *lastModule;
50302 -static struct pci_dev *pdev;
50303 -
50304  /*
50305  ** List the SROM infoleaf functions and chipsets
50306  */
50307 @@ -1115,37 +1082,22 @@
50308  }
50309  
50310  \f
50311 -/*
50312 -** Autoprobing in modules is allowed here. See the top of the file for
50313 -** more info.
50314 -*/
50315 -int __init 
50316 -de4x5_probe(struct net_device *dev)
50317 -{
50318 -    u_long iobase = dev->base_addr;
50319 -
50320 -    pci_probe(dev, iobase);
50321 -#if !defined(__sparc_v9__) && !defined(__powerpc__) && !defined(__alpha__)
50322 -    if ((lastPCI == NO_MORE_PCI) && ((num_de4x5s == 0) || forceEISA)) {
50323 -        eisa_probe(dev, iobase);
50324 -    }
50325 -#endif
50326 -    
50327 -    return (dev->priv ? 0 : -ENODEV);
50328 -}
50329 -
50330  static int __init 
50331 -de4x5_hw_init(struct net_device *dev, u_long iobase, struct pci_dev *pdev)
50332 +de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
50333  {
50334 -    struct de4x5_bus_type *lp = &bus;
50335 +    char name[DE4X5_NAME_LENGTH + 1];
50336 +    struct de4x5_private *lp = dev->priv;
50337 +    struct pci_dev *pdev = NULL;
50338      int i, status=0;
50339 -    char *tmp;
50340 -    
50341 +
50342 +    gendev->driver_data = dev;
50343 +
50344      /* Ensure we're not sleeping */
50345      if (lp->bus == EISA) {
50346         outb(WAKEUP, PCI_CFPM);
50347      } else {
50348 -       pci_write_config_byte(lp->pdev, PCI_CFDA_PSM, WAKEUP);
50349 +       pdev = to_pci_dev (gendev);
50350 +       pci_write_config_byte(pdev, PCI_CFDA_PSM, WAKEUP);
50351      }
50352      mdelay(10);
50353  
50354 @@ -1158,11 +1110,11 @@
50355      /* 
50356      ** Now find out what kind of DC21040/DC21041/DC21140 board we have.
50357      */
50358 -    useSROM = FALSE;
50359 +    lp->useSROM = FALSE;
50360      if (lp->bus == PCI) {
50361         PCI_signature(name, lp);
50362      } else {
50363 -       EISA_signature(name, EISA_ID0);
50364 +       EISA_signature(name, gendev);
50365      }
50366      
50367      if (*name == '\0') {                     /* Not found a board signature */
50368 @@ -1170,13 +1122,7 @@
50369      }
50370      
50371      dev->base_addr = iobase;
50372 -    if (lp->bus == EISA) {
50373 -       printk("%s: %s at 0x%04lx (EISA slot %ld)", 
50374 -              dev->name, name, iobase, ((iobase>>12)&0x0f));
50375 -    } else {                                 /* PCI port address */
50376 -       printk("%s: %s at 0x%04lx (PCI bus %d, device %d)", dev->name, name,
50377 -              iobase, lp->bus_num, lp->device);
50378 -    }
50379 +    printk ("%s: %s at 0x%04lx", gendev->bus_id, name, iobase);
50380      
50381      printk(", h/w address ");
50382      status = get_hw_addr(dev);
50383 @@ -1189,38 +1135,12 @@
50384         printk("      which has an Ethernet PROM CRC error.\n");
50385         return -ENXIO;
50386      } else {
50387 -       struct de4x5_private *lp;
50388 -       
50389 -       /* 
50390 -       ** Reserve a section of kernel memory for the adapter
50391 -       ** private area and the TX/RX descriptor rings.
50392 -       */
50393 -       dev->priv = (void *) kmalloc(sizeof(struct de4x5_private) + DE4X5_ALIGN, 
50394 -                                    GFP_KERNEL);
50395 -       if (dev->priv == NULL) {
50396 -           return -ENOMEM;
50397 -       }
50398 -       
50399 -       /*
50400 -       ** Align to a longword boundary
50401 -       */
50402 -       tmp = dev->priv;
50403 -       dev->priv = (void *)(((u_long)dev->priv + DE4X5_ALIGN) & ~DE4X5_ALIGN);
50404 -       lp = (struct de4x5_private *)dev->priv;
50405 -       memset(dev->priv, 0, sizeof(struct de4x5_private));
50406 -       lp->bus = bus.bus;
50407 -       lp->bus_num = bus.bus_num;
50408 -       lp->device = bus.device;
50409 -       lp->chipset = bus.chipset;
50410 -       lp->cache.priv = tmp;
50411         lp->cache.gepc = GEP_INIT;
50412         lp->asBit = GEP_SLNK;
50413         lp->asPolarity = GEP_SLNK;
50414         lp->asBitValid = TRUE;
50415         lp->timeout = -1;
50416 -       lp->useSROM = useSROM;
50417 -       lp->pdev = pdev;
50418 -       memcpy((char *)&lp->srom,(char *)&bus.srom,sizeof(struct de4x5_srom));
50419 +       lp->gendev = gendev;
50420         lp->lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
50421         init_timer(&lp->timer);
50422         de4x5_parse_params(dev);
50423 @@ -1238,16 +1158,15 @@
50424              }
50425          }
50426         lp->fdx = lp->params.fdx;
50427 -       sprintf(lp->adapter_name,"%s (%s)", name, dev->name);
50428 +       sprintf(lp->adapter_name,"%s (%s)", name, gendev->bus_id);
50429  
50430         lp->dma_size = (NUM_RX_DESC + NUM_TX_DESC) * sizeof(struct de4x5_desc);
50431  #if defined(__alpha__) || defined(__powerpc__) || defined(__sparc_v9__) || defined(DE4X5_DO_MEMCPY)
50432         lp->dma_size += RX_BUFF_SZ * NUM_RX_DESC + DE4X5_ALIGN;
50433  #endif
50434 -       lp->rx_ring = pci_alloc_consistent(pdev, lp->dma_size, &lp->dma_rings);
50435 +       lp->rx_ring = dma_alloc_coherent(gendev, lp->dma_size,
50436 +                                        &lp->dma_rings, GFP_ATOMIC);
50437         if (lp->rx_ring == NULL) {
50438 -           kfree(lp->cache.priv);
50439 -           lp->cache.priv = NULL;
50440             return -ENOMEM;
50441         }
50442  
50443 @@ -1288,11 +1207,7 @@
50444  #endif
50445  
50446         barrier();
50447 -           
50448 -       request_region(iobase, (lp->bus == PCI ? DE4X5_PCI_TOTAL_SIZE :
50449 -                               DE4X5_EISA_TOTAL_SIZE), 
50450 -                      lp->adapter_name);
50451 -           
50452 +
50453         lp->rxRingSize = NUM_RX_DESC;
50454         lp->txRingSize = NUM_TX_DESC;
50455             
50456 @@ -1313,7 +1228,7 @@
50457         create_packet(dev, lp->frame, sizeof(lp->frame));
50458  
50459         /* Check if the RX overflow bug needs testing for */
50460 -       i = cfrv & 0x000000fe;
50461 +       i = lp->cfrv & 0x000000fe;
50462         if ((lp->chipset == DC21140) && (i == 0x20)) {
50463             lp->rx_ovf = 1;
50464         }
50465 @@ -1350,7 +1265,7 @@
50466      
50467      /* The DE4X5-specific entries in the device structure. */
50468      SET_MODULE_OWNER(dev);
50469 -    SET_NETDEV_DEV(dev, &pdev->dev);
50470 +    SET_NETDEV_DEV(dev, gendev);
50471      dev->open = &de4x5_open;
50472      dev->hard_start_xmit = &de4x5_queue_pkt;
50473      dev->stop = &de4x5_close;
50474 @@ -1361,7 +1276,11 @@
50475      dev->mem_start = 0;
50476      
50477      /* Fill in the generic fields of the device structure. */
50478 -    ether_setup(dev);
50479 +    if ((status = register_netdev (dev))) {
50480 +           dma_free_coherent (gendev, lp->dma_size,
50481 +                              lp->rx_ring, lp->dma_rings);
50482 +           return status;
50483 +    }
50484      
50485      /* Let the adapter sleep to save power */
50486      yawn(dev, SLEEP);
50487 @@ -1766,9 +1685,9 @@
50488  static inline void
50489  de4x5_free_tx_buff(struct de4x5_private *lp, int entry)
50490  {
50491 -    pci_unmap_single(lp->pdev, le32_to_cpu(lp->tx_ring[entry].buf),
50492 +    dma_unmap_single(lp->gendev, le32_to_cpu(lp->tx_ring[entry].buf),
50493                      le32_to_cpu(lp->tx_ring[entry].des1) & TD_TBS1,
50494 -                    PCI_DMA_TODEVICE);
50495 +                    DMA_TO_DEVICE);
50496      if ((u_long) lp->tx_skb[entry] > 1)
50497         dev_kfree_skb_irq(lp->tx_skb[entry]);
50498      lp->tx_skb[entry] = NULL;
50499 @@ -1987,7 +1906,7 @@
50500  {
50501      struct de4x5_private *lp = (struct de4x5_private *)dev->priv;
50502      int entry = (lp->tx_new ? lp->tx_new-1 : lp->txRingSize-1);
50503 -    dma_addr_t buf_dma = pci_map_single(lp->pdev, buf, flags & TD_TBS1, PCI_DMA_TODEVICE);
50504 +    dma_addr_t buf_dma = dma_map_single(lp->gendev, buf, flags & TD_TBS1, DMA_TO_DEVICE);
50505  
50506      lp->tx_ring[lp->tx_new].buf = cpu_to_le32(buf_dma);
50507      lp->tx_ring[lp->tx_new].des1 &= cpu_to_le32(TD_TER);
50508 @@ -2084,194 +2003,128 @@
50509      return;
50510  }
50511  
50512 -#if !defined(__sparc_v9__) && !defined(__powerpc__) && !defined(__alpha__)
50513 -/*
50514 -** EISA bus I/O device probe. Probe from slot 1 since slot 0 is usually
50515 -** the motherboard. Upto 15 EISA devices are supported.
50516 -*/
50517 -static void __init 
50518 -eisa_probe(struct net_device *dev, u_long ioaddr)
50519 +#ifdef CONFIG_EISA
50520 +
50521 +static u_char de4x5_irq[] = EISA_ALLOWED_IRQ_LIST;
50522 +
50523 +static int __init de4x5_eisa_probe (struct device *gendev)
50524  {
50525 -    int i, maxSlots, status, device;
50526 -    u_char irq;
50527 -    u_short vendor;
50528 -    u32 cfid;
50529 -    u_long iobase;
50530 -    struct de4x5_bus_type *lp = &bus;
50531 -    char name[DE4X5_STRLEN];
50532 +       struct eisa_device *edev;
50533 +       u_long iobase;
50534 +       u_char irq, regval;
50535 +       u_short vendor;
50536 +       u32 cfid;
50537 +       int status, device;
50538 +       struct net_device *dev;
50539 +       struct de4x5_private *lp;
50540  
50541 -    if (lastEISA == MAX_EISA_SLOTS) return;/* No more EISA devices to search */
50542 +       edev = to_eisa_device (gendev);
50543 +       iobase = edev->base_addr;
50544  
50545 -    lp->bus = EISA;
50546 -    
50547 -    if (ioaddr == 0) {                     /* Autoprobing */
50548 -       iobase = EISA_SLOT_INC;            /* Get the first slot address */
50549 -       i = 1;
50550 -       maxSlots = MAX_EISA_SLOTS;
50551 -    } else {                               /* Probe a specific location */
50552 -       iobase = ioaddr;
50553 -       i = (ioaddr >> 12);
50554 -       maxSlots = i + 1;
50555 -    }
50556 -    
50557 -    for (status = -ENODEV; (i<maxSlots) && (dev!=NULL); i++, iobase+=EISA_SLOT_INC) {
50558 -       if (check_region(iobase, DE4X5_EISA_TOTAL_SIZE)) continue;
50559 -       if (!EISA_signature(name, EISA_ID)) continue;
50560 +       if (!request_region (iobase, DE4X5_EISA_TOTAL_SIZE, "de4x5"))
50561 +               return -EBUSY;
50562  
50563 +       if (!request_region (iobase + DE4X5_EISA_IO_PORTS,
50564 +                            DE4X5_EISA_TOTAL_SIZE, "de4x5")) {
50565 +               status = -EBUSY;
50566 +               goto release_reg_1;
50567 +       }
50568 +       
50569 +       if (!(dev = alloc_etherdev (sizeof (struct de4x5_private)))) {
50570 +               status = -ENOMEM;
50571 +               goto release_reg_2;
50572 +       }
50573 +       lp = dev->priv;
50574 +       
50575         cfid = (u32) inl(PCI_CFID);
50576 -       cfrv = (u_short) inl(PCI_CFRV);
50577 +       lp->cfrv = (u_short) inl(PCI_CFRV);
50578         device = (cfid >> 8) & 0x00ffff00;
50579         vendor = (u_short) cfid;
50580             
50581         /* Read the EISA Configuration Registers */
50582 -       irq = inb(EISA_REG0);
50583 -       irq = de4x5_irq[(irq >> 1) & 0x03];
50584 +       regval = inb(EISA_REG0) & (ER0_INTL | ER0_INTT);
50585 +#ifdef CONFIG_ALPHA
50586 +       /* Looks like the Jensen firmware (rev 2.2) doesn't really
50587 +        * care about the EISA configuration, and thus doesn't
50588 +        * configure the PLX bridge properly. Oh well... Simply mimic
50589 +        * the EISA config file to sort it out. */
50590 +       
50591 +       /* EISA REG1: Assert DecChip 21040 HW Reset */
50592 +       outb (ER1_IAM | 1, EISA_REG1);
50593 +       mdelay (1);
50594 +
50595 +        /* EISA REG1: Deassert DecChip 21040 HW Reset */
50596 +       outb (ER1_IAM, EISA_REG1);
50597 +       mdelay (1);
50598  
50599 +       /* EISA REG3: R/W Burst Transfer Enable */
50600 +       outb (ER3_BWE | ER3_BRE, EISA_REG3);
50601 +       
50602 +       /* 32_bit slave/master, Preempt Time=23 bclks, Unlatched Interrupt */
50603 +       outb (ER0_BSW | ER0_BMW | ER0_EPT | regval, EISA_REG0);
50604 +#endif
50605 +       irq = de4x5_irq[(regval >> 1) & 0x03];
50606 +       
50607         if (is_DC2114x) {
50608 -           device = ((cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143);
50609 +           device = ((lp->cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143);
50610         }
50611         lp->chipset = device;
50612 +       lp->bus = EISA;
50613  
50614         /* Write the PCI Configuration Registers */
50615         outl(PCI_COMMAND_IO | PCI_COMMAND_MASTER, PCI_CFCS);
50616         outl(0x00006000, PCI_CFLT);
50617         outl(iobase, PCI_CBIO);
50618             
50619 -       DevicePresent(EISA_APROM);
50620 +       DevicePresent(dev, EISA_APROM);
50621  
50622         dev->irq = irq;
50623 -       if ((status = de4x5_hw_init(dev, iobase, NULL)) == 0) {
50624 -           num_de4x5s++;
50625 -           if (loading_module) link_modules(lastModule, dev);
50626 -           lastEISA = i;
50627 -           return;
50628 +
50629 +       if (!(status = de4x5_hw_init (dev, iobase, gendev))) {
50630 +               return 0;
50631         }
50632 -    }
50633  
50634 -    if (ioaddr == 0) lastEISA = i;
50635 +       free_netdev (dev);
50636 + release_reg_2:
50637 +       release_region (iobase + DE4X5_EISA_IO_PORTS, DE4X5_EISA_TOTAL_SIZE);
50638 + release_reg_1:
50639 +       release_region (iobase, DE4X5_EISA_TOTAL_SIZE);
50640  
50641 -    return;
50642 +       return status;
50643  }
50644 -#endif          /* !(__sparc_v9__) && !(__powerpc__) && !defined(__alpha__) */
50645  
50646 -/*
50647 -** PCI bus I/O device probe
50648 -** NB: PCI I/O accesses and Bus Mastering are enabled by the PCI BIOS, not
50649 -** the driver. Some PCI BIOS's, pre V2.1, need the slot + features to be
50650 -** enabled by the user first in the set up utility. Hence we just check for
50651 -** enabled features and silently ignore the card if they're not.
50652 -**
50653 -** STOP PRESS: Some BIOS's __require__ the driver to enable the bus mastering
50654 -** bit. Here, check for I/O accesses and then set BM. If you put the card in
50655 -** a non BM slot, you're on your own (and complain to the PC vendor that your
50656 -** PC doesn't conform to the PCI standard)!
50657 -**
50658 -** This function is only compatible with the *latest* 2.1.x kernels. For 2.0.x
50659 -** kernels use the V0.535[n] drivers.
50660 -*/
50661 -#define PCI_LAST_DEV  32
50662 -
50663 -static void __init 
50664 -pci_probe(struct net_device *dev, u_long ioaddr)
50665 +static int __devexit de4x5_eisa_remove (struct device *device)
50666  {
50667 -    u_char pb, pbus, dev_num, dnum, timer;
50668 -    u_short vendor, index, status;
50669 -    u_int irq = 0, device, class = DE4X5_CLASS_CODE;
50670 -    u_long iobase = 0;                     /* Clear upper 32 bits in Alphas */
50671 -    struct de4x5_bus_type *lp = &bus;
50672 -
50673 -    if (lastPCI == NO_MORE_PCI) return;
50674 -
50675 -    lp->bus = PCI;
50676 -    lp->bus_num = 0;
50677 -
50678 -    if ((ioaddr < 0x1000) && loading_module) {
50679 -       pbus = (u_short)(ioaddr >> 8);
50680 -       dnum = (u_short)(ioaddr & 0xff);
50681 -    } else {
50682 -       pbus = 0;
50683 -       dnum = 0;
50684 -    }
50685 -
50686 -    for (index=lastPCI+1;(pdev = pci_find_class(class, pdev))!=NULL;index++) {
50687 -       dev_num = PCI_SLOT(pdev->devfn);
50688 -       pb = pdev->bus->number;
50689 -       if ((pbus || dnum) && ((pbus != pb) || (dnum != dev_num))) continue;
50690 -
50691 -       vendor = pdev->vendor;
50692 -       device = pdev->device << 8;
50693 -       if (!(is_DC21040 || is_DC21041 || is_DC21140 || is_DC2114x)) continue;
50694 -
50695 -       /* Search for an SROM on this bus */
50696 -       if (lp->bus_num != pb) {
50697 -           lp->bus_num = pb;
50698 -           srom_search(pdev);
50699 -       }
50700 -
50701 -       /* Get the chip configuration revision register */
50702 -       pci_read_config_dword(pdev, PCI_REVISION_ID, &cfrv);
50703 -
50704 -       /* Set the device number information */
50705 -       lp->device = dev_num;
50706 -       lp->bus_num = pb;
50707 -       lp->pdev = pdev;
50708 -           
50709 -       /* Set the chipset information */
50710 -       if (is_DC2114x) {
50711 -           device = ((cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143);
50712 -       }
50713 -       lp->chipset = device;
50714 +       struct net_device *dev;
50715 +       u_long iobase;
50716  
50717 -       /* Get the board I/O address (64 bits on sparc64) */
50718 -       iobase = pci_resource_start(pdev, 0);
50719 -
50720 -       /* Fetch the IRQ to be used */
50721 -       irq = pdev->irq;
50722 -       if ((irq == 0) || (irq == 0xff) || ((int)irq == -1)) continue;
50723 -           
50724 -       /* Check if I/O accesses and Bus Mastering are enabled */
50725 -       pci_read_config_word(pdev, PCI_COMMAND, &status);
50726 -#ifdef __powerpc__
50727 -       if (!(status & PCI_COMMAND_IO)) {
50728 -           status |= PCI_COMMAND_IO;
50729 -           pci_write_config_word(pdev, PCI_COMMAND, status);
50730 -           pci_read_config_word(pdev, PCI_COMMAND, &status);
50731 -       }
50732 -#endif /* __powerpc__ */
50733 -       if (!(status & PCI_COMMAND_IO)) continue;
50734 -
50735 -       if (!(status & PCI_COMMAND_MASTER)) {
50736 -           status |= PCI_COMMAND_MASTER;
50737 -           pci_write_config_word(pdev, PCI_COMMAND, status);
50738 -           pci_read_config_word(pdev, PCI_COMMAND, &status);
50739 -       }
50740 -       if (!(status & PCI_COMMAND_MASTER)) continue;
50741 +       dev = device->driver_data;
50742 +       iobase = dev->base_addr;
50743 +       
50744 +       unregister_netdev (dev);
50745 +       free_netdev (dev);
50746 +       release_region (iobase + DE4X5_EISA_IO_PORTS, DE4X5_EISA_TOTAL_SIZE);
50747 +       release_region (iobase, DE4X5_EISA_TOTAL_SIZE);
50748  
50749 -       /* Check the latency timer for values >= 0x60 */
50750 -       pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &timer);
50751 -       if (timer < 0x60) {
50752 -           pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x60);
50753 -       }
50754 +       return 0;
50755 +}
50756  
50757 -       DevicePresent(DE4X5_APROM);
50758 -       if (check_region(iobase, DE4X5_PCI_TOTAL_SIZE) == 0) {
50759 -           dev->irq = irq;
50760 -           if ((status = de4x5_hw_init(dev, iobase, pdev)) == 0) {
50761 -               num_de4x5s++;
50762 -               lastPCI = index;
50763 -               if (loading_module) link_modules(lastModule, dev);
50764 -               return;
50765 -           }
50766 -       } else if (ioaddr != 0) {
50767 -           printk("%s: region already allocated at 0x%04lx.\n", dev->name,
50768 -                  iobase);
50769 -       }
50770 -    }
50771 +static struct eisa_device_id de4x5_eisa_ids[] = {
50772 +        { "DEC4250", 0 },      /* 0 is the board name index... */
50773 +        { "" }
50774 +};
50775  
50776 -    lastPCI = NO_MORE_PCI;
50777 +static struct eisa_driver de4x5_eisa_driver = {
50778 +        .id_table = de4x5_eisa_ids,
50779 +        .driver   = {
50780 +                .name    = "de4x5",
50781 +                .probe   = de4x5_eisa_probe,
50782 +                .remove  = __devexit_p (de4x5_eisa_remove),
50783 +        }
50784 +};
50785 +#endif
50786  
50787 -    return;
50788 -}
50789 +#ifdef CONFIG_PCI
50790  
50791  /*
50792  ** This function searches the current bus (which is >0) for a DECchip with an
50793 @@ -2280,21 +2133,21 @@
50794  ** For single port cards this is a time waster...
50795  */
50796  static void __init 
50797 -srom_search(struct pci_dev *dev)
50798 +srom_search(struct net_device *dev, struct pci_dev *pdev)
50799  {
50800      u_char pb;
50801      u_short vendor, status;
50802      u_int irq = 0, device;
50803      u_long iobase = 0;                     /* Clear upper 32 bits in Alphas */
50804 -    int i, j;
50805 -    struct de4x5_bus_type *lp = &bus;
50806 -    struct list_head *walk = &dev->bus_list;
50807 +    int i, j, cfrv;
50808 +    struct de4x5_private *lp = dev->priv;
50809 +    struct list_head *walk = &pdev->bus_list;
50810  
50811 -    for (walk = walk->next; walk != &dev->bus_list; walk = walk->next) {
50812 +    for (walk = walk->next; walk != &pdev->bus_list; walk = walk->next) {
50813         struct pci_dev *this_dev = pci_dev_b(walk);
50814  
50815         /* Skip the pci_bus list entry */
50816 -       if (list_entry(walk, struct pci_bus, devices) == dev->bus) continue;
50817 +       if (list_entry(walk, struct pci_bus, devices) == pdev->bus) continue;
50818  
50819         vendor = this_dev->vendor;
50820         device = this_dev->device << 8;
50821 @@ -2326,7 +2179,7 @@
50822         if (!(status & PCI_COMMAND_IO)) continue;
50823  
50824         /* Search for a valid SROM attached to this DECchip */
50825 -       DevicePresent(DE4X5_APROM);
50826 +       DevicePresent(dev, DE4X5_APROM);
50827         for (j=0, i=0; i<ETH_ALEN; i++) {
50828             j += (u_char) *((u_char *)&lp->srom + SROM_HWADD + i);
50829         }
50830 @@ -2344,25 +2197,170 @@
50831      return;
50832  }
50833  
50834 -static void __init 
50835 -link_modules(struct net_device *dev, struct net_device *tmp)
50836 +/*
50837 +** PCI bus I/O device probe
50838 +** NB: PCI I/O accesses and Bus Mastering are enabled by the PCI BIOS, not
50839 +** the driver. Some PCI BIOS's, pre V2.1, need the slot + features to be
50840 +** enabled by the user first in the set up utility. Hence we just check for
50841 +** enabled features and silently ignore the card if they're not.
50842 +**
50843 +** STOP PRESS: Some BIOS's __require__ the driver to enable the bus mastering
50844 +** bit. Here, check for I/O accesses and then set BM. If you put the card in
50845 +** a non BM slot, you're on your own (and complain to the PC vendor that your
50846 +** PC doesn't conform to the PCI standard)!
50847 +**
50848 +** This function is only compatible with the *latest* 2.1.x kernels. For 2.0.x
50849 +** kernels use the V0.535[n] drivers.
50850 +*/
50851 +
50852 +static int __init de4x5_pci_probe (struct pci_dev *pdev,
50853 +                                  const struct pci_device_id *ent)
50854  {
50855 -    struct net_device *p=dev;
50856 +       u_char pb, pbus = 0, dev_num, dnum = 0, timer;
50857 +       u_short vendor, status;
50858 +       u_int irq = 0, device;
50859 +       u_long iobase = 0;      /* Clear upper 32 bits in Alphas */
50860 +       int error;
50861 +       struct net_device *dev;
50862 +       struct de4x5_private *lp;
50863  
50864 -    if (p) {
50865 -       while (((struct de4x5_private *)(p->priv))->next_module) {
50866 -           p = ((struct de4x5_private *)(p->priv))->next_module;
50867 +       dev_num = PCI_SLOT(pdev->devfn);
50868 +       pb = pdev->bus->number;
50869 +
50870 +       if (io) { /* probe a single PCI device */
50871 +               pbus = (u_short)(io >> 8);
50872 +               dnum = (u_short)(io & 0xff);
50873 +               if ((pbus != pb) || (dnum != dev_num))
50874 +                       return -ENODEV;
50875         }
50876  
50877 -       if (dev != tmp) {
50878 -           ((struct de4x5_private *)(p->priv))->next_module = tmp;
50879 -       } else {
50880 -           ((struct de4x5_private *)(p->priv))->next_module = NULL;
50881 +       vendor = pdev->vendor;
50882 +       device = pdev->device << 8;
50883 +       if (!(is_DC21040 || is_DC21041 || is_DC21140 || is_DC2114x))
50884 +               return -ENODEV;
50885 +
50886 +       /* Ok, the device seems to be for us. */
50887 +       if (!(dev = alloc_etherdev (sizeof (struct de4x5_private))))
50888 +               return -ENOMEM;
50889 +
50890 +       lp = dev->priv;
50891 +       lp->bus = PCI;
50892 +       lp->bus_num = 0;
50893 +       
50894 +       /* Search for an SROM on this bus */
50895 +       if (lp->bus_num != pb) {
50896 +           lp->bus_num = pb;
50897 +           srom_search(dev, pdev);
50898         }
50899 -    }
50900  
50901 -    return;
50902 -}
50903 +       /* Get the chip configuration revision register */
50904 +       pci_read_config_dword(pdev, PCI_REVISION_ID, &lp->cfrv);
50905 +
50906 +       /* Set the device number information */
50907 +       lp->device = dev_num;
50908 +       lp->bus_num = pb;
50909 +       
50910 +       /* Set the chipset information */
50911 +       if (is_DC2114x) {
50912 +           device = ((lp->cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143);
50913 +       }
50914 +       lp->chipset = device;
50915 +
50916 +       /* Get the board I/O address (64 bits on sparc64) */
50917 +       iobase = pci_resource_start(pdev, 0);
50918 +
50919 +       /* Fetch the IRQ to be used */
50920 +       irq = pdev->irq;
50921 +       if ((irq == 0) || (irq == 0xff) || ((int)irq == -1)) {
50922 +               error = -ENODEV;
50923 +               goto free_dev;
50924 +       }
50925 +           
50926 +       /* Check if I/O accesses and Bus Mastering are enabled */
50927 +       pci_read_config_word(pdev, PCI_COMMAND, &status);
50928 +#ifdef __powerpc__
50929 +       if (!(status & PCI_COMMAND_IO)) {
50930 +           status |= PCI_COMMAND_IO;
50931 +           pci_write_config_word(pdev, PCI_COMMAND, status);
50932 +           pci_read_config_word(pdev, PCI_COMMAND, &status);
50933 +       }
50934 +#endif /* __powerpc__ */
50935 +       if (!(status & PCI_COMMAND_IO)) {
50936 +               error = -ENODEV;
50937 +               goto free_dev;
50938 +       }
50939 +
50940 +       if (!(status & PCI_COMMAND_MASTER)) {
50941 +           status |= PCI_COMMAND_MASTER;
50942 +           pci_write_config_word(pdev, PCI_COMMAND, status);
50943 +           pci_read_config_word(pdev, PCI_COMMAND, &status);
50944 +       }
50945 +       if (!(status & PCI_COMMAND_MASTER)) {
50946 +               error = -ENODEV;
50947 +               goto free_dev;
50948 +       }
50949 +
50950 +       /* Check the latency timer for values >= 0x60 */
50951 +       pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &timer);
50952 +       if (timer < 0x60) {
50953 +           pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x60);
50954 +       }
50955 +
50956 +       DevicePresent(dev, DE4X5_APROM);
50957 +
50958 +       if (!request_region (iobase, DE4X5_PCI_TOTAL_SIZE, "de4x5")) {
50959 +               error = -EBUSY;
50960 +               goto free_dev;
50961 +       }
50962 +
50963 +       dev->irq = irq;
50964 +       
50965 +       if ((error = de4x5_hw_init(dev, iobase, &pdev->dev))) {
50966 +               goto release;
50967 +       }
50968 +
50969 +       return 0;
50970 +
50971 + release:
50972 +       release_region (iobase, DE4X5_PCI_TOTAL_SIZE);
50973 + free_dev:
50974 +       free_netdev (dev);
50975 +       return error;
50976 +}
50977 +
50978 +static void __devexit de4x5_pci_remove (struct pci_dev *pdev)
50979 +{
50980 +       struct net_device *dev;
50981 +       u_long iobase;
50982 +
50983 +       dev = pdev->dev.driver_data;
50984 +       iobase = dev->base_addr;
50985 +
50986 +       unregister_netdev (dev);
50987 +       free_netdev (dev);
50988 +       release_region (iobase, DE4X5_PCI_TOTAL_SIZE);
50989 +}
50990 +
50991 +static struct pci_device_id de4x5_pci_tbl[] = {
50992 +        { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP,
50993 +          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
50994 +        { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS,
50995 +          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
50996 +        { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
50997 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
50998 +        { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
50999 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 },
51000 +        { },
51001 +};
51002 +
51003 +static struct pci_driver de4x5_pci_driver = {
51004 +        .name           = "de4x5",
51005 +        .id_table       = de4x5_pci_tbl,
51006 +        .probe          = de4x5_pci_probe,
51007 +       .remove         = __devexit_p (de4x5_pci_remove),
51008 +};
51009 +
51010 +#endif
51011  
51012  /*
51013  ** Auto configure the media here rather than setting the port at compile
51014 @@ -3945,34 +3943,20 @@
51015  ** Look for a particular board name in the EISA configuration space
51016  */
51017  static int
51018 -EISA_signature(char *name, s32 eisa_id)
51019 +EISA_signature(char *name, struct device *device)
51020  {
51021 -    static c_char *signatures[] = DE4X5_SIGNATURE;
51022 -    char ManCode[DE4X5_STRLEN];
51023 -    union {
51024 -       s32 ID;
51025 -       char Id[4];
51026 -    } Eisa;
51027 -    int i, status = 0, siglen = sizeof(signatures)/sizeof(c_char *);
51028 -    
51029 +    int i, status = 0, siglen = sizeof(de4x5_signatures)/sizeof(c_char *);
51030 +    struct eisa_device *edev;
51031 +
51032      *name = '\0';
51033 -    Eisa.ID = inl(eisa_id);
51034 -    
51035 -    ManCode[0]=(((Eisa.Id[0]>>2)&0x1f)+0x40);
51036 -    ManCode[1]=(((Eisa.Id[1]&0xe0)>>5)+((Eisa.Id[0]&0x03)<<3)+0x40);
51037 -    ManCode[2]=(((Eisa.Id[2]>>4)&0x0f)+0x30);
51038 -    ManCode[3]=((Eisa.Id[2]&0x0f)+0x30);
51039 -    ManCode[4]=(((Eisa.Id[3]>>4)&0x0f)+0x30);
51040 -    ManCode[5]='\0';
51041 -    
51042 -    for (i=0;i<siglen;i++) {
51043 -       if (strstr(ManCode, signatures[i]) != NULL) {
51044 -           strcpy(name,ManCode);
51045 +    edev = to_eisa_device (device);
51046 +    i = edev->id.driver_data;
51047 +
51048 +    if (i >= 0 && i < siglen) {
51049 +           strcpy (name, de4x5_signatures[i]);
51050             status = 1;
51051 -           break;
51052 -       }
51053      }
51054 -    
51055 +
51056      return status;                         /* return the device name string */
51057  }
51058  
51059 @@ -3980,9 +3964,8 @@
51060  ** Look for a particular board name in the PCI configuration space
51061  */
51062  static int
51063 -PCI_signature(char *name, struct de4x5_bus_type *lp)
51064 +PCI_signature(char *name, struct de4x5_private *lp)
51065  {
51066 -    static c_char *de4x5_signatures[] = DE4X5_SIGNATURE;
51067      int i, status = 0, siglen = sizeof(de4x5_signatures)/sizeof(c_char *);
51068      
51069      if (lp->chipset == DC21040) {
51070 @@ -4008,10 +3991,10 @@
51071                              )))))));
51072         }
51073         if (lp->chipset != DC21041) {
51074 -           useSROM = TRUE;             /* card is not recognisably DEC */
51075 +           lp->useSROM = TRUE;             /* card is not recognisably DEC */
51076         }
51077      } else if ((lp->chipset & ~0x00ff) == DC2114x) {
51078 -       useSROM = TRUE;
51079 +       lp->useSROM = TRUE;
51080      }
51081      
51082      return status;
51083 @@ -4026,10 +4009,10 @@
51084  ** be fixed up later).
51085  */
51086  static void
51087 -DevicePresent(u_long aprom_addr)
51088 +DevicePresent(struct net_device *dev, u_long aprom_addr)
51089  {
51090      int i, j=0;
51091 -    struct de4x5_bus_type *lp = &bus;
51092 +    struct de4x5_private *lp = (struct de4x5_private *) dev->priv;
51093      
51094      if (lp->chipset == DC21040) {
51095         if (lp->bus == EISA) {
51096 @@ -4110,7 +4093,7 @@
51097      u_long iobase = dev->base_addr;
51098      int broken, i, k, tmp, status = 0;
51099      u_short j,chksum;
51100 -    struct de4x5_bus_type *lp = &bus;
51101 +    struct de4x5_private *lp = dev->priv;
51102  
51103      broken = de4x5_bad_srom(lp);
51104  
51105 @@ -4191,7 +4174,7 @@
51106  ** didn't seem to work here...?
51107  */
51108  static int
51109 -de4x5_bad_srom(struct de4x5_bus_type *lp)
51110 +de4x5_bad_srom(struct de4x5_private *lp)
51111  {
51112      int i, status = 0;
51113  
51114 @@ -4225,14 +4208,14 @@
51115  static void
51116  srom_repair(struct net_device *dev, int card)
51117  {
51118 -    struct de4x5_bus_type *lp = &bus;
51119 +    struct de4x5_private *lp = dev->priv;
51120  
51121      switch(card) {
51122        case SMC:
51123 -       memset((char *)&bus.srom, 0, sizeof(struct de4x5_srom));
51124 +       memset((char *)&lp->srom, 0, sizeof(struct de4x5_srom));
51125         memcpy(lp->srom.ieee_addr, (char *)dev->dev_addr, ETH_ALEN);
51126         memcpy(lp->srom.info, (char *)&srom_repair_info[SMC-1], 100);
51127 -       useSROM = TRUE;
51128 +       lp->useSROM = TRUE;
51129         break;
51130      }
51131  
51132 @@ -4246,7 +4229,7 @@
51133  static int
51134  test_bad_enet(struct net_device *dev, int status)
51135  {
51136 -    struct de4x5_bus_type *lp = &bus;
51137 +    struct de4x5_private *lp = dev->priv;
51138      int i, tmp;
51139  
51140      for (tmp=0,i=0; i<ETH_ALEN; i++) tmp += (u_char)dev->dev_addr[i];
51141 @@ -4279,7 +4262,7 @@
51142  ** List of board exceptions with correctly wired IRQs
51143  */
51144  static int
51145 -an_exception(struct de4x5_bus_type *lp)
51146 +an_exception(struct de4x5_private *lp)
51147  {
51148      if ((*(u_short *)lp->srom.sub_vendor_id == 0x00c0) && 
51149         (*(u_short *)lp->srom.sub_system_id == 0x95e0)) {
51150 @@ -5312,19 +5295,20 @@
51151             break;
51152         }
51153      } else {
51154 +       struct pci_dev *pdev = to_pci_dev (lp->gendev);
51155         switch(state) {
51156           case WAKEUP:
51157 -           pci_write_config_byte(lp->pdev, PCI_CFDA_PSM, WAKEUP);
51158 +           pci_write_config_byte(pdev, PCI_CFDA_PSM, WAKEUP);
51159             mdelay(10);
51160             break;
51161  
51162           case SNOOZE:
51163 -           pci_write_config_byte(lp->pdev, PCI_CFDA_PSM, SNOOZE);
51164 +           pci_write_config_byte(pdev, PCI_CFDA_PSM, SNOOZE);
51165             break;
51166  
51167           case SLEEP:
51168             outl(0, DE4X5_SICR);
51169 -           pci_write_config_byte(lp->pdev, PCI_CFDA_PSM, SLEEP);
51170 +           pci_write_config_byte(pdev, PCI_CFDA_PSM, SLEEP);
51171             break;
51172         }
51173      }
51174 @@ -5348,9 +5332,6 @@
51175         t = *q;
51176         *q = '\0';
51177  
51178 -#if !defined(__sparc_v9__) && !defined(__powerpc__) && !defined(__alpha__)
51179 -       if (strstr(p, "force_eisa") || strstr(p, "FORCE_EISA")) forceEISA = 1;
51180 -#endif
51181         if (strstr(p, "fdx") || strstr(p, "FDX")) lp->params.fdx = 1;
51182  
51183         if (strstr(p, "autosense") || strstr(p, "AUTOSENSE")) {
51184 @@ -5758,146 +5739,29 @@
51185      return status;
51186  }
51187  
51188 -#ifdef MODULE
51189 -/*
51190 -** Note now that module autoprobing is allowed under EISA and PCI. The
51191 -** IRQ lines will not be auto-detected; instead I'll rely on the BIOSes
51192 -** to "do the right thing".
51193 -*/
51194 -#define LP(a) ((struct de4x5_private *)(a))
51195 -static struct net_device *mdev = NULL;
51196 -static int io=0x0;/* EDIT THIS LINE FOR YOUR CONFIGURATION IF NEEDED        */
51197 -MODULE_PARM(io, "i");
51198 -MODULE_PARM_DESC(io, "de4x5 I/O base address");
51199 -
51200 -int
51201 -init_module(void)
51202 +static int __init de4x5_module_init (void)
51203  {
51204 -    int i, num, status = -EIO;
51205 -    struct net_device *p;
51206 +       int err = 0;
51207  
51208 -    num = count_adapters();
51209 -
51210 -    for (i=0; i<num; i++) {
51211 -       if ((p = insert_device(NULL, io, de4x5_probe)) == NULL) 
51212 -           return -ENOMEM;
51213 -
51214 -       if (!mdev) mdev = p;
51215 -
51216 -       if (register_netdev(p) != 0) {
51217 -           struct de4x5_private *lp = (struct de4x5_private *)p->priv;
51218 -           if (lp) {
51219 -               release_region(p->base_addr, (lp->bus == PCI ? 
51220 -                                             DE4X5_PCI_TOTAL_SIZE :
51221 -                                             DE4X5_EISA_TOTAL_SIZE));
51222 -               if (lp->cache.priv) {       /* Private area allocated?   */
51223 -                   kfree(lp->cache.priv);  /* Free the private area     */
51224 -               }
51225 -               if (lp->rx_ring) {
51226 -                   pci_free_consistent(lp->pdev, lp->dma_size, lp->rx_ring,
51227 -                                       lp->dma_rings);
51228 -               }
51229 -           }
51230 -           kfree(p);
51231 -       } else {
51232 -           status = 0;                 /* At least one adapter will work */
51233 -           lastModule = p;
51234 -       }
51235 -    }
51236 -
51237 -    return status;
51238 -}
51239 -
51240 -void
51241 -cleanup_module(void)
51242 -{
51243 -    while (mdev != NULL) {
51244 -       mdev = unlink_modules(mdev);
51245 -    }
51246 -
51247 -    return;
51248 -}
51249 -
51250 -static struct net_device *
51251 -unlink_modules(struct net_device *p)
51252 -{
51253 -    struct net_device *next = NULL;
51254 -
51255 -    if (p->priv) {                          /* Private areas allocated?  */
51256 -       struct de4x5_private *lp = (struct de4x5_private *)p->priv;
51257 -
51258 -       next = lp->next_module;
51259 -       if (lp->rx_ring) {
51260 -               pci_free_consistent(lp->pdev, lp->dma_size, lp->rx_ring,
51261 -                                   lp->dma_rings);
51262 -       }
51263 -       release_region(p->base_addr, (lp->bus == PCI ? 
51264 -                                     DE4X5_PCI_TOTAL_SIZE :
51265 -                                     DE4X5_EISA_TOTAL_SIZE));
51266 -       kfree(lp->cache.priv);              /* Free the private area     */
51267 -    }
51268 -    unregister_netdev(p);
51269 -    free_netdev(p);                         /* Free the device structure */
51270 -    
51271 -    return next;
51272 -}
51273 -
51274 -static int
51275 -count_adapters(void)
51276 -{
51277 -    int i, j=0;
51278 -    u_short vendor;
51279 -    u_int class = DE4X5_CLASS_CODE;
51280 -    u_int device;
51281 -
51282 -#if !defined(__sparc_v9__) && !defined(__powerpc__) && !defined(__alpha__)
51283 -    char name[DE4X5_STRLEN];
51284 -    u_long iobase = 0x1000;
51285 -
51286 -    for (i=1; i<MAX_EISA_SLOTS; i++, iobase+=EISA_SLOT_INC) {
51287 -       if (EISA_signature(name, EISA_ID)) j++;
51288 -    }
51289 +#if CONFIG_PCI
51290 +       err = pci_module_init (&de4x5_pci_driver);
51291 +#endif
51292 +#ifdef CONFIG_EISA
51293 +       err |= eisa_driver_register (&de4x5_eisa_driver);
51294  #endif
51295  
51296 -    for (i=0; (pdev=pci_find_class(class, pdev))!= NULL; i++) {
51297 -       vendor = pdev->vendor;
51298 -       device = pdev->device << 8;
51299 -       if (is_DC21040 || is_DC21041 || is_DC21140 || is_DC2114x) j++;
51300 -    }
51301 -
51302 -    return j;
51303 +       return err;
51304  }
51305  
51306 -/*
51307 -** If at end of eth device list and can't use current entry, malloc
51308 -** one up. If memory could not be allocated, print an error message.
51309 -*/
51310 -static struct net_device * __init 
51311 -insert_device(struct net_device *dev, u_long iobase, int (*init)(struct net_device *))
51312 +static void __exit de4x5_module_exit (void)
51313  {
51314 -    struct net_device *new;
51315 -
51316 -    new = (struct net_device *)kmalloc(sizeof(struct net_device), GFP_KERNEL);
51317 -    if (new == NULL) {
51318 -       printk("de4x5.c: Device not initialised, insufficient memory\n");
51319 -       return NULL;
51320 -    } else {
51321 -       memset((char *)new, 0, sizeof(struct net_device));
51322 -       new->base_addr = iobase;       /* assign the io address */
51323 -       new->init = init;              /* initialisation routine */
51324 -    }
51325 -
51326 -    return new;
51327 +#if CONFIG_PCI
51328 +       pci_unregister_driver (&de4x5_pci_driver);
51329 +#endif
51330 +#ifdef CONFIG_EISA
51331 +       eisa_driver_unregister (&de4x5_eisa_driver);
51332 +#endif
51333  }
51334  
51335 -#endif /* MODULE */
51336 -
51337 -\f
51338 -/*
51339 - * Local variables:
51340 - *
51341 - * Delete -DMODVERSIONS below if you didn't define this in your kernel
51342 - *
51343 - *  compile-command: "gcc -D__KERNEL__ -DMODULE -I/linux/include -Wall -Wstrict-prototypes -fomit-frame-pointer -fno-strength-reduce -malign-loops=2 -malign-jumps=2 -malign-functions=2 -O2 -m486 -DMODVERSIONS -include /linux/include/linux/modversions.h -c de4x5.c"
51344 - * End:
51345 - */
51346 +module_init (de4x5_module_init);
51347 +module_exit (de4x5_module_exit);
51348 diff -Nru a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
51349 --- a/drivers/net/tulip/dmfe.c  Tue Aug 19 20:53:17 2003
51350 +++ b/drivers/net/tulip/dmfe.c  Tue Aug 26 13:42:22 2003
51351 @@ -296,7 +296,7 @@
51352  static int dmfe_stop(struct DEVICE *);
51353  static struct net_device_stats * dmfe_get_stats(struct DEVICE *);
51354  static void dmfe_set_filter_mode(struct DEVICE *);
51355 -static int dmfe_do_ioctl(struct DEVICE *, struct ifreq *, int);
51356 +static struct ethtool_ops netdev_ethtool_ops;
51357  static u16 read_srom_word(long ,int);
51358  static irqreturn_t dmfe_interrupt(int , void *, struct pt_regs *);
51359  static void dmfe_descriptor_init(struct dmfe_board_info *, unsigned long);
51360 @@ -417,7 +417,7 @@
51361         dev->stop = &dmfe_stop;
51362         dev->get_stats = &dmfe_get_stats;
51363         dev->set_multicast_list = &dmfe_set_filter_mode;
51364 -       dev->do_ioctl = &dmfe_do_ioctl;
51365 +       dev->ethtool_ops = &netdev_ethtool_ops;
51366         spin_lock_init(&db->lock);
51367  
51368         pci_read_config_dword(pdev, 0x50, &pci_pmr);
51369 @@ -1000,55 +1000,23 @@
51370         spin_unlock_irqrestore(&db->lock, flags);
51371  }
51372  
51373 -
51374 -/*
51375 - *     Process the ethtool ioctl command
51376 - */
51377 -
51378 -static int dmfe_ethtool_ioctl(struct net_device *dev, void *useraddr)
51379 +static void netdev_get_drvinfo(struct net_device *dev,
51380 +                              struct ethtool_drvinfo *info)
51381  {
51382 -       struct dmfe_board_info *db = dev->priv;
51383 -       struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
51384 -       u32 ethcmd;
51385 -
51386 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
51387 -               return -EFAULT;
51388 -
51389 -        switch (ethcmd) {
51390 -        case ETHTOOL_GDRVINFO:
51391 -               strcpy(info.driver, DRV_NAME);
51392 -               strcpy(info.version, DRV_VERSION);
51393 -               if (db->pdev)
51394 -                       strcpy(info.bus_info, pci_name(db->pdev));
51395 -               else
51396 -                       sprintf(info.bus_info, "EISA 0x%lx %d",
51397 -                               dev->base_addr, dev->irq);
51398 -               if (copy_to_user(useraddr, &info, sizeof(info)))
51399 -                       return -EFAULT;
51400 -               return 0;
51401 -        }
51402 -
51403 -       return -EOPNOTSUPP;
51404 -}
51405 +       struct dmfe_board_info *np = dev->priv;
51406  
51407 -
51408 -/*
51409 - *     Process the upper socket ioctl command
51410 - */
51411 -
51412 -static int dmfe_do_ioctl(struct DEVICE *dev, struct ifreq *ifr, int cmd)
51413 -{
51414 -       int retval = -EOPNOTSUPP;
51415 -       DMFE_DBUG(0, "dmfe_do_ioctl()", 0);
51416 -
51417 -       switch(cmd) {
51418 -       case SIOCETHTOOL:
51419 -               return dmfe_ethtool_ioctl(dev, (void*)ifr->ifr_data);
51420 -       }
51421 -
51422 -       return retval;
51423 +       strcpy(info->driver, DRV_NAME);
51424 +       strcpy(info->version, DRV_VERSION);
51425 +       if (np->pdev)
51426 +               strcpy(info->bus_info, pci_name(np->pdev));
51427 +       else
51428 +               sprintf(info->bus_info, "EISA 0x%lx %d",
51429 +                       dev->base_addr, dev->irq);
51430  }
51431  
51432 +static struct ethtool_ops netdev_ethtool_ops = {
51433 +       .get_drvinfo            = netdev_get_drvinfo,
51434 +};
51435  
51436  /*
51437   *     A periodic timer routine
51438 diff -Nru a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
51439 --- a/drivers/net/tulip/winbond-840.c   Tue Aug 19 20:53:17 2003
51440 +++ b/drivers/net/tulip/winbond-840.c   Mon Sep  1 14:05:11 2003
51441 @@ -392,6 +392,7 @@
51442  static void set_rx_mode(struct net_device *dev);
51443  static struct net_device_stats *get_stats(struct net_device *dev);
51444  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
51445 +static struct ethtool_ops netdev_ethtool_ops;
51446  static int  netdev_close(struct net_device *dev);
51447  
51448  \f
51449 @@ -482,6 +483,7 @@
51450         dev->get_stats = &get_stats;
51451         dev->set_multicast_list = &set_rx_mode;
51452         dev->do_ioctl = &netdev_ioctl;
51453 +       dev->ethtool_ops = &netdev_ethtool_ops;
51454         dev->tx_timeout = &tx_timeout;
51455         dev->watchdog_timeo = TX_TIMEOUT;
51456  
51457 @@ -1452,88 +1454,79 @@
51458         spin_unlock_irq(&np->lock);
51459  }
51460  
51461 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
51462 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
51463  {
51464         struct netdev_private *np = dev->priv;
51465 -       u32 ethcmd;
51466 -               
51467 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
51468 -               return -EFAULT;
51469 -
51470 -        switch (ethcmd) {
51471 -        case ETHTOOL_GDRVINFO: {
51472 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
51473 -               strcpy(info.driver, DRV_NAME);
51474 -               strcpy(info.version, DRV_VERSION);
51475 -               strcpy(info.bus_info, pci_name(np->pci_dev));
51476 -               if (copy_to_user(useraddr, &info, sizeof(info)))
51477 -                       return -EFAULT;
51478 -               return 0;
51479 -       }
51480 -
51481 -       /* get settings */
51482 -       case ETHTOOL_GSET: {
51483 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
51484 -               spin_lock_irq(&np->lock);
51485 -               mii_ethtool_gset(&np->mii_if, &ecmd);
51486 -               spin_unlock_irq(&np->lock);
51487 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
51488 -                       return -EFAULT;
51489 -               return 0;
51490 -       }
51491 -       /* set settings */
51492 -       case ETHTOOL_SSET: {
51493 -               int r;
51494 -               struct ethtool_cmd ecmd;
51495 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
51496 -                       return -EFAULT;
51497 -               spin_lock_irq(&np->lock);
51498 -               r = mii_ethtool_sset(&np->mii_if, &ecmd);
51499 -               spin_unlock_irq(&np->lock);
51500 -               return r;
51501 -       }
51502 -       /* restart autonegotiation */
51503 -       case ETHTOOL_NWAY_RST: {
51504 -               return mii_nway_restart(&np->mii_if);
51505 -       }
51506 -       /* get link status */
51507 -       case ETHTOOL_GLINK: {
51508 -               struct ethtool_value edata = {ETHTOOL_GLINK};
51509 -               edata.data = mii_link_ok(&np->mii_if);
51510 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
51511 -                       return -EFAULT;
51512 -               return 0;
51513 -       }
51514 -
51515 -       /* get message-level */
51516 -       case ETHTOOL_GMSGLVL: {
51517 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
51518 -               edata.data = debug;
51519 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
51520 -                       return -EFAULT;
51521 -               return 0;
51522 -       }
51523 -       /* set message-level */
51524 -       case ETHTOOL_SMSGLVL: {
51525 -               struct ethtool_value edata;
51526 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
51527 -                       return -EFAULT;
51528 -               debug = edata.data;
51529 -               return 0;
51530 -       }
51531 -        }
51532 -       
51533 -       return -EOPNOTSUPP;
51534 +
51535 +       strcpy (info->driver, DRV_NAME);
51536 +       strcpy (info->version, DRV_VERSION);
51537 +       strcpy (info->bus_info, pci_name(np->pci_dev));
51538 +}
51539 +
51540 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
51541 +{
51542 +       struct netdev_private *np = dev->priv;
51543 +       int rc;
51544 +
51545 +       spin_lock_irq(&np->lock);
51546 +       rc = mii_ethtool_gset(&np->mii_if, cmd);
51547 +       spin_unlock_irq(&np->lock);
51548 +
51549 +       return rc;
51550  }
51551  
51552 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
51553 +{
51554 +       struct netdev_private *np = dev->priv;
51555 +       int rc;
51556 +
51557 +       spin_lock_irq(&np->lock);
51558 +       rc = mii_ethtool_sset(&np->mii_if, cmd);
51559 +       spin_unlock_irq(&np->lock);
51560 +
51561 +       return rc;
51562 +}
51563 +
51564 +static int netdev_nway_reset(struct net_device *dev)
51565 +{
51566 +       struct netdev_private *np = dev->priv;
51567 +       return mii_nway_restart(&np->mii_if);
51568 +}
51569 +
51570 +static u32 netdev_get_link(struct net_device *dev)
51571 +{
51572 +       struct netdev_private *np = dev->priv;
51573 +       return mii_link_ok(&np->mii_if);
51574 +}
51575 +
51576 +static u32 netdev_get_msglevel(struct net_device *dev)
51577 +{
51578 +       return debug;
51579 +}
51580 +
51581 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
51582 +{
51583 +       debug = value;
51584 +}
51585 +
51586 +static struct ethtool_ops netdev_ethtool_ops = {
51587 +       .get_drvinfo            = netdev_get_drvinfo,
51588 +       .get_settings           = netdev_get_settings,
51589 +       .set_settings           = netdev_set_settings,
51590 +       .nway_reset             = netdev_nway_reset,
51591 +       .get_link               = netdev_get_link,
51592 +       .get_msglevel           = netdev_get_msglevel,
51593 +       .set_msglevel           = netdev_set_msglevel,
51594 +       .get_sg                 = ethtool_op_get_sg,
51595 +       .get_tx_csum            = ethtool_op_get_tx_csum,
51596 +};
51597 +
51598  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
51599  {
51600         struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
51601         struct netdev_private *np = dev->priv;
51602  
51603         switch(cmd) {
51604 -       case SIOCETHTOOL:
51605 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
51606         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
51607                 data->phy_id = ((struct netdev_private *)dev->priv)->phys[0] & 0x1f;
51608                 /* Fall Through */
51609 diff -Nru a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
51610 --- a/drivers/net/tulip/xircom_cb.c     Tue Aug 19 20:53:17 2003
51611 +++ b/drivers/net/tulip/xircom_cb.c     Tue Aug 26 14:52:05 2003
51612 @@ -175,37 +175,19 @@
51613  }
51614  #endif
51615  
51616 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
51617 +static void netdev_get_drvinfo(struct net_device *dev,
51618 +                              struct ethtool_drvinfo *info)
51619  {
51620 -       u32 ethcmd;
51621 -               
51622 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
51623 -               return -EFAULT;
51624 -       
51625 -       switch (ethcmd) {
51626 -       case ETHTOOL_GDRVINFO: {
51627 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
51628 -               strncpy(info.driver, "xircom_cb", sizeof(info.driver)-1);
51629 -               if (copy_to_user(useraddr, &info, sizeof(info)))
51630 -                       return -EFAULT;
51631 -               return 0;
51632 -       }
51633 -       }
51634 -       
51635 -       return -EOPNOTSUPP;
51636 -}
51637 +       struct xircom_private *private = dev->priv;
51638  
51639 -static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
51640 -{
51641 -
51642 -       switch(cmd) {
51643 -       case SIOCETHTOOL:
51644 -              return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
51645 -       default:
51646 -               return -EOPNOTSUPP;
51647 -       }
51648 +       strcpy(info->driver, "xircom_cb");
51649 +       strcpy(info->bus_info, pci_name(private->pdev));
51650  }
51651  
51652 +static struct ethtool_ops netdev_ethtool_ops = {
51653 +       .get_drvinfo            = netdev_get_drvinfo,
51654 +};
51655 +
51656  /* xircom_probe is the code that gets called on device insertion.
51657     it sets up the hardware and registers the device to the networklayer.
51658     
51659 @@ -287,7 +269,7 @@
51660         dev->stop = &xircom_close;
51661         dev->get_stats = &xircom_get_stats;
51662         dev->priv = private;
51663 -       dev->do_ioctl = &private_ioctl;
51664 +       SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
51665         pci_set_drvdata(pdev, dev);
51666  
51667         
51668 diff -Nru a/drivers/net/tun.c b/drivers/net/tun.c
51669 --- a/drivers/net/tun.c Tue Aug 19 20:58:55 2003
51670 +++ b/drivers/net/tun.c Wed Sep  3 23:40:14 2003
51671 @@ -640,3 +640,4 @@
51672  module_init(tun_init);
51673  module_exit(tun_cleanup);
51674  MODULE_LICENSE("GPL");
51675 +MODULE_ALIAS_MISCDEV(TUN_MINOR);
51676 diff -Nru a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
51677 --- a/drivers/net/via-rhine.c   Tue Aug 19 20:53:17 2003
51678 +++ b/drivers/net/via-rhine.c   Mon Sep  1 14:05:11 2003
51679 @@ -547,6 +547,7 @@
51680  static void via_rhine_set_rx_mode(struct net_device *dev);
51681  static struct net_device_stats *via_rhine_get_stats(struct net_device *dev);
51682  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
51683 +static struct ethtool_ops netdev_ethtool_ops;
51684  static int  via_rhine_close(struct net_device *dev);
51685  
51686  static inline u32 get_intr_status(struct net_device *dev)
51687 @@ -780,6 +781,7 @@
51688         dev->get_stats = via_rhine_get_stats;
51689         dev->set_multicast_list = via_rhine_set_rx_mode;
51690         dev->do_ioctl = netdev_ioctl;
51691 +       dev->ethtool_ops = &netdev_ethtool_ops;
51692         dev->tx_timeout = via_rhine_tx_timeout;
51693         dev->watchdog_timeo = TX_TIMEOUT;
51694         if (np->drv_flags & ReqTxAlign)
51695 @@ -1741,90 +1743,87 @@
51696         writeb(np->rx_thresh | rx_mode, ioaddr + RxConfig);
51697  }
51698  
51699 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
51700 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
51701  {
51702         struct netdev_private *np = dev->priv;
51703 -       u32 ethcmd;
51704  
51705 -       if (get_user(ethcmd, (u32 *)useraddr))
51706 -               return -EFAULT;
51707 +       strcpy (info->driver, DRV_NAME);
51708 +       strcpy (info->version, DRV_VERSION);
51709 +       strcpy (info->bus_info, pci_name(np->pdev));
51710 +}
51711  
51712 -       switch (ethcmd) {
51713 -       case ETHTOOL_GDRVINFO: {
51714 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
51715 -               strcpy (info.driver, DRV_NAME);
51716 -               strcpy (info.version, DRV_VERSION);
51717 -               strcpy (info.bus_info, pci_name(np->pdev));
51718 -               if (copy_to_user (useraddr, &info, sizeof (info)))
51719 -                       return -EFAULT;
51720 -               return 0;
51721 -       }
51722 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
51723 +{
51724 +       struct netdev_private *np = dev->priv;
51725 +       int rc;
51726  
51727 -       /* get settings */
51728 -       case ETHTOOL_GSET: {
51729 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
51730 -               if (!(np->drv_flags & CanHaveMII))
51731 -                       break;
51732 -               spin_lock_irq(&np->lock);
51733 -               mii_ethtool_gset(&np->mii_if, &ecmd);
51734 -               spin_unlock_irq(&np->lock);
51735 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
51736 -                       return -EFAULT;
51737 -               return 0;
51738 -       }
51739 -       /* set settings */
51740 -       case ETHTOOL_SSET: {
51741 -               int r;
51742 -               struct ethtool_cmd ecmd;
51743 -               if (!(np->drv_flags & CanHaveMII))
51744 -                       break;
51745 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
51746 -                       return -EFAULT;
51747 -               spin_lock_irq(&np->lock);
51748 -               r = mii_ethtool_sset(&np->mii_if, &ecmd);
51749 -               spin_unlock_irq(&np->lock);
51750 -               return r;
51751 -       }
51752 -       /* restart autonegotiation */
51753 -       case ETHTOOL_NWAY_RST: {
51754 -               if (!(np->drv_flags & CanHaveMII))
51755 -                       break;
51756 -               return mii_nway_restart(&np->mii_if);
51757 -       }
51758 -       /* get link status */
51759 -       case ETHTOOL_GLINK: {
51760 -               struct ethtool_value edata = {ETHTOOL_GLINK};
51761 -               if (!(np->drv_flags & CanHaveMII))
51762 -                       break;
51763 -               edata.data = mii_link_ok(&np->mii_if);
51764 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
51765 -                       return -EFAULT;
51766 -               return 0;
51767 -       }
51768 -
51769 -       /* get message-level */
51770 -       case ETHTOOL_GMSGLVL: {
51771 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
51772 -               edata.data = debug;
51773 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
51774 -                       return -EFAULT;
51775 -               return 0;
51776 -       }
51777 -       /* set message-level */
51778 -       case ETHTOOL_SMSGLVL: {
51779 -               struct ethtool_value edata;
51780 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
51781 -                       return -EFAULT;
51782 -               debug = edata.data;
51783 -               return 0;
51784 -       }
51785 -       default:
51786 -               break;
51787 -       }
51788 +       if (!(np->drv_flags & CanHaveMII))
51789 +               return -EINVAL;
51790 +
51791 +       spin_lock_irq(&np->lock);
51792 +       rc = mii_ethtool_gset(&np->mii_if, cmd);
51793 +       spin_unlock_irq(&np->lock);
51794 +
51795 +       return rc;
51796 +}
51797 +
51798 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
51799 +{
51800 +       struct netdev_private *np = dev->priv;
51801 +       int rc;
51802 +
51803 +       if (!(np->drv_flags & CanHaveMII))
51804 +               return -EINVAL;
51805 +
51806 +       spin_lock_irq(&np->lock);
51807 +       rc = mii_ethtool_sset(&np->mii_if, cmd);
51808 +       spin_unlock_irq(&np->lock);
51809  
51810 -       return -EOPNOTSUPP;
51811 +       return rc;
51812  }
51813  
51814 +static int netdev_nway_reset(struct net_device *dev)
51815 +{
51816 +       struct netdev_private *np = dev->priv;
51817 +
51818 +       if (!(np->drv_flags & CanHaveMII))
51819 +               return -EINVAL;
51820 +
51821 +       return mii_nway_restart(&np->mii_if);
51822 +}
51823 +
51824 +static u32 netdev_get_link(struct net_device *dev)
51825 +{
51826 +       struct netdev_private *np = dev->priv;
51827 +
51828 +       if (!(np->drv_flags & CanHaveMII))
51829 +               return 0;       /* -EINVAL */
51830 +
51831 +       return mii_link_ok(&np->mii_if);
51832 +}
51833 +
51834 +static u32 netdev_get_msglevel(struct net_device *dev)
51835 +{
51836 +       return debug;
51837 +}
51838 +
51839 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
51840 +{
51841 +       debug = value;
51842 +}
51843 +
51844 +static struct ethtool_ops netdev_ethtool_ops = {
51845 +       .get_drvinfo            = netdev_get_drvinfo,
51846 +       .get_settings           = netdev_get_settings,
51847 +       .set_settings           = netdev_set_settings,
51848 +       .nway_reset             = netdev_nway_reset,
51849 +       .get_link               = netdev_get_link,
51850 +       .get_msglevel           = netdev_get_msglevel,
51851 +       .set_msglevel           = netdev_set_msglevel,
51852 +       .get_sg                 = ethtool_op_get_sg,
51853 +       .get_tx_csum            = ethtool_op_get_tx_csum,
51854 +};
51855 +
51856  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
51857  {
51858         struct netdev_private *np = dev->priv;
51859 @@ -1834,14 +1833,9 @@
51860         if (!netif_running(dev))
51861                 return -EINVAL;
51862  
51863 -       if (cmd == SIOCETHTOOL)
51864 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
51865 -
51866 -       else {
51867 -               spin_lock_irq(&np->lock);
51868 -               rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL);
51869 -               spin_unlock_irq(&np->lock);
51870 -       }
51871 +       spin_lock_irq(&np->lock);
51872 +       rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL);
51873 +       spin_unlock_irq(&np->lock);
51874  
51875         return rc;
51876  }
51877 diff -Nru a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
51878 --- a/drivers/net/wan/Kconfig   Wed Aug 20 22:31:57 2003
51879 +++ b/drivers/net/wan/Kconfig   Tue Sep  2 08:24:53 2003
51880 @@ -63,7 +63,7 @@
51881  # Not updated to 2.6.
51882  config COMX
51883         tristate "MultiGate (COMX) synchronous serial boards support"
51884 -       depends on WAN && (ISA || PCI) && OBSOLETE
51885 +       depends on WAN && (ISA || PCI) && BROKEN
51886         ---help---
51887           Say Y if you want to use any board from the MultiGate (COMX) family.
51888           These boards are synchronous serial adapters for the PC,
51889 @@ -465,7 +465,7 @@
51890  
51891  config SDLA
51892         tristate "SDLA (Sangoma S502/S508) support"
51893 -       depends on DLCI && ISA
51894 +       depends on DLCI && ISA && BROKEN_ON_SMP
51895         help
51896           Say Y here if you need a driver for the Sangoma S502A, S502E, and
51897           S508 Frame Relay Access Devices. These are multi-protocol cards, but
51898 @@ -498,7 +498,7 @@
51899  
51900  config VENDOR_SANGOMA
51901         tristate "Sangoma WANPIPE(tm) multiprotocol cards"
51902 -       depends on WAN_ROUTER_DRIVERS && WAN_ROUTER && (PCI || ISA)
51903 +       depends on WAN_ROUTER_DRIVERS && WAN_ROUTER && (PCI || ISA) && BROKEN
51904         ---help---
51905           WANPIPE from Sangoma Technologies Inc. (<http://www.sangoma.com/>)
51906           is a family of intelligent multiprotocol WAN adapters with data
51907 diff -Nru a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
51908 --- a/drivers/net/wan/cosa.c    Tue Aug 19 21:00:03 2003
51909 +++ b/drivers/net/wan/cosa.c    Fri Aug 29 22:32:28 2003
51910 @@ -632,7 +632,7 @@
51911  {
51912         sppp_detach(chan->pppdev.dev);
51913         unregister_netdev(chan->pppdev.dev);
51914 -       free_netdev(chan->ppp.dev);
51915 +       free_netdev(chan->pppdev.dev);
51916  }
51917  
51918  static int cosa_sppp_open(struct net_device *d)
51919 @@ -961,12 +961,12 @@
51920         unsigned long flags;
51921         int n;
51922  
51923 -       if ((n=minor(file->f_dentry->d_inode->i_rdev)>>CARD_MINOR_BITS)
51924 +       if ((n=iminor(file->f_dentry->d_inode)>>CARD_MINOR_BITS)
51925                 >= nr_cards)
51926                 return -ENODEV;
51927         cosa = cosa_cards+n;
51928  
51929 -       if ((n=minor(file->f_dentry->d_inode->i_rdev)
51930 +       if ((n=iminor(file->f_dentry->d_inode)
51931                 & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels)
51932                 return -ENODEV;
51933         chan = cosa->chan + n;
51934 @@ -1009,7 +1009,7 @@
51935  /* To be done ... */
51936  static int cosa_fasync(struct inode *inode, struct file *file, int on)
51937  {
51938 -        int port = MINOR(inode->i_rdev);
51939 +        int port = iminor(inode);
51940          int rv = fasync_helper(inode, file, on, &fasync[port]);
51941          return rv < 0 ? rv : 0;
51942  }
51943 diff -Nru a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c
51944 --- a/drivers/net/wan/cycx_drv.c        Tue Jul 15 10:01:29 2003
51945 +++ b/drivers/net/wan/cycx_drv.c        Sat Aug 23 20:42:31 2003
51946 @@ -70,12 +70,12 @@
51947  static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len);
51948  static void cycx_bootcfg(struct cycx_hw *hw);
51949  
51950 -static int reset_cyc2x(u32 addr);
51951 -static int detect_cyc2x(u32 addr);
51952 +static int reset_cyc2x(void *addr);
51953 +static int detect_cyc2x(void *addr);
51954  
51955  /* Miscellaneous functions */
51956  static void delay_cycx(int sec);
51957 -static int get_option_index(u32 *optlist, u32 optval);
51958 +static int get_option_index(long *optlist, long optval);
51959  static u16 checksum(u8 *buf, u32 len);
51960  
51961  #define wait_cyc(addr) cycx_exec(addr + CMD_OFFSET)
51962 @@ -92,14 +92,14 @@
51963   * These are arrays of configuration options used by verification routines.
51964   * The first element of each array is its size (i.e. number of options).
51965   */
51966 -static u32 cyc2x_dpmbase_options[] = {
51967 +static long cyc2x_dpmbase_options[] = {
51968         20,
51969         0xA0000, 0xA4000, 0xA8000, 0xAC000, 0xB0000, 0xB4000, 0xB8000,
51970         0xBC000, 0xC0000, 0xC4000, 0xC8000, 0xCC000, 0xD0000, 0xD4000,
51971         0xD8000, 0xDC000, 0xE0000, 0xE4000, 0xE8000, 0xEC000
51972  };
51973  
51974 -static u32 cycx_2x_irq_options[]  = { 7, 3, 5, 9, 10, 11, 12, 15 };
51975 +static long cycx_2x_irq_options[]  = { 7, 3, 5, 9, 10, 11, 12, 15 };
51976  
51977  /* Kernel Loadable Module Entry Points */
51978  /* Module 'insert' entry point.
51979 @@ -137,7 +137,7 @@
51980  EXPORT_SYMBOL(cycx_setup);
51981  int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len)
51982  {
51983 -       unsigned long dpmbase = hw->dpmbase;
51984 +       long dpmbase = (long)hw->dpmbase;
51985         int err;
51986  
51987         /* Verify IRQ configuration options */
51988 @@ -147,17 +147,17 @@
51989         }
51990  
51991         /* Setup adapter dual-port memory window and test memory */
51992 -       if (!hw->dpmbase) {
51993 +       if (!dpmbase) {
51994                 printk(KERN_ERR "%s: you must specify the dpm address!\n",
51995                                 modname);
51996                 return -EINVAL;
51997 -       } else if (!get_option_index(cyc2x_dpmbase_options, hw->dpmbase)) {
51998 +       } else if (!get_option_index(cyc2x_dpmbase_options, dpmbase)) {
51999                 printk(KERN_ERR "%s: memory address 0x%lX is invalid!\n",
52000                                 modname, dpmbase);
52001                 return -EINVAL;
52002         }
52003  
52004 -       hw->dpmbase = (u32)ioremap(dpmbase, CYCX_WINDOWSIZE);
52005 +       hw->dpmbase = ioremap(dpmbase, CYCX_WINDOWSIZE);
52006         hw->dpmsize = CYCX_WINDOWSIZE;
52007  
52008         if (!detect_cyc2x(hw->dpmbase)) {
52009 @@ -181,8 +181,7 @@
52010  EXPORT_SYMBOL(cycx_down);
52011  int cycx_down(struct cycx_hw *hw)
52012  {
52013 -       iounmap((u32 *)hw->dpmbase);
52014 -
52015 +       iounmap(hw->dpmbase);
52016         return 0;
52017  }
52018  
52019 @@ -204,7 +203,7 @@
52020   * o Set exec flag.
52021   * o Busy-wait until flag is reset. */
52022  EXPORT_SYMBOL(cycx_exec);
52023 -int cycx_exec(u32 addr)
52024 +int cycx_exec(void *addr)
52025  {
52026         u16 i = 0;
52027         /* wait till addr content is zeroed */
52028 @@ -250,7 +249,7 @@
52029  /* Load Aux Routines */
52030  /* Reset board hardware.
52031     return 1 if memory exists at addr and 0 if not. */
52032 -static int memory_exists(u32 addr)
52033 +static int memory_exists(void *addr)
52034  {
52035         int tries = 0;
52036  
52037 @@ -268,9 +267,9 @@
52038  }
52039  
52040  /* Load reset code. */
52041 -static void reset_load(u32 addr, u8 *buffer, u32 cnt)
52042 +static void reset_load(void *addr, u8 *buffer, u32 cnt)
52043  {
52044 -       u32 pt_code = addr + RESET_OFFSET;
52045 +       void *pt_code = addr + RESET_OFFSET;
52046         u16 i; /*, j; */
52047  
52048         for (i = 0 ; i < cnt ; i++) {
52049 @@ -282,7 +281,7 @@
52050  /* Load buffer using boot interface.
52051   * o copy data from buffer to Cyclom-X memory
52052   * o wait for reset code to copy it to right portion of memory */
52053 -static int buffer_load(u32 addr, u8 *buffer, u32 cnt)
52054 +static int buffer_load(void *addr, u8 *buffer, u32 cnt)
52055  {
52056         memcpy_toio(addr + DATA_OFFSET, buffer, cnt);
52057         writew(GEN_BOOT_DAT, addr + CMD_OFFSET);
52058 @@ -291,7 +290,7 @@
52059  }
52060  
52061  /* Set up entry point and kick start Cyclom-X CPU. */
52062 -static void cycx_start(u32 addr)
52063 +static void cycx_start(void *addr)
52064  {
52065         /* put in 0x30 offset the jump instruction to the code entry point */
52066         writeb(0xea, addr + 0x30);
52067 @@ -305,9 +304,9 @@
52068  }
52069  
52070  /* Load and boot reset code. */
52071 -static void cycx_reset_boot(u32 addr, u8 *code, u32 len)
52072 +static void cycx_reset_boot(void *addr, u8 *code, u32 len)
52073  {
52074 -       u32 pt_start = addr + START_OFFSET;
52075 +       void *pt_start = addr + START_OFFSET;
52076  
52077         writeb(0xea, pt_start++); /* jmp to f000:3f00 */
52078         writeb(0x00, pt_start++);
52079 @@ -322,9 +321,9 @@
52080  }
52081  
52082  /* Load data.bin file through boot (reset) interface. */
52083 -static int cycx_data_boot(u32 addr, u8 *code, u32 len)
52084 +static int cycx_data_boot(void *addr, u8 *code, u32 len)
52085  {
52086 -       u32 pt_boot_cmd = addr + CMD_OFFSET;
52087 +       void *pt_boot_cmd = addr + CMD_OFFSET;
52088         u32 i;
52089  
52090         /* boot buffer lenght */
52091 @@ -353,9 +352,9 @@
52092  
52093  
52094  /* Load code.bin file through boot (reset) interface. */
52095 -static int cycx_code_boot(u32 addr, u8 *code, u32 len)
52096 +static int cycx_code_boot(void *addr, u8 *code, u32 len)
52097  {
52098 -       u32 pt_boot_cmd = addr + CMD_OFFSET;
52099 +       void *pt_boot_cmd = addr + CMD_OFFSET;
52100         u32 i;
52101  
52102         /* boot buffer lenght */
52103 @@ -392,7 +391,7 @@
52104         u8 *reset_image,
52105            *data_image,
52106            *code_image;
52107 -       u32 pt_cycld = hw->dpmbase + 0x400;
52108 +       void *pt_cycld = hw->dpmbase + 0x400;
52109         u16 cksum;
52110  
52111         /* Announce */
52112 @@ -426,7 +425,7 @@
52113         if (cksum != cfm->checksum) {
52114                 printk(KERN_ERR "%s:%s: firmware corrupted!\n",
52115                                 modname, __FUNCTION__);
52116 -               printk(KERN_ERR " cdsize = 0x%x (expected 0x%lx)\n",
52117 +               printk(KERN_ERR " cdsize = 0x%lx (expected 0x%lx)\n",
52118                                 len - sizeof(struct cycx_firmware) - 1,
52119                                 cfm->info.codesize);
52120                 printk(KERN_ERR " chksum = 0x%x (expected 0x%x)\n",
52121 @@ -435,9 +434,7 @@
52122         }
52123  
52124         /* If everything is ok, set reset, data and code pointers */
52125 -
52126 -       img_hdr = (struct cycx_fw_header *)(((u8 *)cfm) +
52127 -                                           sizeof(struct cycx_firmware) - 1);
52128 +       img_hdr = (struct cycx_fw_header *)&cfm->image;
52129  #ifdef FIRMWARE_DEBUG
52130         printk(KERN_INFO "%s:%s: image sizes\n", __FUNCTION__, modname);
52131         printk(KERN_INFO " reset=%lu\n", img_hdr->reset_size);
52132 @@ -526,7 +523,7 @@
52133   *     Return 1 if detected o.k. or 0 if failed.
52134   *     Note:   This test is destructive! Adapter will be left in shutdown
52135   *             state after the test. */
52136 -static int detect_cyc2x(u32 addr)
52137 +static int detect_cyc2x(void *addr)
52138  {
52139         reset_cyc2x(addr);
52140  
52141 @@ -536,7 +533,7 @@
52142  /* Miscellaneous */
52143  /* Get option's index into the options list.
52144   *     Return option's index (1 .. N) or zero if option is invalid. */
52145 -static int get_option_index(u32 *optlist, u32 optval)
52146 +static int get_option_index(long *optlist, long optval)
52147  {
52148         int i = 1;
52149  
52150 @@ -548,7 +545,7 @@
52151  }
52152  
52153  /* Reset adapter's CPU. */
52154 -static int reset_cyc2x(u32 addr)
52155 +static int reset_cyc2x(void *addr)
52156  {
52157         writeb(0, addr + RST_ENABLE);
52158         delay_cycx(2);
52159 diff -Nru a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c
52160 --- a/drivers/net/wan/cycx_main.c       Tue May 20 07:19:38 2003
52161 +++ b/drivers/net/wan/cycx_main.c       Sat Aug 23 20:36:33 2003
52162 @@ -223,7 +223,7 @@
52163         /* Configure hardware, load firmware, etc. */
52164         memset(&card->hw, 0, sizeof(card->hw));
52165         card->hw.irq     = irq;
52166 -       card->hw.dpmbase = conf->maddr;
52167 +       card->hw.dpmbase = (void *)conf->maddr;
52168         card->hw.dpmsize = CYCX_WINDOWSIZE;
52169         card->hw.fwid    = CFID_X25_2X;
52170         card->lock       = SPIN_LOCK_UNLOCKED;
52171 @@ -236,7 +236,7 @@
52172         /* Initialize WAN device data space */
52173         wandev->irq       = irq;
52174         wandev->dma       = wandev->ioport = 0;
52175 -       wandev->maddr     = card->hw.dpmbase;
52176 +       wandev->maddr     = (unsigned long)card->hw.dpmbase;
52177         wandev->msize     = card->hw.dpmsize;
52178         wandev->hw_opt[2] = 0;
52179         wandev->hw_opt[3] = card->hw.fwid;
52180 diff -Nru a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
52181 --- a/drivers/net/wireless/airo.c       Tue Aug 19 20:13:55 2003
52182 +++ b/drivers/net/wireless/airo.c       Wed Sep  3 10:53:01 2003
52183 @@ -81,12 +81,12 @@
52184  #endif
52185  
52186  /* Support Cisco MIC feature */
52187 -/* As this feature requires the AES encryption algorithm, it is not included
52188 -   in the kernel tree. If you want to enable it, you need to download the
52189 -   aes.h, aestab.h and mic.h files from the CVS at
52190 -   http://sf.net/projects/airo-linux/ Put the files in the same directory
52191 -   as airo.c and compile normally */
52192 +#define MICSUPPORT
52193 +
52194 +#if defined(MICSUPPORT) && !defined(CONFIG_CRYPTO)
52195 +#warning MIC support requires Crypto API
52196  #undef MICSUPPORT
52197 +#endif
52198  
52199  /* Hack to do some power saving */
52200  #define POWER_ON_DOWN
52201 @@ -615,14 +615,14 @@
52202         u16 arlDelay;
52203         u16 _reserved4[1];
52204         /*---------- Aironet Extensions ----------*/
52205 -       u16 magicAction;
52206 +       u8 magicAction;
52207  #define MAGIC_ACTION_STSCHG 1
52208  #define MACIC_ACTION_RESUME 2
52209  #define MAGIC_IGNORE_MCAST (1<<8)
52210  #define MAGIC_IGNORE_BCAST (1<<9)
52211  #define MAGIC_SWITCH_TO_PSP (0<<10)
52212  #define MAGIC_STAY_IN_CAM (1<<10)
52213 -       u16 magicControl;
52214 +       u8 magicControl;
52215         u16 autoWake;
52216  } ConfigRid;
52217  
52218 @@ -843,6 +843,7 @@
52219  #define AIROGMICRID            11
52220  #define AIROGMICSTATS          12
52221  #define AIROGFLAGS             13
52222 +#define AIRORRID               15
52223  
52224  /* Leave gap of 40 commands after AIROGSTATSD32 for future */
52225  
52226 @@ -994,6 +995,8 @@
52227  static int micsetup(struct airo_info *ai);
52228  static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len);
52229  static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen);
52230 +
52231 +#include <linux/crypto.h>
52232  #endif
52233  
52234  struct airo_info {
52235 @@ -1063,9 +1066,12 @@
52236  #endif /* WIRELESS_SPY */
52237  #endif /* WIRELESS_EXT > 15 */
52238  #endif /* WIRELESS_EXT */
52239 +#ifdef MICSUPPORT
52240         /* MIC stuff */
52241 +       struct crypto_tfm       *tfm;
52242         mic_module              mod[2];
52243         mic_statistics          micstats;
52244 +#endif
52245  };
52246  
52247  static inline int bap_read(struct airo_info *ai, u16 *pu16Dst, int bytelen,
52248 @@ -1079,7 +1085,462 @@
52249                                 struct airo_info *apriv );
52250  
52251  #ifdef MICSUPPORT
52252 -#include "mic.h"
52253 +/***********************************************************************
52254 + *                              MIC ROUTINES                           *
52255 + ***********************************************************************
52256 + */
52257 +
52258 +static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq);
52259 +static void MoveWindow(miccntx *context, u32 micSeq);
52260 +void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *);
52261 +void emmh32_init(emmh32_context *context);
52262 +void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
52263 +void emmh32_final(emmh32_context *context, u8 digest[4]);
52264 +
52265 +/* micinit - Initialize mic seed */
52266 +
52267 +static void micinit(struct airo_info *ai)
52268 +{
52269 +       MICRid mic_rid;
52270 +
52271 +       clear_bit(JOB_MIC, &ai->flags);
52272 +       PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0);
52273 +       up(&ai->sem);
52274 +
52275 +       ai->micstats.enabled = (mic_rid.state & 0x00FF) ? 1 : 0;
52276 +
52277 +       if (ai->micstats.enabled) {
52278 +               /* Key must be valid and different */
52279 +               if (mic_rid.multicastValid && (!ai->mod[0].mCtx.valid ||
52280 +                   (memcmp (ai->mod[0].mCtx.key, mic_rid.multicast,
52281 +                            sizeof(ai->mod[0].mCtx.key)) != 0))) {
52282 +                       /* Age current mic Context */
52283 +                       memcpy(&ai->mod[1].mCtx,&ai->mod[0].mCtx,sizeof(miccntx));
52284 +                       /* Initialize new context */
52285 +                       memcpy(&ai->mod[0].mCtx.key,mic_rid.multicast,sizeof(mic_rid.multicast));
52286 +                       ai->mod[0].mCtx.window  = 33; //Window always points to the middle
52287 +                       ai->mod[0].mCtx.rx      = 0;  //Rx Sequence numbers
52288 +                       ai->mod[0].mCtx.tx      = 0;  //Tx sequence numbers
52289 +                       ai->mod[0].mCtx.valid   = 1;  //Key is now valid
52290 +  
52291 +                       /* Give key to mic seed */
52292 +                       emmh32_setseed(&ai->mod[0].mCtx.seed,mic_rid.multicast,sizeof(mic_rid.multicast), ai->tfm);
52293 +               }
52294 +
52295 +               /* Key must be valid and different */
52296 +               if (mic_rid.unicastValid && (!ai->mod[0].uCtx.valid || 
52297 +                   (memcmp(ai->mod[0].uCtx.key, mic_rid.unicast,
52298 +                           sizeof(ai->mod[0].uCtx.key)) != 0))) {
52299 +                       /* Age current mic Context */
52300 +                       memcpy(&ai->mod[1].uCtx,&ai->mod[0].uCtx,sizeof(miccntx));
52301 +                       /* Initialize new context */
52302 +                       memcpy(&ai->mod[0].uCtx.key,mic_rid.unicast,sizeof(mic_rid.unicast));
52303 +       
52304 +                       ai->mod[0].uCtx.window  = 33; //Window always points to the middle
52305 +                       ai->mod[0].uCtx.rx      = 0;  //Rx Sequence numbers
52306 +                       ai->mod[0].uCtx.tx      = 0;  //Tx sequence numbers
52307 +                       ai->mod[0].uCtx.valid   = 1;  //Key is now valid
52308 +       
52309 +                       //Give key to mic seed
52310 +                       emmh32_setseed(&ai->mod[0].uCtx.seed, mic_rid.unicast, sizeof(mic_rid.unicast), ai->tfm);
52311 +               }
52312 +       } else {
52313 +      /* So next time we have a valid key and mic is enabled, we will update
52314 +       * the sequence number if the key is the same as before.
52315 +       */
52316 +               ai->mod[0].uCtx.valid = 0;
52317 +               ai->mod[0].mCtx.valid = 0;
52318 +       }
52319 +}
52320 +
52321 +/* micsetup - Get ready for business */
52322 +
52323 +static int micsetup(struct airo_info *ai) {
52324 +       int i;
52325 +
52326 +       if (ai->tfm == NULL)
52327 +               ai->tfm = crypto_alloc_tfm("aes", 0);
52328 +
52329 +        if (ai->tfm == NULL) {
52330 +                printk(KERN_ERR "airo: failed to load transform for AES\n");
52331 +                return ERROR;
52332 +        }
52333 +
52334 +       for (i=0; i < NUM_MODULES; i++) {
52335 +               memset(&ai->mod[i].mCtx,0,sizeof(miccntx));
52336 +               memset(&ai->mod[i].uCtx,0,sizeof(miccntx));
52337 +       }
52338 +       return SUCCESS;
52339 +}
52340 +
52341 +char micsnap[]= {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02};
52342 +
52343 +/*===========================================================================
52344 + * Description: Mic a packet
52345 + *    
52346 + *      Inputs: etherHead * pointer to an 802.3 frame
52347 + *    
52348 + *     Returns: BOOLEAN if successful, otherwise false.
52349 + *             PacketTxLen will be updated with the mic'd packets size.
52350 + *
52351 + *    Caveats: It is assumed that the frame buffer will already
52352 + *             be big enough to hold the largets mic message possible.
52353 + *            (No memory allocation is done here).
52354 + *  
52355 + *    Author: sbraneky (10/15/01)
52356 + *    Merciless hacks by rwilcher (1/14/02)
52357 + */
52358 +
52359 +static int encapsulate(struct airo_info *ai ,etherHead *frame, MICBuffer *mic, int payLen)
52360 +{
52361 +       miccntx   *context;
52362 +
52363 +       // Determine correct context
52364 +       // If not adhoc, always use unicast key
52365 +
52366 +       if (test_bit(FLAG_ADHOC, &ai->flags) && (frame->da[0] & 0x1))
52367 +               context = &ai->mod[0].mCtx;
52368 +       else
52369 +               context = &ai->mod[0].uCtx;
52370 +  
52371 +       if (!context->valid)
52372 +               return ERROR;
52373 +
52374 +       mic->typelen = htons(payLen + 16); //Length of Mic'd packet
52375 +
52376 +       memcpy(&mic->u.snap, micsnap, sizeof(micsnap)); // Add Snap
52377 +
52378 +       // Add Tx sequence
52379 +       mic->seq = htonl(context->tx);
52380 +       context->tx += 2;
52381 +
52382 +       emmh32_init(&context->seed); // Mic the packet
52383 +       emmh32_update(&context->seed,frame->da,ETH_ALEN * 2); // DA,SA
52384 +       emmh32_update(&context->seed,(u8*)&mic->typelen,10); // Type/Length and Snap
52385 +       emmh32_update(&context->seed,(u8*)&mic->seq,sizeof(mic->seq)); //SEQ
52386 +       emmh32_update(&context->seed,frame->da + ETH_ALEN * 2,payLen); //payload
52387 +       emmh32_final(&context->seed, (u8*)&mic->mic);
52388 +
52389 +       /*    New Type/length ?????????? */
52390 +       mic->typelen = 0; //Let NIC know it could be an oversized packet
52391 +       return SUCCESS;
52392 +}
52393 +
52394 +typedef enum {
52395 +    NONE,
52396 +    NOMIC,
52397 +    NOMICPLUMMED,
52398 +    SEQUENCE,
52399 +    INCORRECTMIC,
52400 +} mic_error;
52401 +
52402 +/*===========================================================================
52403 + *  Description: Decapsulates a MIC'd packet and returns the 802.3 packet
52404 + *               (removes the MIC stuff) if packet is a valid packet.
52405 + *      
52406 + *       Inputs: etherHead  pointer to the 802.3 packet             
52407 + *     
52408 + *      Returns: BOOLEAN - TRUE if packet should be dropped otherwise FALSE
52409 + *     
52410 + *      Author: sbraneky (10/15/01)
52411 + *    Merciless hacks by rwilcher (1/14/02)
52412 + *---------------------------------------------------------------------------
52413 + */
52414 +
52415 +static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16 payLen)
52416 +{
52417 +       int      i;
52418 +       u32      micSEQ;
52419 +       miccntx  *context;
52420 +       u8       digest[4];
52421 +       mic_error micError = NONE;
52422 +
52423 +       // Check if the packet is a Mic'd packet
52424 +
52425 +       if (!ai->micstats.enabled) {
52426 +               //No Mic set or Mic OFF but we received a MIC'd packet.
52427 +               if (memcmp ((u8*)eth + 14, micsnap, sizeof(micsnap)) == 0) {
52428 +                       ai->micstats.rxMICPlummed++;
52429 +                       return ERROR;
52430 +               }
52431 +               return SUCCESS;
52432 +       }
52433 +
52434 +       if (ntohs(mic->typelen) == 0x888E)
52435 +               return SUCCESS;
52436 +
52437 +       if (memcmp (mic->u.snap, micsnap, sizeof(micsnap)) != 0) {
52438 +           // Mic enabled but packet isn't Mic'd
52439 +               ai->micstats.rxMICPlummed++;
52440 +               return ERROR;
52441 +       }
52442 +
52443 +       micSEQ = ntohl(mic->seq);            //store SEQ as CPU order
52444 +
52445 +       //At this point we a have a mic'd packet and mic is enabled
52446 +       //Now do the mic error checking.
52447 +
52448 +       //Receive seq must be odd
52449 +       if ( (micSEQ & 1) == 0 ) {
52450 +               ai->micstats.rxWrongSequence++;
52451 +               return ERROR;
52452 +       }
52453 +
52454 +       for (i = 0; i < NUM_MODULES; i++) {
52455 +               int mcast = eth->da[0] & 1;
52456 +               //Determine proper context 
52457 +               context = mcast ? &ai->mod[i].mCtx : &ai->mod[i].uCtx;
52458 +       
52459 +               //Make sure context is valid
52460 +               if (!context->valid) {
52461 +                       if (i == 0)
52462 +                               micError = NOMICPLUMMED;
52463 +                       continue;                
52464 +               }
52465 +               //DeMic it 
52466 +
52467 +               if (!mic->typelen)
52468 +                       mic->typelen = htons(payLen + sizeof(MICBuffer) - 2);
52469 +       
52470 +               emmh32_init(&context->seed);
52471 +               emmh32_update(&context->seed, eth->da, ETH_ALEN*2); 
52472 +               emmh32_update(&context->seed, (u8 *)&mic->typelen, sizeof(mic->typelen)+sizeof(mic->u.snap)); 
52473 +               emmh32_update(&context->seed, (u8 *)&mic->seq,sizeof(mic->seq));        
52474 +               emmh32_update(&context->seed, eth->da + ETH_ALEN*2,payLen);     
52475 +               //Calculate MIC
52476 +               emmh32_final(&context->seed, digest);
52477 +       
52478 +               if (memcmp(digest, &mic->mic, 4)) { //Make sure the mics match
52479 +                 //Invalid Mic
52480 +                       if (i == 0)
52481 +                               micError = INCORRECTMIC;
52482 +                       continue;
52483 +               }
52484 +
52485 +               //Check Sequence number if mics pass
52486 +               if (RxSeqValid(ai, context, mcast, micSEQ) == SUCCESS) {
52487 +                       ai->micstats.rxSuccess++;
52488 +                       return SUCCESS;
52489 +               }
52490 +               if (i == 0)
52491 +                       micError = SEQUENCE;
52492 +       }
52493 +
52494 +       // Update statistics
52495 +       switch (micError) {
52496 +               case NOMICPLUMMED: ai->micstats.rxMICPlummed++;   break;
52497 +               case SEQUENCE:    ai->micstats.rxWrongSequence++; break;
52498 +               case INCORRECTMIC: ai->micstats.rxIncorrectMIC++; break;
52499 +               case NONE:  break;
52500 +               case NOMIC: break;
52501 +       }
52502 +       return ERROR;
52503 +}
52504 +
52505 +/*===========================================================================
52506 + * Description:  Checks the Rx Seq number to make sure it is valid
52507 + *               and hasn't already been received
52508 + *   
52509 + *     Inputs: miccntx - mic context to check seq against
52510 + *             micSeq  - the Mic seq number
52511 + *   
52512 + *    Returns: TRUE if valid otherwise FALSE. 
52513 + *
52514 + *    Author: sbraneky (10/15/01)
52515 + *    Merciless hacks by rwilcher (1/14/02)
52516 + *---------------------------------------------------------------------------
52517 + */
52518 +
52519 +static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq)
52520 +{
52521 +       u32 seq,index;
52522 +
52523 +       //Allow for the ap being rebooted - if it is then use the next 
52524 +       //sequence number of the current sequence number - might go backwards
52525 +
52526 +       if (mcast) {
52527 +               if (test_bit(FLAG_UPDATE_MULTI, &ai->flags)) {
52528 +                       clear_bit (FLAG_UPDATE_MULTI, &ai->flags);
52529 +                       context->window = (micSeq > 33) ? micSeq : 33;
52530 +                       context->rx     = 0;        // Reset rx
52531 +               }
52532 +       } else if (test_bit(FLAG_UPDATE_UNI, &ai->flags)) {
52533 +               clear_bit (FLAG_UPDATE_UNI, &ai->flags);
52534 +               context->window = (micSeq > 33) ? micSeq : 33; // Move window
52535 +               context->rx     = 0;        // Reset rx
52536 +       }
52537 +
52538 +       //Make sequence number relative to START of window
52539 +       seq = micSeq - (context->window - 33);
52540 +
52541 +       //Too old of a SEQ number to check.
52542 +       if ((u32)seq < 0)
52543 +               return ERROR;
52544 +    
52545 +       if ( seq > 64 ) {
52546 +               //Window is infinite forward
52547 +               MoveWindow(context,micSeq);
52548 +               return SUCCESS;
52549 +       }
52550 +
52551 +       // We are in the window. Now check the context rx bit to see if it was already sent
52552 +       seq >>= 1;         //divide by 2 because we only have odd numbers
52553 +       index = 1 << seq;  //Get an index number
52554 +
52555 +       if (!(context->rx & index)) {
52556 +               //micSEQ falls inside the window.
52557 +               //Add seqence number to the list of received numbers.
52558 +               context->rx |= index;
52559 +
52560 +               MoveWindow(context,micSeq);
52561 +
52562 +               return SUCCESS;
52563 +       }
52564 +       return ERROR;
52565 +}
52566 +
52567 +static void MoveWindow(miccntx *context, u32 micSeq)
52568 +{
52569 +       u32 shift;
52570 +
52571 +       //Move window if seq greater than the middle of the window
52572 +       if (micSeq > context->window) {
52573 +               shift = (micSeq - context->window) >> 1;
52574 +    
52575 +                   //Shift out old
52576 +               if (shift < 32)
52577 +                       context->rx >>= shift;
52578 +               else
52579 +                       context->rx = 0;
52580 +
52581 +               context->window = micSeq;      //Move window
52582 +       }
52583 +}
52584 +
52585 +/*==============================================*/
52586 +/*========== EMMH ROUTINES  ====================*/
52587 +/*==============================================*/
52588 +
52589 +/* mic accumulate */
52590 +#define MIC_ACCUM(val) \
52591 +       context->accum += (u64)(val) * context->coeff[coeff_position++];
52592 +
52593 +static unsigned char aes_counter[16];
52594 +
52595 +/* expand the key to fill the MMH coefficient array */
52596 +void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *tfm)
52597 +{
52598 +  /* take the keying material, expand if necessary, truncate at 16-bytes */
52599 +  /* run through AES counter mode to generate context->coeff[] */
52600 +  
52601 +       int i,j;
52602 +       u32 counter;
52603 +       u8 *cipher;
52604 +       struct scatterlist sg[1];
52605 +
52606 +       crypto_cipher_setkey(tfm, pkey, 16);
52607 +       counter = 0;
52608 +       for (i = 0; i < (sizeof(context->coeff)/sizeof(context->coeff[0])); ) {
52609 +               aes_counter[15] = (u8)(counter >> 0);
52610 +               aes_counter[14] = (u8)(counter >> 8);
52611 +               aes_counter[13] = (u8)(counter >> 16);
52612 +               aes_counter[12] = (u8)(counter >> 24);
52613 +               counter++;
52614 +               sg[0].page = virt_to_page(aes_counter);
52615 +               sg[0].offset = ((long) aes_counter & ~PAGE_MASK);
52616 +               sg[0].length = 16;
52617 +               crypto_cipher_encrypt(tfm, sg, sg, 16);
52618 +               cipher = kmap(sg[0].page) + sg[0].offset;
52619 +               for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) {
52620 +                       context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
52621 +                       j += 4;
52622 +               }
52623 +       }
52624 +}
52625 +
52626 +/* prepare for calculation of a new mic */
52627 +void emmh32_init(emmh32_context *context)
52628 +{
52629 +       /* prepare for new mic calculation */
52630 +       context->accum = 0;
52631 +       context->position = 0;
52632 +}
52633 +
52634 +/* add some bytes to the mic calculation */
52635 +void emmh32_update(emmh32_context *context, u8 *pOctets, int len)
52636 +{
52637 +       int     coeff_position, byte_position;
52638 +  
52639 +       if (len == 0) return;
52640 +  
52641 +       coeff_position = context->position >> 2;
52642 +  
52643 +       /* deal with partial 32-bit word left over from last update */
52644 +       byte_position = context->position & 3;
52645 +       if (byte_position) {
52646 +               /* have a partial word in part to deal with */
52647 +               do {
52648 +                       if (len == 0) return;
52649 +                       context->part.d8[byte_position++] = *pOctets++;
52650 +                       context->position++;
52651 +                       len--;
52652 +               } while (byte_position < 4);
52653 +               MIC_ACCUM(htonl(context->part.d32));
52654 +       }
52655 +
52656 +       /* deal with full 32-bit words */
52657 +       while (len >= 4) {
52658 +               MIC_ACCUM(htonl(*(u32 *)pOctets));
52659 +               context->position += 4;
52660 +               pOctets += 4;
52661 +               len -= 4;
52662 +       }
52663 +
52664 +       /* deal with partial 32-bit word that will be left over from this update */
52665 +       byte_position = 0;
52666 +       while (len > 0) {
52667 +               context->part.d8[byte_position++] = *pOctets++;
52668 +               context->position++;
52669 +               len--;
52670 +       }
52671 +}
52672 +
52673 +/* mask used to zero empty bytes for final partial word */
52674 +static u32 mask32[4] = { 0x00000000L, 0xFF000000L, 0xFFFF0000L, 0xFFFFFF00L };
52675 +
52676 +/* calculate the mic */
52677 +void emmh32_final(emmh32_context *context, u8 digest[4])
52678 +{
52679 +       int     coeff_position, byte_position;
52680 +       u32     val;
52681 +  
52682 +       u64 sum, utmp;
52683 +       s64 stmp;
52684 +
52685 +       coeff_position = context->position >> 2;
52686 +  
52687 +       /* deal with partial 32-bit word left over from last update */
52688 +       byte_position = context->position & 3;
52689 +       if (byte_position) {
52690 +               /* have a partial word in part to deal with */
52691 +               val = htonl(context->part.d32);
52692 +               MIC_ACCUM(val & mask32[byte_position]); /* zero empty bytes */
52693 +       }
52694 +
52695 +       /* reduce the accumulated u64 to a 32-bit MIC */
52696 +       sum = context->accum;
52697 +       stmp = (sum  & 0xffffffffLL) - ((sum >> 32)  * 15);
52698 +       utmp = (stmp & 0xffffffffLL) - ((stmp >> 32) * 15);
52699 +       sum = utmp & 0xffffffffLL;
52700 +       if (utmp > 0x10000000fLL)
52701 +               sum -= 15;
52702 +
52703 +       val = (u32)sum;
52704 +       digest[0] = (val>>24) & 0xFF;
52705 +       digest[1] = (val>>16) & 0xFF;
52706 +       digest[2] = (val>>8) & 0xFF;
52707 +       digest[3] = val & 0xFF;
52708 +}
52709  #endif
52710  
52711  static int readBSSListRid(struct airo_info *ai, int first,
52712 @@ -1556,6 +2017,7 @@
52713         struct sockaddr *addr = p;
52714         Resp rsp;
52715  
52716 +       readConfigRid(ai, 1);
52717         memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len);
52718         ai->need_commit = 1;
52719         disable_MAC(ai, 1);
52720 @@ -1624,6 +2086,10 @@
52721                 /* PCMCIA frees this stuff, so only for PCI and ISA */
52722                 release_region( dev->base_addr, 64 );
52723          }
52724 +#ifdef MICSUPPORT
52725 +       if (ai->tfm)
52726 +               crypto_free_tfm(ai->tfm);
52727 +#endif
52728         del_airo_dev( dev );
52729         free_netdev( dev );
52730  }
52731 @@ -1725,6 +2191,9 @@
52732         ai->thr_pid = kernel_thread(airo_thread, dev, CLONE_FS | CLONE_FILES);
52733         if (ai->thr_pid < 0)
52734                 goto err_out_free;
52735 +#ifdef MICSUPPORT
52736 +       ai->tfm = NULL;
52737 +#endif
52738         rc = add_airo_dev( dev );
52739         if (rc)
52740                 goto err_out_thr;
52741 @@ -2125,146 +2594,151 @@
52742  
52743                         if (len > 2312) {
52744                                 printk( KERN_ERR "airo: Bad size %d\n", len );
52745 -                               len = 0;
52746 +                               goto badrx;
52747                         }
52748 -                       if (len) {
52749 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
52750 -                                       bap_read (apriv, (u16*)&fc, sizeof(fc), BAP0);
52751 -                                       fc = le16_to_cpu(fc);
52752 -                                       switch (fc & 0xc) {
52753 -                                               case 4:
52754 -                                                       if ((fc & 0xe0) == 0xc0)
52755 -                                                               hdrlen = 10;
52756 -                                                       else
52757 -                                                               hdrlen = 16;
52758 -                                                       break;
52759 -                                               case 8:
52760 -                                                       if ((fc&0x300)==0x300){
52761 -                                                               hdrlen = 30;
52762 -                                                               break;
52763 -                                                       }
52764 -                                               default:
52765 -                                                       hdrlen = 24;
52766 -                                       }
52767 -                               } else
52768 -                                       hdrlen = ETH_ALEN * 2;
52769 +                       if (len == 0)
52770 +                               goto badrx;
52771  
52772 -                               skb = dev_alloc_skb( len + hdrlen + 2 );
52773 -                               if ( !skb ) {
52774 -                                       apriv->stats.rx_dropped++;
52775 -                                       len = 0;
52776 -                               }
52777 -                       }
52778 -                       if (len) {
52779 -                               buffer = (u16*)skb_put (skb, len + hdrlen);
52780 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
52781 -                                       buffer[0] = fc;
52782 -                                       bap_read (apriv, buffer + 1, hdrlen - 2, BAP0);
52783 -                                       if (hdrlen == 24)
52784 -                                               bap_read (apriv, tmpbuf, 6, BAP0);
52785 -
52786 -                                       bap_read (apriv, &gap, sizeof(gap), BAP0);
52787 -                                       gap = le16_to_cpu(gap);
52788 -                                       if (gap) {
52789 -                                               if (gap <= 8)
52790 -                                                       bap_read (apriv, tmpbuf, gap, BAP0);
52791 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
52792 +                               bap_read (apriv, (u16*)&fc, sizeof(fc), BAP0);
52793 +                               fc = le16_to_cpu(fc);
52794 +                               switch (fc & 0xc) {
52795 +                                       case 4:
52796 +                                               if ((fc & 0xe0) == 0xc0)
52797 +                                                       hdrlen = 10;
52798                                                 else
52799 -                                                       printk(KERN_ERR "airo: gaplen too big. Problems will follow...\n");
52800 -                                       }
52801 +                                                       hdrlen = 16;
52802 +                                               break;
52803 +                                       case 8:
52804 +                                               if ((fc&0x300)==0x300){
52805 +                                                       hdrlen = 30;
52806 +                                                       break;
52807 +                                               }
52808 +                                       default:
52809 +                                               hdrlen = 24;
52810 +                               }
52811 +                       } else
52812 +                               hdrlen = ETH_ALEN * 2;
52813  
52814 +                       skb = dev_alloc_skb( len + hdrlen + 2 );
52815 +                       if ( !skb ) {
52816 +                               apriv->stats.rx_dropped++;
52817 +                               goto badrx;
52818 +                       }
52819 +                       buffer = (u16*)skb_put (skb, len + hdrlen);
52820 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
52821 +                               buffer[0] = fc;
52822 +                               bap_read (apriv, buffer + 1, hdrlen - 2, BAP0);
52823 +                               if (hdrlen == 24)
52824 +                                       bap_read (apriv, tmpbuf, 6, BAP0);
52825 +
52826 +                               bap_read (apriv, &gap, sizeof(gap), BAP0);
52827 +                               gap = le16_to_cpu(gap);
52828 +                               if (gap) {
52829 +                                       if (gap <= 8)
52830 +                                               bap_read (apriv, tmpbuf, gap, BAP0);
52831 +                                       else
52832 +                                               printk(KERN_ERR "airo: gaplen too big. Problems will follow...\n");
52833 +                               }
52834 +                               bap_read (apriv, buffer + hdrlen/2, len, BAP0);
52835 +                       } else {
52836 +#ifdef MICSUPPORT
52837 +                               MICBuffer micbuf;
52838 +#endif
52839 +                               bap_read (apriv, buffer, ETH_ALEN*2, BAP0);
52840 +#ifdef MICSUPPORT
52841 +                               if (apriv->micstats.enabled) {
52842 +                                       bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0);
52843 +                                       if (ntohs(micbuf.typelen) > 0x05DC)
52844 +                                               bap_setup (apriv, fid, 0x44, BAP0);
52845 +                                       else {
52846 +                                               if (len <= sizeof(micbuf))
52847 +                                                       goto badmic;
52848  
52849 -                                       bap_read (apriv, buffer + hdrlen/2, len, BAP0);
52850 -                               } else {
52851 -                                       MICBuffer micbuf;
52852 -                                       bap_read (apriv, buffer, ETH_ALEN*2, BAP0);
52853 -                                       if (apriv->micstats.enabled) {
52854 -                                               bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0);
52855 -                                               if (ntohs(micbuf.typelen) > 0x05DC)
52856 -                                                       bap_setup (apriv, fid, 0x44, BAP0);
52857 -                                               else {
52858 -                                                       len -= sizeof(micbuf);
52859 -                                                       if (len < 48)
52860 -                                                               len = 48;
52861 -                                                       skb_trim (skb, len + hdrlen);
52862 -                                               }
52863 +                                               len -= sizeof(micbuf);
52864 +                                               skb_trim (skb, len + hdrlen);
52865                                         }
52866 -                                       bap_read(apriv,buffer+ETH_ALEN,len,BAP0);
52867 +                               }
52868 +#endif
52869 +                               bap_read(apriv,buffer+ETH_ALEN,len,BAP0);
52870  #ifdef MICSUPPORT
52871 -                                       if (decapsulate(apriv,&micbuf,(etherHead*)buffer,len)) {
52872 -                                               dev_kfree_skb_irq (skb);
52873 -                                               len = 0;
52874 -                                       }
52875 +                               if (decapsulate(apriv,&micbuf,(etherHead*)buffer,len)) {
52876 +badmic:
52877 +                                       dev_kfree_skb_irq (skb);
52878 +#else
52879 +                               if (0) {
52880  #endif
52881 +badrx:
52882 +                                       OUT4500( apriv, EVACK, EV_RX);
52883 +                                       goto exitrx;
52884                                 }
52885                         }
52886 -                       if (len) {
52887  #if WIRELESS_EXT > 15
52888  #ifdef IW_WIRELESS_SPY         /* defined in iw_handler.h */
52889 -                               if (apriv->spy_data.spy_number > 0) {
52890 -                                       char *sa;
52891 -                                       struct iw_quality wstats;
52892 -                                       /* Prepare spy data : addr + qual */
52893 -                                       if (!test_bit(FLAG_802_11, &apriv->flags)) {
52894 -                                               sa = (char*)buffer + 6;
52895 -                                               bap_setup (apriv, fid, 8, BAP0);
52896 -                                               bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
52897 -                                       } else
52898 -                                               sa = (char*)buffer + 10;
52899 -                                       wstats.qual = hdr.rssi[0];
52900 -                                       if (apriv->rssi)
52901 -                                               wstats.level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
52902 -                                       else
52903 -                                               wstats.level = (hdr.rssi[1] + 321) / 2;
52904 -                                       wstats.updated = 3;     
52905 -                                       /* Update spy records */
52906 -                                       wireless_spy_update(dev, sa, &wstats);
52907 -                               }
52908 +                       if (apriv->spy_data.spy_number > 0) {
52909 +                               char *sa;
52910 +                               struct iw_quality wstats;
52911 +                               /* Prepare spy data : addr + qual */
52912 +                               if (!test_bit(FLAG_802_11, &apriv->flags)) {
52913 +                                       sa = (char*)buffer + 6;
52914 +                                       bap_setup (apriv, fid, 8, BAP0);
52915 +                                       bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
52916 +                               } else
52917 +                                       sa = (char*)buffer + 10;
52918 +                               wstats.qual = hdr.rssi[0];
52919 +                               if (apriv->rssi)
52920 +                                       wstats.level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
52921 +                               else
52922 +                                       wstats.level = (hdr.rssi[1] + 321) / 2;
52923 +                               wstats.updated = 3;     
52924 +                               /* Update spy records */
52925 +                               wireless_spy_update(dev, sa, &wstats);
52926 +                       }
52927  #endif /* IW_WIRELESS_SPY */
52928  #else /* WIRELESS_EXT > 15 */
52929  #ifdef WIRELESS_SPY
52930 -                               if (apriv->spy_number > 0) {
52931 -                                       int i;
52932 -                                       char *sa;
52933 -
52934 -                                       sa = (char*)buffer + (test_bit(FLAG_802_11, &apriv->flags) ? 10 : 6);
52935 -
52936 -                                       for (i=0; i<apriv->spy_number; i++)
52937 -                                               if (!memcmp(sa,apriv->spy_address[i],ETH_ALEN))
52938 -                                               {
52939 -                                                       if (!test_bit(FLAG_802_11, &apriv->flags)) {
52940 -                                                               bap_setup (apriv, fid, 8, BAP0);
52941 -                                                               bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
52942 -                                                       }
52943 -                                                       apriv->spy_stat[i].qual = hdr.rssi[0];
52944 -                                                       if (apriv->rssi)
52945 -                                                               apriv->spy_stat[i].level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
52946 -                                                       else
52947 -                                                               apriv->spy_stat[i].level = (hdr.rssi[1] + 321) / 2;
52948 -                                                       apriv->spy_stat[i].noise = 0;
52949 -                                                       apriv->spy_stat[i].updated = 3;
52950 -                                                       break;
52951 +                       if (apriv->spy_number > 0) {
52952 +                               int i;
52953 +                               char *sa;
52954 +
52955 +                               sa = (char*)buffer + (test_bit(FLAG_802_11, &apriv->flags) ? 10 : 6);
52956 +
52957 +                               for (i=0; i<apriv->spy_number; i++)
52958 +                                       if (!memcmp(sa,apriv->spy_address[i],ETH_ALEN))
52959 +                                       {
52960 +                                               if (!test_bit(FLAG_802_11, &apriv->flags)) {
52961 +                                                       bap_setup (apriv, fid, 8, BAP0);
52962 +                                                       bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
52963                                                 }
52964 -                               }
52965 +                                               apriv->spy_stat[i].qual = hdr.rssi[0];
52966 +                                               if (apriv->rssi)
52967 +                                                       apriv->spy_stat[i].level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
52968 +                                               else
52969 +                                                       apriv->spy_stat[i].level = (hdr.rssi[1] + 321) / 2;
52970 +                                               apriv->spy_stat[i].noise = 0;
52971 +                                               apriv->spy_stat[i].updated = 3;
52972 +                                               break;
52973 +                                       }
52974 +                       }
52975  #endif /* WIRELESS_SPY  */
52976  #endif /* WIRELESS_EXT > 15 */
52977 -                               OUT4500( apriv, EVACK, EV_RX);
52978 +                       OUT4500( apriv, EVACK, EV_RX);
52979  
52980 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
52981 -                                       skb->mac.raw = skb->data;
52982 -                                       skb->pkt_type = PACKET_OTHERHOST;
52983 -                                       skb->dev = apriv->wifidev;
52984 -                                       skb->protocol = htons(ETH_P_802_2);
52985 -                               } else {
52986 -                                       skb->dev = dev;
52987 -                                       skb->protocol = eth_type_trans(skb,dev);
52988 -                               }
52989 -                               skb->dev->last_rx = jiffies;
52990 -                               skb->ip_summed = CHECKSUM_NONE;
52991 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
52992 +                               skb->mac.raw = skb->data;
52993 +                               skb->pkt_type = PACKET_OTHERHOST;
52994 +                               skb->dev = apriv->wifidev;
52995 +                               skb->protocol = htons(ETH_P_802_2);
52996 +                       } else {
52997 +                               skb->dev = dev;
52998 +                               skb->protocol = eth_type_trans(skb,dev);
52999 +                       }
53000 +                       skb->dev->last_rx = jiffies;
53001 +                       skb->ip_summed = CHECKSUM_NONE;
53002  
53003 -                               netif_rx( skb );
53004 -                       } else
53005 -                               OUT4500( apriv, EVACK, EV_RX);
53006 +                       netif_rx( skb );
53007                 }
53008 +exitrx:
53009  
53010                 /* Check to see if a packet has been transmitted */
53011                 if (  status & ( EV_TX|EV_TXEXC ) ) {
53012 @@ -2469,6 +2943,9 @@
53013                                 printk(KERN_WARNING "airo: unknown received signal level scale\n");
53014                 }
53015                 ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS;
53016 +               ai->config.authType = AUTH_OPEN;
53017 +               ai->config.modulation = MOD_CCK;
53018 +               ai->config._reserved1a[0] = 2; /* ??? */
53019  
53020  #ifdef MICSUPPORT
53021                 if ((cap_rid.len>=sizeof(cap_rid)) && (cap_rid.extSoftCap&1) &&
53022 @@ -2515,6 +2992,7 @@
53023                         memcpy(mySsid.ssids[i].ssid, ssids[i],
53024                                mySsid.ssids[i].len);
53025                 }
53026 +               mySsid.len = sizeof(mySsid);
53027         }
53028  
53029         status = writeConfigRid(ai, 1);
53030 @@ -3692,6 +4170,8 @@
53031                        offset < data->writelen ) offset++;
53032                 offset++;
53033         }
53034 +       if (i)
53035 +               SSID_rid.len = sizeof(SSID_rid);
53036         disable_MAC(ai, 1);
53037         writeSsidRid(ai, &SSID_rid);
53038         enable_MAC(ai, &rsp, 1);
53039 @@ -4156,7 +4636,7 @@
53040  
53041  static int __init airo_init_module( void )
53042  {
53043 -       int i, rc = 0, have_isa_dev = 0;
53044 +       int i, have_isa_dev = 0;
53045  
53046         airo_entry = create_proc_entry("aironet",
53047                                        S_IFDIR | airo_perm,
53048 @@ -4174,7 +4654,7 @@
53049  
53050  #ifdef CONFIG_PCI
53051         printk( KERN_INFO "airo:  Probing for PCI adapters\n" );
53052 -       rc = pci_module_init(&airo_driver);
53053 +       pci_module_init(&airo_driver);
53054         printk( KERN_INFO "airo:  Finished probing for PCI adapters\n" );
53055  #endif
53056  
53057 @@ -4197,8 +4677,11 @@
53058         }
53059         remove_proc_entry("aironet", proc_root_driver);
53060  
53061 -       if (is_pci)
53062 +       if (is_pci) {
53063 +#ifdef CONFIG_PCI
53064                 pci_unregister_driver(&airo_driver);
53065 +#endif
53066 +       }
53067  }
53068  
53069  #ifdef WIRELESS_EXT
53070 @@ -4260,6 +4743,7 @@
53071                         printk(KERN_DEBUG "%s: New channel value of %d is invalid!\n", dev->name, fwrq->m);
53072                         rc = -EINVAL;
53073                 } else {
53074 +                       readConfigRid(local, 1);
53075                         /* Yes ! We can set it !!! */
53076                         local->config.channelSet = (u16)(channel - 1);
53077                         local->need_commit = 1;
53078 @@ -4280,6 +4764,7 @@
53079         struct airo_info *local = dev->priv;
53080         StatusRid status_rid;           /* Card status info */
53081  
53082 +       readConfigRid(local, 1);
53083         if ((local->config.opmode & 0xFF) == MODE_STA_ESS)
53084                 status_rid.channel = local->config.channelSet;
53085         else
53086 @@ -4336,6 +4821,7 @@
53087                        sizeof(SSID_rid.ssids[index].ssid));
53088                 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length);
53089                 SSID_rid.ssids[index].len = dwrq->length - 1;
53090 +               SSID_rid.len = sizeof(SSID_rid);
53091         }
53092         /* Write it to the card */
53093         disable_MAC(local, 1);
53094 @@ -4445,6 +4931,7 @@
53095         if(dwrq->length > 16 + 1) {
53096                 return -E2BIG;
53097         }
53098 +       readConfigRid(local, 1);
53099         memset(local->config.nodeName, 0, sizeof(local->config.nodeName));
53100         memcpy(local->config.nodeName, extra, dwrq->length);
53101         local->need_commit = 1;
53102 @@ -4463,6 +4950,7 @@
53103  {
53104         struct airo_info *local = dev->priv;
53105  
53106 +       readConfigRid(local, 1);
53107         strncpy(extra, local->config.nodeName, 16);
53108         extra[16] = '\0';
53109         dwrq->length = strlen(extra) + 1;
53110 @@ -4519,6 +5007,7 @@
53111                 return -EINVAL;
53112         }
53113  
53114 +       readConfigRid(local, 1);
53115         /* Now, check if we want a fixed or auto value */
53116         if(vwrq->fixed == 0) {
53117                 /* Fill all the rates up to this max rate */
53118 @@ -4555,6 +5044,7 @@
53119  
53120         vwrq->value = status_rid.currentXmitRate * 500000;
53121         /* If more than one rate, set auto */
53122 +       readConfigRid(local, 1);
53123         vwrq->fixed = (local->config.rates[1] == 0);
53124  
53125         return 0;
53126 @@ -4577,6 +5067,7 @@
53127         if((rthr < 0) || (rthr > 2312)) {
53128                 return -EINVAL;
53129         }
53130 +       readConfigRid(local, 1);
53131         local->config.rtsThres = rthr;
53132         local->need_commit = 1;
53133  
53134 @@ -4594,6 +5085,7 @@
53135  {
53136         struct airo_info *local = dev->priv;
53137  
53138 +       readConfigRid(local, 1);
53139         vwrq->value = local->config.rtsThres;
53140         vwrq->disabled = (vwrq->value >= 2312);
53141         vwrq->fixed = 1;
53142 @@ -4619,6 +5111,7 @@
53143                 return -EINVAL;
53144         }
53145         fthr &= ~0x1;   /* Get an even value - is it really needed ??? */
53146 +       readConfigRid(local, 1);
53147         local->config.fragThresh = (u16)fthr;
53148         local->need_commit = 1;
53149  
53150 @@ -4636,6 +5129,7 @@
53151  {
53152         struct airo_info *local = dev->priv;
53153  
53154 +       readConfigRid(local, 1);
53155         vwrq->value = local->config.fragThresh;
53156         vwrq->disabled = (vwrq->value >= 2312);
53157         vwrq->fixed = 1;
53158 @@ -4655,6 +5149,7 @@
53159         struct airo_info *local = dev->priv;
53160         int commit = 1;
53161  
53162 +       readConfigRid(local, 1);
53163         if ((local->config.rmode & 0xff) >= RXMODE_RFMON)
53164                 commit = 2;
53165  
53166 @@ -4714,6 +5209,7 @@
53167  {
53168         struct airo_info *local = dev->priv;
53169  
53170 +       readConfigRid(local, 1);
53171         /* If not managed, assume it's ad-hoc */
53172         switch (local->config.opmode & 0xFF) {
53173                 case MODE_STA_ESS:
53174 @@ -4750,6 +5246,7 @@
53175         if(!(cap_rid.softCap & 2)) {
53176                 return -EOPNOTSUPP;
53177         } */
53178 +       readConfigRid(local, 1);
53179  
53180         /* Basic checking: do we have a key to set ?
53181          * Note : with the new API, it's impossible to get a NULL pointer.
53182 @@ -4836,6 +5333,7 @@
53183         if(!(cap_rid.softCap & 2)) {
53184                 return -EOPNOTSUPP;
53185         }
53186 +       readConfigRid(local, 1);
53187         /* Check encryption mode */
53188         switch(local->config.authType)  {
53189                 case AUTH_ENCRYPT:
53190 @@ -4892,6 +5390,7 @@
53191         clear_bit (FLAG_RADIO_OFF, &local->flags);
53192         for (i = 0; cap_rid.txPowerLevels[i] && (i < 8); i++)
53193                 if ((vwrq->value==cap_rid.txPowerLevels[i])) {
53194 +                       readConfigRid(local, 1);
53195                         local->config.txPower = vwrq->value;
53196                         local->need_commit = 1;
53197                         rc = -EINPROGRESS;      /* Call commit handler */
53198 @@ -4911,6 +5410,7 @@
53199  {
53200         struct airo_info *local = dev->priv;
53201  
53202 +       readConfigRid(local, 1);
53203         vwrq->value = local->config.txPower;
53204         vwrq->fixed = 1;        /* No power control */
53205         vwrq->disabled = test_bit(FLAG_RADIO_OFF, &local->flags);
53206 @@ -4934,6 +5434,7 @@
53207         if(vwrq->disabled) {
53208                 return -EINVAL;
53209         }
53210 +       readConfigRid(local, 1);
53211         if(vwrq->flags & IW_RETRY_LIMIT) {
53212                 if(vwrq->flags & IW_RETRY_MAX)
53213                         local->config.longRetryLimit = vwrq->value;
53214 @@ -4968,6 +5469,7 @@
53215  
53216         vwrq->disabled = 0;      /* Can't be disabled */
53217  
53218 +       readConfigRid(local, 1);
53219         /* Note : by default, display the min retry number */
53220         if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
53221                 vwrq->flags = IW_RETRY_LIFETIME;
53222 @@ -5106,6 +5608,7 @@
53223  {
53224         struct airo_info *local = dev->priv;
53225  
53226 +       readConfigRid(local, 1);
53227         if (vwrq->disabled) {
53228                 if ((local->config.rmode & 0xFF) >= RXMODE_RFMON) {
53229                         return -EINVAL;
53230 @@ -5161,8 +5664,10 @@
53231                           char *extra)
53232  {
53233         struct airo_info *local = dev->priv;
53234 +       int mode;
53235  
53236 -       int mode = local->config.powerSaveMode;
53237 +       readConfigRid(local, 1);
53238 +       mode = local->config.powerSaveMode;
53239         if ((vwrq->disabled = (mode == POWERSAVE_CAM)))
53240                 return 0;
53241         if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
53242 @@ -5191,6 +5696,7 @@
53243  {
53244         struct airo_info *local = dev->priv;
53245  
53246 +       readConfigRid(local, 1);
53247         local->config.rssiThreshold = vwrq->disabled ? RSSI_DEFAULT : vwrq->value;
53248         local->need_commit = 1;
53249  
53250 @@ -5208,6 +5714,7 @@
53251  {
53252         struct airo_info *local = dev->priv;
53253  
53254 +       readConfigRid(local, 1);
53255         vwrq->value = local->config.rssiThreshold;
53256         vwrq->disabled = (vwrq->value == 0);
53257         vwrq->fixed = 1;
53258 @@ -6017,7 +6524,7 @@
53259  
53260                 /* Separate R/W functions bracket legality here
53261                  */
53262 -               if ( com.command <= AIROGMICSTATS )
53263 +               if ( com.command <= AIRORRID )
53264                         rc = readrids(dev,&com);
53265                 else if ( com.command >= AIROPCAP && com.command <= AIROPLEAPUSR )
53266                         rc = writerids(dev,&com);
53267 @@ -6107,6 +6614,7 @@
53268  static int readrids(struct net_device *dev, aironet_ioctl *comp) {
53269         unsigned short ridcode;
53270         unsigned char *iobuf;
53271 +       int len;
53272         struct airo_info *ai = dev->priv;
53273  
53274         if (test_bit(FLAG_FLASHING, &ai->flags))
53275 @@ -6134,11 +6642,14 @@
53276         case AIROGSTAT:     ridcode = RID_STATUS;       break;
53277         case AIROGSTATSD32: ridcode = RID_STATSDELTA;   break;
53278         case AIROGSTATSC32: ridcode = RID_STATS;        break;
53279 +#ifdef MICSUPPORT
53280         case AIROGMICSTATS:
53281                 if (copy_to_user(comp->data, &ai->micstats,
53282                                  min((int)comp->len,(int)sizeof(ai->micstats))))
53283                         return -EFAULT;
53284                 return 0;
53285 +#endif
53286 +       case AIRORRID:      ridcode = comp->len;        break;
53287         default:
53288                 return -EINVAL;
53289                 break;
53290 @@ -6152,9 +6663,12 @@
53291          * then return it to the user
53292          * 9/22/2000 Honor user given length
53293          */
53294 +       if (comp->command == AIRORRID)
53295 +               len = le16_to_cpu(*(unsigned short *)iobuf); /* Yuck! */
53296 +       else
53297 +               len = comp->len;
53298  
53299 -       if (copy_to_user(comp->data, iobuf,
53300 -                        min((int)comp->len, (int)RIDS_SIZE))) {
53301 +       if (copy_to_user(comp->data, iobuf, min(len, (int)RIDS_SIZE))) {
53302                 kfree (iobuf);
53303                 return -EFAULT;
53304         }
53305 @@ -6222,9 +6736,11 @@
53306  
53307                 PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDS_SIZE, 1);
53308  
53309 +#ifdef MICSUPPORT
53310                 enabled = ai->micstats.enabled;
53311                 memset(&ai->micstats,0,sizeof(ai->micstats));
53312                 ai->micstats.enabled = enabled;
53313 +#endif
53314  
53315                 if (copy_to_user(comp->data, iobuf,
53316                                  min((int)comp->len, (int)RIDS_SIZE))) {
53317 diff -Nru a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c
53318 --- a/drivers/net/wireless/airport.c    Tue Aug 19 20:53:17 2003
53319 +++ b/drivers/net/wireless/airport.c    Mon Aug 25 09:51:43 2003
53320 @@ -25,8 +25,6 @@
53321  #include <linux/if_arp.h>
53322  #include <linux/etherdevice.h>
53323  #include <linux/wireless.h>
53324 -#include <linux/adb.h>
53325 -#include <linux/pmu.h>
53326  
53327  #include <asm/io.h>
53328  #include <asm/system.h>
53329 @@ -48,96 +46,115 @@
53330         int ndev_registered;
53331  };
53332  
53333 -#ifdef CONFIG_PMAC_PBOOK
53334 -static int airport_sleep_notify(struct pmu_sleep_notifier *self, int when);
53335 -static struct pmu_sleep_notifier airport_sleep_notifier = {
53336 -       airport_sleep_notify, SLEEP_LEVEL_NET,
53337 -};
53338 -#endif
53339 +static int
53340 +airport_suspend(struct macio_dev *mdev, u32 state)
53341 +{
53342 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
53343 +       struct orinoco_private *priv = dev->priv;
53344 +       struct airport *card = priv->card;
53345 +       unsigned long flags;
53346 +       int err;
53347 +
53348 +       printk(KERN_DEBUG "%s: Airport entering sleep mode\n", dev->name);
53349 +
53350 +       err = orinoco_lock(priv, &flags);
53351 +       if (err) {
53352 +               printk(KERN_ERR "%s: hw_unavailable on PBOOK_SLEEP_NOW\n",
53353 +                      dev->name);
53354 +               return 0;
53355 +       }
53356 +
53357 +       err = __orinoco_down(dev);
53358 +       if (err)
53359 +               printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n",
53360 +                      dev->name, err);
53361  
53362 -/*
53363 - * Function prototypes
53364 - */
53365 +       netif_device_detach(dev);
53366  
53367 -static struct net_device *airport_attach(struct device_node *of_node);
53368 -static void airport_detach(struct net_device *dev);
53369 +       priv->hw_unavailable++;
53370  
53371 -static struct net_device *airport_dev;
53372 +       orinoco_unlock(priv, &flags);
53373 +
53374 +       disable_irq(dev->irq);
53375 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
53376 +
53377 +       return 0;
53378 +}
53379  
53380 -#ifdef CONFIG_PMAC_PBOOK
53381  static int
53382 -airport_sleep_notify(struct pmu_sleep_notifier *self, int when)
53383 +airport_resume(struct macio_dev *mdev)
53384  {
53385 -       struct net_device *dev = airport_dev;
53386 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
53387         struct orinoco_private *priv = dev->priv;
53388         struct airport *card = priv->card;
53389         unsigned long flags;
53390         int err;
53391 -       
53392 -       if (! airport_dev)
53393 -               return PBOOK_SLEEP_OK;
53394 -
53395 -       switch (when) {
53396 -       case PBOOK_SLEEP_NOW:
53397 -               printk(KERN_DEBUG "%s: Airport entering sleep mode\n", dev->name);
53398 -
53399 -               err = orinoco_lock(priv, &flags);
53400 -               if (err) {
53401 -                       printk(KERN_ERR "%s: hw_unavailable on PBOOK_SLEEP_NOW\n",
53402 -                              dev->name);
53403 -                       break;
53404 -               }
53405  
53406 -               err = __orinoco_down(dev);
53407 -               if (err)
53408 -                       printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n",
53409 -                              dev->name, err);
53410 +       printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
53411  
53412 -               netif_device_detach(dev);
53413 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1);
53414 +       mdelay(200);
53415  
53416 -               priv->hw_unavailable++;
53417 +       enable_irq(dev->irq);
53418  
53419 -               orinoco_unlock(priv, &flags);
53420 +       err = orinoco_reinit_firmware(dev);
53421 +       if (err) {
53422 +               printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n",
53423 +                      dev->name, err);
53424 +               return 0;
53425 +       }
53426  
53427 -               disable_irq(dev->irq);
53428 -               pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
53429 -               break;
53430 +       spin_lock_irqsave(&priv->lock, flags);
53431  
53432 -       case PBOOK_WAKE:
53433 -               printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
53434 -               pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1);
53435 -               mdelay(200);
53436 +       netif_device_attach(dev);
53437  
53438 -               enable_irq(dev->irq);
53439 +       priv->hw_unavailable--;
53440  
53441 -               err = orinoco_reinit_firmware(dev);
53442 -               if (err) {
53443 -                       printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n",
53444 +       if (priv->open && (! priv->hw_unavailable)) {
53445 +               err = __orinoco_up(dev);
53446 +               if (err)
53447 +                       printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
53448                                dev->name, err);
53449 -                       break;
53450 -               }
53451 +       }
53452  
53453 -               spin_lock_irqsave(&priv->lock, flags);
53454  
53455 -               netif_device_attach(dev);
53456 +       spin_unlock_irqrestore(&priv->lock, flags);
53457  
53458 -               priv->hw_unavailable--;
53459 +       return 0;
53460 +}
53461  
53462 -               if (priv->open && (! priv->hw_unavailable)) {
53463 -                       err = __orinoco_up(dev);
53464 -                       if (err)
53465 -                               printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
53466 -                                      dev->name, err);
53467 -               }
53468 +static int
53469 +airport_detach(struct macio_dev *mdev)
53470 +{
53471 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
53472 +       struct orinoco_private *priv = dev->priv;
53473 +       struct airport *card = priv->card;
53474  
53475 +       if (card->ndev_registered)
53476 +               unregister_netdev(dev);
53477 +       card->ndev_registered = 0;
53478  
53479 -               spin_unlock_irqrestore(&priv->lock, flags);
53480 +       if (card->irq_requested)
53481 +               free_irq(dev->irq, dev);
53482 +       card->irq_requested = 0;
53483  
53484 -               break;
53485 -       }
53486 -       return PBOOK_SLEEP_OK;
53487 +       if (card->vaddr)
53488 +               iounmap(card->vaddr);
53489 +       card->vaddr = 0;
53490 +
53491 +       dev->base_addr = 0;
53492 +
53493 +       release_OF_resource(card->node, 0);
53494 +
53495 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
53496 +       current->state = TASK_UNINTERRUPTIBLE;
53497 +       schedule_timeout(HZ);
53498 +
53499 +       dev_set_drvdata(&mdev->ofdev.dev, NULL);
53500 +       free_netdev(dev);
53501 +
53502 +       return 0;
53503  }
53504 -#endif /* CONFIG_PMAC_PBOOK */
53505  
53506  static int airport_hard_reset(struct orinoco_private *priv)
53507  {
53508 @@ -170,25 +187,26 @@
53509         return 0;
53510  }
53511  
53512 -static struct net_device *
53513 -airport_attach(struct device_node *of_node)
53514 +static int
53515 +airport_attach(struct macio_dev *mdev, const struct of_match *match)
53516  {
53517         struct orinoco_private *priv;
53518         struct net_device *dev;
53519         struct airport *card;
53520         unsigned long phys_addr;
53521 +       struct device_node *of_node = mdev->ofdev.node;
53522         hermes_t *hw;
53523  
53524         if (of_node->n_addrs < 1 || of_node->n_intrs < 1) {
53525                 printk(KERN_ERR "airport: wrong interrupt/addresses in OF tree\n");
53526 -               return NULL;
53527 +               return -ENODEV;
53528         }
53529  
53530         /* Allocate space for private device-specific data */
53531         dev = alloc_orinocodev(sizeof(*card), airport_hard_reset);
53532         if (! dev) {
53533                 printk(KERN_ERR "airport: can't allocate device datas\n");
53534 -               return NULL;
53535 +               return -ENODEV;
53536         }
53537         priv = dev->priv;
53538         card = priv->card;
53539 @@ -199,11 +217,14 @@
53540         if (! request_OF_resource(of_node, 0, " (airport)")) {
53541                 printk(KERN_ERR "airport: can't request IO resource !\n");
53542                 kfree(dev);
53543 -               return NULL;
53544 +               return -ENODEV;
53545         }
53546  
53547         dev->name[0] = '\0';    /* register_netdev will give us an ethX name */
53548         SET_MODULE_OWNER(dev);
53549 +       SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
53550 +
53551 +       dev_set_drvdata(&mdev->ofdev.dev, dev);
53552  
53553         /* Setup interrupts & base address */
53554         dev->irq = of_node->intrs[0].line;
53555 @@ -240,79 +261,50 @@
53556         }
53557         printk(KERN_DEBUG "airport: card registered for interface %s\n", dev->name);
53558         card->ndev_registered = 1;
53559 -
53560 -#ifdef CONFIG_PMAC_PBOOK
53561 -       pmu_register_sleep_notifier(&airport_sleep_notifier);
53562 -#endif
53563 -       return dev;
53564 -       
53565 +       return 0;
53566   failed:
53567 -       airport_detach(dev);
53568 -       return NULL;
53569 +       airport_detach(mdev);
53570 +       return -ENODEV;
53571  }                              /* airport_attach */
53572  
53573 -/*======================================================================
53574 -  This deletes a driver "instance".  
53575 -  ======================================================================*/
53576 -
53577 -static void
53578 -airport_detach(struct net_device *dev)
53579 -{
53580 -       struct orinoco_private *priv = dev->priv;
53581 -       struct airport *card = priv->card;
53582 -
53583 -#ifdef CONFIG_PMAC_PBOOK
53584 -       pmu_unregister_sleep_notifier(&airport_sleep_notifier);
53585 -#endif
53586 -       if (card->ndev_registered)
53587 -               unregister_netdev(dev);
53588 -       card->ndev_registered = 0;
53589 -
53590 -       if (card->irq_requested)
53591 -               free_irq(dev->irq, dev);
53592 -       card->irq_requested = 0;
53593 -
53594 -       if (card->vaddr)
53595 -               iounmap(card->vaddr);
53596 -       card->vaddr = 0;
53597 -
53598 -       dev->base_addr = 0;
53599 -
53600 -       release_OF_resource(card->node, 0);
53601 -
53602 -       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
53603 -       current->state = TASK_UNINTERRUPTIBLE;
53604 -       schedule_timeout(HZ);
53605 -
53606 -       free_netdev(dev);
53607 -}                              /* airport_detach */
53608  
53609  static char version[] __initdata = "airport.c 0.13e (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
53610  MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
53611  MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
53612  MODULE_LICENSE("Dual MPL/GPL");
53613  
53614 +static struct of_match airport_match[] = 
53615 +{
53616 +       {
53617 +       .name           = "radio",
53618 +       .type           = OF_ANY_MATCH,
53619 +       .compatible     = OF_ANY_MATCH
53620 +       },
53621 +       {},
53622 +};
53623 +
53624 +static struct macio_driver airport_driver = 
53625 +{
53626 +       .name           = "airport",
53627 +       .match_table    = airport_match,
53628 +       .probe          = airport_attach,
53629 +       .remove         = airport_detach,
53630 +       .suspend        = airport_suspend,
53631 +       .resume         = airport_resume,
53632 +};
53633 +
53634  static int __init
53635  init_airport(void)
53636  {
53637 -       struct device_node *airport_node;
53638 -
53639         printk(KERN_DEBUG "%s\n", version);
53640  
53641 -       /* Lookup card in device tree */
53642 -       airport_node = find_devices("radio");
53643 -       if (airport_node && !strcmp(airport_node->parent->name, "mac-io"))
53644 -               airport_dev = airport_attach(airport_node);
53645 -
53646 -       return airport_dev ? 0 : -ENODEV;
53647 +       return macio_register_driver(&airport_driver);
53648  }
53649  
53650  static void __exit
53651  exit_airport(void)
53652  {
53653 -       if (airport_dev)
53654 -               airport_detach(airport_dev);
53655 -       airport_dev = NULL;
53656 +       return macio_unregister_driver(&airport_driver);
53657  }
53658  
53659  module_init(init_airport);
53660 diff -Nru a/drivers/net/wireless/hermes.h b/drivers/net/wireless/hermes.h
53661 --- a/drivers/net/wireless/hermes.h     Tue May 27 00:17:28 2003
53662 +++ b/drivers/net/wireless/hermes.h     Wed Sep  3 23:40:22 2003
53663 @@ -302,12 +302,14 @@
53664  #define hermes_read_reg(hw, off) ((hw)->io_space ? \
53665         inw((hw)->iobase + ( (off) << (hw)->reg_spacing )) : \
53666         readw((hw)->iobase + ( (off) << (hw)->reg_spacing )))
53667 -#define hermes_write_reg(hw, off, val) ((hw)->io_space ? \
53668 -       outw_p((val), (hw)->iobase + ( (off) << (hw)->reg_spacing )) : \
53669 -       writew((val), (hw)->iobase + ( (off) << (hw)->reg_spacing )))
53670 -
53671 -#define hermes_read_regn(hw, name) (hermes_read_reg((hw), HERMES_##name))
53672 -#define hermes_write_regn(hw, name, val) (hermes_write_reg((hw), HERMES_##name, (val)))
53673 +#define hermes_write_reg(hw, off, val) do { \
53674 +       if ((hw)->io_space) \
53675 +               outw_p((val), (hw)->iobase + ((off) << (hw)->reg_spacing)); \
53676 +       else \
53677 +               writew((val), (hw)->iobase + ((off) << (hw)->reg_spacing)); \
53678 +       } while (0)
53679 +#define hermes_read_regn(hw, name) hermes_read_reg((hw), HERMES_##name)
53680 +#define hermes_write_regn(hw, name, val) hermes_write_reg((hw), HERMES_##name, (val))
53681  
53682  /* Function prototypes */
53683  void hermes_struct_init(hermes_t *hw, ulong address, int io_space, int reg_spacing);
53684 diff -Nru a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
53685 --- a/drivers/net/wireless/ray_cs.c     Thu Aug  7 09:17:57 2003
53686 +++ b/drivers/net/wireless/ray_cs.c     Tue Aug 26 14:55:20 2003
53687 @@ -105,6 +105,9 @@
53688  static struct net_device_stats *ray_get_stats(struct net_device *dev);
53689  static int ray_dev_init(struct net_device *dev);
53690  static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
53691 +
53692 +static struct ethtool_ops netdev_ethtool_ops;
53693 +
53694  static int ray_open(struct net_device *dev);
53695  static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev);
53696  static void set_multicast_list(struct net_device *dev);
53697 @@ -408,6 +411,7 @@
53698      dev->set_config = &ray_dev_config;
53699      dev->get_stats  = &ray_get_stats;
53700      dev->do_ioctl = &ray_dev_ioctl;
53701 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
53702  #if WIRELESS_EXT > 7   /* If wireless extension exist in the kernel */
53703      dev->get_wireless_stats = ray_get_wireless_stats;
53704  #endif
53705 @@ -1226,26 +1230,16 @@
53706  
53707  /*===========================================================================*/
53708  
53709 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
53710 +static void netdev_get_drvinfo(struct net_device *dev,
53711 +                              struct ethtool_drvinfo *info)
53712  {
53713 -       u32 ethcmd;
53714 -               
53715 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
53716 -               return -EFAULT;
53717 -       
53718 -       switch (ethcmd) {
53719 -       case ETHTOOL_GDRVINFO: {
53720 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
53721 -               strncpy(info.driver, "ray_cs", sizeof(info.driver)-1);
53722 -               if (copy_to_user(useraddr, &info, sizeof(info)))
53723 -                       return -EFAULT;
53724 -               return 0;
53725 -       }
53726 -       }
53727 -       
53728 -       return -EOPNOTSUPP;
53729 +       strcpy(info->driver, "ray_cs");
53730  }
53731  
53732 +static struct ethtool_ops netdev_ethtool_ops = {
53733 +       .get_drvinfo            = netdev_get_drvinfo,
53734 +};
53735 +
53736  /*====================================================================*/
53737  
53738  static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
53739 @@ -1265,10 +1259,6 @@
53740      /* Validate the command */
53741      switch (cmd)
53742      {
53743 -    case SIOCETHTOOL:
53744 -      err = netdev_ethtool_ioctl(dev, (void *) ifr->ifr_data);
53745 -      break;
53746 -
53747  #if WIRELESS_EXT > 7
53748        /* --------------- WIRELESS EXTENSIONS --------------- */
53749        /* Get name */
53750 diff -Nru a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
53751 --- a/drivers/net/yellowfin.c   Tue Aug 19 20:53:17 2003
53752 +++ b/drivers/net/yellowfin.c   Sun Aug 31 06:34:16 2003
53753 @@ -873,8 +873,6 @@
53754         /* Calculate the next Tx descriptor entry. */
53755         entry = yp->cur_tx % TX_RING_SIZE;
53756  
53757 -       yp->tx_skbuff[entry] = skb;
53758 -
53759         if (gx_fix) {   /* Note: only works for paddable protocols e.g.  IP. */
53760                 int cacheline_end = ((unsigned long)skb->data + skb->len) % 32;
53761                 /* Fix GX chipset errata. */
53762 @@ -889,6 +887,8 @@
53763                         return 0;
53764                 }
53765         }
53766 +       yp->tx_skbuff[entry] = skb;
53767 +
53768  #ifdef NO_TXSTATS
53769         yp->tx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev, 
53770                 skb->data, len, PCI_DMA_TODEVICE));
53771 diff -Nru a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
53772 --- a/drivers/parport/parport_pc.c      Thu Jul 31 08:59:04 2003
53773 +++ b/drivers/parport/parport_pc.c      Sun Aug 31 16:14:16 2003
53774 @@ -93,7 +93,7 @@
53775         int dma;
53776  } superios[NR_SUPERIOS] __devinitdata = { {0,},};
53777  
53778 -static int user_specified __devinitdata = 0;
53779 +static int user_specified;
53780  #if defined(CONFIG_PARPORT_PC_SUPERIO) || \
53781         (defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
53782  static int verbose_probing;
53783 diff -Nru a/drivers/pci/pci.ids b/drivers/pci/pci.ids
53784 --- a/drivers/pci/pci.ids       Wed Aug  6 12:32:59 2003
53785 +++ b/drivers/pci/pci.ids       Thu Aug 28 00:24:56 2003
53786 @@ -3247,7 +3247,8 @@
53787                 1148 5061  SK-9861 V2.0 Gigabit Ethernet 1000Base-SX Adapter
53788                 1148 5071  SK-9871 V2.0 Gigabit Ethernet 1000Base-ZX Adapter
53789                 1148 9521  SK-9521 10/100/1000Base-T Adapter
53790 -       4400  Gigabit Ethernet
53791 +       4400 SK-9Dxx Gigabit Ethernet Adapter
53792 +       4500 SK-9Mxx Gigabit Ethernet Adapter
53793  1149  Win System Corporation
53794  114a  VMIC
53795         5579  VMIPCI-5579 (Reflective Memory Card)
53796 @@ -5313,9 +5314,12 @@
53797                 1166 1648  NetXtreme CIOB-E 1000Base-T
53798         164d  NetXtreme BCM5702FE Gigabit Ethernet
53799         1653  NetXtreme BCM5705 Gigabit Ethernet
53800 +       1654  NetXtreme BCM5705 Gigabit Ethernet
53801         165d  NetXtreme BCM5705M Gigabit Ethernet
53802 +       165e  NetXtreme BCM5705M Gigabit Ethernet
53803         1696  NetXtreme BCM5782 Gigabit Ethernet
53804                 14e4 000d  NetXtreme BCM5782 1000Base-T
53805 +       169c  NetXtreme BCM5788 Gigabit Ethernet
53806         16a6  NetXtreme BCM5702 Gigabit Ethernet
53807                 0e11 00bb  NC7760 Gigabit Server Adapter (PCI-X, 10/100/1000-T)
53808                 1028 0126  BCM5702 1000Base-T
53809 @@ -5337,6 +5341,8 @@
53810         16c7  NetXtreme BCM5703 Gigabit Ethernet
53811                 14e4 0009  NetXtreme BCM5703 1000Base-T
53812                 14e4 000a  NetXtreme BCM5703 1000Base-SX
53813 +       170d  NetXtreme BCM5901 Gigabit Ethernet
53814 +       170e  NetXtreme BCM5901 Gigabit Ethernet
53815         4210  BCM4210 iLine10 HomePNA 2.0
53816         4211  BCM4211 iLine10 HomePNA 2.0 + V.90 56k modem
53817         4212  BCM4212 v.90 56k modem
53818 @@ -5877,6 +5883,8 @@
53819         03e8  AC1000 Gigabit Ethernet
53820         03e9  AC1001 Gigabit Ethernet
53821         03ea  AC9100 Gigabit Ethernet
53822 +               173b 0001  AC1002
53823 +       03eb  AC1003 Gigabit Ethernet
53824  1743  Peppercon AG
53825         8139  ROL/F-100 Fast Ethernet Adapter with ROL
53826  174b  PC Partner Limited
53827 diff -Nru a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
53828 --- a/drivers/pcmcia/cistpl.c   Sun Jul  6 16:03:10 2003
53829 +++ b/drivers/pcmcia/cistpl.c   Wed Aug 27 13:25:31 2003
53830 @@ -293,15 +293,17 @@
53831  #endif
53832         ret = read_cis_mem(s, attr, addr, len, ptr);
53833  
53834 -    /* Copy data into the cache */
53835 -    cis = kmalloc(sizeof(struct cis_cache_entry) + len, GFP_KERNEL);
53836 -    if (cis) {
53837 -       cis->addr = addr;
53838 -       cis->len = len;
53839 -       cis->attr = attr;
53840 -       memcpy(cis->cache, ptr, len);
53841 -       list_add(&cis->node, &s->cis_cache);
53842 -    }
53843 +       if (ret == 0) {
53844 +               /* Copy data into the cache */
53845 +               cis = kmalloc(sizeof(struct cis_cache_entry) + len, GFP_KERNEL);
53846 +               if (cis) {
53847 +                       cis->addr = addr;
53848 +                       cis->len = len;
53849 +                       cis->attr = attr;
53850 +                       memcpy(cis->cache, ptr, len);
53851 +                       list_add(&cis->node, &s->cis_cache);
53852 +               }
53853 +       }
53854  }
53855  
53856  static void
53857 diff -Nru a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
53858 --- a/drivers/pcmcia/ds.c       Mon Jun 16 13:20:14 2003
53859 +++ b/drivers/pcmcia/ds.c       Tue Aug 26 09:25:41 2003
53860 @@ -495,7 +495,7 @@
53861  
53862  static int ds_open(struct inode *inode, struct file *file)
53863  {
53864 -    socket_t i = minor(inode->i_rdev);
53865 +    socket_t i = iminor(inode);
53866      struct pcmcia_bus_socket *s;
53867      user_info_t *user;
53868  
53869 @@ -529,7 +529,7 @@
53870  
53871  static int ds_release(struct inode *inode, struct file *file)
53872  {
53873 -    socket_t i = minor(inode->i_rdev);
53874 +    socket_t i = iminor(inode);
53875      struct pcmcia_bus_socket *s;
53876      user_info_t *user, **link;
53877  
53878 @@ -563,7 +563,7 @@
53879  static ssize_t ds_read(struct file *file, char *buf,
53880                        size_t count, loff_t *ppos)
53881  {
53882 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
53883 +    socket_t i = iminor(file->f_dentry->d_inode);
53884      struct pcmcia_bus_socket *s;
53885      user_info_t *user;
53886  
53887 @@ -594,7 +594,7 @@
53888  static ssize_t ds_write(struct file *file, const char *buf,
53889                         size_t count, loff_t *ppos)
53890  {
53891 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
53892 +    socket_t i = iminor(file->f_dentry->d_inode);
53893      struct pcmcia_bus_socket *s;
53894      user_info_t *user;
53895  
53896 @@ -629,7 +629,7 @@
53897  /* No kernel lock - fine */
53898  static u_int ds_poll(struct file *file, poll_table *wait)
53899  {
53900 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
53901 +    socket_t i = iminor(file->f_dentry->d_inode);
53902      struct pcmcia_bus_socket *s;
53903      user_info_t *user;
53904  
53905 @@ -653,7 +653,7 @@
53906  static int ds_ioctl(struct inode * inode, struct file * file,
53907                     u_int cmd, u_long arg)
53908  {
53909 -    socket_t i = minor(inode->i_rdev);
53910 +    socket_t i = iminor(inode);
53911      struct pcmcia_bus_socket *s;
53912      u_int size;
53913      int ret, err;
53914 diff -Nru a/drivers/pcmcia/ricoh.h b/drivers/pcmcia/ricoh.h
53915 --- a/drivers/pcmcia/ricoh.h    Mon Jul 14 07:42:47 2003
53916 +++ b/drivers/pcmcia/ricoh.h    Wed Aug 27 12:42:52 2003
53917 @@ -142,59 +142,61 @@
53918          config_writeb(socket, RL5C4XX_MISC_CONTROL, reg);
53919  }
53920  
53921 -static void ricoh_set_zv(struct pcmcia_socket *sock)
53922 +static void ricoh_set_zv(struct yenta_socket *socket)
53923  {
53924 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
53925          if(socket->dev->vendor == PCI_VENDOR_ID_RICOH)
53926          {
53927                  switch(socket->dev->device)
53928                  {
53929                          /* There may be more .. */
53930                 case  PCI_DEVICE_ID_RICOH_RL5C478:
53931 -                       sock->zoom_video = ricoh_zoom_video;
53932 +                       socket->socket.zoom_video = ricoh_zoom_video;
53933                         break;  
53934                  }
53935          }
53936  }
53937  
53938 -static int ricoh_init(struct pcmcia_socket *sock)
53939 +static void ricoh_save_state(struct yenta_socket *socket)
53940  {
53941 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
53942 -       yenta_init(sock);
53943 -       ricoh_set_zv(sock);
53944 +       rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
53945 +       rl_ctl(socket) = config_readw(socket, RL5C4XX_16BIT_CTL);
53946 +       rl_io(socket) = config_readw(socket, RL5C4XX_16BIT_IO_0);
53947 +       rl_mem(socket) = config_readw(socket, RL5C4XX_16BIT_MEM_0);
53948 +       rl_config(socket) = config_readw(socket, RL5C4XX_CONFIG);
53949 +}
53950  
53951 +static void ricoh_restore_state(struct yenta_socket *socket)
53952 +{
53953         config_writew(socket, RL5C4XX_MISC, rl_misc(socket));
53954         config_writew(socket, RL5C4XX_16BIT_CTL, rl_ctl(socket));
53955         config_writew(socket, RL5C4XX_16BIT_IO_0, rl_io(socket));
53956         config_writew(socket, RL5C4XX_16BIT_MEM_0, rl_mem(socket));
53957         config_writew(socket, RL5C4XX_CONFIG, rl_config(socket));
53958 -       
53959 -       return 0;
53960  }
53961  
53962  
53963  /*
53964 - * Magic Ricoh initialization code.. Save state at
53965 - * beginning, re-initialize it after suspend.
53966 + * Magic Ricoh initialization code..
53967   */
53968  static int ricoh_override(struct yenta_socket *socket)
53969  {
53970 -       rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
53971 -       rl_ctl(socket) = config_readw(socket, RL5C4XX_16BIT_CTL);
53972 -       rl_io(socket) = config_readw(socket, RL5C4XX_16BIT_IO_0);
53973 -       rl_mem(socket) = config_readw(socket, RL5C4XX_16BIT_MEM_0);
53974 -       rl_config(socket) = config_readw(socket, RL5C4XX_CONFIG);
53975 +       u16 config, ctl;
53976 +
53977 +       config = config_readw(socket, RL5C4XX_CONFIG);
53978  
53979         /* Set the default timings, don't trust the original values */
53980 -       rl_ctl(socket) = RL5C4XX_16CTL_IO_TIMING | RL5C4XX_16CTL_MEM_TIMING;
53981 +       ctl = RL5C4XX_16CTL_IO_TIMING | RL5C4XX_16CTL_MEM_TIMING;
53982  
53983         if(socket->dev->device < PCI_DEVICE_ID_RICOH_RL5C475) {
53984 -               rl_ctl(socket) |= RL5C46X_16CTL_LEVEL_1 | RL5C46X_16CTL_LEVEL_2;
53985 +               ctl |= RL5C46X_16CTL_LEVEL_1 | RL5C46X_16CTL_LEVEL_2;
53986         } else {
53987 -               rl_config(socket) |= RL5C4XX_CONFIG_PREFETCH;
53988 +               config |= RL5C4XX_CONFIG_PREFETCH;
53989         }
53990  
53991 -       socket->socket.ops->init = ricoh_init;
53992 +       config_writew(socket, RL5C4XX_16BIT_CTL, ctl);
53993 +       config_writew(socket, RL5C4XX_CONFIG, config);
53994 +
53995 +       ricoh_set_zv(socket);
53996  
53997         return 0;
53998  }
53999 diff -Nru a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
54000 --- a/drivers/pcmcia/sa1111_generic.c   Sun Jun 15 04:35:08 2003
54001 +++ b/drivers/pcmcia/sa1111_generic.c   Sun Aug 24 07:45:05 2003
54002 @@ -16,6 +16,7 @@
54003  
54004  #include <asm/hardware.h>
54005  #include <asm/hardware/sa1111.h>
54006 +#include <asm/io.h>
54007  #include <asm/irq.h>
54008  
54009  #include "sa1111_generic.h"
54010 @@ -118,16 +119,15 @@
54011         sa11xx_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
54012  }
54013  
54014 -static int pcmcia_probe(struct device *dev)
54015 +static int pcmcia_probe(struct sa1111_dev *dev)
54016  {
54017 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
54018         char *base;
54019  
54020 -       if (!request_mem_region(sadev->res.start, 512,
54021 -                               SA1111_DRIVER_NAME(sadev)))
54022 +       if (!request_mem_region(dev->res.start, 512,
54023 +                               SA1111_DRIVER_NAME(dev)))
54024                 return -EBUSY;
54025  
54026 -       base = sadev->mapbase;
54027 +       base = dev->mapbase;
54028  
54029         /*
54030          * Initialise the suspend state.
54031 @@ -136,61 +136,68 @@
54032         sa1111_writel(PCCR_S0_FLT | PCCR_S1_FLT, base + SA1111_PCCR);
54033  
54034  #ifdef CONFIG_SA1100_ADSBITSY
54035 -       pcmcia_adsbitsy_init(dev);
54036 +       pcmcia_adsbitsy_init(&dev->dev);
54037  #endif
54038  #ifdef CONFIG_SA1100_BADGE4
54039 -       pcmcia_badge4_init(dev);
54040 +       pcmcia_badge4_init(&dev->dev);
54041  #endif
54042  #ifdef CONFIG_SA1100_GRAPHICSMASTER
54043 -       pcmcia_graphicsmaster_init(dev);
54044 +       pcmcia_graphicsmaster_init(&dev->dev);
54045  #endif
54046  #ifdef CONFIG_SA1100_JORNADA720
54047 -       pcmcia_jornada720_init(dev);
54048 +       pcmcia_jornada720_init(&dev->dev);
54049  #endif
54050  #ifdef CONFIG_ASSABET_NEPONSET
54051 -       pcmcia_neponset_init(dev);
54052 +       pcmcia_neponset_init(&dev->dev);
54053  #endif
54054  #ifdef CONFIG_SA1100_PFS168
54055 -       pcmcia_pfs_init(dev);
54056 +       pcmcia_pfs_init(&dev->dev);
54057  #endif
54058  #ifdef CONFIG_SA1100_PT_SYSTEM3
54059 -       pcmcia_system3_init(dev);
54060 +       pcmcia_system3_init(&dev->dev);
54061  #endif
54062  #ifdef CONFIG_SA1100_XP860
54063 -       pcmcia_xp860_init(dev);
54064 +       pcmcia_xp860_init(&dev->dev);
54065  #endif
54066         return 0;
54067  }
54068  
54069 -static int __devexit pcmcia_remove(struct device *dev)
54070 +static int __devexit pcmcia_remove(struct sa1111_dev *dev)
54071  {
54072 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
54073 -
54074 -       sa11xx_drv_pcmcia_remove(dev);
54075 -       release_mem_region(sadev->res.start, 512);
54076 +       sa11xx_drv_pcmcia_remove(&dev->dev);
54077 +       release_mem_region(dev->res.start, 512);
54078         return 0;
54079  }
54080  
54081 +static int pcmcia_suspend(struct sa1111_dev *dev, u32 state)
54082 +{
54083 +       return pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
54084 +}
54085 +
54086 +static int pcmcia_resume(struct sa1111_dev *dev)
54087 +{
54088 +       return pcmcia_socket_dev_resume(&dev->dev, RESUME_RESTORE_STATE);
54089 +}
54090 +
54091  static struct sa1111_driver pcmcia_driver = {
54092         .drv = {
54093 -               .name           = "sa1111-pcmcia",
54094 -               .bus            = &sa1111_bus_type,
54095 -               .probe          = pcmcia_probe,
54096 -               .remove         = __devexit_p(pcmcia_remove),
54097 -               .suspend        = pcmcia_socket_dev_suspend,
54098 -               .resume         = pcmcia_socket_dev_resume,
54099 +               .name   = "sa1111-pcmcia",
54100         },
54101 -       .devid                  = SA1111_DEVID_PCMCIA,
54102 +       .devid          = SA1111_DEVID_PCMCIA,
54103 +       .probe          = pcmcia_probe,
54104 +       .remove         = __devexit_p(pcmcia_remove),
54105 +       .suspend        = pcmcia_suspend,
54106 +       .resume         = pcmcia_resume,
54107  };
54108  
54109  static int __init sa1111_drv_pcmcia_init(void)
54110  {
54111 -       return driver_register(&pcmcia_driver.drv);
54112 +       return sa1111_driver_register(&pcmcia_driver);
54113  }
54114  
54115  static void __exit sa1111_drv_pcmcia_exit(void)
54116  {
54117 -       driver_unregister(&pcmcia_driver.drv);
54118 +       sa1111_driver_unregister(&pcmcia_driver);
54119  }
54120  
54121  module_init(sa1111_drv_pcmcia_init);
54122 diff -Nru a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
54123 --- a/drivers/pcmcia/ti113x.h   Wed Aug  6 15:59:05 2003
54124 +++ b/drivers/pcmcia/ti113x.h   Wed Aug 27 12:58:54 2003
54125 @@ -136,16 +136,34 @@
54126  
54127  #ifdef CONFIG_CARDBUS
54128  
54129 -static int ti_intctl(struct yenta_socket *socket)
54130 +/*
54131 + * Texas Instruments CardBus controller overrides.
54132 + */
54133 +#define ti_sysctl(socket)      ((socket)->private[0])
54134 +#define ti_cardctl(socket)     ((socket)->private[1])
54135 +#define ti_devctl(socket)      ((socket)->private[2])
54136 +#define ti_diag(socket)                ((socket)->private[3])
54137 +#define ti_irqmux(socket)      ((socket)->private[4])
54138 +
54139 +/*
54140 + * These are the TI specific power management handlers.
54141 + */
54142 +static void ti_save_state(struct yenta_socket *socket)
54143  {
54144 -       u8 new, reg = exca_readb(socket, I365_INTCTL);
54145 +       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
54146 +       ti_irqmux(socket) = config_readl(socket, TI122X_IRQMUX);
54147 +       ti_cardctl(socket) = config_readb(socket, TI113X_CARD_CONTROL);
54148 +       ti_devctl(socket) = config_readb(socket, TI113X_DEVICE_CONTROL);
54149 +       ti_diag(socket) = config_readb(socket, TI1250_DIAGNOSTIC);
54150 +}
54151  
54152 -       new = reg & ~I365_INTR_ENA;
54153 -       if (socket->cb_irq)
54154 -               new |= I365_INTR_ENA;
54155 -       if (new != reg)
54156 -               exca_writeb(socket, I365_INTCTL, new);
54157 -       return 0;
54158 +static void ti_restore_state(struct yenta_socket *socket)
54159 +{
54160 +       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
54161 +       config_writel(socket, TI122X_IRQMUX, ti_irqmux(socket));
54162 +       config_writeb(socket, TI113X_CARD_CONTROL, ti_cardctl(socket));
54163 +       config_writeb(socket, TI113X_DEVICE_CONTROL, ti_devctl(socket));
54164 +       config_writeb(socket, TI1250_DIAGNOSTIC, ti_diag(socket));
54165  }
54166  
54167  /*
54168 @@ -185,8 +203,8 @@
54169  
54170         ti_zoom_video(sock, onoff);
54171  
54172 -       reg = config_readb(socket, 0x84);
54173 -       reg |= (1<<7);  /* ZV bus enable */
54174 +       reg = config_readb(socket, TI1250_MULTIMEDIA_CTL);
54175 +       reg |= TI1250_MMC_ZVOUTEN;      /* ZV bus enable */
54176  
54177         if(PCI_FUNC(socket->dev->devfn)==1)
54178                 shift = 1;
54179 @@ -204,12 +222,11 @@
54180                 reg &= ~(1<<shift);     /* Socket zoon video off */
54181         }
54182  
54183 -       config_writeb(socket, 0x84, reg);
54184 +       config_writeb(socket, TI1250_MULTIMEDIA_CTL, reg);
54185  }
54186  
54187 -static void ti_set_zv(struct pcmcia_socket *sock)
54188 +static void ti_set_zv(struct yenta_socket *socket)
54189  {
54190 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
54191         if(socket->dev->vendor == PCI_VENDOR_ID_TI)
54192         {
54193                 switch(socket->dev->device)
54194 @@ -218,24 +235,16 @@
54195                         case PCI_DEVICE_ID_TI_1220:
54196                         case PCI_DEVICE_ID_TI_1221:
54197                         case PCI_DEVICE_ID_TI_1225:
54198 -                               sock->zoom_video = ti_zoom_video;
54199 +                               socket->socket.zoom_video = ti_zoom_video;
54200                                 break;  
54201                         case PCI_DEVICE_ID_TI_1250:
54202                         case PCI_DEVICE_ID_TI_1251A:
54203                         case PCI_DEVICE_ID_TI_1251B:
54204                         case PCI_DEVICE_ID_TI_1450:
54205 -                               sock->zoom_video = ti1250_zoom_video;
54206 +                               socket->socket.zoom_video = ti1250_zoom_video;
54207                 }
54208         }
54209  }
54210 -static int ti_init(struct pcmcia_socket *sock)
54211 -{
54212 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
54213 -       yenta_init(sock);
54214 -       ti_set_zv(sock);
54215 -       ti_intctl(socket);
54216 -       return 0;
54217 -}
54218  
54219  
54220  /*
54221 @@ -250,6 +259,18 @@
54222   *   This makes us correctly get PCI CSC interrupt
54223   *   events.
54224   */
54225 +static int ti_init(struct yenta_socket *socket)
54226 +{
54227 +       u8 new, reg = exca_readb(socket, I365_INTCTL);
54228 +
54229 +       new = reg & ~I365_INTR_ENA;
54230 +       if (socket->cb_irq)
54231 +               new |= I365_INTR_ENA;
54232 +       if (new != reg)
54233 +               exca_writeb(socket, I365_INTCTL, new);
54234 +       return 0;
54235 +}
54236 +
54237  static int ti_override(struct yenta_socket *socket)
54238  {
54239         u8 new, reg = exca_readb(socket, I365_INTCTL);
54240 @@ -258,6 +279,8 @@
54241         if (new != reg)
54242                 exca_writeb(socket, I365_INTCTL, new);
54243  
54244 +       ti_set_zv(socket);
54245 +
54246  #if 0
54247         /*
54248          * If ISA interrupts don't work, then fall back to routing card
54249 @@ -285,83 +308,85 @@
54250         }
54251  #endif
54252  
54253 -       socket->socket.ops->init = ti_init;
54254 -       return 0;
54255 -}
54256 -
54257 -#define ti_sysctl(socket)      ((socket)->private[0])
54258 -#define ti_cardctl(socket)     ((socket)->private[1])
54259 -#define ti_devctl(socket)      ((socket)->private[2])
54260 -#define ti_diag(socket)                ((socket)->private[3])
54261 -#define ti_irqmux(socket)      ((socket)->private[4])
54262 -
54263 -
54264 -static int ti113x_init(struct pcmcia_socket *sock)
54265 -{
54266 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
54267 -       yenta_init(sock);
54268 -       ti_set_zv(sock);
54269 -
54270 -       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
54271 -       config_writeb(socket, TI113X_CARD_CONTROL, ti_cardctl(socket));
54272 -       config_writeb(socket, TI113X_DEVICE_CONTROL, ti_devctl(socket));
54273 -       ti_intctl(socket);
54274         return 0;
54275  }
54276  
54277  static int ti113x_override(struct yenta_socket *socket)
54278  {
54279 -       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
54280 -       ti_cardctl(socket) = config_readb(socket, TI113X_CARD_CONTROL);
54281 -       ti_devctl(socket) = config_readb(socket, TI113X_DEVICE_CONTROL);
54282 +       u8 cardctl;
54283  
54284 -       ti_cardctl(socket) &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC);
54285 +       cardctl = config_readb(socket, TI113X_CARD_CONTROL);
54286 +       cardctl &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC);
54287         if (socket->cb_irq)
54288 -               ti_cardctl(socket) |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ;
54289 -       ti_override(socket);
54290 -       socket->socket.ops->init = ti113x_init;
54291 -       return 0;
54292 +               cardctl |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ;
54293 +       config_writeb(socket, TI113X_CARD_CONTROL, cardctl);
54294 +
54295 +       return ti_override(socket);
54296  }
54297  
54298  
54299 -static int ti1250_init(struct pcmcia_socket *sock)
54300 +static int ti12xx_override(struct yenta_socket *socket)
54301  {
54302 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
54303 -       ti113x_init(sock);
54304 -       ti_irqmux(socket) = config_readl(socket, TI122X_IRQMUX);
54305 -#if 0
54306 -       ti_irqmux(socket) = (ti_irqmux(socket) & ~0x0f) | 0x02; /* route INTA */
54307 -       if (!(ti_sysctl(socket) & TI122X_SCR_INTRTIE))
54308 -               ti_irqmux(socket) |= 0x20; /* route INTB */
54309 -#endif
54310 -       
54311 -       config_writel(socket, TI122X_IRQMUX, ti_irqmux(socket));
54312 -               
54313 -       config_writeb(socket, TI1250_DIAGNOSTIC, ti_diag(socket));
54314 -       return 0;
54315 +       u32 val;
54316 +
54317 +       /* make sure that memory burst is active */
54318 +       val = config_readl(socket, TI113X_SYSTEM_CONTROL);
54319 +       if (!(val & TI122X_SCR_MRBURSTUP)) {
54320 +               printk(KERN_INFO "Yenta: Enabling burst memory read transactions\n");
54321 +               val |= TI122X_SCR_MRBURSTUP;
54322 +               config_writel(socket, TI113X_SYSTEM_CONTROL, val);
54323 +       }
54324 +
54325 +       /*
54326 +        * Yenta expects controllers to use CSCINT to route
54327 +        * CSC interrupts to PCI rather than INTVAL.
54328 +        */
54329 +       val = config_readb(socket, TI1250_DIAGNOSTIC);
54330 +       printk(KERN_INFO "Yenta: Using %s to route CSC interrupts to PCI\n",
54331 +               (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL");
54332 +       printk(KERN_INFO "Yenta: Routing CardBus interrupts to %s\n",
54333 +               (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA");
54334 +
54335 +       return ti_override(socket);
54336  }
54337  
54338 +
54339  static int ti1250_override(struct yenta_socket *socket)
54340  {
54341 -       ti_diag(socket) = config_readb(socket, TI1250_DIAGNOSTIC);
54342 +       u8 old, diag;
54343  
54344 -       ti_diag(socket) &= ~(TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ);
54345 +       old = config_readb(socket, TI1250_DIAGNOSTIC);
54346 +       diag = old & ~(TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ);
54347         if (socket->cb_irq)
54348 -               ti_diag(socket) |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ;
54349 -       ti113x_override(socket);
54350 -       socket->socket.ops->init = ti1250_init;
54351 -       return 0;
54352 -}
54353 +               diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ;
54354  
54355 +       if (diag != old) {
54356 +               printk(KERN_INFO "Yenta: adjusting diagnostic: %02x -> %02x\n",
54357 +                       old, diag);
54358 +               config_writeb(socket, TI1250_DIAGNOSTIC, diag);
54359 +       }
54360  
54361 -static int ti12xx_override(struct yenta_socket *socket)
54362 -{
54363 -       /* make sure that memory burst is active */
54364 -       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
54365 -       ti_sysctl(socket) |= TI122X_SCR_MRBURSTUP;
54366 -       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
54367 +#if 0
54368 +       /*
54369 +        * This is highly machine specific, and we should NOT touch
54370 +        * this register - we have no knowledge how the hardware
54371 +        * is actually wired.
54372 +        *
54373 +        * If we're going to do this, we should probably look into
54374 +        * using the subsystem IDs.
54375 +        *
54376 +        * On ThinkPad 380XD, this changes MFUNC0 from the ISA IRQ3
54377 +        * output (which it is) to IRQ2.  We also change MFUNC1
54378 +        * from ISA IRQ4 to IRQ6.
54379 +        */
54380 +       irqmux = config_readl(socket, TI122X_IRQMUX);
54381 +       irqmux = (irqmux & ~0x0f) | 0x02; /* route INTA */
54382 +       if (!(ti_sysctl(socket) & TI122X_SCR_INTRTIE))
54383 +               irqmux = (irqmux & ~0xf0) | 0x20; /* route INTB */
54384 +       config_writel(socket, TI122X_IRQMUX, irqmux);
54385 +#endif
54386  
54387 -       return ti113x_override(socket);
54388 +       return ti12xx_override(socket);
54389  }
54390  
54391  #endif /* CONFIG_CARDBUS */
54392 diff -Nru a/drivers/pcmcia/topic.h b/drivers/pcmcia/topic.h
54393 --- a/drivers/pcmcia/topic.h    Fri Oct 18 16:11:25 2002
54394 +++ b/drivers/pcmcia/topic.h    Wed Aug 27 13:19:32 2003
54395 @@ -31,20 +31,7 @@
54396  #ifndef _LINUX_TOPIC_H
54397  #define _LINUX_TOPIC_H
54398  
54399 -#ifndef PCI_VENDOR_ID_TOSHIBA
54400 -#define PCI_VENDOR_ID_TOSHIBA          0x1179
54401 -#endif
54402 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC95_A
54403 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_A        0x0603
54404 -#endif
54405 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC95_B
54406 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_B        0x060a
54407 -#endif
54408 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC97
54409 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC97  0x060f
54410 -#endif
54411 -
54412 -/* Register definitions for Toshiba ToPIC95 controllers */
54413 +/* Register definitions for Toshiba ToPIC95/97/100 controllers */
54414  
54415  #define TOPIC_SOCKET_CONTROL           0x0090  /* 32 bit */
54416  #define  TOPIC_SCR_IRQSEL              0x00000001
54417 @@ -92,5 +79,62 @@
54418  #define  TOPIC97_RCR_RI_DISABLE                0x00000004
54419  #define  TOPIC97_RCR_CAUDIO_OFF                0x00000002
54420  #define  TOPIC_RCR_CAUDIO_INVERT       0x00000001
54421 +
54422 +#define TOPIC97_MISC1                  0x00ad  /* 8bit */
54423 +#define  TOPIC97_MISC1_CLOCKRUN_ENABLE 0x80
54424 +#define  TOPIC97_MISC1_CLOCKRUN_MODE   0x40
54425 +#define  TOPIC97_MISC1_DETECT_REQ_ENA  0x10
54426 +#define  TOPIC97_MISC1_SCK_CLEAR_DIS   0x04
54427 +#define  TOPIC97_MISC1_R2_LOW_ENABLE   0x10
54428 +
54429 +#define TOPIC97_MISC2                  0x00ae  /* 8 bit */
54430 +#define  TOPIC97_MISC2_SPWRCLK_MASK    0x70
54431 +#define  TOPIC97_MISC2_SPWRMOD         0x08
54432 +#define  TOPIC97_MISC2_SPWR_ENABLE     0x04
54433 +#define  TOPIC97_MISC2_ZV_MODE         0x02
54434 +#define  TOPIC97_MISC2_ZV_ENABLE       0x01
54435 +
54436 +#define TOPIC97_ZOOM_VIDEO_CONTROL     0x009c  /* 8 bit */
54437 +#define  TOPIC97_ZV_CONTROL_ENABLE     0x01
54438 +
54439 +#define TOPIC97_AUDIO_VIDEO_SWITCH     0x003c  /* 8 bit */
54440 +#define  TOPIC97_AVS_AUDIO_CONTROL     0x02
54441 +#define  TOPIC97_AVS_VIDEO_CONTROL     0x01
54442 +
54443 +
54444 +static void topic97_zoom_video(struct pcmcia_socket *sock, int onoff)
54445 +{
54446 +       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
54447 +       u8 reg_zv, reg;
54448 +
54449 +       reg_zv = config_readb(socket, TOPIC97_ZOOM_VIDEO_CONTROL);
54450 +       if (onoff) {
54451 +               reg_zv |= TOPIC97_ZV_CONTROL_ENABLE;
54452 +               config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
54453 +
54454 +               reg = config_readb(socket, TOPIC97_MISC2);
54455 +               reg |= TOPIC97_MISC2_ZV_ENABLE;
54456 +               config_writeb(socket, TOPIC97_MISC2, reg);
54457 +
54458 +               /* not sure this is needed, doc is unclear */
54459 +#if 0
54460 +               reg = config_readb(socket, TOPIC97_AUDIO_VIDEO_SWITCH);
54461 +               reg |= TOPIC97_AVS_AUDIO_CONTROL | TOPIC97_AVS_VIDEO_CONTROL;
54462 +               config_writeb(socket, TOPIC97_AUDIO_VIDEO_SWITCH, reg);
54463 +#endif
54464 +       }
54465 +       else {
54466 +               reg_zv &= ~TOPIC97_ZV_CONTROL_ENABLE;
54467 +               config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
54468 +       }
54469 +
54470 +}
54471 +
54472 +static int topic97_override(struct yenta_socket *socket)
54473 +{
54474 +       /* ToPIC97/100 support ZV */
54475 +       socket->socket.zoom_video = topic97_zoom_video;
54476 +       return 0;
54477 +}
54478  
54479  #endif /* _LINUX_TOPIC_H */
54480 diff -Nru a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
54481 --- a/drivers/pcmcia/yenta_socket.c     Thu Aug 14 16:53:49 2003
54482 +++ b/drivers/pcmcia/yenta_socket.c     Wed Aug 27 13:19:32 2003
54483 @@ -443,73 +443,6 @@
54484         add_timer(&socket->poll_timer);
54485  }
54486  
54487 -/*
54488 - * Only probe "regular" interrupts, don't
54489 - * touch dangerous spots like the mouse irq,
54490 - * because there are mice that apparently
54491 - * get really confused if they get fondled
54492 - * too intimately.
54493 - *
54494 - * Default to 11, 10, 9, 7, 6, 5, 4, 3.
54495 - */
54496 -static u32 isa_interrupts = 0x0ef8;
54497 -
54498 -static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
54499 -{
54500 -       int i;
54501 -       unsigned long val;
54502 -       u16 bridge_ctrl;
54503 -       u32 mask;
54504 -
54505 -       /* Set up ISA irq routing to probe the ISA irqs.. */
54506 -       bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
54507 -       if (!(bridge_ctrl & CB_BRIDGE_INTR)) {
54508 -               bridge_ctrl |= CB_BRIDGE_INTR;
54509 -               config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
54510 -       }
54511 -
54512 -       /*
54513 -        * Probe for usable interrupts using the force
54514 -        * register to generate bogus card status events.
54515 -        */
54516 -       cb_writel(socket, CB_SOCKET_EVENT, -1);
54517 -       cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
54518 -       exca_writeb(socket, I365_CSCINT, 0);
54519 -       val = probe_irq_on() & isa_irq_mask;
54520 -       for (i = 1; i < 16; i++) {
54521 -               if (!((val >> i) & 1))
54522 -                       continue;
54523 -               exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4));
54524 -               cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
54525 -               udelay(100);
54526 -               cb_writel(socket, CB_SOCKET_EVENT, -1);
54527 -       }
54528 -       cb_writel(socket, CB_SOCKET_MASK, 0);
54529 -       exca_writeb(socket, I365_CSCINT, 0);
54530 -       
54531 -       mask = probe_irq_mask(val) & 0xffff;
54532 -
54533 -       bridge_ctrl &= ~CB_BRIDGE_INTR;
54534 -       config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
54535 -
54536 -       return mask;
54537 -}
54538 -
54539 -/*
54540 - * Set static data that doesn't need re-initializing..
54541 - */
54542 -static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
54543 -{
54544 -       socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
54545 -       socket->socket.map_size = 0x1000;
54546 -       socket->socket.pci_irq = socket->cb_irq;
54547 -       socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
54548 -       socket->socket.cb_dev = socket->dev;
54549 -
54550 -       printk("Yenta IRQ list %04x, PCI irq%d\n", socket->socket.irq_mask, socket->cb_irq);
54551 -}
54552 -
54553 -
54554  static void yenta_clear_maps(struct yenta_socket *socket)
54555  {
54556         int i;
54557 @@ -528,42 +461,13 @@
54558         }
54559  }
54560  
54561 -/*
54562 - * Initialize the standard cardbus registers
54563 - */
54564 -static void yenta_config_init(struct yenta_socket *socket)
54565 +/* Called at resume and initialization events */
54566 +static int yenta_sock_init(struct pcmcia_socket *sock)
54567  {
54568 +       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
54569         u16 bridge;
54570 -       struct pci_dev *dev = socket->dev;
54571 -
54572 -       pci_set_power_state(socket->dev, 0);
54573 -
54574 -       config_writel(socket, CB_LEGACY_MODE_BASE, 0);
54575 -       config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start);
54576 -       config_writew(socket, PCI_COMMAND,
54577 -                       PCI_COMMAND_IO |
54578 -                       PCI_COMMAND_MEMORY |
54579 -                       PCI_COMMAND_MASTER |
54580 -                       PCI_COMMAND_WAIT);
54581 -
54582 -       /* MAGIC NUMBERS! Fixme */
54583 -       config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
54584 -       config_writeb(socket, PCI_LATENCY_TIMER, 168);
54585 -       config_writel(socket, PCI_PRIMARY_BUS,
54586 -               (176 << 24) |                      /* sec. latency timer */
54587 -               (dev->subordinate->subordinate << 16) | /* subordinate bus */
54588 -               (dev->subordinate->secondary << 8) |  /* secondary bus */
54589 -               dev->subordinate->primary);                /* primary bus */
54590  
54591 -       /*
54592 -        * Set up the bridging state:
54593 -        *  - enable write posting.
54594 -        *  - memory window 0 prefetchable, window 1 non-prefetchable
54595 -        *  - PCI interrupts enabled if a PCI interrupt exists..
54596 -        */
54597 -       bridge = config_readw(socket, CB_BRIDGE_CONTROL);
54598 -       bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_INTR | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
54599 -       bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN;
54600 +       bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~CB_BRIDGE_INTR;
54601         if (!socket->cb_irq)
54602                 bridge |= CB_BRIDGE_INTR;
54603         config_writew(socket, CB_BRIDGE_CONTROL, bridge);
54604 @@ -573,41 +477,27 @@
54605  
54606         /* Redo card voltage interrogation */
54607         cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST);
54608 -}
54609  
54610 -/* Called at resume and initialization events */
54611 -static int yenta_init(struct pcmcia_socket *sock)
54612 -{
54613 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
54614 -       yenta_config_init(socket);
54615         yenta_clear_maps(socket);
54616  
54617 -       /* Re-enable interrupts */
54618 +       if (socket->type && socket->type->sock_init)
54619 +               socket->type->sock_init(socket);
54620 +
54621 +       /* Re-enable CSC interrupts */
54622         cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
54623 +
54624         return 0;
54625  }
54626  
54627 -static int yenta_suspend(struct pcmcia_socket *sock)
54628 +static int yenta_sock_suspend(struct pcmcia_socket *sock)
54629  {
54630         struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
54631  
54632         yenta_set_socket(sock, &dead_socket);
54633  
54634 -       /* Disable interrupts */
54635 +       /* Disable CSC interrupts */
54636         cb_writel(socket, CB_SOCKET_MASK, 0x0);
54637  
54638 -       /*
54639 -        * This does not work currently. The controller
54640 -        * loses too much information during D3 to come up
54641 -        * cleanly. We should probably fix yenta_init()
54642 -        * to update all the critical registers, notably
54643 -        * the IO and MEM bridging region data.. That is
54644 -        * something that pci_set_power_state() should
54645 -        * probably know about bridges anyway.
54646 -        *
54647 -       pci_set_power_state(socket->dev, 3);
54648 -        */
54649 -
54650         return 0;
54651  }
54652  
54653 @@ -758,8 +648,8 @@
54654  
54655  
54656  static struct pccard_operations yenta_socket_operations = {
54657 -       .init                   = yenta_init,
54658 -       .suspend                = yenta_suspend,
54659 +       .init                   = yenta_sock_init,
54660 +       .suspend                = yenta_sock_suspend,
54661         .get_status             = yenta_get_status,
54662         .get_socket             = yenta_get_socket,
54663         .set_socket             = yenta_set_socket,
54664 @@ -770,52 +660,165 @@
54665  
54666  #include "ti113x.h"
54667  #include "ricoh.h"
54668 +#include "topic.h"
54669 +
54670 +enum {
54671 +       CARDBUS_TYPE_DEFAULT = -1,
54672 +       CARDBUS_TYPE_TI,
54673 +       CARDBUS_TYPE_TI113X,
54674 +       CARDBUS_TYPE_TI12XX,
54675 +       CARDBUS_TYPE_TI1250,
54676 +       CARDBUS_TYPE_RICOH,
54677 +       CARDBUS_TYPE_TOPIC97
54678 +};
54679  
54680  /*
54681   * Different cardbus controllers have slightly different
54682   * initialization sequences etc details. List them here..
54683   */
54684 -#define PD(x,y) PCI_VENDOR_ID_##x, PCI_DEVICE_ID_##x##_##y
54685 -struct cardbus_override_struct {
54686 -       unsigned short vendor;
54687 -       unsigned short device;
54688 -       int (*override) (struct yenta_socket *socket);
54689 -} cardbus_override[] = {
54690 -       { PD(TI,1031),  &ti_override },
54691 -
54692 -       /* TBD: Check if these TI variants can use more
54693 -        * advanced overrides instead */
54694 -       { PD(TI,1210),  &ti_override },
54695 -       { PD(TI,1211),  &ti_override },
54696 -       { PD(TI,1251A), &ti_override },
54697 -       { PD(TI,1251B), &ti_override },
54698 -       { PD(TI,1420),  &ti_override },
54699 -       { PD(TI,1450),  &ti_override },
54700 -       { PD(TI,4410),  &ti_override },
54701 -       { PD(TI,4451),  &ti_override },
54702 -
54703 -       { PD(TI,1130),  &ti113x_override },
54704 -       { PD(TI,1131),  &ti113x_override },
54705 -
54706 -       { PD(TI,1220),  &ti12xx_override },
54707 -       { PD(TI,1221),  &ti12xx_override },
54708 -       { PD(TI,1225),  &ti12xx_override },
54709 -       { PD(TI,1520),  &ti12xx_override },
54710 -
54711 -       { PD(TI,1250),  &ti1250_override },
54712 -       { PD(TI,1410),  &ti1250_override },
54713 -
54714 -       { PD(RICOH,RL5C465), &ricoh_override },
54715 -       { PD(RICOH,RL5C466), &ricoh_override },
54716 -       { PD(RICOH,RL5C475), &ricoh_override },
54717 -       { PD(RICOH,RL5C476), &ricoh_override },
54718 -       { PD(RICOH,RL5C478), &ricoh_override },
54719 -
54720 -       { }, /* all zeroes */
54721 +struct cardbus_type cardbus_type[] = {
54722 +       [CARDBUS_TYPE_TI]       = {
54723 +               .override       = ti_override,
54724 +               .save_state     = ti_save_state,
54725 +               .restore_state  = ti_restore_state,
54726 +               .sock_init      = ti_init,
54727 +       },
54728 +       [CARDBUS_TYPE_TI113X]   = {
54729 +               .override       = ti113x_override,
54730 +               .save_state     = ti_save_state,
54731 +               .restore_state  = ti_restore_state,
54732 +               .sock_init      = ti_init,
54733 +       },
54734 +       [CARDBUS_TYPE_TI12XX]   = {
54735 +               .override       = ti12xx_override,
54736 +               .save_state     = ti_save_state,
54737 +               .restore_state  = ti_restore_state,
54738 +               .sock_init      = ti_init,
54739 +       },
54740 +       [CARDBUS_TYPE_TI1250]   = {
54741 +               .override       = ti1250_override,
54742 +               .save_state     = ti_save_state,
54743 +               .restore_state  = ti_restore_state,
54744 +               .sock_init      = ti_init,
54745 +       },
54746 +       [CARDBUS_TYPE_RICOH]    = {
54747 +               .override       = ricoh_override,
54748 +               .save_state     = ricoh_save_state,
54749 +               .restore_state  = ricoh_restore_state,
54750 +       },
54751 +       [CARDBUS_TYPE_TOPIC97]  = {
54752 +               .override       = topic97_override,
54753 +       },
54754  };
54755  
54756  
54757  /*
54758 + * Only probe "regular" interrupts, don't
54759 + * touch dangerous spots like the mouse irq,
54760 + * because there are mice that apparently
54761 + * get really confused if they get fondled
54762 + * too intimately.
54763 + *
54764 + * Default to 11, 10, 9, 7, 6, 5, 4, 3.
54765 + */
54766 +static u32 isa_interrupts = 0x0ef8;
54767 +
54768 +static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
54769 +{
54770 +       int i;
54771 +       unsigned long val;
54772 +       u16 bridge_ctrl;
54773 +       u32 mask;
54774 +
54775 +       /* Set up ISA irq routing to probe the ISA irqs.. */
54776 +       bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
54777 +       if (!(bridge_ctrl & CB_BRIDGE_INTR)) {
54778 +               bridge_ctrl |= CB_BRIDGE_INTR;
54779 +               config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
54780 +       }
54781 +
54782 +       /*
54783 +        * Probe for usable interrupts using the force
54784 +        * register to generate bogus card status events.
54785 +        */
54786 +       cb_writel(socket, CB_SOCKET_EVENT, -1);
54787 +       cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
54788 +       exca_writeb(socket, I365_CSCINT, 0);
54789 +       val = probe_irq_on() & isa_irq_mask;
54790 +       for (i = 1; i < 16; i++) {
54791 +               if (!((val >> i) & 1))
54792 +                       continue;
54793 +               exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4));
54794 +               cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
54795 +               udelay(100);
54796 +               cb_writel(socket, CB_SOCKET_EVENT, -1);
54797 +       }
54798 +       cb_writel(socket, CB_SOCKET_MASK, 0);
54799 +       exca_writeb(socket, I365_CSCINT, 0);
54800 +
54801 +       mask = probe_irq_mask(val) & 0xffff;
54802 +
54803 +       bridge_ctrl &= ~CB_BRIDGE_INTR;
54804 +       config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
54805 +
54806 +       return mask;
54807 +}
54808 +
54809 +/*
54810 + * Set static data that doesn't need re-initializing..
54811 + */
54812 +static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
54813 +{
54814 +       socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
54815 +       socket->socket.map_size = 0x1000;
54816 +       socket->socket.pci_irq = socket->cb_irq;
54817 +       socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
54818 +       socket->socket.cb_dev = socket->dev;
54819 +
54820 +       printk(KERN_INFO "Yenta: ISA IRQ list %04x, PCI irq%d\n",
54821 +              socket->socket.irq_mask, socket->cb_irq);
54822 +}
54823 +
54824 +/*
54825 + * Initialize the standard cardbus registers
54826 + */
54827 +static void yenta_config_init(struct yenta_socket *socket)
54828 +{
54829 +       u16 bridge;
54830 +       struct pci_dev *dev = socket->dev;
54831 +
54832 +       pci_set_power_state(socket->dev, 0);
54833 +
54834 +       config_writel(socket, CB_LEGACY_MODE_BASE, 0);
54835 +       config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start);
54836 +       config_writew(socket, PCI_COMMAND,
54837 +                       PCI_COMMAND_IO |
54838 +                       PCI_COMMAND_MEMORY |
54839 +                       PCI_COMMAND_MASTER |
54840 +                       PCI_COMMAND_WAIT);
54841 +
54842 +       /* MAGIC NUMBERS! Fixme */
54843 +       config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
54844 +       config_writeb(socket, PCI_LATENCY_TIMER, 168);
54845 +       config_writel(socket, PCI_PRIMARY_BUS,
54846 +               (176 << 24) |                      /* sec. latency timer */
54847 +               (dev->subordinate->subordinate << 16) | /* subordinate bus */
54848 +               (dev->subordinate->secondary << 8) |  /* secondary bus */
54849 +               dev->subordinate->primary);                /* primary bus */
54850 +
54851 +       /*
54852 +        * Set up the bridging state:
54853 +        *  - enable write posting.
54854 +        *  - memory window 0 prefetchable, window 1 non-prefetchable
54855 +        *  - PCI interrupts enabled if a PCI interrupt exists..
54856 +        */
54857 +       bridge = config_readw(socket, CB_BRIDGE_CONTROL);
54858 +       bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_INTR | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
54859 +       bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN | CB_BRIDGE_INTR;
54860 +       config_writew(socket, CB_BRIDGE_CONTROL, bridge);
54861 +}
54862 +
54863 +/*
54864   * Initialize a cardbus controller. Make sure we have a usable
54865   * interrupt, and that we can map the cardbus area. Fill in the
54866   * socket information structure..
54867 @@ -823,7 +826,6 @@
54868  static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_id *id)
54869  {
54870         struct yenta_socket *socket;
54871 -       struct cardbus_override_struct *d;
54872         int ret;
54873         
54874         socket = kmalloc(sizeof(struct yenta_socket), GFP_KERNEL);
54875 @@ -887,14 +889,13 @@
54876         socket->cb_irq = dev->irq;
54877  
54878         /* Do we have special options for the device? */
54879 -       d = cardbus_override;
54880 -       while (d->override) {
54881 -               if ((dev->vendor == d->vendor) && (dev->device == d->device)) {
54882 -                       ret = d->override(socket);
54883 -                       if (ret < 0)
54884 -                               goto unmap;
54885 -               }
54886 -               d++;
54887 +       if (id->driver_data != CARDBUS_TYPE_DEFAULT &&
54888 +           id->driver_data < ARRAY_SIZE(cardbus_type)) {
54889 +               socket->type = &cardbus_type[id->driver_data];
54890 +
54891 +               ret = socket->type->override(socket);
54892 +               if (ret < 0)
54893 +                       goto unmap;
54894         }
54895  
54896         /* We must finish initialization here */
54897 @@ -933,25 +934,97 @@
54898  
54899  static int yenta_dev_suspend (struct pci_dev *dev, u32 state)
54900  {
54901 -       return pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
54902 +       struct yenta_socket *socket = pci_get_drvdata(dev);
54903 +       int ret;
54904 +
54905 +       ret = pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
54906 +
54907 +       if (socket) {
54908 +               if (socket->type && socket->type->save_state)
54909 +                       socket->type->save_state(socket);
54910 +
54911 +               /* FIXME: pci_save_state needs to have a better interface */
54912 +               pci_save_state(dev, socket->saved_state);
54913 +               pci_read_config_dword(dev, 16*4, &socket->saved_state[16]);
54914 +               pci_read_config_dword(dev, 17*4, &socket->saved_state[17]);
54915 +               pci_set_power_state(dev, 3);
54916 +       }
54917 +
54918 +       return ret;
54919  }
54920  
54921  
54922  static int yenta_dev_resume (struct pci_dev *dev)
54923  {
54924 +       struct yenta_socket *socket = pci_get_drvdata(dev);
54925 +
54926 +       if (socket) {
54927 +               pci_set_power_state(dev, 0);
54928 +               /* FIXME: pci_restore_state needs to have a better interface */
54929 +               pci_restore_state(dev, socket->saved_state);
54930 +               pci_write_config_dword(dev, 16*4, socket->saved_state[16]);
54931 +               pci_write_config_dword(dev, 17*4, socket->saved_state[17]);
54932 +
54933 +               if (socket->type && socket->type->restore_state)
54934 +                       socket->type->restore_state(socket);
54935 +       }
54936 +
54937         return pcmcia_socket_dev_resume(&dev->dev, RESUME_RESTORE_STATE);
54938  }
54939  
54940  
54941 -static struct pci_device_id yenta_table [] = { {
54942 -       .class          = PCI_CLASS_BRIDGE_CARDBUS << 8,
54943 -       .class_mask     = ~0,
54944 -
54945 -       .vendor         = PCI_ANY_ID,
54946 -       .device         = PCI_ANY_ID,
54947 -       .subvendor      = PCI_ANY_ID,
54948 -       .subdevice      = PCI_ANY_ID,
54949 -}, { /* all zeroes */ }
54950 +#define CB_ID(vend,dev,type)                           \
54951 +       {                                               \
54952 +               .vendor         = vend,                 \
54953 +               .device         = dev,                  \
54954 +               .subvendor      = PCI_ANY_ID,           \
54955 +               .subdevice      = PCI_ANY_ID,           \
54956 +               .class          = PCI_CLASS_BRIDGE_CARDBUS << 8, \
54957 +               .class_mask     = ~0,                   \
54958 +               .driver_data    = CARDBUS_TYPE_##type,  \
54959 +       }
54960 +
54961 +static struct pci_device_id yenta_table [] = {
54962 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1031, TI),
54963 +
54964 +       /*
54965 +        * TBD: Check if these TI variants can use more
54966 +        * advanced overrides instead.  (I can't get the
54967 +        * data sheets for these devices. --rmk)
54968 +        */
54969 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI),
54970 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251B, TI),
54971 +
54972 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X),
54973 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1131, TI113X),
54974 +
54975 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, TI12XX),
54976 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1220, TI12XX),
54977 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1221, TI12XX),
54978 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1225, TI12XX),
54979 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251A, TI12XX),
54980 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420, TI12XX),
54981 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1450, TI12XX),
54982 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520, TI12XX),
54983 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4410, TI12XX),
54984 +//     CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4450, TI12XX),
54985 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4451, TI12XX),
54986 +
54987 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250),
54988 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250),
54989 +
54990 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH),
54991 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH),
54992 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH),
54993 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH),
54994 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH),
54995 +
54996 +       CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97),
54997 +       CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97),
54998 +
54999 +       /* match any cardbus bridge */
55000 +       CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT),
55001 +       { /* all zeroes */ }
55002  };
55003  MODULE_DEVICE_TABLE(pci, yenta_table);
55004  
55005 diff -Nru a/drivers/pcmcia/yenta_socket.h b/drivers/pcmcia/yenta_socket.h
55006 --- a/drivers/pcmcia/yenta_socket.h     Mon Jun 30 13:33:00 2003
55007 +++ b/drivers/pcmcia/yenta_socket.h     Wed Aug 27 12:42:53 2003
55008 @@ -95,6 +95,15 @@
55009   */
55010  #define CB_MEM_PAGE(map)       (0x40 + (map))
55011  
55012 +struct yenta_socket;
55013 +
55014 +struct cardbus_type {
55015 +       int     (*override)(struct yenta_socket *);
55016 +       void    (*save_state)(struct yenta_socket *);
55017 +       void    (*restore_state)(struct yenta_socket *);
55018 +       int     (*sock_init)(struct yenta_socket *);
55019 +};
55020 +
55021  struct yenta_socket {
55022         struct pci_dev *dev;
55023         int cb_irq, io_irq;
55024 @@ -102,9 +111,13 @@
55025         struct timer_list poll_timer;
55026  
55027         struct pcmcia_socket socket;
55028 +       struct cardbus_type *type;
55029  
55030         /* A few words of private data for special stuff of overrides... */
55031         unsigned int private[8];
55032 +
55033 +       /* PCI saved state */
55034 +       u32 saved_state[18];
55035  };
55036  
55037  
55038 diff -Nru a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c
55039 --- a/drivers/s390/char/tape_char.c     Mon May 26 12:20:47 2003
55040 +++ b/drivers/s390/char/tape_char.c     Tue Aug 26 09:25:41 2003
55041 @@ -238,14 +238,14 @@
55042         struct tape_device *device;
55043         int minor, rc;
55044  
55045 -       if (major(filp->f_dentry->d_inode->i_rdev) != tapechar_major)
55046 +       if (imajor(filp->f_dentry->d_inode) != tapechar_major)
55047                 return -ENODEV;
55048 -       minor = minor(filp->f_dentry->d_inode->i_rdev);
55049 +       minor = iminor(filp->f_dentry->d_inode);
55050         device = tape_get_device(minor / TAPE_MINORS_PER_DEV);
55051         if (IS_ERR(device)) {
55052                 return PTR_ERR(device);
55053         }
55054 -       DBF_EVENT(6, "TCHAR:open: %x\n", minor(inode->i_rdev));
55055 +       DBF_EVENT(6, "TCHAR:open: %x\n", iminor(inode));
55056         rc = tape_open(device);
55057         if (rc == 0) {
55058                 rc = tape_assign(device);
55059 @@ -269,7 +269,7 @@
55060         struct tape_device *device;
55061  
55062         device = (struct tape_device *) filp->private_data;
55063 -       DBF_EVENT(6, "TCHAR:release: %x\n", minor(inode->i_rdev));
55064 +       DBF_EVENT(6, "TCHAR:release: %x\n", iminor(inode));
55065  #if 0
55066         // FIXME: this is broken. Either MTWEOF/MTWEOF/MTBSR is done
55067         // EVERYTIME the user switches from write to something different
55068 @@ -281,7 +281,7 @@
55069         /*
55070          * If this is the rewinding tape minor then rewind.
55071          */
55072 -       if ((minor(inode->i_rdev) & 1) != 0)
55073 +       if ((iminor(inode) & 1) != 0)
55074                 tape_mtop(device, MTREW, 1);
55075         if (device->char_data.idal_buf != NULL) {
55076                 idal_buffer_free(device->char_data.idal_buf);
55077 diff -Nru a/drivers/s390/char/tubio.h b/drivers/s390/char/tubio.h
55078 --- a/drivers/s390/char/tubio.h Wed Jun 11 12:32:58 2003
55079 +++ b/drivers/s390/char/tubio.h Tue Aug 26 09:25:41 2003
55080 @@ -377,7 +377,7 @@
55081   */
55082  extern inline tub_t *INODE2TUB(struct inode *ip)
55083  {
55084 -       unsigned int minor = minor(ip->i_rdev);
55085 +       unsigned int minor = iminor(ip);
55086         tub_t *tubp = NULL;
55087         if (minor == 0 && current->tty) {
55088                 if (current->tty->driver == tty3270_driver)
55089 diff -Nru a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
55090 --- a/drivers/s390/net/cu3088.c Sun May 25 17:00:00 2003
55091 +++ b/drivers/s390/net/cu3088.c Tue Aug 19 09:22:46 2003
55092 @@ -64,7 +64,7 @@
55093  group_write(struct device_driver *drv, const char *buf, size_t count)
55094  {
55095         const char *start, *end;
55096 -       char bus_ids[2][BUS_ID_SIZE], *argv[2];
55097 +       char bus_ids[2][BUS_ID_SIZE+1], *argv[2];
55098         int i;
55099         int ret;
55100         struct ccwgroup_driver *cdrv;
55101 @@ -79,7 +79,7 @@
55102  
55103                 if (!(end = strchr(start, delim[i])))
55104                         return count;
55105 -               len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start);
55106 +               len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start)+1;
55107                 strlcpy (bus_ids[i], start, len);
55108                 argv[i] = bus_ids[i];
55109                 start = end + 1;
55110 diff -Nru a/drivers/s390/net/qeth.c b/drivers/s390/net/qeth.c
55111 --- a/drivers/s390/net/qeth.c   Thu Jul 17 10:27:34 2003
55112 +++ b/drivers/s390/net/qeth.c   Sun Aug 31 16:14:08 2003
55113 @@ -9765,19 +9765,19 @@
55114  };
55115  
55116  static struct file_operations qeth_procfile_fops = {
55117 -       ioctl:qeth_procfile_ioctl,
55118 -       read:qeth_procfile_read,
55119 -       open:qeth_procfile_open,
55120 -       release:qeth_procfile_release,
55121 +       .ioctl = qeth_procfile_ioctl,
55122 +       .read = qeth_procfile_read,
55123 +       .open = qeth_procfile_open,
55124 +       .release = qeth_procfile_release,
55125  };
55126  
55127  static struct proc_dir_entry *qeth_proc_file;
55128  
55129  static struct file_operations qeth_ipato_procfile_fops = {
55130 -       read:qeth_procfile_read,        /* same as above! */
55131 -       write:qeth_ipato_procfile_write,
55132 -       open:qeth_ipato_procfile_open,
55133 -       release:qeth_procfile_release   /* same as above! */
55134 +       .read = qeth_procfile_read,     /* same as above! */
55135 +       .write = qeth_ipato_procfile_write,
55136 +       .open = qeth_ipato_procfile_open,
55137 +       .release = qeth_procfile_release        /* same as above! */
55138  };
55139  
55140  static struct proc_dir_entry *qeth_ipato_proc_file;
55141 diff -Nru a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c
55142 --- a/drivers/sbus/char/bpp.c   Wed May  7 08:47:30 2003
55143 +++ b/drivers/sbus/char/bpp.c   Tue Aug 26 09:25:41 2003
55144 @@ -440,7 +440,7 @@
55145   */
55146  static int bpp_open(struct inode *inode, struct file *f)
55147  {
55148 -      unsigned minor = minor(inode->i_rdev);
55149 +      unsigned minor = iminor(inode);
55150        int ret;
55151  
55152        spin_lock(&bpp_open_lock);
55153 @@ -470,7 +470,7 @@
55154   */
55155  static int bpp_release(struct inode *inode, struct file *f)
55156  {
55157 -      unsigned minor = minor(inode->i_rdev);
55158 +      unsigned minor = iminor(inode);
55159  
55160        spin_lock(&bpp_open_lock);
55161        instances[minor].opened = 0;
55162 @@ -634,7 +634,7 @@
55163  static ssize_t bpp_read(struct file *f, char *c, size_t cnt, loff_t * ppos)
55164  {
55165        long rc;
55166 -      const unsigned minor = minor(f->f_dentry->d_inode->i_rdev);
55167 +      unsigned minor = iminor(f->f_dentry->d_inode);
55168        if (minor >= BPP_NO) return -ENODEV;
55169        if (!instances[minor].present) return -ENODEV;
55170  
55171 @@ -787,7 +787,7 @@
55172  static ssize_t bpp_write(struct file *f, const char *c, size_t cnt, loff_t * ppos)
55173  {
55174        long errno = 0;
55175 -      const unsigned minor = minor(f->f_dentry->d_inode->i_rdev);
55176 +      unsigned minor = iminor(f->f_dentry->d_inode);
55177        if (minor >= BPP_NO) return -ENODEV;
55178        if (!instances[minor].present) return -ENODEV;
55179  
55180 @@ -813,7 +813,7 @@
55181  {
55182        int errno = 0;
55183  
55184 -      unsigned minor = minor(inode->i_rdev);
55185 +      unsigned minor = iminor(inode);
55186        if (minor >= BPP_NO) return -ENODEV;
55187        if (!instances[minor].present) return -ENODEV;
55188  
55189 diff -Nru a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c
55190 --- a/drivers/sbus/char/cpwatchdog.c    Tue Apr 22 23:40:00 2003
55191 +++ b/drivers/sbus/char/cpwatchdog.c    Tue Aug 26 09:25:41 2003
55192 @@ -295,7 +295,7 @@
55193  
55194  static int wd_open(struct inode *inode, struct file *f)
55195  {
55196 -       switch(minor(inode->i_rdev))
55197 +       switch(iminor(inode))
55198         {
55199                 case WD0_MINOR:
55200                         f->private_data = &wd_dev.watchdog[WD0_ID];
55201 diff -Nru a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
55202 --- a/drivers/sbus/char/display7seg.c   Thu Jan 16 11:49:15 2003
55203 +++ b/drivers/sbus/char/display7seg.c   Tue Aug 26 09:25:41 2003
55204 @@ -91,7 +91,7 @@
55205  
55206  static int d7s_open(struct inode *inode, struct file *f)
55207  {
55208 -       if (D7S_MINOR != minor(inode->i_rdev))
55209 +       if (D7S_MINOR != iminor(inode))
55210                 return -ENODEV;
55211         atomic_inc(&d7s_users);
55212         return 0;
55213 @@ -121,7 +121,7 @@
55214         __u8 regs = readb(d7s_regs);
55215         __u8 ireg = 0;
55216  
55217 -       if (D7S_MINOR != minor(inode->i_rdev))
55218 +       if (D7S_MINOR != iminor(inode))
55219                 return -ENODEV;
55220  
55221         switch (cmd) {
55222 diff -Nru a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c
55223 --- a/drivers/sbus/char/rtc.c   Thu Jul 18 23:11:59 2002
55224 +++ b/drivers/sbus/char/rtc.c   Mon Sep  1 00:27:41 2003
55225 @@ -28,7 +28,7 @@
55226  static int rtc_busy = 0;
55227  
55228  /* Retrieve the current date and time from the real time clock. */
55229 -void get_rtc_time(struct rtc_time *t)
55230 +static void get_rtc_time(struct rtc_time *t)
55231  {
55232         unsigned long regs = mstk48t02_regs;
55233         u8 tmp;
55234 diff -Nru a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c
55235 --- a/drivers/sbus/char/vfc_dev.c       Wed May  7 08:47:30 2003
55236 +++ b/drivers/sbus/char/vfc_dev.c       Tue Aug 26 09:25:41 2003
55237 @@ -184,7 +184,7 @@
55238         struct vfc_dev *dev;
55239  
55240         spin_lock(&vfc_dev_lock);
55241 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
55242 +       dev = vfc_get_dev_ptr(iminor(inode));
55243         if (dev == NULL) {
55244                 spin_unlock(&vfc_dev_lock);
55245                 return -ENODEV;
55246 @@ -215,7 +215,7 @@
55247         struct vfc_dev *dev;
55248  
55249         spin_lock(&vfc_dev_lock);
55250 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
55251 +       dev = vfc_get_dev_ptr(iminor(inode));
55252         if (!dev || !dev->busy) {
55253                 spin_unlock(&vfc_dev_lock);
55254                 return -EINVAL;
55255 @@ -557,7 +557,7 @@
55256         unsigned int tmp;
55257         struct vfc_dev *dev;
55258  
55259 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
55260 +       dev = vfc_get_dev_ptr(iminor(inode));
55261         if(dev == NULL)
55262                 return -ENODEV;
55263         
55264 @@ -602,7 +602,7 @@
55265                 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCRDINFO)\n", dev->instance));
55266                 break;
55267         default:
55268 -               ret = vfc_debug(vfc_get_dev_ptr(MINOR(inode->i_rdev)),
55269 +               ret = vfc_debug(vfc_get_dev_ptr(iminor(inode)),
55270                                 cmd, arg);
55271                 break;
55272         };
55273 @@ -616,7 +616,7 @@
55274         unsigned int map_size, ret, map_offset;
55275         struct vfc_dev *dev;
55276         
55277 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
55278 +       dev = vfc_get_dev_ptr(iminor(inode));
55279         if(dev == NULL)
55280                 return -ENODEV;
55281  
55282 diff -Nru a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
55283 --- a/drivers/scsi/3w-xxxx.c    Sat Aug 16 11:46:50 2003
55284 +++ b/drivers/scsi/3w-xxxx.c    Tue Aug 26 09:25:41 2003
55285 @@ -628,7 +628,7 @@
55286         unsigned long *cpu_addr;
55287         TW_New_Ioctl *tw_ioctl;
55288         TW_Passthru *passthru;
55289 -       TW_Device_Extension *tw_dev = tw_device_extension_list[minor(inode->i_rdev)];
55290 +       TW_Device_Extension *tw_dev = tw_device_extension_list[iminor(inode)];
55291         int retval = -EFAULT;
55292  
55293         dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");
55294 @@ -786,7 +786,7 @@
55295  
55296         dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n");
55297  
55298 -       minor_number = minor(inode->i_rdev);
55299 +       minor_number = iminor(inode);
55300         if (minor_number >= tw_device_extension_count)
55301                 return -ENODEV;
55302  
55303 diff -Nru a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h
55304 --- a/drivers/scsi/3w-xxxx.h    Mon May 12 07:26:10 2003
55305 +++ b/drivers/scsi/3w-xxxx.h    Mon Sep  1 17:20:32 2003
55306 @@ -59,42 +59,37 @@
55307  
55308  /* AEN strings */
55309  static char *tw_aen_string[] = {
55310 -       "INFO: AEN queue empty",                       // 0x000
55311 -       "INFO: Soft reset occurred",                   // 0x001
55312 -       "ERROR: Unit degraded: Unit #",                // 0x002
55313 -       "ERROR: Controller error",                     // 0x003 
55314 -       "ERROR: Rebuild failed: Unit #",               // 0x004
55315 -       "INFO: Rebuild complete: Unit #",              // 0x005
55316 -       "ERROR: Incomplete unit detected: Unit #",     // 0x006
55317 -       "INFO: Initialization complete: Unit #",       // 0x007
55318 -       "WARNING: Unclean shutdown detected: Unit #",  // 0x008
55319 -       "WARNING: ATA port timeout: Port #",           // 0x009
55320 -       "ERROR: Drive error: Port #",                  // 0x00A
55321 -       "INFO: Rebuild started: Unit #",               // 0x00B 
55322 -       "INFO: Initialization started: Unit #",        // 0x00C
55323 -       "ERROR: Logical unit deleted: Unit #",         // 0x00D
55324 -       NULL,                                          // 0x00E unused
55325 -       "WARNING: SMART threshold exceeded: Port #",   // 0x00F
55326 -       NULL, NULL, NULL, NULL, NULL,
55327 -       NULL, NULL, NULL, NULL, NULL,
55328 -       NULL, NULL, NULL, NULL, NULL,
55329 -       NULL, NULL,                                    // 0x010-0x020 unused
55330 -       "WARNING: ATA UDMA downgrade: Port #",         // 0x021
55331 -       "WARNING: ATA UDMA upgrade: Port #",           // 0x022
55332 -       "WARNING: Sector repair occurred: Port #",     // 0x023
55333 -       "ERROR: SBUF integrity check failure",         // 0x024
55334 -       "ERROR: Lost cached write: Port #",            // 0x025
55335 -       "ERROR: Drive ECC error detected: Port #",     // 0x026
55336 -       "ERROR: DCB checksum error: Port #",           // 0x027
55337 -       "ERROR: DCB unsupported version: Port #",      // 0x028
55338 -       "INFO: Verify started: Unit #",                // 0x029
55339 -       "ERROR: Verify failed: Port #",                // 0x02A
55340 -       "INFO: Verify complete: Unit #",               // 0x02B
55341 -       "WARNING: Overwrote bad sector during rebuild: Port #",  //0x02C
55342 -       "ERROR: Encountered bad sector during rebuild: Port #",  //0x02D
55343 -       "ERROR: Replacement drive is too small: Port #",         //0x02E
55344 -       "WARNING: Verify error: Unit not previously initialized: Unit #", //0x02F
55345 -       "ERROR: Drive not supported: Port #"           // 0x030
55346 +       [0x000] = "INFO: AEN queue empty",
55347 +       [0x001] = "INFO: Soft reset occurred",
55348 +       [0x002] = "ERROR: Unit degraded: Unit #",
55349 +       [0x003] = "ERROR: Controller error",
55350 +       [0x004] = "ERROR: Rebuild failed: Unit #",
55351 +       [0x005] = "INFO: Rebuild complete: Unit #",
55352 +       [0x006] = "ERROR: Incomplete unit detected: Unit #",
55353 +       [0x007] = "INFO: Initialization complete: Unit #",
55354 +       [0x008] = "WARNING: Unclean shutdown detected: Unit #",
55355 +       [0x009] = "WARNING: ATA port timeout: Port #",
55356 +       [0x00A] = "ERROR: Drive error: Port #",
55357 +       [0x00B] = "INFO: Rebuild started: Unit #",
55358 +       [0x00C] = "INFO: Initialization started: Unit #",
55359 +       [0x00D] = "ERROR: Logical unit deleted: Unit #",
55360 +       [0x00F] = "WARNING: SMART threshold exceeded: Port #",
55361 +       [0x021] = "WARNING: ATA UDMA downgrade: Port #",
55362 +       [0x021] = "WARNING: ATA UDMA upgrade: Port #",
55363 +       [0x023] = "WARNING: Sector repair occurred: Port #",
55364 +       [0x024] = "ERROR: SBUF integrity check failure",
55365 +       [0x025] = "ERROR: Lost cached write: Port #",
55366 +       [0x026] = "ERROR: Drive ECC error detected: Port #",
55367 +       [0x027] = "ERROR: DCB checksum error: Port #",
55368 +       [0x028] = "ERROR: DCB unsupported version: Port #",
55369 +       [0x029] = "INFO: Verify started: Unit #",
55370 +       [0x02A] = "ERROR: Verify failed: Port #",
55371 +       [0x02B] = "INFO: Verify complete: Unit #",
55372 +       [0x02C] = "WARNING: Overwrote bad sector during rebuild: Port #",
55373 +       [0x02D] = "ERROR: Encountered bad sector during rebuild: Port #",
55374 +       [0x02E] = "ERROR: Replacement drive is too small: Port #",
55375 +       [0x02F] = "WARNING: Verify error: Unit not previously initialized: Unit #",
55376 +       [0x030] = "ERROR: Drive not supported: Port #",
55377  };
55378  
55379  /*
55380 diff -Nru a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
55381 --- a/drivers/scsi/Kconfig      Sun Jun 29 20:43:06 2003
55382 +++ b/drivers/scsi/Kconfig      Wed Sep  3 23:40:08 2003
55383 @@ -355,7 +355,7 @@
55384  # All the I2O code and drivers do not seem to be 64bit safe.
55385  config SCSI_DPT_I2O
55386         tristate "Adaptec I2O RAID support "
55387 -       depends on !X86_64 && SCSI
55388 +       depends on !X86_64 && SCSI && BROKEN
55389         help
55390           This driver supports all of Adaptec's I2O based RAID controllers as 
55391           well as the DPT SmartRaid V cards.  This is an Adaptec maintained
55392 @@ -398,7 +398,7 @@
55393  # does not use pci dma and seems to be onboard only for old machines
55394  config SCSI_AM53C974
55395         tristate "AM53/79C974 PCI SCSI support"
55396 -       depends on X86 && PCI && SCSI
55397 +       depends on X86 && PCI && SCSI && BROKEN
55398         ---help---
55399           This is support for the AM53/79C974 SCSI host adapters.  Please read
55400           <file:Documentation/scsi/AM53C974.txt> for details.  Also, the
55401 @@ -742,7 +742,7 @@
55402  
55403  config SCSI_INITIO
55404         tristate "Initio 9100U(W) support"
55405 -       depends on PCI && SCSI
55406 +       depends on PCI && SCSI && BROKEN
55407         help
55408           This is support for the Initio 91XXU(W) SCSI host adapter.  Please
55409           read the SCSI-HOWTO, available from
55410 @@ -1161,7 +1161,7 @@
55411  
55412  config SCSI_MCA_53C9X
55413         tristate "NCR MCA 53C9x SCSI support"
55414 -       depends on MCA && SCSI
55415 +       depends on MCA && SCSI && BROKEN_ON_SMP
55416         help
55417           Some MicroChannel machines, notably the NCR 35xx line, use a SCSI
55418           controller based on the NCR 53C94.  This driver will allow use of
55419 @@ -1189,7 +1189,7 @@
55420  
55421  config SCSI_PCI2000
55422         tristate "PCI2000 support"
55423 -       depends on PCI && SCSI
55424 +       depends on PCI && SCSI && BROKEN
55425         help
55426           This is support for the PCI2000I EIDE interface card which acts as a
55427           SCSI host adapter.  Please read the SCSI-HOWTO, available from
55428 @@ -1202,7 +1202,7 @@
55429  
55430  config SCSI_PCI2220I
55431         tristate "PCI2220i support"
55432 -       depends on PCI && SCSI
55433 +       depends on PCI && SCSI && BROKEN
55434         help
55435           This is support for the PCI2220i EIDE interface card which acts as a
55436           SCSI host adapter.  Please read the SCSI-HOWTO, available from
55437 @@ -1298,6 +1298,16 @@
55438           The module will be called qla1280. If you want to compile it as
55439           a module, say M here and read <file:Documentation/modules.txt>.
55440  
55441 +config SCSI_QLOGIC_1280_PIO
55442 +       bool "Use PIO instead of MMIO" if !X86_VISWS
55443 +       depends on SCSI_QLOGIC_1280
55444 +       default y if X86_VISWS
55445 +       help
55446 +         This instructs the driver to use programmed I/O ports (PIO) instead
55447 +         of PCI shared memory (MMIO).  This can possibly solve some problems
55448 +         in case your mainboard has memory consistency issues.  If unsure,
55449 +         say N.
55450 +
55451  config SCSI_QLOGICPTI
55452         tristate "PTI Qlogic, ISP Driver"
55453         depends on SBUS && SCSI
55454 @@ -1314,7 +1324,7 @@
55455  
55456  config SCSI_SEAGATE
55457         tristate "Seagate ST-02 and Future Domain TMC-8xx SCSI support"
55458 -       depends on X86 && ISA && SCSI
55459 +       depends on X86 && ISA && SCSI && BROKEN
55460         ---help---
55461           These are 8-bit SCSI controllers; the ST-01 is also supported by
55462           this driver.  It is explained in section 3.9 of the SCSI-HOWTO,
55463 @@ -1381,7 +1391,7 @@
55464  
55465  config SCSI_DC390T
55466         tristate "Tekram DC390(T) and Am53/79C974 SCSI support"
55467 -       depends on PCI && SCSI
55468 +       depends on PCI && SCSI && BROKEN
55469         ---help---
55470           This driver supports PCI SCSI host adapters based on the Am53C974A
55471           chip, e.g. Tekram DC390(T), DawiControl 2974 and some onboard
55472 diff -Nru a/drivers/scsi/a2091.h b/drivers/scsi/a2091.h
55473 --- a/drivers/scsi/a2091.h      Fri Dec 20 06:27:06 2002
55474 +++ b/drivers/scsi/a2091.h      Mon Sep  1 17:20:32 2003
55475 @@ -18,10 +18,6 @@
55476  int wd33c93_abort(Scsi_Cmnd *);
55477  int wd33c93_reset(Scsi_Cmnd *, unsigned int);
55478  
55479 -#ifndef NULL
55480 -#define NULL 0
55481 -#endif
55482 -
55483  #ifndef CMD_PER_LUN
55484  #define CMD_PER_LUN 2
55485  #endif
55486 diff -Nru a/drivers/scsi/a3000.h b/drivers/scsi/a3000.h
55487 --- a/drivers/scsi/a3000.h      Fri Dec 20 06:27:46 2002
55488 +++ b/drivers/scsi/a3000.h      Mon Sep  1 17:20:32 2003
55489 @@ -18,10 +18,6 @@
55490  int wd33c93_abort(Scsi_Cmnd *);
55491  int wd33c93_reset(Scsi_Cmnd *, unsigned int);
55492  
55493 -#ifndef NULL
55494 -#define NULL 0
55495 -#endif
55496 -
55497  #ifndef CMD_PER_LUN
55498  #define CMD_PER_LUN 2
55499  #endif
55500 diff -Nru a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
55501 --- a/drivers/scsi/aacraid/linit.c      Thu Jul 31 07:32:16 2003
55502 +++ b/drivers/scsi/aacraid/linit.c      Tue Aug 26 09:25:41 2003
55503 @@ -565,7 +565,7 @@
55504  
55505  static int aac_cfg_open(struct inode * inode, struct file * file )
55506  {
55507 -       unsigned minor_number = minor(inode->i_rdev);
55508 +       unsigned minor_number = iminor(inode);
55509         if(minor_number >= aac_count)
55510                 return -ENODEV;
55511         return 0;
55512 @@ -601,7 +601,7 @@
55513   
55514  static int aac_cfg_ioctl(struct inode * inode,  struct file * file, unsigned int cmd, unsigned long arg )
55515  {
55516 -       struct aac_dev *dev = aac_devices[minor(inode->i_rdev)];
55517 +       struct aac_dev *dev = aac_devices[iminor(inode)];
55518         return aac_do_ioctl(dev, cmd, (void *)arg);
55519  }
55520  
55521 diff -Nru a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
55522 --- a/drivers/scsi/advansys.c   Fri May  2 12:35:39 2003
55523 +++ b/drivers/scsi/advansys.c   Sun Aug 31 16:15:44 2003
55524 @@ -6199,7 +6199,9 @@
55525  
55526  static Scsi_Host_Template driver_template = {
55527      .proc_name                  = "advansys",
55528 +#ifdef CONFIG_PROC_FS
55529      .proc_info                  = advansys_proc_info,
55530 +#endif
55531      .name                       = "advansys",
55532      .detect                     = advansys_detect, 
55533      .release                    = advansys_release,
55534 diff -Nru a/drivers/scsi/aha1542.h b/drivers/scsi/aha1542.h
55535 --- a/drivers/scsi/aha1542.h    Mon Jul 14 07:50:01 2003
55536 +++ b/drivers/scsi/aha1542.h    Mon Sep  1 17:20:32 2003
55537 @@ -146,8 +146,4 @@
55538  #define AHA1542_SCATTER 16
55539  #define AHA1542_CMDLUN 1
55540  
55541 -#ifndef NULL
55542 -       #define NULL 0
55543 -#endif
55544 -
55545  #endif
55546 diff -Nru a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
55547 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c    Thu Jun 19 16:46:06 2003
55548 +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c    Sun Aug 31 16:14:08 2003
55549 @@ -72,10 +72,10 @@
55550  MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table);
55551  
55552  struct pci_driver aic79xx_pci_driver = {
55553 -       name:           "aic79xx",
55554 -       probe:          ahd_linux_pci_dev_probe,
55555 -       remove:         ahd_linux_pci_dev_remove,
55556 -       id_table:       ahd_linux_pci_id_table
55557 +       .name           = "aic79xx",
55558 +       .probe          = ahd_linux_pci_dev_probe,
55559 +       .remove         = ahd_linux_pci_dev_remove,
55560 +       .id_table       = ahd_linux_pci_id_table
55561  };
55562  
55563  static void
55564 diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
55565 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c    Wed May 14 15:00:40 2003
55566 +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c    Sun Aug 31 16:14:08 2003
55567 @@ -75,10 +75,10 @@
55568  MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table);
55569  
55570  struct pci_driver aic7xxx_pci_driver = {
55571 -       name:           "aic7xxx",
55572 -       probe:          ahc_linux_pci_dev_probe,
55573 -       remove:         ahc_linux_pci_dev_remove,
55574 -       id_table:       ahc_linux_pci_id_table
55575 +       .name           = "aic7xxx",
55576 +       .probe          = ahc_linux_pci_dev_probe,
55577 +       .remove         = ahc_linux_pci_dev_remove,
55578 +       .id_table       = ahc_linux_pci_id_table
55579  };
55580  
55581  static void
55582 diff -Nru a/drivers/scsi/amiga7xx.h b/drivers/scsi/amiga7xx.h
55583 --- a/drivers/scsi/amiga7xx.h   Fri Dec 20 06:28:14 2002
55584 +++ b/drivers/scsi/amiga7xx.h   Mon Sep  1 17:20:32 2003
55585 @@ -10,10 +10,6 @@
55586  int NCR53c7xx_reset(Scsi_Cmnd *, unsigned int);
55587  void NCR53c7x0_intr(int irq, void *dev_id, struct pt_regs * regs);
55588  
55589 -#ifndef NULL
55590 -#define NULL 0
55591 -#endif
55592 -
55593  #ifndef CMD_PER_LUN
55594  #define CMD_PER_LUN 3
55595  #endif
55596 diff -Nru a/drivers/scsi/atp870u.h b/drivers/scsi/atp870u.h
55597 --- a/drivers/scsi/atp870u.h    Sun Jun  8 12:18:41 2003
55598 +++ b/drivers/scsi/atp870u.h    Mon Sep  1 17:20:32 2003
55599 @@ -28,10 +28,6 @@
55600  #define ATP870U_SCATTER 128
55601  #define ATP870U_CMDLUN 1
55602  
55603 -#ifndef NULL
55604 -#define NULL 0
55605 -#endif
55606 -
55607  extern const char *atp870u_info(struct Scsi_Host *);
55608  
55609  #endif
55610 diff -Nru a/drivers/scsi/bvme6000.h b/drivers/scsi/bvme6000.h
55611 --- a/drivers/scsi/bvme6000.h   Fri Dec 20 06:31:43 2002
55612 +++ b/drivers/scsi/bvme6000.h   Mon Sep  1 17:20:32 2003
55613 @@ -11,10 +11,6 @@
55614  int NCR53c7xx_reset(Scsi_Cmnd *, unsigned int);
55615  void NCR53c7x0_intr(int irq, void *dev_id, struct pt_regs * regs);
55616  
55617 -#ifndef NULL
55618 -#define NULL 0
55619 -#endif
55620 -
55621  #ifndef CMD_PER_LUN
55622  #define CMD_PER_LUN 3
55623  #endif
55624 diff -Nru a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
55625 --- a/drivers/scsi/dpt_i2o.c    Fri May  2 12:45:47 2003
55626 +++ b/drivers/scsi/dpt_i2o.c    Tue Aug 26 09:25:41 2003
55627 @@ -1551,7 +1551,7 @@
55628  
55629         //TODO check for root access
55630         //
55631 -       minor = minor(inode->i_rdev);
55632 +       minor = iminor(inode);
55633         if (minor >= hba_count) {
55634                 return -ENXIO;
55635         }
55636 @@ -1582,7 +1582,7 @@
55637         int minor;
55638         adpt_hba* pHba;
55639  
55640 -       minor = minor(inode->i_rdev);
55641 +       minor = iminor(inode);
55642         if (minor >= hba_count) {
55643                 return -ENXIO;
55644         }
55645 @@ -1878,7 +1878,7 @@
55646         adpt_hba* pHba;
55647         ulong flags;
55648  
55649 -       minor = minor(inode->i_rdev);
55650 +       minor = iminor(inode);
55651         if (minor >= DPTI_MAX_HBA){
55652                 return -ENXIO;
55653         }
55654 diff -Nru a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h
55655 --- a/drivers/scsi/gdth.h       Mon May 12 07:26:12 2003
55656 +++ b/drivers/scsi/gdth.h       Mon Sep  1 17:20:32 2003
55657 @@ -16,9 +16,6 @@
55658  #include <linux/version.h>
55659  #include <linux/types.h>
55660  
55661 -#ifndef NULL
55662 -#define NULL 0
55663 -#endif
55664  #ifndef TRUE
55665  #define TRUE 1
55666  #endif
55667 diff -Nru a/drivers/scsi/gvp11.h b/drivers/scsi/gvp11.h
55668 --- a/drivers/scsi/gvp11.h      Fri Dec 20 06:35:20 2002
55669 +++ b/drivers/scsi/gvp11.h      Mon Sep  1 17:20:32 2003
55670 @@ -18,10 +18,6 @@
55671  int wd33c93_abort(Scsi_Cmnd *);
55672  int wd33c93_reset(Scsi_Cmnd *, unsigned int);
55673  
55674 -#ifndef NULL
55675 -#define NULL 0
55676 -#endif
55677 -
55678  #ifndef CMD_PER_LUN
55679  #define CMD_PER_LUN 2
55680  #endif
55681 diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
55682 --- a/drivers/scsi/hosts.c      Sat Aug 16 16:09:46 2003
55683 +++ b/drivers/scsi/hosts.c      Sun Aug 31 16:15:45 2003
55684 @@ -158,7 +158,13 @@
55685         scsi_proc_hostdir_rm(shost->hostt);
55686         scsi_destroy_command_freelist(shost);
55687  
55688 -       put_device(parent);
55689 +       /*
55690 +        * Some drivers (eg aha1542) do scsi_register()/scsi_unregister()
55691 +        * during probing without performing a scsi_set_device() in between.
55692 +        * In this case dev->parent is NULL.
55693 +        */
55694 +       if (parent)
55695 +               put_device(parent);
55696         kfree(shost);
55697  }
55698  
55699 diff -Nru a/drivers/scsi/hosts.h b/drivers/scsi/hosts.h
55700 --- a/drivers/scsi/hosts.h      Mon Jun 23 04:00:34 2003
55701 +++ b/drivers/scsi/hosts.h      Mon Sep  1 13:56:57 2003
55702 @@ -25,7 +25,6 @@
55703  #define _HOSTS_H
55704  
55705  #include <linux/config.h>
55706 -#include <linux/proc_fs.h>
55707  
55708  #include <scsi/scsi_host.h>
55709  
55710 diff -Nru a/drivers/scsi/i91uscsi.h b/drivers/scsi/i91uscsi.h
55711 --- a/drivers/scsi/i91uscsi.h   Sun Feb 16 16:20:08 2003
55712 +++ b/drivers/scsi/i91uscsi.h   Mon Sep  1 17:20:32 2003
55713 @@ -67,9 +67,6 @@
55714  #define UDWORD  unsigned long
55715  #define U32     u32
55716  
55717 -#ifndef NULL
55718 -#define NULL     0             /* zero          */
55719 -#endif
55720  #ifndef FAILURE
55721  #define FAILURE  (-1)
55722  #endif
55723 diff -Nru a/drivers/scsi/imm.h b/drivers/scsi/imm.h
55724 --- a/drivers/scsi/imm.h        Fri May  2 12:27:27 2003
55725 +++ b/drivers/scsi/imm.h        Wed Sep  3 23:40:21 2003
55726 @@ -96,17 +96,17 @@
55727  
55728  static char *IMM_MODE_STRING[] =
55729  {
55730 -    "Autodetect",
55731 -    "SPP",
55732 -    "PS/2",
55733 -    "EPP 8 bit",
55734 -    "EPP 16 bit",
55735 +       [IMM_AUTODETECT] = "Autodetect",
55736 +       [IMM_NIBBLE]     = "SPP",
55737 +       [IMM_PS2]        = "PS/2",
55738 +       [IMM_EPP_8]      = "EPP 8 bit",
55739  #ifdef CONFIG_SCSI_IZIP_EPP16
55740 -    "EPP 16 bit",
55741 +       [IMM_EPP_16]     = "EPP 16 bit",
55742  #else
55743 -    "EPP 32 bit",
55744 +       [IMM_EPP_32]     = "EPP 32 bit",
55745  #endif
55746 -    "Unknown"};
55747 +       [IMM_UNKNOWN]    = "Unknown",
55748 +};
55749  
55750  /* This is a global option */
55751  int imm_sg = SG_ALL;           /* enable/disable scatter-gather. */
55752 diff -Nru a/drivers/scsi/ini9100u.h b/drivers/scsi/ini9100u.h
55753 --- a/drivers/scsi/ini9100u.h   Sun May  4 02:56:43 2003
55754 +++ b/drivers/scsi/ini9100u.h   Mon Sep  1 17:20:32 2003
55755 @@ -99,9 +99,6 @@
55756  #define UDWORD  unsigned long
55757  #define U32   u32
55758  
55759 -#ifndef NULL
55760 -#define NULL     0             /* zero          */
55761 -#endif
55762  #ifndef TRUE
55763  #define TRUE     (1)           /* boolean true  */
55764  #endif
55765 diff -Nru a/drivers/scsi/inia100.h b/drivers/scsi/inia100.h
55766 --- a/drivers/scsi/inia100.h    Sun May  4 02:56:43 2003
55767 +++ b/drivers/scsi/inia100.h    Mon Sep  1 17:20:32 2003
55768 @@ -88,9 +88,6 @@
55769  #define UDWORD  unsigned long
55770  #define U32     u32
55771  
55772 -#ifndef NULL
55773 -#define NULL     0             /* zero          */
55774 -#endif
55775  #ifndef FAILURE
55776  #define FAILURE  (-1)
55777  #endif
55778 diff -Nru a/drivers/scsi/mac_scsi.h b/drivers/scsi/mac_scsi.h
55779 --- a/drivers/scsi/mac_scsi.h   Mon May 12 07:26:13 2003
55780 +++ b/drivers/scsi/mac_scsi.h   Mon Sep  1 17:20:32 2003
55781 @@ -32,9 +32,6 @@
55782  #define MACSCSI_PUBLIC_RELEASE 2
55783  
55784  #ifndef ASM
55785 -#ifndef NULL
55786 -#define NULL 0
55787 -#endif
55788  
55789  #ifndef CMD_PER_LUN
55790  #define CMD_PER_LUN 2
55791 diff -Nru a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
55792 --- a/drivers/scsi/megaraid.c   Sat Aug 16 11:46:50 2003
55793 +++ b/drivers/scsi/megaraid.c   Mon Sep  1 13:56:57 2003
55794 @@ -36,6 +36,7 @@
55795  #include <asm/uaccess.h>
55796  #include <asm/io.h>
55797  #include <linux/delay.h>
55798 +#include <linux/proc_fs.h>
55799  #include <linux/reboot.h>
55800  #include <linux/module.h>
55801  #include <linux/list.h>
55802 diff -Nru a/drivers/scsi/mvme147.h b/drivers/scsi/mvme147.h
55803 --- a/drivers/scsi/mvme147.h    Fri Dec 20 06:38:40 2002
55804 +++ b/drivers/scsi/mvme147.h    Mon Sep  1 17:20:32 2003
55805 @@ -17,10 +17,6 @@
55806  int wd33c93_abort(Scsi_Cmnd *);
55807  int wd33c93_reset(Scsi_Cmnd *, unsigned int);
55808  
55809 -#ifndef NULL
55810 -#define NULL 0
55811 -#endif
55812 -
55813  #ifndef CMD_PER_LUN
55814  #define CMD_PER_LUN 2
55815  #endif
55816 diff -Nru a/drivers/scsi/mvme16x.h b/drivers/scsi/mvme16x.h
55817 --- a/drivers/scsi/mvme16x.h    Fri Dec 20 06:39:02 2002
55818 +++ b/drivers/scsi/mvme16x.h    Mon Sep  1 17:20:32 2003
55819 @@ -11,10 +11,6 @@
55820  int NCR53c7xx_reset(Scsi_Cmnd *, unsigned int);
55821  void NCR53c7x0_intr(int irq, void *dev_id, struct pt_regs * regs);
55822  
55823 -#ifndef NULL
55824 -#define NULL 0
55825 -#endif
55826 -
55827  #ifndef CMD_PER_LUN
55828  #define CMD_PER_LUN 3
55829  #endif
55830 diff -Nru a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
55831 --- a/drivers/scsi/nsp32.c      Tue Aug 19 12:35:44 2003
55832 +++ b/drivers/scsi/nsp32.c      Sun Aug 31 16:14:08 2003
55833 @@ -2809,13 +2809,13 @@
55834                 for (j = 0; j < NUMBER(data->lunt[0]); j++) {
55835                         int offset = i * NUMBER(data->lunt[0]) + j;
55836                         nsp32_lunt tmp = {
55837 -                               SCpnt:       NULL,
55838 -                               save_datp:   0,
55839 -                               msgin03:     FALSE,
55840 -                               sg_num:      0,
55841 -                               cur_entry:   0,
55842 -                               sglun:       &(data->sg_list[offset]),
55843 -                               sglun_paddr: data->sg_paddr + (offset * sizeof(nsp32_sglun)),
55844 +                               .SCpnt       = NULL,
55845 +                               .save_datp   = 0,
55846 +                               .msgin03     = FALSE,
55847 +                               .sg_num      = 0,
55848 +                               .cur_entry   = 0,
55849 +                               .sglun       = &(data->sg_list[offset]),
55850 +                               .sglun_paddr = data->sg_paddr + (offset * sizeof(nsp32_sglun)),
55851                         };
55852  
55853                         data->lunt[i][j] = tmp;
55854 diff -Nru a/drivers/scsi/osst.c b/drivers/scsi/osst.c
55855 --- a/drivers/scsi/osst.c       Fri May  2 12:38:35 2003
55856 +++ b/drivers/scsi/osst.c       Tue Aug 26 09:25:41 2003
55857 @@ -132,9 +132,9 @@
55858  #define OSST_TIMEOUT (200 * HZ)
55859  #define OSST_LONG_TIMEOUT (1800 * HZ)
55860  
55861 -#define TAPE_NR(x) (minor(x) & ~(-1 << ST_MODE_SHIFT))
55862 -#define TAPE_MODE(x) ((minor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
55863 -#define TAPE_REWIND(x) ((minor(x) & 0x80) == 0)
55864 +#define TAPE_NR(x) (iminor(x) & ~(-1 << ST_MODE_SHIFT))
55865 +#define TAPE_MODE(x) ((iminor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
55866 +#define TAPE_REWIND(x) ((iminor(x) & 0x80) == 0)
55867  #define TAPE_IS_RAW(x) (TAPE_MODE(x) & (ST_NBR_MODES >> 1))
55868  
55869  /* Internal ioctl to set both density (uppermost 8 bits) and blocksize (lower
55870 @@ -4215,8 +4215,8 @@
55871         ST_mode      * STm;
55872         ST_partstat  * STps;
55873         char         * name;
55874 -       int            dev  = TAPE_NR(inode->i_rdev);
55875 -       int            mode = TAPE_MODE(inode->i_rdev);
55876 +       int            dev  = TAPE_NR(inode);
55877 +       int            mode = TAPE_MODE(inode);
55878  
55879         write_lock(&os_scsi_tapes_lock);
55880         if (dev >= osst_max_dev || os_scsi_tapes == NULL ||
55881 @@ -4244,7 +4244,7 @@
55882         filp->private_data = STp;
55883         STp->in_use = 1;
55884         write_unlock(&os_scsi_tapes_lock);
55885 -       STp->rew_at_close = TAPE_REWIND(inode->i_rdev);
55886 +       STp->rew_at_close = TAPE_REWIND(inode);
55887  
55888         if( !scsi_block_when_processing_errors(STp->device) ) {
55889                 return -ENXIO;
55890 @@ -4264,7 +4264,7 @@
55891         flags = filp->f_flags;
55892         STp->write_prot = ((flags & O_ACCMODE) == O_RDONLY);
55893  
55894 -       STp->raw = TAPE_IS_RAW(inode->i_rdev);
55895 +       STp->raw = TAPE_IS_RAW(inode);
55896         if (STp->raw)
55897                 STp->header_ok = 0;
55898  
55899 diff -Nru a/drivers/scsi/pas16.h b/drivers/scsi/pas16.h
55900 --- a/drivers/scsi/pas16.h      Mon May 12 07:26:14 2003
55901 +++ b/drivers/scsi/pas16.h      Mon Sep  1 17:20:32 2003
55902 @@ -123,10 +123,6 @@
55903  static int pas16_host_reset(Scsi_Cmnd *);
55904  static int pas16_device_reset(Scsi_Cmnd *);
55905  
55906 -#ifndef NULL
55907 -#define NULL 0
55908 -#endif
55909 -
55910  #ifndef CMD_PER_LUN
55911  #define CMD_PER_LUN 2
55912  #endif
55913 diff -Nru a/drivers/scsi/pci2000.h b/drivers/scsi/pci2000.h
55914 --- a/drivers/scsi/pci2000.h    Sun May  4 02:56:44 2003
55915 +++ b/drivers/scsi/pci2000.h    Mon Sep  1 17:20:32 2003
55916 @@ -197,8 +197,4 @@
55917                                         struct block_device *bdev,
55918                                         sector_t capacity, int geom[]);
55919  
55920 -#ifndef NULL
55921 -       #define NULL 0
55922 -#endif
55923 -
55924  #endif
55925 diff -Nru a/drivers/scsi/pci2220i.h b/drivers/scsi/pci2220i.h
55926 --- a/drivers/scsi/pci2220i.h   Sun May  4 02:56:44 2003
55927 +++ b/drivers/scsi/pci2220i.h   Mon Sep  1 17:20:32 2003
55928 @@ -36,8 +36,4 @@
55929  int Pci2220i_BiosParam         (struct scsi_device *sdev,
55930                                         struct block_device *dev,
55931                                         sector_t capacity, int geom[]);
55932 -
55933 -#ifndef NULL
55934 -       #define NULL 0
55935 -#endif
55936  #endif
55937 diff -Nru a/drivers/scsi/pcmcia/Kconfig b/drivers/scsi/pcmcia/Kconfig
55938 --- a/drivers/scsi/pcmcia/Kconfig       Tue Aug 19 12:36:47 2003
55939 +++ b/drivers/scsi/pcmcia/Kconfig       Wed Sep  3 23:39:56 2003
55940 @@ -3,7 +3,7 @@
55941  #
55942  
55943  menu "PCMCIA SCSI adapter support"
55944 -       depends on SCSI!=n && PCMCIA!=n
55945 +       depends on SCSI!=n && PCMCIA!=n && MODULES
55946  
55947  config PCMCIA_AHA152X
55948         tristate "Adaptec AHA152X PCMCIA support"
55949 diff -Nru a/drivers/scsi/psi240i.h b/drivers/scsi/psi240i.h
55950 --- a/drivers/scsi/psi240i.h    Sun May  4 02:56:45 2003
55951 +++ b/drivers/scsi/psi240i.h    Mon Sep  1 17:20:32 2003
55952 @@ -316,8 +316,4 @@
55953  int Psi240i_Reset                      (Scsi_Cmnd *SCpnt, unsigned int flags);
55954  int Psi240i_BiosParam          (struct scsi_device *sdev, struct block_device *bdev,
55955                                         sector_t capacity, int geom[]);
55956 -
55957 -#ifndef NULL
55958 -       #define NULL 0
55959 -#endif
55960  #endif
55961 diff -Nru a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
55962 --- a/drivers/scsi/qla1280.c    Thu Aug 14 16:08:54 2003
55963 +++ b/drivers/scsi/qla1280.c    Wed Sep  3 23:40:08 2003
55964 @@ -331,10 +331,16 @@
55965   */
55966  #define  QL1280_LUN_SUPPORT    0
55967  #define  WATCHDOGTIMER         0
55968 -#define  MEMORY_MAPPED_IO      1
55969 +
55970  #define  DEBUG_QLA1280_INTR    0
55971  #define  DEBUG_PRINT_NVRAM     0
55972  #define  DEBUG_QLA1280         0
55973 +
55974 +#ifdef CONFIG_SCSI_QLOGIC_1280_PIO
55975 +#define        MEMORY_MAPPED_IO        0
55976 +#else
55977 +#define        MEMORY_MAPPED_IO        1
55978 +#endif
55979  
55980  #define UNIQUE_FW_NAME
55981  #include "qla1280.h"
55982 diff -Nru a/drivers/scsi/qlogicfc.h b/drivers/scsi/qlogicfc.h
55983 --- a/drivers/scsi/qlogicfc.h   Sun May  4 02:56:45 2003
55984 +++ b/drivers/scsi/qlogicfc.h   Mon Sep  1 17:20:32 2003
55985 @@ -77,9 +77,4 @@
55986  int isp2x00_reset(Scsi_Cmnd *, unsigned int);
55987  int isp2x00_biosparam(struct scsi_device *, struct block_device *,
55988                 sector_t, int[]);
55989 -
55990 -#ifndef NULL
55991 -#define NULL (0)
55992 -#endif
55993 -
55994  #endif /* _QLOGICFC_H */
55995 diff -Nru a/drivers/scsi/qlogicisp.h b/drivers/scsi/qlogicisp.h
55996 --- a/drivers/scsi/qlogicisp.h  Sun May  4 02:56:45 2003
55997 +++ b/drivers/scsi/qlogicisp.h  Mon Sep  1 17:20:32 2003
55998 @@ -66,8 +66,4 @@
55999  int isp1020_reset(Scsi_Cmnd *, unsigned int);
56000  int isp1020_biosparam(struct scsi_device *, struct block_device *,
56001                 sector_t, int[]);
56002 -
56003 -#ifndef NULL
56004 -#define NULL (0)
56005 -#endif
56006  #endif /* _QLOGICISP_H */
56007 diff -Nru a/drivers/scsi/sg.c b/drivers/scsi/sg.c
56008 --- a/drivers/scsi/sg.c Sat Aug 16 11:46:50 2003
56009 +++ b/drivers/scsi/sg.c Tue Aug 26 09:25:41 2003
56010 @@ -238,7 +238,7 @@
56011  static int
56012  sg_open(struct inode *inode, struct file *filp)
56013  {
56014 -       int dev = minor(inode->i_rdev);
56015 +       int dev = iminor(inode);
56016         int flags = filp->f_flags;
56017         Sg_device *sdp;
56018         Sg_fd *sfp;
56019 diff -Nru a/drivers/scsi/sgiwd93.h b/drivers/scsi/sgiwd93.h
56020 --- a/drivers/scsi/sgiwd93.h    Sun May  4 02:56:46 2003
56021 +++ b/drivers/scsi/sgiwd93.h    Mon Sep  1 17:20:32 2003
56022 @@ -6,10 +6,6 @@
56023  #ifndef _SGIWD93_H
56024  #define _SGIWD93_H
56025  
56026 -#ifndef NULL
56027 -#define NULL        0
56028 -#endif
56029 -
56030  #ifndef CMD_PER_LUN
56031  #define CMD_PER_LUN 8
56032  #endif
56033 diff -Nru a/drivers/scsi/sr.c b/drivers/scsi/sr.c
56034 --- a/drivers/scsi/sr.c Thu Jul 31 08:28:30 2003
56035 +++ b/drivers/scsi/sr.c Mon Sep  1 06:28:41 2003
56036 @@ -695,6 +695,10 @@
56037         unsigned char *buffer;
56038         int rc, n;
56039         struct scsi_mode_data data;
56040 +       struct scsi_request *SRpnt;
56041 +       unsigned char cmd[MAX_COMMAND_SIZE];
56042 +       unsigned int the_result;
56043 +       int retries;
56044  
56045         static char *loadmech[] =
56046         {
56047 @@ -708,11 +712,46 @@
56048                 ""
56049         };
56050  
56051 +       /* allocate a request for the TEST_UNIT_READY */
56052 +       SRpnt = scsi_allocate_request(cd->device);
56053 +       if (!SRpnt) {
56054 +               printk(KERN_WARNING "(get_capabilities:) Request allocation "
56055 +                      "failure.\n");
56056 +               return;
56057 +       }
56058 +
56059 +       /* allocate transfer buffer */
56060         buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
56061         if (!buffer) {
56062                 printk(KERN_ERR "sr: out of memory.\n");
56063 +               scsi_release_request(SRpnt);
56064                 return;
56065         }
56066 +
56067 +       /* issue TEST_UNIT_READY until the initial startup UNIT_ATTENTION
56068 +        * conditions are gone, or a timeout happens
56069 +        */
56070 +       retries = 0;
56071 +       do {
56072 +               memset((void *)cmd, 0, MAX_COMMAND_SIZE);
56073 +               cmd[0] = TEST_UNIT_READY;
56074 +
56075 +               SRpnt->sr_cmd_len = 0;
56076 +               SRpnt->sr_sense_buffer[0] = 0;
56077 +               SRpnt->sr_sense_buffer[2] = 0;
56078 +               SRpnt->sr_data_direction = DMA_NONE;
56079 +
56080 +               scsi_wait_req (SRpnt, (void *) cmd, buffer,
56081 +                              0, SR_TIMEOUT, MAX_RETRIES);
56082 +
56083 +               the_result = SRpnt->sr_result;
56084 +               retries++;
56085 +       } while (retries < 5 && 
56086 +                (!scsi_status_is_good(the_result) ||
56087 +                 ((driver_byte(the_result) & DRIVER_SENSE) &&
56088 +                  SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION)));
56089 +
56090 +       /* ask for mode page 0x2a */
56091         rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
56092                              SR_TIMEOUT, 3, &data);
56093  
56094 @@ -722,6 +761,7 @@
56095                 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
56096                                          CDC_DVD | CDC_DVD_RAM |
56097                                          CDC_SELECT_DISC | CDC_SELECT_SPEED);
56098 +               scsi_release_request(SRpnt);
56099                 kfree(buffer);
56100                 printk("%s: scsi-1 drive\n", cd->cdi.name);
56101                 return;
56102 @@ -775,6 +815,7 @@
56103         /*else    I don't think it can close its tray
56104                 cd->cdi.mask |= CDC_CLOSE_TRAY; */
56105  
56106 +       scsi_release_request(SRpnt);
56107         kfree(buffer);
56108  }
56109  
56110 diff -Nru a/drivers/scsi/st.c b/drivers/scsi/st.c
56111 --- a/drivers/scsi/st.c Mon Aug 11 11:44:45 2003
56112 +++ b/drivers/scsi/st.c Tue Aug 26 12:05:16 2003
56113 @@ -140,8 +140,8 @@
56114  #define ST_TIMEOUT (900 * HZ)
56115  #define ST_LONG_TIMEOUT (14000 * HZ)
56116  
56117 -#define TAPE_NR(x) (minor(x) & ~(-1 << ST_MODE_SHIFT))
56118 -#define TAPE_MODE(x) ((minor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
56119 +#define TAPE_NR(x) (iminor(x) & ~(-1 << ST_MODE_SHIFT))
56120 +#define TAPE_MODE(x) ((iminor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
56121  
56122  /* Internal ioctl to set both density (uppermost 8 bits) and blocksize (lower
56123     24 bits) */
56124 @@ -786,7 +786,7 @@
56125         ST_partstat *STps;
56126         char *name = tape_name(STp);
56127         struct inode *inode = filp->f_dentry->d_inode;
56128 -       int mode = TAPE_MODE(inode->i_rdev);
56129 +       int mode = TAPE_MODE(inode);
56130  
56131         STp->ready = ST_READY;
56132  
56133 @@ -980,7 +980,7 @@
56134         int i, retval = (-EIO);
56135         Scsi_Tape *STp;
56136         ST_partstat *STps;
56137 -       int dev = TAPE_NR(inode->i_rdev);
56138 +       int dev = TAPE_NR(inode);
56139         char *name;
56140  
56141         write_lock(&st_dev_arr_lock);
56142 @@ -1004,7 +1004,7 @@
56143         }
56144         STp->in_use = 1;
56145         write_unlock(&st_dev_arr_lock);
56146 -       STp->rew_at_close = STp->autorew_dev = (minor(inode->i_rdev) & 0x80) == 0;
56147 +       STp->rew_at_close = STp->autorew_dev = (iminor(inode) & 0x80) == 0;
56148  
56149  
56150         if (!scsi_block_when_processing_errors(STp->device)) {
56151 diff -Nru a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h
56152 --- a/drivers/scsi/sun3_scsi.h  Mon May 12 07:26:15 2003
56153 +++ b/drivers/scsi/sun3_scsi.h  Mon Sep  1 17:20:32 2003
56154 @@ -36,11 +36,6 @@
56155  #ifndef SUN3_NCR5380_H
56156  #define SUN3_NCR5380_H
56157  
56158 -#ifndef NULL
56159 -#define NULL 0
56160 -#endif
56161 -
56162 -
56163  #define SUN3SCSI_PUBLIC_RELEASE 1
56164  
56165  /*
56166 diff -Nru a/drivers/scsi/t128.h b/drivers/scsi/t128.h
56167 --- a/drivers/scsi/t128.h       Mon May 12 07:26:16 2003
56168 +++ b/drivers/scsi/t128.h       Mon Sep  1 17:20:32 2003
56169 @@ -100,10 +100,6 @@
56170  static int t128_bus_reset(Scsi_Cmnd *);
56171  static int t128_device_reset(Scsi_Cmnd *);
56172  
56173 -#ifndef NULL
56174 -#define NULL 0
56175 -#endif
56176 -
56177  #ifndef CMD_PER_LUN
56178  #define CMD_PER_LUN 2
56179  #endif
56180 diff -Nru a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c
56181 --- a/drivers/serial/8250_acpi.c        Wed May 14 07:50:37 2003
56182 +++ b/drivers/serial/8250_acpi.c        Wed Sep  3 23:40:10 2003
56183 @@ -108,3 +108,6 @@
56184  
56185  module_init(acpi_serial_init);
56186  module_exit(acpi_serial_exit);
56187 +
56188 +MODULE_LICENSE("GPL");
56189 +MODULE_DESCRIPTION("Generic 8250/16x50 ACPI serial driver");
56190 diff -Nru a/drivers/serial/Kconfig b/drivers/serial/Kconfig
56191 --- a/drivers/serial/Kconfig    Fri Aug  1 03:02:30 2003
56192 +++ b/drivers/serial/Kconfig    Sun Aug 24 08:17:18 2003
56193 @@ -430,12 +430,12 @@
56194  
56195  config SERIAL_CORE
56196         tristate
56197 -       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)
56198 -       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
56199 +       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)
56200 +       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
56201  
56202  config SERIAL_CORE_CONSOLE
56203         bool
56204 -       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
56205 +       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
56206         default y
56207  
56208  config SERIAL_68328
56209 @@ -472,6 +472,22 @@
56210         bool
56211         depends on SERIAL_68360_SMC || SERIAL_68360_SCC
56212         default y
56213 +
56214 +config SERIAL_PMACZILOG
56215 +       tristate "PowerMac z85c30 ESCC support"
56216 +       depends on PPC_OF
56217 +       help
56218 +         This driver supports the Zilog z85C30 serial ports found on
56219 +         PowerMac machines.
56220 +         Say Y or M if you want to be able to these serial ports.
56221 +
56222 +config SERIAL_PMACZILOG_CONSOLE
56223 +       bool "Console on PowerMac z85c30 serial port"
56224 +       depends on SERIAL_PMACZILOG=y
56225 +       help
56226 +         If you would like to be able to use the z85c30 serial port
56227 +         on your PowerMac as the console, you can do so by answering
56228 +         Y to this option.
56229  
56230  endmenu
56231  
56232 diff -Nru a/drivers/serial/Makefile b/drivers/serial/Makefile
56233 --- a/drivers/serial/Makefile   Tue Jul 15 03:23:50 2003
56234 +++ b/drivers/serial/Makefile   Sun Aug 24 08:17:18 2003
56235 @@ -31,3 +31,4 @@
56236  obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o
56237  obj-$(CONFIG_V850E_UART) += v850e_uart.o
56238  obj-$(CONFIG_SERIAL98) += serial98.o
56239 +obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
56240 diff -Nru a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
56241 --- /dev/null   Wed Dec 31 16:00:00 1969
56242 +++ b/drivers/serial/pmac_zilog.c       Sun Aug 24 08:05:53 2003
56243 @@ -0,0 +1,1626 @@
56244 +/*
56245 + * linux/drivers/serial/pmac_zilog.c
56246 + * 
56247 + * Driver for PowerMac Z85c30 based ESCC cell found in the
56248 + * "macio" ASICs of various PowerMac models
56249 + * 
56250 + * Copyright (C) 2003 Ben. Herrenschmidt (benh@kernel.crashing.org)
56251 + *
56252 + * Derived from drivers/macintosh/macserial.c by Paul Mackerras
56253 + * and drivers/serial/sunzilog.c by David S. Miller
56254 + *
56255 + * Hrm... actually, I ripped most of sunzilog (Thanks David !) and
56256 + * adapted special tweaks needed for us. I don't think it's worth
56257 + * merging back those though. The DMA code still has to get in
56258 + * and once done, I expect that driver to remain fairly stable in
56259 + * the long term, unless we change the driver model again...
56260 + *
56261 + * This program is free software; you can redistribute it and/or modify
56262 + * it under the terms of the GNU General Public License as published by
56263 + * the Free Software Foundation; either version 2 of the License, or
56264 + * (at your option) any later version.
56265 + *
56266 + * This program is distributed in the hope that it will be useful,
56267 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
56268 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
56269 + * GNU General Public License for more details.
56270 + *
56271 + * You should have received a copy of the GNU General Public License
56272 + * along with this program; if not, write to the Free Software
56273 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
56274 + *
56275 + * TODO:   - Add DMA support
56276 + *         - Defer port shutdown to a few seconds after close
56277 + *         - maybe put something right into up->clk_divisor
56278 + */
56279 +
56280 +#undef DEBUG
56281 +
56282 +#include <linux/config.h>
56283 +#include <linux/module.h>
56284 +#include <linux/tty.h>
56285 +
56286 +#include <linux/tty_flip.h>
56287 +#include <linux/major.h>
56288 +#include <linux/string.h>
56289 +#include <linux/fcntl.h>
56290 +#include <linux/mm.h>
56291 +#include <linux/kernel.h>
56292 +#include <linux/delay.h>
56293 +#include <linux/init.h>
56294 +#include <linux/console.h>
56295 +#include <linux/slab.h>
56296 +#include <linux/adb.h>
56297 +#include <linux/pmu.h>
56298 +#include <asm/sections.h>
56299 +#include <asm/io.h>
56300 +#include <asm/irq.h>
56301 +#include <asm/prom.h>
56302 +#include <asm/bitops.h>
56303 +#include <asm/machdep.h>
56304 +#include <asm/pmac_feature.h>
56305 +#include <asm/kgdb.h>
56306 +#include <asm/dbdma.h>
56307 +#include <asm/macio.h>
56308 +
56309 +#include <linux/serial.h>
56310 +#include <linux/serial_core.h>
56311 +
56312 +#include "pmac_zilog.h"
56313 +
56314 +
56315 +/* Not yet implemented */
56316 +#undef HAS_DBDMA
56317 +
56318 +static char version[] __initdata = "pmac_zilog.c 0.5a (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
56319 +MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
56320 +MODULE_DESCRIPTION("Driver for the PowerMac serial ports.");
56321 +MODULE_LICENSE("GPL");
56322 +
56323 +#define PWRDBG(fmt, arg...)    printk(KERN_DEBUG fmt , ## arg)
56324 +
56325 +
56326 +/*
56327 + * For the sake of early serial console, we can do a pre-probe
56328 + * (optional) of the ports at rather early boot time.
56329 + */
56330 +static struct uart_pmac_port   pmz_ports[MAX_ZS_PORTS];
56331 +static int                     pmz_ports_count;
56332 +
56333 +
56334 +/* 
56335 + * Load all registers to reprogram the port
56336 + * This function must only be called when the TX is not busy.  The UART
56337 + * port lock must be held and local interrupts disabled.
56338 + */
56339 +static void pmz_load_zsregs(struct uart_pmac_port *up, u8 *regs)
56340 +{
56341 +       int i;
56342 +
56343 +       /* Let pending transmits finish.  */
56344 +       for (i = 0; i < 1000; i++) {
56345 +               unsigned char stat = read_zsreg(up, R1);
56346 +               if (stat & ALL_SNT)
56347 +                       break;
56348 +               udelay(100);
56349 +       }
56350 +
56351 +       ZS_CLEARERR(up);
56352 +       zssync(up);
56353 +       ZS_CLEARFIFO(up);
56354 +       zssync(up);
56355 +       ZS_CLEARERR(up);
56356 +
56357 +       /* Disable all interrupts.  */
56358 +       write_zsreg(up, R1,
56359 +                   regs[R1] & ~(RxINT_MASK | TxINT_ENAB | EXT_INT_ENAB));
56360 +
56361 +       /* Set parity, sync config, stop bits, and clock divisor.  */
56362 +       write_zsreg(up, R4, regs[R4]);
56363 +
56364 +       /* Set misc. TX/RX control bits.  */
56365 +       write_zsreg(up, R10, regs[R10]);
56366 +
56367 +       /* Set TX/RX controls sans the enable bits.  */
56368 +       write_zsreg(up, R3, regs[R3] & ~RxENABLE);
56369 +       write_zsreg(up, R5, regs[R5] & ~TxENABLE);
56370 +
56371 +       /* Synchronous mode config.  */
56372 +       write_zsreg(up, R6, regs[R6]);
56373 +       write_zsreg(up, R7, regs[R7]);
56374 +
56375 +       /* Disable baud generator.  */
56376 +       write_zsreg(up, R14, regs[R14] & ~BRENAB);
56377 +
56378 +       /* Clock mode control.  */
56379 +       write_zsreg(up, R11, regs[R11]);
56380 +
56381 +       /* Lower and upper byte of baud rate generator divisor.  */
56382 +       write_zsreg(up, R12, regs[R12]);
56383 +       write_zsreg(up, R13, regs[R13]);
56384 +       
56385 +       /* Now rewrite R14, with BRENAB (if set).  */
56386 +       write_zsreg(up, R14, regs[R14]);
56387 +
56388 +       /* External status interrupt control.  */
56389 +       write_zsreg(up, R15, regs[R15]);
56390 +
56391 +       /* Reset external status interrupts.  */
56392 +       write_zsreg(up, R0, RES_EXT_INT);
56393 +       write_zsreg(up, R0, RES_EXT_INT);
56394 +
56395 +       /* Rewrite R3/R5, this time without enables masked.  */
56396 +       write_zsreg(up, R3, regs[R3]);
56397 +       write_zsreg(up, R5, regs[R5]);
56398 +
56399 +       /* Rewrite R1, this time without IRQ enabled masked.  */
56400 +       write_zsreg(up, R1, regs[R1]);
56401 +
56402 +       /* Enable interrupts */
56403 +       write_zsreg(up, R9, regs[R9]);
56404 +}
56405 +
56406 +/* 
56407 + * We do like sunzilog to avoid disrupting pending Tx
56408 + * Reprogram the Zilog channel HW registers with the copies found in the
56409 + * software state struct.  If the transmitter is busy, we defer this update
56410 + * until the next TX complete interrupt.  Else, we do it right now.
56411 + *
56412 + * The UART port lock must be held and local interrupts disabled.
56413 + */
56414 +static void pmz_maybe_update_regs(struct uart_pmac_port *up)
56415 +{
56416 +#if 1
56417 +               if (!ZS_REGS_HELD(up)) {
56418 +               if (ZS_TX_ACTIVE(up)) {
56419 +                       up->flags |= PMACZILOG_FLAG_REGS_HELD;
56420 +               } else {
56421 +                       pr_debug("pmz: maybe_update_regs: updating\n");
56422 +                       pmz_load_zsregs(up, up->curregs);
56423 +               }
56424 +       }
56425 +#else
56426 +               pr_debug("pmz: maybe_update_regs: updating\n");
56427 +        pmz_load_zsregs(up, up->curregs);
56428 +#endif
56429 +}
56430 +
56431 +static void pmz_receive_chars(struct uart_pmac_port *up, struct pt_regs *regs)
56432 +{
56433 +       struct tty_struct *tty = up->port.info->tty;    /* XXX info==NULL? */
56434 +
56435 +       while (1) {
56436 +               unsigned char ch, r1;
56437 +
56438 +               if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
56439 +                       tty->flip.work.func((void *)tty);
56440 +                       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
56441 +                               /* XXX Ignores SysRq when we need it most. Fix. */
56442 +                               return; 
56443 +               }
56444 +
56445 +               r1 = read_zsreg(up, R1);
56446 +               if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) {
56447 +                       write_zsreg(up, R0, ERR_RES);
56448 +                       zssync(up);
56449 +               }
56450 +
56451 +               ch = read_zsreg(up, R0);
56452 +
56453 +               /* This funny hack depends upon BRK_ABRT not interfering
56454 +                * with the other bits we care about in R1.
56455 +                */
56456 +               if (ch & BRK_ABRT)
56457 +                       r1 |= BRK_ABRT;
56458 +
56459 +               ch = read_zsdata(up);
56460 +               ch &= up->parity_mask;
56461 +
56462 +               /* A real serial line, record the character and status.  */
56463 +               *tty->flip.char_buf_ptr = ch;
56464 +               *tty->flip.flag_buf_ptr = TTY_NORMAL;
56465 +               up->port.icount.rx++;
56466 +               if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) {
56467 +                       if (r1 & BRK_ABRT) {
56468 +                               r1 &= ~(PAR_ERR | CRC_ERR);
56469 +                               up->port.icount.brk++;
56470 +                               if (uart_handle_break(&up->port))
56471 +                                       goto next_char;
56472 +                       }
56473 +                       else if (r1 & PAR_ERR)
56474 +                               up->port.icount.parity++;
56475 +                       else if (r1 & CRC_ERR)
56476 +                               up->port.icount.frame++;
56477 +                       if (r1 & Rx_OVR)
56478 +                               up->port.icount.overrun++;
56479 +                       r1 &= up->port.read_status_mask;
56480 +                       if (r1 & BRK_ABRT)
56481 +                               *tty->flip.flag_buf_ptr = TTY_BREAK;
56482 +                       else if (r1 & PAR_ERR)
56483 +                               *tty->flip.flag_buf_ptr = TTY_PARITY;
56484 +                       else if (r1 & CRC_ERR)
56485 +                               *tty->flip.flag_buf_ptr = TTY_FRAME;
56486 +               }
56487 +               if (uart_handle_sysrq_char(&up->port, ch, regs))
56488 +                       goto next_char;
56489 +
56490 +               if (up->port.ignore_status_mask == 0xff ||
56491 +                   (r1 & up->port.ignore_status_mask) == 0) {
56492 +                       tty->flip.flag_buf_ptr++;
56493 +                       tty->flip.char_buf_ptr++;
56494 +                       tty->flip.count++;
56495 +               }
56496 +               if ((r1 & Rx_OVR) &&
56497 +                   tty->flip.count < TTY_FLIPBUF_SIZE) {
56498 +                       *tty->flip.flag_buf_ptr = TTY_OVERRUN;
56499 +                       tty->flip.flag_buf_ptr++;
56500 +                       tty->flip.char_buf_ptr++;
56501 +                       tty->flip.count++;
56502 +               }
56503 +       next_char:
56504 +               ch = read_zsreg(up, R0);
56505 +               if (!(ch & Rx_CH_AV))
56506 +                       break;
56507 +       }
56508 +
56509 +       tty_flip_buffer_push(tty);
56510 +}
56511 +
56512 +static void pmz_status_handle(struct uart_pmac_port *up, struct pt_regs *regs)
56513 +{
56514 +       unsigned char status;
56515 +
56516 +       status = read_zsreg(up, R0);
56517 +       write_zsreg(up, R0, RES_EXT_INT);
56518 +       zssync(up);
56519 +
56520 +       if (ZS_WANTS_MODEM_STATUS(up)) {
56521 +               if (status & SYNC_HUNT)
56522 +                       up->port.icount.dsr++;
56523 +
56524 +               /* The Zilog just gives us an interrupt when DCD/CTS/etc. change.
56525 +                * But it does not tell us which bit has changed, we have to keep
56526 +                * track of this ourselves.
56527 +                */
56528 +               if ((status & DCD) ^ up->prev_status)
56529 +                       uart_handle_dcd_change(&up->port,
56530 +                                              (status & DCD));
56531 +               if ((status & CTS) ^ up->prev_status)
56532 +                       uart_handle_cts_change(&up->port,
56533 +                                              (status & CTS));
56534 +
56535 +               wake_up_interruptible(&up->port.info->delta_msr_wait);
56536 +       }
56537 +
56538 +       up->prev_status = status;
56539 +}
56540 +
56541 +static void pmz_transmit_chars(struct uart_pmac_port *up)
56542 +{
56543 +       struct circ_buf *xmit;
56544 +
56545 +       if (ZS_IS_CONS(up)) {
56546 +               unsigned char status = read_zsreg(up, R0);
56547 +
56548 +               /* TX still busy?  Just wait for the next TX done interrupt.
56549 +                *
56550 +                * It can occur because of how we do serial console writes.  It would
56551 +                * be nice to transmit console writes just like we normally would for
56552 +                * a TTY line. (ie. buffered and TX interrupt driven).  That is not
56553 +                * easy because console writes cannot sleep.  One solution might be
56554 +                * to poll on enough port->xmit space becomming free.  -DaveM
56555 +                */
56556 +               if (!(status & Tx_BUF_EMP))
56557 +                       return;
56558 +       }
56559 +
56560 +       up->flags &= ~PMACZILOG_FLAG_TX_ACTIVE;
56561 +
56562 +       if (ZS_REGS_HELD(up)) {
56563 +               pmz_load_zsregs(up, up->curregs);
56564 +               up->flags &= ~PMACZILOG_FLAG_REGS_HELD;
56565 +       }
56566 +
56567 +       if (ZS_TX_STOPPED(up)) {
56568 +               up->flags &= ~PMACZILOG_FLAG_TX_STOPPED;
56569 +               goto ack_tx_int;
56570 +       }
56571 +
56572 +       if (up->port.x_char) {
56573 +               up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
56574 +               write_zsdata(up, up->port.x_char);
56575 +               zssync(up);
56576 +               up->port.icount.tx++;
56577 +               up->port.x_char = 0;
56578 +               return;
56579 +       }
56580 +
56581 +       if (up->port.info == NULL)
56582 +               goto ack_tx_int;
56583 +       xmit = &up->port.info->xmit;
56584 +       if (uart_circ_empty(xmit)) {
56585 +               uart_write_wakeup(&up->port);
56586 +               goto ack_tx_int;
56587 +       }
56588 +       if (uart_tx_stopped(&up->port))
56589 +               goto ack_tx_int;
56590 +
56591 +       up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
56592 +       write_zsdata(up, xmit->buf[xmit->tail]);
56593 +       zssync(up);
56594 +
56595 +       xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
56596 +       up->port.icount.tx++;
56597 +
56598 +       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
56599 +               uart_write_wakeup(&up->port);
56600 +
56601 +       return;
56602 +
56603 +ack_tx_int:
56604 +       write_zsreg(up, R0, RES_Tx_P);
56605 +       zssync(up);
56606 +}
56607 +
56608 +/* Hrm... we register that twice, fixme later.... */
56609 +static irqreturn_t pmz_interrupt(int irq, void *dev_id, struct pt_regs *regs)
56610 +{
56611 +       struct uart_pmac_port *up = dev_id;
56612 +       struct uart_pmac_port *up_a;
56613 +       struct uart_pmac_port *up_b;
56614 +       int rc = IRQ_NONE;
56615 +       u8 r3;
56616 +
56617 +       up_a = ZS_IS_CHANNEL_A(up) ? up : up->mate;
56618 +       up_b = up_a->mate;
56619 +       
56620 +               spin_lock(&up_a->port.lock);
56621 +       r3 = read_zsreg(up, R3);
56622 +       pr_debug("pmz_irq: %x\n", r3);
56623 +
56624 +               /* Channel A */
56625 +               if (r3 & (CHAEXT | CHATxIP | CHARxIP)) {
56626 +               write_zsreg(up_a, R0, RES_H_IUS);
56627 +               zssync(up_a);           
56628 +               pr_debug("pmz: irq channel A: %x\n", r3);
56629 +               if (r3 & CHARxIP)
56630 +                       pmz_receive_chars(up_a, regs);
56631 +                       if (r3 & CHAEXT)
56632 +                               pmz_status_handle(up_a, regs);
56633 +                       if (r3 & CHATxIP)
56634 +                               pmz_transmit_chars(up_a);
56635 +               rc = IRQ_HANDLED;
56636 +               }
56637 +               spin_unlock(&up_a->port.lock);
56638 +       
56639 +               spin_lock(&up_b->port.lock);
56640 +       if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) {
56641 +               write_zsreg(up_b, R0, RES_H_IUS);
56642 +               zssync(up_b);
56643 +               pr_debug("pmz: irq channel B: %x\n", r3);
56644 +                       if (r3 & CHBRxIP)
56645 +                               pmz_receive_chars(up_b, regs);
56646 +                       if (r3 & CHBEXT)
56647 +                               pmz_status_handle(up_b, regs);
56648 +                       if (r3 & CHBTxIP)
56649 +                               pmz_transmit_chars(up_b);
56650 +               rc = IRQ_HANDLED;
56651 +               }
56652 +               spin_unlock(&up_b->port.lock);
56653 +
56654 +
56655 +       return rc;
56656 +}
56657 +
56658 +/*
56659 + * Peek the status register, lock not held by caller
56660 + */
56661 +static inline u8 pmz_peek_status(struct uart_pmac_port *up)
56662 +{
56663 +       unsigned long flags;
56664 +       u8 status;
56665 +       
56666 +       spin_lock_irqsave(&up->port.lock, flags);
56667 +       status = read_zsreg(up, R0);
56668 +       spin_unlock_irqrestore(&up->port.lock, flags);
56669 +
56670 +       return status;
56671 +}
56672 +
56673 +/* 
56674 + * Check if transmitter is empty
56675 + * The port lock is not held.
56676 + */
56677 +static unsigned int pmz_tx_empty(struct uart_port *port)
56678 +{
56679 +       unsigned char status;
56680 +
56681 +       status = pmz_peek_status(to_pmz(port));
56682 +       if (status & Tx_BUF_EMP)
56683 +               return TIOCSER_TEMT;
56684 +       return 0;
56685 +}
56686 +
56687 +/* 
56688 + * Set Modem Control (RTS & DTR) bits
56689 + * The port lock is held and interrupts are disabled.
56690 + * Note: Shall we really filter out RTS on external ports or
56691 + * should that be dealt at higher level only ?
56692 + */
56693 +static void pmz_set_mctrl(struct uart_port *port, unsigned int mctrl)
56694 +{
56695 +       struct uart_pmac_port *up = to_pmz(port);
56696 +       unsigned char set_bits, clear_bits;
56697 +
56698 +        /* Do nothing for irda for now... */
56699 +       if (ZS_IS_IRDA(up))
56700 +               return;
56701 +
56702 +       set_bits = clear_bits = 0;
56703 +
56704 +       if (ZS_IS_INTMODEM(up)) {
56705 +               if (mctrl & TIOCM_RTS)
56706 +                       set_bits |= RTS;
56707 +               else
56708 +                       clear_bits |= RTS;
56709 +       }
56710 +       if (mctrl & TIOCM_DTR)
56711 +               set_bits |= DTR;
56712 +       else
56713 +               clear_bits |= DTR;
56714 +
56715 +       /* NOTE: Not subject to 'transmitter active' rule.  */ 
56716 +       up->curregs[R5] |= set_bits;
56717 +       up->curregs[R5] &= ~clear_bits;
56718 +       write_zsreg(up, R5, up->curregs[R5]);
56719 +       zssync(up);
56720 +}
56721 +
56722 +/* 
56723 + * Get Modem Control bits (only the input ones, the core will
56724 + * or that with a cached value of the control ones)
56725 + * The port lock is not held.
56726 + */
56727 +static unsigned int pmz_get_mctrl(struct uart_port *port)
56728 +{
56729 +       unsigned char status;
56730 +       unsigned int ret;
56731 +
56732 +       status = pmz_peek_status(to_pmz(port));
56733 +
56734 +       ret = 0;
56735 +       if (status & DCD)
56736 +               ret |= TIOCM_CAR;
56737 +       if (status & SYNC_HUNT)
56738 +               ret |= TIOCM_DSR;
56739 +       if (status & CTS)
56740 +               ret |= TIOCM_CTS;
56741 +
56742 +       return ret;
56743 +}
56744 +
56745 +/* 
56746 + * Stop TX side. Dealt like sunzilog at next Tx interrupt,
56747 + * though for DMA, we will have to do a bit more. What is
56748 + * the meaning of the tty_stop bit ? XXX
56749 + * The port lock is held and interrupts are disabled.
56750 + */
56751 +static void pmz_stop_tx(struct uart_port *port, unsigned int tty_stop)
56752 +{
56753 +       to_pmz(port)->flags |= PMACZILOG_FLAG_TX_STOPPED;
56754 +}
56755 +
56756 +/* 
56757 + * Kick the Tx side.
56758 + * The port lock is held and interrupts are disabled.
56759 + */
56760 +static void pmz_start_tx(struct uart_port *port, unsigned int tty_start)
56761 +{
56762 +       struct uart_pmac_port *up = to_pmz(port);
56763 +       unsigned char status;
56764 +
56765 +       pr_debug("pmz: start_tx()\n");
56766 +
56767 +       up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
56768 +       up->flags &= ~PMACZILOG_FLAG_TX_STOPPED;
56769 +
56770 +       status = read_zsreg(up, R0);
56771 +
56772 +       /* TX busy?  Just wait for the TX done interrupt.  */
56773 +       if (!(status & Tx_BUF_EMP))
56774 +               return;
56775 +
56776 +       /* Send the first character to jump-start the TX done
56777 +        * IRQ sending engine.
56778 +        */
56779 +       if (port->x_char) {
56780 +               write_zsdata(up, port->x_char);
56781 +               zssync(up);
56782 +               port->icount.tx++;
56783 +               port->x_char = 0;
56784 +       } else {
56785 +               struct circ_buf *xmit = &port->info->xmit;
56786 +
56787 +               write_zsdata(up, xmit->buf[xmit->tail]);
56788 +               zssync(up);
56789 +               xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
56790 +               port->icount.tx++;
56791 +
56792 +               if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
56793 +                       uart_write_wakeup(&up->port);
56794 +       }
56795 +       pr_debug("pmz: start_tx() done.\n");
56796 +}
56797 +
56798 +/* 
56799 + * Stop Rx side, basically disable emitting of
56800 + * Rx interrupts on the port
56801 + * The port lock is held.
56802 + */
56803 +static void pmz_stop_rx(struct uart_port *port)
56804 +{
56805 +       struct uart_pmac_port *up = to_pmz(port);
56806 +
56807 +       if (ZS_IS_CONS(up))
56808 +               return;
56809 +
56810 +       pr_debug("pmz: stop_rx()()\n");
56811 +
56812 +       /* Disable all RX interrupts.  */
56813 +       up->curregs[R1] &= ~RxINT_MASK;
56814 +       pmz_maybe_update_regs(up);
56815 +
56816 +       pr_debug("pmz: stop_rx() done.\n");
56817 +}
56818 +
56819 +/* 
56820 + * Enable modem status change interrupts
56821 + * The port lock is not held.
56822 + */
56823 +static void pmz_enable_ms(struct uart_port *port)
56824 +{
56825 +       struct uart_pmac_port *up = to_pmz(port);
56826 +       unsigned char new_reg;
56827 +       unsigned long flags;
56828 +
56829 +       spin_lock_irqsave(&port->lock, flags);
56830 +
56831 +       new_reg = up->curregs[R15] | (DCDIE | SYNCIE | CTSIE);
56832 +       if (new_reg != up->curregs[R15]) {
56833 +               up->curregs[R15] = new_reg;
56834 +
56835 +               /* NOTE: Not subject to 'transmitter active' rule.  */ 
56836 +               write_zsreg(up, R15, up->curregs[R15]);
56837 +       }
56838 +
56839 +       spin_unlock_irqrestore(&port->lock, flags);
56840 +}
56841 +
56842 +/* 
56843 + * Control break state emission
56844 + * The port lock is not held.
56845 + */
56846 +static void pmz_break_ctl(struct uart_port *port, int break_state)
56847 +{
56848 +       struct uart_pmac_port *up = to_pmz(port);
56849 +       unsigned char set_bits, clear_bits, new_reg;
56850 +       unsigned long flags;
56851 +
56852 +       set_bits = clear_bits = 0;
56853 +
56854 +       if (break_state)
56855 +               set_bits |= SND_BRK;
56856 +       else
56857 +               clear_bits |= SND_BRK;
56858 +
56859 +       spin_lock_irqsave(&port->lock, flags);
56860 +
56861 +       new_reg = (up->curregs[R5] | set_bits) & ~clear_bits;
56862 +       if (new_reg != up->curregs[R5]) {
56863 +               up->curregs[R5] = new_reg;
56864 +
56865 +               /* NOTE: Not subject to 'transmitter active' rule.  */ 
56866 +               write_zsreg(up, R5, up->curregs[R5]);
56867 +       }
56868 +
56869 +       spin_unlock_irqrestore(&port->lock, flags);
56870 +}
56871 +
56872 +/*
56873 + * Turn power on or off to the SCC and associated stuff
56874 + * (port drivers, modem, IR port, etc.)
56875 + * Returns the number of milliseconds we should wait before
56876 + * trying to use the port.
56877 + */
56878 +static int pmz_set_scc_power(struct uart_pmac_port *up, int state)
56879 +{
56880 +       int delay = 0;
56881 +
56882 +       if (state) {
56883 +               pmac_call_feature(
56884 +                       PMAC_FTR_SCC_ENABLE, up->node, up->port_type, 1);
56885 +               if (ZS_IS_INTMODEM(up)) {
56886 +                       pmac_call_feature(
56887 +                               PMAC_FTR_MODEM_ENABLE, up->node, 0, 1);
56888 +                       delay = 2500;   /* wait for 2.5s before using */
56889 +               } else if (ZS_IS_IRDA(up))
56890 +                       mdelay(50);     /* Do better here once the problems
56891 +                                        * with blocking have been ironed out
56892 +                                        */
56893 +       } else {
56894 +               /* TODO: Make that depend on a timer, don't power down
56895 +                * immediately
56896 +                */
56897 +               if (ZS_IS_INTMODEM(up)) {
56898 +                       pmac_call_feature(
56899 +                               PMAC_FTR_MODEM_ENABLE, up->node, 0, 0);
56900 +               }
56901 +               pmac_call_feature(
56902 +                       PMAC_FTR_SCC_ENABLE, up->node, up->port_type, 0);
56903 +       }
56904 +       return delay;
56905 +}
56906 +
56907 +/*
56908 + * FixZeroBug....Works around a bug in the SCC receving channel.
56909 + * Taken from Darwin code, 15 Sept. 2000  -DanM
56910 + *
56911 + * The following sequence prevents a problem that is seen with O'Hare ASICs
56912 + * (most versions -- also with some Heathrow and Hydra ASICs) where a zero
56913 + * at the input to the receiver becomes 'stuck' and locks up the receiver.
56914 + * This problem can occur as a result of a zero bit at the receiver input
56915 + * coincident with any of the following events:
56916 + *
56917 + *     The SCC is initialized (hardware or software).
56918 + *     A framing error is detected.
56919 + *     The clocking option changes from synchronous or X1 asynchronous
56920 + *             clocking to X16, X32, or X64 asynchronous clocking.
56921 + *     The decoding mode is changed among NRZ, NRZI, FM0, or FM1.
56922 + *
56923 + * This workaround attempts to recover from the lockup condition by placing
56924 + * the SCC in synchronous loopback mode with a fast clock before programming
56925 + * any of the asynchronous modes.
56926 + */
56927 +static void pmz_fix_zero_bug_scc(struct uart_pmac_port *up)
56928 +{
56929 +       write_zsreg(up, 9, ZS_IS_CHANNEL_A(up) ? CHRA : CHRB);
56930 +       zssync(up);
56931 +       udelay(10);
56932 +       write_zsreg(up, 9, (ZS_IS_CHANNEL_A(up) ? CHRA : CHRB) | NV);
56933 +       zssync(up);
56934 +
56935 +       write_zsreg(up, 4, (X1CLK | EXTSYNC));
56936 +
56937 +       /* I think this is wrong....but, I just copying code....
56938 +       */
56939 +       write_zsreg(up, 3, (8 & ~RxENABLE));
56940 +
56941 +       write_zsreg(up, 5, (8 & ~TxENABLE));
56942 +       write_zsreg(up, 9, NV); /* Didn't we already do this? */
56943 +       write_zsreg(up, 11, (RCBR | TCBR));
56944 +       write_zsreg(up, 12, 0);
56945 +       write_zsreg(up, 13, 0);
56946 +       write_zsreg(up, 14, (LOOPBAK | SSBR));
56947 +       write_zsreg(up, 14, (LOOPBAK | SSBR | BRENAB));
56948 +       write_zsreg(up, 3, (8 | RxENABLE));
56949 +       write_zsreg(up, 0, RES_EXT_INT);
56950 +       write_zsreg(up, 0, RES_EXT_INT);        /* to kill some time */
56951 +
56952 +       /* The channel should be OK now, but it is probably receiving
56953 +        * loopback garbage.
56954 +        * Switch to asynchronous mode, disable the receiver,
56955 +        * and discard everything in the receive buffer.
56956 +        */
56957 +       write_zsreg(up, 9, NV);
56958 +       write_zsreg(up, 4, PAR_ENAB);
56959 +       write_zsreg(up, 3, (8 & ~RxENABLE));
56960 +
56961 +       while (read_zsreg(up, 0) & Rx_CH_AV) {
56962 +               (void)read_zsreg(up, 8);
56963 +               write_zsreg(up, 0, RES_EXT_INT);
56964 +               write_zsreg(up, 0, ERR_RES);
56965 +       }
56966 +}
56967 +
56968 +/*
56969 + * Real startup routine, powers up the hardware and sets up
56970 + * the SCC. Returns a delay in ms where you need to wait before
56971 + * actually using the port, this is typically the internal modem
56972 + * powerup delay. This routine expect the lock to be taken.
56973 + */
56974 +static int __pmz_startup(struct uart_pmac_port *up)
56975 +{
56976 +       int pwr_delay = 0;
56977 +
56978 +       memset(&up->curregs, 0, sizeof(up->curregs));
56979 +
56980 +       /* Power up the SCC & underlying hardware (modem/irda) */
56981 +       pwr_delay = pmz_set_scc_power(up, 1);
56982 +
56983 +       /* Nice buggy HW ... */
56984 +       pmz_fix_zero_bug_scc(up);
56985 +
56986 +       /* Reset the chip */
56987 +       write_zsreg(up, 9, ZS_IS_CHANNEL_A(up) ? CHRA : CHRB);
56988 +       zssync(up);
56989 +       udelay(10);
56990 +       write_zsreg(up, 9, 0);
56991 +       zssync(up);
56992 +
56993 +       /* Clear the interrupt registers */
56994 +       write_zsreg(up, R1, 0);
56995 +       write_zsreg(up, R0, ERR_RES);
56996 +       write_zsreg(up, R0, ERR_RES);
56997 +       write_zsreg(up, R0, RES_H_IUS);
56998 +       write_zsreg(up, R0, RES_H_IUS);
56999 +
57000 +       /* Remember status for DCD/CTS changes */
57001 +       up->prev_status = read_zsreg(up, R0);
57002 +
57003 +       /* Enable receiver and transmitter.  */
57004 +       up->curregs[R3] |= RxENABLE;
57005 +       up->curregs[R5] |= TxENABLE | RTS | DTR;
57006 +
57007 +       /* Master interrupt enable */
57008 +       up->curregs[R9] |= NV | MIE;
57009 +
57010 +       up->curregs[R1] |= EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB;
57011 +       //      pmz_maybe_update_regs(up);
57012 +
57013 +       return pwr_delay;
57014 +}
57015 +
57016 +/*
57017 + * This is the "normal" startup routine, using the above one
57018 + * wrapped with the lock and doing a schedule delay
57019 + */
57020 +static int pmz_startup(struct uart_port *port)
57021 +{
57022 +       struct uart_pmac_port *up = to_pmz(port);
57023 +       unsigned long flags;
57024 +       int pwr_delay = 0;
57025 +
57026 +       pr_debug("pmz: startup()\n");
57027 +
57028 +       /* A console is never powered down */
57029 +       if (!ZS_IS_CONS(up)) {
57030 +               spin_lock_irqsave(&port->lock, flags);
57031 +               pwr_delay = __pmz_startup(up);
57032 +               spin_unlock_irqrestore(&port->lock, flags);
57033 +       }
57034 +       
57035 +       if (request_irq(up->port.irq, pmz_interrupt, SA_SHIRQ, "PowerMac Zilog", up)) {
57036 +               printk(KERN_ERR "Unable to register zs interrupt handler.\n");
57037 +               pmz_set_scc_power(up, 0);
57038 +               return -ENXIO;
57039 +       }
57040 +
57041 +       /* Right now, we deal with delay by blocking here, I'll be
57042 +        * smarter later on
57043 +        */
57044 +       if (pwr_delay != 0) {
57045 +               pr_debug("pmz: delaying %d ms\n", pwr_delay);
57046 +               set_current_state(TASK_UNINTERRUPTIBLE);
57047 +               schedule_timeout((pwr_delay * HZ)/1000);
57048 +       }
57049 +
57050 +       pr_debug("pmz: startup() done.\n");
57051 +
57052 +       return 0;
57053 +}
57054 +
57055 +static void pmz_shutdown(struct uart_port *port)
57056 +{
57057 +       struct uart_pmac_port *up = to_pmz(port);
57058 +       unsigned long flags;
57059 +
57060 +       pr_debug("pmz: shutdown()\n");
57061 +
57062 +       /* Release interrupt handler */
57063 +               free_irq(up->port.irq, up);
57064 +
57065 +       if (ZS_IS_CONS(up))
57066 +               return;
57067 +
57068 +       spin_lock_irqsave(&port->lock, flags);
57069 +
57070 +       /* Disable receiver and transmitter.  */
57071 +       up->curregs[R3] &= ~RxENABLE;
57072 +       up->curregs[R5] &= ~TxENABLE;
57073 +
57074 +       /* Disable all interrupts and BRK assertion.  */
57075 +       up->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK);
57076 +       up->curregs[R5] &= ~SND_BRK;
57077 +       pmz_maybe_update_regs(up);
57078 +
57079 +       /* Shut the chip down */
57080 +       pmz_set_scc_power(up, 0);
57081 +
57082 +       spin_unlock_irqrestore(&port->lock, flags);
57083 +
57084 +       pr_debug("pmz: shutdown() done.\n");
57085 +}
57086 +
57087 +/* Shared by TTY driver and serial console setup.  The port lock is held
57088 + * and local interrupts are disabled.
57089 + */
57090 +static void
57091 +pmz_convert_to_zs(struct uart_pmac_port *up, unsigned int cflag,
57092 +                      unsigned int iflag, int baud)
57093 +{
57094 +       int brg;
57095 +
57096 +       switch (baud) {
57097 +       case ZS_CLOCK/16:       /* 230400 */
57098 +               up->curregs[R4] = X16CLK;
57099 +               up->curregs[R11] = 0;
57100 +               break;
57101 +       case ZS_CLOCK/32:       /* 115200 */
57102 +               up->curregs[R4] = X32CLK;
57103 +               up->curregs[R11] = 0;
57104 +               break;
57105 +       default:
57106 +               up->curregs[R4] = X16CLK;
57107 +               up->curregs[R11] = TCBR | RCBR;
57108 +               brg = BPS_TO_BRG(baud, ZS_CLOCK / 16);
57109 +               up->curregs[R12] = (brg & 255);
57110 +               up->curregs[R13] = ((brg >> 8) & 255);
57111 +               up->curregs[R14] = BRENAB;
57112 +       }
57113 +
57114 +       /* Character size, stop bits, and parity. */
57115 +       up->curregs[3] &= ~RxN_MASK;
57116 +       up->curregs[5] &= ~TxN_MASK;
57117 +
57118 +       switch (cflag & CSIZE) {
57119 +       case CS5:
57120 +               up->curregs[3] |= Rx5;
57121 +               up->curregs[5] |= Tx5;
57122 +               up->parity_mask = 0x1f;
57123 +               break;
57124 +       case CS6:
57125 +               up->curregs[3] |= Rx6;
57126 +               up->curregs[5] |= Tx6;
57127 +               up->parity_mask = 0x3f;
57128 +               break;
57129 +       case CS7:
57130 +               up->curregs[3] |= Rx7;
57131 +               up->curregs[5] |= Tx7;
57132 +               up->parity_mask = 0x7f;
57133 +               break;
57134 +       case CS8:
57135 +       default:
57136 +               up->curregs[3] |= Rx8;
57137 +               up->curregs[5] |= Tx8;
57138 +               up->parity_mask = 0xff;
57139 +               break;
57140 +       };
57141 +       up->curregs[4] &= ~(SB_MASK);
57142 +       if (cflag & CSTOPB)
57143 +               up->curregs[4] |= SB2;
57144 +       else
57145 +               up->curregs[4] |= SB1;
57146 +       if (cflag & PARENB)
57147 +               up->curregs[4] |= PAR_ENAB;
57148 +       else
57149 +               up->curregs[4] &= ~PAR_ENAB;
57150 +       if (!(cflag & PARODD))
57151 +               up->curregs[4] |= PAR_EVEN;
57152 +       else
57153 +               up->curregs[4] &= ~PAR_EVEN;
57154 +
57155 +       up->port.read_status_mask = Rx_OVR;
57156 +       if (iflag & INPCK)
57157 +               up->port.read_status_mask |= CRC_ERR | PAR_ERR;
57158 +       if (iflag & (BRKINT | PARMRK))
57159 +               up->port.read_status_mask |= BRK_ABRT;
57160 +
57161 +       up->port.ignore_status_mask = 0;
57162 +       if (iflag & IGNPAR)
57163 +               up->port.ignore_status_mask |= CRC_ERR | PAR_ERR;
57164 +       if (iflag & IGNBRK) {
57165 +               up->port.ignore_status_mask |= BRK_ABRT;
57166 +               if (iflag & IGNPAR)
57167 +                       up->port.ignore_status_mask |= Rx_OVR;
57168 +       }
57169 +
57170 +       if ((cflag & CREAD) == 0)
57171 +               up->port.ignore_status_mask = 0xff;
57172 +}
57173 +
57174 +static void pmz_irda_rts_pulses(struct uart_pmac_port *up, int w)
57175 +{
57176 +       udelay(w);
57177 +       write_zsreg(up, 5, Tx8 | TxENABLE);
57178 +       zssync(up);
57179 +       udelay(2);
57180 +       write_zsreg(up, 5, Tx8 | TxENABLE | RTS);
57181 +       zssync(up);
57182 +       udelay(8);
57183 +       write_zsreg(up, 5, Tx8 | TxENABLE);
57184 +       zssync(up);
57185 +       udelay(4);
57186 +       write_zsreg(up, 5, Tx8 | TxENABLE | RTS);
57187 +       zssync(up);
57188 +}
57189 +
57190 +/*
57191 + * Set the irda codec on the imac to the specified baud rate.
57192 + */
57193 +static void pmz_irda_setup(struct uart_pmac_port *up, int cflags)
57194 +{
57195 +       int code, speed, t;
57196 +
57197 +       speed = cflags & CBAUD;
57198 +       if (speed < B2400 || speed > B115200)
57199 +               return;
57200 +       code = 0x4d + B115200 - speed;
57201 +
57202 +       /* disable serial interrupts and receive DMA */
57203 +       write_zsreg(up, 1, up->curregs[1] & ~0x9f);
57204 +
57205 +       /* wait for transmitter to drain */
57206 +       t = 10000;
57207 +       while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0
57208 +              || (read_zsreg(up, R1) & ALL_SNT) == 0) {
57209 +               if (--t <= 0) {
57210 +                       printk(KERN_ERR "transmitter didn't drain\n");
57211 +                       return;
57212 +               }
57213 +               udelay(10);
57214 +       }
57215 +       udelay(100);
57216 +
57217 +       /* set to 8 bits, no parity, 19200 baud, RTS on, DTR off */
57218 +       write_zsreg(up, R4, X16CLK | SB1);
57219 +       write_zsreg(up, R11, TCBR | RCBR);
57220 +       t = BPS_TO_BRG(19200, ZS_CLOCK/16);
57221 +       write_zsreg(up, R12, t);
57222 +       write_zsreg(up, R13, t >> 8);
57223 +       write_zsreg(up, R14, BRENAB);
57224 +       write_zsreg(up, R3, Rx8 | RxENABLE);
57225 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS);
57226 +       zssync(up);
57227 +
57228 +       /* set TxD low for ~104us and pulse RTS */
57229 +       udelay(1000);
57230 +       write_zsdata(up, 0xfe);
57231 +       pmz_irda_rts_pulses(up, 150);
57232 +       pmz_irda_rts_pulses(up, 180);
57233 +       pmz_irda_rts_pulses(up, 50);
57234 +       udelay(100);
57235 +
57236 +       /* assert DTR, wait 30ms, talk to the chip */
57237 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS | DTR);
57238 +       zssync(up);
57239 +       mdelay(30);
57240 +       while (read_zsreg(up, R0) & Rx_CH_AV)
57241 +               read_zsdata(up);
57242 +
57243 +       write_zsdata(up, 1);
57244 +       t = 1000;
57245 +       while ((read_zsreg(up, R0) & Rx_CH_AV) == 0) {
57246 +               if (--t <= 0) {
57247 +                       printk(KERN_ERR "irda_setup timed out on 1st byte\n");
57248 +                       goto out;
57249 +               }
57250 +               udelay(10);
57251 +       }
57252 +       t = read_zsdata(up);
57253 +       if (t != 4)
57254 +               printk(KERN_ERR "irda_setup 1st byte = %x\n", t);
57255 +
57256 +       write_zsdata(up, code);
57257 +       t = 1000;
57258 +       while ((read_zsreg(up, R0) & Rx_CH_AV) == 0) {
57259 +               if (--t <= 0) {
57260 +                       printk(KERN_ERR "irda_setup timed out on 2nd byte\n");
57261 +                       goto out;
57262 +               }
57263 +               udelay(10);
57264 +       }
57265 +       t = read_zsdata(up);
57266 +       if (t != code)
57267 +               printk(KERN_ERR "irda_setup 2nd byte = %x (%x)\n", t, code);
57268 +
57269 +       /* Drop DTR again and do some more RTS pulses */
57270 + out:
57271 +       udelay(100);
57272 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS);
57273 +       pmz_irda_rts_pulses(up, 80);
57274 +
57275 +       /* We should be right to go now.  We assume that load_zsregs
57276 +          will get called soon to load up the correct baud rate etc. */
57277 +       up->curregs[R5] = (up->curregs[R5] | RTS) & ~DTR;
57278 +}
57279 +
57280 +/* The port lock is not held.  */
57281 +static void
57282 +pmz_set_termios(struct uart_port *port, struct termios *termios,
57283 +                    struct termios *old)
57284 +{
57285 +       struct uart_pmac_port *up = to_pmz(port);
57286 +       unsigned long flags;
57287 +       int baud;
57288 +
57289 +       pr_debug("pmz: set_termios()\n");
57290 +
57291 +       baud = uart_get_baud_rate(port, termios, old, 1200, 230400);
57292 +
57293 +       spin_lock_irqsave(&up->port.lock, flags);
57294 +
57295 +       pmz_convert_to_zs(up, termios->c_cflag, termios->c_iflag, baud);
57296 +
57297 +       if (UART_ENABLE_MS(&up->port, termios->c_cflag))
57298 +               up->flags |= PMACZILOG_FLAG_MODEM_STATUS;
57299 +       else
57300 +               up->flags &= ~PMACZILOG_FLAG_MODEM_STATUS;
57301 +
57302 +       /* set the irda codec to the right rate */
57303 +       if (ZS_IS_IRDA(up))
57304 +               pmz_irda_setup(up, termios->c_cflag);
57305 +
57306 +       /* Load registers to the chip */
57307 +       pmz_maybe_update_regs(up);
57308 +
57309 +       spin_unlock_irqrestore(&up->port.lock, flags);
57310 +
57311 +       pr_debug("pmz: set_termios() done.\n");
57312 +}
57313 +
57314 +static const char *pmz_type(struct uart_port *port)
57315 +{
57316 +       return "PowerMac Zilog";
57317 +}
57318 +
57319 +/* We do not request/release mappings of the registers here, this
57320 + * happens at early serial probe time.
57321 + */
57322 +static void pmz_release_port(struct uart_port *port)
57323 +{
57324 +}
57325 +
57326 +static int pmz_request_port(struct uart_port *port)
57327 +{
57328 +       return 0;
57329 +}
57330 +
57331 +/* These do not need to do anything interesting either.  */
57332 +static void pmz_config_port(struct uart_port *port, int flags)
57333 +{
57334 +}
57335 +
57336 +/* We do not support letting the user mess with the divisor, IRQ, etc. */
57337 +static int pmz_verify_port(struct uart_port *port, struct serial_struct *ser)
57338 +{
57339 +       return -EINVAL;
57340 +}
57341 +
57342 +static struct uart_ops pmz_pops = {
57343 +       .tx_empty       =       pmz_tx_empty,
57344 +       .set_mctrl      =       pmz_set_mctrl,
57345 +       .get_mctrl      =       pmz_get_mctrl,
57346 +       .stop_tx        =       pmz_stop_tx,
57347 +       .start_tx       =       pmz_start_tx,
57348 +       .stop_rx        =       pmz_stop_rx,
57349 +       .enable_ms      =       pmz_enable_ms,
57350 +       .break_ctl      =       pmz_break_ctl,
57351 +       .startup        =       pmz_startup,
57352 +       .shutdown       =       pmz_shutdown,
57353 +       .set_termios    =       pmz_set_termios,
57354 +       .type           =       pmz_type,
57355 +       .release_port   =       pmz_release_port,
57356 +       .request_port   =       pmz_request_port,
57357 +       .config_port    =       pmz_config_port,
57358 +       .verify_port    =       pmz_verify_port,
57359 +};
57360 +
57361 +/*
57362 + * Setup one port structure after probing, HW is down at this point,
57363 + * Unlike sunzilog, we don't need to pre-init the spinlock as we don't
57364 + * register our console before uart_add_one_port() is called
57365 + */
57366 +static int __init pmz_setup_port(struct uart_pmac_port *up, int early)
57367 +{
57368 +       struct device_node *np = up->node;
57369 +       char *conn;
57370 +       struct slot_names_prop {
57371 +               int     count;
57372 +               char    name[1];
57373 +       } *slots;
57374 +       int len;
57375 +
57376 +       /*
57377 +        * Request & map chip registers
57378 +        */
57379 +       if (!early && request_OF_resource(np, 0, NULL) == NULL) {
57380 +               printk("pmac_zilog: failed to request resources for %s\n",
57381 +                       np->full_name);
57382 +               return -EBUSY;
57383 +       }
57384 +       up->port.mapbase = np->addrs[0].address;
57385 +       up->port.membase = ioremap(up->port.mapbase, 0x1000);
57386 +      
57387 +       up->control_reg = (volatile u8 *)up->port.membase;
57388 +       up->data_reg = up->control_reg + 0x10;
57389 +       
57390 +       /*
57391 +        * Request & map DBDMA registers
57392 +        */
57393 +#ifdef HAS_DBDMA
57394 +       if (np->n_addrs >= 3 && np->n_intrs >= 3)
57395 +               up->flags |= PMACZILOG_FLAG_HAS_DMA;
57396 +#endif 
57397 +       if (ZS_HAS_DMA(up)) {
57398 +               if (!early && request_OF_resource(np, np->n_addrs - 2, " (tx dma)") == NULL) {
57399 +                       printk(KERN_ERR "pmac_zilog: can't request TX DMA resource !\n");
57400 +                       up->flags &= ~PMACZILOG_FLAG_HAS_DMA;
57401 +                       goto no_dma;
57402 +               }
57403 +               if (!early && request_OF_resource(np, np->n_addrs - 1, " (rx dma)") == NULL) {
57404 +                       release_OF_resource(np, np->n_addrs - 2);
57405 +                       printk(KERN_ERR "pmac_zilog: can't request RX DMA resource !\n");
57406 +                       up->flags &= ~PMACZILOG_FLAG_HAS_DMA;
57407 +                       goto no_dma;
57408 +               }
57409 +               up->tx_dma_regs = (volatile struct dbdma_regs *)
57410 +                       ioremap(np->addrs[np->n_addrs - 2].address, 0x1000);
57411 +               up->rx_dma_regs = (volatile struct dbdma_regs *)
57412 +                       ioremap(np->addrs[np->n_addrs - 1].address, 0x1000);
57413 +               up->tx_dma_irq = np->intrs[1].line;
57414 +               up->rx_dma_irq = np->intrs[2].line;
57415 +       }
57416 +no_dma:
57417 +       if (!early)
57418 +               up->flags |= PMACZILOG_FLAG_RSRC_REQUESTED;
57419 +
57420 +       /*
57421 +        * Detect port type
57422 +        */
57423 +       if (device_is_compatible(np, "cobalt"))
57424 +               up->flags |= PMACZILOG_FLAG_IS_INTMODEM;
57425 +       conn = get_property(np, "AAPL,connector", &len);
57426 +       if (conn && (strcmp(conn, "infrared") == 0))
57427 +               up->flags |= PMACZILOG_FLAG_IS_IRDA;
57428 +       up->port_type = PMAC_SCC_ASYNC;
57429 +       /* 1999 Powerbook G3 has slot-names property instead */
57430 +       slots = (struct slot_names_prop *)get_property(np, "slot-names", &len);
57431 +       if (slots && slots->count > 0) {
57432 +               if (strcmp(slots->name, "IrDA") == 0)
57433 +                       up->flags |= PMACZILOG_FLAG_IS_IRDA;
57434 +               else if (strcmp(slots->name, "Modem") == 0)
57435 +                       up->flags |= PMACZILOG_FLAG_IS_INTMODEM;
57436 +       }
57437 +       if (ZS_IS_IRDA(up))
57438 +               up->port_type = PMAC_SCC_IRDA;
57439 +       if (ZS_IS_INTMODEM(up)) {
57440 +               struct device_node* i2c_modem = find_devices("i2c-modem");
57441 +               if (i2c_modem) {
57442 +                       char* mid = get_property(i2c_modem, "modem-id", NULL);
57443 +                       if (mid) switch(*mid) {
57444 +                       case 0x04 :
57445 +                       case 0x05 :
57446 +                       case 0x07 :
57447 +                       case 0x08 :
57448 +                       case 0x0b :
57449 +                       case 0x0c :
57450 +                               up->port_type = PMAC_SCC_I2S1;
57451 +                       }
57452 +                       printk(KERN_INFO "pmac_zilog: i2c-modem detected, id: %d\n",
57453 +                               mid ? (*mid) : 0);
57454 +               } else {
57455 +                       printk(KERN_INFO "pmac_zilog: serial modem detected\n");
57456 +               }
57457 +       }
57458 +
57459 +       /*
57460 +        * Init remaining bits of "port" structure
57461 +        */
57462 +       up->port.iotype = SERIAL_IO_MEM;
57463 +       up->port.irq = np->intrs[0].line;
57464 +       up->port.uartclk = ZS_CLOCK;
57465 +       up->port.fifosize = 1;
57466 +       up->port.ops = &pmz_pops;
57467 +       up->port.type = PORT_PMAC_ZILOG;
57468 +       up->port.flags = 0;
57469 +
57470 +       return 0;
57471 +}
57472 +
57473 +/*
57474 + * Get rid of a port on module removal
57475 + */
57476 +static void pmz_dispose_port(struct uart_pmac_port *up)
57477 +{
57478 +       struct device_node *np;
57479 +
57480 +       if (up->flags & PMACZILOG_FLAG_RSRC_REQUESTED) {
57481 +               release_OF_resource(up->node, 0);
57482 +               if (ZS_HAS_DMA(up)) {
57483 +                       release_OF_resource(up->node, up->node->n_addrs - 2);
57484 +                       release_OF_resource(up->node, up->node->n_addrs - 1);
57485 +               }
57486 +       }
57487 +       iounmap((void *)up->control_reg);
57488 +       np = up->node;
57489 +       up->node = NULL;
57490 +       of_node_put(np);
57491 +}
57492 +
57493 +/*
57494 + * Called upon match with an escc node in the devive-tree.
57495 + */
57496 +static int pmz_attach(struct macio_dev *mdev, const struct of_match *match)
57497 +{
57498 +       int i;
57499 +       
57500 +       /* Iterate the pmz_ports array to find a matching entry
57501 +        */
57502 +       for (i = 0; i < MAX_ZS_PORTS; i++)
57503 +               if (pmz_ports[i].node == mdev->ofdev.node) {
57504 +                       pmz_ports[i].dev = mdev;
57505 +                       dev_set_drvdata(&mdev->ofdev.dev, &pmz_ports[i]);
57506 +                       return 0;
57507 +               }
57508 +       return -ENODEV;
57509 +}
57510 +
57511 +/*
57512 + * That one should not be called, macio isn't really a hotswap device,
57513 + * we don't expect one of those serial ports to go away...
57514 + */
57515 +static int pmz_detach(struct macio_dev *mdev)
57516 +{
57517 +       struct uart_pmac_port   *port = dev_get_drvdata(&mdev->ofdev.dev);
57518 +       
57519 +       if (!port)
57520 +               return -ENODEV;
57521 +
57522 +       dev_set_drvdata(&mdev->ofdev.dev, NULL);
57523 +       port->dev = NULL;
57524 +       
57525 +       return 0;
57526 +}
57527 +
57528 +/*
57529 + * Probe all ports in the system and build the ports array, we register
57530 + * with the serial layer at this point, the macio-type probing is only
57531 + * used later to "attach" to the sysfs tree so we get power management
57532 + * events
57533 + */
57534 +static int __init pmz_probe(int early)
57535 +{
57536 +       struct device_node      *node_p, *node_a, *node_b, *np;
57537 +       int                     count = 0;
57538 +       int                     rc;
57539 +
57540 +       /*
57541 +        * Find all escc chips in the system
57542 +        */
57543 +       node_p = of_find_node_by_name(NULL, "escc");
57544 +       while (node_p) {
57545 +               /*
57546 +                * First get channel A/B node pointers
57547 +                * 
57548 +                * TODO: Add routines with proper locking to do that...
57549 +                */
57550 +               node_a = node_b = NULL;
57551 +               for (np = NULL; (np = of_get_next_child(node_p, np)) != NULL;) {
57552 +                       if (strncmp(np->name, "ch-a", 4) == 0)
57553 +                               node_a = of_node_get(np);
57554 +                       else if (strncmp(np->name, "ch-b", 4) == 0)
57555 +                               node_b = of_node_get(np);
57556 +               }
57557 +               if (!node_a || !node_b) {
57558 +                       of_node_put(node_a);
57559 +                       of_node_put(node_b);
57560 +                       printk(KERN_ERR "pmac_zilog: missing node %c for escc %s\n",
57561 +                               (!node_a) ? 'a' : 'b', node_p->full_name);
57562 +                       goto next;
57563 +               }
57564 +
57565 +               /*
57566 +                * Fill basic fields in the port structures
57567 +                */
57568 +               pmz_ports[count].mate           = &pmz_ports[count+1];
57569 +               pmz_ports[count+1].mate         = &pmz_ports[count];
57570 +               pmz_ports[count].flags          = PMACZILOG_FLAG_IS_CHANNEL_A;
57571 +               pmz_ports[count].node           = node_a;
57572 +               pmz_ports[count+1].node         = node_b;
57573 +               pmz_ports[count].port.line      = count;
57574 +               pmz_ports[count+1].port.line    = count+1;
57575 +
57576 +               /*
57577 +                * Setup the ports for real
57578 +                */
57579 +               rc = pmz_setup_port(&pmz_ports[count], early);
57580 +               if (rc == 0)
57581 +                       rc = pmz_setup_port(&pmz_ports[count+1], early);
57582 +               if (rc != 0) {
57583 +                       of_node_put(node_a);
57584 +                       of_node_put(node_b);
57585 +                       memset(&pmz_ports[count], 0, sizeof(struct uart_pmac_port));
57586 +                       memset(&pmz_ports[count+1], 0, sizeof(struct uart_pmac_port));
57587 +                       goto next;
57588 +               }
57589 +               count += 2;
57590 +next:
57591 +               node_p = of_find_node_by_name(node_p, "escc");
57592 +       }
57593 +       pmz_ports_count = count;
57594 +
57595 +       return 0;
57596 +}
57597 +
57598 +static struct uart_driver pmz_uart_reg = {
57599 +       .owner          =       THIS_MODULE,
57600 +       .driver_name    =       "ttyS",
57601 +       .devfs_name     =       "tts/",
57602 +       .dev_name       =       "ttyS",
57603 +       .major          =       TTY_MAJOR,
57604 +};
57605 +
57606 +#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
57607 +
57608 +static void pmz_console_write(struct console *con, const char *s, unsigned int count);
57609 +static int __init pmz_console_setup(struct console *co, char *options);
57610 +
57611 +static struct console pmz_console = {
57612 +       .name   =       "ttyS",
57613 +       .write  =       pmz_console_write,
57614 +       .device =       uart_console_device,
57615 +       .setup  =       pmz_console_setup,
57616 +       .flags  =       CON_PRINTBUFFER,
57617 +       .index  =       -1,
57618 +       .data   =       &pmz_uart_reg,
57619 +};
57620 +
57621 +#define PMACZILOG_CONSOLE      &pmz_console
57622 +#else /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
57623 +#define PMACZILOG_CONSOLE      (NULL)
57624 +#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
57625 +
57626 +/*
57627 + * Register the driver, console driver and ports with the serial
57628 + * core
57629 + */
57630 +static int __init pmz_register(void)
57631 +{
57632 +       int i, rc;
57633 +       
57634 +       pmz_uart_reg.nr = pmz_ports_count;
57635 +       pmz_uart_reg.cons = PMACZILOG_CONSOLE;
57636 +       pmz_uart_reg.minor = 64;
57637 +
57638 +       /*
57639 +        * Register this driver with the serial core
57640 +        */
57641 +       rc = uart_register_driver(&pmz_uart_reg);
57642 +       if (rc != 0)
57643 +               return rc;
57644 +
57645 +       /*
57646 +        * Register each port with the serial core
57647 +        */
57648 +       for (i = 0; i < pmz_ports_count; i++) {
57649 +               struct uart_pmac_port *uport = &pmz_ports[i];
57650 +               if (uport->node != NULL)
57651 +                       uart_add_one_port(&pmz_uart_reg, &uport->port);
57652 +       }
57653 +
57654 +       return 0;
57655 +}
57656 +
57657 +static struct of_match pmz_match[] = 
57658 +{
57659 +       {
57660 +       .name           = "ch-a",
57661 +       .type           = OF_ANY_MATCH,
57662 +       .compatible     = OF_ANY_MATCH
57663 +       },
57664 +       {
57665 +       .name           = "ch-b",
57666 +       .type           = OF_ANY_MATCH,
57667 +       .compatible     = OF_ANY_MATCH
57668 +       },
57669 +       {},
57670 +};
57671 +
57672 +static struct macio_driver pmz_driver = 
57673 +{
57674 +       .name           = "pmac_zilog",
57675 +       .match_table    = pmz_match,
57676 +       .probe          = pmz_attach,
57677 +       .remove         = pmz_detach,
57678 +//     .suspend        = pmz_suspend, *** NYI
57679 +//     .resume         = pmz_resume,  *** NYI
57680 +};
57681 +
57682 +static void pmz_fixup_resources(void)
57683 +{
57684 +       int i;
57685 +               for (i=0; i<pmz_ports_count; i++) {
57686 +                       struct uart_pmac_port *up = &pmz_ports[i];
57687 +
57688 +               if (up->node == NULL)
57689 +                       continue;
57690 +                       if (up->flags & PMACZILOG_FLAG_RSRC_REQUESTED)
57691 +                       continue;
57692 +               if (request_OF_resource(up->node, 0, NULL) == NULL)
57693 +                       printk(KERN_WARNING "%s: Failed to do late IO resource request, port still active\n",
57694 +                              up->node->name);
57695 +               up->flags |= PMACZILOG_FLAG_RSRC_REQUESTED;
57696 +               if (!ZS_HAS_DMA(up))
57697 +                       continue;
57698 +               if (request_OF_resource(up->node, up->node->n_addrs - 2, NULL) == NULL)
57699 +                       printk(KERN_WARNING "%s: Failed to do late DMA resource request, port still active\n",
57700 +                              up->node->name);
57701 +               if (request_OF_resource(up->node, up->node->n_addrs - 1, NULL) == NULL)
57702 +                       printk(KERN_WARNING "%s: Failed to do late DMA resource request, port still active\n",
57703 +                              up->node->name);
57704 +               }
57705 +
57706 +}
57707 +
57708 +static int __init init_pmz(void)
57709 +{
57710 +       printk(KERN_DEBUG "%s\n", version);
57711 +
57712 +       /*
57713 +        * If we had serial console, then we didn't request
57714 +        * resources yet. We fix that up now
57715 +        */
57716 +       if (pmz_ports_count > 0)
57717 +               pmz_fixup_resources();
57718 +
57719 +       /* 
57720 +        * First, we need to do a direct OF-based probe pass. We
57721 +        * do that because we want serial console up before the
57722 +        * macio stuffs calls us back, and since that makes it
57723 +        * easier to pass the proper number of channels to
57724 +        * uart_register_driver()
57725 +        */
57726 +       if (pmz_ports_count == 0)
57727 +               pmz_probe(0);
57728 +
57729 +       /*
57730 +        * Bail early if no port found
57731 +        */
57732 +       if (pmz_ports_count == 0)
57733 +               return -ENODEV;
57734 +
57735 +       /*
57736 +        * Now we register with the serial layer
57737 +        */
57738 +       pmz_register();
57739 +       
57740 +       /*
57741 +        * Then we register the macio driver itself
57742 +        */
57743 +       return macio_register_driver(&pmz_driver);
57744 +}
57745 +
57746 +static void __exit exit_pmz(void)
57747 +{
57748 +       int i;
57749 +
57750 +       /* Get rid of macio-driver (detach from macio) */
57751 +       macio_unregister_driver(&pmz_driver);
57752 +
57753 +       /* Unregister UART driver */
57754 +       uart_unregister_driver(&pmz_uart_reg);
57755 +
57756 +       for (i = 0; i < pmz_ports_count; i++) {
57757 +               struct uart_pmac_port *uport = &pmz_ports[i];
57758 +               if (uport->node != NULL) {
57759 +                       uart_remove_one_port(&pmz_uart_reg, &uport->port);
57760 +                       pmz_dispose_port(uport);
57761 +               }
57762 +       }
57763 +}
57764 +
57765 +#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
57766 +
57767 +/*
57768 + * Print a string to the serial port trying not to disturb
57769 + * any possible real use of the port...
57770 + */
57771 +static void pmz_console_write(struct console *con, const char *s, unsigned int count)
57772 +{
57773 +       struct uart_pmac_port *up = &pmz_ports[con->index];
57774 +       unsigned long flags;
57775 +       int i;
57776 +
57777 +       spin_lock_irqsave(&up->port.lock, flags);
57778 +
57779 +       /* Turn of interrupts and enable the transmitter. */
57780 +       write_zsreg(up, R1, up->curregs[1] & ~TxINT_ENAB);
57781 +       write_zsreg(up, R5, up->curregs[5] | TxENABLE | RTS | DTR);
57782 +
57783 +       for (i = 0; i < count; i++) {
57784 +               /* Wait for the transmit buffer to empty. */
57785 +               while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0)
57786 +                       udelay(5);
57787 +               write_zsdata(up, s[i]);
57788 +               if (s[i] == 10) {
57789 +                       while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0)
57790 +                               udelay(5);
57791 +                       write_zsdata(up, R13);
57792 +               }
57793 +       }
57794 +
57795 +       /* Restore the values in the registers. */
57796 +       write_zsreg(up, R1, up->curregs[1]);
57797 +       /* Don't disable the transmitter. */
57798 +
57799 +       spin_unlock_irqrestore(&up->port.lock, flags);
57800 +}
57801 +
57802 +/*
57803 + * Setup the serial console
57804 + */
57805 +static int __init pmz_console_setup(struct console *co, char *options)
57806 +{
57807 +       struct uart_port *port;
57808 +       int baud = 38400;
57809 +       int bits = 8;
57810 +       int parity = 'n';
57811 +       int flow = 'n';
57812 +       unsigned long pwr_delay;
57813 +
57814 +       /*
57815 +        * XServe's default to 57600 bps
57816 +        */
57817 +       if (machine_is_compatible("RackMac1,1")
57818 +        || machine_is_compatible("RackMac1,2"))
57819 +               baud = 57600;
57820 +
57821 +       /*
57822 +        * Check whether an invalid uart number has been specified, and
57823 +        * if so, search for the first available port that does have
57824 +        * console support.
57825 +        */
57826 +       if (co->index >= pmz_ports_count)
57827 +               co->index = 0;
57828 +       port = &pmz_ports[co->index].port;
57829 +
57830 +       /*
57831 +        * Mark port as beeing a console
57832 +        */
57833 +       port->flags |= PMACZILOG_FLAG_IS_CONS;
57834 +
57835 +       /*
57836 +        * Temporary fix for uart layer who didn't setup the spinlock yet
57837 +        */
57838 +       spin_lock_init(&port->lock);
57839 +
57840 +       /*
57841 +        * Enable the hardware
57842 +        */
57843 +       pwr_delay = __pmz_startup(&pmz_ports[co->index]);
57844 +       if (pwr_delay)
57845 +               mdelay(pwr_delay);
57846 +       
57847 +       if (options)
57848 +               uart_parse_options(options, &baud, &parity, &bits, &flow);
57849 +
57850 +       return uart_set_options(port, co, baud, parity, bits, flow);
57851 +}
57852 +
57853 +static int __init pmz_console_init(void)
57854 +{
57855 +       /* Probe ports */
57856 +       pmz_probe(1);
57857 +
57858 +       /* TODO: Autoprobe console based on OF */
57859 +       /* pmz_console.index = i; */
57860 +       register_console(&pmz_console);
57861 +
57862 +       return 0;
57863 +
57864 +}
57865 +console_initcall(pmz_console_init);
57866 +#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
57867 +
57868 +module_init(init_pmz);
57869 +module_exit(exit_pmz);
57870 diff -Nru a/drivers/serial/pmac_zilog.h b/drivers/serial/pmac_zilog.h
57871 --- /dev/null   Wed Dec 31 16:00:00 1969
57872 +++ b/drivers/serial/pmac_zilog.h       Sun Aug 24 08:05:54 2003
57873 @@ -0,0 +1,361 @@
57874 +#ifndef __PMAC_ZILOG_H__
57875 +#define __PMAC_ZILOG_H__
57876 +
57877 +/*
57878 + * At most 2 ESCCs with 2 ports each
57879 + */
57880 +#define MAX_ZS_PORTS   4
57881 +
57882 +/* 
57883 + * We wrap our port structure around the generic uart_port.
57884 + */
57885 +#define NUM_ZSREGS    16
57886 +
57887 +struct uart_pmac_port {
57888 +       struct uart_port                port;
57889 +       struct uart_pmac_port           *mate;
57890 +
57891 +       /* macio_dev for the escc holding this port (maybe be null on
57892 +        * early inited port)
57893 +        */
57894 +       struct macio_dev                *dev;
57895 +       /* device node to this port, this points to one of 2 childs
57896 +        * of "escc" node (ie. ch-a or ch-b)
57897 +        */
57898 +       struct device_node              *node;
57899 +
57900 +       /* Port type as obtained from device tree (IRDA, modem, ...) */
57901 +       int                             port_type;
57902 +       u8                              curregs[NUM_ZSREGS];
57903 +
57904 +       unsigned int                    flags;
57905 +#define PMACZILOG_FLAG_IS_CONS         0x00000001
57906 +#define PMACZILOG_FLAG_IS_KGDB         0x00000002
57907 +#define PMACZILOG_FLAG_MODEM_STATUS    0x00000004
57908 +#define PMACZILOG_FLAG_IS_CHANNEL_A    0x00000008
57909 +#define PMACZILOG_FLAG_REGS_HELD       0x00000010
57910 +#define PMACZILOG_FLAG_TX_STOPPED      0x00000020
57911 +#define PMACZILOG_FLAG_TX_ACTIVE       0x00000040
57912 +#define PMACZILOG_FLAG_ENABLED          0x00000080
57913 +#define PMACZILOG_FLAG_IS_IRDA         0x00000100
57914 +#define PMACZILOG_FLAG_IS_INTMODEM     0x00000200
57915 +#define PMACZILOG_FLAG_HAS_DMA         0x00000400
57916 +#define PMACZILOG_FLAG_RSRC_REQUESTED  0x00000800
57917 +
57918 +       unsigned char                   parity_mask;
57919 +       unsigned char                   prev_status;
57920 +
57921 +       volatile u8                     *control_reg;
57922 +       volatile u8                     *data_reg;
57923 +
57924 +       unsigned int                    tx_dma_irq;
57925 +       unsigned int                    rx_dma_irq;
57926 +       volatile struct dbdma_regs      *tx_dma_regs;
57927 +       volatile struct dbdma_regs      *rx_dma_regs;
57928 +};
57929 +
57930 +#define to_pmz(p) ((struct uart_pmac_port *)(p))
57931 +
57932 +/*
57933 + * Register acessors. Note that we don't need to enforce a recovery
57934 + * delay on PCI PowerMac hardware, it's dealt in HW by the MacIO chip,
57935 + * though if we try to use this driver on older machines, we might have
57936 + * to add it back
57937 + */
57938 +static inline u8 read_zsreg(struct uart_pmac_port *port, u8 reg)
57939 +{
57940 +       if (reg != 0)
57941 +               writeb(reg, port->control_reg);
57942 +       return readb(port->control_reg);
57943 +}
57944 +
57945 +static inline void write_zsreg(struct uart_pmac_port *port, u8 reg, u8 value)
57946 +{
57947 +       if (reg != 0)
57948 +               writeb(reg, port->control_reg);
57949 +       writeb(value, port->control_reg);
57950 +}
57951 +
57952 +static inline u8 read_zsdata(struct uart_pmac_port *port)
57953 +{
57954 +       return readb(port->data_reg);
57955 +}
57956 +
57957 +static inline void write_zsdata(struct uart_pmac_port *port, u8 data)
57958 +{
57959 +       writeb(data, port->data_reg);
57960 +}
57961 +
57962 +static inline void zssync(struct uart_pmac_port *port)
57963 +{
57964 +       (void)readb(port->control_reg);
57965 +}
57966 +
57967 +/* Conversion routines to/from brg time constants from/to bits
57968 + * per second.
57969 + */
57970 +#define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
57971 +#define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
57972 +
57973 +#define ZS_CLOCK         3686400       /* Z8530 RTxC input clock rate */
57974 +
57975 +/* The Zilog register set */
57976 +
57977 +#define        FLAG    0x7e
57978 +
57979 +/* Write Register 0 */
57980 +#define        R0      0               /* Register selects */
57981 +#define        R1      1
57982 +#define        R2      2
57983 +#define        R3      3
57984 +#define        R4      4
57985 +#define        R5      5
57986 +#define        R6      6
57987 +#define        R7      7
57988 +#define        R8      8
57989 +#define        R9      9
57990 +#define        R10     10
57991 +#define        R11     11
57992 +#define        R12     12
57993 +#define        R13     13
57994 +#define        R14     14
57995 +#define        R15     15
57996 +
57997 +#define        NULLCODE        0       /* Null Code */
57998 +#define        POINT_HIGH      0x8     /* Select upper half of registers */
57999 +#define        RES_EXT_INT     0x10    /* Reset Ext. Status Interrupts */
58000 +#define        SEND_ABORT      0x18    /* HDLC Abort */
58001 +#define        RES_RxINT_FC    0x20    /* Reset RxINT on First Character */
58002 +#define        RES_Tx_P        0x28    /* Reset TxINT Pending */
58003 +#define        ERR_RES         0x30    /* Error Reset */
58004 +#define        RES_H_IUS       0x38    /* Reset highest IUS */
58005 +
58006 +#define        RES_Rx_CRC      0x40    /* Reset Rx CRC Checker */
58007 +#define        RES_Tx_CRC      0x80    /* Reset Tx CRC Checker */
58008 +#define        RES_EOM_L       0xC0    /* Reset EOM latch */
58009 +
58010 +/* Write Register 1 */
58011 +
58012 +#define        EXT_INT_ENAB    0x1     /* Ext Int Enable */
58013 +#define        TxINT_ENAB      0x2     /* Tx Int Enable */
58014 +#define        PAR_SPEC        0x4     /* Parity is special condition */
58015 +
58016 +#define        RxINT_DISAB     0       /* Rx Int Disable */
58017 +#define        RxINT_FCERR     0x8     /* Rx Int on First Character Only or Error */
58018 +#define        INT_ALL_Rx      0x10    /* Int on all Rx Characters or error */
58019 +#define        INT_ERR_Rx      0x18    /* Int on error only */
58020 +#define RxINT_MASK     0x18
58021 +
58022 +#define        WT_RDY_RT       0x20    /* W/Req reflects recv if 1, xmit if 0 */
58023 +#define        WT_FN_RDYFN     0x40    /* W/Req pin is DMA request if 1, wait if 0 */
58024 +#define        WT_RDY_ENAB     0x80    /* Enable W/Req pin */
58025 +
58026 +/* Write Register #2 (Interrupt Vector) */
58027 +
58028 +/* Write Register 3 */
58029 +
58030 +#define        RxENABLE        0x1     /* Rx Enable */
58031 +#define        SYNC_L_INH      0x2     /* Sync Character Load Inhibit */
58032 +#define        ADD_SM          0x4     /* Address Search Mode (SDLC) */
58033 +#define        RxCRC_ENAB      0x8     /* Rx CRC Enable */
58034 +#define        ENT_HM          0x10    /* Enter Hunt Mode */
58035 +#define        AUTO_ENAB       0x20    /* Auto Enables */
58036 +#define        Rx5             0x0     /* Rx 5 Bits/Character */
58037 +#define        Rx7             0x40    /* Rx 7 Bits/Character */
58038 +#define        Rx6             0x80    /* Rx 6 Bits/Character */
58039 +#define        Rx8             0xc0    /* Rx 8 Bits/Character */
58040 +#define RxN_MASK       0xc0
58041 +
58042 +/* Write Register 4 */
58043 +
58044 +#define        PAR_ENAB        0x1     /* Parity Enable */
58045 +#define        PAR_EVEN        0x2     /* Parity Even/Odd* */
58046 +
58047 +#define        SYNC_ENAB       0       /* Sync Modes Enable */
58048 +#define        SB1             0x4     /* 1 stop bit/char */
58049 +#define        SB15            0x8     /* 1.5 stop bits/char */
58050 +#define        SB2             0xc     /* 2 stop bits/char */
58051 +#define SB_MASK                0xc
58052 +
58053 +#define        MONSYNC         0       /* 8 Bit Sync character */
58054 +#define        BISYNC          0x10    /* 16 bit sync character */
58055 +#define        SDLC            0x20    /* SDLC Mode (01111110 Sync Flag) */
58056 +#define        EXTSYNC         0x30    /* External Sync Mode */
58057 +
58058 +#define        X1CLK           0x0     /* x1 clock mode */
58059 +#define        X16CLK          0x40    /* x16 clock mode */
58060 +#define        X32CLK          0x80    /* x32 clock mode */
58061 +#define        X64CLK          0xC0    /* x64 clock mode */
58062 +#define XCLK_MASK      0xC0
58063 +
58064 +/* Write Register 5 */
58065 +
58066 +#define        TxCRC_ENAB      0x1     /* Tx CRC Enable */
58067 +#define        RTS             0x2     /* RTS */
58068 +#define        SDLC_CRC        0x4     /* SDLC/CRC-16 */
58069 +#define        TxENABLE        0x8     /* Tx Enable */
58070 +#define        SND_BRK         0x10    /* Send Break */
58071 +#define        Tx5             0x0     /* Tx 5 bits (or less)/character */
58072 +#define        Tx7             0x20    /* Tx 7 bits/character */
58073 +#define        Tx6             0x40    /* Tx 6 bits/character */
58074 +#define        Tx8             0x60    /* Tx 8 bits/character */
58075 +#define TxN_MASK       0x60
58076 +#define        DTR             0x80    /* DTR */
58077 +
58078 +/* Write Register 6 (Sync bits 0-7/SDLC Address Field) */
58079 +
58080 +/* Write Register 7 (Sync bits 8-15/SDLC 01111110) */
58081 +
58082 +/* Write Register 7' (Some enhanced feature control) */
58083 +#define        ENEXREAD        0x40    /* Enable read of some write registers */
58084 +
58085 +/* Write Register 8 (transmit buffer) */
58086 +
58087 +/* Write Register 9 (Master interrupt control) */
58088 +#define        VIS     1       /* Vector Includes Status */
58089 +#define        NV      2       /* No Vector */
58090 +#define        DLC     4       /* Disable Lower Chain */
58091 +#define        MIE     8       /* Master Interrupt Enable */
58092 +#define        STATHI  0x10    /* Status high */
58093 +#define        NORESET 0       /* No reset on write to R9 */
58094 +#define        CHRB    0x40    /* Reset channel B */
58095 +#define        CHRA    0x80    /* Reset channel A */
58096 +#define        FHWRES  0xc0    /* Force hardware reset */
58097 +
58098 +/* Write Register 10 (misc control bits) */
58099 +#define        BIT6    1       /* 6 bit/8bit sync */
58100 +#define        LOOPMODE 2      /* SDLC Loop mode */
58101 +#define        ABUNDER 4       /* Abort/flag on SDLC xmit underrun */
58102 +#define        MARKIDLE 8      /* Mark/flag on idle */
58103 +#define        GAOP    0x10    /* Go active on poll */
58104 +#define        NRZ     0       /* NRZ mode */
58105 +#define        NRZI    0x20    /* NRZI mode */
58106 +#define        FM1     0x40    /* FM1 (transition = 1) */
58107 +#define        FM0     0x60    /* FM0 (transition = 0) */
58108 +#define        CRCPS   0x80    /* CRC Preset I/O */
58109 +
58110 +/* Write Register 11 (Clock Mode control) */
58111 +#define        TRxCXT  0       /* TRxC = Xtal output */
58112 +#define        TRxCTC  1       /* TRxC = Transmit clock */
58113 +#define        TRxCBR  2       /* TRxC = BR Generator Output */
58114 +#define        TRxCDP  3       /* TRxC = DPLL output */
58115 +#define        TRxCOI  4       /* TRxC O/I */
58116 +#define        TCRTxCP 0       /* Transmit clock = RTxC pin */
58117 +#define        TCTRxCP 8       /* Transmit clock = TRxC pin */
58118 +#define        TCBR    0x10    /* Transmit clock = BR Generator output */
58119 +#define        TCDPLL  0x18    /* Transmit clock = DPLL output */
58120 +#define        RCRTxCP 0       /* Receive clock = RTxC pin */
58121 +#define        RCTRxCP 0x20    /* Receive clock = TRxC pin */
58122 +#define        RCBR    0x40    /* Receive clock = BR Generator output */
58123 +#define        RCDPLL  0x60    /* Receive clock = DPLL output */
58124 +#define        RTxCX   0x80    /* RTxC Xtal/No Xtal */
58125 +
58126 +/* Write Register 12 (lower byte of baud rate generator time constant) */
58127 +
58128 +/* Write Register 13 (upper byte of baud rate generator time constant) */
58129 +
58130 +/* Write Register 14 (Misc control bits) */
58131 +#define        BRENAB  1       /* Baud rate generator enable */
58132 +#define        BRSRC   2       /* Baud rate generator source */
58133 +#define        DTRREQ  4       /* DTR/Request function */
58134 +#define        AUTOECHO 8      /* Auto Echo */
58135 +#define        LOOPBAK 0x10    /* Local loopback */
58136 +#define        SEARCH  0x20    /* Enter search mode */
58137 +#define        RMC     0x40    /* Reset missing clock */
58138 +#define        DISDPLL 0x60    /* Disable DPLL */
58139 +#define        SSBR    0x80    /* Set DPLL source = BR generator */
58140 +#define        SSRTxC  0xa0    /* Set DPLL source = RTxC */
58141 +#define        SFMM    0xc0    /* Set FM mode */
58142 +#define        SNRZI   0xe0    /* Set NRZI mode */
58143 +
58144 +/* Write Register 15 (external/status interrupt control) */
58145 +#define        EN85C30 1       /* Enable some 85c30-enhanced registers */
58146 +#define        ZCIE    2       /* Zero count IE */
58147 +#define        ENSTFIFO 4      /* Enable status FIFO (SDLC) */
58148 +#define        DCDIE   8       /* DCD IE */
58149 +#define        SYNCIE  0x10    /* Sync/hunt IE */
58150 +#define        CTSIE   0x20    /* CTS IE */
58151 +#define        TxUIE   0x40    /* Tx Underrun/EOM IE */
58152 +#define        BRKIE   0x80    /* Break/Abort IE */
58153 +
58154 +
58155 +/* Read Register 0 */
58156 +#define        Rx_CH_AV        0x1     /* Rx Character Available */
58157 +#define        ZCOUNT          0x2     /* Zero count */
58158 +#define        Tx_BUF_EMP      0x4     /* Tx Buffer empty */
58159 +#define        DCD             0x8     /* DCD */
58160 +#define        SYNC_HUNT       0x10    /* Sync/hunt */
58161 +#define        CTS             0x20    /* CTS */
58162 +#define        TxEOM           0x40    /* Tx underrun */
58163 +#define        BRK_ABRT        0x80    /* Break/Abort */
58164 +
58165 +/* Read Register 1 */
58166 +#define        ALL_SNT         0x1     /* All sent */
58167 +/* Residue Data for 8 Rx bits/char programmed */
58168 +#define        RES3            0x8     /* 0/3 */
58169 +#define        RES4            0x4     /* 0/4 */
58170 +#define        RES5            0xc     /* 0/5 */
58171 +#define        RES6            0x2     /* 0/6 */
58172 +#define        RES7            0xa     /* 0/7 */
58173 +#define        RES8            0x6     /* 0/8 */
58174 +#define        RES18           0xe     /* 1/8 */
58175 +#define        RES28           0x0     /* 2/8 */
58176 +/* Special Rx Condition Interrupts */
58177 +#define        PAR_ERR         0x10    /* Parity error */
58178 +#define        Rx_OVR          0x20    /* Rx Overrun Error */
58179 +#define        CRC_ERR         0x40    /* CRC/Framing Error */
58180 +#define        END_FR          0x80    /* End of Frame (SDLC) */
58181 +
58182 +/* Read Register 2 (channel b only) - Interrupt vector */
58183 +#define        CHB_Tx_EMPTY    0x00
58184 +#define        CHB_EXT_STAT    0x02
58185 +#define        CHB_Rx_AVAIL    0x04
58186 +#define        CHB_SPECIAL     0x06
58187 +#define        CHA_Tx_EMPTY    0x08
58188 +#define        CHA_EXT_STAT    0x0a
58189 +#define        CHA_Rx_AVAIL    0x0c
58190 +#define        CHA_SPECIAL     0x0e
58191 +#define        STATUS_MASK     0x06
58192 +
58193 +/* Read Register 3 (interrupt pending register) ch a only */
58194 +#define        CHBEXT  0x1             /* Channel B Ext/Stat IP */
58195 +#define        CHBTxIP 0x2             /* Channel B Tx IP */
58196 +#define        CHBRxIP 0x4             /* Channel B Rx IP */
58197 +#define        CHAEXT  0x8             /* Channel A Ext/Stat IP */
58198 +#define        CHATxIP 0x10            /* Channel A Tx IP */
58199 +#define        CHARxIP 0x20            /* Channel A Rx IP */
58200 +
58201 +/* Read Register 8 (receive data register) */
58202 +
58203 +/* Read Register 10  (misc status bits) */
58204 +#define        ONLOOP  2               /* On loop */
58205 +#define        LOOPSEND 0x10           /* Loop sending */
58206 +#define        CLK2MIS 0x40            /* Two clocks missing */
58207 +#define        CLK1MIS 0x80            /* One clock missing */
58208 +
58209 +/* Read Register 12 (lower byte of baud rate generator constant) */
58210 +
58211 +/* Read Register 13 (upper byte of baud rate generator constant) */
58212 +
58213 +/* Read Register 15 (value of WR 15) */
58214 +
58215 +/* Misc macros */
58216 +#define ZS_CLEARERR(port)    (write_zsreg(port, 0, ERR_RES))
58217 +#define ZS_CLEARFIFO(port)   do { volatile unsigned char garbage; \
58218 +                                    garbage = read_zsdata(port); \
58219 +                                    garbage = read_zsdata(port); \
58220 +                                    garbage = read_zsdata(port); \
58221 +                               } while(0)
58222 +
58223 +#define ZS_IS_CONS(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_CONS)
58224 +#define ZS_IS_KGDB(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_KGDB)
58225 +#define ZS_IS_CHANNEL_A(UP)            ((UP)->flags & PMACZILOG_FLAG_IS_CHANNEL_A)
58226 +#define ZS_REGS_HELD(UP)               ((UP)->flags & PMACZILOG_FLAG_REGS_HELD)
58227 +#define ZS_TX_STOPPED(UP)              ((UP)->flags & PMACZILOG_FLAG_TX_STOPPED)
58228 +#define ZS_TX_ACTIVE(UP)               ((UP)->flags & PMACZILOG_FLAG_TX_ACTIVE)
58229 +#define ZS_WANTS_MODEM_STATUS(UP)      ((UP)->flags & PMACZILOG_FLAG_MODEM_STATUS)
58230 +#define ZS_IS_IRDA(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_IRDA)
58231 +#define ZS_IS_INTMODEM(UP)             ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM)
58232 +#define ZS_HAS_DMA(UP)                 ((UP)->flags & PMACZILOG_FLAG_HAS_DMA)
58233 +
58234 +#endif /* __PMAC_ZILOG_H__ */
58235 diff -Nru a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
58236 --- a/drivers/telephony/ixj.c   Sun Jul 27 12:29:47 2003
58237 +++ b/drivers/telephony/ixj.c   Tue Aug 26 09:25:41 2003
58238 @@ -278,8 +278,8 @@
58239  
58240  #include "ixj.h"
58241  
58242 -#define TYPE(dev) (minor(dev) >> 4)
58243 -#define NUM(dev) (minor(dev) & 0xf)
58244 +#define TYPE(inode) (iminor(inode) >> 4)
58245 +#define NUM(inode) (iminor(inode) & 0xf)
58246  
58247  static int ixjdebug;
58248  static int hertz = HZ;
58249 @@ -2273,7 +2273,7 @@
58250                 schedule_timeout(1);
58251         }
58252         if (ixjdebug & 0x0002)
58253 -               printk(KERN_INFO "Closing board %d\n", NUM(inode->i_rdev));
58254 +               printk(KERN_INFO "Closing board %d\n", NUM(inode));
58255  
58256         if (j->cardtype == QTI_PHONECARD)
58257                 ixj_set_port(j, PORT_SPEAKER);
58258 @@ -2858,7 +2858,7 @@
58259  static ssize_t ixj_read(struct file * file_p, char *buf, size_t length, loff_t * ppos)
58260  {
58261         unsigned long i = *ppos;
58262 -       IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
58263 +       IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode));
58264  
58265         DECLARE_WAITQUEUE(wait, current);
58266  
58267 @@ -2915,7 +2915,7 @@
58268  {
58269         int pre_retval;
58270         ssize_t read_retval = 0;
58271 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
58272 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
58273  
58274         pre_retval = ixj_PreRead(j, 0L);
58275         switch (pre_retval) {
58276 @@ -2994,7 +2994,7 @@
58277         int pre_retval;
58278         ssize_t write_retval = 0;
58279  
58280 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
58281 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
58282  
58283         pre_retval = ixj_PreWrite(j, 0L);
58284         switch (pre_retval) {
58285 @@ -4707,7 +4707,7 @@
58286  {
58287         unsigned int mask = 0;
58288  
58289 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
58290 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
58291  
58292         poll_wait(file_p, &(j->poll_q), wait);
58293         if (j->read_buffer_ready > 0)
58294 @@ -6208,10 +6208,10 @@
58295         IXJ_FILTER_RAW jfr;
58296  
58297         unsigned int raise, mant;
58298 -       unsigned int minor = minor(inode->i_rdev);
58299 -       int board = NUM(inode->i_rdev);
58300 +       unsigned int minor = iminor(inode);
58301 +       int board = NUM(inode);
58302  
58303 -       IXJ *j = get_ixj(NUM(inode->i_rdev));
58304 +       IXJ *j = get_ixj(NUM(inode));
58305  
58306         int retval = 0;
58307  
58308 @@ -6764,7 +6764,7 @@
58309  
58310  static int ixj_fasync(int fd, struct file *file_p, int mode)
58311  {
58312 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
58313 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
58314  
58315         return fasync_helper(fd, file_p, mode, &j->async_queue);
58316  }
58317 diff -Nru a/drivers/telephony/phonedev.c b/drivers/telephony/phonedev.c
58318 --- a/drivers/telephony/phonedev.c      Mon Jul 14 09:05:52 2003
58319 +++ b/drivers/telephony/phonedev.c      Tue Aug 26 09:25:41 2003
58320 @@ -46,7 +46,7 @@
58321  
58322  static int phone_open(struct inode *inode, struct file *file)
58323  {
58324 -       unsigned int minor = minor(inode->i_rdev);
58325 +       unsigned int minor = iminor(inode);
58326         int err = 0;
58327         struct phone_device *p;
58328         struct file_operations *old_fops, *new_fops = NULL;
58329 diff -Nru a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
58330 --- a/drivers/usb/class/audio.c Wed Jul 30 11:00:01 2003
58331 +++ b/drivers/usb/class/audio.c Tue Aug 26 09:25:41 2003
58332 @@ -1955,7 +1955,7 @@
58333  
58334  static int usb_audio_open_mixdev(struct inode *inode, struct file *file)
58335  {
58336 -       unsigned int minor = minor(inode->i_rdev);
58337 +       unsigned int minor = iminor(inode);
58338         struct list_head *devs, *mdevs;
58339         struct usb_mixerdev *ms;
58340         struct usb_audio_state *s;
58341 @@ -2633,7 +2633,7 @@
58342  
58343  static int usb_audio_open(struct inode *inode, struct file *file)
58344  {
58345 -       unsigned int minor = minor(inode->i_rdev);
58346 +       unsigned int minor = iminor(inode);
58347         DECLARE_WAITQUEUE(wait, current);
58348         struct list_head *devs, *adevs;
58349         struct usb_audiodev *as;
58350 diff -Nru a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c
58351 --- a/drivers/usb/class/bluetty.c       Wed Jul 30 05:49:21 2003
58352 +++ b/drivers/usb/class/bluetty.c       Wed Aug 27 04:45:14 2003
58353 @@ -1,8 +1,8 @@
58354  /*
58355   * bluetty.c   Version 0.13
58356   *
58357 - * Copyright (c) 2000, 2001 Greg Kroah-Hartman <greg@kroah.com>
58358 - * Copyright (c) 2000 Mark Douglas Corner      <mcorner@umich.edu>
58359 + * Copyright (C) 2000, 2001 Greg Kroah-Hartman <greg@kroah.com>
58360 + * Copyright (C) 2000 Mark Douglas Corner      <mcorner@umich.edu>
58361   *
58362   * USB Bluetooth TTY driver, based on the Bluetooth Spec version 1.0B
58363   * 
58364 diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
58365 --- a/drivers/usb/class/cdc-acm.c       Mon Aug 11 07:56:25 2003
58366 +++ b/drivers/usb/class/cdc-acm.c       Sat Aug 23 12:40:13 2003
58367 @@ -767,6 +767,7 @@
58368  
58369  static int __init acm_init(void)
58370  {
58371 +       int retval;
58372         acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
58373         if (!acm_tty_driver)
58374                 return -ENOMEM;
58375 @@ -783,15 +784,17 @@
58376         acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
58377         tty_set_operations(acm_tty_driver, &acm_ops);
58378  
58379 -       if (tty_register_driver(acm_tty_driver)) {
58380 +       retval = tty_register_driver(acm_tty_driver);
58381 +       if (retval) {
58382                 put_tty_driver(acm_tty_driver);
58383 -               return -1;
58384 +               return retval;
58385         }
58386  
58387 -       if (usb_register(&acm_driver) < 0) {
58388 +       retval = usb_register(&acm_driver);
58389 +       if (retval) {
58390                 tty_unregister_driver(acm_tty_driver);
58391                 put_tty_driver(acm_tty_driver);
58392 -               return -1;
58393 +               return retval;
58394         }
58395  
58396         info(DRIVER_VERSION ":" DRIVER_DESC);
58397 diff -Nru a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c
58398 --- a/drivers/usb/class/usb-midi.c      Tue Jul 29 04:28:54 2003
58399 +++ b/drivers/usb/class/usb-midi.c      Tue Sep  2 11:40:27 2003
58400 @@ -812,7 +812,7 @@
58401  
58402  static int usb_midi_open(struct inode *inode, struct file *file)
58403  {
58404 -       int minor = minor(inode->i_rdev);
58405 +       int minor = iminor(inode);
58406         DECLARE_WAITQUEUE(wait, current);
58407         struct list_head      *devs, *mdevs;
58408         struct usb_midi_state *s;
58409 @@ -2084,16 +2084,12 @@
58410  
58411  /* ------------------------------------------------------------------------- */
58412  
58413 -int __init usb_midi_init(void)
58414 +static int __init usb_midi_init(void)
58415  {
58416 -       if ( usb_register(&usb_midi_driver) < 0 )
58417 -               return -1;
58418 -
58419 -       return 0;
58420 -
58421 +       return usb_register(&usb_midi_driver);
58422  }
58423  
58424 -void __exit usb_midi_exit(void)
58425 +static void __exit usb_midi_exit(void)
58426  {
58427         usb_deregister(&usb_midi_driver);
58428  }
58429 diff -Nru a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
58430 --- a/drivers/usb/class/usblp.c Sun Aug 10 02:01:53 2003
58431 +++ b/drivers/usb/class/usblp.c Tue Sep  2 11:40:28 2003
58432 @@ -318,7 +318,7 @@
58433  
58434  static int usblp_open(struct inode *inode, struct file *file)
58435  {
58436 -       int minor = minor(inode->i_rdev);
58437 +       int minor = iminor(inode);
58438         struct usblp *usblp;
58439         struct usb_interface *intf;
58440         int retval;
58441 @@ -1150,10 +1150,13 @@
58442  
58443  static int __init usblp_init(void)
58444  {
58445 -       if (usb_register(&usblp_driver))
58446 -               return -1;
58447 +       int retval;
58448 +       retval = usb_register(&usblp_driver);
58449 +       if (retval)
58450 +               goto out;
58451         info(DRIVER_VERSION ": " DRIVER_DESC);
58452 -       return 0;
58453 +out:
58454 +       return retval;
58455  }
58456  
58457  static void __exit usblp_exit(void)
58458 diff -Nru a/drivers/usb/core/file.c b/drivers/usb/core/file.c
58459 --- a/drivers/usb/core/file.c   Wed Aug 13 06:35:23 2003
58460 +++ b/drivers/usb/core/file.c   Tue Sep  2 11:40:28 2003
58461 @@ -34,7 +34,7 @@
58462  
58463  static int usb_open(struct inode * inode, struct file * file)
58464  {
58465 -       int minor = minor(inode->i_rdev);
58466 +       int minor = iminor(inode);
58467         struct file_operations *c;
58468         int err = -ENODEV;
58469         struct file_operations *old_fops, *new_fops = NULL;
58470 @@ -129,7 +129,7 @@
58471         int retval = -EINVAL;
58472         int minor_base = class_driver->minor_base;
58473         int minor = 0;
58474 -       char name[DEVICE_ID_SIZE];
58475 +       char name[BUS_ID_SIZE];
58476         struct class_device *class_dev;
58477         char *temp;
58478  
58479 @@ -166,7 +166,7 @@
58480         intf->minor = minor;
58481  
58482         /* handle the devfs registration */
58483 -       snprintf(name, DEVICE_ID_SIZE, class_driver->name, minor - minor_base);
58484 +       snprintf(name, BUS_ID_SIZE, class_driver->name, minor - minor_base);
58485         devfs_mk_cdev(MKDEV(USB_MAJOR, minor), class_driver->mode, name);
58486  
58487         /* create a usb class device for this usb interface */
58488 @@ -211,7 +211,7 @@
58489                         struct usb_class_driver *class_driver)
58490  {
58491         int minor_base = class_driver->minor_base;
58492 -       char name[DEVICE_ID_SIZE];
58493 +       char name[BUS_ID_SIZE];
58494  
58495  #ifdef CONFIG_USB_DYNAMIC_MINORS
58496         minor_base = 0;
58497 @@ -226,7 +226,7 @@
58498         usb_minors[intf->minor] = NULL;
58499         spin_unlock (&minor_lock);
58500  
58501 -       snprintf(name, DEVICE_ID_SIZE, class_driver->name, intf->minor - minor_base);
58502 +       snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base);
58503         devfs_remove (name);
58504  
58505         if (intf->class_dev) {
58506 diff -Nru a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
58507 --- a/drivers/usb/core/hcd-pci.c        Tue Aug 12 09:19:01 2003
58508 +++ b/drivers/usb/core/hcd-pci.c        Fri Aug 29 11:14:52 2003
58509 @@ -139,6 +139,7 @@
58510                         return retval;
58511                 }
58512         }
58513 +       // hcd zeroed everything
58514         hcd->regs = base;
58515         hcd->region = region;
58516  
58517 @@ -165,6 +166,7 @@
58518                 dev_err (hcd->controller, "can't reset\n");
58519                 goto clean_3;
58520         }
58521 +       hcd->state = USB_STATE_HALT;
58522  
58523         pci_set_master (dev);
58524  #ifndef __sparc__
58525 @@ -230,7 +232,8 @@
58526                 BUG ();
58527  
58528         hub = hcd->self.root_hub;
58529 -       hcd->state = USB_STATE_QUIESCING;
58530 +       if (HCD_IS_RUNNING (hcd->state))
58531 +               hcd->state = USB_STATE_QUIESCING;
58532  
58533         dev_dbg (hcd->controller, "roothub graceful disconnect\n");
58534         usb_disconnect (&hub);
58535 @@ -287,8 +290,8 @@
58536                 pci_save_state (dev, hcd->pci_state);
58537  
58538                 /* driver may want to disable DMA etc */
58539 +               hcd->state = USB_STATE_QUIESCING;
58540                 retval = hcd->driver->suspend (hcd, state);
58541 -               hcd->state = USB_STATE_SUSPENDED;
58542         }
58543  
58544         pci_set_power_state (dev, state);
58545 diff -Nru a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
58546 --- a/drivers/usb/core/hcd.c    Tue Aug 12 09:07:44 2003
58547 +++ b/drivers/usb/core/hcd.c    Fri Aug 29 11:16:13 2003
58548 @@ -483,7 +483,7 @@
58549  {
58550         struct urb      *urb;
58551         struct usb_hcd  *hcd;
58552 -       int             length;
58553 +       int             length = 0;
58554         unsigned long   flags;
58555  
58556         urb = (struct urb *) ptr;
58557 @@ -499,7 +499,9 @@
58558                 return;
58559         }
58560  
58561 -       length = hcd->driver->hub_status_data (hcd, urb->transfer_buffer);
58562 +       if (!HCD_IS_SUSPENDED (hcd->state))
58563 +               length = hcd->driver->hub_status_data (
58564 +                                       hcd, urb->transfer_buffer);
58565  
58566         /* complete the status urb, or retrigger the timer */
58567         spin_lock (&hcd_data_lock);
58568 @@ -1097,6 +1099,8 @@
58569  static int hcd_get_frame_number (struct usb_device *udev)
58570  {
58571         struct usb_hcd  *hcd = (struct usb_hcd *)udev->bus->hcpriv;
58572 +       if (!HCD_IS_RUNNING (hcd->state))
58573 +               return -ESHUTDOWN;
58574         return hcd->driver->get_frame_number (hcd);
58575  }
58576  
58577 @@ -1193,6 +1197,12 @@
58578                 goto done;
58579         }
58580  
58581 +       /* running ~= hc unlink handshake works (irq, timer, etc)
58582 +        * halted ~= no unlink handshake is needed
58583 +        * suspended, resuming == should never happen
58584 +        */
58585 +       WARN_ON (!HCD_IS_RUNNING (hcd->state) && hcd->state != USB_STATE_HALT);
58586 +
58587         if (!urb->hcpriv) {
58588                 retval = -EINVAL;
58589                 goto done;
58590 @@ -1208,6 +1218,17 @@
58591                 goto done;
58592         }
58593  
58594 +       /* PCI IRQ setup can easily be broken so that USB controllers
58595 +        * never get completion IRQs ... maybe even the ones we need to
58596 +        * finish unlinking the initial failed usb_set_address().
58597 +        */
58598 +       if (!hcd->saw_irq) {
58599 +               dev_warn (hcd->controller, "Unlink after no-IRQ?  "
58600 +                       "Different ACPI or APIC settings may help."
58601 +                       "\n");
58602 +               hcd->saw_irq = 1;
58603 +       }
58604 +
58605         /* maybe set up to block until the urb's completion fires.  the
58606          * lower level hcd code is always async, locking on urb->status
58607          * updates; an intercepted completion unblocks us.
58608 @@ -1287,6 +1308,8 @@
58609         dev = udev->hcpriv;
58610         hcd = udev->bus->hcpriv;
58611  
58612 +       WARN_ON (!HCD_IS_RUNNING (hcd->state) && hcd->state != USB_STATE_HALT);
58613 +
58614         local_irq_disable ();
58615  
58616  rescan:
58617 @@ -1483,6 +1506,7 @@
58618         if (unlikely (hcd->state == USB_STATE_HALT))    /* irq sharing? */
58619                 return IRQ_NONE;
58620  
58621 +       hcd->saw_irq = 1;
58622         hcd->driver->irq (hcd, r);
58623         if (hcd->state != start && hcd->state == USB_STATE_HALT)
58624                 usb_hc_died (hcd);
58625 diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
58626 --- a/drivers/usb/core/hcd.h    Tue Aug 12 09:13:35 2003
58627 +++ b/drivers/usb/core/hcd.h    Fri Aug 29 11:06:37 2003
58628 @@ -73,6 +73,7 @@
58629          * hardware info/state
58630          */
58631         struct hc_driver        *driver;        /* hw-specific hooks */
58632 +       unsigned                saw_irq : 1;
58633         int                     irq;            /* irq allocated */
58634         void                    *regs;          /* device memory/io */
58635         struct device           *controller;    /* handle to hardware */
58636 @@ -89,13 +90,11 @@
58637  
58638         int                     state;
58639  #      define  __ACTIVE                0x01
58640 -#      define  __SLEEPY                0x02
58641  #      define  __SUSPEND               0x04
58642  #      define  __TRANSIENT             0x80
58643  
58644  #      define  USB_STATE_HALT          0
58645  #      define  USB_STATE_RUNNING       (__ACTIVE)
58646 -#      define  USB_STATE_READY         (__ACTIVE|__SLEEPY)
58647  #      define  USB_STATE_QUIESCING     (__SUSPEND|__TRANSIENT|__ACTIVE)
58648  #      define  USB_STATE_RESUMING      (__SUSPEND|__TRANSIENT)
58649  #      define  USB_STATE_SUSPENDED     (__SUSPEND)
58650 diff -Nru a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
58651 --- a/drivers/usb/core/inode.c  Thu Jul 10 06:17:51 2003
58652 +++ b/drivers/usb/core/inode.c  Wed Aug 27 04:45:14 2003
58653 @@ -4,7 +4,7 @@
58654   *     inode.c  --  Inode/Dentry functions for the USB device file system.
58655   *
58656   *     Copyright (C) 2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
58657 - *     Copyright (c) 2001,2002 Greg Kroah-Hartman (greg@kroah.com)
58658 + *     Copyright (C) 2001,2002 Greg Kroah-Hartman (greg@kroah.com)
58659   *
58660   *     This program is free software; you can redistribute it and/or modify
58661   *     it under the terms of the GNU General Public License as published by
58662 diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c
58663 --- a/drivers/usb/core/message.c        Thu Aug 14 09:14:33 2003
58664 +++ b/drivers/usb/core/message.c        Thu Aug 21 04:31:25 2003
58665 @@ -246,21 +246,22 @@
58666                 io->status = urb->status;
58667  
58668                 /* the previous urbs, and this one, completed already.
58669 -                * unlink the later ones so they won't rx/tx bad data,
58670 -                *
58671 -                * FIXME don't bother unlinking urbs that haven't yet been
58672 -                * submitted; those non-error cases shouldn't be syslogged
58673 +                * unlink pending urbs so they won't rx/tx bad data.
58674                  */
58675                 for (i = 0, found = 0; i < io->entries; i++) {
58676 +                       if (!io->urbs [i])
58677 +                               continue;
58678                         if (found) {
58679                                 status = usb_unlink_urb (io->urbs [i]);
58680 -                               if (status && status != -EINPROGRESS)
58681 -                                       err ("sg_complete, unlink --> %d",
58682 -                                                       status);
58683 +                               if (status != -EINPROGRESS && status != -EBUSY)
58684 +                                       dev_err (&io->dev->dev,
58685 +                                               "%s, unlink --> %d\n",
58686 +                                               __FUNCTION__, status);
58687                         } else if (urb == io->urbs [i])
58688                                 found = 1;
58689                 }
58690         }
58691 +       urb->dev = 0;
58692  
58693         /* on the last completion, signal usb_sg_wait() */
58694         io->bytes += urb->actual_length;
58695 @@ -356,7 +357,7 @@
58696                         goto nomem;
58697                 }
58698  
58699 -               io->urbs [i]->dev = dev;
58700 +               io->urbs [i]->dev = 0;
58701                 io->urbs [i]->pipe = pipe;
58702                 io->urbs [i]->interval = period;
58703                 io->urbs [i]->transfer_flags = urb_flags;
58704 @@ -448,6 +449,7 @@
58705         for (i = 0; i < io->entries && !io->status; i++) {
58706                 int     retval;
58707  
58708 +               io->urbs [i]->dev = io->dev;
58709                 retval = usb_submit_urb (io->urbs [i], SLAB_ATOMIC);
58710  
58711                 /* after we submit, let completions or cancelations fire;
58712 @@ -459,9 +461,9 @@
58713                 case -ENXIO:    // hc didn't queue this one
58714                 case -EAGAIN:
58715                 case -ENOMEM:
58716 +                       io->urbs [i]->dev = 0;
58717                         retval = 0;
58718                         i--;
58719 -                       // FIXME:  should it usb_sg_cancel() on INTERRUPT?
58720                         yield ();
58721                         break;
58722  
58723 @@ -477,8 +479,10 @@
58724  
58725                         /* fail any uncompleted urbs */
58726                 default:
58727 +                       io->urbs [i]->dev = 0;
58728                         io->urbs [i]->status = retval;
58729 -                       dbg ("usb_sg_msg, submit --> %d", retval);
58730 +                       dev_dbg (&io->dev->dev, "%s, submit --> %d\n",
58731 +                               __FUNCTION__, retval);
58732                         usb_sg_cancel (io);
58733                 }
58734                 spin_lock_irqsave (&io->lock, flags);
58735 @@ -521,9 +525,9 @@
58736                         if (!io->urbs [i]->dev)
58737                                 continue;
58738                         retval = usb_unlink_urb (io->urbs [i]);
58739 -                       if (retval && retval != -EINPROGRESS)
58740 -                               warn ("usb_sg_cancel, unlink --> %d", retval);
58741 -                       // FIXME don't warn on "not yet submitted" error
58742 +                       if (retval != -EINPROGRESS && retval != -EBUSY)
58743 +                               dev_warn (&io->dev->dev, "%s, unlink --> %d\n",
58744 +                                       __FUNCTION__, retval);
58745                 }
58746         }
58747         spin_unlock_irqrestore (&io->lock, flags);
58748 diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
58749 --- a/drivers/usb/core/usb.c    Mon Aug 11 16:09:09 2003
58750 +++ b/drivers/usb/core/usb.c    Wed Aug 27 10:04:01 2003
58751 @@ -991,8 +991,8 @@
58752   *
58753   * This call is synchronous, and may not be used in an interrupt context.
58754   *
58755 - * Only hub drivers (including virtual root hub drivers for host
58756 - * controllers) should ever call this.
58757 + * Only the hub driver should ever call this; root hub registration
58758 + * uses it only indirectly.
58759   */
58760  #define NEW_DEVICE_RETRYS      2
58761  #define SET_ADDRESS_RETRYS     2
58762 @@ -1417,11 +1417,46 @@
58763                         usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
58764  }
58765  
58766 +static int usb_device_suspend(struct device *dev, u32 state)
58767 +{
58768 +       struct usb_interface *intf;
58769 +       struct usb_driver *driver;
58770 +
58771 +       if ((dev->driver == &usb_generic_driver) || 
58772 +           (dev->driver_data == &usb_generic_driver_data))
58773 +               return 0;
58774 +
58775 +       intf = to_usb_interface(dev);
58776 +       driver = to_usb_driver(dev->driver);
58777 +
58778 +       if (driver && driver->suspend)
58779 +               return driver->suspend(intf, state);
58780 +       return 0;
58781 +}
58782 +
58783 +static int usb_device_resume(struct device *dev)
58784 +{
58785 +       struct usb_interface *intf;
58786 +       struct usb_driver *driver;
58787 +
58788 +       if ((dev->driver == &usb_generic_driver) || 
58789 +           (dev->driver_data == &usb_generic_driver_data))
58790 +               return 0;
58791 +
58792 +       intf = to_usb_interface(dev);
58793 +       driver = to_usb_driver(dev->driver);
58794 +
58795 +       if (driver && driver->resume)
58796 +               return driver->resume(intf);
58797 +       return 0;
58798 +}
58799  
58800  struct bus_type usb_bus_type = {
58801         .name =         "usb",
58802         .match =        usb_device_match,
58803         .hotplug =      usb_hotplug,
58804 +       .suspend =      usb_device_suspend,
58805 +       .resume =       usb_device_resume,
58806  };
58807  
58808  #ifndef MODULE
58809 @@ -1509,7 +1544,6 @@
58810  EXPORT_SYMBOL(usb_find_interface);
58811  EXPORT_SYMBOL(usb_ifnum_to_if);
58812  
58813 -EXPORT_SYMBOL(usb_new_device);
58814  EXPORT_SYMBOL(usb_reset_device);
58815  EXPORT_SYMBOL(usb_disconnect);
58816  
58817 diff -Nru a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
58818 --- a/drivers/usb/gadget/net2280.c      Thu Aug  7 04:00:21 2003
58819 +++ b/drivers/usb/gadget/net2280.c      Mon Sep  1 12:15:45 2003
58820 @@ -30,6 +30,7 @@
58821  
58822  /*
58823   * Copyright (C) 2003 David Brownell
58824 + * Copyright (C) 2003 NetChip Technologies
58825   *
58826   * This program is free software; you can redistribute it and/or modify
58827   * it under the terms of the GNU General Public License as published by
58828 @@ -49,6 +50,7 @@
58829  #define DEBUG  1
58830  // #define     VERBOSE         /* extra debug messages (success too) */
58831  
58832 +#include <linux/version.h>
58833  #include <linux/config.h>
58834  #include <linux/module.h>
58835  #include <linux/pci.h>
58836 @@ -76,7 +78,7 @@
58837  
58838  
58839  #define        DRIVER_DESC             "NetChip 2280 USB Peripheral Controller"
58840 -#define        DRIVER_VERSION          "May Day 2003"
58841 +#define        DRIVER_VERSION          "Bastille Day 2003"
58842  
58843  #define        DMA_ADDR_INVALID        (~(dma_addr_t)0)
58844  #define        EP_DONTUSE              13      /* nonzero */
58845 @@ -448,7 +450,7 @@
58846         struct net2280_ep       *ep;
58847  
58848         ep = container_of (_ep, struct net2280_ep, ep);
58849 -       if (!_ep || (!ep->desc && ep->num != 0))
58850 +       if (!_ep)
58851                 return 0;
58852  
58853         *dma = DMA_ADDR_INVALID;
58854 @@ -1344,11 +1346,12 @@
58855                 s = "(none)";
58856  
58857         /* Main Control Registers */
58858 -       t = snprintf (next, size, "%s " DRIVER_VERSION "\n"
58859 +       t = snprintf (next, size, "%s version " DRIVER_VERSION
58860 +                       ", chiprev %04x\n"
58861                         "devinit %03x fifoctl %08x gadget '%s'\n"
58862                         "pci irqenb0 %02x irqenb1 %08x "
58863                         "irqstat0 %04x irqstat1 %08x\n",
58864 -                       driver_name,
58865 +                       driver_name, dev->chiprev,
58866                         readl (&dev->regs->devinit),
58867                         readl (&dev->regs->fifoctl),
58868                         s,
58869 @@ -1393,16 +1396,33 @@
58870                         continue;
58871  
58872                 t1 = readl (&ep->regs->ep_cfg);
58873 +               t2 = readl (&ep->regs->ep_rsp) & 0xff;
58874                 t = snprintf (next, size,
58875 -                               "%s\tcfg %05x rsp %02x enb %02x ",
58876 -                               ep->ep.name, t1,
58877 -                               readl (&ep->regs->ep_rsp) & 0xff,
58878 +                               "%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
58879 +                                       "irqenb %02x\n",
58880 +                               ep->ep.name, t1, t2,
58881 +                               (t2 & (1 << CLEAR_NAK_OUT_PACKETS))
58882 +                                       ? "NAK " : "",
58883 +                               (t2 & (1 << CLEAR_EP_HIDE_STATUS_PHASE))
58884 +                                       ? "hide " : "",
58885 +                               (t2 & (1 << CLEAR_EP_FORCE_CRC_ERROR))
58886 +                                       ? "CRC " : "",
58887 +                               (t2 & (1 << CLEAR_INTERRUPT_MODE))
58888 +                                       ? "interrupt " : "",
58889 +                               (t2 & (1<<CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE))
58890 +                                       ? "status " : "",
58891 +                               (t2 & (1 << CLEAR_NAK_OUT_PACKETS_MODE))
58892 +                                       ? "NAKmode " : "",
58893 +                               (t2 & (1 << CLEAR_ENDPOINT_TOGGLE))
58894 +                                       ? "DATA1 " : "DATA0 ",
58895 +                               (t2 & (1 << CLEAR_ENDPOINT_HALT))
58896 +                                       ? "HALT " : "",
58897                                 readl (&ep->regs->ep_irqenb));
58898                 size -= t;
58899                 next += t;
58900  
58901                 t = snprintf (next, size,
58902 -                               "stat %08x avail %04x "
58903 +                               "\tstat %08x avail %04x "
58904                                 "(ep%d%s-%s)%s\n",
58905                                 readl (&ep->regs->ep_stat),
58906                                 readl (&ep->regs->ep_avail),
58907 @@ -1796,6 +1816,7 @@
58908                 dev->ep [i].irqs = 0;
58909  
58910         /* hook up the driver ... */
58911 +       driver->driver.bus = 0;
58912         dev->driver = driver;
58913         dev->gadget.dev.driver = &driver->driver;
58914         retval = driver->bind (&dev->gadget);
58915 @@ -1807,10 +1828,6 @@
58916                 return retval;
58917         }
58918  
58919 -       // FIXME
58920 -       // driver_register (&driver->driver);
58921 -       // device_register (&dev->gadget.dev);
58922 -
58923         device_create_file (&dev->pdev->dev, &dev_attr_function);
58924         device_create_file (&dev->pdev->dev, &dev_attr_queues);
58925  
58926 @@ -1877,10 +1894,6 @@
58927         device_remove_file (&dev->pdev->dev, &dev_attr_function);
58928         device_remove_file (&dev->pdev->dev, &dev_attr_queues);
58929  
58930 -       // FIXME
58931 -       // device_unregister()
58932 -       // driver_unregister (&driver->driver);
58933 -
58934         DEBUG (dev, "unregistered driver '%s'\n", driver->driver.name);
58935         return 0;
58936  }
58937 @@ -2049,9 +2062,9 @@
58938  
58939                 /* maybe advance queue to next request */
58940                 if (ep->num == 0) {
58941 -                       /* FIXME need mechanism (request flag?) so control OUT
58942 -                        * can decide to stall ep0 after that done() returns,
58943 -                        * from non-irq context
58944 +                       /* NOTE:  net2280 could let gadget driver start the
58945 +                        * status stage later. since not all controllers let
58946 +                        * them control that, the api doesn't (yet) allow it.
58947                          */
58948                         if (!ep->stopped)
58949                                 allow_status (ep);
58950 @@ -2174,6 +2187,8 @@
58951  
58952                 /* watch control traffic at the token level, and force
58953                  * synchronization before letting the status stage happen.
58954 +                * FIXME ignore tokens we'll NAK, until driver responds.
58955 +                * that'll mean a lot less irqs for some drivers.
58956                  */
58957                 ep->is_in = (u.r.bRequestType & USB_DIR_IN) != 0;
58958                 if (ep->is_in)
58959 @@ -2417,6 +2432,28 @@
58960                         if ((tmp & (1 << DMA_SCATTER_GATHER_ENABLE)) == 0
58961                                         || (tmp & (1 << DMA_ENABLE)) == 0)
58962                                 restart_dma (ep);
58963 +#ifdef USE_DMA_CHAINING
58964 +                       else if (ep->desc->bEndpointAddress & USB_DIR_IN) {
58965 +                               struct net2280_request  *req;
58966 +                               u32                     dmacount;
58967 +
58968 +                               /* the descriptor at the head of the chain
58969 +                                * may still have VALID_BIT clear; that's
58970 +                                * used to trigger changing DMA_FIFO_VALIDATE
58971 +                                * (affects automagic zlp writes).
58972 +                                */
58973 +                               req = list_entry (ep->queue.next,
58974 +                                               struct net2280_request, queue);
58975 +                               dmacount = req->td->dmacount;
58976 +                               dmacount &= __constant_cpu_to_le32 (
58977 +                                               (1 << VALID_BIT)
58978 +                                               | DMA_BYTE_COUNT_MASK);
58979 +                               if (dmacount && (dmacount & valid_bit) == 0) {
58980 +                                       stop_dma (ep->dma);
58981 +                                       restart_dma (ep);
58982 +                               }
58983 +                       }
58984 +#endif
58985                 }
58986                 ep->irqs++;
58987         }
58988 @@ -2458,6 +2495,13 @@
58989  
58990  /*-------------------------------------------------------------------------*/
58991  
58992 +static void gadget_release (struct device *_dev)
58993 +{
58994 +       struct net2280  *dev = dev_get_drvdata (_dev);
58995 +
58996 +       kfree (dev);
58997 +}
58998 +
58999  /* tear down the binding between this driver and the pci device */
59000  
59001  static void net2280_remove (struct pci_dev *pdev)
59002 @@ -2493,12 +2537,12 @@
59003                                 pci_resource_len (pdev, 0));
59004         if (dev->enabled)
59005                 pci_disable_device (pdev);
59006 +       device_unregister (&dev->gadget.dev);
59007         device_remove_file (&pdev->dev, &dev_attr_registers);
59008         pci_set_drvdata (pdev, 0);
59009  
59010 -       INFO (dev, "unbind from pci %s\n", pci_name(pdev));
59011 +       INFO (dev, "unbind\n");
59012  
59013 -       kfree (dev);
59014         the_controller = 0;
59015  }
59016  
59017 @@ -2518,7 +2562,7 @@
59018          * usb_gadget_driver_{register,unregister}() must change.
59019          */
59020         if (the_controller) {
59021 -               WARN (the_controller, "ignoring %s\n", pci_name(pdev));
59022 +               dev_warn (&pdev->dev, "ignoring\n");
59023                 return -EBUSY;
59024         }
59025  
59026 @@ -2534,9 +2578,11 @@
59027         dev->pdev = pdev;
59028         dev->gadget.ops = &net2280_ops;
59029  
59030 -       strcpy (dev->gadget.dev.bus_id, pci_name(pdev));
59031 +       /* the "gadget" abstracts/virtualizes the controller */
59032 +       strcpy (dev->gadget.dev.bus_id, "gadget");
59033         dev->gadget.dev.parent = &pdev->dev;
59034         dev->gadget.dev.dma_mask = pdev->dev.dma_mask;
59035 +       dev->gadget.dev.release = gadget_release;
59036         dev->gadget.name = driver_name;
59037  
59038         /* now all the pci goodies ... */
59039 @@ -2650,6 +2696,7 @@
59040         INFO (dev, "version: %s\n", bufp);
59041         the_controller = dev;
59042  
59043 +       device_register (&dev->gadget.dev);
59044         device_create_file (&pdev->dev, &dev_attr_registers);
59045  
59046         return 0;
59047 diff -Nru a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
59048 --- a/drivers/usb/gadget/net2280.h      Mon Jul 14 09:07:22 2003
59049 +++ b/drivers/usb/gadget/net2280.h      Wed Aug 27 10:30:35 2003
59050 @@ -389,6 +389,7 @@
59051         u32             ep_rsp;
59052  #define     SET_NAK_OUT_PACKETS                                 15
59053  #define     SET_EP_HIDE_STATUS_PHASE                            14
59054 +#define     SET_EP_FORCE_CRC_ERROR                              13
59055  #define     SET_INTERRUPT_MODE                                  12
59056  #define     SET_CONTROL_STATUS_PHASE_HANDSHAKE                  11
59057  #define     SET_NAK_OUT_PACKETS_MODE                            10
59058 @@ -396,6 +397,7 @@
59059  #define     SET_ENDPOINT_HALT                                   8
59060  #define     CLEAR_NAK_OUT_PACKETS                               7
59061  #define     CLEAR_EP_HIDE_STATUS_PHASE                          6
59062 +#define     CLEAR_EP_FORCE_CRC_ERROR                            5
59063  #define     CLEAR_INTERRUPT_MODE                                4
59064  #define     CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE                3
59065  #define     CLEAR_NAK_OUT_PACKETS_MODE                          2
59066 @@ -476,6 +478,9 @@
59067  #define REG_CHIPREV            0x03    /* in bcd */
59068  #define        REG_HS_NAK_RATE         0x0a    /* NAK per N uframes */
59069  
59070 +#define        CHIPREV_1       0x0100
59071 +#define        CHIPREV_1A      0x0110
59072 +
59073  #ifdef __KERNEL__
59074  
59075  /* ep a-f highspeed and fullspeed maxpacket, addresses
59076 @@ -529,24 +534,6 @@
59077         ep->stopped = 1;
59078  }
59079  
59080 -static inline void set_halt (struct net2280_ep *ep)
59081 -{
59082 -       /* ep0 and bulk/intr endpoints */
59083 -       writel (  (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
59084 -                   /* set NAK_OUT for erratum 0114 */
59085 -               | (1 << SET_NAK_OUT_PACKETS)
59086 -               | (1 << SET_ENDPOINT_HALT)
59087 -               , &ep->regs->ep_rsp);
59088 -}
59089 -
59090 -static inline void clear_halt (struct net2280_ep *ep)
59091 -{
59092 -       /* bulk/intr endpoints */
59093 -       writel (  (1 << CLEAR_ENDPOINT_HALT)
59094 -               | (1 << CLEAR_ENDPOINT_TOGGLE)
59095 -               , &ep->regs->ep_rsp);
59096 -}
59097 -
59098  /* count (<= 4) bytes in the next fifo write will be valid */
59099  static inline void set_fifo_bytecount (struct net2280_ep *ep, unsigned count)
59100  {
59101 @@ -588,6 +575,28 @@
59102         struct pci_pool                 *requests;
59103         // statistics...
59104  };
59105 +
59106 +static inline void set_halt (struct net2280_ep *ep)
59107 +{
59108 +       /* ep0 and bulk/intr endpoints */
59109 +       writel (  (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
59110 +                   /* set NAK_OUT for erratum 0114 */
59111 +               | ((ep->dev->chiprev == CHIPREV_1) << SET_NAK_OUT_PACKETS)
59112 +               | (1 << SET_ENDPOINT_HALT)
59113 +               , &ep->regs->ep_rsp);
59114 +}
59115 +
59116 +static inline void clear_halt (struct net2280_ep *ep)
59117 +{
59118 +       /* ep0 and bulk/intr endpoints */
59119 +       writel (  (1 << CLEAR_ENDPOINT_HALT)
59120 +               | (1 << CLEAR_ENDPOINT_TOGGLE)
59121 +                   /* unless the gadget driver left a short packet in the
59122 +                    * fifo, this reverses the erratum 0114 workaround.
59123 +                    */
59124 +               | ((ep->dev->chiprev == CHIPREV_1) << CLEAR_NAK_OUT_PACKETS)
59125 +               , &ep->regs->ep_rsp);
59126 +}
59127  
59128  #ifdef USE_RDK_LEDS
59129  
59130 diff -Nru a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
59131 --- a/drivers/usb/host/ehci-hcd.c       Thu Jul 31 07:25:14 2003
59132 +++ b/drivers/usb/host/ehci-hcd.c       Fri Aug 29 11:21:44 2003
59133 @@ -41,7 +41,6 @@
59134  #include <linux/usb.h>
59135  #include <linux/moduleparam.h>
59136  
59137 -#include <linux/version.h>
59138  #include "../core/hcd.h"
59139  
59140  #include <asm/byteorder.h>
59141 @@ -232,7 +231,6 @@
59142                 ehci->hcd.state = USB_STATE_HALT;
59143                 return;
59144         }
59145 -       ehci->hcd.state = USB_STATE_READY;
59146  }
59147  
59148  /*-------------------------------------------------------------------------*/
59149 @@ -482,7 +480,7 @@
59150         ehci->reboot_notifier.notifier_call = ehci_reboot;
59151         register_reboot_notifier (&ehci->reboot_notifier);
59152  
59153 -       ehci->hcd.state = USB_STATE_READY;
59154 +       ehci->hcd.state = USB_STATE_RUNNING;
59155         writel (FLAG_CF, &ehci->regs->configured_flag);
59156         readl (&ehci->regs->command);   /* unblock posted write */
59157  
59158 @@ -626,7 +624,7 @@
59159         /* resume HC and each port */
59160  // restore pci FLADJ value
59161         // khubd and drivers will set HC running, if needed;
59162 -       hcd->state = USB_STATE_READY;
59163 +       hcd->state = USB_STATE_RUNNING;
59164         // FIXME Philips/Intel/... etc don't really have a "READY"
59165         // state ... turn on CMD_RUN too
59166         for (i = 0; i < ports; i++) {
59167 @@ -979,21 +977,12 @@
59168  /* EHCI spec says PCI is required. */
59169  
59170  /* PCI driver selection metadata; PCI hotplugging uses this */
59171 -static struct pci_device_id pci_ids [] = { {
59172 -
59173 +static const struct pci_device_id pci_ids [] = { {
59174         /* handle any USB 2.0 EHCI controller */
59175 -
59176 -       .class =                ((PCI_CLASS_SERIAL_USB << 8) | 0x20),
59177 -       .class_mask =   ~0,
59178 +       PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0),
59179         .driver_data =  (unsigned long) &ehci_driver,
59180 -
59181 -       /* no matter who makes it */
59182 -       .vendor =       PCI_ANY_ID,
59183 -       .device =       PCI_ANY_ID,
59184 -       .subvendor =    PCI_ANY_ID,
59185 -       .subdevice =    PCI_ANY_ID,
59186 -
59187 -}, { /* end: all zeroes */ }
59188 +       },
59189 +       { /* end: all zeroes */ }
59190  };
59191  MODULE_DEVICE_TABLE (pci, pci_ids);
59192  
59193 diff -Nru a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
59194 --- a/drivers/usb/host/ohci-hcd.c       Thu Jul 31 13:51:23 2003
59195 +++ b/drivers/usb/host/ohci-hcd.c       Fri Aug 29 11:23:08 2003
59196 @@ -529,7 +529,7 @@
59197         /* connect the virtual root hub */
59198         bus = hcd_to_bus (&ohci->hcd);
59199         bus->root_hub = udev = usb_alloc_dev (NULL, bus);
59200 -       ohci->hcd.state = USB_STATE_READY;
59201 +       ohci->hcd.state = USB_STATE_RUNNING;
59202         if (!udev) {
59203                 disable (ohci);
59204                 ohci->hc_control &= ~OHCI_CTRL_HCFS;
59205 diff -Nru a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
59206 --- a/drivers/usb/host/ohci-pci.c       Thu Jul 31 14:36:49 2003
59207 +++ b/drivers/usb/host/ohci-pci.c       Fri Aug 29 11:24:51 2003
59208 @@ -30,6 +30,15 @@
59209  
59210  /*-------------------------------------------------------------------------*/
59211  
59212 +static int
59213 +ohci_pci_reset (struct usb_hcd *hcd)
59214 +{
59215 +       struct ohci_hcd *ohci = hcd_to_ohci (hcd);
59216 +
59217 +       ohci->regs = hcd->regs;
59218 +       return hc_reset (ohci);
59219 +}
59220 +
59221  static int __devinit
59222  ohci_pci_start (struct usb_hcd *hcd)
59223  {
59224 @@ -89,12 +98,6 @@
59225                 ohci_stop (hcd);
59226                 return ret;
59227         }
59228 -       ohci->regs = hcd->regs;
59229 -
59230 -       if (hc_reset (ohci) < 0) {
59231 -               ohci_stop (hcd);
59232 -               return -ENODEV;
59233 -       }
59234  
59235         if (hc_start (ohci) < 0) {
59236                 ohci_err (ohci, "can't start\n");
59237 @@ -264,7 +267,7 @@
59238                         if (ohci->ed_bulktail)
59239                                 ohci->hc_control |= OHCI_CTRL_BLE;
59240                 }
59241 -               hcd->state = USB_STATE_READY;
59242 +               hcd->state = USB_STATE_RUNNING;
59243                 writel (ohci->hc_control, &ohci->regs->control);
59244  
59245                 /* trigger a start-frame interrupt (why?) */
59246 @@ -315,6 +318,7 @@
59247         /*
59248          * basic lifecycle operations
59249          */
59250 +       .reset =                ohci_pci_reset,
59251         .start =                ohci_pci_start,
59252  #ifdef CONFIG_PM
59253         .suspend =              ohci_pci_suspend,
59254 @@ -351,18 +355,9 @@
59255  
59256  
59257  static const struct pci_device_id pci_ids [] = { {
59258 -
59259         /* handle any USB OHCI controller */
59260 -       .class =        (PCI_CLASS_SERIAL_USB << 8) | 0x10,
59261 -       .class_mask =   ~0,
59262 +       PCI_DEVICE_CLASS((PCI_CLASS_SERIAL_USB << 8) | 0x10, ~0),
59263         .driver_data =  (unsigned long) &ohci_pci_hc_driver,
59264 -
59265 -       /* no matter who makes it */
59266 -       .vendor =       PCI_ANY_ID,
59267 -       .device =       PCI_ANY_ID,
59268 -       .subvendor =    PCI_ANY_ID,
59269 -       .subdevice =    PCI_ANY_ID,
59270 -
59271         }, { /* end: all zeroes */ }
59272  };
59273  MODULE_DEVICE_TABLE (pci, pci_ids);
59274 diff -Nru a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
59275 --- a/drivers/usb/host/ohci-q.c Mon Jul 14 11:27:33 2003
59276 +++ b/drivers/usb/host/ohci-q.c Wed Aug 27 10:29:59 2003
59277 @@ -1013,10 +1013,22 @@
59278                 if (list_empty (&ed->td_list))
59279                         ed_deschedule (ohci, ed);
59280                 /* ... reenabling halted EDs only after fault cleanup */
59281 -               else if (!(ed->hwINFO & ED_DEQUEUE)) {
59282 +               else if ((ed->hwINFO & (ED_SKIP | ED_DEQUEUE)) == ED_SKIP) {
59283                         td = list_entry (ed->td_list.next, struct td, td_list);
59284 -                       if (!(td->hwINFO & TD_DONE))
59285 +                       if (!(td->hwINFO & TD_DONE)) {
59286                                 ed->hwINFO &= ~ED_SKIP;
59287 +                               /* ... hc may need waking-up */
59288 +                               switch (ed->type) {
59289 +                               case PIPE_CONTROL:
59290 +                                       writel (OHCI_CLF,
59291 +                                               &ohci->regs->cmdstatus);   
59292 +                                       break;
59293 +                               case PIPE_BULK:
59294 +                                       writel (OHCI_BLF,
59295 +                                               &ohci->regs->cmdstatus);   
59296 +                                       break;
59297 +                               }
59298 +                       }
59299                 }
59300  
59301                 td = td_next;
59302 diff -Nru a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
59303 --- a/drivers/usb/host/ohci-sa1111.c    Thu Jul 31 13:51:23 2003
59304 +++ b/drivers/usb/host/ohci-sa1111.c    Sun Aug 24 07:45:05 2003
59305 @@ -352,9 +352,8 @@
59306  
59307  /*-------------------------------------------------------------------------*/
59308  
59309 -static int ohci_hcd_sa1111_drv_probe(struct device *_dev)
59310 +static int ohci_hcd_sa1111_drv_probe(struct sa1111_dev *dev)
59311  {
59312 -       struct sa1111_dev *dev = SA1111_DEV(_dev);
59313         struct usb_hcd *hcd = NULL;
59314         int ret;
59315  
59316 @@ -364,43 +363,29 @@
59317         ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, &hcd, dev);
59318  
59319         if (ret == 0)
59320 -               dev->dev.driver_data = hcd;
59321 +               sa1111_set_drvdata(dev, hcd);
59322  
59323         return ret;
59324  }
59325  
59326 -static int ohci_hcd_sa1111_drv_remove(struct device *_dev)
59327 +static int ohci_hcd_sa1111_drv_remove(struct sa1111_dev *dev)
59328  {
59329 -       struct sa1111_dev *dev = SA1111_DEV(_dev);
59330 -       struct usb_hcd *hcd = dev->dev.driver_data;
59331 +       struct usb_hcd *hcd = sa1111_get_drvdata(dev);
59332  
59333         usb_hcd_sa1111_remove(hcd, dev);
59334  
59335 -       dev->dev.driver_data = NULL;
59336 +       sa1111_set_drvdata(dev, NULL);
59337  
59338         return 0;
59339  }
59340  
59341 -static int ohci_hcd_sa1111_drv_suspend(struct device *dev, u32 state, u32 level)
59342 -{
59343 -       return 0;
59344 -}
59345 -
59346 -static int ohci_hcd_sa1111_drv_resume(struct device *dev, u32 level)
59347 -{
59348 -       return 0;
59349 -}
59350 -
59351  static struct sa1111_driver ohci_hcd_sa1111_driver = {
59352         .drv = {
59353 -               .name           = "sa1111-ohci",
59354 -               .bus            = &sa1111_bus_type,
59355 -               .probe          = ohci_hcd_sa1111_drv_probe,
59356 -               .remove         = ohci_hcd_sa1111_drv_remove,
59357 -               .suspend        = ohci_hcd_sa1111_drv_suspend,
59358 -               .resume         = ohci_hcd_sa1111_drv_resume,
59359 +               .name   = "sa1111-ohci",
59360         },
59361 -       .devid                  = SA1111_DEVID_USB,
59362 +       .devid          = SA1111_DEVID_USB,
59363 +       .probe          = ohci_hcd_sa1111_drv_probe,
59364 +       .remove         = ohci_hcd_sa1111_drv_remove,
59365  };
59366  
59367  static int __init ohci_hcd_sa1111_init (void)
59368 @@ -409,12 +394,12 @@
59369         dbg ("block sizes: ed %d td %d",
59370                 sizeof (struct ed), sizeof (struct td));
59371  
59372 -       return driver_register(&ohci_hcd_sa1111_driver.drv);
59373 +       return sa1111_driver_register(&ohci_hcd_sa1111_driver);
59374  }
59375  
59376  static void __exit ohci_hcd_sa1111_cleanup (void)
59377  {
59378 -       driver_unregister(&ohci_hcd_sa1111_driver.drv);
59379 +       sa1111_driver_unregister(&ohci_hcd_sa1111_driver);
59380  }
59381  
59382  module_init (ohci_hcd_sa1111_init);
59383 diff -Nru a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
59384 --- a/drivers/usb/host/uhci-hcd.c       Wed Aug  6 04:52:20 2003
59385 +++ b/drivers/usb/host/uhci-hcd.c       Fri Aug 29 11:29:09 2003
59386 @@ -2099,7 +2099,7 @@
59387         uhci->state_end = jiffies + HZ;
59388         outw(USBCMD_RS | USBCMD_CF | USBCMD_MAXP, io_addr + USBCMD);
59389  
59390 -        uhci->hcd.state = USB_STATE_READY;
59391 +        uhci->hcd.state = USB_STATE_RUNNING;
59392  }
59393  
59394  /*
59395 @@ -2143,6 +2143,20 @@
59396  #endif
59397  }
59398  
59399 +static int uhci_reset(struct usb_hcd *hcd)
59400 +{
59401 +       struct uhci_hcd *uhci = hcd_to_uhci(hcd);
59402 +
59403 +       uhci->io_addr = (unsigned long) hcd->regs;
59404 +
59405 +       /* Maybe kick BIOS off this hardware.  Then reset, so we won't get
59406 +        * interrupts from any previous setup.
59407 +        */
59408 +       pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
59409 +       reset_hc(uhci);
59410 +       return 0;
59411 +}
59412 +
59413  /*
59414   * Allocate a frame list, and then setup the skeleton
59415   *
59416 @@ -2159,7 +2173,7 @@
59417   *  - The fourth queue is the bandwidth reclamation queue, which loops back
59418   *    to the high speed control queue.
59419   */
59420 -static int __devinit uhci_start(struct usb_hcd *hcd)
59421 +static int uhci_start(struct usb_hcd *hcd)
59422  {
59423         struct uhci_hcd *uhci = hcd_to_uhci(hcd);
59424         int retval = -EBUSY;
59425 @@ -2171,7 +2185,6 @@
59426         struct proc_dir_entry *ent;
59427  #endif
59428  
59429 -       uhci->io_addr = (unsigned long) hcd->regs;
59430         io_size = pci_resource_len(hcd->pdev, hcd->region);
59431  
59432  #ifdef CONFIG_PROC_FS
59433 @@ -2188,10 +2201,6 @@
59434         uhci->proc_entry = ent;
59435  #endif
59436  
59437 -       /* Reset here so we don't get any interrupts from an old setup */
59438 -       /*  or broken setup */
59439 -       reset_hc(uhci);
59440 -
59441         uhci->fsbr = 0;
59442         uhci->fsbrtimeout = 0;
59443  
59444 @@ -2343,9 +2352,6 @@
59445  
59446         init_stall_timer(hcd);
59447  
59448 -       /* disable legacy emulation */
59449 -       pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
59450 -
59451         udev->speed = USB_SPEED_FULL;
59452  
59453         if (usb_register_root_hub(udev, &hcd->pdev->dev) != 0) {
59454 @@ -2446,7 +2452,7 @@
59455                 reset_hc(uhci);
59456                 start_hc(uhci);
59457         }
59458 -       uhci->hcd.state = USB_STATE_READY;
59459 +       uhci->hcd.state = USB_STATE_RUNNING;
59460         return 0;
59461  }
59462  #endif
59463 @@ -2484,6 +2490,7 @@
59464         .flags =                HCD_USB11,
59465  
59466         /* Basic lifecycle operations */
59467 +       .reset =                uhci_reset,
59468         .start =                uhci_start,
59469  #ifdef CONFIG_PM
59470         .suspend =              uhci_suspend,
59471 @@ -2504,18 +2511,9 @@
59472  };
59473  
59474  static const struct pci_device_id uhci_pci_ids[] = { {
59475 -
59476         /* handle any USB UHCI controller */
59477 -       .class =                ((PCI_CLASS_SERIAL_USB << 8) | 0x00),
59478 -       .class_mask =   ~0,
59479 +       PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x00), ~0),
59480         .driver_data =  (unsigned long) &uhci_driver,
59481 -
59482 -       /* no matter who makes it */
59483 -       .vendor =       PCI_ANY_ID,
59484 -       .device =       PCI_ANY_ID,
59485 -       .subvendor =    PCI_ANY_ID,
59486 -       .subdevice =    PCI_ANY_ID,
59487 -
59488         }, { /* end: all zeroes */ }
59489  };
59490  
59491 diff -Nru a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
59492 --- a/drivers/usb/image/mdc800.c        Wed Jun 11 20:02:46 2003
59493 +++ b/drivers/usb/image/mdc800.c        Wed Aug 27 03:46:31 2003
59494 @@ -977,8 +977,9 @@
59495  #define try_free_mem(A)  if (A != 0) { kfree (A); A=0; }
59496  #define try_free_urb(A)  if (A != 0) { usb_free_urb (A); A=0; }
59497  
59498 -int __init usb_mdc800_init (void)
59499 +static int __init usb_mdc800_init (void)
59500  {
59501 +       int retval = -ENODEV;
59502         /* Allocate Memory */
59503         try (mdc800=kmalloc (sizeof (struct mdc800_data), GFP_KERNEL));
59504  
59505 @@ -1005,7 +1006,8 @@
59506         try (mdc800->write_urb=usb_alloc_urb (0, GFP_KERNEL));
59507  
59508         /* Register the driver */
59509 -       if (usb_register (&mdc800_usb_driver) < 0)
59510 +       retval = usb_register(&mdc800_usb_driver);
59511 +       if (retval)
59512                 goto cleanup_on_fail;
59513  
59514         info (DRIVER_VERSION ":" DRIVER_DESC);
59515 @@ -1031,11 +1033,11 @@
59516                 kfree (mdc800);
59517         }
59518         mdc800=0;
59519 -       return -1;
59520 +       return retval;
59521  }
59522  
59523  
59524 -void __exit usb_mdc800_cleanup (void)
59525 +static void __exit usb_mdc800_cleanup (void)
59526  {
59527         usb_deregister (&mdc800_usb_driver);
59528  
59529 diff -Nru a/drivers/usb/image/scanner.h b/drivers/usb/image/scanner.h
59530 --- a/drivers/usb/image/scanner.h       Tue Jul 15 02:37:52 2003
59531 +++ b/drivers/usb/image/scanner.h       Tue Aug 26 09:25:41 2003
59532 @@ -313,7 +313,7 @@
59533  #define IS_EP_BULK_OUT(ep) (IS_EP_BULK(ep) && ((ep)->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT)
59534  #define IS_EP_INTR(ep) ((ep)->bmAttributes == USB_ENDPOINT_XFER_INT ? 1 : 0)
59535  
59536 -#define USB_SCN_MINOR(X) minor((X)->i_rdev)
59537 +#define USB_SCN_MINOR(X) iminor(X)
59538  
59539  #ifdef DEBUG
59540  #define SCN_DEBUG(X) X
59541 diff -Nru a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
59542 --- a/drivers/usb/input/hid-core.c      Sat Jun 21 04:45:12 2003
59543 +++ b/drivers/usb/input/hid-core.c      Tue Aug 26 17:19:45 2003
59544 @@ -1328,6 +1328,7 @@
59545  #define USB_DEVICE_ID_ATEN_CS124U      0x2202
59546  #define USB_DEVICE_ID_ATEN_2PORTKVM    0x2204
59547  #define USB_DEVICE_ID_ATEN_4PORTKVM    0x2205
59548 +#define USB_DEVICE_ID_ATEN_4PORTKVMC   0x2208
59549  
59550  #define USB_VENDOR_ID_TOPMAX           0x0663
59551  #define USB_DEVICE_ID_TOPMAX_COBRAPAD  0x0103
59552 @@ -1386,6 +1387,7 @@
59553         { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
59554         { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
59555         { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
59556 +       { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
59557         { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_HIDDEV },
59558         { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_HIDDEV },
59559         { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
59560 @@ -1691,11 +1693,20 @@
59561  
59562  static int __init hid_init(void)
59563  {
59564 -       hiddev_init();
59565 -       usb_register(&hid_driver);
59566 +       int retval;
59567 +       retval = hiddev_init();
59568 +       if (retval)
59569 +               goto hiddev_init_fail;
59570 +       retval = usb_register(&hid_driver);
59571 +       if (retval)
59572 +               goto usb_register_fail;
59573         info(DRIVER_VERSION ":" DRIVER_DESC);
59574  
59575         return 0;
59576 +usb_register_fail:
59577 +       hiddev_exit();
59578 +hiddev_init_fail:
59579 +       return retval;
59580  }
59581  
59582  static void __exit hid_exit(void)
59583 diff -Nru a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
59584 --- a/drivers/usb/input/hiddev.c        Wed Jun 11 07:58:27 2003
59585 +++ b/drivers/usb/input/hiddev.c        Tue Sep  2 11:40:28 2003
59586 @@ -271,7 +271,7 @@
59587  static int hiddev_open(struct inode * inode, struct file * file) {
59588         struct hiddev_list *list;
59589  
59590 -       int i = minor(inode->i_rdev) - HIDDEV_MINOR_BASE;
59591 +       int i = iminor(inode) - HIDDEV_MINOR_BASE;
59592  
59593         if (i >= HIDDEV_MINORS || !hiddev_table[i])
59594                 return -ENODEV;
59595 @@ -795,8 +795,7 @@
59596  int __init hiddev_init(void)
59597  {
59598         devfs_mk_dir("usb/hid");
59599 -       usb_register(&hiddev_driver);
59600 -       return 0;
59601 +       return usb_register(&hiddev_driver);
59602  }
59603  
59604  void __exit hiddev_exit(void)
59605 diff -Nru a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
59606 --- a/drivers/usb/input/kbtab.c Thu Jun 12 07:28:01 2003
59607 +++ b/drivers/usb/input/kbtab.c Sat Aug 23 07:09:53 2003
59608 @@ -216,9 +216,13 @@
59609  
59610  static int __init kbtab_init(void)
59611  {
59612 -       usb_register(&kbtab_driver);
59613 +       int retval;
59614 +       retval = usb_register(&kbtab_driver);
59615 +       if (retval)
59616 +               goto out;
59617         info(DRIVER_VERSION ":" DRIVER_DESC);
59618 -       return 0;
59619 +out:
59620 +       return retval;
59621  }
59622  
59623  static void __exit kbtab_exit(void)
59624 diff -Nru a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
59625 --- a/drivers/usb/input/powermate.c     Thu Jun 12 07:28:01 2003
59626 +++ b/drivers/usb/input/powermate.c     Sat Aug 23 07:11:02 2003
59627 @@ -433,14 +433,12 @@
59628          .id_table =     powermate_devices,
59629  };
59630  
59631 -int powermate_init(void)
59632 +static int __init powermate_init(void)
59633  {
59634 -       if (usb_register(&powermate_driver) < 0)
59635 -               return -1;
59636 -       return 0;
59637 +       return usb_register(&powermate_driver);
59638  }
59639  
59640 -void powermate_cleanup(void)
59641 +static void __exit powermate_cleanup(void)
59642  {
59643         usb_deregister(&powermate_driver);
59644  }
59645 diff -Nru a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c
59646 --- a/drivers/usb/media/dabusb.c        Mon Aug 11 07:56:25 2003
59647 +++ b/drivers/usb/media/dabusb.c        Tue Sep  2 11:40:28 2003
59648 @@ -29,7 +29,6 @@
59649  
59650  #include <linux/module.h>
59651  #include <linux/socket.h>
59652 -#include <linux/miscdevice.h>
59653  #include <linux/list.h>
59654  #include <linux/vmalloc.h>
59655  #include <linux/slab.h>
59656 @@ -583,7 +582,7 @@
59657  
59658  static int dabusb_open (struct inode *inode, struct file *file)
59659  {
59660 -       int devnum = minor (inode->i_rdev);
59661 +       int devnum = iminor(inode);
59662         pdabusb_t s;
59663  
59664         if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB))
59665 @@ -819,6 +818,7 @@
59666  
59667  static int __init dabusb_init (void)
59668  {
59669 +       int retval;
59670         unsigned u;
59671  
59672         /* initialize struct */
59673 @@ -836,14 +836,16 @@
59674         }
59675  
59676         /* register misc device */
59677 -       if (usb_register(&dabusb_driver))
59678 -               return -1;
59679 +       retval = usb_register(&dabusb_driver);
59680 +       if (retval)
59681 +               goto out;
59682  
59683         dbg("dabusb_init: driver registered");
59684  
59685         info(DRIVER_VERSION ":" DRIVER_DESC);
59686  
59687 -       return 0;
59688 +out:
59689 +       return retval;
59690  }
59691  
59692  static void __exit dabusb_cleanup (void)
59693 diff -Nru a/drivers/usb/media/dsbr100.c b/drivers/usb/media/dsbr100.c
59694 --- a/drivers/usb/media/dsbr100.c       Thu May 29 13:20:21 2003
59695 +++ b/drivers/usb/media/dsbr100.c       Sat Aug 23 07:19:42 2003
59696 @@ -354,15 +354,23 @@
59697  
59698  static int __init dsbr100_init(void)
59699  {
59700 +       int retval;
59701         usb_dsbr100_radio.priv = NULL;
59702 -       usb_register(&usb_dsbr100_driver);
59703 -       if (video_register_device(&usb_dsbr100_radio, VFL_TYPE_RADIO,
59704 -               radio_nr)==-1) {        
59705 +       retval = usb_register(&usb_dsbr100_driver);
59706 +       if (retval)
59707 +               goto failed_usb_register;
59708 +       retval = video_register_device(&usb_dsbr100_radio, VFL_TYPE_RADIO,
59709 +                                      radio_nr);
59710 +       if (retval) {   
59711                 warn("Couldn't register video device");
59712 -               return -EINVAL;
59713 +               goto failed_video_register;
59714         }
59715         info(DRIVER_VERSION ":" DRIVER_DESC);
59716         return 0;
59717 +failed_video_register:
59718 +       usb_deregister(&usb_dsbr100_driver);
59719 +failed_usb_register:
59720 +       return retval;
59721  }
59722  
59723  static void __exit dsbr100_exit(void)
59724 diff -Nru a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
59725 --- a/drivers/usb/media/ov511.c Tue Aug 12 23:54:33 2003
59726 +++ b/drivers/usb/media/ov511.c Wed Aug 27 05:44:53 2003
59727 @@ -4592,7 +4592,7 @@
59728         return rc;
59729  }
59730  
59731 -static int
59732 +static ssize_t
59733  ov51x_v4l1_read(struct file *file, char *buf, size_t cnt, loff_t *ppos)
59734  {
59735         struct video_device *vdev = file->private_data;
59736 @@ -6115,13 +6115,16 @@
59737  static int __init
59738  usb_ov511_init(void)
59739  {
59740 +       int retval;
59741  
59742 -       if (usb_register(&ov511_driver) < 0)
59743 -               return -1;
59744 +       retval = usb_register(&ov511_driver);
59745 +       if (retval)
59746 +               goto out;
59747  
59748         info(DRIVER_VERSION " : " DRIVER_DESC);
59749  
59750 -       return 0;
59751 +out:
59752 +       return retval;
59753  }
59754  
59755  static void __exit
59756 diff -Nru a/drivers/usb/media/pwc-if.c b/drivers/usb/media/pwc-if.c
59757 --- a/drivers/usb/media/pwc-if.c        Sat Jul 26 18:54:19 2003
59758 +++ b/drivers/usb/media/pwc-if.c        Wed Aug 27 05:44:03 2003
59759 @@ -129,7 +129,7 @@
59760  
59761  static int pwc_video_open(struct inode *inode, struct file *file);
59762  static int pwc_video_close(struct inode *inode, struct file *file);
59763 -static int pwc_video_read(struct file *file, char *buf,
59764 +static ssize_t pwc_video_read(struct file *file, char *buf,
59765                           size_t count, loff_t *ppos);
59766  static unsigned int pwc_video_poll(struct file *file, poll_table *wait);
59767  static int  pwc_video_ioctl(struct inode *inode, struct file *file,
59768 @@ -1116,7 +1116,7 @@
59769                  device is tricky anyhow.
59770   */
59771  
59772 -static int pwc_video_read(struct file *file, char *buf,
59773 +static ssize_t pwc_video_read(struct file *file, char *buf,
59774                           size_t count, loff_t *ppos)
59775  {
59776         struct video_device *vdev = file->private_data;
59777 @@ -1124,7 +1124,7 @@
59778         int noblock = file->f_flags & O_NONBLOCK;
59779         DECLARE_WAITQUEUE(wait, current);
59780  
59781 -       Trace(TRACE_READ, "video_read(0x%p, %p, %d) called.\n", vdev, buf, count);
59782 +       Trace(TRACE_READ, "video_read(0x%p, %p, %Zd) called.\n", vdev, buf, count);
59783         if (vdev == NULL)
59784                 return -EFAULT;
59785         pdev = vdev->priv;
59786 diff -Nru a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c
59787 --- a/drivers/usb/media/se401.c Thu Aug 21 09:01:34 2003
59788 +++ b/drivers/usb/media/se401.c Wed Aug 27 05:45:24 2003
59789 @@ -30,16 +30,10 @@
59790  #include <linux/config.h>
59791  #include <linux/module.h>
59792  #include <linux/init.h>
59793 -#include <linux/fs.h>
59794  #include <linux/vmalloc.h>
59795  #include <linux/slab.h>
59796 -#include <linux/proc_fs.h>
59797  #include <linux/pagemap.h>
59798  #include <linux/usb.h>
59799 -#include <asm/io.h>
59800 -#include <asm/semaphore.h>
59801 -#include <linux/mm.h>
59802 -
59803  #include "se401.h"
59804  
59805  static int flickerless=0;
59806 @@ -126,131 +120,6 @@
59807  
59808  /****************************************************************************
59809   *
59810 - * /proc interface
59811 - *
59812 - ***************************************************************************/
59813 -
59814 -#warning please convert me from procfs to sysfs
59815 -#undef CONFIG_VIDEO_PROC_FS
59816 -
59817 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
59818 -
59819 -static struct proc_dir_entry *se401_proc_entry = NULL;
59820 -extern struct proc_dir_entry *video_proc_entry;
59821 -
59822 -#define YES_NO(x) ((x) ? "yes" : "no")
59823 -
59824 -static int se401_read_proc(char *page, char **start, off_t off, int count,
59825 -                          int *eof, void *data)
59826 -{
59827 -       char *out = page;
59828 -       int i, len;
59829 -       struct usb_se401 *se401 = data;
59830 -       
59831 -       /* Stay under PAGE_SIZE or else bla bla bla.... */
59832 -
59833 -       out+=sprintf(out, "driver_version  : %s\n", version);
59834 -       out+=sprintf(out, "model           : %s\n", se401->camera_name);
59835 -       out+=sprintf(out, "in use          : %s\n", YES_NO (se401->user));
59836 -       out+=sprintf(out, "streaming       : %s\n", YES_NO (se401->streaming));
59837 -       out+=sprintf(out, "button state    : %s\n", YES_NO (se401->button));
59838 -       out+=sprintf(out, "button pressed  : %s\n", YES_NO (se401->buttonpressed));
59839 -       out+=sprintf(out, "num_frames      : %d\n", SE401_NUMFRAMES);
59840 -
59841 -       out+=sprintf(out, "Sizes           :");
59842 -       for (i=0; i<se401->sizes; i++) {
59843 -               out+=sprintf(out, " %dx%d", se401->width[i],
59844 -                   se401->height[i]);
59845 -       }
59846 -       out+=sprintf(out, "\n");
59847 -       
59848 -       out+=sprintf(out, "Frames total    : %d\n", se401->readcount);
59849 -       out+=sprintf(out, "Frames read     : %d\n", se401->framecount);
59850 -       out+=sprintf(out, "Packets dropped : %d\n", se401->dropped);
59851 -       out+=sprintf(out, "Decoding Errors : %d\n", se401->error);
59852 -
59853 -       len = out - page;
59854 -       len -= off;
59855 -       if (len < count) {
59856 -               *eof = 1;
59857 -               if (len <= 0)
59858 -                       return 0;
59859 -       } else
59860 -               len = count;
59861 -
59862 -       *start = page + off;
59863 -       
59864 -       return len;     
59865 -}
59866 -
59867 -static int se401_write_proc(struct file *file, const char *buffer, 
59868 -                           unsigned long count, void *data)
59869 -{
59870 -       return -EINVAL;
59871 -}
59872 -
59873 -static void create_proc_se401_cam (struct usb_se401 *se401)
59874 -{
59875 -       char name[7];
59876 -       struct proc_dir_entry *ent;
59877 -
59878 -       if (!se401_proc_entry || !se401)
59879 -               return;
59880 -
59881 -       sprintf (name, "video%d", se401->vdev.minor);
59882 -
59883 -       ent = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
59884 -                               se401_proc_entry);
59885 -
59886 -       if (!ent)
59887 -               return;
59888 -
59889 -       ent->data = se401;
59890 -       ent->read_proc = se401_read_proc;
59891 -       ent->write_proc = se401_write_proc;
59892 -       se401->proc_entry = ent;
59893 -}
59894 -
59895 -static void destroy_proc_se401_cam (struct usb_se401 *se401)
59896 -{
59897 -       /* One to much, just to be sure :) */
59898 -       char name[9];
59899 -
59900 -       if (!se401 || !se401->proc_entry)
59901 -               return;
59902 -       
59903 -       sprintf(name, "video%d", se401->vdev.minor);
59904 -       remove_proc_entry(name, se401_proc_entry);
59905 -       se401->proc_entry = NULL;
59906 -}
59907 -
59908 -static void proc_se401_create (void)
59909 -{
59910 -       if (video_proc_entry == NULL) {
59911 -               err("/proc/video/ doesn't exist");
59912 -               return;
59913 -       }
59914 -
59915 -       se401_proc_entry=create_proc_entry("se401", S_IFDIR, video_proc_entry);
59916 -
59917 -       if (se401_proc_entry)
59918 -               se401_proc_entry->owner = THIS_MODULE;
59919 -       else
59920 -               err("Unable to initialize /proc/video/se401");
59921 -}
59922 -
59923 -static void proc_se401_destroy(void)
59924 -{
59925 -       if (se401_proc_entry == NULL)
59926 -               return;
59927 -
59928 -       remove_proc_entry("se401", video_proc_entry);
59929 -}
59930 -#endif /* CONFIG_PROC_FS && CONFIG_VIDEO_PROC_FS */
59931 -
59932 -
59933 -/****************************************************************************
59934 - *
59935   * se401 register read/write functions
59936   *
59937   ***************************************************************************/
59938 @@ -1252,7 +1121,7 @@
59939         return video_usercopy(inode, file, cmd, arg, se401_do_ioctl);
59940  }
59941  
59942 -static int se401_read(struct file *file, char *buf,
59943 +static ssize_t se401_read(struct file *file, char *buf,
59944                      size_t count, loff_t *ppos)
59945  {
59946         int realcount=count, ret=0;
59947 @@ -1517,9 +1386,6 @@
59948                 err("video_register_device failed");
59949                 return -EIO;
59950         }
59951 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
59952 -        create_proc_se401_cam(se401);
59953 -#endif
59954         info("registered new video device: video%d", se401->vdev.minor);
59955  
59956         usb_set_intfdata (intf, se401);
59957 @@ -1544,9 +1410,6 @@
59958                         wake_up_interruptible(&se401->wq);
59959                         se401->removed = 1;
59960                 }
59961 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
59962 -               destroy_proc_se401_cam(se401);
59963 -#endif
59964         }
59965  }
59966  
59967 @@ -1568,29 +1431,19 @@
59968  
59969  static int __init usb_se401_init(void)
59970  {
59971 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
59972 -       proc_se401_create();
59973 -#endif
59974 -
59975         info("SE401 usb camera driver version %s registering", version);
59976         if (flickerless)
59977                 if (flickerless!=50 && flickerless!=60) {
59978                         info("Invallid flickerless value, use 0, 50 or 60.");
59979                         return -1;
59980         }
59981 -       if (usb_register(&se401_driver) < 0)
59982 -               return -1;
59983 -       return 0;
59984 +       return usb_register(&se401_driver);
59985  }
59986  
59987  static void __exit usb_se401_exit(void)
59988  {
59989         usb_deregister(&se401_driver);
59990         info("SE401 driver deregistered");
59991 -
59992 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
59993 -       proc_se401_destroy();
59994 -#endif
59995  }
59996  
59997  module_init(usb_se401_init);
59998 diff -Nru a/drivers/usb/media/se401.h b/drivers/usb/media/se401.h
59999 --- a/drivers/usb/media/se401.h Thu Sep  5 16:27:15 2002
60000 +++ b/drivers/usb/media/se401.h Wed Aug 27 10:22:35 2003
60001 @@ -224,9 +224,6 @@
60002  
60003         wait_queue_head_t wq;   /* Processes waiting */
60004  
60005 -       /* proc interface */
60006 -       struct proc_dir_entry *proc_entry;      /* /proc/se401/videoX */
60007 -
60008         int nullpackets;
60009  };
60010  
60011 diff -Nru a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c
60012 --- a/drivers/usb/media/stv680.c        Thu Aug 21 09:02:29 2003
60013 +++ b/drivers/usb/media/stv680.c        Wed Aug 27 05:46:09 2003
60014 @@ -61,14 +61,9 @@
60015  #include <linux/config.h>
60016  #include <linux/module.h>
60017  #include <linux/init.h>
60018 -#include <linux/fs.h>
60019  #include <linux/vmalloc.h>
60020  #include <linux/slab.h>
60021 -#include <linux/proc_fs.h>
60022  #include <linux/pagemap.h>
60023 -#include <linux/smp_lock.h>
60024 -#include <linux/sched.h>
60025 -#include <linux/signal.h>
60026  #include <linux/errno.h>
60027  #include <linux/videodev.h>
60028  #include <linux/usb.h>
60029 @@ -515,124 +510,57 @@
60030  
60031  /***************** last of pencam  routines  *******************/
60032  
60033 -/********************************************************************
60034 - * /proc interface
60035 - *******************************************************************/
60036 -
60037 -#warning please convert me from procfs to sysfs
60038 -#undef CONFIG_VIDEO_PROC_FS
60039 -
60040 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
60041 -
60042 -static struct proc_dir_entry *stv680_proc_entry = NULL;
60043 -extern struct proc_dir_entry *video_proc_entry;
60044 -
60045 -#define YES_NO(x) ((x) ? "yes" : "no")
60046 -#define ON_OFF(x) ((x) ? "(auto) on" : "(auto) off")
60047 -
60048 -static int stv680_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data)
60049 -{
60050 -       char *out = page;
60051 -       int len;
60052 -       struct usb_stv *stv680 = data;
60053 -
60054 -       /* Stay under PAGE_SIZE or else bla bla bla.... */
60055 -
60056 -       out += sprintf (out, "driver_version  : %s\n", DRIVER_VERSION);
60057 -       out += sprintf (out, "model           : %s\n", stv680->camera_name);
60058 -       out += sprintf (out, "in use          : %s\n", YES_NO (stv680->user));
60059 -       out += sprintf (out, "streaming       : %s\n", YES_NO (stv680->streaming));
60060 -       out += sprintf (out, "num_frames      : %d\n", STV680_NUMFRAMES);
60061 -
60062 -       out += sprintf (out, "Current size    : %ix%i\n", stv680->vwidth, stv680->vheight);
60063 -       if (swapRGB_on == 0)
60064 -               out += sprintf (out, "swapRGB         : %s\n", ON_OFF (swapRGB));
60065 -       else if (swapRGB_on == 1)
60066 -               out += sprintf (out, "swapRGB         : (forced) on\n");
60067 -       else if (swapRGB_on == -1)
60068 -               out += sprintf (out, "swapRGB         : (forced) off\n");
60069 -
60070 -       out += sprintf (out, "Palette         : %i", stv680->palette);
60071 -
60072 -       out += sprintf (out, "\n");
60073 -
60074 -       out += sprintf (out, "Frames total    : %d\n", stv680->readcount);
60075 -       out += sprintf (out, "Frames read     : %d\n", stv680->framecount);
60076 -       out += sprintf (out, "Packets dropped : %d\n", stv680->dropped);
60077 -       out += sprintf (out, "Decoding Errors : %d\n", stv680->error);
60078 -
60079 -       len = out - page;
60080 -       len -= off;
60081 -       if (len < count) {
60082 -               *eof = 1;
60083 -               if (len <= 0)
60084 -                       return 0;
60085 -       } else
60086 -               len = count;
60087 -
60088 -       *start = page + off;
60089 -       return len;
60090 -}
60091 -
60092 -static int create_proc_stv680_cam (struct usb_stv *stv680)
60093 -{
60094 -       char name[9];
60095 -       struct proc_dir_entry *ent;
60096 -
60097 -       if (!stv680_proc_entry || !stv680)
60098 -               return -1;
60099 -
60100 -       sprintf (name, "video%d", stv680->vdev.minor);
60101 -
60102 -       ent = create_proc_entry (name, S_IFREG | S_IRUGO | S_IWUSR, stv680_proc_entry);
60103 -       if (!ent)
60104 -               return -1;
60105 -
60106 -       ent->data = stv680;
60107 -       ent->read_proc = stv680_read_proc;
60108 -       stv680->proc_entry = ent;
60109 -       return 0;
60110 +/****************************************************************************
60111 + *  sysfs
60112 + ***************************************************************************/
60113 +static inline struct usb_stv *cd_to_stv(struct class_device *cd)
60114 +{
60115 +       struct video_device *vdev = to_video_device(cd);
60116 +       return video_get_drvdata(vdev);
60117 +}
60118 +
60119 +#define stv680_file(name, variable, field)                             \
60120 +static ssize_t show_##name(struct class_device *class_dev, char *buf)  \
60121 +{                                                                      \
60122 +       struct video_device *vdev = to_video_device(class_dev);         \
60123 +       struct usb_stv *stv = video_get_drvdata(vdev);                  \
60124 +       return sprintf(buf, field, stv->variable);                      \
60125 +}                                                                      \
60126 +static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
60127 +
60128 +stv680_file(model, camera_name, "%s\n");
60129 +stv680_file(in_use, user, "%d\n");
60130 +stv680_file(streaming, streaming, "%d\n");
60131 +stv680_file(palette, palette, "%i\n");
60132 +stv680_file(frames_total, readcount, "%d\n");
60133 +stv680_file(frames_read, framecount, "%d\n");
60134 +stv680_file(packets_dropped, dropped, "%d\n");
60135 +stv680_file(decoding_errors, error, "%d\n");
60136 +
60137 +static void stv680_create_sysfs_files(struct video_device *vdev)
60138 +{
60139 +       video_device_create_file(vdev, &class_device_attr_model);
60140 +       video_device_create_file(vdev, &class_device_attr_in_use);
60141 +       video_device_create_file(vdev, &class_device_attr_streaming);
60142 +       video_device_create_file(vdev, &class_device_attr_palette);
60143 +       video_device_create_file(vdev, &class_device_attr_frames_total);
60144 +       video_device_create_file(vdev, &class_device_attr_frames_read);
60145 +       video_device_create_file(vdev, &class_device_attr_packets_dropped);
60146 +       video_device_create_file(vdev, &class_device_attr_decoding_errors);
60147 +}
60148 +
60149 +static void stv680_remove_sysfs_files(struct video_device *vdev)
60150 +{
60151 +       video_device_remove_file(vdev, &class_device_attr_model);
60152 +       video_device_remove_file(vdev, &class_device_attr_in_use);
60153 +       video_device_remove_file(vdev, &class_device_attr_streaming);
60154 +       video_device_remove_file(vdev, &class_device_attr_palette);
60155 +       video_device_remove_file(vdev, &class_device_attr_frames_total);
60156 +       video_device_remove_file(vdev, &class_device_attr_frames_read);
60157 +       video_device_remove_file(vdev, &class_device_attr_packets_dropped);
60158 +       video_device_remove_file(vdev, &class_device_attr_decoding_errors);
60159  }
60160  
60161 -static void destroy_proc_stv680_cam (struct usb_stv *stv680)
60162 -{
60163 -       /* One to much, just to be sure :) */
60164 -       char name[9];
60165 -
60166 -       if (!stv680 || !stv680->proc_entry)
60167 -               return;
60168 -
60169 -       sprintf (name, "video%d", stv680->vdev.minor);
60170 -       remove_proc_entry (name, stv680_proc_entry);
60171 -       stv680->proc_entry = NULL;
60172 -}
60173 -
60174 -static int proc_stv680_create (void)
60175 -{
60176 -       if (video_proc_entry == NULL) {
60177 -               PDEBUG (0, "STV(e): /proc/video/ doesn't exist!");
60178 -               return -1;
60179 -       }
60180 -       stv680_proc_entry = create_proc_entry ("stv680", S_IFDIR, video_proc_entry);
60181 -
60182 -       if (stv680_proc_entry) {
60183 -               stv680_proc_entry->owner = THIS_MODULE;
60184 -       } else {
60185 -               PDEBUG (0, "STV(e): Unable to initialize /proc/video/stv680");
60186 -               return -1;
60187 -       }
60188 -       return 0;
60189 -}
60190 -
60191 -static void proc_stv680_destroy (void)
60192 -{
60193 -       if (stv680_proc_entry == NULL)
60194 -               return;
60195 -
60196 -       remove_proc_entry ("stv680", video_proc_entry);
60197 -}
60198 -#endif                         /* CONFIG_PROC_FS && CONFIG_VIDEO_PROC_FS */
60199 -
60200  /********************************************************************
60201   * Camera control
60202   *******************************************************************/
60203 @@ -1123,7 +1051,7 @@
60204  static int stv_open (struct inode *inode, struct file *file)
60205  {
60206         struct video_device *dev = video_devdata(file);
60207 -       struct usb_stv *stv680 = (struct usb_stv *) dev;
60208 +       struct usb_stv *stv680 = video_get_drvdata(dev);
60209         int err = 0;
60210  
60211         /* we are called with the BKL held */
60212 @@ -1147,7 +1075,7 @@
60213  static int stv_close (struct inode *inode, struct file *file)
60214  {
60215         struct video_device *dev = file->private_data;
60216 -       struct usb_stv *stv680 = (struct usb_stv *) dev;
60217 +       struct usb_stv *stv680 = video_get_drvdata(dev);
60218         int i;
60219  
60220         for (i = 0; i < STV680_NUMFRAMES; i++)
60221 @@ -1174,7 +1102,7 @@
60222                             unsigned int cmd, void *arg)
60223  {
60224         struct video_device *vdev = file->private_data;
60225 -       struct usb_stv *stv680 = (struct usb_stv *) vdev;
60226 +       struct usb_stv *stv680 = video_get_drvdata(vdev);
60227  
60228         if (!stv680->udev)
60229                 return -EIO;
60230 @@ -1350,7 +1278,7 @@
60231  static int stv680_mmap (struct file *file, struct vm_area_struct *vma)
60232  {
60233         struct video_device *dev = file->private_data;
60234 -       struct usb_stv *stv680 = (struct usb_stv *) dev;
60235 +       struct usb_stv *stv680 = video_get_drvdata(dev);
60236         unsigned long start = vma->vm_start;
60237         unsigned long size  = vma->vm_end-vma->vm_start;
60238         unsigned long page, pos;
60239 @@ -1385,13 +1313,13 @@
60240         return 0;
60241  }
60242  
60243 -static int stv680_read (struct file *file, char *buf,
60244 +static ssize_t stv680_read (struct file *file, char *buf,
60245                         size_t count, loff_t *ppos)
60246  {
60247         struct video_device *dev = file->private_data;
60248         unsigned long int realcount = count;
60249         int ret = 0;
60250 -       struct usb_stv *stv680 = (struct usb_stv *) dev;
60251 +       struct usb_stv *stv680 = video_get_drvdata(dev);
60252         unsigned long int i;
60253  
60254         if (STV680_NUMFRAMES != 2) {
60255 @@ -1448,14 +1376,17 @@
60256         .type =         VID_TYPE_CAPTURE,
60257         .hardware =     VID_HARDWARE_SE401,
60258         .fops =         &stv680_fops,
60259 +       .release =      video_device_release,
60260 +       .minor =        -1,
60261  };
60262  
60263  static int stv680_probe (struct usb_interface *intf, const struct usb_device_id *id)
60264  {
60265         struct usb_device *dev = interface_to_usbdev(intf);
60266         struct usb_host_interface *interface;
60267 -       struct usb_stv *stv680;
60268 +       struct usb_stv *stv680 = NULL;
60269         char *camera_name = NULL;
60270 +       int retval = 0;
60271  
60272         /* We don't handle multi-config cameras */
60273         if (dev->descriptor.bNumConfigurations != 1) {
60274 @@ -1471,12 +1402,14 @@
60275         } else {
60276                 PDEBUG (0, "STV(e): Vendor/Product ID do not match STV0680 values.");
60277                 PDEBUG (0, "STV(e): Check that the STV0680 camera is connected to the computer.");
60278 -               return -ENODEV;
60279 +               retval = -ENODEV;
60280 +               goto error;
60281         }
60282         /* We found one */
60283         if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
60284                 PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct.");
60285 -               return -ENOMEM;
60286 +               retval = -ENOMEM;
60287 +               goto error;
60288         }
60289  
60290         memset (stv680, 0, sizeof (*stv680));
60291 @@ -1484,24 +1417,34 @@
60292         stv680->udev = dev;
60293         stv680->camera_name = camera_name;
60294  
60295 -       memcpy (&stv680->vdev, &stv680_template, sizeof (stv680_template));
60296 -       memcpy (stv680->vdev.name, stv680->camera_name, strlen (stv680->camera_name));
60297 +       stv680->vdev = video_device_alloc();
60298 +       if (!stv680->vdev) {
60299 +               retval = -ENOMEM;
60300 +               goto error;
60301 +       }
60302 +       memcpy(stv680->vdev, &stv680_template, sizeof(stv680_template));
60303 +       stv680->vdev->dev = &intf->dev;
60304 +       video_set_drvdata(stv680->vdev, stv680);
60305 +
60306 +       memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name));
60307         init_waitqueue_head (&stv680->wq);
60308         init_MUTEX (&stv680->lock);
60309         wmb ();
60310  
60311 -       if (video_register_device (&stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
60312 -               kfree (stv680);
60313 +       if (video_register_device (stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
60314                 PDEBUG (0, "STV(e): video_register_device failed");
60315 -               return -EIO;
60316 +               retval = -EIO;
60317 +               goto error;
60318         }
60319 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
60320 -       create_proc_stv680_cam (stv680);
60321 -#endif
60322 -       PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev.minor);
60323 +       PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev->minor);
60324  
60325         usb_set_intfdata (intf, stv680);
60326 +       stv680_create_sysfs_files(stv680->vdev);
60327         return 0;
60328 +
60329 +error:
60330 +       kfree(stv680);
60331 +       return retval;
60332  }
60333  
60334  static inline void usb_stv680_remove_disconnected (struct usb_stv *stv680)
60335 @@ -1528,9 +1471,6 @@
60336                 }
60337         PDEBUG (0, "STV(i): %s disconnected", stv680->camera_name);
60338  
60339 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
60340 -       destroy_proc_stv680_cam (stv680);
60341 -#endif
60342         /* Free the memory */
60343         kfree (stv680);
60344  }
60345 @@ -1543,7 +1483,11 @@
60346  
60347         if (stv680) {
60348                 /* We don't want people trying to open up the device */
60349 -               video_unregister_device (&stv680->vdev);
60350 +               if (stv680->vdev) {
60351 +                       stv680_remove_sysfs_files(stv680->vdev);
60352 +                       video_unregister_device(stv680->vdev);
60353 +                       stv680->vdev = NULL;
60354 +               }
60355                 if (!stv680->user) {
60356                         usb_stv680_remove_disconnected (stv680);
60357                 } else {
60358 @@ -1566,10 +1510,6 @@
60359  
60360  static int __init usb_stv680_init (void)
60361  {
60362 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
60363 -       if (proc_stv680_create () < 0)
60364 -               return -1;
60365 -#endif
60366         if (usb_register (&stv680_driver) < 0) {
60367                 PDEBUG (0, "STV(e): Could not setup STV0680 driver");
60368                 return -1;
60369 @@ -1584,10 +1524,6 @@
60370  {
60371         usb_deregister (&stv680_driver);
60372         PDEBUG (0, "STV(i): driver deregistered");
60373 -
60374 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
60375 -       proc_stv680_destroy ();
60376 -#endif
60377  }
60378  
60379  module_init (usb_stv680_init);
60380 diff -Nru a/drivers/usb/media/stv680.h b/drivers/usb/media/stv680.h
60381 --- a/drivers/usb/media/stv680.h        Wed Dec 18 09:12:15 2002
60382 +++ b/drivers/usb/media/stv680.h        Fri Aug 22 08:40:08 2003
60383 @@ -89,7 +89,7 @@
60384  
60385  /* this is almost the video structure uvd_t, with extra parameters for stv */
60386  struct usb_stv {
60387 -       struct video_device vdev;
60388 +       struct video_device *vdev;
60389  
60390         struct usb_device *udev;
60391  
60392 @@ -142,7 +142,6 @@
60393  
60394         wait_queue_head_t wq;   /* Processes waiting */
60395  
60396 -       struct proc_dir_entry *proc_entry;      /* /proc/stv680/videoX */
60397         int nullpackets;
60398  };
60399  
60400 diff -Nru a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c
60401 --- a/drivers/usb/media/usbvideo.c      Thu Aug 21 09:00:15 2003
60402 +++ b/drivers/usb/media/usbvideo.c      Wed Aug 27 05:32:59 2003
60403 @@ -37,24 +37,9 @@
60404  static int video_nr = -1;
60405  MODULE_PARM(video_nr, "i");
60406  
60407 -#warning please convert me from procfs to sysfs
60408 -#define USES_PROC_FS 0
60409  /*
60410   * Local prototypes.
60411   */
60412 -#if USES_PROC_FS
60413 -static void usbvideo_procfs_level1_create(struct usbvideo *ut);
60414 -static void usbvideo_procfs_level1_destroy(struct usbvideo *ut);
60415 -static void usbvideo_procfs_level2_create(struct uvd *uvd);
60416 -static void usbvideo_procfs_level2_destroy(struct uvd *uvd);
60417 -static int usbvideo_default_procfs_read_proc(
60418 -       char *page, char **start, off_t off, int count,
60419 -       int *eof, void *data);
60420 -static int usbvideo_default_procfs_write_proc(
60421 -       struct file *file, const char *buffer, 
60422 -       unsigned long count, void *data);
60423 -#endif
60424 -
60425  static void usbvideo_Disconnect(struct usb_interface *intf);
60426  static void usbvideo_CameraRelease(struct uvd *uvd);
60427  
60428 @@ -813,24 +798,7 @@
60429                 cams->cb.startDataPump = usbvideo_StartDataPump;
60430         if (cams->cb.stopDataPump == NULL)
60431                 cams->cb.stopDataPump = usbvideo_StopDataPump;
60432 -#if USES_PROC_FS
60433 -       /*
60434 -        * If both /proc fs callbacks are NULL then we assume that the driver
60435 -        * does not need procfs services at all. Leave them NULL.
60436 -        */
60437 -       cams->uses_procfs = (cams->cb.procfs_read != NULL) || (cams->cb.procfs_write == NULL);
60438 -       if (cams->uses_procfs) {
60439 -               if (cams->cb.procfs_read == NULL)
60440 -                       cams->cb.procfs_read = usbvideo_default_procfs_read_proc;
60441 -               if (cams->cb.procfs_write == NULL)
60442 -                       cams->cb.procfs_write = usbvideo_default_procfs_write_proc;
60443 -       }
60444 -#else /* !USES_PROC_FS */
60445 -       /* Report a warning so that user knows why there is no /proc entries */
60446 -       if ((cams->cb.procfs_read != NULL) || (cams->cb.procfs_write == NULL)) {
60447 -               dbg("%s: /proc fs support requested but not configured!", __FUNCTION__);
60448 -       }
60449 -#endif
60450 +
60451         cams->num_cameras = num_cams;
60452         cams->cam = (struct uvd *) &cams[1];
60453         cams->md_module = md;
60454 @@ -871,13 +839,6 @@
60455         cams->usbdrv.disconnect = cams->cb.disconnect;
60456         cams->usbdrv.id_table = id_table;
60457  
60458 -#if USES_PROC_FS
60459 -       if (cams->uses_procfs) {
60460 -               dbg("%s: Creating /proc filesystem entries.", __FUNCTION__);
60461 -               usbvideo_procfs_level1_create(cams);
60462 -       }
60463 -#endif
60464 -
60465         /*
60466          * Update global handle to usbvideo. This is very important
60467          * because probe() can be called before usb_register() returns.
60468 @@ -920,13 +881,6 @@
60469                 return;
60470         }
60471  
60472 -#if USES_PROC_FS
60473 -       if (cams->uses_procfs) {
60474 -               dbg("%s: Deregistering filesystem entries.", __FUNCTION__);
60475 -               usbvideo_procfs_level1_destroy(cams);
60476 -       }
60477 -#endif
60478 -
60479         dbg("%s: Deregistering %s driver.", __FUNCTION__, cams->drvName);
60480         usb_deregister(&cams->usbdrv);
60481  
60482 @@ -1041,14 +995,6 @@
60483                 return;
60484         }
60485  
60486 -#if USES_PROC_FS
60487 -       assert(uvd->handle != NULL);
60488 -       if (uvd->handle->uses_procfs) {
60489 -               dbg("%s: Removing /proc/%s/ filesystem entries.", __FUNCTION__, uvd->handle->drvName);
60490 -               usbvideo_procfs_level2_destroy(uvd);
60491 -       }
60492 -#endif
60493 -
60494         RingQueue_Free(&uvd->dp);
60495         if (VALID_CALLBACK(uvd, userFree))
60496                 GET_CALLBACK(uvd, userFree)(uvd);
60497 @@ -1200,17 +1146,6 @@
60498              (uvd->handle != NULL) ? uvd->handle->drvName : "???",
60499              uvd->vdev.minor, tmp2, tmp1);
60500  
60501 -#if USES_PROC_FS
60502 -       assert(uvd->handle != NULL);
60503 -       if (uvd->handle->uses_procfs) {
60504 -               if (uvd->debug > 0) {
60505 -                       info("%s: Creating /proc/video/%s/ filesystem entries.",
60506 -                            __FUNCTION__, uvd->handle->drvName);
60507 -               }
60508 -               usbvideo_procfs_level2_create(uvd);
60509 -       }
60510 -#endif
60511 -
60512         usb_get_dev(uvd->dev);
60513         return 0;
60514  }
60515 @@ -1665,7 +1600,7 @@
60516                 return -EFAULT;
60517  
60518         if (uvd->debug >= 1)
60519 -               info("%s: %d. bytes, noblock=%d.", __FUNCTION__, count, noblock);
60520 +               info("%s: %Zd. bytes, noblock=%d.", __FUNCTION__, count, noblock);
60521  
60522         down(&uvd->lock);       
60523  
60524 @@ -1783,7 +1718,7 @@
60525         /* Update last read position */
60526         frame->seqRead_Index += count;
60527         if (uvd->debug >= 1) {
60528 -               err("%s: {copy} count used=%d, new seqRead_Index=%ld",
60529 +               err("%s: {copy} count used=%Zd, new seqRead_Index=%ld",
60530                         __FUNCTION__, count, frame->seqRead_Index);
60531         }
60532  
60533 @@ -2345,130 +2280,4 @@
60534         }
60535  }
60536  
60537 -/*
60538 - * /proc interface
60539 - *
60540 - * We will be creating directories and entries under /proc/video using
60541 - * external 'video_proc_entry' directory which is exported by videodev.o
60542 - * module. Within that directory we will create $driver/ directory to
60543 - * uniquely and uniformly refer to our specific $driver. Within that
60544 - * directory we will finally create an entry that is named after the
60545 - * video device node - video3, for example. The format of that file
60546 - * is determined by callbacks that the minidriver may provide. If no
60547 - * callbacks are provided (neither read nor write) then we don't create
60548 - * the entry.
60549 - *
60550 - * Here is a sample directory entry: /proc/video/ibmcam/video3
60551 - *
60552 - * The "file" video3 (in example above) is readable and writeable, in
60553 - * theory. If the minidriver provides callbacks to do reading and
60554 - * writing then both those procedures are supported. However if the
60555 - * driver leaves callbacks in default (NULL) state the default
60556 - * read and write handlers are used. The default read handler reports
60557 - * that the driver does not support /proc fs. The default write handler
60558 - * returns error code on any write attempt.
60559 - */
60560 -
60561 -#if USES_PROC_FS
60562 -
60563 -extern struct proc_dir_entry *video_proc_entry;
60564 -
60565 -static void usbvideo_procfs_level1_create(struct usbvideo *ut)
60566 -{
60567 -       if (ut == NULL) {
60568 -               err("%s: ut == NULL", __FUNCTION__);
60569 -               return;
60570 -       }
60571 -       if (video_proc_entry == NULL) {
60572 -               err("%s: /proc/video/ doesn't exist.", __FUNCTION__);
60573 -               return;
60574 -       }
60575 -       ut->procfs_dEntry = create_proc_entry(ut->drvName, S_IFDIR, video_proc_entry);
60576 -       if (ut->procfs_dEntry != NULL) {
60577 -               if (ut->md_module != NULL)
60578 -                       ut->procfs_dEntry->owner = ut->md_module;
60579 -       } else {
60580 -               err("%s: Unable to initialize /proc/video/%s", __FUNCTION__, ut->drvName);
60581 -       }
60582 -}
60583 -
60584 -static void usbvideo_procfs_level1_destroy(struct usbvideo *ut)
60585 -{
60586 -       if (ut == NULL) {
60587 -               err("%s: ut == NULL", __FUNCTION__);
60588 -               return;
60589 -       }
60590 -       if (ut->procfs_dEntry != NULL) {
60591 -               remove_proc_entry(ut->drvName, video_proc_entry);
60592 -               ut->procfs_dEntry = NULL;
60593 -       }
60594 -}
60595 -
60596 -static void usbvideo_procfs_level2_create(struct uvd *uvd)
60597 -{
60598 -       if (uvd == NULL) {
60599 -               err("%s: uvd == NULL", __FUNCTION__);
60600 -               return;
60601 -       }
60602 -       assert(uvd->handle != NULL);
60603 -       if (uvd->handle->procfs_dEntry == NULL) {
60604 -               err("%s: uvd->handle->procfs_dEntry == NULL", __FUNCTION__);
60605 -               return;
60606 -       }
60607 -
60608 -       sprintf(uvd->videoName, "video%d", uvd->vdev.minor);
60609 -       uvd->procfs_vEntry = create_proc_entry(
60610 -               uvd->videoName,
60611 -               S_IFREG | S_IRUGO | S_IWUSR,
60612 -               uvd->handle->procfs_dEntry);
60613 -       if (uvd->procfs_vEntry != NULL) {
60614 -               uvd->procfs_vEntry->data = uvd;
60615 -               uvd->procfs_vEntry->read_proc = uvd->handle->cb.procfs_read;
60616 -               uvd->procfs_vEntry->write_proc = uvd->handle->cb.procfs_write;
60617 -       } else {
60618 -               err("%s: Failed to create entry \"%s\"", __FUNCTION__, uvd->videoName);
60619 -       }
60620 -}
60621 -
60622 -static void usbvideo_procfs_level2_destroy(struct uvd *uvd)
60623 -{
60624 -       if (uvd == NULL) {
60625 -               err("%s: uvd == NULL", __FUNCTION__);
60626 -               return;
60627 -       }
60628 -       if (uvd->procfs_vEntry != NULL) {
60629 -               remove_proc_entry(uvd->videoName, uvd->procfs_vEntry);
60630 -               uvd->procfs_vEntry = NULL;
60631 -       }
60632 -}
60633 -
60634 -static int usbvideo_default_procfs_read_proc(
60635 -       char *page, char **start, off_t off, int count,
60636 -       int *eof, void *data)
60637 -{
60638 -       char *out = page;
60639 -       int len;
60640 -       
60641 -       /* Stay under PAGE_SIZE or else */
60642 -       out += sprintf(out, "This driver does not support /proc services.\n");
60643 -       len = out - page;
60644 -       len -= off;
60645 -       if (len < count) {
60646 -               *eof = 1;
60647 -               if (len <= 0)
60648 -                       return 0;
60649 -       } else
60650 -               len = count;
60651 -       *start = page + off;
60652 -       return len;     
60653 -}
60654 -
60655 -static int usbvideo_default_procfs_write_proc(
60656 -       struct file *file, const char *buffer, 
60657 -       unsigned long count, void *data)
60658 -{
60659 -       return -EINVAL;
60660 -}
60661 -
60662 -#endif /* USES_PROC_FS */
60663  MODULE_LICENSE("GPL");
60664 diff -Nru a/drivers/usb/media/usbvideo.h b/drivers/usb/media/usbvideo.h
60665 --- a/drivers/usb/media/usbvideo.h      Thu Oct 24 13:11:38 2002
60666 +++ b/drivers/usb/media/usbvideo.h      Wed Aug 27 10:14:38 2003
60667 @@ -17,14 +17,12 @@
60668  #define        usbvideo_h
60669  
60670  #include <linux/config.h>
60671 -#include <linux/proc_fs.h>
60672  #include <linux/videodev.h>
60673  #include <linux/usb.h>
60674  
60675  /* Most helpful debugging aid */
60676  #define assert(expr) ((void) ((expr) ? 0 : (err("assert failed at line %d",__LINE__))))
60677  
60678 -#define USES_PROC_FS   (defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS))
60679  #define USBVIDEO_REPORT_STATS  1       /* Set to 0 to block statistics on close */
60680  
60681  /* Bit flags (options) */
60682 @@ -244,7 +242,6 @@
60683         struct video_capability vcap;           /* Video capabilities */
60684         struct video_channel vchan;     /* May be used for tuner support */
60685         struct usbvideo_statistics stats;
60686 -       struct proc_dir_entry *procfs_vEntry;   /* /proc/video/MYDRIVER/video2 */
60687         char videoName[32];             /* Holds name like "video7" */
60688  };
60689  
60690 @@ -266,8 +263,6 @@
60691         int (*getFPS)(struct uvd *);
60692         int (*overlayHook)(struct uvd *, struct usbvideo_frame *);
60693         int (*getFrame)(struct uvd *, int);
60694 -       int (*procfs_read)(char *page,char **start,off_t off,int count,int *eof,void *data);
60695 -       int (*procfs_write)(struct file *file,const char *buffer,unsigned long count,void *data);
60696         int (*startDataPump)(struct uvd *uvd);
60697         void (*stopDataPump)(struct uvd *uvd);
60698         int (*setVideoMode)(struct uvd *uvd, struct video_window *vw);
60699 @@ -281,8 +276,6 @@
60700         struct usbvideo_cb cb;          /* Table of callbacks (virtual methods) */
60701         struct video_device vdt;        /* Video device template */
60702         struct uvd *cam;                        /* Array of camera structures */
60703 -       int uses_procfs;                /* Non-zero if we create /proc entries */
60704 -       struct proc_dir_entry *procfs_dEntry;   /* /proc/video/MYDRIVER */
60705         struct module *md_module;       /* Minidriver module */
60706  };
60707  
60708 diff -Nru a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c
60709 --- a/drivers/usb/media/vicam.c Thu Jun  5 15:57:38 2003
60710 +++ b/drivers/usb/media/vicam.c Sat Aug 23 07:15:33 2003
60711 @@ -1388,11 +1388,13 @@
60712  static int __init
60713  usb_vicam_init(void)
60714  {
60715 +       int retval;
60716         DBG(KERN_INFO "ViCam-based WebCam driver startup\n");
60717         vicam_create_proc_root();
60718 -       if (usb_register(&vicam_driver) != 0)
60719 +       retval = usb_register(&vicam_driver);
60720 +       if (retval)
60721                 printk(KERN_WARNING "usb_register failed!\n");
60722 -       return 0;
60723 +       return retval;
60724  }
60725  
60726  static void __exit
60727 diff -Nru a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
60728 --- a/drivers/usb/misc/auerswald.c      Wed Jul 30 06:14:48 2003
60729 +++ b/drivers/usb/misc/auerswald.c      Tue Aug 26 09:25:41 2003
60730 @@ -1380,7 +1380,7 @@
60731  /* Open a new character device */
60732  static int auerchar_open (struct inode *inode, struct file *file)
60733  {
60734 -       int dtindex = minor(inode->i_rdev);
60735 +       int dtindex = iminor(inode);
60736         pauerswald_t cp = NULL;
60737         pauerchar_t ccp = NULL;
60738         struct usb_interface *intf;
60739 diff -Nru a/drivers/usb/misc/brlvger.c b/drivers/usb/misc/brlvger.c
60740 --- a/drivers/usb/misc/brlvger.c        Tue Jul 29 04:28:54 2003
60741 +++ b/drivers/usb/misc/brlvger.c        Tue Sep  2 11:40:28 2003
60742 @@ -249,17 +249,20 @@
60743  static int
60744  __init brlvger_init (void)
60745  {
60746 +       int retval;
60747         printk(BANNER);
60748  
60749         if(stall_tries < 1 || write_repeats < 1)
60750           return -EINVAL;
60751  
60752 -       if (usb_register(&brlvger_driver)) {
60753 +       retval = usb_register(&brlvger_driver);
60754 +       if (retval) {
60755                 err("USB registration failed");
60756 -               return -ENOSYS;
60757 +               goto out;
60758         }
60759  
60760 -       return 0;
60761 +out:
60762 +       return retval;
60763  }
60764  
60765  static void
60766 @@ -432,7 +435,7 @@
60767  static int
60768  brlvger_open(struct inode *inode, struct file *file)
60769  {
60770 -       int devnum = minor (inode->i_rdev);
60771 +       int devnum = iminor(inode);
60772         struct usb_interface *intf = NULL;
60773         struct brlvger_priv *priv = NULL;
60774         int n, ret;
60775 diff -Nru a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
60776 --- a/drivers/usb/misc/rio500.c Tue Jun 17 08:12:48 2003
60777 +++ b/drivers/usb/misc/rio500.c Sat Aug 23 07:28:41 2003
60778 @@ -33,7 +33,6 @@
60779  #include <linux/signal.h>
60780  #include <linux/sched.h>
60781  #include <linux/errno.h>
60782 -#include <linux/miscdevice.h>
60783  #include <linux/random.h>
60784  #include <linux/poll.h>
60785  #include <linux/init.h>
60786 @@ -531,12 +530,15 @@
60787  
60788  static int __init usb_rio_init(void)
60789  {
60790 -       if (usb_register(&rio_driver) < 0)
60791 -               return -1;
60792 +       int retval;
60793 +       retval = usb_register(&rio_driver);
60794 +       if (retval)
60795 +               goto out;
60796  
60797         info(DRIVER_VERSION ":" DRIVER_DESC);
60798  
60799 -       return 0;
60800 +out:
60801 +       return retval;
60802  }
60803  
60804  
60805 diff -Nru a/drivers/usb/misc/tiglusb.c b/drivers/usb/misc/tiglusb.c
60806 --- a/drivers/usb/misc/tiglusb.c        Mon Aug 11 07:56:25 2003
60807 +++ b/drivers/usb/misc/tiglusb.c        Tue Sep  2 11:40:28 2003
60808 @@ -24,7 +24,6 @@
60809  
60810  #include <linux/module.h>
60811  #include <linux/socket.h>
60812 -#include <linux/miscdevice.h>
60813  #include <linux/slab.h>
60814  #include <linux/init.h>
60815  #include <asm/uaccess.h>
60816 @@ -93,7 +92,7 @@
60817  static int
60818  tiglusb_open (struct inode *inode, struct file *filp)
60819  {
60820 -       int devnum = minor (inode->i_rdev);
60821 +       int devnum = iminor(inode);
60822         ptiglusb_t s;
60823  
60824         if (devnum < TIUSB_MINOR || devnum >= (TIUSB_MINOR + MAXTIGL))
60825 diff -Nru a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
60826 --- a/drivers/usb/misc/usblcd.c Wed Jul 16 06:00:04 2003
60827 +++ b/drivers/usb/misc/usblcd.c Sat Aug 23 07:24:57 2003
60828 @@ -342,18 +342,21 @@
60829         .id_table =     id_table,
60830  };
60831  
60832 -int usb_lcd_init(void)
60833 +static int __init usb_lcd_init(void)
60834  {
60835 -       if (usb_register(&lcd_driver) < 0)
60836 -               return -1;
60837 +       int retval;
60838 +       retval = usb_register(&lcd_driver);
60839 +       if (retval)
60840 +               goto out;
60841  
60842         info("%s (C) Adams IT Services http://www.usblcd.de", DRIVER_VERSION);
60843         info("USBLCD support registered.");
60844 -       return 0;
60845 +out:
60846 +       return retval;
60847  }
60848  
60849  
60850 -void usb_lcd_cleanup(void)
60851 +static void __exit usb_lcd_cleanup(void)
60852  {
60853         struct lcd_usb_data *lcd = &lcd_instance;
60854  
60855 diff -Nru a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
60856 --- a/drivers/usb/misc/usbtest.c        Sat Aug 16 11:46:50 2003
60857 +++ b/drivers/usb/misc/usbtest.c        Thu Aug 21 08:34:01 2003
60858 @@ -435,7 +435,7 @@
60859                 return 0;
60860         }
60861  
60862 -       le32_to_cpus (&config->wTotalLength);
60863 +       le16_to_cpus (&config->wTotalLength);
60864         if (config->wTotalLength == len)                /* read it all */
60865                 return 1;
60866         return config->wTotalLength >= TBUF_SIZE;       /* max partial read */
60867 diff -Nru a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
60868 --- a/drivers/usb/misc/uss720.c Tue May 13 05:34:40 2003
60869 +++ b/drivers/usb/misc/uss720.c Sat Aug 23 07:26:14 2003
60870 @@ -653,11 +653,14 @@
60871  
60872  static int __init uss720_init(void)
60873  {
60874 -       if (usb_register(&uss720_driver) < 0)
60875 -               return -1;
60876 +       int retval;
60877 +       retval = usb_register(&uss720_driver);
60878 +       if (retval)
60879 +               goto out;
60880  
60881         info(DRIVER_VERSION ":" DRIVER_DESC);
60882 -       return 0;
60883 +out:
60884 +       return retval;
60885  }
60886  
60887  static void __exit uss720_cleanup(void)
60888 diff -Nru a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
60889 --- a/drivers/usb/net/Kconfig   Tue Jun 17 07:37:22 2003
60890 +++ b/drivers/usb/net/Kconfig   Sun Aug 24 11:31:24 2003
60891 @@ -7,7 +7,7 @@
60892  comment "Networking support is needed for USB Networking device support"
60893         depends on USB && !NET
60894  
60895 -config USB_AX8817X
60896 +config USB_AX8817X_STANDALONE
60897         tristate "USB ASIX AX8817X Ethernet device support (EXPERIMENTAL)"
60898         depends on USB && NET && EXPERIMENTAL
60899         ---help---
60900 @@ -121,15 +121,15 @@
60901           module, say M here and read <file:Documentation/modules.txt>.
60902  
60903  config USB_USBNET
60904 -       tristate "Host-to-Host Networking for Cables and Smart Devices"
60905 +       tristate "Multi-purpose USB Networking Framework"
60906         depends on USB && NET
60907         ---help---
60908           This driver supports several kinds of network links over USB,
60909           with "minidrivers" built around a common network driver core
60910 -         that supports deep queues for efficient transfers.
60911 -
60912 -         Typically, these links involves only two network hosts.  The
60913 -         host runs "usbnet", and the other end of the link might be:
60914 +         that supports deep queues for efficient transfers.  (This gives
60915 +         better performance with small packets and at high speeds).
60916 +         
60917 +         The USB host runs "usbnet", and the other end of the link might be:
60918  
60919           - Another USB host, when using USB "network" or "data transfer"
60920             cables.  These are often used to network laptops to PCs, like
60921 @@ -141,6 +141,9 @@
60922             others), and devices that interoperate using the standard
60923             CDC-Ethernet specification (including many cable modems).
60924  
60925 +         - Network adapter hardware (like those for 10/100 Ethernet) which
60926 +           uses this driver framework.
60927 +
60928           The link will appear with a name like "usb0", when the link is
60929           a two-node link, or "eth0" for most CDC-Ethernet devices.  Those
60930           two-node links are most easily managed with Ethernet Bridging
60931 @@ -265,4 +268,30 @@
60932           what other networking devices you have in use.  However, if the
60933           IEEE 802 "local assignment" bit is set in the address, a "usbX"
60934           name is used instead.
60935 +
60936 +comment "USB Network Adapters"
60937 +       depends on USB_USBNET
60938 +
60939 +config USB_AX8817X
60940 +       boolean "ASIX AX88172 Based USB 2.0 Ethernet Devices"
60941 +       depends on USB_USBNET && EXPERIMENTAL
60942 +       default y
60943 +       help
60944 +
60945 +         This option adds support for ASIX AX88172 based USB 2.0
60946 +         10/100 Ethernet devices.
60947 +
60948 +         This driver should work with at least the following devices:
60949 +           * ASIX AX88172
60950 +           * D-Link DUB-E100
60951 +           * Hawking UF200
60952 +           * Linksys USB200M
60953 +           * Netgear FA120
60954 +           * Intellinet
60955 +           * ST Lab USB Ethernet
60956 +           * TrendNet TU2-ET100
60957 +
60958 +         This driver creates an interface named "ethX", where X depends on
60959 +         what other networking devices you have in use.  
60960 +
60961  
60962 diff -Nru a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
60963 --- a/drivers/usb/net/Makefile  Mon Jun 16 14:19:37 2003
60964 +++ b/drivers/usb/net/Makefile  Fri Aug 29 01:06:26 2003
60965 @@ -2,7 +2,7 @@
60966  # Makefile for USB Network drivers
60967  #
60968  
60969 -obj-$(CONFIG_USB_AX8817X)      += ax8817x.o
60970 +obj-$(CONFIG_USB_AX8817X_STANDALONE)   += ax8817x.o
60971  obj-$(CONFIG_USB_CATC)         += catc.o
60972  obj-$(CONFIG_USB_KAWETH)       += kaweth.o
60973  obj-$(CONFIG_USB_PEGASUS)      += pegasus.o
60974 diff -Nru a/drivers/usb/net/Makefile.mii b/drivers/usb/net/Makefile.mii
60975 --- a/drivers/usb/net/Makefile.mii      Mon Jun 16 14:19:37 2003
60976 +++ b/drivers/usb/net/Makefile.mii      Sat Aug 23 04:56:14 2003
60977 @@ -4,3 +4,4 @@
60978  
60979  obj-$(CONFIG_USB_AX8817X)      += mii.o
60980  obj-$(CONFIG_USB_PEGASUS)      += mii.o
60981 +obj-$(CONFIG_USB_USBNET)       += mii.o
60982 diff -Nru a/drivers/usb/net/ax8817x.c b/drivers/usb/net/ax8817x.c
60983 --- a/drivers/usb/net/ax8817x.c Thu Aug  7 10:28:47 2003
60984 +++ b/drivers/usb/net/ax8817x.c Thu Aug 21 20:23:38 2003
60985 @@ -75,7 +75,6 @@
60986  #include <linux/mii.h>
60987  #include <linux/crc32.h>
60988  #include <asm/uaccess.h>
60989 -#include <linux/version.h>
60990  
60991  /* Version Information */
60992  #define DRIVER_VERSION "v2.0.2"
60993 diff -Nru a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
60994 --- a/drivers/usb/net/usbnet.c  Wed Aug 13 17:22:50 2003
60995 +++ b/drivers/usb/net/usbnet.c  Thu Aug 28 15:25:45 2003
60996 @@ -1,7 +1,9 @@
60997  /*
60998 - * USB Host-to-Host Links
60999 - * Copyright (C) 2000-2002 by David Brownell <dbrownell@users.sourceforge.net>
61000 + * USB Networking Links
61001 + * Copyright (C) 2000-2003 by David Brownell <dbrownell@users.sourceforge.net>
61002   * Copyright (C) 2002 Pavel Machek <pavel@ucw.cz>
61003 + * Copyright (C) 2003 David Hollis <dhollis@davehollis.com>
61004 + * Copyright (c) 2002-2003 TiVo Inc.
61005   *
61006   * This program is free software; you can redistribute it and/or modify
61007   * it under the terms of the GNU General Public License as published by
61008 @@ -19,63 +21,38 @@
61009   */
61010  
61011  /*
61012 - * This is used for "USB networking", connecting USB hosts as peers.
61013 - *
61014 - * It can be used with USB "network cables", for IP-over-USB communications;
61015 - * Ethernet speeds without the Ethernet.  USB devices (including some PDAs)
61016 - * can support such links directly, replacing device-specific protocols
61017 - * with Internet standard ones.
61018 - *
61019 - * The links can be bridged using the Ethernet bridging (net/bridge)
61020 - * support as appropriate.  Devices currently supported include:
61021 + * This is a generic "USB networking" framework that works with several
61022 + * kinds of full and high speed networking devices:
61023   *
61024 + *   + USB host-to-host "network cables", used for IP-over-USB links.
61025 + *     These are often used for Laplink style connectivity products.
61026   *     - AnchorChip 2720
61027   *     - Belkin, eTEK (interops with Win32 drivers)
61028 - *     - EPSON USB clients
61029   *     - GeneSys GL620USB-A
61030   *     - NetChip 1080 (interoperates with NetChip Win32 drivers)
61031   *     - Prolific PL-2301/2302 (replaces "plusb" driver)
61032 - *     - PXA-250 or SA-1100 Linux PDAs like iPaq, Yopy, and Zaurus
61033 + *
61034 + *   + Smart USB devices can support such links directly, using Internet
61035 + *     standard protocols instead of proprietary host-to-device links.
61036 + *     - Linux PDAs like iPaq, Yopy, and Zaurus
61037 + *     - The BLOB boot loader (for diskless booting)
61038 + *     - Linux "gadgets", perhaps using PXA-2xx or Net2280 controllers
61039 + *     - Devices using EPSON's sample USB firmware
61040 + *     - CDC-Ethernet class devices, such as many cable modems
61041 + *
61042 + *   + Adapters to networks such as Ethernet.
61043 + *     - AX8817X based USB 2.0 products
61044 + *
61045 + * Links to these devices can be bridged using Linux Ethernet bridging.
61046 + * With minor exceptions, these all use similar USB framing for network
61047 + * traffic, but need different protocols for control traffic.
61048   *
61049   * USB devices can implement their side of this protocol at the cost
61050   * of two bulk endpoints; it's not restricted to "cable" applications.
61051   * See the SA1110, Zaurus, or EPSON device/client support in this driver;
61052 - * slave/target drivers such as "usb-eth" (on most SA-1100 PDAs) are
61053 - * used inside USB slave/target devices.
61054 - *
61055 - * 
61056 - * Status:
61057 - *
61058 - * - AN2720 ... not widely available, but reportedly works well
61059 - *
61060 - * - Belkin/eTEK ... no known issues
61061 - *
61062 - * - Both GeneSys and PL-230x use interrupt transfers for driver-to-driver
61063 - *   handshaking; it'd be worth implementing those as "carrier detect".
61064 - *   Prefer generic hooks, not minidriver-specific hacks.
61065 - *
61066 - * - For Netchip, should use keventd to poll via control requests to detect
61067 - *   hardware level "carrier detect". 
61068 - *
61069 - * - PL-230x ... the initialization protocol doesn't seem to match chip data
61070 - *   sheets, sometimes it's not needed and sometimes it hangs.  Prolific has
61071 - *   not responded to repeated support/information requests.
61072 - *
61073 - * - SA-1100 PDAs ... the standard ARM Linux SA-1100 support works nicely,
61074 - *   as found in www.handhelds.org and other kernels.  The Sharp/Lineo
61075 - *   kernels use different drivers, which also talk to this code.
61076 - *
61077 - * Interop with more Win32 drivers may be a good thing.
61078 - *
61079 - * Seems like reporting "peer connected" (carrier present) events may end
61080 - * up going through the netlink event system, not hotplug ... so new links
61081 - * would likely be handled with a link monitoring thread in some daemon.
61082 - *
61083 - * There are reports that bridging gives lower-than-usual throughput.
61084 - *
61085 - * Need smarter hotplug policy scripts ... ones that know how to arrange
61086 - * bridging with "brctl", and can handle static and dynamic ("pump") setups.
61087 - * Use those eventual "peer connected" events, and zeroconf.
61088 + * slave/target drivers such as "usb-eth" (on most SA-1100 PDAs) or
61089 + * "g_ether" (in the Linux "gadget" framework) implement that behavior
61090 + * within devices.
61091   *
61092   *
61093   * CHANGELOG:
61094 @@ -126,6 +103,7 @@
61095   *             vs pxa25x, and CDC Ethernet.  Throttle down log floods on
61096   *             disconnect; other cleanups. (db)  Flush net1080 fifos
61097   *             after several sequential framing errors. (Johannes Erdfelt)
61098 + * 22-aug-2003 AX8817X support (Dave Hollis).
61099   *
61100   *-------------------------------------------------------------------------*/
61101  
61102 @@ -139,9 +117,11 @@
61103  #include <linux/random.h>
61104  #include <linux/ethtool.h>
61105  #include <linux/workqueue.h>
61106 +#include <linux/mii.h>
61107  #include <asm/uaccess.h>
61108  #include <asm/unaligned.h>
61109  
61110 +
61111  // #define     DEBUG                   // error path messages, extra info
61112  // #define     VERBOSE                 // more; success messages
61113  #define        REALLY_QUEUE
61114 @@ -157,7 +137,7 @@
61115  #include <linux/dma-mapping.h>
61116  
61117  
61118 -#define DRIVER_VERSION         "25-Apr-2003"
61119 +#define DRIVER_VERSION         "25-Aug-2003"
61120  
61121  /*-------------------------------------------------------------------------*/
61122  
61123 @@ -218,6 +198,8 @@
61124         int                     msg_level;
61125         unsigned long           data [5];
61126  
61127 +       struct mii_if_info      mii;
61128 +
61129         // various kinds of pending driver work
61130         struct sk_buff_head     rxq;
61131         struct sk_buff_head     txq;
61132 @@ -399,6 +381,275 @@
61133  
61134  #endif /* CONFIG_USB_AN2720 */
61135  
61136 +\f
61137 +#ifdef CONFIG_USB_AX8817X
61138 +#define NEED_MII
61139 +/* ASIX AX8817X based USB 2.0 Ethernet Devices */
61140 +
61141 +#define HAVE_HARDWARE
61142 +
61143 +#include <linux/crc32.h>
61144 +
61145 +#define AX_CMD_SET_SW_MII              0x06
61146 +#define AX_CMD_READ_MII_REG            0x07
61147 +#define AX_CMD_WRITE_MII_REG           0x08
61148 +#define AX_CMD_SET_HW_MII              0x0a
61149 +#define AX_CMD_WRITE_RX_CTL            0x10
61150 +#define AX_CMD_READ_IPG012             0x11
61151 +#define AX_CMD_WRITE_IPG0              0x12
61152 +#define AX_CMD_WRITE_IPG1              0x13
61153 +#define AX_CMD_WRITE_IPG2              0x14
61154 +#define AX_CMD_WRITE_MULTI_FILTER      0x16
61155 +#define AX_CMD_READ_NODE_ID            0x17
61156 +#define AX_CMD_READ_PHY_ID             0x19
61157 +#define AX_CMD_WRITE_MEDIUM_MODE       0x1b
61158 +#define AX_CMD_WRITE_GPIOS             0x1f
61159 +
61160 +#define AX_MCAST_FILTER_SIZE           8
61161 +#define AX_MAX_MCAST                   64
61162 +
61163 +static int ax8817x_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
61164 +                           u16 size, void *data)
61165 +{
61166 +       return usb_control_msg(
61167 +               dev->udev,
61168 +               usb_rcvctrlpipe(dev->udev, 0),
61169 +               cmd,
61170 +               USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
61171 +               value,
61172 +               index,
61173 +               data,
61174 +               size,
61175 +               CONTROL_TIMEOUT_JIFFIES);
61176 +}
61177 +
61178 +static int ax8817x_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
61179 +                            u16 size, void *data)
61180 +{
61181 +       return usb_control_msg(
61182 +               dev->udev,
61183 +               usb_sndctrlpipe(dev->udev, 0),
61184 +               cmd,
61185 +               USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
61186 +               value,
61187 +               index,
61188 +               data,
61189 +               size,
61190 +               CONTROL_TIMEOUT_JIFFIES);
61191 +}
61192 +
61193 +static void ax8817x_async_cmd_callback(struct urb *urb, struct pt_regs *regs)
61194 +{
61195 +       struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
61196 +       
61197 +       if (urb->status < 0)
61198 +               printk(KERN_DEBUG "ax8817x_async_cmd_callback() failed with %d",
61199 +                       urb->status);
61200 +       
61201 +       kfree(req);
61202 +       usb_free_urb(urb);
61203 +}
61204 +
61205 +static void ax8817x_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
61206 +                                   u16 size, void *data)
61207 +{
61208 +       struct usb_ctrlrequest *req;
61209 +       int status;
61210 +       struct urb *urb;
61211 +       
61212 +       if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) {
61213 +               devdbg(dev, "Error allocating URB in write_cmd_async!");
61214 +               return;
61215 +       }
61216 +       
61217 +       if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) {
61218 +               deverr(dev, "Failed to allocate memory for control request");
61219 +               usb_free_urb(urb);
61220 +               return;
61221 +       }
61222 +
61223 +       req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
61224 +       req->bRequest = cmd;
61225 +       req->wValue = cpu_to_le16(value);
61226 +       req->wIndex = cpu_to_le16(index); 
61227 +       req->wLength = cpu_to_le16(size);
61228 +
61229 +       usb_fill_control_urb(urb, dev->udev,
61230 +                            usb_sndctrlpipe(dev->udev, 0),
61231 +                            (void *)req, data, size,
61232 +                            ax8817x_async_cmd_callback, req);
61233 +
61234 +       if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0)
61235 +               deverr(dev, "Error submitting the control message: status=%d", status);
61236 +}
61237 +
61238 +static void ax8817x_set_multicast(struct net_device *net)
61239 +{
61240 +       struct usbnet *dev = (struct usbnet *) net->priv;
61241 +       u8 rx_ctl = 0x8c;
61242 +
61243 +       if (net->flags & IFF_PROMISC) {
61244 +               rx_ctl |= 0x01;
61245 +       } else if (net->flags & IFF_ALLMULTI
61246 +                  || net->mc_count > AX_MAX_MCAST) {
61247 +               rx_ctl |= 0x02;
61248 +       } else if (net->mc_count == 0) {
61249 +               /* just broadcast and directed */
61250 +       } else {
61251 +               struct dev_mc_list *mc_list = net->mc_list;
61252 +               u8 *multi_filter;
61253 +               u32 crc_bits;
61254 +               int i;
61255 +
61256 +               multi_filter = kmalloc(AX_MCAST_FILTER_SIZE, GFP_ATOMIC);
61257 +               if (multi_filter == NULL) {
61258 +                       /* Oops, couldn't allocate a buffer for setting the multicast
61259 +                          filter. Try all multi mode. */
61260 +                       rx_ctl |= 0x02;
61261 +               } else {
61262 +                       memset(multi_filter, 0, AX_MCAST_FILTER_SIZE);
61263 +
61264 +                       /* Build the multicast hash filter. */
61265 +                       for (i = 0; i < net->mc_count; i++) {
61266 +                               crc_bits =
61267 +                                   ether_crc(ETH_ALEN,
61268 +                                             mc_list->dmi_addr) >> 26;
61269 +                               multi_filter[crc_bits >> 3] |=
61270 +                                   1 << (crc_bits & 7);
61271 +                               mc_list = mc_list->next;
61272 +                       }
61273 +
61274 +                       ax8817x_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
61275 +                                          AX_MCAST_FILTER_SIZE, multi_filter);
61276 +
61277 +                       rx_ctl |= 0x10;
61278 +               }
61279 +       }
61280 +
61281 +       ax8817x_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
61282 +}
61283 +
61284 +static int ax8817x_mdio_read(struct net_device *netdev, int phy_id, int loc)
61285 +{
61286 +       struct usbnet *dev = netdev->priv;
61287 +       u16 res;
61288 +       u8 buf[4];
61289 +
61290 +       ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf);
61291 +       ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, (u16 *)&res);
61292 +       ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf);
61293 +
61294 +       return res & 0xffff;
61295 +}
61296 +
61297 +static void ax8817x_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
61298 +{
61299 +       struct usbnet *dev = netdev->priv;
61300 +       u16 res = val;
61301 +       u8 buf[4];
61302 +
61303 +       ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf);
61304 +       ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, (u16 *)&res);
61305 +       ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf);
61306 +}
61307 +
61308 +static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
61309 +{
61310 +       int ret;
61311 +       u8 buf[6];
61312 +       u16 *buf16 = (u16 *) buf;
61313 +       int i;
61314 +
61315 +       dev->in = usb_rcvbulkpipe(dev->udev, 3);
61316 +       dev->out = usb_sndbulkpipe(dev->udev, 2);
61317 +
61318 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf)) < 0) {
61319 +               dbg("send AX_CMD_WRITE_RX_CTL failed: %d", ret);
61320 +               return ret;
61321 +       }
61322 +
61323 +       /* Get the MAC address */
61324 +       memset(buf, 0, ETH_ALEN);
61325 +       if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, 6, buf)) < 0) {
61326 +               dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
61327 +               return ret;
61328 +       }
61329 +       memcpy(dev->net->dev_addr, buf, ETH_ALEN);
61330 +
61331 +       /* Get IPG values */
61332 +       if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_IPG012, 0, 0, 3, buf)) < 0) {
61333 +               dbg("Error reading IPG values: %d", ret);
61334 +               return ret;
61335 +       }
61336 +
61337 +       for(i = 0;i < 3;i++) {
61338 +               ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0 + i, 0, 0, 1, &buf[i]);
61339 +       }
61340 +
61341 +       /* Get the PHY id */
61342 +       if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) {
61343 +               dbg("error on read AX_CMD_READ_PHY_ID: %02x", ret);
61344 +               return ret;
61345 +       } else if (ret < 2) {
61346 +               /* this should always return 2 bytes */
61347 +               dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", ret);
61348 +               return -EIO;
61349 +       }
61350 +
61351 +       /* Initialize MII structure */
61352 +       dev->mii.dev = dev->net;
61353 +       dev->mii.mdio_read = ax8817x_mdio_read;
61354 +       dev->mii.mdio_write = ax8817x_mdio_write;
61355 +       dev->mii.phy_id_mask = 0x3f;
61356 +       dev->mii.reg_num_mask = 0x1f;
61357 +       dev->mii.phy_id = buf[1];
61358 +
61359 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf)) < 0) {
61360 +               dbg("Failed to go to software MII mode: %02x", ret);
61361 +               return ret;
61362 +       }
61363 +
61364 +       *buf16 = cpu_to_le16(BMCR_RESET);
61365 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG,
61366 +                                    dev->mii.phy_id, MII_BMCR, 2, buf16)) < 0) {
61367 +               dbg("Failed to write MII reg - MII_BMCR: %02x", ret);
61368 +               return ret;
61369 +       }
61370 +
61371 +       /* Advertise that we can do full-duplex pause */
61372 +       *buf16 = cpu_to_le16(ADVERTISE_ALL | ADVERTISE_CSMA | 0x0400);
61373 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG,
61374 +                                    dev->mii.phy_id, MII_ADVERTISE, 
61375 +                                    2, buf16)) < 0) {
61376 +               dbg("Failed to write MII_REG advertisement: %02x", ret);
61377 +               return ret;
61378 +       }
61379 +
61380 +       *buf16 = cpu_to_le16(BMCR_ANENABLE | BMCR_ANRESTART);
61381 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG,
61382 +                                    dev->mii.phy_id, MII_BMCR, 
61383 +                                    2, buf16)) < 0) {
61384 +               dbg("Failed to write MII reg autonegotiate: %02x", ret);
61385 +               return ret;
61386 +       }
61387 +
61388 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf)) < 0) {
61389 +               dbg("Failed to set hardware MII: %02x", ret);
61390 +               return ret;
61391 +       }
61392 +
61393 +       dev->net->set_multicast_list = ax8817x_set_multicast;
61394 +
61395 +       return 0;
61396 +}
61397 +
61398 +static const struct driver_info ax8817x_info = {
61399 +       .description = "ASIX AX8817x USB 2.0 Ethernet",
61400 +       .bind = ax8817x_bind,
61401 +       .flags =  FLAG_ETHER,
61402 +};
61403 +#endif /* CONFIG_USB_AX8817X */
61404 +
61405  
61406  \f
61407  #ifdef CONFIG_USB_BELKIN
61408 @@ -470,7 +721,7 @@
61409         u8      bNumberPowerFilters;
61410  } __attribute__ ((packed));
61411  
61412 -struct cdc_info {
61413 +struct cdc_state {
61414         struct header_desc      *header;
61415         struct union_desc       *u;
61416         struct ether_desc       *ether;
61417 @@ -513,7 +764,7 @@
61418         u8                              *buf = intf->altsetting->extra;
61419         int                             len = intf->altsetting->extralen;
61420         struct usb_interface_descriptor *d;
61421 -       struct cdc_info                 *info = (void *) &dev->data;
61422 +       struct cdc_state                *info = (void *) &dev->data;
61423         int                             status;
61424  
61425         if (sizeof dev->data < sizeof *info)
61426 @@ -522,12 +773,15 @@
61427         /* expect strict spec conformance for the descriptors, but
61428          * cope with firmware which stores them in the wrong place
61429          */
61430 -       if (len == 0 && dev->udev->config->extralen) {
61431 -               /* Motorola SB4100 (and maybe others) put
61432 -                * CDC descriptors here
61433 +       if (len == 0 && dev->udev->actconfig->extralen) {
61434 +               /* Motorola SB4100 (and others: Brad Hards says it's
61435 +                * from a Broadcom design) put CDC descriptors here
61436                  */
61437 -               buf = dev->udev->config->extra;
61438 -               len = dev->udev->config->extralen;
61439 +               buf = dev->udev->actconfig->extra;
61440 +               len = dev->udev->actconfig->extralen;
61441 +               if (len)
61442 +                       dev_dbg (&intf->dev,
61443 +                               "CDC descriptors on config\n");
61444         }
61445  
61446         memset (info, 0, sizeof *info);
61447 @@ -542,48 +796,92 @@
61448                  */
61449                 switch (buf [2]) {
61450                 case 0x00:              /* Header, mostly useless */
61451 -                       if (info->header)
61452 +                       if (info->header) {
61453 +                               dev_dbg (&intf->dev, "extra CDC header\n");
61454                                 goto bad_desc;
61455 +                       }
61456                         info->header = (void *) buf;
61457 -                       if (info->header->bLength != sizeof *info->header)
61458 +                       if (info->header->bLength != sizeof *info->header) {
61459 +                               dev_dbg (&intf->dev, "CDC header len %u\n",
61460 +                                       info->header->bLength);
61461                                 goto bad_desc;
61462 +                       }
61463                         break;
61464                 case 0x06:              /* Union (groups interfaces) */
61465 -                       if (info->u)
61466 +                       if (info->u) {
61467 +                               dev_dbg (&intf->dev, "extra CDC union\n");
61468                                 goto bad_desc;
61469 +                       }
61470                         info->u = (void *) buf;
61471 -                       if (info->u->bLength != sizeof *info->u)
61472 -                               goto bad_desc;
61473 -                       d = &intf->altsetting->desc;
61474 -                       if (info->u->bMasterInterface0 != d->bInterfaceNumber)
61475 +                       if (info->u->bLength != sizeof *info->u) {
61476 +                               dev_dbg (&intf->dev, "CDC union len %u\n",
61477 +                                       info->u->bLength);
61478                                 goto bad_desc;
61479 -                       info->data = dev->udev->actconfig->interface[0];
61480 -                       if (intf != (info->data + info->u->bMasterInterface0))
61481 +                       }
61482 +
61483 +                       /* we need a master/control interface (what we're
61484 +                        * probed with) and a slave/data interface; union
61485 +                        * descriptors sort this all out.
61486 +                        */
61487 +                       info->control = usb_ifnum_to_if(dev->udev,
61488 +                                               info->u->bMasterInterface0);
61489 +                       info->data = usb_ifnum_to_if(dev->udev,
61490 +                                               info->u->bSlaveInterface0);
61491 +                       if (!info->control || !info->data) {
61492 +                               dev_dbg (&intf->dev,
61493 +                                       "master #%u/%p slave #%u/%p\n",
61494 +                                       info->u->bMasterInterface0
61495 +                                       info->control,
61496 +                                       info->u->bSlaveInterface0,
61497 +                                       info->data);
61498                                 goto bad_desc;
61499 +                       }
61500 +                       if (info->control != intf) {
61501 +                               dev_dbg (&intf->dev, "bogus CDC Union\n");
61502 +                               /* Ambit USB Cable Modem (and maybe others)
61503 +                                * interchanges master and slave interface.
61504 +                                */
61505 +                               if (info->data == intf) {
61506 +                                       info->data = info->control;
61507 +                                       info->control = intf;
61508 +                               } else
61509 +                                       goto bad_desc;
61510 +                       }
61511  
61512                         /* a data interface altsetting does the real i/o */
61513 -                       info->data += info->u->bSlaveInterface0;
61514                         d = &info->data->altsetting->desc;
61515 -                       if (info->u->bSlaveInterface0 != d->bInterfaceNumber
61516 -                                   || d->bInterfaceClass != USB_CLASS_CDC_DATA)
61517 +                       if (d->bInterfaceClass != USB_CLASS_CDC_DATA) {
61518 +                               dev_dbg (&intf->dev, "slave class %u\n",
61519 +                                       d->bInterfaceClass);
61520                                 goto bad_desc;
61521 +                       }
61522                         if (usb_interface_claimed (info->data))
61523                                 return -EBUSY;
61524                         break;
61525                 case 0x0F:              /* Ethernet Networking */
61526 -                       if (info->ether)
61527 +                       if (info->ether) {
61528 +                               dev_dbg (&intf->dev, "extra CDC ether\n");
61529                                 goto bad_desc;
61530 +                       }
61531                         info->ether = (void *) buf;
61532 -                       if (info->ether->bLength != sizeof *info->ether)
61533 +                       if (info->ether->bLength != sizeof *info->ether) {
61534 +                               dev_dbg (&intf->dev, "CDC ether len %u\n",
61535 +                                       info->u->bLength);
61536                                 goto bad_desc;
61537 +                       }
61538                         break;
61539                 }
61540  next_desc:
61541                 len -= buf [0]; /* bLength */
61542                 buf += buf [0];
61543         }
61544 -       if (!info->header || !info ->u || !info->ether)
61545 +       if (!info->header || !info ->u || !info->ether) {
61546 +               dev_dbg (&intf->dev, "missing cdc %s%s%sdescriptor\n",
61547 +                       info->header ? "" : "header ",
61548 +                       info->u ? "" : "union ",
61549 +                       info->ether ? "" : "ether ");
61550                 goto bad_desc;
61551 +       }
61552  
61553  #ifdef CONFIG_USB_ZAURUS
61554         /* Zaurus ethernet addresses aren't unique ... */
61555 @@ -624,7 +922,7 @@
61556  
61557  static void cdc_unbind (struct usbnet *dev, struct usb_interface *intf)
61558  {
61559 -       struct cdc_info                 *info = (void *) &dev->data;
61560 +       struct cdc_state                *info = (void *) &dev->data;
61561  
61562         /* disconnect master --> disconnect slave */
61563         if (intf == info->control && info->data) {
61564 @@ -2091,16 +2389,23 @@
61565         }
61566  
61567         netif_start_queue (net);
61568 -       if (dev->msg_level >= 2)
61569 +       if (dev->msg_level >= 2) {
61570 +               char    *framing;
61571 +
61572 +               if (dev->driver_info->flags & FLAG_FRAMING_NC)
61573 +                       framing = "NetChip";
61574 +               else if (dev->driver_info->flags & FLAG_FRAMING_GL)
61575 +                       framing = "GeneSys";
61576 +               else if (dev->driver_info->flags & FLAG_FRAMING_Z)
61577 +                       framing = "Zaurus";
61578 +               else
61579 +                       framing = "simple";
61580 +
61581                 devinfo (dev, "open: enable queueing "
61582                                 "(rx %d, tx %d) mtu %d %s framing",
61583                         RX_QLEN (dev), TX_QLEN (dev), dev->net->mtu,
61584 -                       (info->flags & (FLAG_FRAMING_NC | FLAG_FRAMING_GL))
61585 -                           ? ((info->flags & FLAG_FRAMING_NC)
61586 -                               ? "NetChip"
61587 -                               : "GeneSys")
61588 -                           : "raw"
61589 -                       );
61590 +                       framing);
61591 +       }
61592  
61593         // delay posting reads until we're fully open
61594         tasklet_schedule (&dev->bh);
61595 @@ -2173,12 +2478,20 @@
61596  
61597  static int usbnet_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
61598  {
61599 -       switch (cmd) {
61600 -       case SIOCETHTOOL:
61601 +       if (cmd == SIOCETHTOOL)
61602                 return usbnet_ethtool_ioctl (net, (void __user *)rq->ifr_data);
61603 -       default:
61604 -               return -EOPNOTSUPP;
61605 +
61606 +#ifdef NEED_MII
61607 +       {
61608 +       struct usbnet *dev = (struct usbnet *)net->priv;
61609 +
61610 +       if (dev->mii.mdio_read != NULL && dev->mii.mdio_write != NULL)
61611 +               return generic_mii_ioctl(&dev->mii,
61612 +                               (struct mii_ioctl_data *) &rq->ifr_data,
61613 +                               cmd, NULL);
61614         }
61615 +#endif
61616 +       return -EOPNOTSUPP;
61617  }
61618  
61619  /*-------------------------------------------------------------------------*/
61620 @@ -2342,7 +2655,7 @@
61621                 if (!((skb->len + sizeof *trailer) & 0x01))
61622                         *skb_put (skb, 1) = PAD_BYTE;
61623                 trailer = (struct nc_trailer *) skb_put (skb, sizeof *trailer);
61624 -       } 
61625 +       }
61626  #endif /* CONFIG_USB_NET1080 */
61627  
61628         usb_fill_bulk_urb (urb, dev->udev, dev->out,
61629 @@ -2670,6 +2983,30 @@
61630  },
61631  #endif
61632  
61633 +#ifdef CONFIG_USB_AX8817X
61634 +{
61635 +       // Linksys USB200M
61636 +       USB_DEVICE (0x077b, 0x2226),
61637 +       .driver_info =  (unsigned long) &ax8817x_info,
61638 +}, {
61639 +       // Netgear FA120
61640 +       USB_DEVICE (0x0846, 0x1040),
61641 +       .driver_info =  (unsigned long) &ax8817x_info,
61642 +}, {
61643 +       // DLink DUB-E100
61644 +       USB_DEVICE (0x2001, 0x1a00),
61645 +       .driver_info =  (unsigned long) &ax8817x_info,
61646 +}, {
61647 +       // Intellinet, ST Lab USB Ethernet
61648 +       USB_DEVICE (0x0b95, 0x1720),
61649 +       .driver_info =  (unsigned long) &ax8817x_info,
61650 +}, {
61651 +       // Hawking UF200, TrendNet TU2-ET100
61652 +       USB_DEVICE (0x07b8, 0x420a),
61653 +       .driver_info =  (unsigned long) &ax8817x_info,
61654 +}, 
61655 +#endif
61656 +
61657  #ifdef CONFIG_USB_EPSON2888
61658  {
61659         USB_DEVICE (0x0525, 0x2888),    // EPSON USB client
61660 @@ -2834,18 +3171,19 @@
61661  
61662  static int __init usbnet_init (void)
61663  {
61664 -       // compiler should optimize this out
61665 -       if (sizeof (((struct sk_buff *)0)->cb) < sizeof (struct skb_data))
61666 -               BUG ();
61667 +       // compiler should optimize these out
61668 +       BUG_ON (sizeof (((struct sk_buff *)0)->cb)
61669 +                       < sizeof (struct skb_data));
61670 +#ifdef CONFIG_USB_CDCETHER
61671 +       BUG_ON ((sizeof (((struct usbnet *)0)->data)
61672 +                       < sizeof (struct cdc_state)));
61673 +#endif
61674  
61675         get_random_bytes (node_id, sizeof node_id);
61676         node_id [0] &= 0xfe;    // clear multicast bit
61677         node_id [0] |= 0x02;    // set local assignment bit (IEEE802)
61678  
61679 -       if (usb_register (&usbnet_driver) < 0)
61680 -               return -1;
61681 -
61682 -       return 0;
61683 +       return usb_register(&usbnet_driver);
61684  }
61685  module_init (usbnet_init);
61686  
61687 diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
61688 --- a/drivers/usb/serial/belkin_sa.c    Wed Aug 13 03:06:57 2003
61689 +++ b/drivers/usb/serial/belkin_sa.c    Fri Aug 22 13:52:01 2003
61690 @@ -602,10 +602,19 @@
61691  
61692  static int __init belkin_sa_init (void)
61693  {
61694 -       usb_serial_register (&belkin_device);
61695 -       usb_register (&belkin_driver);
61696 +       int retval;
61697 +       retval = usb_serial_register(&belkin_device);
61698 +       if (retval)
61699 +               goto failed_usb_serial_register;
61700 +       retval = usb_register(&belkin_driver);
61701 +       if (retval)
61702 +               goto failed_usb_register;
61703         info(DRIVER_DESC " " DRIVER_VERSION);
61704         return 0;
61705 +failed_usb_register:
61706 +       usb_serial_deregister(&belkin_device);
61707 +failed_usb_serial_register:
61708 +       return retval;
61709  }
61710  
61711  
61712 diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
61713 --- a/drivers/usb/serial/cyberjack.c    Wed Aug 13 03:06:57 2003
61714 +++ b/drivers/usb/serial/cyberjack.c    Mon Aug 25 03:18:48 2003
61715 @@ -101,10 +101,11 @@
61716  };
61717  
61718  struct cyberjack_private {
61719 -       short   rdtodo;         /* Bytes still to read */
61720 +       spinlock_t      lock;           /* Lock for SMP */
61721 +       short           rdtodo;         /* Bytes still to read */
61722         unsigned char   wrbuf[5*64];    /* Buffer for collecting data to write */
61723 -       short   wrfilled;       /* Overall data size we already got */
61724 -       short   wrsent;         /* Data akready sent */
61725 +       short           wrfilled;       /* Overall data size we already got */
61726 +       short           wrsent;         /* Data akready sent */
61727  };
61728  
61729  /* do some startup allocations not currently performed by usb_serial_probe() */
61730 @@ -120,6 +121,7 @@
61731                 return -ENOMEM;
61732  
61733         /* set initial values */
61734 +       spin_lock_init(&priv->lock);
61735         priv->rdtodo = 0;
61736         priv->wrfilled = 0;
61737         priv->wrsent = 0;
61738 @@ -146,6 +148,7 @@
61739  static int  cyberjack_open (struct usb_serial_port *port, struct file *filp)
61740  {
61741         struct cyberjack_private *priv;
61742 +       unsigned long flags;
61743         int result = 0;
61744  
61745         if (port_paranoia_check (port, __FUNCTION__))
61746 @@ -160,9 +163,11 @@
61747         port->tty->low_latency = 1;
61748  
61749         priv = usb_get_serial_port_data(port);
61750 +       spin_lock_irqsave(&priv->lock, flags);
61751         priv->rdtodo = 0;
61752         priv->wrfilled = 0;
61753         priv->wrsent = 0;
61754 +       spin_unlock_irqrestore(&priv->lock, flags);
61755  
61756         /* shutdown any bulk reads that might be going on */
61757         usb_unlink_urb (port->write_urb);
61758 @@ -194,6 +199,7 @@
61759  {
61760         struct usb_serial *serial = port->serial;
61761         struct cyberjack_private *priv = usb_get_serial_port_data(port);
61762 +       unsigned long flags;
61763         int result;
61764         int wrexpected;
61765  
61766 @@ -210,15 +216,19 @@
61767                 return (0);
61768         }
61769  
61770 +       spin_lock_irqsave(&priv->lock, flags);
61771 +
61772         if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ) {
61773                 /* To much data  for buffer. Reset buffer. */
61774                 priv->wrfilled=0;
61775 +               spin_unlock_irqrestore(&priv->lock, flags);
61776                 return (0);
61777         }
61778  
61779         /* Copy data */
61780         if (from_user) {
61781                 if (copy_from_user(priv->wrbuf+priv->wrfilled, buf, count)) {
61782 +                       spin_unlock_irqrestore(&priv->lock, flags);
61783                         return -EFAULT;
61784                 }
61785         } else {
61786 @@ -261,6 +271,7 @@
61787                         /* Throw away data. No better idea what to do with it. */
61788                         priv->wrfilled=0;
61789                         priv->wrsent=0;
61790 +                       spin_unlock_irqrestore(&priv->lock, flags);
61791                         return 0;
61792                 }
61793  
61794 @@ -275,6 +286,8 @@
61795                 }
61796         }
61797  
61798 +       spin_unlock_irqrestore(&priv->lock, flags);
61799 +
61800         return (count);
61801  } 
61802  
61803 @@ -282,8 +295,10 @@
61804  {
61805         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
61806         struct cyberjack_private *priv = usb_get_serial_port_data(port);
61807 +       unsigned long flags;
61808         struct usb_serial *serial;
61809         unsigned char *data = urb->transfer_buffer;
61810 +       int result;
61811  
61812         if (port_paranoia_check (port, __FUNCTION__))
61813                 return;
61814 @@ -302,21 +317,20 @@
61815  
61816         /* React only to interrupts signaling a bulk_in transfer */
61817         if( (urb->actual_length==4) && (data[0]==0x01) ) {
61818 -               short old_rdtodo = priv->rdtodo;
61819 +               short old_rdtodo;
61820                 int result;
61821  
61822                 /* This is a announcement of coming bulk_ins. */
61823                 unsigned short size = ((unsigned short)data[3]<<8)+data[2]+3;
61824  
61825 -               if( (size>259) || (size==0) ) {
61826 -                       dbg( "Bad announced bulk_in data length: %d", size );
61827 -                       /* Dunno what is most reliable to do here. */
61828 -                       /* return; */
61829 -               }
61830 +               spin_lock_irqsave(&priv->lock, flags);
61831 +
61832 +               old_rdtodo = priv->rdtodo;
61833  
61834                 if( (old_rdtodo+size)<(old_rdtodo) ) {
61835                         dbg( "To many bulk_in urbs to do." );
61836 -                       return;
61837 +                       spin_unlock_irqrestore(&priv->lock, flags);
61838 +                       goto resubmit;
61839                 }
61840  
61841                 /* "+=" is probably more fault tollerant than "=" */
61842 @@ -324,23 +338,34 @@
61843  
61844                 dbg("%s - rdtodo: %d", __FUNCTION__, priv->rdtodo);
61845  
61846 +               spin_unlock_irqrestore(&priv->lock, flags);
61847 +
61848                 if( !old_rdtodo ) {
61849                         port->read_urb->dev = port->serial->dev;
61850 -                       result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
61851 +                       result = usb_submit_urb(port->read_urb, GFP_KERNEL);
61852                         if( result )
61853                                 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
61854                         dbg("%s - usb_submit_urb(read urb)", __FUNCTION__);
61855                 }
61856         }
61857 +
61858 +resubmit:
61859 +       port->interrupt_in_urb->dev = port->serial->dev;
61860 +       result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
61861 +       if (result)
61862 +               err(" usb_submit_urb(read int) failed");
61863 +       dbg("%s - usb_submit_urb(int urb)", __FUNCTION__);
61864  }
61865  
61866  static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
61867  {
61868         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
61869         struct cyberjack_private *priv = usb_get_serial_port_data(port);
61870 +       unsigned long flags;
61871         struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
61872         struct tty_struct *tty;
61873         unsigned char *data = urb->transfer_buffer;
61874 +       short todo;
61875         int i;
61876         int result;
61877  
61878 @@ -372,18 +397,22 @@
61879                 tty_flip_buffer_push(tty);
61880         }
61881  
61882 +       spin_lock_irqsave(&priv->lock, flags);
61883 +
61884         /* Reduce urbs to do by one. */
61885         priv->rdtodo-=urb->actual_length;
61886         /* Just to be sure */
61887 -       if ( priv->rdtodo<0 )
61888 -               priv->rdtodo = 0;
61889 +       if ( priv->rdtodo<0 ) priv->rdtodo = 0;
61890 +       todo = priv->rdtodo;
61891  
61892 -       dbg("%s - rdtodo: %d", __FUNCTION__, priv->rdtodo);
61893 +       spin_unlock_irqrestore(&priv->lock, flags);
61894 +
61895 +       dbg("%s - rdtodo: %d", __FUNCTION__, todo);
61896  
61897         /* Continue to read if we have still urbs to do. */
61898 -       if( priv->rdtodo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) {
61899 +       if( todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) {
61900                 port->read_urb->dev = port->serial->dev;
61901 -               result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
61902 +               result = usb_submit_urb(port->read_urb, GFP_KERNEL);
61903                 if (result)
61904                         err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
61905                 dbg("%s - usb_submit_urb(read urb)", __FUNCTION__);
61906 @@ -394,6 +423,7 @@
61907  {
61908         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
61909         struct cyberjack_private *priv = usb_get_serial_port_data(port);
61910 +       unsigned long flags;
61911         struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
61912  
61913         dbg("%s - port %d", __FUNCTION__, port->number);
61914 @@ -408,12 +438,15 @@
61915                 return;
61916         }
61917  
61918 +       spin_lock_irqsave(&priv->lock, flags);
61919 +
61920         /* only do something if we have more data to send */
61921         if( priv->wrfilled ) {
61922                 int length, blksize, result;
61923  
61924                 if (port->write_urb->status == -EINPROGRESS) {
61925                         dbg("%s - already writing", __FUNCTION__);
61926 +                       spin_unlock_irqrestore(&priv->lock, flags);
61927                         return;
61928                 }
61929  
61930 @@ -459,18 +492,28 @@
61931         }
61932  
61933  exit:
61934 +       spin_unlock_irqrestore(&priv->lock, flags);
61935         schedule_work(&port->work);
61936  }
61937  
61938  static int __init cyberjack_init (void)
61939  {
61940 -       usb_serial_register (&cyberjack_device);
61941 -       usb_register (&cyberjack_driver);
61942 +       int retval;
61943 +       retval  = usb_serial_register(&cyberjack_device);
61944 +       if (retval)
61945 +               goto failed_usb_serial_register;
61946 +       retval = usb_register(&cyberjack_driver);
61947 +       if (retval) 
61948 +               goto failed_usb_register;
61949  
61950         info(DRIVER_VERSION " " DRIVER_AUTHOR);
61951         info(DRIVER_DESC);
61952  
61953         return 0;
61954 +failed_usb_register:
61955 +       usb_serial_deregister(&cyberjack_device);
61956 +failed_usb_serial_register:
61957 +       return retval;
61958  }
61959  
61960  static void __exit cyberjack_exit (void)
61961 diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
61962 --- a/drivers/usb/serial/digi_acceleport.c      Wed Aug 13 03:06:57 2003
61963 +++ b/drivers/usb/serial/digi_acceleport.c      Tue Sep  2 11:40:28 2003
61964 @@ -218,7 +218,7 @@
61965  *    interrupt time.
61966  *  - digi_write_bulk_callback() and digi_read_bulk_callback() are
61967  *    called directly from interrupts.  Hence spin_lock_irqsave()
61968 -*    and spin_lock_irqrestore() are used in the rest of the code
61969 +*    and spin_unlock_irqrestore() are used in the rest of the code
61970  *    for any locks they acquire.
61971  *  - digi_write_bulk_callback() gets the port lock before waking up
61972  *    processes sleeping on the port write_wait.  It also schedules
61973 @@ -571,7 +571,7 @@
61974  *
61975  *  Do spin_unlock_irqrestore and interruptible_sleep_on_timeout
61976  *  so that wake ups are not lost if they occur between the unlock
61977 -*  and the sleep.  In other words, spin_lock_irqrestore and
61978 +*  and the sleep.  In other words, spin_unlock_irqrestore and
61979  *  interruptible_sleep_on_timeout are "atomic" with respect to
61980  *  wake ups.  This is used to implement condition variables.
61981  */
61982 @@ -2045,11 +2045,24 @@
61983  
61984  static int __init digi_init (void)
61985  {
61986 -       usb_serial_register (&digi_acceleport_2_device);
61987 -       usb_serial_register (&digi_acceleport_4_device);
61988 -       usb_register (&digi_driver);
61989 +       int retval;
61990 +       retval = usb_serial_register(&digi_acceleport_2_device);
61991 +       if (retval)
61992 +               goto failed_acceleport_2_device;
61993 +       retval = usb_serial_register(&digi_acceleport_4_device);
61994 +       if (retval) 
61995 +               goto failed_acceleport_4_device;
61996 +       retval = usb_register(&digi_driver);
61997 +       if (retval)
61998 +               goto failed_usb_register;
61999         info(DRIVER_VERSION ":" DRIVER_DESC);
62000         return 0;
62001 +failed_usb_register:
62002 +       usb_serial_deregister(&digi_acceleport_4_device);
62003 +failed_acceleport_4_device:
62004 +       usb_serial_deregister(&digi_acceleport_2_device);
62005 +failed_acceleport_2_device:
62006 +       return retval;
62007  }
62008  
62009  
62010 diff -Nru a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
62011 --- a/drivers/usb/serial/empeg.c        Mon Aug 11 07:56:25 2003
62012 +++ b/drivers/usb/serial/empeg.c        Fri Aug 22 13:52:01 2003
62013 @@ -558,7 +558,7 @@
62014  static int __init empeg_init (void)
62015  {
62016         struct urb *urb;
62017 -       int i;
62018 +       int i, retval;
62019  
62020         /* create our write urb pool and transfer buffers */ 
62021         spin_lock_init (&write_urb_pool_lock);
62022 @@ -570,7 +570,6 @@
62023                         continue;
62024                 }
62025  
62026 -               urb->transfer_buffer = NULL;
62027                 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
62028                 if (!urb->transfer_buffer) {
62029                         err("%s - out of memory for urb buffers.", 
62030 @@ -579,12 +578,27 @@
62031                 }
62032         }
62033  
62034 -       usb_serial_register (&empeg_device);
62035 -       usb_register (&empeg_driver);
62036 +       retval = usb_serial_register(&empeg_device);
62037 +       if (retval)
62038 +               goto failed_usb_serial_register;
62039 +       retval = usb_register(&empeg_driver);
62040 +       if (retval)
62041 +               goto failed_usb_register;
62042  
62043         info(DRIVER_VERSION ":" DRIVER_DESC);
62044  
62045         return 0;
62046 +failed_usb_register:
62047 +       usb_serial_deregister(&empeg_device);
62048 +failed_usb_serial_register:
62049 +       for (i = 0; i < NUM_URBS; ++i) {
62050 +               if (write_urb_pool[i]) {
62051 +                       if (write_urb_pool[i]->transfer_buffer)
62052 +                               kfree(write_urb_pool[i]->transfer_buffer);
62053 +                       usb_free_urb(write_urb_pool[i]);
62054 +               }
62055 +       }
62056 +       return retval;
62057  }
62058  
62059  
62060 @@ -593,7 +607,7 @@
62061         int i;
62062         unsigned long flags;
62063  
62064 -       usb_register (&empeg_driver);
62065 +       usb_deregister(&empeg_driver);
62066         usb_serial_deregister (&empeg_device);
62067  
62068         spin_lock_irqsave (&write_urb_pool_lock, flags);
62069 diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
62070 --- a/drivers/usb/serial/ftdi_sio.c     Wed Aug 13 03:06:57 2003
62071 +++ b/drivers/usb/serial/ftdi_sio.c     Tue Aug 19 05:26:50 2003
62072 @@ -17,6 +17,11 @@
62073   * See http://ftdi-usb-sio.sourceforge.net for upto date testing info
62074   *     and extra documentation
62075   *
62076 + * (19/Aug/2003) Ian Abbott
62077 + *      Freed urb's transfer buffer in write bulk callback.
62078 + *      Omitted some paranoid checks in write bulk callback that don't matter.
62079 + *      Scheduled work in write bulk callback regardless of port's open count.
62080 + *
62081   * (05/Aug/2003) Ian Abbott
62082   *      Added VID/PID for ID TECH IDT1221U USB to RS-232 adapter.
62083   *      VID/PID provided by Steve Briggs.
62084 @@ -1391,31 +1396,21 @@
62085  static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
62086  {
62087         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
62088 -       struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
62089  
62090 -       dbg("%s", __FUNCTION__);
62091 +       /* free up the transfer buffer, as usb_free_urb() does not do this */
62092 +       kfree (urb->transfer_buffer);
62093  
62094         if (port_paranoia_check (port, __FUNCTION__))
62095                 return;
62096         
62097 +       dbg("%s - port %d", __FUNCTION__, port->number);
62098 +       
62099         if (urb->status) {
62100                 dbg("nonzero write bulk status received: %d", urb->status);
62101                 return;
62102         }
62103  
62104 -       if (!serial) {
62105 -               dbg("%s - bad serial pointer, exiting", __FUNCTION__);
62106 -               return;
62107 -       }
62108 -
62109 -       /* Have to check for validity of queueing up the tasks */
62110 -       dbg("%s - port->open_count = %d", __FUNCTION__, port->open_count);
62111 -
62112 -       if (port->open_count > 0){
62113 -               schedule_work(&port->work);
62114 -       } 
62115 -
62116 -       return;
62117 +       schedule_work(&port->work);
62118  } /* ftdi_write_bulk_callback */
62119  
62120  
62121 @@ -1999,17 +1994,42 @@
62122  
62123  static int __init ftdi_init (void)
62124  {
62125 +       int retval;
62126  
62127         dbg("%s", __FUNCTION__);
62128 -       usb_serial_register (&ftdi_SIO_device);
62129 -       usb_serial_register (&ftdi_8U232AM_device);
62130 -       usb_serial_register (&ftdi_FT232BM_device);
62131 -       usb_serial_register (&ftdi_USB_UIRT_device);
62132 -       usb_serial_register (&ftdi_HE_TIRA1_device);
62133 -       usb_register (&ftdi_driver);
62134 +       retval = usb_serial_register(&ftdi_SIO_device);
62135 +       if (retval)
62136 +               goto failed_SIO_register;
62137 +       retval = usb_serial_register(&ftdi_8U232AM_device);
62138 +       if (retval)
62139 +               goto failed_8U232AM_register;
62140 +       retval = usb_serial_register(&ftdi_FT232BM_device);
62141 +       if (retval)
62142 +               goto failed_FT232BM_register;
62143 +       retval = usb_serial_register(&ftdi_USB_UIRT_device);
62144 +       if (retval)
62145 +               goto failed_USB_UIRT_register;
62146 +       retval = usb_serial_register(&ftdi_HE_TIRA1_device);
62147 +       if (retval)
62148 +               goto failed_HE_TIRA1_register;
62149 +       retval = usb_register(&ftdi_driver);
62150 +       if (retval) 
62151 +               goto failed_usb_register;
62152  
62153         info(DRIVER_VERSION ":" DRIVER_DESC);
62154         return 0;
62155 +failed_usb_register:
62156 +       usb_serial_deregister(&ftdi_HE_TIRA1_device);
62157 +failed_HE_TIRA1_register:
62158 +       usb_serial_deregister(&ftdi_USB_UIRT_device);
62159 +failed_USB_UIRT_register:
62160 +       usb_serial_deregister(&ftdi_FT232BM_device);
62161 +failed_FT232BM_register:
62162 +       usb_serial_deregister(&ftdi_8U232AM_device);
62163 +failed_8U232AM_register:
62164 +       usb_serial_deregister(&ftdi_SIO_device);
62165 +failed_SIO_register:
62166 +       return retval;
62167  }
62168  
62169  
62170 diff -Nru a/drivers/usb/serial/io_16654.h b/drivers/usb/serial/io_16654.h
62171 --- a/drivers/usb/serial/io_16654.h     Mon Feb  4 23:38:25 2002
62172 +++ b/drivers/usb/serial/io_16654.h     Sat Aug 23 12:56:34 2003
62173 @@ -2,7 +2,7 @@
62174   *
62175   *     16654.H         Definitions for 16C654 UART used on EdgePorts
62176   *
62177 - *     Copyright (c) 1998 Inside Out Networks, Inc.
62178 + *     Copyright (C) 1998 Inside Out Networks, Inc.
62179   *     This program is free software; you can redistribute it and/or modify
62180   *     it under the terms of the GNU General Public License as published by
62181   *     the Free Software Foundation; either version 2 of the License, or
62182 @@ -142,14 +142,14 @@
62183  #define LSR_FIFO_ERR           0x80    // Rx Fifo contains at least 1 erred char
62184  
62185  
62186 -#define MSR_DELTA_CTS          0x01    // CTS changed from last read
62187 -#define MSR_DELTA_DSR          0x02    // DSR changed from last read
62188 -#define MSR_DELTA_RI           0x04    // RI  changed from 0 -> 1
62189 -#define MSR_DELTA_CD           0x08    // CD  changed from last read
62190 -#define MSR_CTS                        0x10    // Current state of CTS
62191 -#define MSR_DSR                        0x20    // Current state of DSR
62192 -#define MSR_RI                 0x40    // Current state of RI
62193 -#define MSR_CD                 0x80    // Current state of CD
62194 +#define EDGEPORT_MSR_DELTA_CTS 0x01    // CTS changed from last read
62195 +#define EDGEPORT_MSR_DELTA_DSR 0x02    // DSR changed from last read
62196 +#define EDGEPORT_MSR_DELTA_RI  0x04    // RI  changed from 0 -> 1
62197 +#define EDGEPORT_MSR_DELTA_CD  0x08    // CD  changed from last read
62198 +#define EDGEPORT_MSR_CTS       0x10    // Current state of CTS
62199 +#define EDGEPORT_MSR_DSR       0x20    // Current state of DSR
62200 +#define EDGEPORT_MSR_RI                0x40    // Current state of RI
62201 +#define EDGEPORT_MSR_CD                0x80    // Current state of CD
62202  
62203  
62204  
62205 diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
62206 --- a/drivers/usb/serial/io_edgeport.c  Wed Aug 13 03:06:57 2003
62207 +++ b/drivers/usb/serial/io_edgeport.c  Sat Aug 23 12:56:50 2003
62208 @@ -1,8 +1,8 @@
62209  /*
62210   * Edgeport USB Serial Converter driver
62211   *
62212 - * Copyright(c) 2000 Inside Out Networks, All rights reserved.
62213 - * Copyright(c) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
62214 + * Copyright (C) 2000 Inside Out Networks, All rights reserved.
62215 + * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
62216   *
62217   *     This program is free software; you can redistribute it and/or modify
62218   *     it under the terms of the GNU General Public License as published by
62219 @@ -1806,10 +1806,10 @@
62220         mcr = edge_port->shadowMCR;
62221         result = ((mcr & MCR_DTR)       ? TIOCM_DTR: 0)   /* 0x002 */
62222                   | ((mcr & MCR_RTS)    ? TIOCM_RTS: 0)   /* 0x004 */
62223 -                 | ((msr & MSR_CTS)    ? TIOCM_CTS: 0)   /* 0x020 */
62224 -                 | ((msr & MSR_CD)     ? TIOCM_CAR: 0)   /* 0x040 */
62225 -                 | ((msr & MSR_RI)     ? TIOCM_RI:  0)   /* 0x080 */
62226 -                 | ((msr & MSR_DSR)    ? TIOCM_DSR: 0);  /* 0x100 */
62227 +                 | ((msr & EDGEPORT_MSR_CTS)   ? TIOCM_CTS: 0)   /* 0x020 */
62228 +                 | ((msr & EDGEPORT_MSR_CD)    ? TIOCM_CAR: 0)   /* 0x040 */
62229 +                 | ((msr & EDGEPORT_MSR_RI)    ? TIOCM_RI:  0)   /* 0x080 */
62230 +                 | ((msr & EDGEPORT_MSR_DSR)   ? TIOCM_DSR: 0);  /* 0x100 */
62231  
62232  
62233         dbg("%s -- %x", __FUNCTION__, result);
62234 @@ -2221,20 +2221,20 @@
62235  
62236         dbg("%s %02x", __FUNCTION__, newMsr);
62237  
62238 -       if (newMsr & (MSR_DELTA_CTS | MSR_DELTA_DSR | MSR_DELTA_RI | MSR_DELTA_CD)) {
62239 +       if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
62240                 icount = &edge_port->icount;
62241  
62242                 /* update input line counters */
62243 -               if (newMsr & MSR_DELTA_CTS) {
62244 +               if (newMsr & EDGEPORT_MSR_DELTA_CTS) {
62245                         icount->cts++;
62246                 }
62247 -               if (newMsr & MSR_DELTA_DSR) {
62248 +               if (newMsr & EDGEPORT_MSR_DELTA_DSR) {
62249                         icount->dsr++;
62250                 }
62251 -               if (newMsr & MSR_DELTA_CD) {
62252 +               if (newMsr & EDGEPORT_MSR_DELTA_CD) {
62253                         icount->dcd++;
62254                 }
62255 -               if (newMsr & MSR_DELTA_RI) {
62256 +               if (newMsr & EDGEPORT_MSR_DELTA_RI) {
62257                         icount->rng++;
62258                 }
62259                 wake_up_interruptible(&edge_port->delta_msr_wait);
62260 @@ -3051,15 +3051,36 @@
62261   * edgeport_init
62262   *     This is called by the module subsystem, or on startup to initialize us
62263   ****************************************************************************/
62264 -int __init edgeport_init(void)
62265 +static int __init edgeport_init(void)
62266  {
62267 -       usb_serial_register (&edgeport_1port_device);
62268 -       usb_serial_register (&edgeport_2port_device);
62269 -       usb_serial_register (&edgeport_4port_device);
62270 -       usb_serial_register (&edgeport_8port_device);
62271 -       usb_register (&io_driver);
62272 +       int retval;
62273 +       retval = usb_serial_register(&edgeport_1port_device);
62274 +       if (retval) 
62275 +               goto failed_1port_device_register;
62276 +       retval = usb_serial_register(&edgeport_2port_device);
62277 +       if (retval)
62278 +               goto failed_2port_device_register;
62279 +       retval = usb_serial_register(&edgeport_4port_device);
62280 +       if (retval)
62281 +               goto failed_4port_device_register;
62282 +       retval = usb_serial_register(&edgeport_8port_device);
62283 +       if (retval)
62284 +               goto failed_8port_device_register;
62285 +       retval = usb_register(&io_driver);
62286 +       if (retval) 
62287 +               goto failed_usb_register;
62288         info(DRIVER_DESC " " DRIVER_VERSION);
62289         return 0;
62290 +failed_usb_register:
62291 +       usb_serial_deregister(&edgeport_8port_device);
62292 +failed_8port_device_register:
62293 +       usb_serial_deregister(&edgeport_4port_device);
62294 +failed_4port_device_register:
62295 +       usb_serial_deregister(&edgeport_2port_device);
62296 +failed_2port_device_register:
62297 +       usb_serial_deregister(&edgeport_1port_device);
62298 +failed_1port_device_register:
62299 +       return retval;
62300  }
62301  
62302  
62303 @@ -3068,7 +3089,7 @@
62304   * edgeport_exit
62305   *     Called when the driver is about to be unloaded.
62306   ****************************************************************************/
62307 -void __exit edgeport_exit (void)
62308 +static void __exit edgeport_exit (void)
62309  {
62310         usb_deregister (&io_driver);
62311         usb_serial_deregister (&edgeport_1port_device);
62312 diff -Nru a/drivers/usb/serial/io_edgeport.h b/drivers/usb/serial/io_edgeport.h
62313 --- a/drivers/usb/serial/io_edgeport.h  Mon Feb 11 13:54:53 2002
62314 +++ b/drivers/usb/serial/io_edgeport.h  Wed Aug 27 04:45:14 2003
62315 @@ -2,7 +2,7 @@
62316   *
62317   *     io_edgeport.h   Edgeport Linux Interface definitions
62318   *
62319 - *     Copyright (c) 2000 Inside Out Networks, Inc.
62320 + *     Copyright (C) 2000 Inside Out Networks, Inc.
62321   *
62322   *     This program is free software; you can redistribute it and/or modify
62323   *     it under the terms of the GNU General Public License as published by
62324 diff -Nru a/drivers/usb/serial/io_fw_boot.h b/drivers/usb/serial/io_fw_boot.h
62325 --- a/drivers/usb/serial/io_fw_boot.h   Mon Feb 11 13:54:53 2002
62326 +++ b/drivers/usb/serial/io_fw_boot.h   Wed Aug 27 04:45:13 2003
62327 @@ -1,7 +1,7 @@
62328  //**************************************************************
62329  //* Edgeport/4 Binary Image
62330  //* Generated by HEX2C v1.06
62331 -//* Copyright(c) 1998 Inside Out Networks, All rights reserved.
62332 +//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
62333  //*    This program is free software; you can redistribute it and/or modify
62334  //*    it under the terms of the GNU General Public License as published by
62335  //*    the Free Software Foundation; either version 2 of the License, or
62336 diff -Nru a/drivers/usb/serial/io_fw_boot2.h b/drivers/usb/serial/io_fw_boot2.h
62337 --- a/drivers/usb/serial/io_fw_boot2.h  Mon Feb 11 13:54:53 2002
62338 +++ b/drivers/usb/serial/io_fw_boot2.h  Wed Aug 27 04:45:14 2003
62339 @@ -1,7 +1,7 @@
62340  //**************************************************************
62341  //* Edgeport/4 Binary Image
62342  //* Generated by HEX2C v1.06
62343 -//* Copyright(c) 1998 Inside Out Networks, All rights reserved.
62344 +//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
62345  //*    This program is free software; you can redistribute it and/or modify
62346  //*    it under the terms of the GNU General Public License as published by
62347  //*    the Free Software Foundation; either version 2 of the License, or
62348 diff -Nru a/drivers/usb/serial/io_fw_down.h b/drivers/usb/serial/io_fw_down.h
62349 --- a/drivers/usb/serial/io_fw_down.h   Mon Feb 11 13:54:53 2002
62350 +++ b/drivers/usb/serial/io_fw_down.h   Wed Aug 27 04:45:14 2003
62351 @@ -1,7 +1,7 @@
62352  //**************************************************************
62353  //* Edgeport/4 Binary Image
62354  //* Generated by HEX2C v1.06
62355 -//* Copyright(c) 1998 Inside Out Networks, All rights reserved.
62356 +//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
62357  //*    This program is free software; you can redistribute it and/or modify
62358  //*    it under the terms of the GNU General Public License as published by
62359  //*    the Free Software Foundation; either version 2 of the License, or
62360 diff -Nru a/drivers/usb/serial/io_fw_down2.h b/drivers/usb/serial/io_fw_down2.h
62361 --- a/drivers/usb/serial/io_fw_down2.h  Mon Feb 11 13:54:53 2002
62362 +++ b/drivers/usb/serial/io_fw_down2.h  Wed Aug 27 04:45:14 2003
62363 @@ -1,7 +1,7 @@
62364  //**************************************************************
62365  //* Edgeport/4 Binary Image
62366  //* Generated by HEX2C v1.06
62367 -//* Copyright(c) 1998 Inside Out Networks, All rights reserved.
62368 +//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
62369  //*    This program is free software; you can redistribute it and/or modify
62370  //*    it under the terms of the GNU General Public License as published by
62371  //*    the Free Software Foundation; either version 2 of the License, or
62372 diff -Nru a/drivers/usb/serial/io_fw_down3.h b/drivers/usb/serial/io_fw_down3.h
62373 --- a/drivers/usb/serial/io_fw_down3.h  Fri Jul 26 11:59:43 2002
62374 +++ b/drivers/usb/serial/io_fw_down3.h  Wed Aug 27 04:45:13 2003
62375 @@ -1,7 +1,7 @@
62376  //**************************************************************
62377  //* Edgeport Binary Image (for TI based products)
62378  //* Generated by TIBin2C v1.00
62379 -//* Copyright(c) 2001 Inside Out Networks, All rights reserved.
62380 +//* Copyright (C) 2001 Inside Out Networks, All rights reserved.
62381  //**************************************************************
62382  
62383  
62384 diff -Nru a/drivers/usb/serial/io_ionsp.h b/drivers/usb/serial/io_ionsp.h
62385 --- a/drivers/usb/serial/io_ionsp.h     Thu Mar 13 10:36:02 2003
62386 +++ b/drivers/usb/serial/io_ionsp.h     Wed Aug 27 04:45:13 2003
62387 @@ -2,7 +2,7 @@
62388   *
62389   *     IONSP.H         Definitions for I/O Networks Serial Protocol
62390   *
62391 - *     Copyright (c) 1997-1998 Inside Out Networks, Inc.
62392 + *     Copyright (C) 1997-1998 Inside Out Networks, Inc.
62393   *
62394   *     This program is free software; you can redistribute it and/or modify
62395   *     it under the terms of the GNU General Public License as published by
62396 diff -Nru a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
62397 --- a/drivers/usb/serial/io_ti.c        Wed Aug 13 03:06:57 2003
62398 +++ b/drivers/usb/serial/io_ti.c        Sat Aug 23 12:57:20 2003
62399 @@ -1,8 +1,8 @@
62400  /*
62401   * Edgeport USB Serial Converter driver
62402   *
62403 - * Copyright(c) 2000-2002 Inside Out Networks, All rights reserved.
62404 - * Copyright(c) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
62405 + * Copyright (C) 2000-2002 Inside Out Networks, All rights reserved.
62406 + * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
62407   *
62408   *     This program is free software; you can redistribute it and/or modify
62409   *     it under the terms of the GNU General Public License as published by
62410 @@ -127,6 +127,7 @@
62411  
62412  static struct usb_device_id edgeport_2port_id_table [] = {
62413         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) },
62414 +       { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) },
62415         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) },
62416         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421) },
62417         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421_BOOT) },
62418 @@ -145,6 +146,7 @@
62419  static struct usb_device_id id_table_combined [] = {
62420         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) },
62421         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) },
62422 +       { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) },
62423         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) },
62424         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421) },
62425         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421_BOOT) },
62426 @@ -1575,17 +1577,17 @@
62427  
62428         dbg ("%s - %02x", __FUNCTION__, msr);
62429  
62430 -       if (msr & (MSR_DELTA_CTS | MSR_DELTA_DSR | MSR_DELTA_RI | MSR_DELTA_CD)) {
62431 +       if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
62432                 icount = &edge_port->icount;
62433  
62434                 /* update input line counters */
62435 -               if (msr & MSR_DELTA_CTS)
62436 +               if (msr & EDGEPORT_MSR_DELTA_CTS)
62437                         icount->cts++;
62438 -               if (msr & MSR_DELTA_DSR)
62439 +               if (msr & EDGEPORT_MSR_DELTA_DSR)
62440                         icount->dsr++;
62441 -               if (msr & MSR_DELTA_CD)
62442 +               if (msr & EDGEPORT_MSR_DELTA_CD)
62443                         icount->dcd++;
62444 -               if (msr & MSR_DELTA_RI)
62445 +               if (msr & EDGEPORT_MSR_DELTA_RI)
62446                         icount->rng++;
62447                 wake_up_interruptible (&edge_port->delta_msr_wait);
62448         }
62449 @@ -2447,10 +2449,10 @@
62450         mcr = edge_port->shadow_mcr;
62451         result = ((mcr & MCR_DTR)       ? TIOCM_DTR: 0)   /* 0x002 */
62452                   | ((mcr & MCR_RTS)    ? TIOCM_RTS: 0)   /* 0x004 */
62453 -                 | ((msr & MSR_CTS)    ? TIOCM_CTS: 0)   /* 0x020 */
62454 -                 | ((msr & MSR_CD)     ? TIOCM_CAR: 0)   /* 0x040 */
62455 -                 | ((msr & MSR_RI)     ? TIOCM_RI:  0)   /* 0x080 */
62456 -                 | ((msr & MSR_DSR)    ? TIOCM_DSR: 0);  /* 0x100 */
62457 +                 | ((msr & EDGEPORT_MSR_CTS)   ? TIOCM_CTS: 0)   /* 0x020 */
62458 +                 | ((msr & EDGEPORT_MSR_CD)    ? TIOCM_CAR: 0)   /* 0x040 */
62459 +                 | ((msr & EDGEPORT_MSR_RI)    ? TIOCM_RI:  0)   /* 0x080 */
62460 +                 | ((msr & EDGEPORT_MSR_DSR)   ? TIOCM_DSR: 0);  /* 0x100 */
62461  
62462  
62463         dbg("%s -- %x", __FUNCTION__, result);
62464 @@ -2679,11 +2681,24 @@
62465  
62466  static int __init edgeport_init(void)
62467  {
62468 -       usb_serial_register (&edgeport_1port_device);
62469 -       usb_serial_register (&edgeport_2port_device);
62470 -       usb_register (&io_driver);
62471 +       int retval;
62472 +       retval = usb_serial_register(&edgeport_1port_device);
62473 +       if (retval)
62474 +               goto failed_1port_device_register;
62475 +       retval = usb_serial_register(&edgeport_2port_device);
62476 +       if (retval)
62477 +               goto failed_2port_device_register;
62478 +       retval = usb_register(&io_driver);
62479 +       if (retval) 
62480 +               goto failed_usb_register;
62481         info(DRIVER_DESC " " DRIVER_VERSION);
62482         return 0;
62483 +failed_usb_register:
62484 +       usb_serial_deregister(&edgeport_2port_device);
62485 +failed_2port_device_register:
62486 +       usb_serial_deregister(&edgeport_1port_device);
62487 +failed_1port_device_register:
62488 +       return retval;
62489  }
62490  
62491  static void __exit edgeport_exit (void)
62492 diff -Nru a/drivers/usb/serial/io_ti.h b/drivers/usb/serial/io_ti.h
62493 --- a/drivers/usb/serial/io_ti.h        Fri Jul 26 11:59:44 2002
62494 +++ b/drivers/usb/serial/io_ti.h        Wed Aug 27 04:45:13 2003
62495 @@ -1,6 +1,6 @@
62496  /*****************************************************************************  
62497   *
62498 - *     Copyright (c) 1997-2002 Inside Out Networks, Inc.
62499 + *     Copyright (C) 1997-2002 Inside Out Networks, Inc.
62500   *
62501   *     This program is free software; you can redistribute it and/or modify
62502   *     it under the terms of the GNU General Public License as published by
62503 diff -Nru a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
62504 --- a/drivers/usb/serial/io_usbvend.h   Fri Jul 26 11:59:43 2002
62505 +++ b/drivers/usb/serial/io_usbvend.h   Wed Aug 27 04:45:13 2003
62506 @@ -7,7 +7,7 @@
62507   *
62508   ************************************************************************
62509   *
62510 - *     Copyright (c) 1998 Inside Out Networks, Inc.
62511 + *     Copyright (C) 1998 Inside Out Networks, Inc.
62512   *     This program is free software; you can redistribute it and/or modify
62513   *     it under the terms of the GNU General Public License as published by
62514   *     the Free Software Foundation; either version 2 of the License, or
62515 @@ -118,6 +118,7 @@
62516  #define ION_DEVICE_ID_TI_EDGEPORT_1            0x0215  /* Edgeport/1 RS232 */
62517  #define ION_DEVICE_ID_TI_EDGEPORT_42           0x0217  /* Edgeport/42 4 hub 2 RS232 */
62518  #define ION_DEVICE_ID_TI_EDGEPORT_22           0x021A  /* Edgeport/22  Edgeport/22I is an Edgeport/4 with ports 1&2 RS422 and ports 3&4 RS232 */
62519 +#define ION_DEVICE_ID_TI_EDGEPORT_2C           0x021B  /* Edgeport/2c RS232 */
62520  
62521  #define ION_DEVICE_ID_TI_EDGEPORT_421_BOOT     0x0240  /* Edgeport/421 in boot mode */
62522  #define ION_DEVICE_ID_TI_EDGEPORT_421_DOWN     0x0241  /* Edgeport/421 in download mode first interface is 2 RS232 (Note that the second interface of this multi interface device should be a standard USB class 7 printer port) */
62523 diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
62524 --- a/drivers/usb/serial/ipaq.c Mon Aug 11 07:56:25 2003
62525 +++ b/drivers/usb/serial/ipaq.c Fri Aug 22 13:52:01 2003
62526 @@ -570,16 +570,25 @@
62527  
62528  static int __init ipaq_init(void)
62529  {
62530 +       int retval;
62531         spin_lock_init(&write_list_lock);
62532 -       usb_serial_register(&ipaq_device);
62533 +       retval = usb_serial_register(&ipaq_device);
62534 +       if (retval) 
62535 +               goto failed_usb_serial_register;
62536         info(DRIVER_DESC " " DRIVER_VERSION);
62537         if (vendor) {
62538                 ipaq_id_table[0].idVendor = vendor;
62539                 ipaq_id_table[0].idProduct = product;
62540         }
62541 -       usb_register(&ipaq_driver);
62542 -
62543 +       retval = usb_register(&ipaq_driver);
62544 +       if (retval)
62545 +               goto failed_usb_register;
62546 +                 
62547         return 0;
62548 +failed_usb_register:
62549 +       usb_serial_deregister(&ipaq_device);
62550 +failed_usb_serial_register:
62551 +       return retval;
62552  }
62553  
62554  
62555 diff -Nru a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
62556 --- a/drivers/usb/serial/ir-usb.c       Thu May 29 14:13:24 2003
62557 +++ b/drivers/usb/serial/ir-usb.c       Fri Aug 22 13:52:01 2003
62558 @@ -609,10 +609,19 @@
62559  
62560  static int __init ir_init (void)
62561  {
62562 -       usb_serial_register (&ir_device);
62563 -       usb_register (&ir_driver);
62564 +       int retval;
62565 +       retval = usb_serial_register(&ir_device);
62566 +       if (retval)
62567 +               goto failed_usb_serial_register;
62568 +       retval = usb_register(&ir_driver);
62569 +       if (retval) 
62570 +               goto failed_usb_register;
62571         info(DRIVER_DESC " " DRIVER_VERSION);
62572         return 0;
62573 +failed_usb_register:
62574 +       usb_serial_deregister(&ir_device);
62575 +failed_usb_serial_register:
62576 +       return retval;
62577  }
62578  
62579  
62580 diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
62581 --- a/drivers/usb/serial/keyspan.c      Wed Aug 13 03:06:57 2003
62582 +++ b/drivers/usb/serial/keyspan.c      Fri Aug 22 13:52:01 2003
62583 @@ -197,15 +197,36 @@
62584  /* Functions used by new usb-serial code. */
62585  static int __init keyspan_init (void)
62586  {
62587 -       usb_serial_register (&keyspan_pre_device);
62588 -       usb_serial_register (&keyspan_1port_device);
62589 -       usb_serial_register (&keyspan_2port_device);
62590 -       usb_serial_register (&keyspan_4port_device);
62591 -       usb_register (&keyspan_driver);
62592 +       int retval;
62593 +       retval = usb_serial_register(&keyspan_pre_device);
62594 +       if (retval)
62595 +               goto failed_pre_device_register;
62596 +       retval = usb_serial_register(&keyspan_1port_device);
62597 +       if (retval)
62598 +               goto failed_1port_device_register;
62599 +       retval = usb_serial_register(&keyspan_2port_device);
62600 +       if (retval)
62601 +               goto failed_2port_device_register;
62602 +       retval = usb_serial_register(&keyspan_4port_device);
62603 +       if (retval)
62604 +               goto failed_4port_device_register;
62605 +       retval = usb_register(&keyspan_driver);
62606 +       if (retval) 
62607 +               goto failed_usb_register;
62608  
62609         info(DRIVER_VERSION ":" DRIVER_DESC);
62610  
62611         return 0;
62612 +failed_usb_register:
62613 +       usb_serial_deregister(&keyspan_4port_device);
62614 +failed_4port_device_register:
62615 +       usb_serial_deregister(&keyspan_2port_device);
62616 +failed_2port_device_register:
62617 +       usb_serial_deregister(&keyspan_1port_device);
62618 +failed_1port_device_register:
62619 +       usb_serial_deregister(&keyspan_pre_device);
62620 +failed_pre_device_register:
62621 +       return retval;
62622  }
62623  
62624  static void __exit keyspan_exit (void)
62625 diff -Nru a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
62626 --- a/drivers/usb/serial/keyspan_pda.c  Wed Aug 13 03:06:57 2003
62627 +++ b/drivers/usb/serial/keyspan_pda.c  Wed Aug 27 04:45:14 2003
62628 @@ -1,9 +1,9 @@
62629  /*
62630   * USB Keyspan PDA / Xircom / Entregra Converter driver
62631   *
62632 - * Copyright (c) 1999 - 2001 Greg Kroah-Hartman        <greg@kroah.com>
62633 - * Copyright (c) 1999, 2000 Brian Warner       <warner@lothar.com>
62634 - * Copyright (c) 2000 Al Borchers              <borchers@steinerpoint.com>
62635 + * Copyright (C) 1999 - 2001 Greg Kroah-Hartman        <greg@kroah.com>
62636 + * Copyright (C) 1999, 2000 Brian Warner       <warner@lothar.com>
62637 + * Copyright (C) 2000 Al Borchers              <borchers@steinerpoint.com>
62638   *
62639   *     This program is free software; you can redistribute it and/or modify
62640   *     it under the terms of the GNU General Public License as published by
62641 @@ -876,16 +876,39 @@
62642  
62643  static int __init keyspan_pda_init (void)
62644  {
62645 -       usb_serial_register (&keyspan_pda_device);
62646 +       int retval;
62647 +       retval = usb_serial_register(&keyspan_pda_device);
62648 +       if (retval)
62649 +               goto failed_pda_register;
62650  #ifdef KEYSPAN
62651 -       usb_serial_register (&keyspan_pda_fake_device);
62652 +       retval = usb_serial_register(&keyspan_pda_fake_device);
62653 +       if (retval)
62654 +               goto failed_pda_fake_register;
62655  #endif
62656  #ifdef XIRCOM
62657 -       usb_serial_register (&xircom_pgs_fake_device);
62658 -#endif
62659 -       usb_register (&keyspan_pda_driver);
62660 +       retval = usb_serial_register(&xircom_pgs_fake_device);
62661 +       if (retval)
62662 +               goto failed_xircom_register;
62663 +#endif
62664 +       retval = usb_register(&keyspan_pda_driver);
62665 +       if (retval)
62666 +               goto failed_usb_register;
62667         info(DRIVER_DESC " " DRIVER_VERSION);
62668         return 0;
62669 +failed_usb_register:   
62670 +#ifdef XIRCOM
62671 +       usb_serial_deregister(&xircom_pgs_fake_device);
62672 +failed_xircom_register:
62673 +#endif /* XIRCOM */
62674 +#ifdef KEYSPAN
62675 +       usb_serial_deregister(&keyspan_pda_fake_device);
62676 +#endif
62677 +#ifdef KEYSPAN
62678 +failed_pda_fake_register:
62679 +#endif
62680 +       usb_serial_deregister(&keyspan_pda_device);
62681 +failed_pda_register:
62682 +       return retval;
62683  }
62684  
62685  
62686 diff -Nru a/drivers/usb/serial/keyspan_pda_fw.h b/drivers/usb/serial/keyspan_pda_fw.h
62687 --- a/drivers/usb/serial/keyspan_pda_fw.h       Mon Feb  4 23:40:21 2002
62688 +++ b/drivers/usb/serial/keyspan_pda_fw.h       Wed Aug 27 04:45:14 2003
62689 @@ -1,7 +1,7 @@
62690  /*
62691   * USB Keyspan PDA Firmware
62692   *
62693 - * Copyright (c) 1999, 2000 Brian Warner       <warner@lothar.com>
62694 + * Copyright (C) 1999, 2000 Brian Warner       <warner@lothar.com>
62695   *
62696   *     This program is free software; you can redistribute it and/or modify
62697   *     it under the terms of the GNU General Public License as published by
62698 diff -Nru a/drivers/usb/serial/keyspan_usa26msg.h b/drivers/usb/serial/keyspan_usa26msg.h
62699 --- a/drivers/usb/serial/keyspan_usa26msg.h     Thu Mar 13 10:36:02 2003
62700 +++ b/drivers/usb/serial/keyspan_usa26msg.h     Wed Aug 27 04:45:13 2003
62701 @@ -1,7 +1,7 @@
62702  /*
62703         usa26msg.h
62704  
62705 -       Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62706 +       Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62707         This file is available under a BSD-style copyright
62708  
62709         Keyspan USB Async Firmware to run on Anchor EZ-USB
62710 @@ -15,7 +15,7 @@
62711         disclaimer.  The following copyright notice must appear immediately at
62712         the beginning of all source files:
62713  
62714 -               Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62715 +               Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62716  
62717                 This file is available under a BSD-style copyright
62718  
62719 diff -Nru a/drivers/usb/serial/keyspan_usa28msg.h b/drivers/usb/serial/keyspan_usa28msg.h
62720 --- a/drivers/usb/serial/keyspan_usa28msg.h     Thu Mar 13 10:36:02 2003
62721 +++ b/drivers/usb/serial/keyspan_usa28msg.h     Wed Aug 27 04:45:14 2003
62722 @@ -1,7 +1,7 @@
62723  /*
62724         usa28msg.h
62725  
62726 -       Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62727 +       Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62728         This file is available under a BSD-style copyright
62729  
62730         Keyspan USB Async Firmware to run on Anchor EZ-USB
62731 @@ -15,7 +15,7 @@
62732         disclaimer.  The following copyright notice must appear immediately at
62733         the beginning of all source files:
62734  
62735 -               Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62736 +               Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62737  
62738                 This file is available under a BSD-style copyright
62739  
62740 diff -Nru a/drivers/usb/serial/keyspan_usa49msg.h b/drivers/usb/serial/keyspan_usa49msg.h
62741 --- a/drivers/usb/serial/keyspan_usa49msg.h     Thu Mar 13 10:36:02 2003
62742 +++ b/drivers/usb/serial/keyspan_usa49msg.h     Wed Aug 27 04:45:14 2003
62743 @@ -1,7 +1,7 @@
62744  /*
62745         usa49msg.h
62746  
62747 -       Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62748 +       Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62749         This file is available under a BSD-style copyright
62750  
62751         Keyspan USB Async Firmware to run on Anchor EZ-USB
62752 @@ -15,7 +15,7 @@
62753         disclaimer.  The following copyright notice must appear immediately at
62754         the beginning of all source files:
62755  
62756 -               Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62757 +               Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
62758  
62759                 This file is available under a BSD-style copyright
62760  
62761 diff -Nru a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
62762 --- a/drivers/usb/serial/kl5kusb105.c   Wed Aug 13 03:06:57 2003
62763 +++ b/drivers/usb/serial/kl5kusb105.c   Fri Aug 22 13:52:01 2003
62764 @@ -1037,11 +1037,20 @@
62765  
62766  static int __init klsi_105_init (void)
62767  {
62768 -       usb_serial_register (&kl5kusb105d_device);
62769 -       usb_register (&kl5kusb105d_driver);
62770 +       int retval;
62771 +       retval = usb_serial_register(&kl5kusb105d_device);
62772 +       if (retval)
62773 +               goto failed_usb_serial_register;
62774 +       retval = usb_register(&kl5kusb105d_driver);
62775 +       if (retval)
62776 +               goto failed_usb_register;
62777  
62778         info(DRIVER_DESC " " DRIVER_VERSION);
62779         return 0;
62780 +failed_usb_register:
62781 +       usb_serial_deregister(&kl5kusb105d_device);
62782 +failed_usb_serial_register:
62783 +       return retval;
62784  }
62785  
62786  
62787 diff -Nru a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
62788 --- a/drivers/usb/serial/kobil_sct.c    Wed Aug 13 03:06:57 2003
62789 +++ b/drivers/usb/serial/kobil_sct.c    Fri Aug 22 13:52:01 2003
62790 @@ -743,13 +743,22 @@
62791  
62792  static int __init kobil_init (void)
62793  {
62794 -       usb_serial_register (&kobil_device);
62795 -       usb_register (&kobil_driver);
62796 +       int retval;
62797 +       retval = usb_serial_register(&kobil_device);
62798 +       if (retval)
62799 +               goto failed_usb_serial_register;
62800 +       retval = usb_register(&kobil_driver);
62801 +       if (retval) 
62802 +               goto failed_usb_register;
62803  
62804         info(DRIVER_VERSION " " DRIVER_AUTHOR);
62805         info(DRIVER_DESC);
62806  
62807         return 0;
62808 +failed_usb_register:
62809 +       usb_serial_deregister(&kobil_device);
62810 +failed_usb_serial_register:
62811 +       return retval;
62812  }
62813  
62814  
62815 diff -Nru a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
62816 --- a/drivers/usb/serial/mct_u232.c     Wed Aug 13 03:06:57 2003
62817 +++ b/drivers/usb/serial/mct_u232.c     Fri Aug 22 13:52:01 2003
62818 @@ -850,10 +850,19 @@
62819  
62820  static int __init mct_u232_init (void)
62821  {
62822 -       usb_serial_register (&mct_u232_device);
62823 -       usb_register (&mct_u232_driver);
62824 +       int retval;
62825 +       retval = usb_serial_register(&mct_u232_device);
62826 +       if (retval)
62827 +               goto failed_usb_serial_register;
62828 +       retval = usb_register(&mct_u232_driver);
62829 +       if (retval)
62830 +               goto failed_usb_register;
62831         info(DRIVER_DESC " " DRIVER_VERSION);
62832         return 0;
62833 +failed_usb_register:
62834 +       usb_serial_deregister(&mct_u232_device);
62835 +failed_usb_serial_register:
62836 +       return retval;
62837  }
62838  
62839  
62840 diff -Nru a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
62841 --- a/drivers/usb/serial/omninet.c      Wed Aug 13 03:06:57 2003
62842 +++ b/drivers/usb/serial/omninet.c      Fri Aug 22 13:52:01 2003
62843 @@ -375,10 +375,19 @@
62844  
62845  static int __init omninet_init (void)
62846  {
62847 -       usb_serial_register (&zyxel_omninet_device);
62848 -       usb_register (&omninet_driver);
62849 +       int retval;
62850 +       retval = usb_serial_register(&zyxel_omninet_device);
62851 +       if (retval)
62852 +               goto failed_usb_serial_register;
62853 +       retval = usb_register(&omninet_driver);
62854 +       if (retval)
62855 +               goto failed_usb_register;
62856         info(DRIVER_VERSION ":" DRIVER_DESC);
62857         return 0;
62858 +failed_usb_register:
62859 +       usb_serial_deregister(&zyxel_omninet_device);
62860 +failed_usb_serial_register:
62861 +       return retval;
62862  }
62863  
62864  
62865 diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
62866 --- a/drivers/usb/serial/pl2303.c       Wed Aug 13 03:06:57 2003
62867 +++ b/drivers/usb/serial/pl2303.c       Fri Aug 22 13:52:01 2003
62868 @@ -768,10 +768,19 @@
62869  
62870  static int __init pl2303_init (void)
62871  {
62872 -       usb_serial_register (&pl2303_device);
62873 -       usb_register (&pl2303_driver);
62874 +       int retval;
62875 +       retval = usb_serial_register(&pl2303_device);
62876 +       if (retval)
62877 +               goto failed_usb_serial_register;
62878 +       retval = usb_register(&pl2303_driver);
62879 +       if (retval)
62880 +               goto failed_usb_register;
62881         info(DRIVER_DESC " " DRIVER_VERSION);
62882         return 0;
62883 +failed_usb_register:
62884 +       usb_serial_deregister(&pl2303_device);
62885 +failed_usb_serial_register:
62886 +       return retval;
62887  }
62888  
62889  
62890 diff -Nru a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
62891 --- a/drivers/usb/serial/safe_serial.c  Thu May 29 14:53:27 2003
62892 +++ b/drivers/usb/serial/safe_serial.c  Wed Aug 27 04:45:14 2003
62893 @@ -1,8 +1,8 @@
62894  /*
62895   * Safe Encapsulated USB Serial Driver
62896   *
62897 - *      Copyright (c) 2001 Lineo
62898 - *      Copyright (c) 2001 Hewlett-Packard
62899 + *      Copyright (C) 2001 Lineo
62900 + *      Copyright (C) 2001 Hewlett-Packard
62901   *
62902   *     This program is free software; you can redistribute it and/or modify
62903   *     it under the terms of the GNU General Public License as published by
62904 @@ -422,7 +422,7 @@
62905  
62906  static int __init safe_init (void)
62907  {
62908 -       int i;
62909 +       int i, retval;
62910  
62911         info (DRIVER_VERSION " " DRIVER_AUTHOR);
62912         info (DRIVER_DESC);
62913 @@ -441,10 +441,18 @@
62914                 }
62915         }
62916  
62917 -       usb_serial_register (&safe_device);
62918 -       usb_register (&safe_driver);
62919 +       retval = usb_serial_register(&safe_device);
62920 +       if (retval)
62921 +               goto failed_usb_serial_register;
62922 +       retval = usb_register(&safe_driver);
62923 +       if (retval)
62924 +               goto failed_usb_register;
62925  
62926         return 0;
62927 +failed_usb_register:
62928 +       usb_serial_deregister(&safe_device);
62929 +failed_usb_serial_register:
62930 +       return retval;
62931  }
62932  
62933  static void __exit safe_exit (void)
62934 diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
62935 --- a/drivers/usb/serial/usb-serial.c   Thu Aug 14 15:51:23 2003
62936 +++ b/drivers/usb/serial/usb-serial.c   Fri Aug 29 06:39:11 2003
62937 @@ -2,8 +2,8 @@
62938   * USB Serial Converter driver
62939   *
62940   * Copyright (C) 1999 - 2003 Greg Kroah-Hartman (greg@kroah.com)
62941 - * Copyright (c) 2000 Peter Berger (pberger@brimson.com)
62942 - * Copyright (c) 2000 Al Borchers (borchers@steinerpoint.com)
62943 + * Copyright (C) 2000 Peter Berger (pberger@brimson.com)
62944 + * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com)
62945   *
62946   *     This program is free software; you can redistribute it and/or
62947   *     modify it under the terms of the GNU General Public License version
62948 @@ -871,7 +871,8 @@
62949  
62950         /* the ports are cleaned up and released in port_release() */
62951         for (i = 0; i < serial->num_ports; ++i)
62952 -               device_unregister(&serial->port[i]->dev);
62953 +               if (serial->port[i]->dev.parent != NULL)
62954 +                       device_unregister(&serial->port[i]->dev);
62955  
62956         /* If this is a "fake" port, we have to clean it up here, as it will
62957          * not get cleaned up in port_release() as it was never registered with
62958 diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
62959 --- a/drivers/usb/serial/visor.c        Wed Aug 13 03:06:57 2003
62960 +++ b/drivers/usb/serial/visor.c        Thu Aug 28 06:49:27 2003
62961 @@ -225,11 +225,16 @@
62962                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
62963         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_S360_ID),
62964                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
62965 -       { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID) },
62966 +       { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID),
62967 +               .driver_info = (kernel_ulong_t)&palm_os_4_probe },
62968         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NX60_ID),
62969                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
62970         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NZ90V_ID),
62971                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
62972 +       { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), 
62973 +               .driver_info = (kernel_ulong_t)&palm_os_4_probe },
62974 +       { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), 
62975 +               .driver_info = (kernel_ulong_t)&palm_os_4_probe },
62976         { },                                    /* optional parameter entry */
62977         { }                                     /* Terminating entry */
62978  };
62979 @@ -258,6 +263,8 @@
62980         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID) },
62981         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NX60_ID) },
62982         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NZ90V_ID) },
62983 +       { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID) },
62984 +       { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID) },
62985         { },                                    /* optional parameter entry */
62986         { }                                     /* Terminating entry */
62987  };
62988 @@ -649,7 +656,7 @@
62989  
62990         transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL);
62991         if (!transfer_buffer) {
62992 -               dev_err(dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__,
62993 +               dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__,
62994                         sizeof(*connection_info));
62995                 return -ENOMEM;
62996         }
62997 @@ -735,7 +742,7 @@
62998  
62999         transfer_buffer =  kmalloc (sizeof (*connection_info), GFP_KERNEL);
63000         if (!transfer_buffer) {
63001 -               dev_err(dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__,
63002 +               dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__,
63003                         sizeof(*connection_info));
63004                 return -ENOMEM;
63005         }
63006 @@ -956,7 +963,7 @@
63007  
63008  static int __init visor_init (void)
63009  {
63010 -       int i;
63011 +       int i, retval;
63012         /* Only if parameters were passed to us */
63013         if ((vendor>0) && (product>0)) {
63014                 struct usb_device_id usb_dev_temp[]=
63015 @@ -983,12 +990,24 @@
63016                 info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
63017                         vendor, product);
63018         }
63019 -       usb_serial_register (&handspring_device);
63020 -       usb_serial_register (&clie_3_5_device);
63021 -       usb_register (&visor_driver);
63022 +       retval = usb_serial_register(&handspring_device);
63023 +       if (retval)
63024 +               goto failed_handspring_register;
63025 +       retval = usb_serial_register(&clie_3_5_device);
63026 +       if (retval)
63027 +               goto failed_clie_3_5_register;
63028 +       retval = usb_register(&visor_driver);
63029 +       if (retval) 
63030 +               goto failed_usb_register;
63031         info(DRIVER_DESC " " DRIVER_VERSION);
63032  
63033         return 0;
63034 +failed_usb_register:
63035 +       usb_serial_deregister(&clie_3_5_device);
63036 +failed_clie_3_5_register:
63037 +       usb_serial_deregister(&handspring_device);
63038 +failed_handspring_register:
63039 +       return retval;
63040  }
63041  
63042  
63043 diff -Nru a/drivers/usb/serial/visor.h b/drivers/usb/serial/visor.h
63044 --- a/drivers/usb/serial/visor.h        Wed May  7 04:49:36 2003
63045 +++ b/drivers/usb/serial/visor.h        Thu Aug 28 06:49:27 2003
63046 @@ -41,6 +41,12 @@
63047  #define SONY_CLIE_NX60_ID              0x00DA
63048  #define SONY_CLIE_NZ90V_ID             0x00E9
63049  
63050 +#define SAMSUNG_VENDOR_ID              0x04E8
63051 +#define SAMSUNG_SCH_I330_ID            0x8001
63052 +
63053 +#define GARMIN_VENDOR_ID               0x091E
63054 +#define GARMIN_IQUE_3600_ID            0x0004
63055 +
63056  /****************************************************************************
63057   * Handspring Visor Vendor specific request codes (bRequest values)
63058   * A big thank you to Handspring for providing the following information.
63059 diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
63060 --- a/drivers/usb/serial/whiteheat.c    Wed Aug 13 03:06:57 2003
63061 +++ b/drivers/usb/serial/whiteheat.c    Fri Aug 22 13:52:01 2003
63062 @@ -1486,11 +1486,24 @@
63063   *****************************************************************************/
63064  static int __init whiteheat_init (void)
63065  {
63066 -       usb_serial_register (&whiteheat_fake_device);
63067 -       usb_serial_register (&whiteheat_device);
63068 -       usb_register (&whiteheat_driver);
63069 +       int retval;
63070 +       retval = usb_serial_register(&whiteheat_fake_device);
63071 +       if (retval)
63072 +               goto failed_fake_register;
63073 +       retval = usb_serial_register(&whiteheat_device);
63074 +       if (retval)
63075 +               goto failed_device_register;
63076 +       retval = usb_register(&whiteheat_driver);
63077 +       if (retval)
63078 +               goto failed_usb_register;
63079         info(DRIVER_DESC " " DRIVER_VERSION);
63080         return 0;
63081 +failed_usb_register:
63082 +       usb_serial_deregister(&whiteheat_device);
63083 +failed_device_register:
63084 +       usb_serial_deregister(&whiteheat_fake_device);
63085 +failed_fake_register:
63086 +       return retval;
63087  }
63088  
63089  
63090 diff -Nru a/drivers/usb/serial/xircom_pgs_fw.h b/drivers/usb/serial/xircom_pgs_fw.h
63091 --- a/drivers/usb/serial/xircom_pgs_fw.h        Mon Feb  4 23:49:26 2002
63092 +++ b/drivers/usb/serial/xircom_pgs_fw.h        Wed Aug 27 04:45:14 2003
63093 @@ -1,8 +1,8 @@
63094  /*
63095   * USB Xircom PGS Firmware
63096   *
63097 - * Copyright (c) 1999, 2000 Brian Warner        <warner@lothar.com>
63098 - * Copyright (c) 2001 Cristian M. Craciunescu  <cristi@dnt.ro>
63099 + * Copyright (C) 1999, 2000 Brian Warner        <warner@lothar.com>
63100 + * Copyright (C) 2001 Cristian M. Craciunescu  <cristi@dnt.ro>
63101   *
63102   *      This program is free software; you can redistribute it and/or modify
63103   *      it under the terms of the GNU General Public License as published by
63104 diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
63105 --- a/drivers/usb/storage/isd200.c      Sun Jul 13 18:02:23 2003
63106 +++ b/drivers/usb/storage/isd200.c      Tue Sep  2 10:47:41 2003
63107 @@ -272,8 +272,9 @@
63108  
63109  struct isd200_info {
63110         struct inquiry_data InquiryData;
63111 -       struct hd_driveid drive;
63112 +       struct hd_driveid *id;
63113         struct isd200_config ConfigData;
63114 +       unsigned char *RegsBuf;
63115         unsigned char ATARegs[8];
63116         unsigned char DeviceHead;
63117         unsigned char DeviceFlags;
63118 @@ -473,7 +474,7 @@
63119                 ata.generic.RegisterSelect = REG_COMMAND;
63120                 ata.write.CommandByte = WIN_IDENTIFY;
63121                 srb->sc_data_direction = SCSI_DATA_READ;
63122 -               srb->request_buffer = (void *)&info->drive;
63123 +               srb->request_buffer = (void *) info->id;
63124                 srb->request_bufflen = sizeof(struct hd_driveid);
63125                 break;
63126  
63127 @@ -513,11 +514,12 @@
63128         US_DEBUGP("Entering isd200_IssueATAReadRegs\n");
63129  
63130         transferStatus = isd200_action( us, ACTION_READ_STATUS,
63131 -                                   info->ATARegs, sizeof(info->ATARegs) );
63132 +                                   info->RegsBuf, sizeof(info->ATARegs) );
63133         if (transferStatus != ISD200_TRANSPORT_GOOD) {
63134                 US_DEBUGP("   Error reading ATA registers\n");
63135                 retStatus = ISD200_ERROR;
63136         } else {
63137 +               memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs));
63138                 US_DEBUGP("   Got ATA Register[IDE_ERROR_OFFSET] = 0x%x\n", 
63139                           info->ATARegs[IDE_ERROR_OFFSET]);
63140         }
63141 @@ -835,9 +837,9 @@
63142                            int detect )
63143  {
63144         int status = ISD200_GOOD;
63145 -       unsigned char *regs = us->iobuf;
63146         unsigned long endTime;
63147         struct isd200_info *info = (struct isd200_info *)us->extra;
63148 +       unsigned char *regs = info->RegsBuf;
63149         int recheckAsMaster = FALSE;
63150  
63151         if ( detect )
63152 @@ -984,6 +986,7 @@
63153  {
63154         struct isd200_info *info = (struct isd200_info *)us->extra;
63155         int retStatus = ISD200_GOOD;
63156 +       struct hd_driveid *id = info->id;
63157  
63158         US_DEBUGP("Entering isd200_get_inquiry_data\n");
63159  
63160 @@ -1000,7 +1003,7 @@
63161                         /* this must be an ATA device */
63162                         /* perform an ATA Command Identify */
63163                         transferStatus = isd200_action( us, ACTION_IDENTIFY,
63164 -                                                       &info->drive, 
63165 +                                                       id, 
63166                                                         sizeof(struct hd_driveid) );
63167                         if (transferStatus != ISD200_TRANSPORT_GOOD) {
63168                                 /* Error issuing ATA Command Identify */
63169 @@ -1010,35 +1013,35 @@
63170                                 /* ATA Command Identify successful */
63171                                 int i;
63172                                 __u16 *src, *dest;
63173 -                               ide_fix_driveid(&info->drive);
63174 +                               ide_fix_driveid(id);
63175  
63176                                 US_DEBUGP("   Identify Data Structure:\n");
63177 -                               US_DEBUGP("      config = 0x%x\n", info->drive.config);
63178 -                               US_DEBUGP("      cyls = 0x%x\n", info->drive.cyls);
63179 -                               US_DEBUGP("      heads = 0x%x\n", info->drive.heads);
63180 -                               US_DEBUGP("      track_bytes = 0x%x\n", info->drive.track_bytes);
63181 -                               US_DEBUGP("      sector_bytes = 0x%x\n", info->drive.sector_bytes);
63182 -                               US_DEBUGP("      sectors = 0x%x\n", info->drive.sectors);
63183 -                               US_DEBUGP("      serial_no[0] = 0x%x\n", info->drive.serial_no[0]);
63184 -                               US_DEBUGP("      buf_type = 0x%x\n", info->drive.buf_type);
63185 -                               US_DEBUGP("      buf_size = 0x%x\n", info->drive.buf_size);
63186 -                               US_DEBUGP("      ecc_bytes = 0x%x\n", info->drive.ecc_bytes);
63187 -                               US_DEBUGP("      fw_rev[0] = 0x%x\n", info->drive.fw_rev[0]);
63188 -                               US_DEBUGP("      model[0] = 0x%x\n", info->drive.model[0]);
63189 -                               US_DEBUGP("      max_multsect = 0x%x\n", info->drive.max_multsect);
63190 -                               US_DEBUGP("      dword_io = 0x%x\n", info->drive.dword_io);
63191 -                               US_DEBUGP("      capability = 0x%x\n", info->drive.capability);
63192 -                               US_DEBUGP("      tPIO = 0x%x\n", info->drive.tPIO);
63193 -                               US_DEBUGP("      tDMA = 0x%x\n", info->drive.tDMA);
63194 -                               US_DEBUGP("      field_valid = 0x%x\n", info->drive.field_valid);
63195 -                               US_DEBUGP("      cur_cyls = 0x%x\n", info->drive.cur_cyls);
63196 -                               US_DEBUGP("      cur_heads = 0x%x\n", info->drive.cur_heads);
63197 -                               US_DEBUGP("      cur_sectors = 0x%x\n", info->drive.cur_sectors);
63198 -                               US_DEBUGP("      cur_capacity = 0x%x\n", (info->drive.cur_capacity1 << 16) + info->drive.cur_capacity0 );
63199 -                               US_DEBUGP("      multsect = 0x%x\n", info->drive.multsect);
63200 -                               US_DEBUGP("      lba_capacity = 0x%x\n", info->drive.lba_capacity);
63201 -                               US_DEBUGP("      command_set_1 = 0x%x\n", info->drive.command_set_1);
63202 -                               US_DEBUGP("      command_set_2 = 0x%x\n", info->drive.command_set_2);
63203 +                               US_DEBUGP("      config = 0x%x\n", id->config);
63204 +                               US_DEBUGP("      cyls = 0x%x\n", id->cyls);
63205 +                               US_DEBUGP("      heads = 0x%x\n", id->heads);
63206 +                               US_DEBUGP("      track_bytes = 0x%x\n", id->track_bytes);
63207 +                               US_DEBUGP("      sector_bytes = 0x%x\n", id->sector_bytes);
63208 +                               US_DEBUGP("      sectors = 0x%x\n", id->sectors);
63209 +                               US_DEBUGP("      serial_no[0] = 0x%x\n", id->serial_no[0]);
63210 +                               US_DEBUGP("      buf_type = 0x%x\n", id->buf_type);
63211 +                               US_DEBUGP("      buf_size = 0x%x\n", id->buf_size);
63212 +                               US_DEBUGP("      ecc_bytes = 0x%x\n", id->ecc_bytes);
63213 +                               US_DEBUGP("      fw_rev[0] = 0x%x\n", id->fw_rev[0]);
63214 +                               US_DEBUGP("      model[0] = 0x%x\n", id->model[0]);
63215 +                               US_DEBUGP("      max_multsect = 0x%x\n", id->max_multsect);
63216 +                               US_DEBUGP("      dword_io = 0x%x\n", id->dword_io);
63217 +                               US_DEBUGP("      capability = 0x%x\n", id->capability);
63218 +                               US_DEBUGP("      tPIO = 0x%x\n", id->tPIO);
63219 +                               US_DEBUGP("      tDMA = 0x%x\n", id->tDMA);
63220 +                               US_DEBUGP("      field_valid = 0x%x\n", id->field_valid);
63221 +                               US_DEBUGP("      cur_cyls = 0x%x\n", id->cur_cyls);
63222 +                               US_DEBUGP("      cur_heads = 0x%x\n", id->cur_heads);
63223 +                               US_DEBUGP("      cur_sectors = 0x%x\n", id->cur_sectors);
63224 +                               US_DEBUGP("      cur_capacity = 0x%x\n", (id->cur_capacity1 << 16) + id->cur_capacity0 );
63225 +                               US_DEBUGP("      multsect = 0x%x\n", id->multsect);
63226 +                               US_DEBUGP("      lba_capacity = 0x%x\n", id->lba_capacity);
63227 +                               US_DEBUGP("      command_set_1 = 0x%x\n", id->command_set_1);
63228 +                               US_DEBUGP("      command_set_2 = 0x%x\n", id->command_set_2);
63229  
63230                                 memset(&info->InquiryData, 0, sizeof(info->InquiryData));
63231  
63232 @@ -1054,30 +1057,30 @@
63233                                 /* The length must be at least 36 (5 + 31) */
63234                                 info->InquiryData.AdditionalLength = 0x1F;
63235  
63236 -                               if (info->drive.command_set_1 & COMMANDSET_MEDIA_STATUS) {
63237 +                               if (id->command_set_1 & COMMANDSET_MEDIA_STATUS) {
63238                                         /* set the removable bit */
63239                                         info->InquiryData.DeviceTypeModifier = DEVICE_REMOVABLE;
63240                                         info->DeviceFlags |= DF_REMOVABLE_MEDIA;
63241                                 }
63242  
63243                                 /* Fill in vendor identification fields */
63244 -                               src = (__u16*)info->drive.model;
63245 +                               src = (__u16*)id->model;
63246                                 dest = (__u16*)info->InquiryData.VendorId;
63247                                 for (i=0;i<4;i++)
63248                                         dest[i] = be16_to_cpu(src[i]);
63249  
63250 -                               src = (__u16*)(info->drive.model+8);
63251 +                               src = (__u16*)(id->model+8);
63252                                 dest = (__u16*)info->InquiryData.ProductId;
63253                                 for (i=0;i<8;i++)
63254                                         dest[i] = be16_to_cpu(src[i]);
63255  
63256 -                               src = (__u16*)info->drive.fw_rev;
63257 +                               src = (__u16*)id->fw_rev;
63258                                 dest = (__u16*)info->InquiryData.ProductRevisionLevel;
63259                                 for (i=0;i<2;i++)
63260                                         dest[i] = be16_to_cpu(src[i]);
63261  
63262                                 /* determine if it supports Media Status Notification */
63263 -                               if (info->drive.command_set_2 & COMMANDSET_MEDIA_STATUS) {
63264 +                               if (id->command_set_2 & COMMANDSET_MEDIA_STATUS) {
63265                                         US_DEBUGP("   Device supports Media Status Notification\n");
63266  
63267                                         /* Indicate that it is enabled, even though it is not
63268 @@ -1101,11 +1104,9 @@
63269                         US_DEBUGP("Protocol changed to: %s\n", us->protocol_name);
63270             
63271                         /* Free driver structure */         
63272 -                       if (us->extra != NULL) {
63273 -                               kfree(us->extra);
63274 -                               us->extra = NULL;
63275 -                               us->extra_destructor = NULL;
63276 -                       }
63277 +                       us->extra_destructor(info);
63278 +                       us->extra = NULL;
63279 +                       us->extra_destructor = NULL;
63280                 }
63281         }
63282  
63283 @@ -1182,6 +1183,7 @@
63284                        union ata_cdb * ataCdb)
63285  {
63286         struct isd200_info *info = (struct isd200_info *)us->extra;
63287 +       struct hd_driveid *id = info->id;
63288         int sendToTransport = TRUE;
63289         unsigned char sectnum, head;
63290         unsigned short cylinder;
63291 @@ -1254,12 +1256,12 @@
63292  
63293                 US_DEBUGP("   ATA OUT - SCSIOP_READ_CAPACITY\n");
63294  
63295 -               if (info->drive.capability & CAPABILITY_LBA ) {
63296 -                       capacity = info->drive.lba_capacity - 1;
63297 +               if (id->capability & CAPABILITY_LBA ) {
63298 +                       capacity = id->lba_capacity - 1;
63299                 } else {
63300 -                       capacity = (info->drive.heads *
63301 -                                   info->drive.cyls *
63302 -                                   info->drive.sectors) - 1;
63303 +                       capacity = (id->heads *
63304 +                                   id->cyls *
63305 +                                   id->sectors) - 1;
63306                 }
63307                 readCapacityData.LogicalBlockAddress = cpu_to_be32(capacity);
63308                 readCapacityData.BytesPerBlock = cpu_to_be32(0x200);
63309 @@ -1280,16 +1282,16 @@
63310                 lba = cpu_to_be32(lba);
63311                 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8];
63312  
63313 -               if (info->drive.capability & CAPABILITY_LBA) {
63314 +               if (id->capability & CAPABILITY_LBA) {
63315                         sectnum = (unsigned char)(lba);
63316                         cylinder = (unsigned short)(lba>>8);
63317                         head = ATA_ADDRESS_DEVHEAD_LBA_MODE | (unsigned char)(lba>>24 & 0x0F);
63318                 } else {
63319 -                       sectnum = (unsigned char)((lba % info->drive.sectors) + 1);
63320 -                       cylinder = (unsigned short)(lba / (info->drive.sectors *
63321 -                                                          info->drive.heads));
63322 -                       head = (unsigned char)((lba / info->drive.sectors) %
63323 -                                              info->drive.heads);
63324 +                       sectnum = (unsigned char)((lba % id->sectors) + 1);
63325 +                       cylinder = (unsigned short)(lba / (id->sectors *
63326 +                                                          id->heads));
63327 +                       head = (unsigned char)((lba / id->sectors) %
63328 +                                              id->heads);
63329                 }
63330                 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
63331                 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
63332 @@ -1313,14 +1315,14 @@
63333                 lba = cpu_to_be32(lba);
63334                 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8];
63335  
63336 -               if (info->drive.capability & CAPABILITY_LBA) {
63337 +               if (id->capability & CAPABILITY_LBA) {
63338                         sectnum = (unsigned char)(lba);
63339                         cylinder = (unsigned short)(lba>>8);
63340                         head = ATA_ADDRESS_DEVHEAD_LBA_MODE | (unsigned char)(lba>>24 & 0x0F);
63341                 } else {
63342 -                       sectnum = (unsigned char)((lba % info->drive.sectors) + 1);
63343 -                       cylinder = (unsigned short)(lba / (info->drive.sectors * info->drive.heads));
63344 -                       head = (unsigned char)((lba / info->drive.sectors) % info->drive.heads);
63345 +                       sectnum = (unsigned char)((lba % id->sectors) + 1);
63346 +                       cylinder = (unsigned short)(lba / (id->sectors * id->heads));
63347 +                       head = (unsigned char)((lba / id->sectors) % id->heads);
63348                 }
63349                 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
63350                 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
63351 @@ -1398,6 +1400,21 @@
63352  
63353  
63354  /**************************************************************************
63355 + * isd200_free_info
63356 + *
63357 + * Frees the driver structure.
63358 + */
63359 +void isd200_free_info_ptrs(void *info_)
63360 +{
63361 +       struct isd200_info *info = (struct isd200_info *) info_;
63362 +
63363 +       if (info) {
63364 +               kfree(info->id);
63365 +               kfree(info->RegsBuf);
63366 +       }
63367 +}
63368 +
63369 +/**************************************************************************
63370   * isd200_init_info
63371   *                                                                      
63372   * Allocates (if necessary) and initializes the driver structure.
63373 @@ -1408,18 +1425,31 @@
63374  int isd200_init_info(struct us_data *us)
63375  {
63376         int retStatus = ISD200_GOOD;
63377 +       struct isd200_info *info;
63378  
63379 -       if (!us->extra) {
63380 -               us->extra = (void *) kmalloc(sizeof(struct isd200_info), GFP_KERNEL);
63381 -               if (!us->extra) {
63382 -                       US_DEBUGP("ERROR - kmalloc failure\n");
63383 +       info = (struct isd200_info *)
63384 +                       kmalloc(sizeof(struct isd200_info), GFP_KERNEL);
63385 +       if (!info)
63386 +               retStatus = ISD200_ERROR;
63387 +       else {
63388 +               memset(info, 0, sizeof(struct isd200_info));
63389 +               info->id = (struct hd_driveid *)
63390 +                               kmalloc(sizeof(struct hd_driveid), GFP_KERNEL);
63391 +               info->RegsBuf = (unsigned char *)
63392 +                               kmalloc(sizeof(info->ATARegs), GFP_KERNEL);
63393 +               if (!info->id || !info->RegsBuf) {
63394 +                       isd200_free_info_ptrs(info);
63395 +                       kfree(info);
63396                         retStatus = ISD200_ERROR;
63397 -               }
63398 +               } else
63399 +                       memset(info->id, 0, sizeof(struct hd_driveid));
63400         }
63401  
63402         if (retStatus == ISD200_GOOD) {
63403 -               memset(us->extra, 0, sizeof(struct isd200_info));
63404 -       }
63405 +               us->extra = info;
63406 +               us->extra_destructor = isd200_free_info_ptrs;
63407 +       } else
63408 +               US_DEBUGP("ERROR - kmalloc failure\n");
63409  
63410         return(retStatus);
63411  }
63412 diff -Nru a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
63413 --- a/drivers/usb/storage/sddr09.c      Sat Aug 16 11:46:50 2003
63414 +++ b/drivers/usb/storage/sddr09.c      Thu Aug 21 20:31:46 2003
63415 @@ -34,6 +34,7 @@
63416  #include "debug.h"
63417  #include "sddr09.h"
63418  
63419 +#include <linux/version.h>
63420  #include <linux/sched.h>
63421  #include <linux/errno.h>
63422  #include <linux/slab.h>
63423 diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
63424 --- a/drivers/usb/storage/transport.c   Sat Jun 28 13:31:18 2003
63425 +++ b/drivers/usb/storage/transport.c   Tue Aug 19 14:34:50 2003
63426 @@ -942,11 +942,11 @@
63427         memcpy(bcb->CDB, srb->cmnd, bcb->Length);
63428  
63429         /* send it to out endpoint */
63430 -       US_DEBUGP("Bulk command S 0x%x T 0x%x Trg %d LUN %d L %d F %d CL %d\n",
63431 +       US_DEBUGP("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
63432                         le32_to_cpu(bcb->Signature), bcb->Tag,
63433 +                       le32_to_cpu(bcb->DataTransferLength), bcb->Flags,
63434                         (bcb->Lun >> 4), (bcb->Lun & 0x0F), 
63435 -                       le32_to_cpu(bcb->DataTransferLength),
63436 -                       bcb->Flags, bcb->Length);
63437 +                       bcb->Length);
63438         result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
63439                                 bcb, US_BULK_CB_WRAP_LEN, NULL);
63440         US_DEBUGP("Bulk command transfer result=%d\n", result);
63441 @@ -999,7 +999,7 @@
63442                 return USB_STOR_TRANSPORT_ERROR;
63443  
63444         /* check bulk status */
63445 -       US_DEBUGP("Bulk status Sig 0x%x T 0x%x R %d Stat 0x%x\n",
63446 +       US_DEBUGP("Bulk Status S 0x%x T 0x%x R %d Stat 0x%x\n",
63447                         le32_to_cpu(bcs->Signature), bcs->Tag, 
63448                         bcs->Residue, bcs->Status);
63449         if ((bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN) &&
63450 diff -Nru a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
63451 --- a/drivers/usb/storage/unusual_devs.h        Wed Aug  6 10:59:43 2003
63452 +++ b/drivers/usb/storage/unusual_devs.h        Wed Aug 27 03:03:51 2003
63453 @@ -264,7 +264,7 @@
63454  UNUSUAL_DEV(  0x054c, 0x002e, 0x0106, 0x0310, 
63455                 "Sony",
63456                 "Handycam",
63457 -               US_SC_SCSI, US_PR_CB, NULL,
63458 +               US_SC_SCSI, US_PR_DEVICE, NULL,
63459                 US_FL_SINGLE_LUN | US_FL_MODE_XLATE),
63460  
63461  UNUSUAL_DEV(  0x054c, 0x0032, 0x0000, 0x9999,
63462 diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
63463 --- a/drivers/usb/storage/usb.c Fri Aug 15 10:14:26 2003
63464 +++ b/drivers/usb/storage/usb.c Sat Aug 23 02:37:39 2003
63465 @@ -1006,20 +1006,23 @@
63466   * Initialization and registration
63467   ***********************************************************************/
63468  
63469 -int __init usb_stor_init(void)
63470 +static int __init usb_stor_init(void)
63471  {
63472 +       int retval;
63473         printk(KERN_INFO "Initializing USB Mass Storage driver...\n");
63474  
63475 -       /* register the driver, return -1 if error */
63476 -       if (usb_register(&usb_storage_driver) < 0)
63477 -               return -1;
63478 +       /* register the driver, return usb_register return code if error */
63479 +       retval = usb_register(&usb_storage_driver);
63480 +       if (retval)
63481 +               goto out;
63482  
63483         /* we're all set */
63484         printk(KERN_INFO "USB Mass Storage support registered.\n");
63485 -       return 0;
63486 +out:
63487 +       return retval;
63488  }
63489  
63490 -void __exit usb_stor_exit(void)
63491 +static void __exit usb_stor_exit(void)
63492  {
63493         US_DEBUGP("usb_stor_exit() called\n");
63494  
63495 diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
63496 --- a/drivers/usb/storage/usb.h Thu Jul 17 15:58:30 2003
63497 +++ b/drivers/usb/storage/usb.h Thu Aug 21 20:31:58 2003
63498 @@ -48,7 +48,6 @@
63499  #include <linux/blkdev.h>
63500  #include <linux/smp_lock.h>
63501  #include <linux/completion.h>
63502 -#include <linux/version.h>
63503  #include "scsi.h"
63504  #include "hosts.h"
63505  
63506 diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
63507 --- a/drivers/usb/usb-skeleton.c        Wed Aug  6 02:20:34 2003
63508 +++ b/drivers/usb/usb-skeleton.c        Tue Sep  2 11:40:27 2003
63509 @@ -1,7 +1,7 @@
63510  /*
63511   * USB Skeleton driver - 1.1
63512   *
63513 - * Copyright (c) 2001-2003 Greg Kroah-Hartman (greg@kroah.com)
63514 + * Copyright (C) 2001-2003 Greg Kroah-Hartman (greg@kroah.com)
63515   *
63516   *     This program is free software; you can redistribute it and/or
63517   *     modify it under the terms of the GNU General Public License as
63518 @@ -229,7 +229,7 @@
63519  
63520         dbg("%s", __FUNCTION__);
63521  
63522 -       subminor = minor (inode->i_rdev);
63523 +       subminor = iminor(inode);
63524  
63525         /* prevent disconnects */
63526         down (&disconnect_sem);
63527 @@ -295,7 +295,7 @@
63528         if (atomic_read (&dev->write_busy))
63529                 wait_for_completion (&dev->write_finished);
63530  
63531 -       dev->open = 0;
63532 +       --dev->open;
63533  
63534         if (!dev->present) {
63535                 /* the device was unplugged before the file was released */
63536 @@ -677,10 +677,10 @@
63537  
63538         /* register this driver with the USB subsystem */
63539         result = usb_register(&skel_driver);
63540 -       if (result < 0) {
63541 +       if (result) {
63542                 err("usb_register failed. Error number %d",
63543                     result);
63544 -               return -1;
63545 +               return result;
63546         }
63547  
63548         info(DRIVER_DESC " " DRIVER_VERSION);
63549 diff -Nru a/drivers/video/68328fb.c b/drivers/video/68328fb.c
63550 --- a/drivers/video/68328fb.c   Fri Dec  6 12:36:20 2002
63551 +++ b/drivers/video/68328fb.c   Sun Aug 31 16:14:08 2003
63552 @@ -401,12 +401,12 @@
63553                                                ((1<<(width))-1)) : 0))
63554  
63555  static struct fb_ops mc68328_fb_ops = {
63556 -       .owner:         THIS_MODULE,
63557 -       .fb_setcolreg:  mc68328fb_setcolreg,
63558 -       .fb_fillrect:   cfbfillrect,
63559 -       .fb_copyarea:   cfbcopyarea,
63560 -       .fb_imageblit:  cfbimgblt,
63561 -       .fb_cursor:     softcursor,
63562 +       .owner          = THIS_MODULE,
63563 +       .fb_setcolreg   = mc68328fb_setcolreg,
63564 +       .fb_fillrect    = cfbfillrect,
63565 +       .fb_copyarea    = cfbcopyarea,
63566 +       .fb_imageblit   = cfbimgblt,
63567 +       .fb_cursor      = softcursor,
63568  };
63569  
63570  
63571 diff -Nru a/drivers/video/Kconfig b/drivers/video/Kconfig
63572 --- a/drivers/video/Kconfig     Wed Jun  4 22:54:29 2003
63573 +++ b/drivers/video/Kconfig     Sun Aug 24 06:05:48 2003
63574 @@ -40,7 +40,7 @@
63575  
63576  config FB_CIRRUS
63577         tristate "Cirrus Logic support"
63578 -       depends on FB && (AMIGA || PCI)
63579 +       depends on FB && (AMIGA || PCI) && BROKEN
63580         ---help---
63581           This enables support for Cirrus Logic GD542x/543x based boards on
63582           Amiga: SD64, Piccolo, Picasso II/II+, Picasso IV, or EGS Spectrum.
63583 @@ -55,7 +55,7 @@
63584  
63585  config FB_PM2
63586         tristate "Permedia2 support"
63587 -       depends on FB && (AMIGA || PCI)
63588 +       depends on FB && (AMIGA || PCI) && BROKEN
63589         help
63590           This is the frame buffer device driver for the Permedia2 AGP frame
63591           buffer card from ASK, aka `Graphic Blaster Exxtreme'.  There is a
63592 @@ -802,7 +802,7 @@
63593  
63594  config FB_PM3
63595         tristate "Permedia3 support"
63596 -       depends on FB && PCI
63597 +       depends on FB && PCI && BROKEN
63598         help
63599           This is the frame buffer device driver for the 3DLabs Permedia3
63600           chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 &
63601 diff -Nru a/drivers/video/Makefile b/drivers/video/Makefile
63602 --- a/drivers/video/Makefile    Sun May 25 08:40:39 2003
63603 +++ b/drivers/video/Makefile    Sun Aug 24 08:05:27 2003
63604 @@ -24,8 +24,8 @@
63605  obj-$(CONFIG_FB_RADEON)                  += radeonfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
63606  obj-$(CONFIG_FB_NEOMAGIC)         += neofb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
63607  obj-$(CONFIG_FB_IGA)              += igafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
63608 -obj-$(CONFIG_FB_CONTROL)          += controlfb.o
63609 -obj-$(CONFIG_FB_PLATINUM)         += platinumfb.o
63610 +obj-$(CONFIG_FB_CONTROL)          += controlfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
63611 +obj-$(CONFIG_FB_PLATINUM)         += platinumfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
63612  obj-$(CONFIG_FB_VALKYRIE)         += valkyriefb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
63613  obj-$(CONFIG_FB_CT65550)          += chipsfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
63614  obj-$(CONFIG_FB_ANAKIN)           += anakinfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
63615 diff -Nru a/drivers/video/controlfb.c b/drivers/video/controlfb.c
63616 --- a/drivers/video/controlfb.c Thu Apr 24 03:30:41 2003
63617 +++ b/drivers/video/controlfb.c Sun Aug 24 06:15:21 2003
63618 @@ -475,7 +475,7 @@
63619  
63620         /* Apply default var */
63621         var.activate = FB_ACTIVATE_NOW;
63622 -       rc = fb_set_var(&var, &p->info);
63623 +       rc = fb_set_var(&p->info, &var);
63624         if (rc && (vmode != VMODE_640_480_60 || cmode != CMODE_8))
63625                 goto try_again;
63626  
63627 diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
63628 --- a/drivers/video/fbmem.c     Wed Jul 23 07:45:30 2003
63629 +++ b/drivers/video/fbmem.c     Tue Aug 26 09:25:41 2003
63630 @@ -768,7 +768,7 @@
63631  {
63632         unsigned long p = *ppos;
63633         struct inode *inode = file->f_dentry->d_inode;
63634 -       int fbidx = minor(inode->i_rdev);
63635 +       int fbidx = iminor(inode);
63636         struct fb_info *info = registered_fb[fbidx];
63637  
63638         if (!info || ! info->screen_base)
63639 @@ -802,7 +802,7 @@
63640  {
63641         unsigned long p = *ppos;
63642         struct inode *inode = file->f_dentry->d_inode;
63643 -       int fbidx = minor(inode->i_rdev);
63644 +       int fbidx = iminor(inode);
63645         struct fb_info *info = registered_fb[fbidx];
63646         int err;
63647  
63648 @@ -964,7 +964,7 @@
63649  fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
63650          unsigned long arg)
63651  {
63652 -       int fbidx = minor(inode->i_rdev);
63653 +       int fbidx = iminor(inode);
63654         struct fb_info *info = registered_fb[fbidx];
63655         struct fb_ops *fb = info->fbops;
63656         struct fb_var_screeninfo var;
63657 @@ -1050,7 +1050,7 @@
63658  static int 
63659  fb_mmap(struct file *file, struct vm_area_struct * vma)
63660  {
63661 -       int fbidx = minor(file->f_dentry->d_inode->i_rdev);
63662 +       int fbidx = iminor(file->f_dentry->d_inode);
63663         struct fb_info *info = registered_fb[fbidx];
63664         struct fb_ops *fb = info->fbops;
63665         unsigned long off;
63666 @@ -1149,7 +1149,7 @@
63667  static int
63668  fb_open(struct inode *inode, struct file *file)
63669  {
63670 -       int fbidx = minor(inode->i_rdev);
63671 +       int fbidx = iminor(inode);
63672         struct fb_info *info;
63673         int res = 0;
63674  
63675 @@ -1174,7 +1174,7 @@
63676  static int 
63677  fb_release(struct inode *inode, struct file *file)
63678  {
63679 -       int fbidx = minor(inode->i_rdev);
63680 +       int fbidx = iminor(inode);
63681         struct fb_info *info;
63682  
63683         lock_kernel();
63684 diff -Nru a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
63685 --- a/drivers/video/platinumfb.c        Thu Apr 24 03:30:41 2003
63686 +++ b/drivers/video/platinumfb.c        Sun Aug 24 07:51:47 2003
63687 @@ -35,6 +35,7 @@
63688  #include <asm/io.h>
63689  #include <asm/prom.h>
63690  #include <asm/pgtable.h>
63691 +#include <asm/of_device.h>
63692  
63693  #include "macmodes.h"
63694  #include "platinumfb.h"
63695 @@ -87,7 +88,6 @@
63696   * internal functions
63697   */
63698  
63699 -static void platinum_of_init(struct device_node *dp);
63700  static inline int platinum_vram_reqd(int video_mode, int color_mode);
63701  static int read_platinum_sense(struct fb_info_platinum *info);
63702  static void set_platinum_clock(struct fb_info_platinum *info);
63703 @@ -323,7 +323,7 @@
63704  /*
63705   * Set misc info vars for this driver
63706   */
63707 -static void __init platinum_init_info(struct fb_info *info, struct fb_info_platinum *p)
63708 +static void __devinit platinum_init_info(struct fb_info *info, struct fb_info_platinum *p)
63709  {
63710         /* Fill fb_info */
63711         info->par = &p->par;
63712 @@ -349,7 +349,7 @@
63713  }
63714  
63715  
63716 -static int __init init_platinum(struct fb_info_platinum *p)
63717 +static int __devinit platinum_init_fb(struct fb_info_platinum *p)
63718  {
63719         struct fb_var_screeninfo var;
63720         int sense, rc;
63721 @@ -399,126 +399,21 @@
63722         /* Apply default var */
63723         p->info.var = var;
63724         var.activate = FB_ACTIVATE_NOW;
63725 -       rc = fb_set_var(&var, &p->info);
63726 +       rc = fb_set_var(&p->info, &var);
63727         if (rc && (default_vmode != VMODE_640_480_60 || default_cmode != CMODE_8))
63728                 goto try_again;
63729  
63730         /* Register with fbdev layer */
63731 -       if (register_framebuffer(&p->info) < 0)
63732 -               return 0;
63733 +       rc = register_framebuffer(&p->info);
63734 +       if (rc < 0)
63735 +               return rc;
63736  
63737         printk(KERN_INFO "fb%d: platinum frame buffer device\n",
63738                p->info.node);
63739  
63740 -       return 1;
63741 -}
63742 -
63743 -int __init platinum_init(void)
63744 -{
63745 -       struct device_node *dp;
63746 -
63747 -       dp = find_devices("platinum");
63748 -       if (dp != 0)
63749 -               platinum_of_init(dp);
63750         return 0;
63751  }
63752  
63753 -#ifdef __powerpc__
63754 -#define invalidate_cache(addr) \
63755 -       asm volatile("eieio; dcbf 0,%1" \
63756 -       : "=m" (*(addr)) : "r" (addr) : "memory");
63757 -#else
63758 -#define invalidate_cache(addr)
63759 -#endif
63760 -
63761 -static void __init platinum_of_init(struct device_node *dp)
63762 -{
63763 -       struct fb_info_platinum *info;
63764 -       unsigned long           addr, size;
63765 -       volatile __u8           *fbuffer;
63766 -       int                     i, bank0, bank1, bank2, bank3;
63767 -
63768 -       if(dp->n_addrs != 2) {
63769 -               printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs);
63770 -               return;
63771 -       }
63772 -
63773 -       info = kmalloc(sizeof(*info), GFP_ATOMIC);
63774 -       if (info == 0)
63775 -               return;
63776 -       memset(info, 0, sizeof(*info));
63777 -
63778 -       /* Map in frame buffer and registers */
63779 -       for (i = 0; i < dp->n_addrs; ++i) {
63780 -               addr = dp->addrs[i].address;
63781 -               size = dp->addrs[i].size;
63782 -               /* Let's assume we can request either all or nothing */
63783 -               if (!request_mem_region(addr, size, "platinumfb")) {
63784 -                       kfree(info);
63785 -                       return;
63786 -               }
63787 -               if (size >= 0x400000) {
63788 -                       /* frame buffer - map only 4MB */
63789 -                       info->frame_buffer_phys = addr;
63790 -                       info->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU);
63791 -                       info->base_frame_buffer = info->frame_buffer;
63792 -               } else {
63793 -                       /* registers */
63794 -                       info->platinum_regs_phys = addr;
63795 -                       info->platinum_regs = ioremap(addr, size);
63796 -               }
63797 -       }
63798 -
63799 -       info->cmap_regs_phys = 0xf301b000;      /* XXX not in prom? */
63800 -       request_mem_region(info->cmap_regs_phys, 0x1000, "platinumfb cmap");
63801 -       info->cmap_regs = ioremap(info->cmap_regs_phys, 0x1000);
63802 -
63803 -       /* Grok total video ram */
63804 -       out_be32(&info->platinum_regs->reg[16].r, (unsigned)info->frame_buffer_phys);
63805 -       out_be32(&info->platinum_regs->reg[20].r, 0x1011);      /* select max vram */
63806 -       out_be32(&info->platinum_regs->reg[24].r, 0);   /* switch in vram */
63807 -
63808 -       fbuffer = info->base_frame_buffer;
63809 -       fbuffer[0x100000] = 0x34;
63810 -       fbuffer[0x100008] = 0x0;
63811 -       invalidate_cache(&fbuffer[0x100000]);
63812 -       fbuffer[0x200000] = 0x56;
63813 -       fbuffer[0x200008] = 0x0;
63814 -       invalidate_cache(&fbuffer[0x200000]);
63815 -       fbuffer[0x300000] = 0x78;
63816 -       fbuffer[0x300008] = 0x0;
63817 -       invalidate_cache(&fbuffer[0x300000]);
63818 -       bank0 = 1; /* builtin 1MB vram, always there */
63819 -       bank1 = fbuffer[0x100000] == 0x34;
63820 -       bank2 = fbuffer[0x200000] == 0x56;
63821 -       bank3 = fbuffer[0x300000] == 0x78;
63822 -       info->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
63823 -       printk(KERN_INFO "Total VRAM = %dMB %d%d%d%d\n", (int) (info->total_vram / 1024 / 1024), bank3, bank2, bank1, bank0);
63824 -
63825 -       /*
63826 -        * Try to determine whether we have an old or a new DACula.
63827 -        */
63828 -       out_8(&info->cmap_regs->addr, 0x40);
63829 -       info->dactype = in_8(&info->cmap_regs->d2);
63830 -       switch (info->dactype) {
63831 -       case 0x3c:
63832 -               info->clktype = 1;
63833 -               break;
63834 -       case 0x84:
63835 -               info->clktype = 0;
63836 -               break;
63837 -       default:
63838 -               info->clktype = 0;
63839 -               printk(KERN_INFO "Unknown DACula type: %x\n", info->dactype);
63840 -               break;
63841 -       }
63842 -
63843 -       if (!init_platinum(info)) {
63844 -               kfree(info);
63845 -               return;
63846 -       }
63847 -}
63848 -
63849  /*
63850   * Get the monitor sense value.
63851   * Note that this can be called before calibrate_delay,
63852 @@ -630,4 +525,169 @@
63853         return 0;
63854  }
63855  
63856 +#ifdef __powerpc__
63857 +#define invalidate_cache(addr) \
63858 +       asm volatile("eieio; dcbf 0,%1" \
63859 +       : "=m" (*(addr)) : "r" (addr) : "memory");
63860 +#else
63861 +#define invalidate_cache(addr)
63862 +#endif
63863 +
63864 +static int __devinit platinumfb_probe(struct of_device* odev, const struct of_match *match)
63865 +{
63866 +       struct device_node      *dp = odev->node;
63867 +       struct fb_info_platinum *info;
63868 +       unsigned long           addr, size;
63869 +       volatile __u8           *fbuffer;
63870 +       int                     i, bank0, bank1, bank2, bank3, rc;
63871 +
63872 +       if (dp->n_addrs != 2) {
63873 +               printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs);
63874 +               return -ENXIO;
63875 +       }
63876 +
63877 +       info = kmalloc(sizeof(*info), GFP_ATOMIC);
63878 +       if (info == 0)
63879 +               return -ENOMEM;
63880 +       memset(info, 0, sizeof(*info));
63881 +
63882 +       /* Map in frame buffer and registers */
63883 +       for (i = 0; i < dp->n_addrs; ++i) {
63884 +               addr = dp->addrs[i].address;
63885 +               size = dp->addrs[i].size;
63886 +               /* Let's assume we can request either all or nothing */
63887 +               if (!request_mem_region(addr, size, "platinumfb")) {
63888 +                       kfree(info);
63889 +                       return -ENXIO;
63890 +               }
63891 +               if (size >= 0x400000) {
63892 +                       /* frame buffer - map only 4MB */
63893 +                       info->frame_buffer_phys = addr;
63894 +                       info->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU);
63895 +                       info->base_frame_buffer = info->frame_buffer;
63896 +               } else {
63897 +                       /* registers */
63898 +                       info->platinum_regs_phys = addr;
63899 +                       info->platinum_regs = ioremap(addr, size);
63900 +               }
63901 +       }
63902 +
63903 +       info->cmap_regs_phys = 0xf301b000;      /* XXX not in prom? */
63904 +       request_mem_region(info->cmap_regs_phys, 0x1000, "platinumfb cmap");
63905 +       info->cmap_regs = ioremap(info->cmap_regs_phys, 0x1000);
63906 +
63907 +       /* Grok total video ram */
63908 +       out_be32(&info->platinum_regs->reg[16].r, (unsigned)info->frame_buffer_phys);
63909 +       out_be32(&info->platinum_regs->reg[20].r, 0x1011);      /* select max vram */
63910 +       out_be32(&info->platinum_regs->reg[24].r, 0);   /* switch in vram */
63911 +
63912 +       fbuffer = info->base_frame_buffer;
63913 +       fbuffer[0x100000] = 0x34;
63914 +       fbuffer[0x100008] = 0x0;
63915 +       invalidate_cache(&fbuffer[0x100000]);
63916 +       fbuffer[0x200000] = 0x56;
63917 +       fbuffer[0x200008] = 0x0;
63918 +       invalidate_cache(&fbuffer[0x200000]);
63919 +       fbuffer[0x300000] = 0x78;
63920 +       fbuffer[0x300008] = 0x0;
63921 +       invalidate_cache(&fbuffer[0x300000]);
63922 +       bank0 = 1; /* builtin 1MB vram, always there */
63923 +       bank1 = fbuffer[0x100000] == 0x34;
63924 +       bank2 = fbuffer[0x200000] == 0x56;
63925 +       bank3 = fbuffer[0x300000] == 0x78;
63926 +       info->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
63927 +       printk(KERN_INFO "Total VRAM = %dMB %d%d%d%d\n", (int) (info->total_vram / 1024 / 1024), bank3, bank2, bank1, bank0);
63928 +
63929 +       /*
63930 +        * Try to determine whether we have an old or a new DACula.
63931 +        */
63932 +       out_8(&info->cmap_regs->addr, 0x40);
63933 +       info->dactype = in_8(&info->cmap_regs->d2);
63934 +       switch (info->dactype) {
63935 +       case 0x3c:
63936 +               info->clktype = 1;
63937 +               break;
63938 +       case 0x84:
63939 +               info->clktype = 0;
63940 +               break;
63941 +       default:
63942 +               info->clktype = 0;
63943 +               printk(KERN_INFO "Unknown DACula type: %x\n", info->dactype);
63944 +               break;
63945 +       }
63946 +       dev_set_drvdata(&odev->dev, info);
63947 +       
63948 +       rc = platinum_init_fb(info);
63949 +       if (rc != 0) {
63950 +               dev_set_drvdata(&odev->dev, NULL);
63951 +               kfree(info);
63952 +       }
63953 +
63954 +       return rc;
63955 +}
63956 +
63957 +static int __devexit platinumfb_remove(struct of_device* odev)
63958 +{
63959 +       struct fb_info_platinum *pinfo = dev_get_drvdata(&odev->dev);
63960 +       struct device_node *dp = odev->node;
63961 +       unsigned long addr, size;
63962 +       int i;
63963 +       
63964 +       if (!pinfo)
63965 +               return 0;
63966 +
63967 +        unregister_framebuffer (&pinfo->info);
63968 +       
63969 +       /* Unmap frame buffer and registers */
63970 +       for (i = 0; i < dp->n_addrs; ++i) {
63971 +               addr = dp->addrs[i].address;
63972 +               size = dp->addrs[i].size;
63973 +               release_mem_region(addr, size);
63974 +       }
63975 +       iounmap((void *)pinfo->frame_buffer);
63976 +       iounmap((void *)pinfo->platinum_regs);
63977 +       release_mem_region(pinfo->cmap_regs_phys, 0x1000);
63978 +       iounmap((void *)pinfo->cmap_regs);
63979 +
63980 +       kfree(pinfo);
63981 +
63982 +       return 0;
63983 +}
63984 +
63985 +static struct of_match platinumfb_match[] = 
63986 +{
63987 +       {
63988 +       .name           = "platinum",
63989 +       .type           = OF_ANY_MATCH,
63990 +       .compatible     = OF_ANY_MATCH,
63991 +       },
63992 +       {},
63993 +};
63994 +
63995 +static struct of_platform_driver platinum_driver = 
63996 +{
63997 +       .name           = "platinumfb",
63998 +       .match_table    = platinumfb_match,
63999 +       .probe          = platinumfb_probe,
64000 +       .remove         = platinumfb_remove,
64001 +};
64002 +
64003 +int __init platinum_init(void)
64004 +{
64005 +       of_register_driver(&platinum_driver);
64006 +
64007 +       return 0;
64008 +}
64009 +
64010 +void __exit platinum_exit(void)
64011 +{
64012 +       of_unregister_driver(&platinum_driver); 
64013 +}
64014 +
64015  MODULE_LICENSE("GPL");
64016 +MODULE_DESCRIPTION("framebuffer driver for Apple Platinum video");
64017 +
64018 +#ifdef MODULE
64019 +module_init(platinum_init);
64020 +module_exit(platinum_exit);
64021 +#endif
64022 diff -Nru a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
64023 --- a/drivers/video/riva/fbdev.c        Thu Jul 31 08:58:45 2003
64024 +++ b/drivers/video/riva/fbdev.c        Sun Aug 31 16:14:08 2003
64025 @@ -297,34 +297,34 @@
64026  #endif
64027  
64028  static struct fb_fix_screeninfo rivafb_fix = {
64029 -       id:             "nVidia",
64030 -       type:           FB_TYPE_PACKED_PIXELS,
64031 -       xpanstep:       1,
64032 -       ypanstep:       1,
64033 +       .id             = "nVidia",
64034 +       .type           = FB_TYPE_PACKED_PIXELS,
64035 +       .xpanstep       = 1,
64036 +       .ypanstep       = 1,
64037  };
64038  
64039  static struct fb_var_screeninfo rivafb_default_var = {
64040 -       xres:           640,
64041 -       yres:           480,
64042 -       xres_virtual:   640,
64043 -       yres_virtual:   480,
64044 -       bits_per_pixel: 8,
64045 -       red:            {0, 8, 0},
64046 -       green:          {0, 8, 0},
64047 -       blue:           {0, 8, 0},
64048 -       transp:         {0, 0, 0},
64049 -       activate:       FB_ACTIVATE_NOW,
64050 -       height:         -1,
64051 -       width:          -1,
64052 -       accel_flags:    FB_ACCELF_TEXT,
64053 -       pixclock:       39721,
64054 -       left_margin:    40,
64055 -       right_margin:   24,
64056 -       upper_margin:   32,
64057 -       lower_margin:   11,
64058 -       hsync_len:      96,
64059 -       vsync_len:      2,
64060 -       vmode:          FB_VMODE_NONINTERLACED
64061 +       .xres           = 640,
64062 +       .yres           = 480,
64063 +       .xres_virtual   = 640,
64064 +       .yres_virtual   = 480,
64065 +       .bits_per_pixel = 8,
64066 +       .red            = {0, 8, 0},
64067 +       .green          = {0, 8, 0},
64068 +       .blue           = {0, 8, 0},
64069 +       .transp         = {0, 0, 0},
64070 +       .activate       = FB_ACTIVATE_NOW,
64071 +       .height         = -1,
64072 +       .width          = -1,
64073 +       .accel_flags    = FB_ACCELF_TEXT,
64074 +       .pixclock       = 39721,
64075 +       .left_margin    = 40,
64076 +       .right_margin   = 24,
64077 +       .upper_margin   = 32,
64078 +       .lower_margin   = 11,
64079 +       .hsync_len      = 96,
64080 +       .vsync_len      = 2,
64081 +       .vmode          = FB_VMODE_NONINTERLACED
64082  };
64083  
64084  /* from GGI */
64085 @@ -1977,10 +1977,10 @@
64086  #endif /* !MODULE */
64087  
64088  static struct pci_driver rivafb_driver = {
64089 -       name:           "rivafb",
64090 -       id_table:       rivafb_pci_tbl,
64091 -       probe:          rivafb_probe,
64092 -       remove:         __exit_p(rivafb_remove),
64093 +       .name           = "rivafb",
64094 +       .id_table       = rivafb_pci_tbl,
64095 +       .probe          = rivafb_probe,
64096 +       .remove         = __exit_p(rivafb_remove),
64097  };
64098  
64099  
64100 diff -Nru a/drivers/video/stifb.c b/drivers/video/stifb.c
64101 --- a/drivers/video/stifb.c     Sat May 31 23:26:17 2003
64102 +++ b/drivers/video/stifb.c     Tue Aug 26 09:25:41 2003
64103 @@ -890,7 +890,7 @@
64104  {
64105         unsigned long p = *ppos;
64106         struct inode *inode = file->f_dentry->d_inode;
64107 -       int fbidx = minor(inode->i_rdev);
64108 +       int fbidx = iminor(inode);
64109         struct fb_info *info = registered_fb[fbidx];
64110         char tmpbuf[TMPBUFLEN];
64111  
64112 @@ -922,7 +922,7 @@
64113  stifb_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
64114  {
64115         struct inode *inode = file->f_dentry->d_inode;
64116 -       int fbidx = minor(inode->i_rdev);
64117 +       int fbidx = iminor(inode);
64118         struct fb_info *info = registered_fb[fbidx];
64119         unsigned long p = *ppos;
64120         size_t c;
64121 diff -Nru a/fs/affs/file.c b/fs/affs/file.c
64122 --- a/fs/affs/file.c    Sat Dec 14 09:42:09 2002
64123 +++ b/fs/affs/file.c    Sun Aug 31 16:14:08 2003
64124 @@ -793,8 +793,8 @@
64125  
64126  struct address_space_operations affs_aops_ofs = {
64127         .readpage = affs_readpage_ofs,
64128 -       //writepage: affs_writepage_ofs,
64129 -       //sync_page: affs_sync_page_ofs,
64130 +       //.writepage = affs_writepage_ofs,
64131 +       //.sync_page = affs_sync_page_ofs,
64132         .prepare_write = affs_prepare_write_ofs,
64133         .commit_write = affs_commit_write_ofs
64134  };
64135 diff -Nru a/fs/afs/callback.c b/fs/afs/callback.c
64136 --- a/fs/afs/callback.c Tue Oct  8 01:00:44 2002
64137 +++ b/fs/afs/callback.c Tue Aug 26 09:37:39 2003
64138 @@ -146,7 +146,7 @@
64139                         spin_unlock(&vnode->lock);
64140  
64141                         if (valid) {
64142 -                               invalidate_inode_pages(inode->i_mapping);
64143 +                               invalidate_remote_inode(inode);
64144                                 afs_put_server(server);
64145                         }
64146                         iput(inode);
64147 diff -Nru a/fs/afs/dir.c b/fs/afs/dir.c
64148 --- a/fs/afs/dir.c      Thu Jul  3 06:36:44 2003
64149 +++ b/fs/afs/dir.c      Tue Aug 26 09:37:39 2003
64150 @@ -569,7 +569,7 @@
64151                         spin_lock(&AFS_FS_I(inode)->lock);
64152                         AFS_FS_I(inode)->flags |= AFS_VNODE_DELETED;
64153                         spin_unlock(&AFS_FS_I(inode)->lock);
64154 -                       invalidate_inode_pages(inode->i_mapping);
64155 +                       invalidate_remote_inode(inode);
64156                         goto out_bad;
64157                 }
64158  
64159 diff -Nru a/fs/bad_inode.c b/fs/bad_inode.c
64160 --- a/fs/bad_inode.c    Tue Dec  3 11:20:54 2002
64161 +++ b/fs/bad_inode.c    Sun Aug 31 16:14:21 2003
64162 @@ -4,6 +4,8 @@
64163   *  Copyright (C) 1997, Stephen Tweedie
64164   *
64165   *  Provide stub functions for unreadable inodes
64166 + *
64167 + *  Fabian Frederick : August 2003 - All file operations assigned to EIO
64168   */
64169  
64170  #include <linux/fs.h>
64171 @@ -31,8 +33,10 @@
64172  static struct file_operations bad_file_ops =
64173  {
64174         .llseek         = EIO_ERROR,
64175 +       .aio_read       = EIO_ERROR,
64176         .read           = EIO_ERROR,
64177         .write          = EIO_ERROR,
64178 +       .aio_write      = EIO_ERROR,
64179         .readdir        = EIO_ERROR,
64180         .poll           = EIO_ERROR,
64181         .ioctl          = EIO_ERROR,
64182 @@ -41,8 +45,14 @@
64183         .flush          = EIO_ERROR,
64184         .release        = EIO_ERROR,
64185         .fsync          = EIO_ERROR,
64186 +       .aio_fsync      = EIO_ERROR,
64187         .fasync         = EIO_ERROR,
64188         .lock           = EIO_ERROR,
64189 +       .readv          = EIO_ERROR,
64190 +       .writev         = EIO_ERROR,
64191 +       .sendfile       = EIO_ERROR,
64192 +       .sendpage       = EIO_ERROR,
64193 +       .get_unmapped_area = EIO_ERROR,
64194  };
64195  
64196  struct inode_operations bad_inode_ops =
64197 @@ -61,6 +71,11 @@
64198         .truncate       = EIO_ERROR,
64199         .permission     = EIO_ERROR,
64200         .getattr        = EIO_ERROR,
64201 +       .setattr        = EIO_ERROR,
64202 +       .setxattr       = EIO_ERROR,
64203 +       .getxattr       = EIO_ERROR,
64204 +       .listxattr      = EIO_ERROR,
64205 +       .removexattr    = EIO_ERROR,
64206  };
64207  
64208  
64209 diff -Nru a/fs/bio.c b/fs/bio.c
64210 --- a/fs/bio.c  Fri May  2 11:30:24 2003
64211 +++ b/fs/bio.c  Wed Sep  3 23:40:00 2003
64212 @@ -296,7 +296,7 @@
64213                  unsigned int offset)
64214  {
64215         request_queue_t *q = bdev_get_queue(bio->bi_bdev);
64216 -       int fail_segments = 0, retried_segments = 0;
64217 +       int retried_segments = 0;
64218         struct bio_vec *bvec;
64219  
64220         /*
64221 @@ -315,18 +315,15 @@
64222          * we might lose a segment or two here, but rather that than
64223          * make this too complex.
64224          */
64225 -retry_segments:
64226 -       if (bio_phys_segments(q, bio) >= q->max_phys_segments
64227 -           || bio_hw_segments(q, bio) >= q->max_hw_segments)
64228 -               fail_segments = 1;
64229  
64230 -       if (fail_segments) {
64231 +       while (bio_phys_segments(q, bio) >= q->max_phys_segments
64232 +           || bio_hw_segments(q, bio) >= q->max_hw_segments) {
64233 +
64234                 if (retried_segments)
64235                         return 0;
64236  
64237                 bio->bi_flags &= ~(1 << BIO_SEG_VALID);
64238                 retried_segments = 1;
64239 -               goto retry_segments;
64240         }
64241  
64242         /*
64243 @@ -793,10 +790,6 @@
64244                                         mempool_free_slab, bp->slab);
64245                 if (!bp->pool)
64246                         panic("biovec: can't init mempool\n");
64247 -
64248 -               printk("biovec pool[%d]: %3d bvecs: %3d entries (%d bytes)\n",
64249 -                                               i, bp->nr_vecs, pool_entries,
64250 -                                               size);
64251         }
64252  }
64253  
64254 @@ -809,8 +802,6 @@
64255         bio_pool = mempool_create(BIO_POOL_SIZE, mempool_alloc_slab, mempool_free_slab, bio_slab);
64256         if (!bio_pool)
64257                 panic("bio: can't create mempool\n");
64258 -
64259 -       printk("BIO: pool of %d setup, %ZuKb (%Zd bytes/bio)\n", BIO_POOL_SIZE, BIO_POOL_SIZE * sizeof(struct bio) >> 10, sizeof(struct bio));
64260  
64261         biovec_init_pools();
64262  
64263 diff -Nru a/fs/block_dev.c b/fs/block_dev.c
64264 --- a/fs/block_dev.c    Wed Aug 20 22:31:51 2003
64265 +++ b/fs/block_dev.c    Tue Aug 26 12:06:15 2003
64266 @@ -197,40 +197,36 @@
64267   * pseudo-fs
64268   */
64269  
64270 -static struct super_block *bd_get_sb(struct file_system_type *fs_type,
64271 -       int flags, const char *dev_name, void *data)
64272 -{
64273 -       return get_sb_pseudo(fs_type, "bdev:", NULL, 0x62646576);
64274 -}
64275 +static spinlock_t bdev_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
64276 +static kmem_cache_t * bdev_cachep;
64277  
64278 -static struct file_system_type bd_type = {
64279 -       .name           = "bdev",
64280 -       .get_sb         = bd_get_sb,
64281 -       .kill_sb        = kill_anon_super,
64282 +struct bdev_inode {
64283 +       struct block_device bdev;
64284 +       struct inode vfs_inode;
64285  };
64286  
64287 -static struct vfsmount *bd_mnt;
64288 -struct super_block *blockdev_superblock;
64289 -
64290 -/*
64291 - * bdev cache handling - shamelessly stolen from inode.c
64292 - * We use smaller hashtable, though.
64293 - */
64294 +static inline struct bdev_inode *BDEV_I(struct inode *inode)
64295 +{
64296 +       return container_of(inode, struct bdev_inode, vfs_inode);
64297 +}
64298  
64299 -#define HASH_BITS      6
64300 -#define HASH_SIZE      (1UL << HASH_BITS)
64301 -#define HASH_MASK      (HASH_SIZE-1)
64302 -static struct list_head bdev_hashtable[HASH_SIZE];
64303 -static spinlock_t bdev_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
64304 -static kmem_cache_t * bdev_cachep;
64305 +static struct inode *bdev_alloc_inode(struct super_block *sb)
64306 +{
64307 +       struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, SLAB_KERNEL);
64308 +       if (!ei)
64309 +               return NULL;
64310 +       return &ei->vfs_inode;
64311 +}
64312  
64313 -#define alloc_bdev() \
64314 -        ((struct block_device *) kmem_cache_alloc(bdev_cachep, SLAB_KERNEL))
64315 -#define destroy_bdev(bdev) kmem_cache_free(bdev_cachep, (bdev))
64316 +static void bdev_destroy_inode(struct inode *inode)
64317 +{
64318 +       kmem_cache_free(bdev_cachep, BDEV_I(inode));
64319 +}
64320  
64321  static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
64322  {
64323 -       struct block_device * bdev = (struct block_device *) foo;
64324 +       struct bdev_inode *ei = (struct bdev_inode *) foo;
64325 +       struct block_device *bdev = &ei->bdev;
64326  
64327         if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
64328             SLAB_CTOR_CONSTRUCTOR)
64329 @@ -238,25 +234,62 @@
64330                 memset(bdev, 0, sizeof(*bdev));
64331                 sema_init(&bdev->bd_sem, 1);
64332                 INIT_LIST_HEAD(&bdev->bd_inodes);
64333 +               INIT_LIST_HEAD(&bdev->bd_list);
64334 +               inode_init_once(&ei->vfs_inode);
64335         }
64336  }
64337  
64338 -void __init bdev_cache_init(void)
64339 +static inline void __bd_forget(struct inode *inode)
64340 +{
64341 +       list_del_init(&inode->i_devices);
64342 +       inode->i_bdev = NULL;
64343 +       inode->i_mapping = &inode->i_data;
64344 +}
64345 +
64346 +static void bdev_clear_inode(struct inode *inode)
64347 +{
64348 +       struct block_device *bdev = &BDEV_I(inode)->bdev;
64349 +       struct list_head *p;
64350 +       spin_lock(&bdev_lock);
64351 +       while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
64352 +               __bd_forget(list_entry(p, struct inode, i_devices));
64353 +       }
64354 +       list_del_init(&bdev->bd_list);
64355 +       spin_unlock(&bdev_lock);
64356 +}
64357 +
64358 +static struct super_operations bdev_sops = {
64359 +       .statfs = simple_statfs,
64360 +       .alloc_inode = bdev_alloc_inode,
64361 +       .destroy_inode = bdev_destroy_inode,
64362 +       .drop_inode = generic_delete_inode,
64363 +       .clear_inode = bdev_clear_inode,
64364 +};
64365 +
64366 +static struct super_block *bd_get_sb(struct file_system_type *fs_type,
64367 +       int flags, const char *dev_name, void *data)
64368  {
64369 -       int i, err;
64370 -       struct list_head *head = bdev_hashtable;
64371 +       return get_sb_pseudo(fs_type, "bdev:", &bdev_sops, 0x62646576);
64372 +}
64373 +
64374 +static struct file_system_type bd_type = {
64375 +       .name           = "bdev",
64376 +       .get_sb         = bd_get_sb,
64377 +       .kill_sb        = kill_anon_super,
64378 +};
64379  
64380 -       i = HASH_SIZE;
64381 -       do {
64382 -               INIT_LIST_HEAD(head);
64383 -               head++;
64384 -               i--;
64385 -       } while (i);
64386 +static struct vfsmount *bd_mnt;
64387 +struct super_block *blockdev_superblock;
64388  
64389 +void __init bdev_cache_init(void)
64390 +{
64391 +       int err;
64392         bdev_cachep = kmem_cache_create("bdev_cache",
64393 -                                        sizeof(struct block_device),
64394 -                                        0, SLAB_HWCACHE_ALIGN, init_once,
64395 -                                        NULL);
64396 +                                       sizeof(struct bdev_inode),
64397 +                                       0,
64398 +                                       SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
64399 +                                       init_once,
64400 +                                       NULL);
64401         if (!bdev_cachep)
64402                 panic("Cannot create bdev_cache SLAB cache");
64403         err = register_filesystem(&bd_type);
64404 @@ -272,123 +305,83 @@
64405  /*
64406   * Most likely _very_ bad one - but then it's hardly critical for small
64407   * /dev and can be fixed when somebody will need really large one.
64408 + * Keep in mind that it will be fed through icache hash function too.
64409   */
64410  static inline unsigned long hash(dev_t dev)
64411  {
64412 -       unsigned long tmp = dev;
64413 -       tmp = tmp + (tmp >> HASH_BITS) + (tmp >> HASH_BITS*2);
64414 -       return tmp & HASH_MASK;
64415 +       return MAJOR(dev)+MINOR(dev);
64416  }
64417  
64418 -static struct block_device *bdfind(dev_t dev, struct list_head *head)
64419 +static int bdev_test(struct inode *inode, void *data)
64420  {
64421 -       struct list_head *p;
64422 -       struct block_device *bdev;
64423 -       list_for_each(p, head) {
64424 -               bdev = list_entry(p, struct block_device, bd_hash);
64425 -               if (bdev->bd_dev != dev)
64426 -                       continue;
64427 -               atomic_inc(&bdev->bd_count);
64428 -               return bdev;
64429 -       }
64430 -       return NULL;
64431 +       return BDEV_I(inode)->bdev.bd_dev == *(dev_t *)data;
64432  }
64433  
64434 +static int bdev_set(struct inode *inode, void *data)
64435 +{
64436 +       BDEV_I(inode)->bdev.bd_dev = *(dev_t *)data;
64437 +       return 0;
64438 +}
64439 +
64440 +static LIST_HEAD(all_bdevs);
64441 +
64442  struct block_device *bdget(dev_t dev)
64443  {
64444 -       struct list_head * head = bdev_hashtable + hash(dev);
64445 -       struct block_device *bdev, *new_bdev;
64446 -       spin_lock(&bdev_lock);
64447 -       bdev = bdfind(dev, head);
64448 -       spin_unlock(&bdev_lock);
64449 -       if (bdev)
64450 -               return bdev;
64451 -       new_bdev = alloc_bdev();
64452 -       if (new_bdev) {
64453 -               struct inode *inode = new_inode(bd_mnt->mnt_sb);
64454 -               if (inode) {
64455 -                       kdev_t kdev = to_kdev_t(dev);
64456 -
64457 -                       atomic_set(&new_bdev->bd_count,1);
64458 -                       new_bdev->bd_dev = dev;
64459 -                       new_bdev->bd_contains = NULL;
64460 -                       new_bdev->bd_inode = inode;
64461 -                       new_bdev->bd_block_size = (1 << inode->i_blkbits);
64462 -                       new_bdev->bd_part_count = 0;
64463 -                       new_bdev->bd_invalidated = 0;
64464 -                       inode->i_mode = S_IFBLK;
64465 -                       inode->i_rdev = kdev;
64466 -                       inode->i_bdev = new_bdev;
64467 -                       inode->i_data.a_ops = &def_blk_aops;
64468 -                       mapping_set_gfp_mask(&inode->i_data, GFP_USER);
64469 -                       inode->i_data.backing_dev_info = &default_backing_dev_info;
64470 -                       spin_lock(&bdev_lock);
64471 -                       bdev = bdfind(dev, head);
64472 -                       if (!bdev) {
64473 -                               list_add(&new_bdev->bd_hash, head);
64474 -                               spin_unlock(&bdev_lock);
64475 -                               return new_bdev;
64476 -                       }
64477 -                       spin_unlock(&bdev_lock);
64478 -                       iput(new_bdev->bd_inode);
64479 -               }
64480 -               destroy_bdev(new_bdev);
64481 +       struct block_device *bdev;
64482 +       struct inode *inode;
64483 +
64484 +       inode = iget5_locked(bd_mnt->mnt_sb, hash(dev),
64485 +                       bdev_test, bdev_set, &dev);
64486 +
64487 +       if (!inode)
64488 +               return NULL;
64489 +
64490 +       bdev = &BDEV_I(inode)->bdev;
64491 +
64492 +       if (inode->i_state & I_NEW) {
64493 +               bdev->bd_contains = NULL;
64494 +               bdev->bd_inode = inode;
64495 +               bdev->bd_block_size = (1 << inode->i_blkbits);
64496 +               bdev->bd_part_count = 0;
64497 +               bdev->bd_invalidated = 0;
64498 +               inode->i_mode = S_IFBLK;
64499 +               inode->i_rdev = to_kdev_t(dev);
64500 +               inode->i_bdev = bdev;
64501 +               inode->i_data.a_ops = &def_blk_aops;
64502 +               mapping_set_gfp_mask(&inode->i_data, GFP_USER);
64503 +               inode->i_data.backing_dev_info = &default_backing_dev_info;
64504 +               spin_lock(&bdev_lock);
64505 +               list_add(&bdev->bd_list, &all_bdevs);
64506 +               spin_unlock(&bdev_lock);
64507 +               unlock_new_inode(inode);
64508         }
64509         return bdev;
64510  }
64511  
64512  long nr_blockdev_pages(void)
64513  {
64514 +       struct list_head *p;
64515         long ret = 0;
64516 -       int i;
64517 -
64518         spin_lock(&bdev_lock);
64519 -       for (i = 0; i < ARRAY_SIZE(bdev_hashtable); i++) {
64520 -               struct list_head *head = &bdev_hashtable[i];
64521 -               struct list_head *lh;
64522 -
64523 -               if (head == NULL)
64524 -                       continue;
64525 -               list_for_each(lh, head) {
64526 -                       struct block_device *bdev;
64527 -
64528 -                       bdev = list_entry(lh, struct block_device, bd_hash);
64529 -                       ret += bdev->bd_inode->i_mapping->nrpages;
64530 -               }
64531 +       list_for_each(p, &all_bdevs) {
64532 +               struct block_device *bdev;
64533 +               bdev = list_entry(p, struct block_device, bd_list);
64534 +               ret += bdev->bd_inode->i_mapping->nrpages;
64535         }
64536         spin_unlock(&bdev_lock);
64537         return ret;
64538  }
64539  
64540 -static inline void __bd_forget(struct inode *inode)
64541 -{
64542 -       list_del_init(&inode->i_devices);
64543 -       inode->i_bdev = NULL;
64544 -       inode->i_mapping = &inode->i_data;
64545 -}
64546 -
64547  void bdput(struct block_device *bdev)
64548  {
64549 -       if (atomic_dec_and_lock(&bdev->bd_count, &bdev_lock)) {
64550 -               struct list_head *p;
64551 -               if (bdev->bd_openers)
64552 -                       BUG();
64553 -               list_del(&bdev->bd_hash);
64554 -               while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
64555 -                       __bd_forget(list_entry(p, struct inode, i_devices));
64556 -               }
64557 -               spin_unlock(&bdev_lock);
64558 -               iput(bdev->bd_inode);
64559 -               destroy_bdev(bdev);
64560 -       }
64561 +       iput(bdev->bd_inode);
64562  }
64563   
64564  int bd_acquire(struct inode *inode)
64565  {
64566         struct block_device *bdev;
64567         spin_lock(&bdev_lock);
64568 -       if (inode->i_bdev) {
64569 -               atomic_inc(&inode->i_bdev->bd_count);
64570 +       if (inode->i_bdev && igrab(inode->i_bdev->bd_inode)) {
64571                 spin_unlock(&bdev_lock);
64572                 return 0;
64573         }
64574 @@ -397,12 +390,11 @@
64575         if (!bdev)
64576                 return -ENOMEM;
64577         spin_lock(&bdev_lock);
64578 -       if (!inode->i_bdev) {
64579 -               inode->i_bdev = bdev;
64580 -               inode->i_mapping = bdev->bd_inode->i_mapping;
64581 -               list_add(&inode->i_devices, &bdev->bd_inodes);
64582 -       } else if (inode->i_bdev != bdev)
64583 -               BUG();
64584 +       if (inode->i_bdev)
64585 +               __bd_forget(inode);
64586 +       inode->i_bdev = bdev;
64587 +       inode->i_mapping = bdev->bd_inode->i_mapping;
64588 +       list_add(&inode->i_devices, &bdev->bd_inodes);
64589         spin_unlock(&bdev_lock);
64590         return 0;
64591  }
64592 @@ -548,7 +540,6 @@
64593                                 if (ret)
64594                                         goto out_first;
64595                         }
64596 -                       bdev->bd_offset = 0;
64597                         if (!bdev->bd_openers) {
64598                                 bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
64599                                 bdi = blk_get_backing_dev_info(bdev);
64600 @@ -580,7 +571,8 @@
64601                                 ret = -ENXIO;
64602                                 goto out_first;
64603                         }
64604 -                       bdev->bd_offset = p->start_sect;
64605 +                       kobject_get(&p->kobj);
64606 +                       bdev->bd_part = p;
64607                         bd_set_size(bdev, (loff_t) p->nr_sects << 9);
64608                         up(&whole->bd_sem);
64609                 }
64610 @@ -701,6 +693,10 @@
64611                 put_disk(disk);
64612                 module_put(owner);
64613  
64614 +               if (bdev->bd_contains != bdev) {
64615 +                       kobject_put(&bdev->bd_part->kobj);
64616 +                       bdev->bd_part = NULL;
64617 +               }
64618                 bdev->bd_disk = NULL;
64619                 bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
64620                 if (bdev != bdev->bd_contains) {
64621 diff -Nru a/fs/cifs/CHANGES b/fs/cifs/CHANGES
64622 --- a/fs/cifs/CHANGES   Thu Aug 21 16:44:46 2003
64623 +++ b/fs/cifs/CHANGES   Tue Sep  2 11:34:09 2003
64624 @@ -1,3 +1,14 @@
64625 +Version 0.91
64626 +------------
64627 +Fix oops in reopen_files when invalid dentry. drop dentry on server rename 
64628 +and on revalidate errors. Fix cases where pid is now tgid.  Fix return code
64629 +on create hard link when server does not support them. 
64630 +
64631 +Version 0.90
64632 +------------
64633 +Fix scheduling while atomic error in getting inode info on newly created file. 
64634 +Fix truncate of existing files opened with O_CREAT but not O_TRUNC set.
64635 +
64636  Version 0.89
64637  ------------
64638  Fix oops on write to dead tcp session. Remove error log write for case when file open
64639 diff -Nru a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
64640 --- a/fs/cifs/cifsfs.c  Sun Aug 10 22:50:41 2003
64641 +++ b/fs/cifs/cifsfs.c  Tue Aug 26 09:37:39 2003
64642 @@ -598,10 +598,12 @@
64643                                 netfid = oplock_item->netfid;
64644                                 DeleteOplockQEntry(oplock_item);
64645                                 write_unlock(&GlobalMid_Lock);
64646 -                               rc = filemap_fdatawrite(inode->i_mapping);
64647 -                               if(rc)
64648 -                                       CIFS_I(inode)->write_behind_rc 
64649 -                                               = rc;
64650 +                               if (S_ISREG(inode->i_mode))
64651 +                                       rc = filemap_fdatawrite(inode->i_mapping);
64652 +                               else
64653 +                                       rc = 0;
64654 +                               if (rc)
64655 +                                       CIFS_I(inode)->write_behind_rc = rc;
64656                                 cFYI(1,("Oplock flush inode %p rc %d",inode,rc));
64657                                 rc = CIFSSMBLock(0, pTcon, netfid,
64658                                         0 /* len */ , 0 /* offset */, 0, 
64659 diff -Nru a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
64660 --- a/fs/cifs/cifssmb.c Thu Aug 21 15:06:59 2003
64661 +++ b/fs/cifs/cifssmb.c Fri Aug 29 01:50:52 2003
64662 @@ -1,7 +1,7 @@
64663  /*
64664   *   fs/cifs/cifssmb.c
64665   *
64666 - *   Copyright (c) International Business Machines  Corp., 2002
64667 + *   Copyright (C) International Business Machines  Corp., 2002,2003
64668   *   Author(s): Steve French (sfrench@us.ibm.com)
64669   *
64670   *   Contains the routines for constructing the SMB PDUs themselves
64671 @@ -656,7 +656,7 @@
64672         pSMB->AndXCommand = 0xFF;       /* none */
64673         pSMB->Fid = smb_file_id; /* netfid stays le */
64674  
64675 -       pSMB->Locks[0].Pid = cpu_to_le16(current->pid);
64676 +       pSMB->Locks[0].Pid = cpu_to_le16(current->tgid);
64677         pSMB->Locks[0].Length = cpu_to_le64(len);
64678         pSMB->Locks[0].Offset = cpu_to_le64(offset);
64679         pSMB->ByteCount = sizeof (LOCKING_ANDX_RANGE);
64680 diff -Nru a/fs/cifs/dir.c b/fs/cifs/dir.c
64681 --- a/fs/cifs/dir.c     Thu Aug 21 15:06:59 2003
64682 +++ b/fs/cifs/dir.c     Fri Aug 29 01:50:52 2003
64683 @@ -3,7 +3,7 @@
64684   *
64685   *   vfs operations that deal with dentries
64686   * 
64687 - *   Copyright (c) International Business Machines  Corp., 2002
64688 + *   Copyright (C) International Business Machines  Corp., 2002,2003
64689   *   Author(s): Steve French (sfrench@us.ibm.com)
64690   *
64691   *   This library is free software; you can redistribute it and/or modify
64692 @@ -134,6 +134,7 @@
64693         struct inode *newinode = NULL;
64694         struct cifsFileInfo * pCifsFile = NULL;
64695         struct cifsInodeInfo * pCifsInode;
64696 +       int disposition = FILE_OVERWRITE_IF;
64697  
64698         xid = GetXid();
64699  
64700 @@ -151,6 +152,16 @@
64701                         desiredAccess = GENERIC_WRITE;
64702                 else if ((nd->intent.open.flags & O_ACCMODE) == O_RDWR)
64703                         desiredAccess = GENERIC_ALL;
64704 +
64705 +               if((nd->intent.open.flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
64706 +                       disposition = FILE_CREATE;
64707 +               else if((nd->intent.open.flags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC))
64708 +                       disposition = FILE_OVERWRITE_IF;
64709 +               else if((nd->intent.open.flags & O_CREAT) == O_CREAT)
64710 +                       disposition = FILE_OPEN_IF;
64711 +               else {
64712 +                       cFYI(1,("Create flag not set in create function"));
64713 +               }
64714         }
64715  
64716         /* BB add processing to set equivalent of mode - e.g. via CreateX with ACLs */
64717 @@ -158,7 +169,7 @@
64718                 oplock = REQ_OPLOCK;
64719  
64720         buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL);
64721 -       rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OVERWRITE_IF,
64722 +       rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
64723                          desiredAccess, CREATE_NOT_DIR,
64724                          &fileHandle, &oplock, buf, cifs_sb->local_nls);
64725         if (rc) {
64726 @@ -205,7 +216,7 @@
64727                                 memset((char *)pCifsFile, 0,
64728                                        sizeof (struct cifsFileInfo));
64729                                 pCifsFile->netfid = fileHandle;
64730 -                               pCifsFile->pid = current->pid;
64731 +                               pCifsFile->pid = current->tgid;
64732                                 pCifsFile->pInode = newinode;
64733                                 /* pCifsFile->pfile = file; */ /* put in at open time */
64734                                 write_lock(&GlobalSMBSeslock);
64735 @@ -297,6 +308,9 @@
64736              (" parent inode = 0x%p name is: %s and dentry = 0x%p",
64737               parent_dir_inode, direntry->d_name.name, direntry));
64738  
64739 +       if(nd) {  /* BB removeme */
64740 +               cFYI(1,("In lookup nd flags 0x%x open intent flags 0x%x",nd->flags,nd->intent.open.flags));
64741 +       } /* BB removeme BB */
64742         /* BB Add check of incoming data - e.g. frame not longer than maximum SMB - let server check the namelen BB */
64743  
64744         /* check whether path exists */
64745 diff -Nru a/fs/cifs/file.c b/fs/cifs/file.c
64746 --- a/fs/cifs/file.c    Thu Aug 21 15:13:09 2003
64747 +++ b/fs/cifs/file.c    Fri Aug 29 00:58:20 2003
64748 @@ -3,7 +3,7 @@
64749   *
64750   *   vfs operations that deal with files
64751   * 
64752 - *   Copyright (c) International Business Machines  Corp., 2002
64753 + *   Copyright (C) International Business Machines  Corp., 2002,2003
64754   *   Author(s): Steve French (sfrench@us.ibm.com)
64755   *
64756   *   This library is free software; you can redistribute it and/or modify
64757 @@ -144,6 +144,10 @@
64758                         list_add(&pCifsFile->tlist,&pTcon->openFileList);
64759                         pCifsInode = CIFS_I(file->f_dentry->d_inode);
64760                         if(pCifsInode) {
64761 +                               list_add(&pCifsFile->flist,&pCifsInode->openFileList);
64762 +                               write_unlock(&GlobalSMBSeslock);
64763 +                               write_unlock(&file->f_owner.lock);
64764 +
64765                                 if (pTcon->ses->capabilities & CAP_UNIX)
64766                                         rc = cifs_get_inode_info_unix(&file->f_dentry->d_inode,
64767                                                 full_path, inode->i_sb);
64768 @@ -151,16 +155,16 @@
64769                                         rc = cifs_get_inode_info(&file->f_dentry->d_inode,
64770                                                 full_path, buf, inode->i_sb);
64771  
64772 -                               list_add(&pCifsFile->flist,&pCifsInode->openFileList);
64773                                 if(oplock == OPLOCK_EXCLUSIVE) {
64774                                         pCifsInode->clientCanCacheAll = TRUE;
64775                                         pCifsInode->clientCanCacheRead = TRUE;
64776                                         cFYI(1,("Exclusive Oplock granted on inode %p",file->f_dentry->d_inode));
64777                                 } else if(oplock == OPLOCK_READ)
64778                                         pCifsInode->clientCanCacheRead = TRUE;
64779 +                       } else {
64780 +                               write_unlock(&GlobalSMBSeslock);
64781 +                               write_unlock(&file->f_owner.lock);
64782                         }
64783 -                       write_unlock(&GlobalSMBSeslock);
64784 -                       write_unlock(&file->f_owner.lock);
64785                         if(file->f_flags & O_CREAT) {           
64786                                 /* time to set mode which we can not set earlier due
64787                                  to problems creating new read-only files */
64788 @@ -221,16 +225,21 @@
64789                         if(file) {                
64790                                 file->private_data = NULL;
64791                                 read_unlock(&GlobalSMBSeslock);
64792 -                               rc = cifs_open(file->f_dentry->d_inode,file);
64793 -                               read_lock(&GlobalSMBSeslock);
64794 -                               if(rc) {
64795 -                                       cFYI(1,("reconnecting file %s failed with %d",
64796 -                                               file->f_dentry->d_name.name,rc));
64797 +                               if(file->f_dentry == 0) {
64798 +                                       cFYI(1,("Null dentry for file %p",file));
64799 +                                       read_lock(&GlobalSMBSeslock);
64800                                 } else {
64801 -                                       cFYI(1,("reconnection of %s succeeded",
64802 -                                               file->f_dentry->d_name.name));
64803 -                               }
64804 -                       } 
64805 +                                       rc = cifs_open(file->f_dentry->d_inode,file);
64806 +                                       read_lock(&GlobalSMBSeslock);
64807 +                                       if(rc) {
64808 +                                               cFYI(1,("reconnecting file %s failed with %d",
64809 +                                                       file->f_dentry->d_name.name,rc));
64810 +                                       } else {
64811 +                                               cFYI(1,("reconnection of %s succeeded",
64812 +                                                       file->f_dentry->d_name.name));
64813 +                                       }
64814 +                               } 
64815 +                       }
64816                 }
64817         }
64818         read_unlock(&GlobalSMBSeslock);
64819 diff -Nru a/fs/cifs/inode.c b/fs/cifs/inode.c
64820 --- a/fs/cifs/inode.c   Fri Aug 15 04:18:47 2003
64821 +++ b/fs/cifs/inode.c   Mon Sep  1 03:41:02 2003
64822 @@ -1,7 +1,7 @@
64823  /*
64824   *   fs/cifs/inode.c
64825   *
64826 - *   Copyright (c) International Business Machines  Corp., 2002
64827 + *   Copyright (C) International Business Machines  Corp., 2002,2003
64828   *   Author(s): Steve French (sfrench@us.ibm.com)
64829   *
64830   *   This library is free software; you can redistribute it and/or modify
64831 @@ -345,6 +345,8 @@
64832  
64833         if (!rc) {
64834                 direntry->d_inode->i_nlink--;
64835 +       } else if (rc == -ENOENT) {
64836 +               d_drop(direntry);
64837         } else if (rc == -ETXTBSY) {
64838                 int oplock = FALSE;
64839                 __u16 netfid;
64840 @@ -585,12 +587,24 @@
64841                 }            
64842         }
64843  
64844 -       if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)
64845 -               cifs_get_inode_info_unix(&direntry->d_inode, full_path,
64846 +       if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
64847 +               rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path,
64848                                          direntry->d_sb);
64849 -       else
64850 -               cifs_get_inode_info(&direntry->d_inode, full_path, NULL,
64851 +               if(rc) {
64852 +                       cFYI(1,("error on getting revalidate info %d",rc));
64853 +/*                     if(rc != -ENOENT)
64854 +                               rc = 0; */ /* BB should we cache info on certain errors? */
64855 +               }
64856 +       } else {
64857 +               rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL,
64858                                     direntry->d_sb);
64859 +               if(rc) {
64860 +                       cFYI(1,("error on getting revalidate info %d",rc));
64861 +/*                     if(rc != -ENOENT)
64862 +                               rc = 0; */  /* BB should we cache info on certain errors? */
64863 +               }
64864 +       }
64865 +       /* should we remap certain errors, access denied?, to zero */
64866  
64867         /* BB if not oplocked, invalidate inode pages if mtime has changed */
64868  
64869 diff -Nru a/fs/cifs/link.c b/fs/cifs/link.c
64870 --- a/fs/cifs/link.c    Mon Jul 21 22:32:20 2003
64871 +++ b/fs/cifs/link.c    Tue Sep  2 11:34:10 2003
64872 @@ -1,7 +1,7 @@
64873  /*
64874   *   fs/cifs/link.c
64875   *
64876 - *   Copyright (c) International Business Machines  Corp., 2002
64877 + *   Copyright (C) International Business Machines  Corp., 2002,2003
64878   *   Author(s): Steve French (sfrench@us.ibm.com)
64879   *
64880   *   This library is free software; you can redistribute it and/or modify
64881 @@ -51,9 +51,12 @@
64882         if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX)
64883                 rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName,
64884                                             cifs_sb_target->local_nls);
64885 -       else
64886 +       else {
64887                 rc = CIFSCreateHardLink(xid, pTcon, fromName, toName,
64888                                         cifs_sb_target->local_nls);
64889 +               if(rc == -EIO)
64890 +                       rc = -EOPNOTSUPP;  
64891 +       }
64892  
64893  /* if (!rc)     */
64894         {
64895 diff -Nru a/fs/cifs/misc.c b/fs/cifs/misc.c
64896 --- a/fs/cifs/misc.c    Wed Aug  6 12:45:33 2003
64897 +++ b/fs/cifs/misc.c    Fri Aug 29 01:50:52 2003
64898 @@ -1,7 +1,7 @@
64899  /*
64900   *   fs/cifs/misc.c
64901   *
64902 - *   Copyright (c) International Business Machines  Corp., 2002
64903 + *   Copyright (c) International Business Machines  Corp., 2002,2003
64904   *   Author(s): Steve French (sfrench@us.ibm.com)
64905   *
64906   *   This library is free software; you can redistribute it and/or modify
64907 @@ -213,7 +213,7 @@
64908         buffer->Command = smb_command;
64909         buffer->Flags = 0x00;   /* case sensitive */
64910         buffer->Flags2 = SMBFLG2_KNOWS_LONG_NAMES;
64911 -       tmp = cpu_to_le32(current->pid);
64912 +       tmp = cpu_to_le32(current->tgid);
64913         buffer->Pid = tmp & 0xFFFF;
64914         tmp >>= 16;
64915         buffer->PidHigh = tmp & 0xFFFF;
64916 diff -Nru a/fs/coda/inode.c b/fs/coda/inode.c
64917 --- a/fs/coda/inode.c   Fri Jun 20 13:16:06 2003
64918 +++ b/fs/coda/inode.c   Tue Aug 26 09:25:41 2003
64919 @@ -115,7 +115,7 @@
64920                 inode = file->f_dentry->d_inode;
64921         
64922         if(!inode || !S_ISCHR(inode->i_mode) ||
64923 -          major(inode->i_rdev) != CODA_PSDEV_MAJOR) {
64924 +          imajor(inode) != CODA_PSDEV_MAJOR) {
64925                 if(file)
64926                         fput(file);
64927  
64928 @@ -123,7 +123,7 @@
64929                 return -1;
64930         }
64931  
64932 -       idx = minor(inode->i_rdev);
64933 +       idx = iminor(inode);
64934         fput(file);
64935  
64936         if(idx < 0 || idx >= MAX_CODADEVS) {
64937 diff -Nru a/fs/coda/psdev.c b/fs/coda/psdev.c
64938 --- a/fs/coda/psdev.c   Wed May  7 08:47:30 2003
64939 +++ b/fs/coda/psdev.c   Tue Aug 26 09:25:41 2003
64940 @@ -279,7 +279,7 @@
64941         int idx;
64942  
64943         lock_kernel();
64944 -       idx = minor(inode->i_rdev);
64945 +       idx = iminor(inode);
64946         if(idx >= MAX_CODADEVS) {
64947                 unlock_kernel();
64948                 return -ENODEV;
64949 diff -Nru a/fs/compat.c b/fs/compat.c
64950 --- a/fs/compat.c       Sun Jul 13 14:26:23 2003
64951 +++ b/fs/compat.c       Sun Aug 31 16:14:44 2003
64952 @@ -227,7 +227,8 @@
64953  #define IOCTL_HASHSIZE 256
64954  struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
64955  
64956 -extern struct ioctl_trans ioctl_start[], ioctl_end[]; 
64957 +extern struct ioctl_trans ioctl_start[];
64958 +extern int ioctl_table_size;
64959  
64960  static inline unsigned long ioctl32_hash(unsigned long cmd)
64961  {
64962 @@ -255,7 +256,7 @@
64963  {
64964         int i;
64965  
64966 -       for (i = 0; &ioctl_start[i] < &ioctl_end[0]; i++) {
64967 +       for (i = 0; i < ioctl_table_size; i++) {
64968                 if (ioctl_start[i].next != 0) { 
64969                         printk("ioctl translation %d bad\n",i); 
64970                         return -1;
64971 @@ -318,8 +319,7 @@
64972  
64973  static inline int builtin_ioctl(struct ioctl_trans *t)
64974  { 
64975 -       return t >= (struct ioctl_trans *)ioctl_start &&
64976 -              t < (struct ioctl_trans *)ioctl_end; 
64977 +       return t >= ioctl_start && t < (ioctl_start + ioctl_table_size);
64978  } 
64979  
64980  /* Problem: 
64981 diff -Nru a/fs/compat_ioctl.c b/fs/compat_ioctl.c
64982 --- a/fs/compat_ioctl.c Thu Jul  3 15:19:48 2003
64983 +++ b/fs/compat_ioctl.c Tue Aug 26 09:25:40 2003
64984 @@ -1573,7 +1573,7 @@
64985                 return -EINVAL;
64986                         
64987         tty = (struct tty_struct *)file->private_data;
64988 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
64989 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
64990                 return -EINVAL;
64991                                                         
64992         if (tty->driver->ioctl != vt_ioctl)
64993 diff -Nru a/fs/dnotify.c b/fs/dnotify.c
64994 --- a/fs/dnotify.c      Wed Apr  2 22:51:32 2003
64995 +++ b/fs/dnotify.c      Sun Aug 31 16:14:42 2003
64996 @@ -20,8 +20,6 @@
64997  #include <linux/spinlock.h>
64998  #include <linux/slab.h>
64999  
65000 -extern void send_sigio(struct fown_struct *fown, int fd, int band);
65001 -
65002  int dir_notify_enable = 1;
65003  
65004  static rwlock_t dn_lock = RW_LOCK_UNLOCKED;
65005 @@ -94,7 +92,7 @@
65006                 prev = &odn->dn_next;
65007         }
65008  
65009 -       error = f_setown(filp, current->pid, 1);
65010 +       error = f_setown(filp, current->tgid, 1);
65011         if (error)
65012                 goto out_free;
65013  
65014 diff -Nru a/fs/ext2/namei.c b/fs/ext2/namei.c
65015 --- a/fs/ext2/namei.c   Sun Jun 29 23:49:04 2003
65016 +++ b/fs/ext2/namei.c   Sun Aug 31 16:14:21 2003
65017 @@ -143,7 +143,7 @@
65018         int err = PTR_ERR(inode);
65019         if (!IS_ERR(inode)) {
65020                 init_special_inode(inode, inode->i_mode, rdev);
65021 -#ifdef CONFIG_EXT2_FS_EXT_ATTR
65022 +#ifdef CONFIG_EXT2_FS_XATTR
65023                 inode->i_op = &ext2_special_inode_operations;
65024  #endif
65025                 mark_inode_dirty(inode);
65026 diff -Nru a/fs/ext3/namei.c b/fs/ext3/namei.c
65027 --- a/fs/ext3/namei.c   Wed Aug 20 22:32:02 2003
65028 +++ b/fs/ext3/namei.c   Sun Aug 31 16:14:18 2003
65029 @@ -1306,7 +1306,7 @@
65030  
65031         /* The 0th block becomes the root, move the dirents out */
65032         fde = &root->dotdot;
65033 -       de = (struct ext3_dir_entry_2 *)((char *)fde + fde->rec_len);
65034 +       de = (struct ext3_dir_entry_2 *)((char *)fde + le16_to_cpu(fde->rec_len));
65035         len = ((char *) root) + blocksize - (char *) de;
65036         memcpy (data1, de, len);
65037         de = (struct ext3_dir_entry_2 *) data1;
65038 diff -Nru a/fs/ext3/xattr.c b/fs/ext3/xattr.c
65039 --- a/fs/ext3/xattr.c   Thu Jul 17 22:30:42 2003
65040 +++ b/fs/ext3/xattr.c   Sun Aug 31 16:15:47 2003
65041 @@ -873,17 +873,22 @@
65042                const void *value, size_t value_len, int flags)
65043  {
65044         handle_t *handle;
65045 -       int error, error2;
65046 +       int error;
65047  
65048         handle = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS);
65049 -       if (IS_ERR(handle))
65050 +       if (IS_ERR(handle)) {
65051                 error = PTR_ERR(handle);
65052 -       else
65053 +       } else {
65054 +               int error2;
65055 +
65056                 error = ext3_xattr_set_handle(handle, inode, name_index, name,
65057                                               value, value_len, flags);
65058 -       error2 = ext3_journal_stop(handle);
65059 +               error2 = ext3_journal_stop(handle);
65060 +               if (error == 0)
65061 +                       error = error2;
65062 +       }
65063  
65064 -       return error ? error : error2;
65065 +       return error;
65066  }
65067  
65068  /*
65069 diff -Nru a/fs/fcntl.c b/fs/fcntl.c
65070 --- a/fs/fcntl.c        Thu Jun  5 23:36:40 2003
65071 +++ b/fs/fcntl.c        Sun Aug 31 16:14:42 2003
65072 @@ -6,6 +6,7 @@
65073  
65074  #include <linux/init.h>
65075  #include <linux/mm.h>
65076 +#include <linux/fs.h>
65077  #include <linux/file.h>
65078  #include <linux/dnotify.h>
65079  #include <linux/smp_lock.h>
65080 @@ -17,9 +18,6 @@
65081  #include <asm/poll.h>
65082  #include <asm/siginfo.h>
65083  #include <asm/uaccess.h>
65084 -
65085 -extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
65086 -extern int fcntl_getlease(struct file *filp);
65087  
65088  void set_close_on_exec(unsigned int fd, int flag)
65089  {
65090 diff -Nru a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
65091 --- a/fs/freevxfs/vxfs_inode.c  Sun Nov 17 11:53:57 2002
65092 +++ b/fs/freevxfs/vxfs_inode.c  Sun Aug 31 16:14:27 2003
65093 @@ -171,7 +171,7 @@
65094         return NULL;
65095  
65096  fail:
65097 -       printk(KERN_WARNING "vxfs: unable to read inode %ld\n", ino);
65098 +       printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino);
65099         vxfs_put_page(pp);
65100         return NULL;
65101  }
65102 diff -Nru a/fs/hpfs/namei.c b/fs/hpfs/namei.c
65103 --- a/fs/hpfs/namei.c   Sun Jun 29 23:49:25 2003
65104 +++ b/fs/hpfs/namei.c   Tue Aug 26 09:37:39 2003
65105 @@ -375,6 +375,7 @@
65106                 spin_lock(&dentry->d_lock);
65107                 if (atomic_read(&dentry->d_count) > 1 ||
65108                     permission(inode, MAY_WRITE, NULL) ||
65109 +                   !S_ISREG(inode->i_mode) ||
65110                     get_write_access(inode)) {
65111                         spin_unlock(&dentry->d_lock);
65112                         d_rehash(dentry);
65113 diff -Nru a/fs/intermezzo/presto.c b/fs/intermezzo/presto.c
65114 --- a/fs/intermezzo/presto.c    Fri Dec 13 17:27:19 2002
65115 +++ b/fs/intermezzo/presto.c    Tue Aug 26 09:33:56 2003
65116 @@ -66,8 +66,8 @@
65117          cache = presto_get_cache(inode);
65118          CDEBUG(D_PSDEV, "\n");
65119          if ( !cache ) {
65120 -                CERROR("PRESTO: BAD: cannot find cache for dev %d, ino %ld\n",
65121 -                       inode->i_sb->s_dev, inode->i_ino);
65122 +                CERROR("PRESTO: BAD: cannot find cache for dev %s, ino %ld\n",
65123 +                       inode->i_sb->s_id, inode->i_ino);
65124                  EXIT;
65125                  return -1;
65126          }
65127 diff -Nru a/fs/intermezzo/vfs.c b/fs/intermezzo/vfs.c
65128 --- a/fs/intermezzo/vfs.c       Thu Aug  7 10:29:14 2003
65129 +++ b/fs/intermezzo/vfs.c       Tue Aug 26 09:33:56 2003
65130 @@ -743,7 +743,7 @@
65131                  goto exit_lock;
65132  
65133          error = -EXDEV;
65134 -        if (dir->d_inode->i_sb->s_dev != inode->i_sb->s_dev)
65135 +        if (dir->d_inode->i_sb != inode->i_sb)
65136                  goto exit_lock;
65137  
65138          /*
65139 @@ -1800,7 +1800,7 @@
65140          if (error)
65141                  return error;
65142  
65143 -        if (new_dir->i_sb->s_dev != old_dir->i_sb->s_dev)
65144 +        if (new_dir->i_sb != old_dir->i_sb)
65145                  return -EXDEV;
65146  
65147          if (!new_dentry->d_inode)
65148 @@ -1881,7 +1881,7 @@
65149          if (error)
65150                  return error;
65151  
65152 -        if (new_dir->i_sb->s_dev != old_dir->i_sb->s_dev)
65153 +        if (new_dir->i_sb != old_dir->i_sb)
65154                  return -EXDEV;
65155  
65156          if (!new_dentry->d_inode)
65157 diff -Nru a/fs/jbd/journal.c b/fs/jbd/journal.c
65158 --- a/fs/jbd/journal.c  Sat Aug 16 11:46:50 2003
65159 +++ b/fs/jbd/journal.c  Sun Aug 31 16:14:25 2003
65160 @@ -1890,7 +1890,6 @@
65161  {
65162         int ret;
65163  
65164 -       printk(KERN_INFO "Journalled Block Device driver loaded\n");
65165         ret = journal_init_caches();
65166         if (ret != 0)
65167                 journal_destroy_caches();
65168 diff -Nru a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
65169 --- a/fs/jffs/inode-v23.c       Thu Aug 14 18:17:32 2003
65170 +++ b/fs/jffs/inode-v23.c       Sun Aug 31 16:13:59 2003
65171 @@ -1080,9 +1080,11 @@
65172         struct jffs_control *c;
65173         struct inode *inode;
65174         int result = 0;
65175 -       kdev_t dev = to_kdev_t(rdev);
65176 +       u16 data;
65177         int err;
65178  
65179 +       data = (MAJOR(rdev) << 8) | MINOR(rdev);
65180 +
65181         D1(printk("***jffs_mknod()\n"));
65182  
65183         lock_kernel();
65184 @@ -1114,7 +1116,7 @@
65185         raw_inode.mtime = raw_inode.atime;
65186         raw_inode.ctime = raw_inode.atime;
65187         raw_inode.offset = 0;
65188 -       raw_inode.dsize = sizeof(kdev_t);
65189 +       raw_inode.dsize = 2;
65190         raw_inode.rsize = 0;
65191         raw_inode.nsize = dentry->d_name.len;
65192         raw_inode.nlink = 1;
65193 @@ -1124,7 +1126,7 @@
65194  
65195         /* Write the new node to the flash.  */
65196         if ((err = jffs_write_node(c, node, &raw_inode, dentry->d_name.name,
65197 -                                  (unsigned char *)&dev, 0, NULL)) < 0) {
65198 +                                  (unsigned char *)&data, 0, NULL)) < 0) {
65199                 D(printk("jffs_mknod(): jffs_write_node() failed.\n"));
65200                 result = err;
65201                 goto jffs_mknod_err;
65202 @@ -1530,7 +1532,7 @@
65203         return err;
65204  } /* jffs_file_write()  */
65205  
65206 -static ssize_t
65207 +static int
65208  jffs_prepare_write(struct file *filp, struct page *page,
65209                    unsigned from, unsigned to)
65210  {
65211 @@ -1543,7 +1545,7 @@
65212         return 0;
65213  } /* jffs_prepare_write() */
65214  
65215 -static ssize_t
65216 +static int
65217  jffs_commit_write(struct file *filp, struct page *page,
65218                   unsigned from, unsigned to)
65219  {
65220 @@ -1732,9 +1734,10 @@
65221                 /* If the node is a device of some sort, then the number of
65222                    the device should be read from the flash memory and then
65223                    added to the inode's i_rdev member.  */
65224 -               kdev_t rdev;
65225 -               jffs_read_data(f, (char *)&rdev, 0, sizeof(kdev_t));
65226 -               init_special_inode(inode, inode->i_mode, kdev_t_to_nr(rdev));
65227 +               u16 val;
65228 +               jffs_read_data(f, (char *)val, 0, 2);
65229 +               init_special_inode(inode, inode->i_mode,
65230 +                       MKDEV((val >> 8) & 255, val & 255));
65231         }
65232  
65233         D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
65234 diff -Nru a/fs/jffs2/file.c b/fs/jffs2/file.c
65235 --- a/fs/jffs2/file.c   Wed May 28 08:01:06 2003
65236 +++ b/fs/jffs2/file.c   Tue Aug 26 09:25:41 2003
65237 @@ -103,8 +103,8 @@
65238            it out again with the appropriate data attached */
65239         if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
65240                 /* For these, we don't actually need to read the old node */
65241 -               dev =  (major(dentry->d_inode->i_rdev) << 8) | 
65242 -                       minor(dentry->d_inode->i_rdev);
65243 +               dev =  (imajor(dentry->d_inode) << 8) | 
65244 +                       iminor(dentry->d_inode);
65245                 mdata = (char *)&dev;
65246                 mdatalen = sizeof(dev);
65247                 D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen));
65248 diff -Nru a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
65249 --- a/fs/jffs2/os-linux.h       Mon Jun 23 06:03:50 2003
65250 +++ b/fs/jffs2/os-linux.h       Tue Aug 26 09:25:41 2003
65251 @@ -44,8 +44,8 @@
65252  #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
65253  
65254  #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,1)
65255 -#define JFFS2_F_I_RDEV_MIN(f) (minor(OFNI_EDONI_2SFFJ(f)->i_rdev))
65256 -#define JFFS2_F_I_RDEV_MAJ(f) (major(OFNI_EDONI_2SFFJ(f)->i_rdev))
65257 +#define JFFS2_F_I_RDEV_MIN(f) (iminor(OFNI_EDONI_2SFFJ(f)))
65258 +#define JFFS2_F_I_RDEV_MAJ(f) (imajor(OFNI_EDONI_2SFFJ(f)))
65259  #else
65260  #define JFFS2_F_I_RDEV_MIN(f) (MINOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
65261  #define JFFS2_F_I_RDEV_MAJ(f) (MAJOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
65262 diff -Nru a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
65263 --- a/fs/jffs2/wbuf.c   Wed May 28 08:01:07 2003
65264 +++ b/fs/jffs2/wbuf.c   Sun Aug 31 16:14:08 2003
65265 @@ -37,8 +37,8 @@
65266  #define NAND_JFFS2_OOB16_FSDALEN       8
65267  
65268  struct nand_oobinfo jffs2_oobinfo = {
65269 -       useecc: 1,
65270 -       eccpos: {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1, JFFS2_OOB_ECCPOS2, JFFS2_OOB_ECCPOS3, JFFS2_OOB_ECCPOS4, JFFS2_OOB_ECCPOS5}
65271 +       .useecc = 1,
65272 +       .eccpos = {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1, JFFS2_OOB_ECCPOS2, JFFS2_OOB_ECCPOS3, JFFS2_OOB_ECCPOS4, JFFS2_OOB_ECCPOS5}
65273  };
65274  
65275  static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c)
65276 diff -Nru a/fs/nfs/inode.c b/fs/nfs/inode.c
65277 --- a/fs/nfs/inode.c    Fri Jul 11 10:32:02 2003
65278 +++ b/fs/nfs/inode.c    Tue Aug 26 09:37:39 2003
65279 @@ -620,7 +620,7 @@
65280         NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);
65281         NFS_ATTRTIMEO_UPDATE(inode) = jiffies;
65282  
65283 -       invalidate_inode_pages(inode->i_mapping);
65284 +       invalidate_remote_inode(inode);
65285  
65286         memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
65287         NFS_CACHEINV(inode);
65288 @@ -823,14 +823,15 @@
65289                 goto out;
65290         }
65291  
65292 -       if (!S_ISREG(inode->i_mode))
65293 +       if (!S_ISREG(inode->i_mode)) {
65294                 attr->ia_valid &= ~ATTR_SIZE;
65295 -
65296 -       filemap_fdatawrite(inode->i_mapping);
65297 -       error = nfs_wb_all(inode);
65298 -       filemap_fdatawait(inode->i_mapping);
65299 -       if (error)
65300 -               goto out;
65301 +       } else {
65302 +               filemap_fdatawrite(inode->i_mapping);
65303 +               error = nfs_wb_all(inode);
65304 +               filemap_fdatawait(inode->i_mapping);
65305 +               if (error)
65306 +                       goto out;
65307 +       }
65308  
65309         error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr);
65310         if (error)
65311 @@ -1205,7 +1206,7 @@
65312         if (invalid) {
65313                 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
65314                 nfsi->attrtimeo_timestamp = jiffies;
65315 -               invalidate_inode_pages(inode->i_mapping);
65316 +               invalidate_remote_inode(inode);
65317                 memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
65318         } else if (time_after(jiffies, nfsi->attrtimeo_timestamp+nfsi->attrtimeo)) {
65319                 if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode))
65320 diff -Nru a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
65321 --- a/fs/nfsd/nfs4proc.c        Thu Jun 26 21:26:02 2003
65322 +++ b/fs/nfsd/nfs4proc.c        Sun Aug 31 16:14:23 2003
65323 @@ -106,7 +106,8 @@
65324  nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
65325  {
65326         int status;
65327 -       dprintk("NFSD: nfsd4_open filename %.*s\n",open->op_fname.len, open->op_fname.data);
65328 +       dprintk("NFSD: nfsd4_open filename %.*s\n",
65329 +               (int)open->op_fname.len, open->op_fname.data);
65330  
65331         /* This check required by spec. */
65332         if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
65333 diff -Nru a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
65334 --- a/fs/nfsd/nfs4state.c       Thu Jul 31 16:53:11 2003
65335 +++ b/fs/nfsd/nfs4state.c       Sun Aug 31 16:14:23 2003
65336 @@ -688,7 +688,7 @@
65337  #define OPENSTATEID_HASH_MASK              (OPENSTATEID_HASH_SIZE - 1)
65338  
65339  #define file_hashval(x) \
65340 -        ((unsigned int)((x)->dev + (x)->ino + (x)->generation) & FILE_HASH_MASK)
65341 +        hash_ptr(x, FILE_HASH_BITS)
65342  #define openstateid_hashval(owner_id, file_id)  \
65343          (((owner_id) + (file_id)) & OPENSTATEID_HASH_MASK)
65344  
65345 @@ -697,13 +697,13 @@
65346  
65347  /* OPEN Share state helper functions */
65348  static inline struct nfs4_file *
65349 -alloc_init_file(unsigned int hashval, nfs4_ino_desc_t *ino) {
65350 +alloc_init_file(unsigned int hashval, struct inode *ino) {
65351         struct nfs4_file *fp;
65352         if ((fp = kmalloc(sizeof(struct nfs4_file),GFP_KERNEL))) {
65353                 INIT_LIST_HEAD(&fp->fi_hash);
65354                 INIT_LIST_HEAD(&fp->fi_perfile);
65355                 list_add(&fp->fi_hash, &file_hashtbl[hashval]);
65356 -               memcpy(&fp->fi_ino, ino, sizeof(nfs4_ino_desc_t));
65357 +               fp->fi_inode = igrab(ino);
65358                 fp->fi_id = current_fileid++;
65359                 alloc_file++;
65360                 return fp;
65361 @@ -841,11 +841,12 @@
65362  {
65363         free_file++;
65364         list_del_init(&fp->fi_hash);
65365 +       iput(fp->fi_inode);
65366         kfree(fp);
65367  }      
65368  
65369  void
65370 -release_open_state(struct nfs4_stateid *stp)
65371 +release_open_state(struct nfs4_stateid *stp, struct nfsd4_close *cl)
65372  {
65373         struct nfs4_stateowner *sop = stp->st_stateowner;
65374         struct nfs4_file *fp = stp->st_file;
65375 @@ -860,6 +861,7 @@
65376          */
65377         if (sop->so_confirmed && list_empty(&sop->so_peropenstate)) {
65378                 release_stateowner(sop);
65379 +               cl->cl_stateowner = NULL;
65380         }
65381         /* unused nfs4_file's are releseed. XXX slab cache? */
65382         if (list_empty(&fp->fi_perfile)) {
65383 @@ -911,13 +913,13 @@
65384  
65385  /* search file_hashtbl[] for file */
65386  static int
65387 -find_file(unsigned int hashval, nfs4_ino_desc_t *ino, struct nfs4_file **fp) {
65388 +find_file(unsigned int hashval, struct inode *ino, struct nfs4_file **fp) {
65389         struct list_head *pos, *next;
65390         struct nfs4_file *local = NULL;
65391  
65392         list_for_each_safe(pos, next, &file_hashtbl[hashval]) {
65393                 local = list_entry(pos, struct nfs4_file, fi_hash);
65394 -               if(!memcmp(&local->fi_ino, ino, sizeof(nfs4_ino_desc_t))) {
65395 +               if (local->fi_inode == ino) {
65396                         *fp = local;
65397                         return(1);
65398                 }
65399 @@ -934,24 +936,10 @@
65400         return 1;
65401  }
65402  
65403 -static inline void
65404 -nfs4_init_ino(nfs4_ino_desc_t *ino, struct svc_fh *fhp)
65405 -{
65406 -       struct inode *inode;
65407 -       if (!fhp->fh_dentry)
65408 -               BUG();
65409 -       inode = fhp->fh_dentry->d_inode;
65410 -       if (!inode)
65411 -               BUG();
65412 -       ino->dev = inode->i_sb->s_dev;
65413 -       ino->ino = inode->i_ino;
65414 -       ino->generation = inode->i_generation;
65415 -}
65416 -
65417  int
65418  nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
65419  {
65420 -       nfs4_ino_desc_t ino;
65421 +       struct inode *ino = current_fh->fh_dentry->d_inode;
65422         unsigned int fi_hashval;
65423         struct nfs4_file *fp;
65424         struct nfs4_stateid *stp;
65425 @@ -959,9 +947,8 @@
65426  
65427         dprintk("NFSD: nfs4_share_conflict\n");
65428  
65429 -       nfs4_init_ino(&ino, current_fh);
65430 -       fi_hashval = file_hashval(&ino);
65431 -       if (find_file(fi_hashval, &ino, &fp)) {
65432 +       fi_hashval = file_hashval(ino);
65433 +       if (find_file(fi_hashval, ino, &fp)) {
65434         /* Search for conflicting share reservations */
65435                 list_for_each_safe(pos, next, &fp->fi_perfile) {
65436                         stp = list_entry(pos, struct nfs4_stateid, st_perfile);
65437 @@ -1084,7 +1071,7 @@
65438         struct iattr iattr;
65439         struct nfs4_stateowner *sop = open->op_stateowner;
65440         struct nfs4_file *fp;
65441 -       nfs4_ino_desc_t ino;
65442 +       struct inode *ino;
65443         unsigned int fi_hashval;
65444         struct list_head *pos, *next;
65445         struct nfs4_stateid *stq, *stp = NULL;
65446 @@ -1094,11 +1081,11 @@
65447         if (!sop)
65448                 goto out;
65449  
65450 -       nfs4_init_ino(&ino, current_fh);
65451 +       ino = current_fh->fh_dentry->d_inode;
65452  
65453         down(&client_sema); /*XXX need finer grained locking */
65454 -       fi_hashval = file_hashval(&ino);
65455 -       if (find_file(fi_hashval, &ino, &fp)) {
65456 +       fi_hashval = file_hashval(ino);
65457 +       if (find_file(fi_hashval, ino, &fp)) {
65458                 /* Search for conflicting share reservations */
65459                 status = nfserr_share_denied;
65460                 list_for_each_safe(pos, next, &fp->fi_perfile) {
65461 @@ -1113,7 +1100,7 @@
65462         } else {
65463         /* No nfs4_file found; allocate and init a new one */
65464                 status = nfserr_resource;
65465 -               if ((fp = alloc_init_file(fi_hashval, &ino)) == NULL)
65466 +               if ((fp = alloc_init_file(fi_hashval, ino)) == NULL)
65467                         goto out;
65468         }
65469  
65470 @@ -1172,6 +1159,9 @@
65471         open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE;
65472         status = nfs_ok;
65473  out:
65474 +       if (fp && list_empty(&fp->fi_perfile))
65475 +               release_file(fp);
65476 +
65477         /*
65478         * To finish the open response, we just need to set the rflags.
65479         */
65480 @@ -1494,7 +1484,7 @@
65481         struct nfs4_stateid *stp;
65482  
65483         dprintk("NFSD: nfsd4_open_confirm on file %.*s\n",
65484 -                       current_fh->fh_dentry->d_name.len,
65485 +                       (int)current_fh->fh_dentry->d_name.len,
65486                         current_fh->fh_dentry->d_name.name);
65487         oc->oc_stateowner = NULL;
65488         down(&client_sema); /* XXX need finer grained locking */
65489 @@ -1528,7 +1518,7 @@
65490         struct nfs4_stateid *stp;
65491  
65492         dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n", 
65493 -                       current_fh->fh_dentry->d_name.len, 
65494 +                       (int)current_fh->fh_dentry->d_name.len,
65495                         current_fh->fh_dentry->d_name.name);
65496  
65497         down(&client_sema); /* XXX need finer grained locking */
65498 @@ -1567,7 +1557,7 @@
65499         struct nfs4_stateid *stp;
65500  
65501         dprintk("NFSD: nfsd4_close on file %.*s\n", 
65502 -                       current_fh->fh_dentry->d_name.len, 
65503 +                       (int)current_fh->fh_dentry->d_name.len,
65504                         current_fh->fh_dentry->d_name.name);
65505  
65506         down(&client_sema); /* XXX need finer grained locking */
65507 @@ -1584,7 +1574,7 @@
65508         memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t));
65509  
65510         /* release_open_state() calls nfsd_close() if needed */
65511 -       release_open_state(stp);
65512 +       release_open_state(stp,close);
65513  out:
65514         up(&client_sema);
65515         return status;
65516 diff -Nru a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
65517 --- a/fs/nfsd/nfs4xdr.c Sun Aug  3 21:42:17 2003
65518 +++ b/fs/nfsd/nfs4xdr.c Sat Aug 23 15:07:47 2003
65519 @@ -1631,6 +1631,8 @@
65520                 WRITEMEM(&close->cl_stateid.si_opaque, sizeof(stateid_opaque_t));
65521                 ADJUST_ARGS();
65522         }
65523 +       if ((close->cl_stateowner) && (close->cl_stateowner->so_confirmed))
65524 +               close->cl_stateowner->so_seqid++;
65525  }
65526  
65527  
65528 @@ -1767,6 +1769,8 @@
65529         default:
65530                 BUG();
65531         }
65532 +
65533 +       ENCODE_SEQID_OP_TAIL(open->op_stateowner);
65534  }
65535  
65536  static int
65537 diff -Nru a/fs/open.c b/fs/open.c
65538 --- a/fs/open.c Mon Aug 18 22:38:39 2003
65539 +++ b/fs/open.c Sun Aug 31 16:14:00 2003
65540 @@ -945,20 +945,12 @@
65541   */
65542  int filp_close(struct file *filp, fl_owner_t id)
65543  {
65544 -       struct address_space *mapping = filp->f_dentry->d_inode->i_mapping;
65545 -       int retval = 0, err;
65546 +       int retval;
65547  
65548         /* Report and clear outstanding errors */
65549 -       err = filp->f_error;
65550 -       if (err) {
65551 +       retval = filp->f_error;
65552 +       if (retval)
65553                 filp->f_error = 0;
65554 -               retval = err;
65555 -       }
65556 -
65557 -       if (test_and_clear_bit(AS_ENOSPC, &mapping->flags))
65558 -               retval = -ENOSPC;
65559 -       if (test_and_clear_bit(AS_EIO, &mapping->flags))
65560 -               retval = -EIO;
65561  
65562         if (!file_count(filp)) {
65563                 printk(KERN_ERR "VFS: Close: file count is 0\n");
65564 @@ -966,7 +958,7 @@
65565         }
65566  
65567         if (filp->f_op && filp->f_op->flush) {
65568 -               err = filp->f_op->flush(filp);
65569 +               int err = filp->f_op->flush(filp);
65570                 if (!retval)
65571                         retval = err;
65572         }
65573 diff -Nru a/fs/partitions/check.c b/fs/partitions/check.c
65574 --- a/fs/partitions/check.c     Tue Aug 12 06:46:16 2003
65575 +++ b/fs/partitions/check.c     Tue Aug 26 12:06:15 2003
65576 @@ -267,7 +267,14 @@
65577  
65578  extern struct subsystem block_subsys;
65579  
65580 +static void part_release(struct kobject *kobj)
65581 +{
65582 +       struct hd_struct * p = container_of(kobj,struct hd_struct,kobj);
65583 +       kfree(p);
65584 +}
65585 +
65586  struct kobj_type ktype_part = {
65587 +       .release        = part_release,
65588         .default_attrs  = default_attrs,
65589         .sysfs_ops      = &part_sysfs_ops,
65590  };
65591 @@ -279,13 +286,12 @@
65592                 return;
65593         if (!p->nr_sects)
65594                 return;
65595 +       disk->part[part-1] = NULL;
65596         p->start_sect = 0;
65597         p->nr_sects = 0;
65598         p->reads = p->writes = p->read_sectors = p->write_sectors = 0;
65599         devfs_remove("%s/part%d", disk->devfs_name, part);
65600         kobject_unregister(&p->kobj);
65601 -       disk->part[part-1] = NULL;
65602 -       kfree(p);
65603  }
65604  
65605  void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
65606 @@ -300,7 +306,6 @@
65607         p->start_sect = start;
65608         p->nr_sects = len;
65609         p->partno = part;
65610 -       disk->part[part-1] = p;
65611  
65612         devfs_mk_bdev(MKDEV(disk->major, disk->first_minor + part),
65613                         S_IFBLK|S_IRUSR|S_IWUSR,
65614 @@ -310,6 +315,7 @@
65615         p->kobj.parent = &disk->kobj;
65616         p->kobj.ktype = &ktype_part;
65617         kobject_register(&p->kobj);
65618 +       disk->part[part-1] = p;
65619  }
65620  
65621  static void disk_sysfs_symlinks(struct gendisk *disk)
65622 diff -Nru a/fs/proc/base.c b/fs/proc/base.c
65623 --- a/fs/proc/base.c    Thu Jul 10 22:23:45 2003
65624 +++ b/fs/proc/base.c    Sun Aug 31 16:13:56 2003
65625 @@ -864,19 +864,34 @@
65626   *     Exceptional case: normally we are not allowed to unhash a busy
65627   * directory. In this case, however, we can do it - no aliasing problems
65628   * due to the way we treat inodes.
65629 + *
65630 + * Rewrite the inode's ownerships here because the owning task may have
65631 + * performed a setuid(), etc.
65632   */
65633 -static int pid_revalidate(struct dentry * dentry, struct nameidata *nd)
65634 +static int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
65635  {
65636 -       if (pid_alive(proc_task(dentry->d_inode)))
65637 +       struct inode *inode = dentry->d_inode;
65638 +       struct task_struct *task = proc_task(inode);
65639 +       if (pid_alive(task)) {
65640 +               if (proc_type(inode) == PROC_PID_INO || task_dumpable(task)) {
65641 +                       inode->i_uid = task->euid;
65642 +                       inode->i_gid = task->egid;
65643 +               } else {
65644 +                       inode->i_uid = 0;
65645 +                       inode->i_gid = 0;
65646 +               }
65647 +               security_task_to_inode(task, inode);
65648                 return 1;
65649 +       }
65650         d_drop(dentry);
65651         return 0;
65652  }
65653  
65654 -static int pid_fd_revalidate(struct dentry * dentry, struct nameidata *nd)
65655 +static int pid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
65656  {
65657 -       struct task_struct *task = proc_task(dentry->d_inode);
65658 -       int fd = proc_type(dentry->d_inode) - PROC_PID_FD_DIR;
65659 +       struct inode *inode = dentry->d_inode;
65660 +       struct task_struct *task = proc_task(inode);
65661 +       int fd = proc_type(inode) - PROC_PID_FD_DIR;
65662         struct files_struct *files;
65663  
65664         task_lock(task);
65665 @@ -889,6 +904,14 @@
65666                 if (fcheck_files(files, fd)) {
65667                         spin_unlock(&files->file_lock);
65668                         put_files_struct(files);
65669 +                       if (task_dumpable(task)) {
65670 +                               inode->i_uid = task->euid;
65671 +                               inode->i_gid = task->egid;
65672 +                       } else {
65673 +                               inode->i_uid = 0;
65674 +                               inode->i_gid = 0;
65675 +                       }
65676 +                       security_task_to_inode(task, inode);
65677                         return 1;
65678                 }
65679                 spin_unlock(&files->file_lock);
65680 diff -Nru a/fs/proc/kcore.c b/fs/proc/kcore.c
65681 --- a/fs/proc/kcore.c   Fri Jun 20 13:16:05 2003
65682 +++ b/fs/proc/kcore.c   Sun Aug 31 16:14:22 2003
65683 @@ -1,5 +1,5 @@
65684  /*
65685 - *     fs/proc/kcore.c kernel ELF/AOUT core dumper
65686 + *     fs/proc/kcore.c kernel ELF core dumper
65687   *
65688   *     Modelled on fs/exec.c:aout_core_dump()
65689   *     Jeremy Fitzhardinge <jeremy@sw.oz.au>
65690 @@ -34,71 +34,6 @@
65691         .open           = open_kcore,
65692  };
65693  
65694 -#ifdef CONFIG_KCORE_AOUT
65695 -static ssize_t read_kcore(struct file *file, char *buf, size_t count, loff_t *ppos)
65696 -{
65697 -       unsigned long long p = *ppos, memsize;
65698 -       ssize_t read;
65699 -       ssize_t count1;
65700 -       char * pnt;
65701 -       struct user dump;
65702 -#if defined (__i386__) || defined (__mc68000__) || defined(__x86_64__)
65703 -#      define FIRST_MAPPED     PAGE_SIZE       /* we don't have page 0 mapped on x86.. */
65704 -#else
65705 -#      define FIRST_MAPPED     0
65706 -#endif
65707 -
65708 -       memset(&dump, 0, sizeof(struct user));
65709 -       dump.magic = CMAGIC;
65710 -       dump.u_dsize = (virt_to_phys(high_memory) >> PAGE_SHIFT);
65711 -#if defined (__i386__) || defined(__x86_64__)
65712 -       dump.start_code = PAGE_OFFSET;
65713 -#endif
65714 -#ifdef __alpha__
65715 -       dump.start_data = PAGE_OFFSET;
65716 -#endif
65717 -
65718 -       memsize = virt_to_phys(high_memory);
65719 -       if (p >= memsize)
65720 -               return 0;
65721 -       if (count > memsize - p)
65722 -               count = memsize - p;
65723 -       read = 0;
65724 -
65725 -       if (p < sizeof(struct user) && count > 0) {
65726 -               count1 = count;
65727 -               if (p + count1 > sizeof(struct user))
65728 -                       count1 = sizeof(struct user)-p;
65729 -               pnt = (char *) &dump + p;
65730 -               if (copy_to_user(buf,(void *) pnt, count1))
65731 -                       return -EFAULT;
65732 -               buf += count1;
65733 -               p += count1;
65734 -               count -= count1;
65735 -               read += count1;
65736 -       }
65737 -
65738 -       if (count > 0 && p < PAGE_SIZE + FIRST_MAPPED) {
65739 -               count1 = PAGE_SIZE + FIRST_MAPPED - p;
65740 -               if (count1 > count)
65741 -                       count1 = count;
65742 -               if (clear_user(buf, count1))
65743 -                       return -EFAULT;
65744 -               buf += count1;
65745 -               p += count1;
65746 -               count -= count1;
65747 -               read += count1;
65748 -       }
65749 -       if (count > 0) {
65750 -               if (copy_to_user(buf, (void *) (PAGE_OFFSET+p-PAGE_SIZE), count))
65751 -                       return -EFAULT;
65752 -               read += count;
65753 -       }
65754 -       *ppos += read;
65755 -       return read;
65756 -}
65757 -#else /* CONFIG_KCORE_AOUT */
65758 -
65759  #ifndef kc_vaddr_to_offset
65760  #define        kc_vaddr_to_offset(v) ((v) - PAGE_OFFSET)
65761  #endif
65762 @@ -480,4 +415,3 @@
65763  
65764         return acc;
65765  }
65766 -#endif /* CONFIG_KCORE_AOUT */
65767 diff -Nru a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
65768 --- a/fs/proc/proc_misc.c       Sun Aug 17 10:23:59 2003
65769 +++ b/fs/proc/proc_misc.c       Wed Sep  3 23:40:10 2003
65770 @@ -44,6 +44,7 @@
65771  #include <linux/jiffies.h>
65772  #include <linux/sysrq.h>
65773  #include <linux/vmalloc.h>
65774 +#include <linux/irq.h>
65775  #include <asm/uaccess.h>
65776  #include <asm/pgtable.h>
65777  #include <asm/io.h>
65778 @@ -356,10 +357,9 @@
65779         .release        = seq_release,
65780  };
65781  
65782 -static int kstat_read_proc(char *page, char **start, off_t off,
65783 -                                int count, int *eof, void *data)
65784 +int show_stat(struct seq_file *p, void *v)
65785  {
65786 -       int i, len;
65787 +       int i;
65788         extern unsigned long total_forks;
65789         u64 jif;
65790         unsigned int sum = 0, user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0;
65791 @@ -379,10 +379,10 @@
65792         jif = ((u64)now.tv_sec * HZ) + (now.tv_usec/(1000000/HZ)) - jif;
65793         do_div(jif, HZ);
65794  
65795 -       for (i = 0 ; i < NR_CPUS; i++) {
65796 +       for (i = 0; i < NR_CPUS; i++) {
65797                 int j;
65798  
65799 -               if(!cpu_online(i)) continue;
65800 +               if (!cpu_online(i)) continue;
65801                 user += kstat_cpu(i).cpustat.user;
65802                 nice += kstat_cpu(i).cpustat.nice;
65803                 system += kstat_cpu(i).cpustat.system;
65804 @@ -394,7 +394,7 @@
65805                         sum += kstat_cpu(i).irqs[j];
65806         }
65807  
65808 -       len = sprintf(page, "cpu  %u %u %u %u %u %u %u\n",
65809 +       seq_printf(p, "cpu  %u %u %u %u %u %u %u\n",
65810                 jiffies_to_clock_t(user),
65811                 jiffies_to_clock_t(nice),
65812                 jiffies_to_clock_t(system),
65813 @@ -402,9 +402,9 @@
65814                 jiffies_to_clock_t(iowait),
65815                 jiffies_to_clock_t(irq),
65816                 jiffies_to_clock_t(softirq));
65817 -       for (i = 0 ; i < NR_CPUS; i++){
65818 +       for (i = 0; i < NR_CPUS; i++){
65819                 if (!cpu_online(i)) continue;
65820 -               len += sprintf(page + len, "cpu%d %u %u %u %u %u %u %u\n",
65821 +               seq_printf(p, "cpu%d %u %u %u %u %u %u %u\n",
65822                         i,
65823                         jiffies_to_clock_t(kstat_cpu(i).cpustat.user),
65824                         jiffies_to_clock_t(kstat_cpu(i).cpustat.nice),
65825 @@ -414,14 +414,25 @@
65826                         jiffies_to_clock_t(kstat_cpu(i).cpustat.irq),
65827                         jiffies_to_clock_t(kstat_cpu(i).cpustat.softirq));
65828         }
65829 -       len += sprintf(page + len, "intr %u", sum);
65830 +       seq_printf(p, "intr %u", sum);
65831  
65832  #if !defined(CONFIG_PPC64) && !defined(CONFIG_ALPHA)
65833 -       for (i = 0 ; i < NR_IRQS ; i++)
65834 -               len += sprintf(page + len, " %u", kstat_irqs(i));
65835 +{
65836 +       static int last_irq = 0;
65837 +
65838 +       for (i = last_irq; i < NR_IRQS; i++) {
65839 +               if (irq_desc[i].action) {
65840 +                       if (i > last_irq)
65841 +                               last_irq = i;
65842 +               }
65843 +       }
65844 +
65845 +       for (i = 0; i <= last_irq; i++)
65846 +               seq_printf(p, " %u", kstat_irqs(i));
65847 +}
65848  #endif
65849  
65850 -       len += sprintf(page + len,
65851 +       seq_printf(p,
65852                 "\nctxt %lu\n"
65853                 "btime %lu\n"
65854                 "processes %lu\n"
65855 @@ -433,8 +444,38 @@
65856                 nr_running(),
65857                 nr_iowait());
65858  
65859 -       return proc_calc_metrics(page, start, off, count, eof, len);
65860 +       return 0;
65861 +}
65862 +
65863 +static int stat_open(struct inode *inode, struct file *file)
65864 +{
65865 +       unsigned size = 4096 * (1 + num_online_cpus() / 32);
65866 +       char *buf;
65867 +       struct seq_file *m;
65868 +       int res;
65869 +
65870 +       /* don't ask for more than the kmalloc() max size, currently 128 KB */
65871 +       if (size > 128 * 1024)
65872 +               size = 128 * 1024;
65873 +       buf = kmalloc(size, GFP_KERNEL);
65874 +       if (!buf)
65875 +               return -ENOMEM;
65876 +
65877 +       res = single_open(file, show_stat, NULL);
65878 +       if (!res) {
65879 +               m = file->private_data;
65880 +               m->buf = buf;
65881 +               m->size = size;
65882 +       } else
65883 +               kfree(buf);
65884 +       return res;
65885  }
65886 +static struct file_operations proc_stat_operations = {
65887 +       .open           = stat_open,
65888 +       .read           = seq_read,
65889 +       .llseek         = seq_lseek,
65890 +       .release        = single_release,
65891 +};
65892  
65893  static int devices_read_proc(char *page, char **start, off_t off,
65894                                  int count, int *eof, void *data)
65895 @@ -626,7 +667,6 @@
65896  #ifdef CONFIG_STRAM_PROC
65897                 {"stram",       stram_read_proc},
65898  #endif
65899 -               {"stat",        kstat_read_proc},
65900                 {"devices",     devices_read_proc},
65901                 {"filesystems", filesystems_read_proc},
65902                 {"cmdline",     cmdline_read_proc},
65903 @@ -648,6 +688,7 @@
65904                 entry->proc_fops = &proc_kmsg_operations;
65905         create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
65906         create_seq_entry("partitions", 0, &proc_partitions_operations);
65907 +       create_seq_entry("stat", 0, &proc_stat_operations);
65908         create_seq_entry("interrupts", 0, &proc_interrupts_operations);
65909         create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
65910         create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations);
65911 diff -Nru a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
65912 --- a/fs/proc/task_mmu.c        Thu Jun 19 16:57:39 2003
65913 +++ b/fs/proc/task_mmu.c        Sat Aug 23 05:08:00 2003
65914 @@ -90,14 +90,14 @@
65915                 ino = inode->i_ino;
65916         }
65917  
65918 -       seq_printf(m, "%0*lx-%0*lx %c%c%c%c %0*lx %02x:%02x %lu %n",
65919 -                       (int) (2*sizeof(void*)), map->vm_start,
65920 -                       (int) (2*sizeof(void*)), map->vm_end,
65921 +       seq_printf(m, "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n",
65922 +                       map->vm_start,
65923 +                       map->vm_end,
65924                         flags & VM_READ ? 'r' : '-',
65925                         flags & VM_WRITE ? 'w' : '-',
65926                         flags & VM_EXEC ? 'x' : '-',
65927                         flags & VM_MAYSHARE ? 's' : 'p',
65928 -                       (int) (2*sizeof(void*)), map->vm_pgoff << PAGE_SHIFT,
65929 +                       map->vm_pgoff << PAGE_SHIFT,
65930                         MAJOR(dev), MINOR(dev), ino, &len);
65931  
65932         if (map->vm_file) {
65933 diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
65934 --- a/fs/reiserfs/inode.c       Mon Aug 18 22:42:17 2003
65935 +++ b/fs/reiserfs/inode.c       Sun Aug 31 16:14:17 2003
65936 @@ -2048,8 +2048,8 @@
65937          last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1) ;
65938         /* no file contents in this page */
65939         if (page->index >= end_index + 1 || !last_offset) {
65940 -           error = 0 ;
65941 -           goto done ;
65942 +           unlock_page(page);
65943 +           return 0;
65944         }
65945         kaddr = kmap_atomic(page, KM_USER0);
65946         memset(kaddr + last_offset, 0, PAGE_CACHE_SIZE-last_offset) ;
65947 diff -Nru a/fs/smbfs/inode.c b/fs/smbfs/inode.c
65948 --- a/fs/smbfs/inode.c  Wed Jun 25 16:30:54 2003
65949 +++ b/fs/smbfs/inode.c  Tue Aug 26 09:37:39 2003
65950 @@ -212,7 +212,7 @@
65951                         (long) last_sz, (long) inode->i_size);
65952  
65953                 if (!S_ISDIR(inode->i_mode))
65954 -                       invalidate_inode_pages(inode->i_mapping);
65955 +                       invalidate_remote_inode(inode);
65956         }
65957  }
65958  
65959 @@ -276,7 +276,7 @@
65960                          * But we do want to invalidate the caches ...
65961                          */
65962                         if (!S_ISDIR(inode->i_mode))
65963 -                               invalidate_inode_pages(inode->i_mapping);
65964 +                               invalidate_remote_inode(inode);
65965                         else
65966                                 smb_invalid_dir_cache(inode);
65967                         error = -EIO;
65968 diff -Nru a/fs/vfat/namei.c b/fs/vfat/namei.c
65969 --- a/fs/vfat/namei.c   Sat Aug  2 15:10:30 2003
65970 +++ b/fs/vfat/namei.c   Mon Sep  1 08:45:36 2003
65971 @@ -200,20 +200,6 @@
65972         return 1;
65973  }
65974  
65975 -/* MS-DOS "device special files" */
65976 -
65977 -static const unsigned char *reserved3_names[] = {
65978 -       "con     ", "prn     ", "nul     ", "aux     ", NULL
65979 -};
65980 -
65981 -static const unsigned char *reserved4_names[] = {
65982 -       "com1    ", "com2    ", "com3    ", "com4    ", "com5    ",
65983 -       "com6    ", "com7    ", "com8    ", "com9    ",
65984 -       "lpt1    ", "lpt2    ", "lpt3    ", "lpt4    ", "lpt5    ",
65985 -       "lpt6    ", "lpt7    ", "lpt8    ", "lpt9    ",
65986 -       NULL };
65987 -
65988 -
65989  /* Characters that are undesirable in an MS-DOS file name */
65990  
65991  static wchar_t bad_chars[] = {
65992 @@ -255,38 +241,31 @@
65993         return 0;
65994  }
65995  
65996 -/* Checks the validity of a long MS-DOS filename */
65997 -/* Returns negative number on error, 0 for a normal
65998 - * return, and 1 for . or .. */
65999 -
66000 -static int vfat_valid_longname(const unsigned char *name, int len, int xlate)
66001 +static int vfat_valid_longname(const unsigned char *name, unsigned int len)
66002  {
66003 -       const unsigned char **reserved, *walk;
66004 -       int baselen;
66005 -
66006         if (len && name[len-1] == ' ')
66007 -               return -EINVAL;
66008 +               return 0;
66009         if (len >= 256)
66010 -               return -EINVAL;
66011 -       if (len < 3)
66012                 return 0;
66013  
66014 -       for (walk = name; *walk != 0 && *walk != '.'; walk++)
66015 -               ;
66016 -       baselen = walk - name;
66017 -
66018 -       if (baselen == 3) {
66019 -               for (reserved = reserved3_names; *reserved; reserved++) {
66020 -                       if (!strnicmp(name,*reserved,baselen))
66021 -                               return -EINVAL;
66022 -               }
66023 -       } else if (baselen == 4) {
66024 -               for (reserved = reserved4_names; *reserved; reserved++) {
66025 -                       if (!strnicmp(name,*reserved,baselen))
66026 -                               return -EINVAL;
66027 +       /* MS-DOS "device special files" */
66028 +       if (len == 3 || (len > 3 && name[3] == '.')) {  /* basename == 3 */
66029 +               if (!strnicmp(name, "aux", 3) ||
66030 +                   !strnicmp(name, "con", 3) ||
66031 +                   !strnicmp(name, "nul", 3) ||
66032 +                   !strnicmp(name, "prn", 3))
66033 +                       return 0;
66034 +       }
66035 +       if (len == 4 || (len > 4 && name[4] == '.')) {  /* basename == 4 */
66036 +               /* "com1", "com2", ... */
66037 +               if ('1' <= name[3] && name[3] <= '9') {
66038 +                       if (!strnicmp(name, "com", 3) ||
66039 +                           !strnicmp(name, "lpt", 3))
66040 +                               return 0;
66041                 }
66042         }
66043 -       return 0;
66044 +
66045 +       return 1;
66046  }
66047  
66048  static int vfat_find_form(struct inode *dir, unsigned char *name)
66049 @@ -684,9 +663,8 @@
66050         loff_t offset;
66051  
66052         *slots = 0;
66053 -       res = vfat_valid_longname(name, len, opts->unicode_xlate);
66054 -       if (res < 0)
66055 -               return res;
66056 +       if (!vfat_valid_longname(name, len))
66057 +               return -EINVAL;
66058  
66059         if(!(page = __get_free_page(GFP_KERNEL)))
66060                 return -ENOMEM;
66061 diff -Nru a/include/asm-alpha/semaphore.h b/include/asm-alpha/semaphore.h
66062 --- a/include/asm-alpha/semaphore.h     Mon Feb  4 23:55:32 2002
66063 +++ b/include/asm-alpha/semaphore.h     Wed Sep  3 23:40:12 2003
66064 @@ -88,14 +88,18 @@
66065  
66066  static inline void __down(struct semaphore *sem)
66067  {
66068 -       long count = atomic_dec_return(&sem->count);
66069 +       long count;
66070 +       might_sleep();
66071 +       count = atomic_dec_return(&sem->count);
66072         if (unlikely(count < 0))
66073                 __down_failed(sem);
66074  }
66075  
66076  static inline int __down_interruptible(struct semaphore *sem)
66077  {
66078 -       long count = atomic_dec_return(&sem->count);
66079 +       long count;
66080 +       might_sleep();
66081 +       count = atomic_dec_return(&sem->count);
66082         if (unlikely(count < 0))
66083                 return __down_failed_interruptible(sem);
66084         return 0;
66085 diff -Nru a/include/asm-arm/apm.h b/include/asm-arm/apm.h
66086 --- /dev/null   Wed Dec 31 16:00:00 1969
66087 +++ b/include/asm-arm/apm.h     Thu Aug  7 11:38:41 2003
66088 @@ -0,0 +1,56 @@
66089 +/* -*- linux-c -*-
66090 + *
66091 + * (C) 2003 zecke@handhelds.org
66092 + *
66093 + * GPL version 2
66094 + *
66095 + * based on arch/arm/kernel/apm.c
66096 + * factor out the information needed by architectures to provide
66097 + * apm status
66098 + *
66099 + *
66100 + */
66101 +#ifndef ARM_ASM_SA1100_APM_H
66102 +#define ARM_ASM_SA1100_APM_H
66103 +
66104 +#include <linux/config.h>
66105 +
66106 +#ifdef CONFIG_APM
66107 +
66108 +
66109 +#define APM_AC_OFFLINE 0
66110 +#define APM_AC_ONLINE 1
66111 +#define APM_AC_BACKUP 2
66112 +#define APM_AC_UNKNOWN 0xFF
66113 +
66114 +#define APM_BATTERY_STATUS_HIGH 0
66115 +#define APM_BATTERY_STATUS_LOW  1
66116 +#define APM_BATTERY_STATUS_CRITICAL 2
66117 +#define APM_BATTERY_STATUS_CHARGING 3
66118 +#define APM_BATTERY_STATUS_UNKNOWN 0xFF
66119 +
66120 +#define APM_BATTERY_LIFE_UNKNOWN 0xFFFF
66121 +#define APM_BATTERY_LIFE_MINUTES 0x8000
66122 +#define APM_BATTERY_LIFE_VALUE_MASK 0x7FFF
66123 +
66124 +/*
66125 + * This structure gets filled in by the machine specific 'get_power_status'
66126 + * implementation.  Any fields which are not set default to a safe value.
66127 + */
66128 +struct apm_power_info {
66129 +       unsigned char   ac_line_status;
66130 +       unsigned char   battery_status;
66131 +       unsigned char   battery_flag;
66132 +       unsigned char   battery_life;
66133 +       int             time;
66134 +       int             units;
66135 +};
66136 +
66137 +/*
66138 + * This allows machines to provide their own "apm get power status" function.
66139 + */
66140 +extern void (*apm_get_power_status)(struct apm_power_info *);
66141 +#endif
66142 +
66143 +
66144 +#endif
66145 diff -Nru a/include/asm-arm/arch-ebsa285/time.h b/include/asm-arm/arch-ebsa285/time.h
66146 --- a/include/asm-arm/arch-ebsa285/time.h       Tue May 13 08:20:50 2003
66147 +++ b/include/asm-arm/arch-ebsa285/time.h       Sun Aug 24 07:55:20 2003
66148 @@ -181,12 +181,13 @@
66149  }
66150  
66151  
66152 +static unsigned long timer1_latch;
66153  
66154  static unsigned long timer1_gettimeoffset (void)
66155  {
66156 -       unsigned long value = LATCH - *CSR_TIMER1_VALUE;
66157 +       unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
66158  
66159 -       return ((tick_nsec / 1000) * value) / LATCH;
66160 +       return ((tick_nsec / 1000) * value) / timer1_latch;
66161  }
66162  
66163  static irqreturn_t
66164 @@ -260,8 +261,10 @@
66165             machine_is_personal_server()) {
66166                 gettimeoffset = timer1_gettimeoffset;
66167  
66168 +               timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
66169 +
66170                 *CSR_TIMER1_CLR  = 0;
66171 -               *CSR_TIMER1_LOAD = LATCH;
66172 +               *CSR_TIMER1_LOAD = timer1_latch;
66173                 *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
66174  
66175                 timer_irq.handler = timer1_interrupt;
66176 diff -Nru a/include/asm-arm/arch-ebsa285/timex.h b/include/asm-arm/arch-ebsa285/timex.h
66177 --- a/include/asm-arm/arch-ebsa285/timex.h      Tue Feb  5 09:39:51 2002
66178 +++ b/include/asm-arm/arch-ebsa285/timex.h      Sun Aug 24 07:55:20 2003
66179 @@ -11,8 +11,8 @@
66180   */
66181  
66182  /*
66183 - * On EBSA285 boards, the clock runs at 50MHz and is
66184 - * divided by a 4-bit prescaler.  Other boards use an
66185 - * ISA derived timer, and this is unused.
66186 + * We assume a constant here; this satisfies the maths in linux/timex.h
66187 + * and linux/time.h.  CLOCK_TICK_RATE is actually system dependent, but
66188 + * this must be a constant.
66189   */
66190 -#define CLOCK_TICK_RATE                (mem_fclk_21285 / 16)
66191 +#define CLOCK_TICK_RATE                (50000000/16)
66192 diff -Nru a/include/asm-arm/arch-iop3xx/iop310.h b/include/asm-arm/arch-iop3xx/iop310.h
66193 --- a/include/asm-arm/arch-iop3xx/iop310.h      Mon Apr 21 15:43:42 2003
66194 +++ b/include/asm-arm/arch-iop3xx/iop310.h      Wed Aug 13 16:46:20 2003
66195 @@ -12,6 +12,14 @@
66196  #define _IOP310_HW_H_
66197  
66198  /*
66199 + * This is needed for mixed drivers that need to work on all
66200 + * IOP3xx variants but behave slightly differently on each.
66201 + */
66202 +#ifndef __ASSEMBLY__
66203 +#define iop_is_310() ((processor_id & 0xffffe3f0) == 0x69052000)
66204 +#endif
66205 +
66206 +/*
66207   * IOP310 I/O and Mem space regions for PCI autoconfiguration
66208   */
66209  #define IOP310_PCISEC_LOWER_IO         0x90010000
66210 diff -Nru a/include/asm-arm/arch-iop3xx/iop321.h b/include/asm-arm/arch-iop3xx/iop321.h
66211 --- a/include/asm-arm/arch-iop3xx/iop321.h      Fri May 30 07:09:39 2003
66212 +++ b/include/asm-arm/arch-iop3xx/iop321.h      Wed Aug 13 16:46:20 2003
66213 @@ -15,6 +15,10 @@
66214  #define _IOP321_HW_H_
66215  
66216  
66217 +/*
66218 + * This is needed for mixed drivers that need to work on all
66219 + * IOP3xx variants but behave slightly differently on each.
66220 + */
66221  #ifndef __ASSEMBLY__
66222  #define iop_is_321() ((processor_id & 0xfffff7e0) == 0x69052420)
66223  #endif
66224 diff -Nru a/include/asm-arm/arch-iop3xx/memory.h b/include/asm-arm/arch-iop3xx/memory.h
66225 --- a/include/asm-arm/arch-iop3xx/memory.h      Tue Apr 15 08:12:47 2003
66226 +++ b/include/asm-arm/arch-iop3xx/memory.h      Wed Aug 13 16:46:20 2003
66227 @@ -66,4 +66,6 @@
66228  extern void *mu_mem;
66229  #endif
66230  
66231 +#define PFN_TO_NID(addr)       (0)
66232 +
66233  #endif
66234 diff -Nru a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
66235 --- a/include/asm-arm/arch-pxa/pxa-regs.h       Mon Apr 21 15:43:42 2003
66236 +++ b/include/asm-arm/arch-pxa/pxa-regs.h       Mon Jun 30 04:20:34 2003
66237 @@ -836,7 +836,7 @@
66238  
66239  #define GPIO1_RST              1       /* reset */
66240  #define GPIO6_MMCCLK           6       /* MMC Clock */
66241 -#define GPIO8_48MHz            7       /* 48 MHz clock output */
66242 +#define GPIO7_48MHz            7       /* 48 MHz clock output */
66243  #define GPIO8_MMCCS0           8       /* MMC Chip Select 0 */
66244  #define GPIO9_MMCCS1           9       /* MMC Chip Select 1 */
66245  #define GPIO10_RTCCLK          10      /* real time clock (1 Hz) */
66246 @@ -939,7 +939,7 @@
66247  
66248  #define GPIO1_RTS_MD           ( 1 | GPIO_ALT_FN_1_IN)
66249  #define GPIO6_MMCCLK_MD                ( 6 | GPIO_ALT_FN_1_OUT)
66250 -#define GPIO8_48MHz_MD         ( 8 | GPIO_ALT_FN_1_OUT)
66251 +#define GPIO7_48MHz_MD         ( 7 | GPIO_ALT_FN_1_OUT)
66252  #define GPIO8_MMCCS0_MD                ( 8 | GPIO_ALT_FN_1_OUT)
66253  #define GPIO9_MMCCS1_MD                ( 9 | GPIO_ALT_FN_1_OUT)
66254  #define GPIO10_RTCCLK_MD       (10 | GPIO_ALT_FN_1_OUT)
66255 diff -Nru a/include/asm-arm/arch-sa1100/simpad.h b/include/asm-arm/arch-sa1100/simpad.h
66256 --- a/include/asm-arm/arch-sa1100/simpad.h      Mon Feb 24 10:29:41 2003
66257 +++ b/include/asm-arm/arch-sa1100/simpad.h      Thu Aug  7 11:49:10 2003
66258 @@ -5,17 +5,13 @@
66259   *
66260   * This file contains the hardware specific definitions for SIMpad
66261   *
66262 - * 2001/05/14 Juergen Messerer <juergen.messerer@siemens.ch>
66263 + * 2001/05/14 Juergen Messerer <juergen.messerer@freesurf.ch>
66264   */
66265  
66266 -#ifndef SIMPAD_H
66267 -#define SIMPAD_H
66268 +#ifndef __ASM_ARCH_SIMPAD_H
66269 +#define __ASM_ARCH_SIMPAD_H
66270  
66271  
66272 -#ifndef __ASM_ARCH_HARDWARE_H
66273 -#error "include <asm/hardware.h> instead"
66274 -#endif
66275 -
66276  #define GPIO_UART1_RTS GPIO_GPIO14
66277  #define GPIO_UART1_DTR GPIO_GPIO7
66278  #define GPIO_UART1_CTS GPIO_GPIO8
66279 @@ -28,7 +24,8 @@
66280  #define GPIO_UART3_DCD GPIO_GPIO18
66281  #define GPIO_UART3_DSR GPIO_GPIO17
66282  
66283 -#define GPIO_UCB1300_IRQ       GPIO_GPIO (22)  /* UCB GPIO and touchscreen */
66284 +#define GPIO_POWER_BUTTON      GPIO_GPIO0
66285 +#define GPIO_UCB1300_IRQ       GPIO_GPIO22     /* UCB GPIO and touchscreen */
66286  
66287  #define IRQ_UART1_CTS  IRQ_GPIO15
66288  #define IRQ_UART1_DCD  GPIO_GPIO23
66289 @@ -37,21 +34,26 @@
66290  #define IRQ_UART3_DCD  GPIO_GPIO18
66291  #define IRQ_UART3_DSR  GPIO_GPIO17
66292  
66293 -#define IRQ_GPIO_UCB1300_IRQ IRQ_GPIO22 
66294 +#define IRQ_GPIO_UCB1300_IRQ IRQ_GPIO22
66295 +#define IRQ_GPIO_POWER_BUTTON IRQ_GPIO0
66296  
66297  
66298  /*---  PCMCIA  ---*/
66299  #define GPIO_CF_CD              GPIO_GPIO24
66300 -#define GPIO_CF_IRQ             GPIO_GPIO1          
66301 +#define GPIO_CF_IRQ             GPIO_GPIO1
66302  #define IRQ_GPIO_CF_IRQ         IRQ_GPIO1
66303 -#define IRQ_GPIO_CF_CD          IRQ_GPIO24      
66304 +#define IRQ_GPIO_CF_CD          IRQ_GPIO24
66305 +
66306 +/*--- SmartCard ---*/
66307 +#define GPIO_SMART_CARD                GPIO_GPIO10
66308 +#define IRQ_GPIO_SMARD_CARD    IRQ_GPIO10
66309  
66310 -// CS3 Latch is write only, a shadow is necessary 
66311 +// CS3 Latch is write only, a shadow is necessary
66312  
66313 -#define CS3BUSTYPE unsigned volatile long           
66314 +#define CS3BUSTYPE unsigned volatile long
66315  #define CS3_BASE        0xf1000000
66316  
66317 -#define VCC_5V_EN       0x0001 // For 5V PCMCIA 
66318 +#define VCC_5V_EN       0x0001 // For 5V PCMCIA
66319  #define VCC_3V_EN       0x0002 // FOR 3.3V PCMCIA
66320  #define EN1             0x0004 // This is only for EPROM's
66321  #define EN0             0x0008 // Both should be enable for 3.3V or 5V
66322 @@ -63,15 +65,43 @@
66323  #define IRDA_SD         0x0200 // Shutdown for powersave
66324  #define RS232_ON        0x0400
66325  #define SD_MEDIAQ       0x0800 // Shutdown for powersave
66326 -#define LED2_ON         0x1000 
66327 +#define LED2_ON         0x1000
66328  #define IRDA_MODE       0x2000 // Fast/Slow IrDA mode
66329  #define ENABLE_5V       0x4000 // Enable 5V circuit
66330  #define RESET_SIMCARD   0x8000
66331  
66332  #define RS232_ENABLE    0x0440
66333 -#define PCMCIAMASK      0x402f   
66334 +#define PCMCIAMASK      0x402f
66335 +
66336 +
66337 +struct simpad_battery {
66338 +       unsigned char ac_status;        /* line connected yes/no */
66339 +       unsigned char status;           /* battery loading yes/no */
66340 +       unsigned char percentage;       /* percentage loaded */
66341 +       unsigned short life;            /* life till empty */
66342 +};
66343 +
66344 +/* These should match the apm_bios.h definitions */
66345 +#define SIMPAD_AC_STATUS_AC_OFFLINE      0x00
66346 +#define SIMPAD_AC_STATUS_AC_ONLINE       0x01
66347 +#define SIMPAD_AC_STATUS_AC_BACKUP       0x02   /* What does this mean? */
66348 +#define SIMPAD_AC_STATUS_AC_UNKNOWN      0xff
66349 +
66350 +/* These bitfields are rarely "or'd" together */
66351 +#define SIMPAD_BATT_STATUS_HIGH          0x01
66352 +#define SIMPAD_BATT_STATUS_LOW           0x02
66353 +#define SIMPAD_BATT_STATUS_CRITICAL      0x04
66354 +#define SIMPAD_BATT_STATUS_CHARGING      0x08
66355 +#define SIMPAD_BATT_STATUS_CHARGE_MAIN   0x10
66356 +#define SIMPAD_BATT_STATUS_DEAD          0x20   /* Battery will not charge */
66357 +#define SIMPAD_BATT_NOT_INSTALLED        0x20   /* For expansion pack batteries */
66358 +#define SIMPAD_BATT_STATUS_FULL          0x40   /* Battery fully charged (and connected to AC) */
66359 +#define SIMPAD_BATT_STATUS_NOBATT        0x80
66360 +#define SIMPAD_BATT_STATUS_UNKNOWN       0xff
66361 +
66362 +extern int simpad_get_battery(struct simpad_battery* );
66363  
66364 -#endif // SIMPAD_H
66365 +#endif // __ASM_ARCH_SIMPAD_H
66366  
66367  
66368  
66369 diff -Nru a/include/asm-arm/assembler.h b/include/asm-arm/assembler.h
66370 --- a/include/asm-arm/assembler.h       Sat Jan 18 04:24:07 2003
66371 +++ b/include/asm-arm/assembler.h       Wed Sep  3 10:17:57 2003
66372 @@ -1,18 +1,23 @@
66373  /*
66374 - * linux/asm/assembler.h
66375 + *  linux/include/asm-arm/assembler.h
66376   *
66377 - * This file contains arm architecture specific defines
66378 - * for the different processors.
66379 + *  Copyright (C) 1996-2000 Russell King
66380   *
66381 - * Do not include any C declarations in this file - it is included by
66382 - * assembler source.
66383 + * This program is free software; you can redistribute it and/or modify
66384 + * it under the terms of the GNU General Public License version 2 as
66385 + * published by the Free Software Foundation.
66386 + *
66387 + *  This file contains arm architecture specific defines
66388 + *  for the different processors.
66389 + *
66390 + *  Do not include any C declarations in this file - it is included by
66391 + *  assembler source.
66392   */
66393  #ifndef __ASSEMBLY__
66394  #error "Only include this from assembly code"
66395  #endif
66396  
66397 -#include <asm/proc/ptrace.h>
66398 -#include <asm/proc/assembler.h>
66399 +#include <asm/ptrace.h>
66400  
66401  /*
66402   * Endian independent macros for shifting bytes within registers.
66403 @@ -36,3 +41,63 @@
66404  #define PLD(code...)
66405  #endif
66406  
66407 +#define MODE_USR       USR_MODE
66408 +#define MODE_FIQ       FIQ_MODE
66409 +#define MODE_IRQ       IRQ_MODE
66410 +#define MODE_SVC       SVC_MODE
66411 +
66412 +#define DEFAULT_FIQ    MODE_FIQ
66413 +
66414 +/*
66415 + * LOADREGS - ldm with PC in register list (eg, ldmfd sp!, {pc})
66416 + */
66417 +#ifdef __STDC__
66418 +#define LOADREGS(cond, base, reglist...)\
66419 +       ldm##cond       base,reglist
66420 +#else
66421 +#define LOADREGS(cond, base, reglist...)\
66422 +       ldm/**/cond     base,reglist
66423 +#endif
66424 +
66425 +/*
66426 + * Build a return instruction for this processor type.
66427 + */
66428 +#define RETINSTR(instr, regs...)\
66429 +       instr   regs
66430 +
66431 +/*
66432 + * Save the current IRQ state and disable IRQs.  Note that this macro
66433 + * assumes FIQs are enabled, and that the processor is in SVC mode.
66434 + */
66435 +       .macro  save_and_disable_irqs, oldcpsr, temp
66436 +       mrs     \oldcpsr, cpsr
66437 +       mov     \temp, #PSR_I_BIT | MODE_SVC
66438 +       msr     cpsr_c, \temp
66439 +       .endm
66440 +
66441 +/*
66442 + * Restore interrupt state previously stored in a register.  We don't
66443 + * guarantee that this will preserve the flags.
66444 + */
66445 +       .macro  restore_irqs, oldcpsr
66446 +       msr     cpsr_c, \oldcpsr
66447 +       .endm
66448 +
66449 +/*
66450 + * These two are used to save LR/restore PC over a user-based access.
66451 + * The old 26-bit architecture requires that we do.  On 32-bit
66452 + * architecture, we can safely ignore this requirement.
66453 + */
66454 +       .macro  save_lr
66455 +       .endm
66456 +
66457 +       .macro  restore_pc
66458 +       mov     pc, lr
66459 +       .endm
66460 +
66461 +#define USER(x...)                             \
66462 +9999:  x;                                      \
66463 +       .section __ex_table,"a";                \
66464 +       .align  3;                              \
66465 +       .long   9999b,9001f;                    \
66466 +       .previous
66467 diff -Nru a/include/asm-arm/atomic.h b/include/asm-arm/atomic.h
66468 --- a/include/asm-arm/atomic.h  Sat Jul 27 08:53:16 2002
66469 +++ b/include/asm-arm/atomic.h  Wed Sep  3 10:17:57 2003
66470 @@ -27,7 +27,7 @@
66471  #define ATOMIC_INIT(i) { (i) }
66472  
66473  #ifdef __KERNEL__
66474 -#include <asm/proc/system.h>
66475 +#include <asm/system.h>
66476  
66477  #define atomic_read(v) ((v)->counter)
66478  #define atomic_set(v,i)        (((v)->counter) = (i))
66479 diff -Nru a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h
66480 --- a/include/asm-arm/cacheflush.h      Tue Jul  9 14:02:08 2002
66481 +++ b/include/asm-arm/cacheflush.h      Wed Sep  3 10:17:57 2003
66482 @@ -1,7 +1,7 @@
66483  /*
66484   *  linux/include/asm-arm/cacheflush.h
66485   *
66486 - *  Copyright (C) 2000-2002 Russell King
66487 + *  Copyright (C) 1999-2002 Russell King
66488   *
66489   * This program is free software; you can redistribute it and/or modify
66490   * it under the terms of the GNU General Public License version 2 as
66491 @@ -12,6 +12,275 @@
66492  
66493  #include <linux/sched.h>
66494  #include <linux/mm.h>
66495 -#include <asm/proc/cache.h>
66496 +
66497 +#include <asm/mman.h>
66498 +#include <asm/glue.h>
66499 +
66500 +/*
66501 + *     Cache Model
66502 + *     ===========
66503 + */
66504 +#undef _CACHE
66505 +#undef MULTI_CACHE
66506 +
66507 +#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
66508 +# ifdef _CACHE
66509 +#  define MULTI_CACHE 1
66510 +# else
66511 +#  define _CACHE v3
66512 +# endif
66513 +#endif
66514 +
66515 +#if defined(CONFIG_CPU_ARM720T)
66516 +# ifdef _CACHE
66517 +#  define MULTI_CACHE 1
66518 +# else
66519 +#  define _CACHE v4
66520 +# endif
66521 +#endif
66522 +
66523 +#if defined(CONFIG_CPU_ARM920T) || defined(CONFIG_CPU_ARM922T) || \
66524 +    defined(CONFIG_CPU_ARM1020)
66525 +# define MULTI_CACHE 1
66526 +#endif
66527 +
66528 +#if defined(CONFIG_CPU_ARM926T)
66529 +# ifdef _CACHE
66530 +#  define MULTI_CACHE 1
66531 +# else
66532 +#  define _CACHE arm926
66533 +# endif
66534 +#endif
66535 +
66536 +#if defined(CONFIG_CPU_SA110) || defined(CONFIG_CPU_SA1100)
66537 +# ifdef _CACHE
66538 +#  define MULTI_CACHE 1
66539 +# else
66540 +#  define _CACHE v4wb
66541 +# endif
66542 +#endif
66543 +
66544 +#if defined(CONFIG_CPU_XSCALE)
66545 +# ifdef _CACHE
66546 +#  define MULTI_CACHE 1
66547 +# else
66548 +#  define _CACHE xscale
66549 +# endif
66550 +#endif
66551 +
66552 +#if !defined(_CACHE) && !defined(MULTI_CACHE)
66553 +#error Unknown cache maintainence model
66554 +#endif
66555 +
66556 +/*
66557 + * This flag is used to indicate that the page pointed to by a pte
66558 + * is dirty and requires cleaning before returning it to the user.
66559 + */
66560 +#define PG_dcache_dirty PG_arch_1
66561 +
66562 +/*
66563 + *     MM Cache Management
66564 + *     ===================
66565 + *
66566 + *     The arch/arm/mm/cache-*.S and arch/arm/mm/proc-*.S files
66567 + *     implement these methods.
66568 + *
66569 + *     Start addresses are inclusive and end addresses are exclusive;
66570 + *     start addresses should be rounded down, end addresses up.
66571 + *
66572 + *     See linux/Documentation/cachetlb.txt for more information.
66573 + *     Please note that the implementation of these, and the required
66574 + *     effects are cache-type (VIVT/VIPT/PIPT) specific.
66575 + *
66576 + *     flush_cache_kern_all()
66577 + *
66578 + *             Unconditionally clean and invalidate the entire cache.
66579 + *
66580 + *     flush_cache_user_mm(mm)
66581 + *
66582 + *             Clean and invalidate all user space cache entries
66583 + *             before a change of page tables.
66584 + *
66585 + *     flush_cache_user_range(start, end, flags)
66586 + *
66587 + *             Clean and invalidate a range of cache entries in the
66588 + *             specified address space before a change of page tables.
66589 + *             - start - user start address (inclusive, page aligned)
66590 + *             - end   - user end address   (exclusive, page aligned)
66591 + *             - flags - vma->vm_flags field
66592 + *
66593 + *     coherent_kern_range(start, end)
66594 + *
66595 + *             Ensure coherency between the Icache and the Dcache in the
66596 + *             region described by start, end.  If you have non-snooping
66597 + *             Harvard caches, you need to implement this function.
66598 + *             - start  - virtual start address
66599 + *             - end    - virtual end address
66600 + *
66601 + *     DMA Cache Coherency
66602 + *     ===================
66603 + *
66604 + *     dma_inv_range(start, end)
66605 + *
66606 + *             Invalidate (discard) the specified virtual address range.
66607 + *             May not write back any entries.  If 'start' or 'end'
66608 + *             are not cache line aligned, those lines must be written
66609 + *             back.
66610 + *             - start  - virtual start address
66611 + *             - end    - virtual end address
66612 + *
66613 + *     dma_clean_range(start, end)
66614 + *
66615 + *             Clean (write back) the specified virtual address range.
66616 + *             - start  - virtual start address
66617 + *             - end    - virtual end address
66618 + *
66619 + *     dma_flush_range(start, end)
66620 + *
66621 + *             Clean and invalidate the specified virtual address range.
66622 + *             - start  - virtual start address
66623 + *             - end    - virtual end address
66624 + */
66625 +
66626 +struct cpu_cache_fns {
66627 +       void (*flush_kern_all)(void);
66628 +       void (*flush_user_all)(void);
66629 +       void (*flush_user_range)(unsigned long, unsigned long, unsigned int);
66630 +
66631 +       void (*coherent_kern_range)(unsigned long, unsigned long);
66632 +       void (*flush_kern_dcache_page)(void *);
66633 +
66634 +       void (*dma_inv_range)(unsigned long, unsigned long);
66635 +       void (*dma_clean_range)(unsigned long, unsigned long);
66636 +       void (*dma_flush_range)(unsigned long, unsigned long);
66637 +};
66638 +
66639 +/*
66640 + * Select the calling method
66641 + */
66642 +#ifdef MULTI_CACHE
66643 +
66644 +extern struct cpu_cache_fns cpu_cache;
66645 +
66646 +#define __cpuc_flush_kern_all          cpu_cache.flush_kern_all
66647 +#define __cpuc_flush_user_all          cpu_cache.flush_user_all
66648 +#define __cpuc_flush_user_range                cpu_cache.flush_user_range
66649 +#define __cpuc_coherent_kern_range     cpu_cache.coherent_kern_range
66650 +#define __cpuc_flush_dcache_page       cpu_cache.flush_kern_dcache_page
66651 +
66652 +/*
66653 + * These are private to the dma-mapping API.  Do not use directly.
66654 + * Their sole purpose is to ensure that data held in the cache
66655 + * is visible to DMA, or data written by DMA to system memory is
66656 + * visible to the CPU.
66657 + */
66658 +#define dmac_inv_range                 cpu_cache.dma_inv_range
66659 +#define dmac_clean_range               cpu_cache.dma_clean_range
66660 +#define dmac_flush_range               cpu_cache.dma_flush_range
66661 +
66662 +#else
66663 +
66664 +#define __cpuc_flush_kern_all          __glue(_CACHE,_flush_kern_cache_all)
66665 +#define __cpuc_flush_user_all          __glue(_CACHE,_flush_user_cache_all)
66666 +#define __cpuc_flush_user_range                __glue(_CACHE,_flush_user_cache_range)
66667 +#define __cpuc_coherent_kern_range     __glue(_CACHE,_coherent_kern_range)
66668 +#define __cpuc_flush_dcache_page       __glue(_CACHE,_flush_kern_dcache_page)
66669 +
66670 +extern void __cpuc_flush_kern_all(void);
66671 +extern void __cpuc_flush_user_all(void);
66672 +extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int);
66673 +extern void __cpuc_coherent_kern_range(unsigned long, unsigned long);
66674 +extern void __cpuc_flush_dcache_page(void *);
66675 +
66676 +/*
66677 + * These are private to the dma-mapping API.  Do not use directly.
66678 + * Their sole purpose is to ensure that data held in the cache
66679 + * is visible to DMA, or data written by DMA to system memory is
66680 + * visible to the CPU.
66681 + */
66682 +#define dmac_inv_range                 __glue(_CACHE,_dma_inv_range)
66683 +#define dmac_clean_range               __glue(_CACHE,_dma_clean_range)
66684 +#define dmac_flush_range               __glue(_CACHE,_dma_flush_range)
66685 +
66686 +extern void dmac_inv_range(unsigned long, unsigned long);
66687 +extern void dmac_clean_range(unsigned long, unsigned long);
66688 +extern void dmac_flush_range(unsigned long, unsigned long);
66689 +
66690 +#endif
66691 +
66692 +/*
66693 + * Convert calls to our calling convention.
66694 + */
66695 +#define flush_cache_all()              __cpuc_flush_kern_all()
66696 +
66697 +static inline void flush_cache_mm(struct mm_struct *mm)
66698 +{
66699 +       if (current->active_mm == mm)
66700 +               __cpuc_flush_user_all();
66701 +}
66702 +
66703 +static inline void
66704 +flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
66705 +{
66706 +       if (current->active_mm == vma->vm_mm)
66707 +               __cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
66708 +                                       vma->vm_flags);
66709 +}
66710 +
66711 +static inline void
66712 +flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr)
66713 +{
66714 +       if (current->active_mm == vma->vm_mm) {
66715 +               unsigned long addr = user_addr & PAGE_MASK;
66716 +               __cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
66717 +       }
66718 +}
66719 +
66720 +/*
66721 + * Perform necessary cache operations to ensure that data previously
66722 + * stored within this range of addresses can be executed by the CPU.
66723 + */
66724 +#define flush_icache_range(s,e)                __cpuc_coherent_kern_range(s,e)
66725 +
66726 +/*
66727 + * Perform necessary cache operations to ensure that the TLB will
66728 + * see data written in the specified area.
66729 + */
66730 +#define clean_dcache_area(start,size)  cpu_dcache_clean_area(start, size)
66731 +
66732 +/*
66733 + * flush_dcache_page is used when the kernel has written to the page
66734 + * cache page at virtual address page->virtual.
66735 + *
66736 + * If this page isn't mapped (ie, page->mapping = NULL), or it has
66737 + * userspace mappings (page->mapping->i_mmap or page->mapping->i_mmap_shared)
66738 + * then we _must_ always clean + invalidate the dcache entries associated
66739 + * with the kernel mapping.
66740 + *
66741 + * Otherwise we can defer the operation, and clean the cache when we are
66742 + * about to change to user space.  This is the same method as used on SPARC64.
66743 + * See update_mmu_cache for the user space part.
66744 + */
66745 +#define mapping_mapped(map)    (!list_empty(&(map)->i_mmap) || \
66746 +                                !list_empty(&(map)->i_mmap_shared))
66747 +
66748 +extern void __flush_dcache_page(struct page *);
66749 +
66750 +static inline void flush_dcache_page(struct page *page)
66751 +{
66752 +       if (page->mapping && !mapping_mapped(page->mapping))
66753 +               set_bit(PG_dcache_dirty, &page->flags);
66754 +       else
66755 +               __flush_dcache_page(page);
66756 +}
66757 +
66758 +#define flush_icache_user_range(vma,page,addr,len) \
66759 +       flush_dcache_page(page)
66760 +
66761 +/*
66762 + * We don't appear to need to do anything here.  In fact, if we did, we'd
66763 + * duplicate cache flushing elsewhere performed by flush_dcache_page().
66764 + */
66765 +#define flush_icache_page(vma,page)    do { } while (0)
66766  
66767  #endif
66768 diff -Nru a/include/asm-arm/checksum.h b/include/asm-arm/checksum.h
66769 --- a/include/asm-arm/checksum.h        Tue Oct 15 10:15:06 2002
66770 +++ b/include/asm-arm/checksum.h        Mon Jun 23 03:41:42 2003
66771 @@ -105,7 +105,7 @@
66772         adcs    %0, %0, %5                                      \n\
66773         adc     %0, %0, #0"
66774         : "=&r"(sum)
66775 -       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len) << 16), "Ir" (proto << 8)
66776 +       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto))
66777         : "cc");
66778         return sum;
66779  }      
66780 @@ -127,7 +127,7 @@
66781         addcs   %0, %0, #0x10000                                \n\
66782         mvn     %0, %0"
66783         : "=&r"(sum)
66784 -       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (proto << 8)
66785 +       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto))
66786         : "cc");
66787         return sum >> 16;
66788  }
66789 diff -Nru a/include/asm-arm/cpu-multi26.h b/include/asm-arm/cpu-multi26.h
66790 --- a/include/asm-arm/cpu-multi26.h     Sun Apr 27 17:16:26 2003
66791 +++ /dev/null   Wed Dec 31 16:00:00 1969
66792 @@ -1,47 +0,0 @@
66793 -/*
66794 - *  linux/include/asm-arm/cpu-multi26.h
66795 - *
66796 - *  Copyright (C) 2000 Russell King
66797 - *
66798 - * This program is free software; you can redistribute it and/or modify
66799 - * it under the terms of the GNU General Public License version 2 as
66800 - * published by the Free Software Foundation.
66801 - */
66802 -#ifndef __ASSEMBLY__
66803 -
66804 -#include <asm/page.h>
66805 -
66806 -/* forward-declare task_struct */
66807 -struct task_struct;
66808 -
66809 -/*
66810 - * Don't change this structure - ASM code
66811 - * relies on it.
66812 - */
66813 -extern struct processor {
66814 -       /* Set up any processor specifics */
66815 -       void (*_proc_init)(void);
66816 -       /* Disable any processor specifics */
66817 -       void (*_proc_fin)(void);
66818 -       /* set the MEMC hardware mappings */
66819 -       void (*_switch_mm)(pgd_t *pgd);
66820 -       /* XCHG */
66821 -       unsigned long (*_xchg_1)(unsigned long x, volatile void *ptr);
66822 -       unsigned long (*_xchg_4)(unsigned long x, volatile void *ptr);
66823 -} processor;
66824 -
66825 -extern const struct processor arm2_processor_functions;
66826 -extern const struct processor arm250_processor_functions;
66827 -extern const struct processor arm3_processor_functions;
66828 -
66829 -#define cpu_proc_init()                                processor._proc_init()
66830 -#define cpu_proc_fin()                         processor._proc_fin()
66831 -#define cpu_do_idle()                          do { } while (0)
66832 -#define cpu_switch_mm(pgd,mm)                  processor._switch_mm(pgd)
66833 -#define cpu_xchg_1(x,ptr)                      processor._xchg_1(x,ptr)
66834 -#define cpu_xchg_4(x,ptr)                      processor._xchg_4(x,ptr)
66835 -
66836 -extern void cpu_memc_update_all(pgd_t *pgd);
66837 -extern void cpu_memc_update_entry(pgd_t *pgd, unsigned long phys_pte, unsigned long log_addr);
66838 -
66839 -#endif
66840 diff -Nru a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
66841 --- a/include/asm-arm/dma-mapping.h     Wed Jun  4 08:09:55 2003
66842 +++ b/include/asm-arm/dma-mapping.h     Wed Aug 13 16:46:20 2003
66843 @@ -129,6 +129,28 @@
66844  }
66845  
66846  /**
66847 + * dma_map_page - map a portion of a page for streaming DMA
66848 + * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
66849 + * @page: page that buffer resides in
66850 + * @offset: offset into page for start of buffer
66851 + * @size: size of buffer to map
66852 + * @dir: DMA transfer direction
66853 + *
66854 + * Ensure that any data held in the cache is appropriately discarded
66855 + * or written back.
66856 + *
66857 + * The device owns this memory once this call has completed.  The CPU
66858 + * can regain ownership by calling dma_unmap_page() or dma_sync_single().
66859 + */
66860 +static inline dma_addr_t
66861 +dma_map_page(struct device *dev, struct page *page,
66862 +            unsigned long offset, size_t size,
66863 +            enum dma_data_direction dir)
66864 +{
66865 +       return dma_map_single(dev, page_address(page) + offset, size, (int)dir);
66866 +}
66867 +
66868 +/**
66869   * dma_unmap_single - unmap a single buffer previously mapped
66870   * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
66871   * @handle: DMA address of buffer
66872 @@ -152,21 +174,26 @@
66873         /* nothing to do */
66874  }
66875  
66876 -#if 0
66877 -static inline dma_addr_t
66878 -dma_map_page(struct device *dev, struct page *page, unsigned long off,
66879 -            size_t size, enum dma_data_direction dir)
66880 -{
66881 -       /* fixme */
66882 -}
66883 -
66884 +/**
66885 + * dma_unmap_page - unmap a buffer previously mapped through dma_map_page()
66886 + * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
66887 + * @handle: DMA address of buffer
66888 + * @size: size of buffer to map
66889 + * @dir: DMA transfer direction
66890 + *
66891 + * Unmap a single streaming mode DMA translation.  The handle and size
66892 + * must match what was provided in the previous dma_map_single() call.
66893 + * All other usages are undefined.
66894 + *
66895 + * After this call, reads by the CPU to the buffer are guaranteed to see
66896 + * whatever the device wrote there.
66897 + */
66898  static inline void
66899  dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size,
66900                enum dma_data_direction dir)
66901  {
66902 -       /* fixme */
66903 +       dma_unmap_single(dev, handle, size, (int)dir);
66904  }
66905 -#endif
66906  
66907  /**
66908   * dma_map_sg - map a set of SG buffers for streaming mode DMA
66909 diff -Nru a/include/asm-arm/domain.h b/include/asm-arm/domain.h
66910 --- /dev/null   Wed Dec 31 16:00:00 1969
66911 +++ b/include/asm-arm/domain.h  Wed Sep  3 10:17:59 2003
66912 @@ -0,0 +1,50 @@
66913 +/*
66914 + *  linux/include/asm-arm/domain.h
66915 + *
66916 + *  Copyright (C) 1999 Russell King.
66917 + *
66918 + * This program is free software; you can redistribute it and/or modify
66919 + * it under the terms of the GNU General Public License version 2 as
66920 + * published by the Free Software Foundation.
66921 + */
66922 +#ifndef __ASM_PROC_DOMAIN_H
66923 +#define __ASM_PROC_DOMAIN_H
66924 +
66925 +/*
66926 + * Domain numbers
66927 + *
66928 + *  DOMAIN_IO     - domain 2 includes all IO only
66929 + *  DOMAIN_KERNEL - domain 1 includes all kernel memory only
66930 + *  DOMAIN_USER   - domain 0 includes all user memory only
66931 + */
66932 +#define DOMAIN_USER    0
66933 +#define DOMAIN_KERNEL  1
66934 +#define DOMAIN_TABLE   1
66935 +#define DOMAIN_IO      2
66936 +
66937 +/*
66938 + * Domain types
66939 + */
66940 +#define DOMAIN_NOACCESS        0
66941 +#define DOMAIN_CLIENT  1
66942 +#define DOMAIN_MANAGER 3
66943 +
66944 +#define domain_val(dom,type)   ((type) << 2*(dom))
66945 +
66946 +#define set_domain(x)                                  \
66947 +       do {                                            \
66948 +       __asm__ __volatile__(                           \
66949 +       "mcr    p15, 0, %0, c3, c0      @ set domain"   \
66950 +         : : "r" (x));                                 \
66951 +       } while (0)
66952 +
66953 +#define modify_domain(dom,type)                                        \
66954 +       do {                                                    \
66955 +       struct thread_info *thread = current_thread_info();     \
66956 +       unsigned int domain = thread->cpu_domain;               \
66957 +       domain &= ~domain_val(dom, DOMAIN_MANAGER);             \
66958 +       thread->cpu_domain = domain | domain_val(dom, type);    \
66959 +       set_domain(thread->cpu_domain);                         \
66960 +       } while (0)
66961 +
66962 +#endif
66963 diff -Nru a/include/asm-arm/elf.h b/include/asm-arm/elf.h
66964 --- a/include/asm-arm/elf.h     Mon May 12 06:59:47 2003
66965 +++ b/include/asm-arm/elf.h     Wed Sep  3 10:17:57 2003
66966 @@ -7,7 +7,6 @@
66967  
66968  #include <asm/ptrace.h>
66969  #include <asm/user.h>
66970 -#include <asm/proc/elf.h>
66971  #include <asm/procinfo.h>
66972  
66973  typedef unsigned long elf_greg_t;
66974 @@ -42,6 +41,7 @@
66975  #define ELF_ARCH       EM_ARM
66976  
66977  #define USE_ELF_CORE_DUMP
66978 +#define ELF_EXEC_PAGESIZE      4096
66979  
66980  /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
66981     use of this is to invoke "./ld.so someprog" to test out a new version of
66982 @@ -75,5 +75,30 @@
66983  #define ELF_PLATFORM_SIZE 8
66984  extern char elf_platform[];
66985  #define ELF_PLATFORM   (elf_platform)
66986 +
66987 +#ifdef __KERNEL__
66988 +
66989 +/*
66990 + * 32-bit code is always OK.  Some cpus can do 26-bit, some can't.
66991 + */
66992 +#define ELF_PROC_OK(x) (ELF_THUMB_OK(x) && ELF_26BIT_OK(x))
66993 +
66994 +#define ELF_THUMB_OK(x) \
66995 +       (( (elf_hwcap & HWCAP_THUMB) && ((x)->e_entry & 1) == 1) || \
66996 +        ((x)->e_entry & 3) == 0)
66997 +
66998 +#define ELF_26BIT_OK(x) \
66999 +       (( (elf_hwcap & HWCAP_26BIT) && (x)->e_flags & EF_ARM_APCS26) || \
67000 +         ((x)->e_flags & EF_ARM_APCS26) == 0)
67001 +
67002 +/* Old NetWinder binaries were compiled in such a way that the iBCS
67003 +   heuristic always trips on them.  Until these binaries become uncommon
67004 +   enough not to care, don't trust the `ibcs' flag here.  In any case
67005 +   there is no other ELF system currently supported by iBCS.
67006 +   @@ Could print a warning message to encourage users to upgrade.  */
67007 +#define SET_PERSONALITY(ex,ibcs2) \
67008 +       set_personality(((ex).e_flags&EF_ARM_APCS26 ?PER_LINUX :PER_LINUX_32BIT))
67009 +
67010 +#endif
67011  
67012  #endif
67013 diff -Nru a/include/asm-arm/hardware/amba.h b/include/asm-arm/hardware/amba.h
67014 --- a/include/asm-arm/hardware/amba.h   Wed Jun 18 15:23:24 2003
67015 +++ b/include/asm-arm/hardware/amba.h   Sun Aug 24 07:16:13 2003
67016 @@ -28,8 +28,8 @@
67017         int                     (*probe)(struct amba_device *, void *);
67018         int                     (*remove)(struct amba_device *);
67019         void                    (*shutdown)(struct amba_device *);
67020 -       int                     (*suspend)(struct amba_device *, u32, u32);
67021 -       int                     (*resume)(struct amba_device *, u32);
67022 +       int                     (*suspend)(struct amba_device *, u32);
67023 +       int                     (*resume)(struct amba_device *);
67024         struct amba_id          *id_table;
67025  };
67026  
67027 diff -Nru a/include/asm-arm/hardware/sa1111.h b/include/asm-arm/hardware/sa1111.h
67028 --- a/include/asm-arm/hardware/sa1111.h Tue Aug  5 12:36:08 2003
67029 +++ b/include/asm-arm/hardware/sa1111.h Sun Aug 24 07:45:05 2003
67030 @@ -542,9 +542,16 @@
67031  
67032  #define SA1111_DEV(_d) container_of((_d), struct sa1111_dev, dev)
67033  
67034 +#define sa1111_get_drvdata(d)  dev_get_drvdata(&(d)->dev)
67035 +#define sa1111_set_drvdata(d,p)        dev_get_drvdata(&(d)->dev, p)
67036 +
67037  struct sa1111_driver {
67038         struct device_driver    drv;
67039         unsigned int            devid;
67040 +       int (*probe)(struct sa1111_dev *);
67041 +       int (*remove)(struct sa1111_dev *);
67042 +       int (*suspend)(struct sa1111_dev *, u32);
67043 +       int (*resume)(struct sa1111_dev *);
67044  };
67045  
67046  #define SA1111_DRV(_d) container_of((_d), struct sa1111_driver, drv)
67047 @@ -572,5 +579,8 @@
67048  int sa1111_get_audio_rate(struct sa1111_dev *sadev);
67049  
67050  int sa1111_check_dma_bug(dma_addr_t addr);
67051 +
67052 +int sa1111_driver_register(struct sa1111_driver *);
67053 +void sa1111_driver_unregister(struct sa1111_driver *);
67054  
67055  #endif  /* _ASM_ARCH_SA1111 */
67056 diff -Nru a/include/asm-arm/locks.h b/include/asm-arm/locks.h
67057 --- /dev/null   Wed Dec 31 16:00:00 1969
67058 +++ b/include/asm-arm/locks.h   Wed Sep  3 10:17:59 2003
67059 @@ -0,0 +1,139 @@
67060 +/*
67061 + *  linux/include/asm-arm/locks.h
67062 + *
67063 + *  Copyright (C) 2000 Russell King
67064 + *
67065 + * This program is free software; you can redistribute it and/or modify
67066 + * it under the terms of the GNU General Public License version 2 as
67067 + * published by the Free Software Foundation.
67068 + *
67069 + *  Interrupt safe locking assembler. 
67070 + */
67071 +#ifndef __ASM_PROC_LOCKS_H
67072 +#define __ASM_PROC_LOCKS_H
67073 +
67074 +#define __down_op(ptr,fail)                    \
67075 +       ({                                      \
67076 +       __asm__ __volatile__(                   \
67077 +       "@ down_op\n"                           \
67078 +"      mrs     ip, cpsr\n"                     \
67079 +"      orr     lr, ip, #128\n"                 \
67080 +"      msr     cpsr_c, lr\n"                   \
67081 +"      ldr     lr, [%0]\n"                     \
67082 +"      subs    lr, lr, %1\n"                   \
67083 +"      str     lr, [%0]\n"                     \
67084 +"      msr     cpsr_c, ip\n"                   \
67085 +"      movmi   ip, %0\n"                       \
67086 +"      blmi    " #fail                         \
67087 +       :                                       \
67088 +       : "r" (ptr), "I" (1)                    \
67089 +       : "ip", "lr", "cc", "memory");          \
67090 +       })
67091 +
67092 +#define __down_op_ret(ptr,fail)                        \
67093 +       ({                                      \
67094 +               unsigned int ret;               \
67095 +       __asm__ __volatile__(                   \
67096 +       "@ down_op_ret\n"                       \
67097 +"      mrs     ip, cpsr\n"                     \
67098 +"      orr     lr, ip, #128\n"                 \
67099 +"      msr     cpsr_c, lr\n"                   \
67100 +"      ldr     lr, [%1]\n"                     \
67101 +"      subs    lr, lr, %2\n"                   \
67102 +"      str     lr, [%1]\n"                     \
67103 +"      msr     cpsr_c, ip\n"                   \
67104 +"      movmi   ip, %1\n"                       \
67105 +"      movpl   ip, #0\n"                       \
67106 +"      blmi    " #fail "\n"                    \
67107 +"      mov     %0, ip"                         \
67108 +       : "=&r" (ret)                           \
67109 +       : "r" (ptr), "I" (1)                    \
67110 +       : "ip", "lr", "cc", "memory");          \
67111 +       ret;                                    \
67112 +       })
67113 +
67114 +#define __up_op(ptr,wake)                      \
67115 +       ({                                      \
67116 +       __asm__ __volatile__(                   \
67117 +       "@ up_op\n"                             \
67118 +"      mrs     ip, cpsr\n"                     \
67119 +"      orr     lr, ip, #128\n"                 \
67120 +"      msr     cpsr_c, lr\n"                   \
67121 +"      ldr     lr, [%0]\n"                     \
67122 +"      adds    lr, lr, %1\n"                   \
67123 +"      str     lr, [%0]\n"                     \
67124 +"      msr     cpsr_c, ip\n"                   \
67125 +"      movle   ip, %0\n"                       \
67126 +"      blle    " #wake                         \
67127 +       :                                       \
67128 +       : "r" (ptr), "I" (1)                    \
67129 +       : "ip", "lr", "cc", "memory");          \
67130 +       })
67131 +
67132 +/*
67133 + * The value 0x01000000 supports up to 128 processors and
67134 + * lots of processes.  BIAS must be chosen such that sub'ing
67135 + * BIAS once per CPU will result in the long remaining
67136 + * negative.
67137 + */
67138 +#define RW_LOCK_BIAS      0x01000000
67139 +#define RW_LOCK_BIAS_STR "0x01000000"
67140 +
67141 +#define __down_op_write(ptr,fail)              \
67142 +       ({                                      \
67143 +       __asm__ __volatile__(                   \
67144 +       "@ down_op_write\n"                     \
67145 +"      mrs     ip, cpsr\n"                     \
67146 +"      orr     lr, ip, #128\n"                 \
67147 +"      msr     cpsr_c, lr\n"                   \
67148 +"      ldr     lr, [%0]\n"                     \
67149 +"      subs    lr, lr, %1\n"                   \
67150 +"      str     lr, [%0]\n"                     \
67151 +"      msr     cpsr_c, ip\n"                   \
67152 +"      movne   ip, %0\n"                       \
67153 +"      blne    " #fail                         \
67154 +       :                                       \
67155 +       : "r" (ptr), "I" (RW_LOCK_BIAS)         \
67156 +       : "ip", "lr", "cc", "memory");          \
67157 +       })
67158 +
67159 +#define __up_op_write(ptr,wake)                        \
67160 +       ({                                      \
67161 +       __asm__ __volatile__(                   \
67162 +       "@ up_op_read\n"                        \
67163 +"      mrs     ip, cpsr\n"                     \
67164 +"      orr     lr, ip, #128\n"                 \
67165 +"      msr     cpsr_c, lr\n"                   \
67166 +"      ldr     lr, [%0]\n"                     \
67167 +"      adds    lr, lr, %1\n"                   \
67168 +"      str     lr, [%0]\n"                     \
67169 +"      msr     cpsr_c, ip\n"                   \
67170 +"      movcs   ip, %0\n"                       \
67171 +"      blcs    " #wake                         \
67172 +       :                                       \
67173 +       : "r" (ptr), "I" (RW_LOCK_BIAS)         \
67174 +       : "ip", "lr", "cc", "memory");          \
67175 +       })
67176 +
67177 +#define __down_op_read(ptr,fail)               \
67178 +       __down_op(ptr, fail)
67179 +
67180 +#define __up_op_read(ptr,wake)                 \
67181 +       ({                                      \
67182 +       __asm__ __volatile__(                   \
67183 +       "@ up_op_read\n"                        \
67184 +"      mrs     ip, cpsr\n"                     \
67185 +"      orr     lr, ip, #128\n"                 \
67186 +"      msr     cpsr_c, lr\n"                   \
67187 +"      ldr     lr, [%0]\n"                     \
67188 +"      adds    lr, lr, %1\n"                   \
67189 +"      str     lr, [%0]\n"                     \
67190 +"      msr     cpsr_c, ip\n"                   \
67191 +"      moveq   ip, %0\n"                       \
67192 +"      bleq    " #wake                         \
67193 +       :                                       \
67194 +       : "r" (ptr), "I" (1)                    \
67195 +       : "ip", "lr", "cc", "memory");          \
67196 +       })
67197 +
67198 +#endif
67199 diff -Nru a/include/asm-arm/memory.h b/include/asm-arm/memory.h
67200 --- a/include/asm-arm/memory.h  Wed Jun 18 16:12:59 2003
67201 +++ b/include/asm-arm/memory.h  Wed Sep  3 10:17:57 2003
67202 @@ -15,6 +15,8 @@
67203  #include <linux/config.h>
67204  #include <asm/arch/memory.h>
67205  
67206 +#ifndef __ASSEMBLY__
67207 +
67208  /*
67209   * PFNs are used to describe any physical page; this means
67210   * PFN 0 == physical address 0.
67211 @@ -118,5 +120,7 @@
67212   * We should really eliminate virt_to_bus() here - it's deprecated.
67213   */
67214  #define page_to_bus(page)      (virt_to_bus(page_address(page)))
67215 +
67216 +#endif
67217  
67218  #endif
67219 diff -Nru a/include/asm-arm/page.h b/include/asm-arm/page.h
67220 --- a/include/asm-arm/page.h    Thu Oct 10 05:14:05 2002
67221 +++ b/include/asm-arm/page.h    Wed Sep  3 10:17:57 2003
67222 @@ -1,9 +1,27 @@
67223 +/*
67224 + *  linux/include/asm-arm/page.h
67225 + *
67226 + *  Copyright (C) 1995-2003 Russell King
67227 + *
67228 + * This program is free software; you can redistribute it and/or modify
67229 + * it under the terms of the GNU General Public License version 2 as
67230 + * published by the Free Software Foundation.
67231 + */
67232  #ifndef _ASMARM_PAGE_H
67233  #define _ASMARM_PAGE_H
67234  
67235  #include <linux/config.h>
67236  
67237 +/* PAGE_SHIFT determines the page size */
67238 +#define PAGE_SHIFT             12
67239 +#define PAGE_SIZE              (1UL << PAGE_SHIFT)
67240 +#define PAGE_MASK              (~(PAGE_SIZE-1))
67241 +
67242  #ifdef __KERNEL__
67243 +
67244 +/* to align the pointer to the (next) page boundary */
67245 +#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
67246 +
67247  #ifndef __ASSEMBLY__
67248  
67249  #include <asm/glue.h>
67250 @@ -119,10 +137,12 @@
67251   */
67252  typedef struct { unsigned long pte; } pte_t;
67253  typedef struct { unsigned long pmd; } pmd_t;
67254 +typedef struct { unsigned long pgd[2]; } pgd_t;
67255  typedef struct { unsigned long pgprot; } pgprot_t;
67256  
67257  #define pte_val(x)      ((x).pte)
67258  #define pmd_val(x)      ((x).pmd)
67259 +#define pgd_val(x)     ((x).pgd[0])
67260  #define pgprot_val(x)   ((x).pgprot)
67261  
67262  #define __pte(x)        ((pte_t) { (x) } )
67263 @@ -135,10 +155,12 @@
67264   */
67265  typedef unsigned long pte_t;
67266  typedef unsigned long pmd_t;
67267 +typedef unsigned long pgd_t[2];
67268  typedef unsigned long pgprot_t;
67269  
67270  #define pte_val(x)      (x)
67271  #define pmd_val(x)      (x)
67272 +#define pgd_val(x)     ((x)[0])
67273  #define pgprot_val(x)   (x)
67274  
67275  #define __pte(x)        (x)
67276 @@ -146,19 +168,6 @@
67277  #define __pgprot(x)     (x)
67278  
67279  #endif /* STRICT_MM_TYPECHECKS */
67280 -#endif /* !__ASSEMBLY__ */
67281 -#endif /* __KERNEL__ */
67282 -
67283 -#include <asm/proc/page.h>
67284 -
67285 -#define PAGE_SIZE              (1UL << PAGE_SHIFT)
67286 -#define PAGE_MASK              (~(PAGE_SIZE-1))
67287 -
67288 -/* to align the pointer to the (next) page boundary */
67289 -#define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
67290 -
67291 -#ifdef __KERNEL__
67292 -#ifndef __ASSEMBLY__
67293  
67294  /* Pure 2^n version of get_order */
67295  static inline int get_order(unsigned long size)
67296 diff -Nru a/include/asm-arm/param.h b/include/asm-arm/param.h
67297 --- a/include/asm-arm/param.h   Tue Jul  9 12:05:39 2002
67298 +++ b/include/asm-arm/param.h   Wed Sep  3 10:17:57 2003
67299 @@ -11,7 +11,6 @@
67300  #define __ASM_PARAM_H
67301  
67302  #include <asm/arch/param.h>    /* for HZ */
67303 -#include <asm/proc/page.h>     /* for EXEC_PAGE_SIZE */
67304  
67305  #ifndef __KERNEL_HZ
67306  #define __KERNEL_HZ    100
67307 @@ -24,6 +23,8 @@
67308  #else
67309  # define HZ            100
67310  #endif
67311 +
67312 +#define EXEC_PAGESIZE  4096
67313  
67314  #ifndef NGROUPS
67315  #define NGROUPS         32
67316 diff -Nru a/include/asm-arm/pci.h b/include/asm-arm/pci.h
67317 --- a/include/asm-arm/pci.h     Mon Jun  9 09:25:33 2003
67318 +++ b/include/asm-arm/pci.h     Wed Aug 13 16:46:20 2003
67319 @@ -96,6 +96,19 @@
67320         return dma_unmap_sg(hwdev ? &hwdev->dev : NULL, sg, nents, dir);
67321  }
67322  
67323 +static inline dma_addr_t
67324 +pci_map_page(struct pci_dev *hwdev, struct page *page, unsigned long offset,
67325 +               size_t size, int dir)
67326 +{
67327 +       return  pci_map_single(hwdev, page_address(page) + offset, size, dir);
67328 +}
67329 +
67330 +static inline void
67331 +pci_unmap_page(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
67332 +{
67333 +       return pci_unmap_single(hwdev, handle, size, dir);
67334 +}
67335 +
67336  static inline void
67337  pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
67338  {
67339 diff -Nru a/include/asm-arm/pgalloc.h b/include/asm-arm/pgalloc.h
67340 --- a/include/asm-arm/pgalloc.h Sun Oct 13 03:46:44 2002
67341 +++ b/include/asm-arm/pgalloc.h Wed Sep  3 10:17:57 2003
67342 @@ -11,7 +11,8 @@
67343  #define _ASMARM_PGALLOC_H
67344  
67345  #include <asm/processor.h>
67346 -#include <asm/proc/pgalloc.h>
67347 +#include <asm/cacheflush.h>
67348 +#include <asm/tlbflush.h>
67349  
67350  /*
67351   * Since we have only two-level page tables, these are trivial
67352 @@ -27,5 +28,105 @@
67353  #define pgd_free(pgd)                  free_pgd_slow(pgd)
67354  
67355  #define check_pgt_cache()              do { } while (0)
67356 +
67357 +/*
67358 + * Allocate one PTE table.
67359 + *
67360 + * This actually allocates two hardware PTE tables, but we wrap this up
67361 + * into one table thus:
67362 + *
67363 + *  +------------+
67364 + *  |  h/w pt 0  |
67365 + *  +------------+
67366 + *  |  h/w pt 1  |
67367 + *  +------------+
67368 + *  | Linux pt 0 |
67369 + *  +------------+
67370 + *  | Linux pt 1 |
67371 + *  +------------+
67372 + */
67373 +static inline pte_t *
67374 +pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
67375 +{
67376 +       pte_t *pte;
67377 +
67378 +       pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
67379 +       if (pte) {
67380 +               clear_page(pte);
67381 +               clean_dcache_area(pte, sizeof(pte_t) * PTRS_PER_PTE);
67382 +               pte += PTRS_PER_PTE;
67383 +       }
67384 +
67385 +       return pte;
67386 +}
67387 +
67388 +static inline struct page *
67389 +pte_alloc_one(struct mm_struct *mm, unsigned long addr)
67390 +{
67391 +       struct page *pte;
67392 +
67393 +       pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
67394 +       if (pte) {
67395 +               void *page = page_address(pte);
67396 +               clear_page(page);
67397 +               clean_dcache_area(page, sizeof(pte_t) * PTRS_PER_PTE);
67398 +       }
67399 +
67400 +       return pte;
67401 +}
67402 +
67403 +/*
67404 + * Free one PTE table.
67405 + */
67406 +static inline void pte_free_kernel(pte_t *pte)
67407 +{
67408 +       if (pte) {
67409 +               pte -= PTRS_PER_PTE;
67410 +               free_page((unsigned long)pte);
67411 +       }
67412 +}
67413 +
67414 +static inline void pte_free(struct page *pte)
67415 +{
67416 +       __free_page(pte);
67417 +}
67418 +
67419 +/*
67420 + * Populate the pmdp entry with a pointer to the pte.  This pmd is part
67421 + * of the mm address space.
67422 + *
67423 + * Ensure that we always set both PMD entries.
67424 + */
67425 +static inline void
67426 +pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
67427 +{
67428 +       unsigned long pte_ptr = (unsigned long)ptep;
67429 +       unsigned long pmdval;
67430 +
67431 +       BUG_ON(mm != &init_mm);
67432 +
67433 +       /*
67434 +        * The pmd must be loaded with the physical
67435 +        * address of the PTE table
67436 +        */
67437 +       pte_ptr -= PTRS_PER_PTE * sizeof(void *);
67438 +       pmdval = __pa(pte_ptr) | _PAGE_KERNEL_TABLE;
67439 +       pmdp[0] = __pmd(pmdval);
67440 +       pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t));
67441 +       flush_pmd_entry(pmdp);
67442 +}
67443 +
67444 +static inline void
67445 +pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep)
67446 +{
67447 +       unsigned long pmdval;
67448 +
67449 +       BUG_ON(mm == &init_mm);
67450 +
67451 +       pmdval = page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE;
67452 +       pmdp[0] = __pmd(pmdval);
67453 +       pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t));
67454 +       flush_pmd_entry(pmdp);
67455 +}
67456  
67457  #endif
67458 diff -Nru a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
67459 --- a/include/asm-arm/pgtable.h Thu Mar  6 08:19:03 2003
67460 +++ b/include/asm-arm/pgtable.h Wed Sep  3 10:17:58 2003
67461 @@ -1,7 +1,7 @@
67462  /*
67463   *  linux/include/asm-arm/pgtable.h
67464   *
67465 - *  Copyright (C) 2000-2002 Russell King
67466 + *  Copyright (C) 1995-2002 Russell King
67467   *
67468   * This program is free software; you can redistribute it and/or modify
67469   * it under the terms of the GNU General Public License version 2 as
67470 @@ -16,15 +16,24 @@
67471  #include <asm/arch/vmalloc.h>
67472  
67473  /*
67474 + * We pull a couple of tricks here:
67475 + *  1. We wrap the PMD into the PGD.
67476 + *  2. We lie about the size of the PTE and PGD.
67477 + * Even though we have 256 PTE entries and 4096 PGD entries, we tell
67478 + * Linux that we actually have 512 PTE entries and 2048 PGD entries.
67479 + * Each "Linux" PGD entry is made up of two hardware PGD entries, and
67480 + * each PTE table is actually two hardware PTE tables.
67481 + */
67482 +#define PTRS_PER_PTE           512
67483 +#define PTRS_PER_PMD           1
67484 +#define PTRS_PER_PGD           2048
67485 +
67486 +/*
67487   * PMD_SHIFT determines the size of the area a second-level page table can map
67488   * PGDIR_SHIFT determines what a third-level page table entry can map
67489   */
67490  #define PMD_SHIFT              20
67491 -#ifdef CONFIG_CPU_32
67492  #define PGDIR_SHIFT            21
67493 -#else
67494 -#define PGDIR_SHIFT            20
67495 -#endif
67496  
67497  #define LIBRARY_TEXT_START     0x0c000000
67498  
67499 @@ -47,6 +56,117 @@
67500  #define USER_PTRS_PER_PGD      ((TASK_SIZE/PGDIR_SIZE) - FIRST_USER_PGD_NR)
67501  
67502  /*
67503 + * Hardware page table definitions.
67504 + *
67505 + * + Level 1 descriptor (PMD)
67506 + *   - common
67507 + */
67508 +#define PMD_TYPE_MASK          (3 << 0)
67509 +#define PMD_TYPE_FAULT         (0 << 0)
67510 +#define PMD_TYPE_TABLE         (1 << 0)
67511 +#define PMD_TYPE_SECT          (2 << 0)
67512 +#define PMD_BIT4               (1 << 4)
67513 +#define PMD_DOMAIN(x)          ((x) << 5)
67514 +#define PMD_PROTECTION         (1 << 9)        /* v5 */
67515 +/*
67516 + *   - section
67517 + */
67518 +#define PMD_SECT_BUFFERABLE    (1 << 2)
67519 +#define PMD_SECT_CACHEABLE     (1 << 3)
67520 +#define PMD_SECT_AP_WRITE      (1 << 10)
67521 +#define PMD_SECT_AP_READ       (1 << 11)
67522 +#define PMD_SECT_TEX(x)                ((x) << 12)     /* v5 */
67523 +#define PMD_SECT_APX           (1 << 15)       /* v6 */
67524 +#define PMD_SECT_S             (1 << 16)       /* v6 */
67525 +#define PMD_SECT_nG            (1 << 17)       /* v6 */
67526 +
67527 +#define PMD_SECT_UNCACHED      (0)
67528 +#define PMD_SECT_BUFFERED      (PMD_SECT_BUFFERABLE)
67529 +#define PMD_SECT_WT            (PMD_SECT_CACHEABLE)
67530 +#define PMD_SECT_WB            (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE)
67531 +#define PMD_SECT_MINICACHE     (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE)
67532 +#define PMD_SECT_WBWA          (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE)
67533 +
67534 +/*
67535 + *   - coarse table (not used)
67536 + */
67537 +
67538 +/*
67539 + * + Level 2 descriptor (PTE)
67540 + *   - common
67541 + */
67542 +#define PTE_TYPE_MASK          (3 << 0)
67543 +#define PTE_TYPE_FAULT         (0 << 0)
67544 +#define PTE_TYPE_LARGE         (1 << 0)
67545 +#define PTE_TYPE_SMALL         (2 << 0)
67546 +#define PTE_TYPE_EXT           (3 << 0)        /* v5 */
67547 +#define PTE_BUFFERABLE         (1 << 2)
67548 +#define PTE_CACHEABLE          (1 << 3)
67549 +
67550 +/*
67551 + *   - extended small page/tiny page
67552 + */
67553 +#define PTE_EXT_AP_UNO_SRO     (0 << 4)
67554 +#define PTE_EXT_AP_UNO_SRW     (1 << 4)
67555 +#define PTE_EXT_AP_URO_SRW     (2 << 4)
67556 +#define PTE_EXT_AP_URW_SRW     (3 << 4)
67557 +#define PTE_EXT_TEX(x)         ((x) << 6)      /* v5 */
67558 +
67559 +/*
67560 + *   - small page
67561 + */
67562 +#define PTE_SMALL_AP_UNO_SRO   (0x00 << 4)
67563 +#define PTE_SMALL_AP_UNO_SRW   (0x55 << 4)
67564 +#define PTE_SMALL_AP_URO_SRW   (0xaa << 4)
67565 +#define PTE_SMALL_AP_URW_SRW   (0xff << 4)
67566 +#define PTE_AP_READ            PTE_SMALL_AP_URO_SRW
67567 +#define PTE_AP_WRITE           PTE_SMALL_AP_UNO_SRW
67568 +
67569 +/*
67570 + * "Linux" PTE definitions.
67571 + *
67572 + * We keep two sets of PTEs - the hardware and the linux version.
67573 + * This allows greater flexibility in the way we map the Linux bits
67574 + * onto the hardware tables, and allows us to have YOUNG and DIRTY
67575 + * bits.
67576 + *
67577 + * The PTE table pointer refers to the hardware entries; the "Linux"
67578 + * entries are stored 1024 bytes below.
67579 + */
67580 +#define L_PTE_PRESENT          (1 << 0)
67581 +#define L_PTE_FILE             (1 << 1)        /* only when !PRESENT */
67582 +#define L_PTE_YOUNG            (1 << 1)
67583 +#define L_PTE_BUFFERABLE       (1 << 2)        /* matches PTE */
67584 +#define L_PTE_CACHEABLE                (1 << 3)        /* matches PTE */
67585 +#define L_PTE_USER             (1 << 4)
67586 +#define L_PTE_WRITE            (1 << 5)
67587 +#define L_PTE_EXEC             (1 << 6)
67588 +#define L_PTE_DIRTY            (1 << 7)
67589 +
67590 +#ifndef __ASSEMBLY__
67591 +
67592 +#include <asm/domain.h>
67593 +
67594 +#define _PAGE_USER_TABLE       (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_USER))
67595 +#define _PAGE_KERNEL_TABLE     (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_KERNEL))
67596 +
67597 +/*
67598 + * The following macros handle the cache and bufferable bits...
67599 + */
67600 +#define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
67601 +#define _L_PTE_READ    L_PTE_USER | L_PTE_EXEC | L_PTE_CACHEABLE | L_PTE_BUFFERABLE
67602 +
67603 +#define PAGE_NONE       __pgprot(_L_PTE_DEFAULT)
67604 +#define PAGE_COPY       __pgprot(_L_PTE_DEFAULT | _L_PTE_READ)
67605 +#define PAGE_SHARED     __pgprot(_L_PTE_DEFAULT | _L_PTE_READ | L_PTE_WRITE)
67606 +#define PAGE_READONLY   __pgprot(_L_PTE_DEFAULT | _L_PTE_READ)
67607 +#define PAGE_KERNEL     __pgprot(_L_PTE_DEFAULT | L_PTE_CACHEABLE | L_PTE_BUFFERABLE | L_PTE_DIRTY | L_PTE_WRITE | L_PTE_EXEC)
67608 +
67609 +#define _PAGE_CHG_MASK (PAGE_MASK | L_PTE_DIRTY | L_PTE_YOUNG)
67610 +
67611 +#endif /* __ASSEMBLY__ */
67612 +
67613 +/*
67614   * The table below defines the page protection levels that we insert into our
67615   * Linux page table version.  These get translated into the best that the
67616   * architecture can perform.  Note that on most ARM hardware:
67617 @@ -86,9 +206,82 @@
67618  #define pte_none(pte)          (!pte_val(pte))
67619  #define pte_clear(ptep)                set_pte((ptep), __pte(0))
67620  #define pte_page(pte)          (pfn_to_page(pte_pfn(pte)))
67621 +#define pte_offset_kernel(dir,addr)    (pmd_page_kernel(*(dir)) + __pte_index(addr))
67622 +#define pte_offset_map(dir,addr)       (pmd_page_kernel(*(dir)) + __pte_index(addr))
67623 +#define pte_offset_map_nested(dir,addr)        (pmd_page_kernel(*(dir)) + __pte_index(addr))
67624 +#define pte_unmap(pte)         do { } while (0)
67625 +#define pte_unmap_nested(pte)  do { } while (0)
67626 +
67627 +#define set_pte(ptep, pte)     cpu_set_pte(ptep,pte)
67628 +
67629 +/*
67630 + * The following only work if pte_present() is true.
67631 + * Undefined behaviour if not..
67632 + */
67633 +#define pte_present(pte)       (pte_val(pte) & L_PTE_PRESENT)
67634 +#define pte_read(pte)          (pte_val(pte) & L_PTE_USER)
67635 +#define pte_write(pte)         (pte_val(pte) & L_PTE_WRITE)
67636 +#define pte_exec(pte)          (pte_val(pte) & L_PTE_EXEC)
67637 +#define pte_dirty(pte)         (pte_val(pte) & L_PTE_DIRTY)
67638 +#define pte_young(pte)         (pte_val(pte) & L_PTE_YOUNG)
67639 +
67640 +/*
67641 + * The following only works if pte_present() is not true.
67642 + */
67643 +#define pte_file(pte)          (pte_val(pte) & L_PTE_FILE)
67644 +#define pte_to_pgoff(x)                (pte_val(x) >> 2)
67645 +#define pgoff_to_pte(x)                __pte(((x) << 2) | L_PTE_FILE)
67646 +
67647 +#define PTE_FILE_MAX_BITS      30
67648 +
67649 +#define PTE_BIT_FUNC(fn,op) \
67650 +static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; }
67651 +
67652 +/*PTE_BIT_FUNC(rdprotect, &= ~L_PTE_USER);*/
67653 +/*PTE_BIT_FUNC(mkread,    |= L_PTE_USER);*/
67654 +PTE_BIT_FUNC(wrprotect, &= ~L_PTE_WRITE);
67655 +PTE_BIT_FUNC(mkwrite,   |= L_PTE_WRITE);
67656 +PTE_BIT_FUNC(exprotect, &= ~L_PTE_EXEC);
67657 +PTE_BIT_FUNC(mkexec,    |= L_PTE_EXEC);
67658 +PTE_BIT_FUNC(mkclean,   &= ~L_PTE_DIRTY);
67659 +PTE_BIT_FUNC(mkdirty,   |= L_PTE_DIRTY);
67660 +PTE_BIT_FUNC(mkold,     &= ~L_PTE_YOUNG);
67661 +PTE_BIT_FUNC(mkyoung,   |= L_PTE_YOUNG);
67662 +
67663 +/*
67664 + * Mark the prot value as uncacheable and unbufferable.
67665 + */
67666 +#define pgprot_noncached(prot) __pgprot(pgprot_val(prot) & ~(L_PTE_CACHEABLE | L_PTE_BUFFERABLE))
67667 +#define pgprot_writecombine(prot) __pgprot(pgprot_val(prot) & ~L_PTE_CACHEABLE)
67668  
67669  #define pmd_none(pmd)          (!pmd_val(pmd))
67670  #define pmd_present(pmd)       (pmd_val(pmd))
67671 +#define pmd_bad(pmd)           (pmd_val(pmd) & 2)
67672 +
67673 +#define set_pmd(pmdp,pmd)              \
67674 +       do {                            \
67675 +               *pmdp = pmd;            \
67676 +               flush_pmd_entry(pmdp);  \
67677 +       } while (0)
67678 +
67679 +#define pmd_clear(pmdp)                        \
67680 +       do {                            \
67681 +               pmdp[0] = __pmd(0);     \
67682 +               pmdp[1] = __pmd(0);     \
67683 +               clean_pmd_entry(pmdp);  \
67684 +       } while (0)
67685 +
67686 +static inline pte_t *pmd_page_kernel(pmd_t pmd)
67687 +{
67688 +       unsigned long ptr;
67689 +
67690 +       ptr = pmd_val(pmd) & ~(PTRS_PER_PTE * sizeof(void *) - 1);
67691 +       ptr += PTRS_PER_PTE * sizeof(void *);
67692 +
67693 +       return __va(ptr);
67694 +}
67695 +
67696 +#define pmd_page(pmd) virt_to_page(__va(pmd_val(pmd)))
67697  
67698  /*
67699   * Permanent address of a page. We never have highmem, so this is trivial.
67700 @@ -129,8 +322,6 @@
67701  /* Find an entry in the third-level page table.. */
67702  #define __pte_index(addr)      (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
67703  
67704 -#include <asm/proc/pgtable.h>
67705 -
67706  static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
67707  {
67708         pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
67709 @@ -163,6 +354,8 @@
67710                 remap_page_range(vma,from,phys,size,prot)
67711  
67712  typedef pte_t *pte_addr_t;
67713 +
67714 +#define pgtable_cache_init() do { } while (0)
67715  
67716  #endif /* !__ASSEMBLY__ */
67717  
67718 diff -Nru a/include/asm-arm/proc-armo/assembler.h b/include/asm-arm/proc-armo/assembler.h
67719 --- a/include/asm-arm/proc-armo/assembler.h     Tue Feb  5 09:39:52 2002
67720 +++ /dev/null   Wed Dec 31 16:00:00 1969
67721 @@ -1,106 +0,0 @@
67722 -/*
67723 - *  linux/asm-arm/proc-armo/assembler.h
67724 - *
67725 - *  Copyright (C) 1996 Russell King
67726 - *
67727 - * This program is free software; you can redistribute it and/or modify
67728 - * it under the terms of the GNU General Public License version 2 as
67729 - * published by the Free Software Foundation.
67730 - *
67731 - *  This file contains arm architecture specific defines
67732 - *  for the different processors
67733 - */
67734 -#define MODE_USR       USR26_MODE
67735 -#define MODE_FIQ       FIQ26_MODE
67736 -#define MODE_IRQ       IRQ26_MODE
67737 -#define MODE_SVC       SVC26_MODE
67738 -
67739 -#define DEFAULT_FIQ    MODE_FIQ
67740 -
67741 -#ifdef __STDC__
67742 -#define LOADREGS(cond, base, reglist...)\
67743 -       ldm##cond       base,reglist^
67744 -
67745 -#define RETINSTR(instr, regs...)\
67746 -       instr##s        regs
67747 -#else
67748 -#define LOADREGS(cond, base, reglist...)\
67749 -       ldm/**/cond     base,reglist^
67750 -
67751 -#define RETINSTR(instr, regs...)\
67752 -       instr/**/s      regs
67753 -#endif
67754 -
67755 -#define MODENOP\
67756 -       mov     r0, r0
67757 -
67758 -#define MODE(savereg,tmpreg,mode) \
67759 -       mov     savereg, pc; \
67760 -       bic     tmpreg, savereg, $0x0c000003; \
67761 -       orr     tmpreg, tmpreg, $mode; \
67762 -       teqp    tmpreg, $0
67763 -
67764 -#define RESTOREMODE(savereg) \
67765 -       teqp    savereg, $0
67766 -
67767 -#define SAVEIRQS(tmpreg)
67768 -
67769 -#define RESTOREIRQS(tmpreg)
67770 -
67771 -#define DISABLEIRQS(tmpreg)\
67772 -       teqp    pc, $0x08000003
67773 -
67774 -#define ENABLEIRQS(tmpreg)\
67775 -       teqp    pc, $0x00000003
67776 -
67777 -#define USERMODE(tmpreg)\
67778 -       teqp    pc, $0x00000000;\
67779 -       mov     r0, r0
67780 -
67781 -#define SVCMODE(tmpreg)\
67782 -       teqp    pc, $0x00000003;\
67783 -       mov     r0, r0
67784 -
67785 -
67786 -/*
67787 - * Save the current IRQ state and disable IRQs
67788 - * Note that this macro assumes FIQs are enabled, and
67789 - * that the processor is in SVC mode.
67790 - */
67791 -       .macro  save_and_disable_irqs, oldcpsr, temp
67792 -  mov \oldcpsr, pc
67793 -  orr \temp, \oldcpsr, #0x08000000
67794 -  teqp \temp, #0
67795 -  .endm
67796 -
67797 -/*
67798 - * Restore interrupt state previously stored in
67799 - * a register
67800 - * ** Actually do nothing on Arc - hope that the caller uses a MOVS PC soon
67801 - * after!
67802 - */
67803 -       .macro  restore_irqs, oldcpsr
67804 -  @ This be restore_irqs
67805 -  .endm
67806 -
67807 -/*
67808 - * These two are used to save LR/restore PC over a user-based access.
67809 - * The old 26-bit architecture requires that we do.  On 32-bit
67810 - * architecture, we can safely ignore this requirement.
67811 - */
67812 -       .macro  save_lr
67813 -       str     lr, [sp, #-4]!
67814 -       .endm
67815 -
67816 -       .macro  restore_pc
67817 -       ldmfd   sp!, {pc}^
67818 -       .endm
67819 -
67820 -#define USER(x...)                             \
67821 -9999:  x;                                      \
67822 -       .section __ex_table,"a";                \
67823 -       .align  3;                              \
67824 -       .long   9999b,9001f;                    \
67825 -       .previous
67826 -
67827 -
67828 diff -Nru a/include/asm-arm/proc-armo/cache.h b/include/asm-arm/proc-armo/cache.h
67829 --- a/include/asm-arm/proc-armo/cache.h Sat Apr 12 16:21:01 2003
67830 +++ /dev/null   Wed Dec 31 16:00:00 1969
67831 @@ -1,28 +0,0 @@
67832 -/*
67833 - *  linux/include/asm-arm/proc-armo/cache.h
67834 - *
67835 - *  Copyright (C) 1999-2001 Russell King
67836 - *
67837 - * This program is free software; you can redistribute it and/or modify
67838 - * it under the terms of the GNU General Public License version 2 as
67839 - * published by the Free Software Foundation.
67840 - *
67841 - *  Cache handling for 26-bit ARM processors.
67842 - */
67843 -#define flush_cache_all()                      do { } while (0)
67844 -#define flush_cache_mm(mm)                     do { } while (0)
67845 -#define flush_cache_range(vma,start,end)       do { } while (0)
67846 -#define flush_cache_page(vma,vmaddr)           do { } while (0)
67847 -
67848 -#define invalidate_dcache_range(start,end)     do { } while (0)
67849 -#define clean_dcache_range(start,end)          do { } while (0)
67850 -#define flush_dcache_range(start,end)          do { } while (0)
67851 -#define flush_dcache_page(page)                        do { } while (0)
67852 -#define clean_dcache_entry(_s)      do { } while (0)
67853 -#define clean_cache_entry(_start)              do { } while (0)
67854 -
67855 -#define flush_icache_range(start,end)          do { } while (0)
67856 -#define flush_icache_page(vma,page)            do { } while (0)
67857 -
67858 -/* DAG: ARM3 will flush cache on MEMC updates anyway? so don't bother */
67859 -#define clean_cache_area(_start,_size) do { } while (0)
67860 diff -Nru a/include/asm-arm/proc-armo/elf.h b/include/asm-arm/proc-armo/elf.h
67861 --- a/include/asm-arm/proc-armo/elf.h   Tue Feb  5 09:39:52 2002
67862 +++ /dev/null   Wed Dec 31 16:00:00 1969
67863 @@ -1,15 +0,0 @@
67864 -/*
67865 - * ELF definitions for 26-bit CPUs
67866 - */
67867 -
67868 -#define ELF_EXEC_PAGESIZE      32768
67869 -
67870 -#ifdef __KERNEL__
67871 -
67872 -/* We can only execute 26-bit code. */
67873 -#define ELF_PROC_OK(x)         \
67874 -       ((x)->e_flags & EF_ARM_APCS26)
67875 -
67876 -#define SET_PERSONALITY(ex,ibcs2) set_personality(PER_LINUX)
67877 -
67878 -#endif
67879 diff -Nru a/include/asm-arm/proc-armo/locks.h b/include/asm-arm/proc-armo/locks.h
67880 --- a/include/asm-arm/proc-armo/locks.h Sat Apr 27 16:19:55 2002
67881 +++ /dev/null   Wed Dec 31 16:00:00 1969
67882 @@ -1,161 +0,0 @@
67883 -/*
67884 - *  linux/include/asm-arm/proc-armo/locks.h
67885 - *
67886 - *  Copyright (C) 2000 Russell King
67887 - *  Fixes for 26 bit machines, (C) 2000 Dave Gilbert
67888 - *
67889 - * This program is free software; you can redistribute it and/or modify
67890 - * it under the terms of the GNU General Public License version 2 as
67891 - * published by the Free Software Foundation.
67892 - *
67893 - *  Interrupt safe locking assembler. 
67894 - */
67895 -#ifndef __ASM_PROC_LOCKS_H
67896 -#define __ASM_PROC_LOCKS_H
67897 -
67898 -/* Decrements by 1, fails if value < 0 */
67899 -#define __down_op(ptr,fail)                    \
67900 -       ({                                      \
67901 -       __asm__ __volatile__ (                  \
67902 -       "@ atomic down operation\n"             \
67903 -"      mov     ip, pc\n"                       \
67904 -"      orr     lr, ip, #0x08000000\n"          \
67905 -"      teqp    lr, #0\n"                       \
67906 -"      ldr     lr, [%0]\n"                     \
67907 -"      and     ip, ip, #0x0c000003\n"          \
67908 -"      subs    lr, lr, #1\n"                   \
67909 -"      str     lr, [%0]\n"                     \
67910 -"      orrmi   ip, ip, #0x80000000     @ set N\n" \
67911 -"      teqp    ip, #0\n"                       \
67912 -"      movmi   ip, %0\n"                       \
67913 -"      blmi    " #fail                         \
67914 -       :                                       \
67915 -       : "r" (ptr)                             \
67916 -       : "ip", "lr", "cc");                    \
67917 -       })
67918 -
67919 -#define __down_op_ret(ptr,fail)                        \
67920 -       ({                                      \
67921 -               unsigned int result;            \
67922 -       __asm__ __volatile__ (                  \
67923 -"      @ down_op_ret\n"                        \
67924 -"      mov     ip, pc\n"                       \
67925 -"      orr     lr, ip, #0x08000000\n"          \
67926 -"      teqp    lr, #0\n"                       \
67927 -"      ldr     lr, [%1]\n"                     \
67928 -"      and     ip, ip, #0x0c000003\n"          \
67929 -"      subs    lr, lr, #1\n"                   \
67930 -"      str     lr, [%1]\n"                     \
67931 -"      orrmi   ip, ip, #0x80000000     @ set N\n" \
67932 -"      teqp    ip, #0\n"                       \
67933 -"      movmi   ip, %1\n"                       \
67934 -"      movpl   ip, #0\n"                       \
67935 -"      blmi    " #fail "\n"                    \
67936 -"      mov     %0, ip"                         \
67937 -       : "=&r" (result)                        \
67938 -       : "r" (ptr)                             \
67939 -       : "ip", "lr", "cc");                    \
67940 -       result;                                 \
67941 -       })
67942 -
67943 -#define __up_op(ptr,wake)                      \
67944 -       ({                                      \
67945 -       __asm__ __volatile__ (                  \
67946 -       "@ up_op\n"                             \
67947 -"      mov     ip, pc\n"                       \
67948 -"      orr     lr, ip, #0x08000000\n"          \
67949 -"      teqp    lr, #0\n"                       \
67950 -"      ldr     lr, [%0]\n"                     \
67951 -"      and     ip, ip, #0x0c000003\n"          \
67952 -"      adds    lr, lr, #1\n"                   \
67953 -"      str     lr, [%0]\n"                     \
67954 -"      orrle   ip, ip, #0x80000000     @ set N - should this be mi ??? DAG ! \n" \
67955 -"      teqp    ip, #0\n"                       \
67956 -"      movmi   ip, %0\n"                       \
67957 -"      blmi    " #wake                         \
67958 -       :                                       \
67959 -       : "r" (ptr)                             \
67960 -       : "ip", "lr", "cc");                    \
67961 -       })
67962 -
67963 -/*
67964 - * The value 0x01000000 supports up to 128 processors and
67965 - * lots of processes.  BIAS must be chosen such that sub'ing
67966 - * BIAS once per CPU will result in the long remaining
67967 - * negative.
67968 - */
67969 -#define RW_LOCK_BIAS      0x01000000
67970 -#define RW_LOCK_BIAS_STR "0x01000000"
67971 -
67972 -/* Decrements by RW_LOCK_BIAS rather than 1, fails if value != 0 */
67973 -#define __down_op_write(ptr,fail)              \
67974 -       ({                                      \
67975 -       __asm__ __volatile__(                   \
67976 -       "@ down_op_write\n"                     \
67977 -"      mov     ip, pc\n"                       \
67978 -"      orr     lr, ip, #0x08000000\n"          \
67979 -"      teqp    lr, #0\n"                       \
67980 -"      and     ip, ip, #0x0c000003\n"          \
67981 -\
67982 -"      ldr     lr, [%0]\n"                     \
67983 -"      subs    lr, lr, %1\n"                   \
67984 -"      str     lr, [%0]\n"                     \
67985 -\
67986 -" orreq ip, ip, #0x40000000 @ set Z \n"\
67987 -"      teqp    ip, #0\n"                       \
67988 -"      movne   ip, %0\n"                       \
67989 -"      blne    " #fail                         \
67990 -       :                                       \
67991 -       : "r" (ptr), "I" (RW_LOCK_BIAS)         \
67992 -       : "ip", "lr", "cc");                    \
67993 -       })
67994 -
67995 -/* Increments by RW_LOCK_BIAS, wakes if value >= 0 */
67996 -#define __up_op_write(ptr,wake)                        \
67997 -       ({                                      \
67998 -       __asm__ __volatile__(                   \
67999 -       "@ up_op_read\n"                        \
68000 -"      mov     ip, pc\n"                       \
68001 -"      orr     lr, ip, #0x08000000\n"          \
68002 -"      teqp    lr, #0\n"                       \
68003 -\
68004 -"      ldr     lr, [%0]\n"                     \
68005 -"      and     ip, ip, #0x0c000003\n"          \
68006 -"      adds    lr, lr, %1\n"                   \
68007 -"      str     lr, [%0]\n"                     \
68008 -\
68009 -" orrcs ip, ip, #0x20000000 @ set C\n" \
68010 -"      teqp    ip, #0\n"                       \
68011 -"      movcs   ip, %0\n"                       \
68012 -"      blcs    " #wake                         \
68013 -       :                                       \
68014 -       : "r" (ptr), "I" (RW_LOCK_BIAS)         \
68015 -       : "ip", "lr", "cc");                    \
68016 -       })
68017 -
68018 -#define __down_op_read(ptr,fail)               \
68019 -       __down_op(ptr, fail)
68020 -
68021 -#define __up_op_read(ptr,wake)                 \
68022 -       ({                                      \
68023 -       __asm__ __volatile__(                   \
68024 -       "@ up_op_read\n"                        \
68025 -"      mov     ip, pc\n"                       \
68026 -"      orr     lr, ip, #0x08000000\n"          \
68027 -"      teqp    lr, #0\n"                       \
68028 -\
68029 -"      ldr     lr, [%0]\n"                     \
68030 -"      and     ip, ip, #0x0c000003\n"          \
68031 -"      adds    lr, lr, %1\n"                   \
68032 -"      str     lr, [%0]\n"                     \
68033 -\
68034 -" orreq ip, ip, #0x40000000 @ Set Z \n" \
68035 -"      teqp    ip, #0\n"                       \
68036 -"      moveq   ip, %0\n"                       \
68037 -"      bleq    " #wake                         \
68038 -       :                                       \
68039 -       : "r" (ptr), "I" (1)                    \
68040 -       : "ip", "lr", "cc");                    \
68041 -       })
68042 -
68043 -#endif
68044 diff -Nru a/include/asm-arm/proc-armo/page.h b/include/asm-arm/proc-armo/page.h
68045 --- a/include/asm-arm/proc-armo/page.h  Sun Mar 10 04:04:31 2002
68046 +++ /dev/null   Wed Dec 31 16:00:00 1969
68047 @@ -1,40 +0,0 @@
68048 -/*
68049 - *  linux/include/asm-arm/proc-armo/page.h
68050 - *
68051 - *  Copyright (C) 1995-2002 Russell King
68052 - *
68053 - * This program is free software; you can redistribute it and/or modify
68054 - * it under the terms of the GNU General Public License version 2 as
68055 - * published by the Free Software Foundation.
68056 - */
68057 -#ifndef __ASM_PROC_PAGE_H
68058 -#define __ASM_PROC_PAGE_H
68059 -
68060 -#include <linux/config.h>
68061 -
68062 -/* PAGE_SHIFT determines the page size.  This is configurable. */
68063 -#if defined(CONFIG_PAGESIZE_16)
68064 -#define PAGE_SHIFT     14              /* 16K */
68065 -#else          /* default */
68066 -#define PAGE_SHIFT     15              /* 32K */
68067 -#endif
68068 -
68069 -#define EXEC_PAGESIZE   32768
68070 -
68071 -#ifndef __ASSEMBLY__
68072 -#ifdef STRICT_MM_TYPECHECKS
68073 -
68074 -typedef struct { unsigned long pgd; } pgd_t;
68075 -
68076 -#define pgd_val(x)     ((x).pgd)
68077 -
68078 -#else
68079 -
68080 -typedef unsigned long pgd_t;
68081 -
68082 -#define pgd_val(x)     (x)
68083 -
68084 -#endif
68085 -#endif /* __ASSEMBLY__ */
68086 -
68087 -#endif /* __ASM_PROC_PAGE_H */
68088 diff -Nru a/include/asm-arm/proc-armo/pgalloc.h b/include/asm-arm/proc-armo/pgalloc.h
68089 --- a/include/asm-arm/proc-armo/pgalloc.h       Mon Apr 21 15:43:43 2003
68090 +++ /dev/null   Wed Dec 31 16:00:00 1969
68091 @@ -1,44 +0,0 @@
68092 -/*
68093 - *  linux/include/asm-arm/proc-armo/pgalloc.h
68094 - *
68095 - *  Copyright (C) 2001-2002 Russell King
68096 - *
68097 - * Page table allocation/freeing primitives for 26-bit ARM processors.
68098 - */
68099 -
68100 -#include <linux/slab.h>
68101 -
68102 -extern kmem_cache_t *pte_cache;
68103 -
68104 -static inline pte_t *
68105 -pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
68106 -{
68107 -       return kmem_cache_alloc(pte_cache, GFP_KERNEL);
68108 -}
68109 -
68110 -static inline void pte_free_kernel(pte_t *pte)
68111 -{
68112 -       if (pte)
68113 -               kmem_cache_free(pte_cache, pte);
68114 -}
68115 -
68116 -/*
68117 - * Populate the pmdp entry with a pointer to the pte.  This pmd is part
68118 - * of the mm address space.
68119 - *
68120 - * If 'mm' is the init tasks mm, then we are doing a vmalloc, and we
68121 - * need to set stuff up correctly for it.
68122 - */
68123 -static inline void
68124 -pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
68125 -{
68126 -       set_pmd(pmdp, __mk_pmd(ptep, _PAGE_TABLE));
68127 -}
68128 -
68129 -/*
68130 - * We use the old 2.5.5-rmk1 hack for this.
68131 - * This is not truly correct, but should be functional.
68132 - */
68133 -#define pte_alloc_one(mm,addr) ((struct page *)pte_alloc_one_kernel(mm,addr))
68134 -#define pte_free(pte)          pte_free_kernel((pte_t *)pte)
68135 -#define pmd_populate(mm,pmdp,ptep) pmd_populate_kernel(mm,pmdp,(pte_t *)ptep)
68136 diff -Nru a/include/asm-arm/proc-armo/pgtable.h b/include/asm-arm/proc-armo/pgtable.h
68137 --- a/include/asm-arm/proc-armo/pgtable.h       Sun Mar 10 04:04:32 2002
68138 +++ /dev/null   Wed Dec 31 16:00:00 1969
68139 @@ -1,106 +0,0 @@
68140 -/*
68141 - *  linux/include/asm-arm/proc-armo/pgtable.h
68142 - *
68143 - *  Copyright (C) 1995-2002 Russell King
68144 - *
68145 - * This program is free software; you can redistribute it and/or modify
68146 - * it under the terms of the GNU General Public License version 2 as
68147 - * published by the Free Software Foundation.
68148 - *
68149 - *  18-Oct-1997        RMK     Now two-level (32x32)
68150 - */
68151 -#ifndef __ASM_PROC_PGTABLE_H
68152 -#define __ASM_PROC_PGTABLE_H
68153 -
68154 -/*
68155 - * entries per page directory level: they are two-level, so
68156 - * we don't really have any PMD directory.
68157 - */
68158 -#define PTRS_PER_PTE           32
68159 -#define PTRS_PER_PMD           1
68160 -#define PTRS_PER_PGD           32
68161 -
68162 -/*
68163 - * The vmalloc() routines leaves a hole of 4kB between each vmalloced
68164 - * area for the same reason. ;)
68165 - */
68166 -#define VMALLOC_START    0x01a00000
68167 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
68168 -#define VMALLOC_END      0x01c00000
68169 -
68170 -#define _PAGE_TABLE     (0x01)
68171 -
68172 -#define pmd_bad(pmd)           ((pmd_val(pmd) & 0xfc000002))
68173 -#define set_pmd(pmdp,pmd)      ((*(pmdp)) = (pmd))
68174 -#define pmd_clear(pmdp)                set_pmd(pmdp, __pmd(0))
68175 -
68176 -static inline pmd_t __mk_pmd(pte_t *ptep, unsigned long prot)
68177 -{
68178 -       unsigned long pte_ptr = (unsigned long)ptep;
68179 -       pmd_t pmd;
68180 -
68181 -       pmd_val(pmd) = __virt_to_phys(pte_ptr) | prot;
68182 -
68183 -       return pmd;
68184 -}
68185 -
68186 -static inline unsigned long pmd_page(pmd_t pmd)
68187 -{
68188 -       return __phys_to_virt(pmd_val(pmd) & ~_PAGE_TABLE);
68189 -}
68190 -
68191 -#define pte_offset_kernel(dir,addr)    (pmd_page_kernel(*(dir)) + __pte_index(addr))
68192 -#define pte_offset_map(dir,addr)       (pmd_page_kernel(*(dir)) + __pte_index(addr))
68193 -#define pte_offset_map_nested(dir,addr)        (pmd_page_kernel(*(dir)) + __pte_index(addr))
68194 -#define pte_unmap(pte)                 do { } while (0)
68195 -#define pte_unmap_nested(pte)          do { } while (0)
68196 -
68197 -#define set_pte(pteptr, pteval)        ((*(pteptr)) = (pteval))
68198 -
68199 -#define _PAGE_PRESENT  0x01
68200 -#define _PAGE_READONLY 0x02
68201 -#define _PAGE_NOT_USER 0x04
68202 -#define _PAGE_OLD      0x08
68203 -#define _PAGE_CLEAN    0x10
68204 -
68205 -/*                               -- present --   -- !dirty --  --- !write ---   ---- !user --- */
68206 -#define PAGE_NONE       __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY | _PAGE_NOT_USER)
68207 -#define PAGE_SHARED     __pgprot(_PAGE_PRESENT | _PAGE_CLEAN                                  )
68208 -#define PAGE_COPY       __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY                 )
68209 -#define PAGE_READONLY   __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY                 )
68210 -#define PAGE_KERNEL     __pgprot(_PAGE_PRESENT                                | _PAGE_NOT_USER)
68211 -
68212 -#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_OLD | _PAGE_CLEAN)
68213 -
68214 -
68215 -/*
68216 - * The following only work if pte_present() is true.
68217 - * Undefined behaviour if not..
68218 - */
68219 -#define pte_present(pte)               (pte_val(pte) & _PAGE_PRESENT)
68220 -#define pte_read(pte)                  (!(pte_val(pte) & _PAGE_NOT_USER))
68221 -#define pte_write(pte)                 (!(pte_val(pte) & _PAGE_READONLY))
68222 -#define pte_exec(pte)                  (!(pte_val(pte) & _PAGE_NOT_USER))
68223 -#define pte_dirty(pte)                 (!(pte_val(pte) & _PAGE_CLEAN))
68224 -#define pte_young(pte)                 (!(pte_val(pte) & _PAGE_OLD))
68225 -
68226 -static inline pte_t pte_wrprotect(pte_t pte)    { pte_val(pte) |= _PAGE_READONLY;  return pte; }
68227 -static inline pte_t pte_rdprotect(pte_t pte)    { pte_val(pte) |= _PAGE_NOT_USER;  return pte; }
68228 -static inline pte_t pte_exprotect(pte_t pte)    { pte_val(pte) |= _PAGE_NOT_USER;  return pte; }
68229 -static inline pte_t pte_mkclean(pte_t pte)      { pte_val(pte) |= _PAGE_CLEAN;     return pte; }
68230 -static inline pte_t pte_mkold(pte_t pte)        { pte_val(pte) |= _PAGE_OLD;       return pte; }
68231 -
68232 -static inline pte_t pte_mkwrite(pte_t pte)      { pte_val(pte) &= ~_PAGE_READONLY; return pte; }
68233 -static inline pte_t pte_mkread(pte_t pte)       { pte_val(pte) &= ~_PAGE_NOT_USER; return pte; }
68234 -static inline pte_t pte_mkexec(pte_t pte)       { pte_val(pte) &= ~_PAGE_NOT_USER; return pte; }
68235 -static inline pte_t pte_mkdirty(pte_t pte)      { pte_val(pte) &= ~_PAGE_CLEAN;    return pte; }
68236 -static inline pte_t pte_mkyoung(pte_t pte)      { pte_val(pte) &= ~_PAGE_OLD;      return pte; }
68237 -
68238 -/*
68239 - * We don't store cache state bits in the page table here.
68240 - */
68241 -#define pgprot_noncached(prot) (prot)
68242 -
68243 -extern void pgtable_cache_init(void);
68244 -
68245 -#endif /* __ASM_PROC_PGTABLE_H */
68246 diff -Nru a/include/asm-arm/proc-armo/processor.h b/include/asm-arm/proc-armo/processor.h
68247 --- a/include/asm-arm/proc-armo/processor.h     Wed May 29 08:06:36 2002
68248 +++ /dev/null   Wed Dec 31 16:00:00 1969
68249 @@ -1,63 +0,0 @@
68250 -/*
68251 - *  linux/include/asm-arm/proc-armo/processor.h
68252 - *
68253 - *  Copyright (C) 1996 Russell King.
68254 - *
68255 - * This program is free software; you can redistribute it and/or modify
68256 - * it under the terms of the GNU General Public License version 2 as
68257 - * published by the Free Software Foundation.
68258 - *
68259 - *  Changelog:
68260 - *   27-06-1996        RMK     Created
68261 - *   10-10-1996        RMK     Brought up to date with SA110
68262 - *   26-09-1996        RMK     Added 'EXTRA_THREAD_STRUCT*'
68263 - *   28-09-1996        RMK     Moved start_thread into the processor dependencies
68264 - *   11-01-1998        RMK     Added new uaccess_t
68265 - *   09-09-1998        PJB     Delete redundant `wp_works_ok'
68266 - *   30-05-1999        PJB     Save sl across context switches
68267 - */
68268 -#ifndef __ASM_PROC_PROCESSOR_H
68269 -#define __ASM_PROC_PROCESSOR_H
68270 -
68271 -#include <linux/string.h>
68272 -
68273 -#define KERNEL_STACK_SIZE 4096
68274 -
68275 -typedef struct {
68276 -       void (*put_byte)(void);                 /* Special calling convention */
68277 -       void (*get_byte)(void);                 /* Special calling convention */
68278 -       void (*put_half)(void);                 /* Special calling convention */
68279 -       void (*get_half)(void);                 /* Special calling convention */
68280 -       void (*put_word)(void);                 /* Special calling convention */
68281 -       void (*get_word)(void);                 /* Special calling convention */
68282 -       unsigned long (*copy_from_user)(void *to, const void *from, unsigned long sz);
68283 -       unsigned long (*copy_to_user)(void *to, const void *from, unsigned long sz);
68284 -       unsigned long (*clear_user)(void *addr, unsigned long sz);
68285 -       unsigned long (*strncpy_from_user)(char *to, const char *from, unsigned long sz);
68286 -       unsigned long (*strnlen_user)(const char *s, long n);
68287 -} uaccess_t;
68288 -
68289 -extern uaccess_t uaccess_user, uaccess_kernel;
68290 -
68291 -#define EXTRA_THREAD_STRUCT                                                    \
68292 -       uaccess_t       *uaccess;               /* User access functions*/
68293 -
68294 -#define EXTRA_THREAD_STRUCT_INIT               \
68295 -       uaccess:        &uaccess_kernel,
68296 -
68297 -#define start_thread(regs,pc,sp)                                       \
68298 -({                                                                     \
68299 -       unsigned long *stack = (unsigned long *)sp;                     \
68300 -       set_fs(USER_DS);                                                \
68301 -       memzero(regs->uregs, sizeof (regs->uregs));                     \
68302 -       regs->ARM_pc = pc;              /* pc */                        \
68303 -       regs->ARM_sp = sp;              /* sp */                        \
68304 -       regs->ARM_r2 = stack[2];        /* r2 (envp) */                 \
68305 -       regs->ARM_r1 = stack[1];        /* r1 (argv) */                 \
68306 -       regs->ARM_r0 = stack[0];        /* r0 (argc) */                 \
68307 -})
68308 -
68309 -#define KSTK_EIP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)))[1020])
68310 -#define KSTK_ESP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)))[1018])
68311 -
68312 -#endif
68313 diff -Nru a/include/asm-arm/proc-armo/ptrace.h b/include/asm-arm/proc-armo/ptrace.h
68314 --- a/include/asm-arm/proc-armo/ptrace.h        Tue Feb  5 07:23:18 2002
68315 +++ /dev/null   Wed Dec 31 16:00:00 1969
68316 @@ -1,98 +0,0 @@
68317 -/*
68318 - *  linux/include/asm-arm/proc-armo/ptrace.h
68319 - *
68320 - *  Copyright (C) 1996-2001 Russell King
68321 - *
68322 - * This program is free software; you can redistribute it and/or modify
68323 - * it under the terms of the GNU General Public License version 2 as
68324 - * published by the Free Software Foundation.
68325 - */
68326 -#ifndef __ASM_PROC_PTRACE_H
68327 -#define __ASM_PROC_PTRACE_H
68328 -
68329 -#define USR26_MODE     0x00000000
68330 -#define FIQ26_MODE     0x00000001
68331 -#define IRQ26_MODE     0x00000002
68332 -#define SVC26_MODE     0x00000003
68333 -#define USR_MODE       USR26_MODE
68334 -#define FIQ_MODE       FIQ26_MODE
68335 -#define IRQ_MODE       IRQ26_MODE
68336 -#define SVC_MODE       SVC26_MODE
68337 -#define MODE_MASK      0x00000003
68338 -#define PSR_F_BIT      0x04000000
68339 -#define PSR_I_BIT      0x08000000
68340 -#define PSR_V_BIT      0x10000000
68341 -#define PSR_C_BIT      0x20000000
68342 -#define PSR_Z_BIT      0x40000000
68343 -#define PSR_N_BIT      0x80000000
68344 -#define PCMASK         0xfc000003
68345 -
68346 -#ifndef __ASSEMBLY__
68347 -
68348 -/* this struct defines the way the registers are stored on the
68349 -   stack during a system call. */
68350 -
68351 -struct pt_regs {
68352 -       long uregs[17];
68353 -};
68354 -
68355 -#define ARM_pc         uregs[15]
68356 -#define ARM_lr         uregs[14]
68357 -#define ARM_sp         uregs[13]
68358 -#define ARM_ip         uregs[12]
68359 -#define ARM_fp         uregs[11]
68360 -#define ARM_r10                uregs[10]
68361 -#define ARM_r9         uregs[9]
68362 -#define ARM_r8         uregs[8]
68363 -#define ARM_r7         uregs[7]
68364 -#define ARM_r6         uregs[6]
68365 -#define ARM_r5         uregs[5]
68366 -#define ARM_r4         uregs[4]
68367 -#define ARM_r3         uregs[3]
68368 -#define ARM_r2         uregs[2]
68369 -#define ARM_r1         uregs[1]
68370 -#define ARM_r0         uregs[0]
68371 -#define ARM_ORIG_r0    uregs[16]
68372 -
68373 -#ifdef __KERNEL__
68374 -
68375 -#define processor_mode(regs) \
68376 -       ((regs)->ARM_pc & MODE_MASK)
68377 -
68378 -#define user_mode(regs) \
68379 -       (processor_mode(regs) == USR26_MODE)
68380 -
68381 -#define thumb_mode(regs) (0)
68382 -
68383 -#define interrupts_enabled(regs) \
68384 -       (!((regs)->ARM_pc & PSR_I_BIT))
68385 -
68386 -#define fast_interrupts_enabled(regs) \
68387 -       (!((regs)->ARM_pc & PSR_F_BIT))
68388 -
68389 -#define condition_codes(regs) \
68390 -       ((regs)->ARM_pc & (PSR_V_BIT|PSR_C_BIT|PSR_Z_BIT|PSR_N_BIT))
68391 -
68392 -/* Are the current registers suitable for user mode?
68393 - * (used to maintain security in signal handlers)
68394 - */
68395 -static inline int valid_user_regs(struct pt_regs *regs)
68396 -{
68397 -       if (user_mode(regs) &&
68398 -           (regs->ARM_pc & (PSR_F_BIT | PSR_I_BIT)) == 0)
68399 -               return 1;
68400 -
68401 -       /*
68402 -        * force it to be something sensible
68403 -        */
68404 -       regs->ARM_pc &= ~(MODE_MASK | PSR_F_BIT | PSR_I_BIT);
68405 -
68406 -       return 0;
68407 -}
68408 -
68409 -#endif /* __KERNEL__ */
68410 -
68411 -#endif /* __ASSEMBLY__ */
68412 -
68413 -#endif
68414 -
68415 diff -Nru a/include/asm-arm/proc-armo/shmparam.h b/include/asm-arm/proc-armo/shmparam.h
68416 --- a/include/asm-arm/proc-armo/shmparam.h      Tue Feb  5 09:39:52 2002
68417 +++ /dev/null   Wed Dec 31 16:00:00 1969
68418 @@ -1,19 +0,0 @@
68419 -/*
68420 - *  linux/include/asm-arm/proc-armo/shmparam.h
68421 - *
68422 - *  Copyright (C) 1996 Russell King
68423 - *
68424 - * This program is free software; you can redistribute it and/or modify
68425 - * it under the terms of the GNU General Public License version 2 as
68426 - * published by the Free Software Foundation.
68427 - *
68428 - *  definitions for the shared process memory on the ARM3
68429 - */
68430 -#ifndef __ASM_PROC_SHMPARAM_H
68431 -#define __ASM_PROC_SHMPARAM_H
68432 -
68433 -#ifndef SHMMAX
68434 -#define SHMMAX         0x003fa000
68435 -#endif
68436 -
68437 -#endif
68438 diff -Nru a/include/asm-arm/proc-armo/system.h b/include/asm-arm/proc-armo/system.h
68439 --- a/include/asm-arm/proc-armo/system.h        Sun Oct 13 03:46:44 2002
68440 +++ /dev/null   Wed Dec 31 16:00:00 1969
68441 @@ -1,128 +0,0 @@
68442 -/*
68443 - *  linux/include/asm-arm/proc-armo/system.h
68444 - *
68445 - *  Copyright (C) 1995, 1996 Russell King
68446 - *
68447 - * This program is free software; you can redistribute it and/or modify
68448 - * it under the terms of the GNU General Public License version 2 as
68449 - * published by the Free Software Foundation.
68450 - */
68451 -#ifndef __ASM_PROC_SYSTEM_H
68452 -#define __ASM_PROC_SYSTEM_H
68453 -
68454 -#define vectors_base() (0)
68455 -
68456 -static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
68457 -{
68458 -       extern void __bad_xchg(volatile void *, int);
68459 -
68460 -       switch (size) {
68461 -               case 1: return cpu_xchg_1(x, ptr);
68462 -               case 4: return cpu_xchg_4(x, ptr);
68463 -               default: __bad_xchg(ptr, size);
68464 -       }
68465 -       return 0;
68466 -}
68467 -
68468 -/*
68469 - * We need to turn the caches off before calling the reset vector - RiscOS
68470 - * messes up if we don't
68471 - */
68472 -#define proc_hard_reset()      cpu_proc_fin()
68473 -
68474 -/*
68475 - * A couple of speedups for the ARM
68476 - */
68477 -
68478 -/*
68479 - * Save the current interrupt enable state & disable IRQs
68480 - */
68481 -#define local_save_flags_cli(x)                                \
68482 -       do {                                            \
68483 -         unsigned long temp;                           \
68484 -         __asm__ __volatile__(                         \
68485 -"      mov     %0, pc          @ save_flags_cli\n"     \
68486 -"      orr     %1, %0, #0x08000000\n"                  \
68487 -"      and     %0, %0, #0x0c000000\n"                  \
68488 -"      teqp    %1, #0\n"                               \
68489 -         : "=r" (x), "=r" (temp)                       \
68490 -         :                                             \
68491 -         : "memory");                                  \
68492 -       } while (0)
68493 -       
68494 -/*
68495 - * Enable IRQs
68496 - */
68497 -#define local_irq_enable()                                     \
68498 -       do {                                    \
68499 -         unsigned long temp;                   \
68500 -         __asm__ __volatile__(                 \
68501 -"      mov     %0, pc          @ sti\n"        \
68502 -"      bic     %0, %0, #0x08000000\n"          \
68503 -"      teqp    %0, #0\n"                       \
68504 -         : "=r" (temp)                         \
68505 -         :                                     \
68506 -         : "memory");                          \
68507 -       } while(0)
68508 -
68509 -/*
68510 - * Disable IRQs
68511 - */
68512 -#define local_irq_disable()                                    \
68513 -       do {                                    \
68514 -         unsigned long temp;                   \
68515 -         __asm__ __volatile__(                 \
68516 -"      mov     %0, pc          @ cli\n"        \
68517 -"      orr     %0, %0, #0x08000000\n"          \
68518 -"      teqp    %0, #0\n"                       \
68519 -         : "=r" (temp)                         \
68520 -         :                                     \
68521 -         : "memory");                          \
68522 -       } while(0)
68523 -
68524 -#define __clf()        do {                            \
68525 -       unsigned long temp;                     \
68526 -       __asm__ __volatile__(                   \
68527 -"      mov     %0, pc          @ clf\n"        \
68528 -"      orr     %0, %0, #0x04000000\n"          \
68529 -"      teqp    %0, #0\n"                       \
68530 -       : "=r" (temp));                         \
68531 -    } while(0)
68532 -
68533 -#define __stf()        do {                            \
68534 -       unsigned long temp;                     \
68535 -       __asm__ __volatile__(                   \
68536 -"      mov     %0, pc          @ stf\n"        \
68537 -"      bic     %0, %0, #0x04000000\n"          \
68538 -"      teqp    %0, #0\n"                       \
68539 -       : "=r" (temp));                         \
68540 -    } while(0)
68541 -
68542 -/*
68543 - * save current IRQ & FIQ state
68544 - */
68545 -#define local_save_flags(x)                            \
68546 -       do {                                    \
68547 -         __asm__ __volatile__(                 \
68548 -"      mov     %0, pc          @ save_flags\n" \
68549 -"      and     %0, %0, #0x0c000000\n"          \
68550 -         : "=r" (x));                          \
68551 -       } while (0)
68552 -
68553 -/*
68554 - * restore saved IRQ & FIQ state
68555 - */
68556 -#define local_irq_restore(x)                           \
68557 -       do {                                            \
68558 -         unsigned long temp;                           \
68559 -         __asm__ __volatile__(                         \
68560 -"      mov     %0, pc          @ restore_flags\n"      \
68561 -"      bic     %0, %0, #0x0c000000\n"                  \
68562 -"      orr     %0, %0, %1\n"                           \
68563 -"      teqp    %0, #0\n"                               \
68564 -         : "=&r" (temp)                                \
68565 -         : "r" (x)                                     \
68566 -         : "memory");                                  \
68567 -       } while (0)
68568 -
68569 -#endif
68570 diff -Nru a/include/asm-arm/proc-armo/tlbflush.h b/include/asm-arm/proc-armo/tlbflush.h
68571 --- a/include/asm-arm/proc-armo/tlbflush.h      Wed Apr 17 11:47:51 2002
68572 +++ /dev/null   Wed Dec 31 16:00:00 1969
68573 @@ -1,63 +0,0 @@
68574 -/*
68575 - * TLB flushing:
68576 - *
68577 - *  - flush_tlb_all() flushes all processes TLBs
68578 - *  - flush_tlb_mm(mm) flushes the specified mm context TLB's
68579 - *  - flush_tlb_page(vma, vmaddr) flushes one page
68580 - *  - flush_tlb_range(vma, start, end) flushes a range of pages
68581 - */
68582 -#define flush_tlb_all()                                memc_update_all()
68583 -#define flush_tlb_mm(mm)                       memc_update_mm(mm)
68584 -#define flush_tlb_range(vma,start,end)         \
68585 -               do { memc_update_mm(vma->vm_mm); (void)(start); (void)(end); } while (0)
68586 -#define flush_tlb_page(vma, vmaddr)            do { } while (0)
68587 -
68588 -/*
68589 - * The following handle the weird MEMC chip
68590 - */
68591 -static inline void memc_update_all(void)
68592 -{
68593 -       struct task_struct *p;
68594 -
68595 -       cpu_memc_update_all(init_mm.pgd);
68596 -       for_each_task(p) {
68597 -               if (!p->mm)
68598 -                       continue;
68599 -               cpu_memc_update_all(p->mm->pgd);
68600 -       }
68601 -       processor._set_pgd(current->active_mm->pgd);
68602 -}
68603 -
68604 -static inline void memc_update_mm(struct mm_struct *mm)
68605 -{
68606 -       cpu_memc_update_all(mm->pgd);
68607 -
68608 -       if (mm == current->active_mm)
68609 -               processor._set_pgd(mm->pgd);
68610 -}
68611 -
68612 -static inline void
68613 -memc_clear(struct mm_struct *mm, struct page *page)
68614 -{
68615 -       cpu_memc_update_entry(mm->pgd, (unsigned long) page_address(page), 0);
68616 -
68617 -       if (mm == current->active_mm)
68618 -               processor._set_pgd(mm->pgd);
68619 -}
68620 -
68621 -static inline void
68622 -memc_update_addr(struct mm_struct *mm, pte_t pte, unsigned long vaddr)
68623 -{
68624 -       cpu_memc_update_entry(mm->pgd, pte_val(pte), vaddr);
68625 -
68626 -       if (mm == current->active_mm)
68627 -               processor._set_pgd(mm->pgd);
68628 -}
68629 -
68630 -static inline void
68631 -update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
68632 -{
68633 -       struct mm_struct *mm = vma->vm_mm;
68634 -       memc_update_addr(mm, pte, addr);
68635 -}
68636 -
68637 diff -Nru a/include/asm-arm/proc-armo/uaccess.h b/include/asm-arm/proc-armo/uaccess.h
68638 --- a/include/asm-arm/proc-armo/uaccess.h       Mon Feb  4 23:44:00 2002
68639 +++ /dev/null   Wed Dec 31 16:00:00 1969
68640 @@ -1,138 +0,0 @@
68641 -/*
68642 - *  linux/include/asm-arm/proc-armo/segment.h
68643 - *
68644 - *  Copyright (C) 1996 Russell King
68645 - *
68646 - * This program is free software; you can redistribute it and/or modify
68647 - * it under the terms of the GNU General Public License version 2 as
68648 - * published by the Free Software Foundation.
68649 - */
68650 -
68651 -/*
68652 - * The fs functions are implemented on the ARM2 and ARM3 architectures
68653 - * manually.
68654 - * Use *_user functions to access user memory with faulting behaving
68655 - *   as though the user is accessing the memory.
68656 - * Use set_fs(get_ds()) and then the *_user functions to allow them to
68657 - *   access kernel memory.
68658 - */
68659 -
68660 -/*
68661 - * These are the values used to represent the user `fs' and the kernel `ds'
68662 - */
68663 -#define KERNEL_DS      0x03000000
68664 -#define USER_DS        0x02000000
68665 -
68666 -extern uaccess_t uaccess_user, uaccess_kernel;
68667 -
68668 -static inline void set_fs (mm_segment_t fs)
68669 -{
68670 -       current->addr_limit = fs;
68671 -       current->thread.uaccess = fs == USER_DS ? &uaccess_user : &uaccess_kernel;
68672 -}
68673 -
68674 -#define __range_ok(addr,size) ({                                       \
68675 -       unsigned long flag, sum;                                        \
68676 -       __asm__ __volatile__("subs %1, %0, %3; cmpcs %1, %2; movcs %0, #0" \
68677 -               : "=&r" (flag), "=&r" (sum)                             \
68678 -               : "r" (addr), "Ir" (size), "0" (current->addr_limit)    \
68679 -               : "cc");                                                \
68680 -       flag; })
68681 -
68682 -#define __addr_ok(addr) ({                                             \
68683 -       unsigned long flag;                                             \
68684 -       __asm__ __volatile__("cmp %2, %0; movlo %0, #0"                 \
68685 -               : "=&r" (flag)                                          \
68686 -               : "0" (current->addr_limit), "r" (addr)                 \
68687 -               : "cc");                                                \
68688 -       (flag == 0); })
68689 -
68690 -#define __put_user_asm_byte(x,addr,err)                                        \
68691 -       __asm__ __volatile__(                                           \
68692 -       "       mov     r0, %1\n"                                       \
68693 -       "       mov     r1, %2\n"                                       \
68694 -       "       mov     r2, %0\n"                                       \
68695 -       "       mov     lr, pc\n"                                       \
68696 -       "       mov     pc, %3\n"                                       \
68697 -       "       mov     %0, r2\n"                                       \
68698 -       : "=r" (err)                                                    \
68699 -       : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_byte), \
68700 -         "0" (err)                                                     \
68701 -       : "r0", "r1", "r2", "lr")
68702 -
68703 -#define __put_user_asm_half(x,addr,err)                                        \
68704 -       __asm__ __volatile__(                                           \
68705 -       "       mov     r0, %1\n"                                       \
68706 -       "       mov     r1, %2\n"                                       \
68707 -       "       mov     r2, %0\n"                                       \
68708 -       "       mov     lr, pc\n"                                       \
68709 -       "       mov     pc, %3\n"                                       \
68710 -       "       mov     %0, r2\n"                                       \
68711 -       : "=r" (err)                                                    \
68712 -       : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_half), \
68713 -         "0" (err)                                                     \
68714 -       : "r0", "r1", "r2", "lr")
68715 -
68716 -#define __put_user_asm_word(x,addr,err)                                        \
68717 -       __asm__ __volatile__(                                           \
68718 -       "       mov     r0, %1\n"                                       \
68719 -       "       mov     r1, %2\n"                                       \
68720 -       "       mov     r2, %0\n"                                       \
68721 -       "       mov     lr, pc\n"                                       \
68722 -       "       mov     pc, %3\n"                                       \
68723 -       "       mov     %0, r2\n"                                       \
68724 -       : "=r" (err)                                                    \
68725 -       : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_word), \
68726 -         "0" (err)                                                     \
68727 -       : "r0", "r1", "r2", "lr")
68728 -
68729 -#define __get_user_asm_byte(x,addr,err)                                        \
68730 -       __asm__ __volatile__(                                           \
68731 -       "       mov     r0, %2\n"                                       \
68732 -       "       mov     r1, %0\n"                                       \
68733 -       "       mov     lr, pc\n"                                       \
68734 -       "       mov     pc, %3\n"                                       \
68735 -       "       mov     %0, r1\n"                                       \
68736 -       "       mov     %1, r0\n"                                       \
68737 -       : "=r" (err), "=r" (x)                                          \
68738 -       : "r" (addr), "r" (current->thread.uaccess->get_byte), "0" (err)        \
68739 -       : "r0", "r1", "r2", "lr")
68740 -
68741 -#define __get_user_asm_half(x,addr,err)                                        \
68742 -       __asm__ __volatile__(                                           \
68743 -       "       mov     r0, %2\n"                                       \
68744 -       "       mov     r1, %0\n"                                       \
68745 -       "       mov     lr, pc\n"                                       \
68746 -       "       mov     pc, %3\n"                                       \
68747 -       "       mov     %0, r1\n"                                       \
68748 -       "       mov     %1, r0\n"                                       \
68749 -       : "=r" (err), "=r" (x)                                          \
68750 -       : "r" (addr), "r" (current->thread.uaccess->get_half), "0" (err)        \
68751 -       : "r0", "r1", "r2", "lr")
68752 -
68753 -#define __get_user_asm_word(x,addr,err)                                        \
68754 -       __asm__ __volatile__(                                           \
68755 -       "       mov     r0, %2\n"                                       \
68756 -       "       mov     r1, %0\n"                                       \
68757 -       "       mov     lr, pc\n"                                       \
68758 -       "       mov     pc, %3\n"                                       \
68759 -       "       mov     %0, r1\n"                                       \
68760 -       "       mov     %1, r0\n"                                       \
68761 -       : "=r" (err), "=r" (x)                                          \
68762 -       : "r" (addr), "r" (current->thread.uaccess->get_word), "0" (err)        \
68763 -       : "r0", "r1", "r2", "lr")
68764 -
68765 -#define __do_copy_from_user(to,from,n)                                 \
68766 -       (n) = current->thread.uaccess->copy_from_user((to),(from),(n))
68767 -
68768 -#define __do_copy_to_user(to,from,n)                                   \
68769 -       (n) = current->thread.uaccess->copy_to_user((to),(from),(n))
68770 -
68771 -#define __do_clear_user(addr,sz)                                       \
68772 -       (sz) = current->thread.uaccess->clear_user((addr),(sz))
68773 -
68774 -#define __do_strncpy_from_user(dst,src,count,res)                      \
68775 -       (res) = current->thread.uaccess->strncpy_from_user(dst,src,count)
68776 -
68777 -#define __do_strnlen_user(s,n,res)                                     \
68778 -       (res) = current->thread.uaccess->strnlen_user(s,n)
68779 diff -Nru a/include/asm-arm/proc-armv/assembler.h b/include/asm-arm/proc-armv/assembler.h
68780 --- a/include/asm-arm/proc-armv/assembler.h     Tue Feb  5 07:23:18 2002
68781 +++ /dev/null   Wed Dec 31 16:00:00 1969
68782 @@ -1,74 +0,0 @@
68783 -/*
68784 - *  linux/asm-arm/proc-armv/assembler.h
68785 - *
68786 - *  Copyright (C) 1996-2000 Russell King
68787 - *
68788 - * This program is free software; you can redistribute it and/or modify
68789 - * it under the terms of the GNU General Public License version 2 as
68790 - * published by the Free Software Foundation.
68791 - *
68792 - *  This file contains ARM processor specifics for
68793 - *  the ARM6 and better processors.
68794 - */
68795 -#define MODE_USR       USR_MODE
68796 -#define MODE_FIQ       FIQ_MODE
68797 -#define MODE_IRQ       IRQ_MODE
68798 -#define MODE_SVC       SVC_MODE
68799 -
68800 -#define DEFAULT_FIQ    MODE_FIQ
68801 -
68802 -/*
68803 - * LOADREGS - ldm with PC in register list (eg, ldmfd sp!, {pc})
68804 - */
68805 -#ifdef __STDC__
68806 -#define LOADREGS(cond, base, reglist...)\
68807 -       ldm##cond       base,reglist
68808 -#else
68809 -#define LOADREGS(cond, base, reglist...)\
68810 -       ldm/**/cond     base,reglist
68811 -#endif
68812 -
68813 -/*
68814 - * Build a return instruction for this processor type.
68815 - */
68816 -#define RETINSTR(instr, regs...)\
68817 -       instr   regs
68818 -
68819 -/*
68820 - * Save the current IRQ state and disable IRQs.  Note that this macro
68821 - * assumes FIQs are enabled, and that the processor is in SVC mode.
68822 - */
68823 -       .macro  save_and_disable_irqs, oldcpsr, temp
68824 -       mrs     \oldcpsr, cpsr
68825 -       mov     \temp, #PSR_I_BIT | MODE_SVC
68826 -       msr     cpsr_c, \temp
68827 -       .endm
68828 -
68829 -/*
68830 - * Restore interrupt state previously stored in a register.  We don't
68831 - * guarantee that this will preserve the flags.
68832 - */
68833 -       .macro  restore_irqs, oldcpsr
68834 -       msr     cpsr_c, \oldcpsr
68835 -       .endm
68836 -
68837 -/*
68838 - * These two are used to save LR/restore PC over a user-based access.
68839 - * The old 26-bit architecture requires that we do.  On 32-bit
68840 - * architecture, we can safely ignore this requirement.
68841 - */
68842 -       .macro  save_lr
68843 -       .endm
68844 -
68845 -       .macro  restore_pc
68846 -       mov     pc, lr
68847 -       .endm
68848 -
68849 -#define USER(x...)                             \
68850 -9999:  x;                                      \
68851 -       .section __ex_table,"a";                \
68852 -       .align  3;                              \
68853 -       .long   9999b,9001f;                    \
68854 -       .previous
68855 -
68856 -
68857 diff -Nru a/include/asm-arm/proc-armv/cache.h b/include/asm-arm/proc-armv/cache.h
68858 --- a/include/asm-arm/proc-armv/cache.h Sun Apr 27 16:46:33 2003
68859 +++ /dev/null   Wed Dec 31 16:00:00 1969
68860 @@ -1,278 +0,0 @@
68861 -/*
68862 - *  linux/include/asm-arm/proc-armv/cache.h
68863 - *
68864 - *  Copyright (C) 1999-2002 Russell King
68865 - *
68866 - * This program is free software; you can redistribute it and/or modify
68867 - * it under the terms of the GNU General Public License version 2 as
68868 - * published by the Free Software Foundation.
68869 - */
68870 -#include <asm/mman.h>
68871 -#include <asm/glue.h>
68872 -
68873 -/*
68874 - *     Cache Model
68875 - *     ===========
68876 - */
68877 -#undef _CACHE
68878 -#undef MULTI_CACHE
68879 -
68880 -#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
68881 -# ifdef _CACHE
68882 -#  define MULTI_CACHE 1
68883 -# else
68884 -#  define _CACHE v3
68885 -# endif
68886 -#endif
68887 -
68888 -#if defined(CONFIG_CPU_ARM720T)
68889 -# ifdef _CACHE
68890 -#  define MULTI_CACHE 1
68891 -# else
68892 -#  define _CACHE v4
68893 -# endif
68894 -#endif
68895 -
68896 -#if defined(CONFIG_CPU_ARM920T) || defined(CONFIG_CPU_ARM922T) || \
68897 -    defined(CONFIG_CPU_ARM1020)
68898 -# define MULTI_CACHE 1
68899 -#endif
68900 -
68901 -#if defined(CONFIG_CPU_ARM926T)
68902 -# ifdef _CACHE
68903 -#  define MULTI_CACHE 1
68904 -# else
68905 -#  define _CACHE arm926
68906 -# endif
68907 -#endif
68908 -
68909 -#if defined(CONFIG_CPU_SA110) || defined(CONFIG_CPU_SA1100)
68910 -# ifdef _CACHE
68911 -#  define MULTI_CACHE 1
68912 -# else
68913 -#  define _CACHE v4wb
68914 -# endif
68915 -#endif
68916 -
68917 -#if defined(CONFIG_CPU_XSCALE)
68918 -# ifdef _CACHE
68919 -#  define MULTI_CACHE 1
68920 -# else
68921 -#  define _CACHE xscale
68922 -# endif
68923 -#endif
68924 -
68925 -#if !defined(_CACHE) && !defined(MULTI_CACHE)
68926 -#error Unknown cache maintainence model
68927 -#endif
68928 -
68929 -/*
68930 - * This flag is used to indicate that the page pointed to by a pte
68931 - * is dirty and requires cleaning before returning it to the user.
68932 - */
68933 -#define PG_dcache_dirty PG_arch_1
68934 -
68935 -/*
68936 - *     MM Cache Management
68937 - *     ===================
68938 - *
68939 - *     The arch/arm/mm/cache-*.S and arch/arm/mm/proc-*.S files
68940 - *     implement these methods.
68941 - *
68942 - *     Start addresses are inclusive and end addresses are exclusive;
68943 - *     start addresses should be rounded down, end addresses up.
68944 - *
68945 - *     See linux/Documentation/cachetlb.txt for more information.
68946 - *     Please note that the implementation of these, and the required
68947 - *     effects are cache-type (VIVT/VIPT/PIPT) specific.
68948 - *
68949 - *     flush_cache_kern_all()
68950 - *
68951 - *             Unconditionally clean and invalidate the entire cache.
68952 - *
68953 - *     flush_cache_user_mm(mm)
68954 - *
68955 - *             Clean and invalidate all user space cache entries
68956 - *             before a change of page tables.
68957 - *
68958 - *     flush_cache_user_range(start, end, flags)
68959 - *
68960 - *             Clean and invalidate a range of cache entries in the
68961 - *             specified address space before a change of page tables.
68962 - *             - start - user start address (inclusive, page aligned)
68963 - *             - end   - user end address   (exclusive, page aligned)
68964 - *             - flags - vma->vm_flags field
68965 - *
68966 - *     coherent_kern_range(start, end)
68967 - *
68968 - *             Ensure coherency between the Icache and the Dcache in the
68969 - *             region described by start, end.  If you have non-snooping
68970 - *             Harvard caches, you need to implement this function.
68971 - *             - start  - virtual start address
68972 - *             - end    - virtual end address
68973 - *
68974 - *     DMA Cache Coherency
68975 - *     ===================
68976 - *
68977 - *     dma_inv_range(start, end)
68978 - *
68979 - *             Invalidate (discard) the specified virtual address range.
68980 - *             May not write back any entries.  If 'start' or 'end'
68981 - *             are not cache line aligned, those lines must be written
68982 - *             back.
68983 - *             - start  - virtual start address
68984 - *             - end    - virtual end address
68985 - *
68986 - *     dma_clean_range(start, end)
68987 - *
68988 - *             Clean (write back) the specified virtual address range.
68989 - *             - start  - virtual start address
68990 - *             - end    - virtual end address
68991 - *
68992 - *     dma_flush_range(start, end)
68993 - *
68994 - *             Clean and invalidate the specified virtual address range.
68995 - *             - start  - virtual start address
68996 - *             - end    - virtual end address
68997 - */
68998 -
68999 -struct cpu_cache_fns {
69000 -       void (*flush_kern_all)(void);
69001 -       void (*flush_user_all)(void);
69002 -       void (*flush_user_range)(unsigned long, unsigned long, unsigned int);
69003 -
69004 -       void (*coherent_kern_range)(unsigned long, unsigned long);
69005 -       void (*flush_kern_dcache_page)(void *);
69006 -
69007 -       void (*dma_inv_range)(unsigned long, unsigned long);
69008 -       void (*dma_clean_range)(unsigned long, unsigned long);
69009 -       void (*dma_flush_range)(unsigned long, unsigned long);
69010 -};
69011 -
69012 -/*
69013 - * Select the calling method
69014 - */
69015 -#ifdef MULTI_CACHE
69016 -
69017 -extern struct cpu_cache_fns cpu_cache;
69018 -
69019 -#define __cpuc_flush_kern_all          cpu_cache.flush_kern_all
69020 -#define __cpuc_flush_user_all          cpu_cache.flush_user_all
69021 -#define __cpuc_flush_user_range                cpu_cache.flush_user_range
69022 -#define __cpuc_coherent_kern_range     cpu_cache.coherent_kern_range
69023 -#define __cpuc_flush_dcache_page       cpu_cache.flush_kern_dcache_page
69024 -
69025 -/*
69026 - * These are private to the dma-mapping API.  Do not use directly.
69027 - * Their sole purpose is to ensure that data held in the cache
69028 - * is visible to DMA, or data written by DMA to system memory is
69029 - * visible to the CPU.
69030 - */
69031 -#define dmac_inv_range                 cpu_cache.dma_inv_range
69032 -#define dmac_clean_range               cpu_cache.dma_clean_range
69033 -#define dmac_flush_range               cpu_cache.dma_flush_range
69034 -
69035 -#else
69036 -
69037 -#define __cpuc_flush_kern_all          __glue(_CACHE,_flush_kern_cache_all)
69038 -#define __cpuc_flush_user_all          __glue(_CACHE,_flush_user_cache_all)
69039 -#define __cpuc_flush_user_range                __glue(_CACHE,_flush_user_cache_range)
69040 -#define __cpuc_coherent_kern_range     __glue(_CACHE,_coherent_kern_range)
69041 -#define __cpuc_flush_dcache_page       __glue(_CACHE,_flush_kern_dcache_page)
69042 -
69043 -extern void __cpuc_flush_kern_all(void);
69044 -extern void __cpuc_flush_user_all(void);
69045 -extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int);
69046 -extern void __cpuc_coherent_kern_range(unsigned long, unsigned long);
69047 -extern void __cpuc_flush_dcache_page(void *);
69048 -
69049 -/*
69050 - * These are private to the dma-mapping API.  Do not use directly.
69051 - * Their sole purpose is to ensure that data held in the cache
69052 - * is visible to DMA, or data written by DMA to system memory is
69053 - * visible to the CPU.
69054 - */
69055 -#define dmac_inv_range                 __glue(_CACHE,_dma_inv_range)
69056 -#define dmac_clean_range               __glue(_CACHE,_dma_clean_range)
69057 -#define dmac_flush_range               __glue(_CACHE,_dma_flush_range)
69058 -
69059 -extern void dmac_inv_range(unsigned long, unsigned long);
69060 -extern void dmac_clean_range(unsigned long, unsigned long);
69061 -extern void dmac_flush_range(unsigned long, unsigned long);
69062 -
69063 -#endif
69064 -
69065 -/*
69066 - * Convert calls to our calling convention.
69067 - */
69068 -#define flush_cache_all()              __cpuc_flush_kern_all()
69069 -
69070 -static inline void flush_cache_mm(struct mm_struct *mm)
69071 -{
69072 -       if (current->active_mm == mm)
69073 -               __cpuc_flush_user_all();
69074 -}
69075 -
69076 -static inline void
69077 -flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
69078 -{
69079 -       if (current->active_mm == vma->vm_mm)
69080 -               __cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
69081 -                                       vma->vm_flags);
69082 -}
69083 -
69084 -static inline void
69085 -flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr)
69086 -{
69087 -       if (current->active_mm == vma->vm_mm) {
69088 -               unsigned long addr = user_addr & PAGE_MASK;
69089 -               __cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
69090 -       }
69091 -}
69092 -
69093 -/*
69094 - * Perform necessary cache operations to ensure that data previously
69095 - * stored within this range of addresses can be executed by the CPU.
69096 - */
69097 -#define flush_icache_range(s,e)                __cpuc_coherent_kern_range(s,e)
69098 -
69099 -/*
69100 - * Perform necessary cache operations to ensure that the TLB will
69101 - * see data written in the specified area.
69102 - */
69103 -#define clean_dcache_area(start,size)  cpu_dcache_clean_area(start, size)
69104 -
69105 -/*
69106 - * flush_dcache_page is used when the kernel has written to the page
69107 - * cache page at virtual address page->virtual.
69108 - *
69109 - * If this page isn't mapped (ie, page->mapping = NULL), or it has
69110 - * userspace mappings (page->mapping->i_mmap or page->mapping->i_mmap_shared)
69111 - * then we _must_ always clean + invalidate the dcache entries associated
69112 - * with the kernel mapping.
69113 - *
69114 - * Otherwise we can defer the operation, and clean the cache when we are
69115 - * about to change to user space.  This is the same method as used on SPARC64.
69116 - * See update_mmu_cache for the user space part.
69117 - */
69118 -#define mapping_mapped(map)    (!list_empty(&(map)->i_mmap) || \
69119 -                                !list_empty(&(map)->i_mmap_shared))
69120 -
69121 -extern void __flush_dcache_page(struct page *);
69122 -
69123 -static inline void flush_dcache_page(struct page *page)
69124 -{
69125 -       if (page->mapping && !mapping_mapped(page->mapping))
69126 -               set_bit(PG_dcache_dirty, &page->flags);
69127 -       else
69128 -               __flush_dcache_page(page);
69129 -}
69130 -
69131 -#define flush_icache_user_range(vma,page,addr,len) \
69132 -       flush_dcache_page(page)
69133 -
69134 -/*
69135 - * We don't appear to need to do anything here.  In fact, if we did, we'd
69136 - * duplicate cache flushing elsewhere performed by flush_dcache_page().
69137 - */
69138 -#define flush_icache_page(vma,page)    do { } while (0)
69139 diff -Nru a/include/asm-arm/proc-armv/domain.h b/include/asm-arm/proc-armv/domain.h
69140 --- a/include/asm-arm/proc-armv/domain.h        Wed Mar 13 14:14:05 2002
69141 +++ /dev/null   Wed Dec 31 16:00:00 1969
69142 @@ -1,50 +0,0 @@
69143 -/*
69144 - *  linux/include/asm-arm/proc-armv/domain.h
69145 - *
69146 - *  Copyright (C) 1999 Russell King.
69147 - *
69148 - * This program is free software; you can redistribute it and/or modify
69149 - * it under the terms of the GNU General Public License version 2 as
69150 - * published by the Free Software Foundation.
69151 - */
69152 -#ifndef __ASM_PROC_DOMAIN_H
69153 -#define __ASM_PROC_DOMAIN_H
69154 -
69155 -/*
69156 - * Domain numbers
69157 - *
69158 - *  DOMAIN_IO     - domain 2 includes all IO only
69159 - *  DOMAIN_KERNEL - domain 1 includes all kernel memory only
69160 - *  DOMAIN_USER   - domain 0 includes all user memory only
69161 - */
69162 -#define DOMAIN_USER    0
69163 -#define DOMAIN_KERNEL  1
69164 -#define DOMAIN_TABLE   1
69165 -#define DOMAIN_IO      2
69166 -
69167 -/*
69168 - * Domain types
69169 - */
69170 -#define DOMAIN_NOACCESS        0
69171 -#define DOMAIN_CLIENT  1
69172 -#define DOMAIN_MANAGER 3
69173 -
69174 -#define domain_val(dom,type)   ((type) << 2*(dom))
69175 -
69176 -#define set_domain(x)                                  \
69177 -       do {                                            \
69178 -       __asm__ __volatile__(                           \
69179 -       "mcr    p15, 0, %0, c3, c0      @ set domain"   \
69180 -         : : "r" (x));                                 \
69181 -       } while (0)
69182 -
69183 -#define modify_domain(dom,type)                                        \
69184 -       do {                                                    \
69185 -       struct thread_info *thread = current_thread_info();     \
69186 -       unsigned int domain = thread->cpu_domain;               \
69187 -       domain &= ~domain_val(dom, DOMAIN_MANAGER);             \
69188 -       thread->cpu_domain = domain | domain_val(dom, type);    \
69189 -       set_domain(thread->cpu_domain);                         \
69190 -       } while (0)
69191 -
69192 -#endif
69193 diff -Nru a/include/asm-arm/proc-armv/elf.h b/include/asm-arm/proc-armv/elf.h
69194 --- a/include/asm-arm/proc-armv/elf.h   Sun Nov 24 15:14:23 2002
69195 +++ /dev/null   Wed Dec 31 16:00:00 1969
69196 @@ -1,30 +0,0 @@
69197 -/*
69198 - * ELF definitions for 32-bit CPUs
69199 - */
69200 -
69201 -#define ELF_EXEC_PAGESIZE      4096
69202 -
69203 -#ifdef __KERNEL__
69204 -
69205 -/*
69206 - * 32-bit code is always OK.  Some cpus can do 26-bit, some can't.
69207 - */
69208 -#define ELF_PROC_OK(x) (ELF_THUMB_OK(x) && ELF_26BIT_OK(x))
69209 -
69210 -#define ELF_THUMB_OK(x) \
69211 -       (( (elf_hwcap & HWCAP_THUMB) && ((x)->e_entry & 1) == 1) || \
69212 -        ((x)->e_entry & 3) == 0)
69213 -
69214 -#define ELF_26BIT_OK(x) \
69215 -       (( (elf_hwcap & HWCAP_26BIT) && (x)->e_flags & EF_ARM_APCS26) || \
69216 -         ((x)->e_flags & EF_ARM_APCS26) == 0)
69217 -
69218 -/* Old NetWinder binaries were compiled in such a way that the iBCS
69219 -   heuristic always trips on them.  Until these binaries become uncommon
69220 -   enough not to care, don't trust the `ibcs' flag here.  In any case
69221 -   there is no other ELF system currently supported by iBCS.
69222 -   @@ Could print a warning message to encourage users to upgrade.  */
69223 -#define SET_PERSONALITY(ex,ibcs2) \
69224 -       set_personality(((ex).e_flags&EF_ARM_APCS26 ?PER_LINUX :PER_LINUX_32BIT))
69225 -
69226 -#endif
69227 diff -Nru a/include/asm-arm/proc-armv/locks.h b/include/asm-arm/proc-armv/locks.h
69228 --- a/include/asm-arm/proc-armv/locks.h Sun Apr 27 08:39:00 2003
69229 +++ /dev/null   Wed Dec 31 16:00:00 1969
69230 @@ -1,139 +0,0 @@
69231 -/*
69232 - *  linux/include/asm-arm/proc-armv/locks.h
69233 - *
69234 - *  Copyright (C) 2000 Russell King
69235 - *
69236 - * This program is free software; you can redistribute it and/or modify
69237 - * it under the terms of the GNU General Public License version 2 as
69238 - * published by the Free Software Foundation.
69239 - *
69240 - *  Interrupt safe locking assembler. 
69241 - */
69242 -#ifndef __ASM_PROC_LOCKS_H
69243 -#define __ASM_PROC_LOCKS_H
69244 -
69245 -#define __down_op(ptr,fail)                    \
69246 -       ({                                      \
69247 -       __asm__ __volatile__(                   \
69248 -       "@ down_op\n"                           \
69249 -"      mrs     ip, cpsr\n"                     \
69250 -"      orr     lr, ip, #128\n"                 \
69251 -"      msr     cpsr_c, lr\n"                   \
69252 -"      ldr     lr, [%0]\n"                     \
69253 -"      subs    lr, lr, %1\n"                   \
69254 -"      str     lr, [%0]\n"                     \
69255 -"      msr     cpsr_c, ip\n"                   \
69256 -"      movmi   ip, %0\n"                       \
69257 -"      blmi    " #fail                         \
69258 -       :                                       \
69259 -       : "r" (ptr), "I" (1)                    \
69260 -       : "ip", "lr", "cc", "memory");          \
69261 -       })
69262 -
69263 -#define __down_op_ret(ptr,fail)                        \
69264 -       ({                                      \
69265 -               unsigned int ret;               \
69266 -       __asm__ __volatile__(                   \
69267 -       "@ down_op_ret\n"                       \
69268 -"      mrs     ip, cpsr\n"                     \
69269 -"      orr     lr, ip, #128\n"                 \
69270 -"      msr     cpsr_c, lr\n"                   \
69271 -"      ldr     lr, [%1]\n"                     \
69272 -"      subs    lr, lr, %2\n"                   \
69273 -"      str     lr, [%1]\n"                     \
69274 -"      msr     cpsr_c, ip\n"                   \
69275 -"      movmi   ip, %1\n"                       \
69276 -"      movpl   ip, #0\n"                       \
69277 -"      blmi    " #fail "\n"                    \
69278 -"      mov     %0, ip"                         \
69279 -       : "=&r" (ret)                           \
69280 -       : "r" (ptr), "I" (1)                    \
69281 -       : "ip", "lr", "cc", "memory");          \
69282 -       ret;                                    \
69283 -       })
69284 -
69285 -#define __up_op(ptr,wake)                      \
69286 -       ({                                      \
69287 -       __asm__ __volatile__(                   \
69288 -       "@ up_op\n"                             \
69289 -"      mrs     ip, cpsr\n"                     \
69290 -"      orr     lr, ip, #128\n"                 \
69291 -"      msr     cpsr_c, lr\n"                   \
69292 -"      ldr     lr, [%0]\n"                     \
69293 -"      adds    lr, lr, %1\n"                   \
69294 -"      str     lr, [%0]\n"                     \
69295 -"      msr     cpsr_c, ip\n"                   \
69296 -"      movle   ip, %0\n"                       \
69297 -"      blle    " #wake                         \
69298 -       :                                       \
69299 -       : "r" (ptr), "I" (1)                    \
69300 -       : "ip", "lr", "cc", "memory");          \
69301 -       })
69302 -
69303 -/*
69304 - * The value 0x01000000 supports up to 128 processors and
69305 - * lots of processes.  BIAS must be chosen such that sub'ing
69306 - * BIAS once per CPU will result in the long remaining
69307 - * negative.
69308 - */
69309 -#define RW_LOCK_BIAS      0x01000000
69310 -#define RW_LOCK_BIAS_STR "0x01000000"
69311 -
69312 -#define __down_op_write(ptr,fail)              \
69313 -       ({                                      \
69314 -       __asm__ __volatile__(                   \
69315 -       "@ down_op_write\n"                     \
69316 -"      mrs     ip, cpsr\n"                     \
69317 -"      orr     lr, ip, #128\n"                 \
69318 -"      msr     cpsr_c, lr\n"                   \
69319 -"      ldr     lr, [%0]\n"                     \
69320 -"      subs    lr, lr, %1\n"                   \
69321 -"      str     lr, [%0]\n"                     \
69322 -"      msr     cpsr_c, ip\n"                   \
69323 -"      movne   ip, %0\n"                       \
69324 -"      blne    " #fail                         \
69325 -       :                                       \
69326 -       : "r" (ptr), "I" (RW_LOCK_BIAS)         \
69327 -       : "ip", "lr", "cc", "memory");          \
69328 -       })
69329 -
69330 -#define __up_op_write(ptr,wake)                        \
69331 -       ({                                      \
69332 -       __asm__ __volatile__(                   \
69333 -       "@ up_op_read\n"                        \
69334 -"      mrs     ip, cpsr\n"                     \
69335 -"      orr     lr, ip, #128\n"                 \
69336 -"      msr     cpsr_c, lr\n"                   \
69337 -"      ldr     lr, [%0]\n"                     \
69338 -"      adds    lr, lr, %1\n"                   \
69339 -"      str     lr, [%0]\n"                     \
69340 -"      msr     cpsr_c, ip\n"                   \
69341 -"      movcs   ip, %0\n"                       \
69342 -"      blcs    " #wake                         \
69343 -       :                                       \
69344 -       : "r" (ptr), "I" (RW_LOCK_BIAS)         \
69345 -       : "ip", "lr", "cc", "memory");          \
69346 -       })
69347 -
69348 -#define __down_op_read(ptr,fail)               \
69349 -       __down_op(ptr, fail)
69350 -
69351 -#define __up_op_read(ptr,wake)                 \
69352 -       ({                                      \
69353 -       __asm__ __volatile__(                   \
69354 -       "@ up_op_read\n"                        \
69355 -"      mrs     ip, cpsr\n"                     \
69356 -"      orr     lr, ip, #128\n"                 \
69357 -"      msr     cpsr_c, lr\n"                   \
69358 -"      ldr     lr, [%0]\n"                     \
69359 -"      adds    lr, lr, %1\n"                   \
69360 -"      str     lr, [%0]\n"                     \
69361 -"      msr     cpsr_c, ip\n"                   \
69362 -"      moveq   ip, %0\n"                       \
69363 -"      bleq    " #wake                         \
69364 -       :                                       \
69365 -       : "r" (ptr), "I" (1)                    \
69366 -       : "ip", "lr", "cc", "memory");          \
69367 -       })
69368 -
69369 -#endif
69370 diff -Nru a/include/asm-arm/proc-armv/page.h b/include/asm-arm/proc-armv/page.h
69371 --- a/include/asm-arm/proc-armv/page.h  Sun Mar 10 04:04:32 2002
69372 +++ /dev/null   Wed Dec 31 16:00:00 1969
69373 @@ -1,37 +0,0 @@
69374 -/*
69375 - *  linux/include/asm-arm/proc-armv/page.h
69376 - *
69377 - *  Copyright (C) 1995-2002 Russell King
69378 - *
69379 - * This program is free software; you can redistribute it and/or modify
69380 - * it under the terms of the GNU General Public License version 2 as
69381 - * published by the Free Software Foundation.
69382 - */
69383 -#ifndef __ASM_PROC_PAGE_H
69384 -#define __ASM_PROC_PAGE_H
69385 -
69386 -/* PAGE_SHIFT determines the page size */
69387 -#define PAGE_SHIFT     12
69388 -
69389 -#define EXEC_PAGESIZE   4096
69390 -
69391 -#ifndef __ASSEMBLY__
69392 -#ifdef STRICT_MM_TYPECHECKS
69393 -
69394 -typedef struct {
69395 -       unsigned long pgd0;
69396 -       unsigned long pgd1;
69397 -} pgd_t;
69398 -
69399 -#define pgd_val(x)     ((x).pgd0)
69400 -
69401 -#else
69402 -
69403 -typedef unsigned long pgd_t[2];
69404 -
69405 -#define pgd_val(x)     ((x)[0])
69406 -
69407 -#endif
69408 -#endif /* __ASSEMBLY__ */
69409 -
69410 -#endif /* __ASM_PROC_PAGE_H */
69411 diff -Nru a/include/asm-arm/proc-armv/pgalloc.h b/include/asm-arm/proc-armv/pgalloc.h
69412 --- a/include/asm-arm/proc-armv/pgalloc.h       Sun Apr 27 09:49:44 2003
69413 +++ /dev/null   Wed Dec 31 16:00:00 1969
69414 @@ -1,110 +0,0 @@
69415 -/*
69416 - *  linux/include/asm-arm/proc-armv/pgalloc.h
69417 - *
69418 - *  Copyright (C) 2001-2002 Russell King
69419 - *
69420 - * Page table allocation/freeing primitives for 32-bit ARM processors.
69421 - */
69422 -#include <asm/cacheflush.h>
69423 -#include <asm/tlbflush.h>
69424 -#include "pgtable.h"
69425 -
69426 -/*
69427 - * Allocate one PTE table.
69428 - *
69429 - * This actually allocates two hardware PTE tables, but we wrap this up
69430 - * into one table thus:
69431 - *
69432 - *  +------------+
69433 - *  |  h/w pt 0  |
69434 - *  +------------+
69435 - *  |  h/w pt 1  |
69436 - *  +------------+
69437 - *  | Linux pt 0 |
69438 - *  +------------+
69439 - *  | Linux pt 1 |
69440 - *  +------------+
69441 - */
69442 -static inline pte_t *
69443 -pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
69444 -{
69445 -       pte_t *pte;
69446 -
69447 -       pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
69448 -       if (pte) {
69449 -               clear_page(pte);
69450 -               clean_dcache_area(pte, sizeof(pte_t) * PTRS_PER_PTE);
69451 -               pte += PTRS_PER_PTE;
69452 -       }
69453 -
69454 -       return pte;
69455 -}
69456 -
69457 -static inline struct page *
69458 -pte_alloc_one(struct mm_struct *mm, unsigned long addr)
69459 -{
69460 -       struct page *pte;
69461 -
69462 -       pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
69463 -       if (pte) {
69464 -               void *page = page_address(pte);
69465 -               clear_page(page);
69466 -               clean_dcache_area(page, sizeof(pte_t) * PTRS_PER_PTE);
69467 -       }
69468 -
69469 -       return pte;
69470 -}
69471 -
69472 -/*
69473 - * Free one PTE table.
69474 - */
69475 -static inline void pte_free_kernel(pte_t *pte)
69476 -{
69477 -       if (pte) {
69478 -               pte -= PTRS_PER_PTE;
69479 -               free_page((unsigned long)pte);
69480 -       }
69481 -}
69482 -
69483 -static inline void pte_free(struct page *pte)
69484 -{
69485 -       __free_page(pte);
69486 -}
69487 -
69488 -/*
69489 - * Populate the pmdp entry with a pointer to the pte.  This pmd is part
69490 - * of the mm address space.
69491 - *
69492 - * Ensure that we always set both PMD entries.
69493 - */
69494 -static inline void
69495 -pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
69496 -{
69497 -       unsigned long pte_ptr = (unsigned long)ptep;
69498 -       unsigned long pmdval;
69499 -
69500 -       BUG_ON(mm != &init_mm);
69501 -
69502 -       /*
69503 -        * The pmd must be loaded with the physical
69504 -        * address of the PTE table
69505 -        */
69506 -       pte_ptr -= PTRS_PER_PTE * sizeof(void *);
69507 -       pmdval = __pa(pte_ptr) | _PAGE_KERNEL_TABLE;
69508 -       pmdp[0] = __pmd(pmdval);
69509 -       pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t));
69510 -       flush_pmd_entry(pmdp);
69511 -}
69512 -
69513 -static inline void
69514 -pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep)
69515 -{
69516 -       unsigned long pmdval;
69517 -
69518 -       BUG_ON(mm == &init_mm);
69519 -
69520 -       pmdval = page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE;
69521 -       pmdp[0] = __pmd(pmdval);
69522 -       pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t));
69523 -       flush_pmd_entry(pmdp);
69524 -}
69525 diff -Nru a/include/asm-arm/proc-armv/pgtable.h b/include/asm-arm/proc-armv/pgtable.h
69526 --- a/include/asm-arm/proc-armv/pgtable.h       Thu Aug 14 07:38:28 2003
69527 +++ /dev/null   Wed Dec 31 16:00:00 1969
69528 @@ -1,217 +0,0 @@
69529 -/*
69530 - *  linux/include/asm-arm/proc-armv/pgtable.h
69531 - *
69532 - *  Copyright (C) 1995-2002 Russell King
69533 - *
69534 - * This program is free software; you can redistribute it and/or modify
69535 - * it under the terms of the GNU General Public License version 2 as
69536 - * published by the Free Software Foundation.
69537 - *
69538 - *  12-Jan-1997        RMK     Altered flushing routines to use function pointers
69539 - *                     now possible to combine ARM6, ARM7 and StrongARM versions.
69540 - *  17-Apr-1999        RMK     Now pass an area size to clean_cache_area and
69541 - *                     flush_icache_area.
69542 - */
69543 -#ifndef __ASM_PROC_PGTABLE_H
69544 -#define __ASM_PROC_PGTABLE_H
69545 -
69546 -/*
69547 - * We pull a couple of tricks here:
69548 - *  1. We wrap the PMD into the PGD.
69549 - *  2. We lie about the size of the PTE and PGD.
69550 - * Even though we have 256 PTE entries and 4096 PGD entries, we tell
69551 - * Linux that we actually have 512 PTE entries and 2048 PGD entries.
69552 - * Each "Linux" PGD entry is made up of two hardware PGD entries, and
69553 - * each PTE table is actually two hardware PTE tables.
69554 - */
69555 -#define PTRS_PER_PTE           512
69556 -#define PTRS_PER_PMD           1
69557 -#define PTRS_PER_PGD           2048
69558 -
69559 -/*
69560 - * Hardware page table definitions.
69561 - *
69562 - * + Level 1 descriptor (PMD)
69563 - *   - common
69564 - */
69565 -#define PMD_TYPE_MASK          (3 << 0)
69566 -#define PMD_TYPE_FAULT         (0 << 0)
69567 -#define PMD_TYPE_TABLE         (1 << 0)
69568 -#define PMD_TYPE_SECT          (2 << 0)
69569 -#define PMD_BIT4               (1 << 4)
69570 -#define PMD_DOMAIN(x)          ((x) << 5)
69571 -#define PMD_PROTECTION         (1 << 9)        /* v5 */
69572 -/*
69573 - *   - section
69574 - */
69575 -#define PMD_SECT_BUFFERABLE    (1 << 2)
69576 -#define PMD_SECT_CACHEABLE     (1 << 3)
69577 -#define PMD_SECT_AP_WRITE      (1 << 10)
69578 -#define PMD_SECT_AP_READ       (1 << 11)
69579 -#define PMD_SECT_TEX(x)                ((x) << 12)     /* v5 */
69580 -#define PMD_SECT_APX           (1 << 15)       /* v6 */
69581 -#define PMD_SECT_S             (1 << 16)       /* v6 */
69582 -#define PMD_SECT_nG            (1 << 17)       /* v6 */
69583 -
69584 -#define PMD_SECT_UNCACHED      (0)
69585 -#define PMD_SECT_BUFFERED      (PMD_SECT_BUFFERABLE)
69586 -#define PMD_SECT_WT            (PMD_SECT_CACHEABLE)
69587 -#define PMD_SECT_WB            (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE)
69588 -#define PMD_SECT_MINICACHE     (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE)
69589 -#define PMD_SECT_WBWA          (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE)
69590 -
69591 -/*
69592 - *   - coarse table (not used)
69593 - */
69594 -
69595 -/*
69596 - * + Level 2 descriptor (PTE)
69597 - *   - common
69598 - */
69599 -#define PTE_TYPE_MASK          (3 << 0)
69600 -#define PTE_TYPE_FAULT         (0 << 0)
69601 -#define PTE_TYPE_LARGE         (1 << 0)
69602 -#define PTE_TYPE_SMALL         (2 << 0)
69603 -#define PTE_TYPE_EXT           (3 << 0)        /* v5 */
69604 -#define PTE_BUFFERABLE         (1 << 2)
69605 -#define PTE_CACHEABLE          (1 << 3)
69606 -
69607 -/*
69608 - *   - extended small page/tiny page
69609 - */
69610 -#define PTE_EXT_AP_UNO_SRO     (0 << 4)
69611 -#define PTE_EXT_AP_UNO_SRW     (1 << 4)
69612 -#define PTE_EXT_AP_URO_SRW     (2 << 4)
69613 -#define PTE_EXT_AP_URW_SRW     (3 << 4)
69614 -#define PTE_EXT_TEX(x)         ((x) << 6)      /* v5 */
69615 -
69616 -/*
69617 - *   - small page
69618 - */
69619 -#define PTE_SMALL_AP_UNO_SRO   (0x00 << 4)
69620 -#define PTE_SMALL_AP_UNO_SRW   (0x55 << 4)
69621 -#define PTE_SMALL_AP_URO_SRW   (0xaa << 4)
69622 -#define PTE_SMALL_AP_URW_SRW   (0xff << 4)
69623 -#define PTE_AP_READ            PTE_SMALL_AP_URO_SRW
69624 -#define PTE_AP_WRITE           PTE_SMALL_AP_UNO_SRW
69625 -
69626 -/*
69627 - * "Linux" PTE definitions.
69628 - *
69629 - * We keep two sets of PTEs - the hardware and the linux version.
69630 - * This allows greater flexibility in the way we map the Linux bits
69631 - * onto the hardware tables, and allows us to have YOUNG and DIRTY
69632 - * bits.
69633 - *
69634 - * The PTE table pointer refers to the hardware entries; the "Linux"
69635 - * entries are stored 1024 bytes below.
69636 - */
69637 -#define L_PTE_PRESENT          (1 << 0)
69638 -#define L_PTE_FILE             (1 << 1)        /* only when !PRESENT */
69639 -#define L_PTE_YOUNG            (1 << 1)
69640 -#define L_PTE_BUFFERABLE       (1 << 2)        /* matches PTE */
69641 -#define L_PTE_CACHEABLE                (1 << 3)        /* matches PTE */
69642 -#define L_PTE_USER             (1 << 4)
69643 -#define L_PTE_WRITE            (1 << 5)
69644 -#define L_PTE_EXEC             (1 << 6)
69645 -#define L_PTE_DIRTY            (1 << 7)
69646 -
69647 -#ifndef __ASSEMBLY__
69648 -
69649 -#include <asm/proc/domain.h>
69650 -
69651 -#define _PAGE_USER_TABLE       (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_USER))
69652 -#define _PAGE_KERNEL_TABLE     (PMD_TYPE_TABLE | PMD_BIT4 | PMD_DOMAIN(DOMAIN_KERNEL))
69653 -
69654 -#define pmd_bad(pmd)           (pmd_val(pmd) & 2)
69655 -
69656 -#define set_pmd(pmdp,pmd)              \
69657 -       do {                            \
69658 -               *pmdp = pmd;            \
69659 -               flush_pmd_entry(pmdp);  \
69660 -       } while (0)
69661 -
69662 -#define pmd_clear(pmdp)                        \
69663 -       do {                            \
69664 -               pmdp[0] = __pmd(0);     \
69665 -               pmdp[1] = __pmd(0);     \
69666 -               clean_pmd_entry(pmdp);  \
69667 -       } while (0)
69668 -
69669 -static inline pte_t *pmd_page_kernel(pmd_t pmd)
69670 -{
69671 -       unsigned long ptr;
69672 -
69673 -       ptr = pmd_val(pmd) & ~(PTRS_PER_PTE * sizeof(void *) - 1);
69674 -       ptr += PTRS_PER_PTE * sizeof(void *);
69675 -
69676 -       return __va(ptr);
69677 -}
69678 -
69679 -#define pmd_page(pmd) virt_to_page(__va(pmd_val(pmd)))
69680 -
69681 -#define pte_offset_kernel(dir,addr)    (pmd_page_kernel(*(dir)) + __pte_index(addr))
69682 -#define pte_offset_map(dir,addr)       (pmd_page_kernel(*(dir)) + __pte_index(addr))
69683 -#define pte_offset_map_nested(dir,addr)        (pmd_page_kernel(*(dir)) + __pte_index(addr))
69684 -#define pte_unmap(pte)                 do { } while (0)
69685 -#define pte_unmap_nested(pte)          do { } while (0)
69686 -
69687 -#define set_pte(ptep, pte)     cpu_set_pte(ptep,pte)
69688 -
69689 -/*
69690 - * The following macros handle the cache and bufferable bits...
69691 - */
69692 -#define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
69693 -#define _L_PTE_READ    L_PTE_USER | L_PTE_EXEC | L_PTE_CACHEABLE | L_PTE_BUFFERABLE
69694 -
69695 -#define PAGE_NONE       __pgprot(_L_PTE_DEFAULT)
69696 -#define PAGE_COPY       __pgprot(_L_PTE_DEFAULT | _L_PTE_READ)
69697 -#define PAGE_SHARED     __pgprot(_L_PTE_DEFAULT | _L_PTE_READ | L_PTE_WRITE)
69698 -#define PAGE_READONLY   __pgprot(_L_PTE_DEFAULT | _L_PTE_READ)
69699 -#define PAGE_KERNEL     __pgprot(_L_PTE_DEFAULT | L_PTE_CACHEABLE | L_PTE_BUFFERABLE | L_PTE_DIRTY | L_PTE_WRITE | L_PTE_EXEC)
69700 -
69701 -#define _PAGE_CHG_MASK (PAGE_MASK | L_PTE_DIRTY | L_PTE_YOUNG)
69702 -
69703 -
69704 -/*
69705 - * The following only work if pte_present() is true.
69706 - * Undefined behaviour if not..
69707 - */
69708 -#define pte_present(pte)               (pte_val(pte) & L_PTE_PRESENT)
69709 -#define pte_read(pte)                  (pte_val(pte) & L_PTE_USER)
69710 -#define pte_write(pte)                 (pte_val(pte) & L_PTE_WRITE)
69711 -#define pte_exec(pte)                  (pte_val(pte) & L_PTE_EXEC)
69712 -#define pte_dirty(pte)                 (pte_val(pte) & L_PTE_DIRTY)
69713 -#define pte_young(pte)                 (pte_val(pte) & L_PTE_YOUNG)
69714 -#define pte_file(pte)                  (pte_val(pte) & L_PTE_FILE)
69715 -
69716 -#define PTE_BIT_FUNC(fn,op)                    \
69717 -static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; }
69718 -
69719 -/*PTE_BIT_FUNC(rdprotect, &= ~L_PTE_USER);*/
69720 -/*PTE_BIT_FUNC(mkread,    |= L_PTE_USER);*/
69721 -PTE_BIT_FUNC(wrprotect, &= ~L_PTE_WRITE);
69722 -PTE_BIT_FUNC(mkwrite,   |= L_PTE_WRITE);
69723 -PTE_BIT_FUNC(exprotect, &= ~L_PTE_EXEC);
69724 -PTE_BIT_FUNC(mkexec,    |= L_PTE_EXEC);
69725 -PTE_BIT_FUNC(mkclean,   &= ~L_PTE_DIRTY);
69726 -PTE_BIT_FUNC(mkdirty,   |= L_PTE_DIRTY);
69727 -PTE_BIT_FUNC(mkold,     &= ~L_PTE_YOUNG);
69728 -PTE_BIT_FUNC(mkyoung,   |= L_PTE_YOUNG);
69729 -
69730 -/*
69731 - * Mark the prot value as uncacheable and unbufferable.
69732 - */
69733 -#define pgprot_noncached(prot) __pgprot(pgprot_val(prot) & ~(L_PTE_CACHEABLE | L_PTE_BUFFERABLE))
69734 -#define pgprot_writecombine(prot) __pgprot(pgprot_val(prot) & ~L_PTE_CACHEABLE)
69735 -
69736 -#define pgtable_cache_init() do { } while (0)
69737 -
69738 -#define pte_to_pgoff(x)        (pte_val(x) >> 2)
69739 -#define pgoff_to_pte(x)        __pte(((x) << 2) | L_PTE_FILE)
69740 -
69741 -#define PTE_FILE_MAX_BITS      30
69742 -
69743 -#endif /* __ASSEMBLY__ */
69744 -
69745 -#endif /* __ASM_PROC_PGTABLE_H */
69746 diff -Nru a/include/asm-arm/proc-armv/processor.h b/include/asm-arm/proc-armv/processor.h
69747 --- a/include/asm-arm/proc-armv/processor.h     Thu Feb  6 11:28:42 2003
69748 +++ /dev/null   Wed Dec 31 16:00:00 1969
69749 @@ -1,51 +0,0 @@
69750 -/*
69751 - *  linux/include/asm-arm/proc-armv/processor.h
69752 - *
69753 - *  Copyright (C) 1996-1999 Russell King.
69754 - *
69755 - * This program is free software; you can redistribute it and/or modify
69756 - * it under the terms of the GNU General Public License version 2 as
69757 - * published by the Free Software Foundation.
69758 - *
69759 - *  Changelog:
69760 - *   20-09-1996        RMK     Created
69761 - *   26-09-1996        RMK     Added 'EXTRA_THREAD_STRUCT*'
69762 - *   28-09-1996        RMK     Moved start_thread into the processor dependencies
69763 - *   09-09-1998        PJB     Delete redundant `wp_works_ok'
69764 - *   30-05-1999        PJB     Save sl across context switches
69765 - *   31-07-1999        RMK     Added 'domain' stuff
69766 - */
69767 -#ifndef __ASM_PROC_PROCESSOR_H
69768 -#define __ASM_PROC_PROCESSOR_H
69769 -
69770 -#include <asm/proc/domain.h>
69771 -
69772 -#define KERNEL_STACK_SIZE      PAGE_SIZE
69773 -
69774 -#define INIT_EXTRA_THREAD_INFO                                         \
69775 -       .cpu_domain     = domain_val(DOMAIN_USER, DOMAIN_MANAGER) |     \
69776 -                         domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) |   \
69777 -                         domain_val(DOMAIN_IO, DOMAIN_CLIENT)
69778 -
69779 -#define start_thread(regs,pc,sp)                                       \
69780 -({                                                                     \
69781 -       unsigned long *stack = (unsigned long *)sp;                     \
69782 -       set_fs(USER_DS);                                                \
69783 -       memzero(regs->uregs, sizeof(regs->uregs));                      \
69784 -       if (current->personality & ADDR_LIMIT_32BIT)                    \
69785 -               regs->ARM_cpsr = USR_MODE;                              \
69786 -       else                                                            \
69787 -               regs->ARM_cpsr = USR26_MODE;                            \
69788 -       if (elf_hwcap & HWCAP_THUMB && pc & 1)                          \
69789 -               regs->ARM_cpsr |= PSR_T_BIT;                            \
69790 -       regs->ARM_pc = pc & ~1;         /* pc */                        \
69791 -       regs->ARM_sp = sp;              /* sp */                        \
69792 -       regs->ARM_r2 = stack[2];        /* r2 (envp) */                 \
69793 -       regs->ARM_r1 = stack[1];        /* r1 (argv) */                 \
69794 -       regs->ARM_r0 = stack[0];        /* r0 (argc) */                 \
69795 -})
69796 -
69797 -#define KSTK_EIP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1019])
69798 -#define KSTK_ESP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1017])
69799 -
69800 -#endif
69801 diff -Nru a/include/asm-arm/proc-armv/ptrace.h b/include/asm-arm/proc-armv/ptrace.h
69802 --- a/include/asm-arm/proc-armv/ptrace.h        Tue Jul  9 14:02:09 2002
69803 +++ /dev/null   Wed Dec 31 16:00:00 1969
69804 @@ -1,143 +0,0 @@
69805 -/*
69806 - *  linux/include/asm-arm/proc-armv/ptrace.h
69807 - *
69808 - *  Copyright (C) 1996-1999 Russell King
69809 - *
69810 - * This program is free software; you can redistribute it and/or modify
69811 - * it under the terms of the GNU General Public License version 2 as
69812 - * published by the Free Software Foundation.
69813 - */
69814 -#ifndef __ASM_PROC_PTRACE_H
69815 -#define __ASM_PROC_PTRACE_H
69816 -
69817 -#include <linux/config.h>
69818 -
69819 -/*
69820 - * PSR bits
69821 - */
69822 -#define USR26_MODE     0x00000000
69823 -#define FIQ26_MODE     0x00000001
69824 -#define IRQ26_MODE     0x00000002
69825 -#define SVC26_MODE     0x00000003
69826 -#define USR_MODE       0x00000010
69827 -#define FIQ_MODE       0x00000011
69828 -#define IRQ_MODE       0x00000012
69829 -#define SVC_MODE       0x00000013
69830 -#define ABT_MODE       0x00000017
69831 -#define UND_MODE       0x0000001b
69832 -#define SYSTEM_MODE    0x0000001f
69833 -#define MODE32_BIT     0x00000010
69834 -#define MODE_MASK      0x0000001f
69835 -#define PSR_T_BIT      0x00000020
69836 -#define PSR_F_BIT      0x00000040
69837 -#define PSR_I_BIT      0x00000080
69838 -#define PSR_J_BIT      0x01000000
69839 -#define PSR_Q_BIT      0x08000000
69840 -#define PSR_V_BIT      0x10000000
69841 -#define PSR_C_BIT      0x20000000
69842 -#define PSR_Z_BIT      0x40000000
69843 -#define PSR_N_BIT      0x80000000
69844 -#define PCMASK         0
69845 -
69846 -/*
69847 - * Groups of PSR bits
69848 - */
69849 -#define PSR_f          0xff000000      /* Flags                */
69850 -#define PSR_s          0x00ff0000      /* Status               */
69851 -#define PSR_x          0x0000ff00      /* Extension            */
69852 -#define PSR_c          0x000000ff      /* Control              */
69853 -
69854 -/*
69855 - * CR1 bits
69856 - */
69857 -#define CR1_M          0x00000001      /* MMU                  */
69858 -#define CR1_A          0x00000002      /* Alignment fault      */
69859 -#define CR1_C          0x00000004      /* Dcache               */
69860 -#define CR1_W          0x00000008      /* Write buffer         */
69861 -#define CR1_P          0x00000010      /* Prog32               */
69862 -#define CR1_D          0x00000020      /* Data32               */
69863 -#define CR1_L          0x00000040      /* Late abort           */
69864 -#define CR1_B          0x00000080      /* Big endian           */
69865 -#define CR1_S          0x00000100      /* System protection    */
69866 -#define CR1_R          0x00000200      /* ROM protection       */
69867 -#define CR1_F          0x00000400
69868 -#define CR1_Z          0x00000800      /* BTB enable           */
69869 -#define CR1_I          0x00001000      /* Icache               */
69870 -#define CR1_V          0x00002000      /* Vector relocation    */
69871 -#define CR1_RR         0x00004000      /* Round Robin          */
69872 -
69873 -#ifndef __ASSEMBLY__
69874 -
69875 -/* this struct defines the way the registers are stored on the
69876 -   stack during a system call. */
69877 -
69878 -struct pt_regs {
69879 -       long uregs[18];
69880 -};
69881 -
69882 -#define ARM_cpsr       uregs[16]
69883 -#define ARM_pc         uregs[15]
69884 -#define ARM_lr         uregs[14]
69885 -#define ARM_sp         uregs[13]
69886 -#define ARM_ip         uregs[12]
69887 -#define ARM_fp         uregs[11]
69888 -#define ARM_r10                uregs[10]
69889 -#define ARM_r9         uregs[9]
69890 -#define ARM_r8         uregs[8]
69891 -#define ARM_r7         uregs[7]
69892 -#define ARM_r6         uregs[6]
69893 -#define ARM_r5         uregs[5]
69894 -#define ARM_r4         uregs[4]
69895 -#define ARM_r3         uregs[3]
69896 -#define ARM_r2         uregs[2]
69897 -#define ARM_r1         uregs[1]
69898 -#define ARM_r0         uregs[0]
69899 -#define ARM_ORIG_r0    uregs[17]
69900 -
69901 -#ifdef __KERNEL__
69902 -
69903 -#define user_mode(regs)        \
69904 -       (((regs)->ARM_cpsr & 0xf) == 0)
69905 -
69906 -#ifdef CONFIG_ARM_THUMB
69907 -#define thumb_mode(regs) \
69908 -       (((regs)->ARM_cpsr & PSR_T_BIT))
69909 -#else
69910 -#define thumb_mode(regs) (0)
69911 -#endif
69912 -
69913 -#define processor_mode(regs) \
69914 -       ((regs)->ARM_cpsr & MODE_MASK)
69915 -
69916 -#define interrupts_enabled(regs) \
69917 -       (!((regs)->ARM_cpsr & PSR_I_BIT))
69918 -
69919 -#define fast_interrupts_enabled(regs) \
69920 -       (!((regs)->ARM_cpsr & PSR_F_BIT))
69921 -
69922 -#define condition_codes(regs) \
69923 -       ((regs)->ARM_cpsr & (PSR_V_BIT|PSR_C_BIT|PSR_Z_BIT|PSR_N_BIT))
69924 -       
69925 -/* Are the current registers suitable for user mode?
69926 - * (used to maintain security in signal handlers)
69927 - */
69928 -static inline int valid_user_regs(struct pt_regs *regs)
69929 -{
69930 -       if (user_mode(regs) &&
69931 -           (regs->ARM_cpsr & (PSR_F_BIT|PSR_I_BIT)) == 0)
69932 -               return 1;
69933 -
69934 -       /*
69935 -        * Force CPSR to something logical...
69936 -        */
69937 -       regs->ARM_cpsr &= PSR_f | PSR_s | PSR_x | PSR_T_BIT | MODE32_BIT;
69938 -
69939 -       return 0;
69940 -}
69941 -
69942 -#endif /* __KERNEL__ */
69943 -
69944 -#endif /* __ASSEMBLY__ */
69945 -
69946 -#endif
69947 -
69948 diff -Nru a/include/asm-arm/proc-armv/shmparam.h b/include/asm-arm/proc-armv/shmparam.h
69949 --- a/include/asm-arm/proc-armv/shmparam.h      Tue Feb  5 09:39:52 2002
69950 +++ /dev/null   Wed Dec 31 16:00:00 1969
69951 @@ -1,20 +0,0 @@
69952 -/*
69953 - *  linux/include/asm-arm/proc-armv/shmparam.h
69954 - *
69955 - *  Copyright (C) 1996 Russell King
69956 - *
69957 - * This program is free software; you can redistribute it and/or modify
69958 - * it under the terms of the GNU General Public License version 2 as
69959 - * published by the Free Software Foundation.
69960 - *
69961 - *  definitions for the shared process memory on ARM v3 or v4
69962 - *  processors
69963 - */
69964 -#ifndef __ASM_PROC_SHMPARAM_H
69965 -#define __ASM_PROC_SHMPARAM_H
69966 -
69967 -#ifndef SHMMAX
69968 -#define SHMMAX         0x01000000
69969 -#endif
69970 -
69971 -#endif
69972 diff -Nru a/include/asm-arm/proc-armv/system.h b/include/asm-arm/proc-armv/system.h
69973 --- a/include/asm-arm/proc-armv/system.h        Thu Aug 14 07:38:28 2003
69974 +++ /dev/null   Wed Dec 31 16:00:00 1969
69975 @@ -1,215 +0,0 @@
69976 -/*
69977 - *  linux/include/asm-arm/proc-armv/system.h
69978 - *
69979 - *  Copyright (C) 1996 Russell King
69980 - *
69981 - * This program is free software; you can redistribute it and/or modify
69982 - * it under the terms of the GNU General Public License version 2 as
69983 - * published by the Free Software Foundation.
69984 - */
69985 -#ifndef __ASM_PROC_SYSTEM_H
69986 -#define __ASM_PROC_SYSTEM_H
69987 -
69988 -#include <linux/config.h>
69989 -
69990 -#define set_cr(x)                                      \
69991 -       __asm__ __volatile__(                           \
69992 -       "mcr    p15, 0, %0, c1, c0, 0   @ set CR"       \
69993 -       : : "r" (x) : "cc")
69994 -
69995 -#define get_cr()                                       \
69996 -       ({                                              \
69997 -       unsigned int __val;                             \
69998 -       __asm__ __volatile__(                           \
69999 -       "mrc    p15, 0, %0, c1, c0, 0   @ get CR"       \
70000 -       : "=r" (__val) : : "cc");                       \
70001 -       __val;                                          \
70002 -       })
70003 -
70004 -#define CR_M   (1 << 0)        /* MMU enable                           */
70005 -#define CR_A   (1 << 1)        /* Alignment abort enable               */
70006 -#define CR_C   (1 << 2)        /* Dcache enable                        */
70007 -#define CR_W   (1 << 3)        /* Write buffer enable                  */
70008 -#define CR_P   (1 << 4)        /* 32-bit exception handler             */
70009 -#define CR_D   (1 << 5)        /* 32-bit data address range            */
70010 -#define CR_L   (1 << 6)        /* Implementation defined               */
70011 -#define CR_B   (1 << 7)        /* Big endian                           */
70012 -#define CR_S   (1 << 8)        /* System MMU protection                */
70013 -#define CR_R   (1 << 9)        /* ROM MMU protection                   */
70014 -#define CR_F   (1 << 10)       /* Implementation defined               */
70015 -#define CR_Z   (1 << 11)       /* Implementation defined               */
70016 -#define CR_I   (1 << 12)       /* Icache enable                        */
70017 -#define CR_V   (1 << 13)       /* Vectors relocated to 0xffff0000      */
70018 -#define CR_RR  (1 << 14)       /* Round Robin cache replacement        */
70019 -#define CR_L4  (1 << 15)       /* LDR pc can set T bit                 */
70020 -#define CR_DT  (1 << 16)
70021 -#define CR_IT  (1 << 18)
70022 -#define CR_ST  (1 << 19)
70023 -#define CR_FI  (1 << 21)
70024 -#define CR_U   (1 << 22)       /* Unaligned access operation           */
70025 -#define CR_XP  (1 << 23)       /* Extended page tables                 */
70026 -#define CR_VE  (1 << 24)       /* Vectored interrupts                  */
70027 -
70028 -extern unsigned long cr_no_alignment;  /* defined in entry-armv.S */
70029 -extern unsigned long cr_alignment;     /* defined in entry-armv.S */
70030 -
70031 -#if __LINUX_ARM_ARCH__ >= 4
70032 -#define vectors_base() ((cr_alignment & CR_V) ? 0xffff0000 : 0)
70033 -#else
70034 -#define vectors_base() (0)
70035 -#endif
70036 -
70037 -/*
70038 - * Save the current interrupt enable state & disable IRQs
70039 - */
70040 -#define local_irq_save(x)                                      \
70041 -       ({                                                      \
70042 -               unsigned long temp;                             \
70043 -               (void) (&temp == &x);                           \
70044 -       __asm__ __volatile__(                                   \
70045 -       "mrs    %0, cpsr                @ local_irq_save\n"     \
70046 -"      orr     %1, %0, #128\n"                                 \
70047 -"      msr     cpsr_c, %1"                                     \
70048 -       : "=r" (x), "=r" (temp)                                 \
70049 -       :                                                       \
70050 -       : "memory", "cc");                                      \
70051 -       })
70052 -       
70053 -/*
70054 - * Enable IRQs
70055 - */
70056 -#define local_irq_enable()                                     \
70057 -       ({                                                      \
70058 -               unsigned long temp;                             \
70059 -       __asm__ __volatile__(                                   \
70060 -       "mrs    %0, cpsr                @ local_irq_enable\n"   \
70061 -"      bic     %0, %0, #128\n"                                 \
70062 -"      msr     cpsr_c, %0"                                     \
70063 -       : "=r" (temp)                                           \
70064 -       :                                                       \
70065 -       : "memory", "cc");                                      \
70066 -       })
70067 -
70068 -/*
70069 - * Disable IRQs
70070 - */
70071 -#define local_irq_disable()                                    \
70072 -       ({                                                      \
70073 -               unsigned long temp;                             \
70074 -       __asm__ __volatile__(                                   \
70075 -       "mrs    %0, cpsr                @ local_irq_disable\n"  \
70076 -"      orr     %0, %0, #128\n"                                 \
70077 -"      msr     cpsr_c, %0"                                     \
70078 -       : "=r" (temp)                                           \
70079 -       :                                                       \
70080 -       : "memory", "cc");                                      \
70081 -       })
70082 -
70083 -/*
70084 - * Enable FIQs
70085 - */
70086 -#define __stf()                                                        \
70087 -       ({                                                      \
70088 -               unsigned long temp;                             \
70089 -       __asm__ __volatile__(                                   \
70090 -       "mrs    %0, cpsr                @ stf\n"                \
70091 -"      bic     %0, %0, #64\n"                                  \
70092 -"      msr     cpsr_c, %0"                                     \
70093 -       : "=r" (temp)                                           \
70094 -       :                                                       \
70095 -       : "memory", "cc");                                      \
70096 -       })
70097 -
70098 -/*
70099 - * Disable FIQs
70100 - */
70101 -#define __clf()                                                        \
70102 -       ({                                                      \
70103 -               unsigned long temp;                             \
70104 -       __asm__ __volatile__(                                   \
70105 -       "mrs    %0, cpsr                @ clf\n"                \
70106 -"      orr     %0, %0, #64\n"                                  \
70107 -"      msr     cpsr_c, %0"                                     \
70108 -       : "=r" (temp)                                           \
70109 -       :                                                       \
70110 -       : "memory", "cc");                                      \
70111 -       })
70112 -
70113 -/*
70114 - * Save the current interrupt enable state.
70115 - */
70116 -#define local_save_flags(x)                                    \
70117 -       ({                                                      \
70118 -       __asm__ __volatile__(                                   \
70119 -       "mrs    %0, cpsr                @ local_save_flags"     \
70120 -       : "=r" (x) : : "memory", "cc");                         \
70121 -       })
70122 -
70123 -/*
70124 - * restore saved IRQ & FIQ state
70125 - */
70126 -#define local_irq_restore(x)                                   \
70127 -       __asm__ __volatile__(                                   \
70128 -       "msr    cpsr_c, %0              @ local_irq_restore\n"  \
70129 -       :                                                       \
70130 -       : "r" (x)                                               \
70131 -       : "memory", "cc")
70132 -
70133 -#if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
70134 -/*
70135 - * On the StrongARM, "swp" is terminally broken since it bypasses the
70136 - * cache totally.  This means that the cache becomes inconsistent, and,
70137 - * since we use normal loads/stores as well, this is really bad.
70138 - * Typically, this causes oopsen in filp_close, but could have other,
70139 - * more disasterous effects.  There are two work-arounds:
70140 - *  1. Disable interrupts and emulate the atomic swap
70141 - *  2. Clean the cache, perform atomic swap, flush the cache
70142 - *
70143 - * We choose (1) since its the "easiest" to achieve here and is not
70144 - * dependent on the processor type.
70145 - */
70146 -#define swp_is_buggy
70147 -#endif
70148 -
70149 -static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
70150 -{
70151 -       extern void __bad_xchg(volatile void *, int);
70152 -       unsigned long ret;
70153 -#ifdef swp_is_buggy
70154 -       unsigned long flags;
70155 -#endif
70156 -
70157 -       switch (size) {
70158 -#ifdef swp_is_buggy
70159 -               case 1:
70160 -                       local_irq_save(flags);
70161 -                       ret = *(volatile unsigned char *)ptr;
70162 -                       *(volatile unsigned char *)ptr = x;
70163 -                       local_irq_restore(flags);
70164 -                       break;
70165 -
70166 -               case 4:
70167 -                       local_irq_save(flags);
70168 -                       ret = *(volatile unsigned long *)ptr;
70169 -                       *(volatile unsigned long *)ptr = x;
70170 -                       local_irq_restore(flags);
70171 -                       break;
70172 -#else
70173 -               case 1: __asm__ __volatile__ ("swpb %0, %1, [%2]"
70174 -                                       : "=&r" (ret)
70175 -                                       : "r" (x), "r" (ptr)
70176 -                                       : "memory", "cc");
70177 -                       break;
70178 -               case 4: __asm__ __volatile__ ("swp %0, %1, [%2]"
70179 -                                       : "=&r" (ret)
70180 -                                       : "r" (x), "r" (ptr)
70181 -                                       : "memory", "cc");
70182 -                       break;
70183 -#endif
70184 -               default: __bad_xchg(ptr, size), ret = 0;
70185 -       }
70186 -
70187 -       return ret;
70188 -}
70189 -
70190 -#endif
70191 diff -Nru a/include/asm-arm/proc-armv/tlbflush.h b/include/asm-arm/proc-armv/tlbflush.h
70192 --- a/include/asm-arm/proc-armv/tlbflush.h      Thu Aug 14 07:54:08 2003
70193 +++ /dev/null   Wed Dec 31 16:00:00 1969
70194 @@ -1,410 +0,0 @@
70195 -/*
70196 - *  linux/include/asm-arm/proc-armv/tlbflush.h
70197 - *
70198 - *  Copyright (C) 1999-2003 Russell King
70199 - *
70200 - * This program is free software; you can redistribute it and/or modify
70201 - * it under the terms of the GNU General Public License version 2 as
70202 - * published by the Free Software Foundation.
70203 - */
70204 -#include <linux/config.h>
70205 -#include <asm/glue.h>
70206 -
70207 -#define TLB_V3_PAGE    (1 << 0)
70208 -#define TLB_V4_U_PAGE  (1 << 1)
70209 -#define TLB_V4_D_PAGE  (1 << 2)
70210 -#define TLB_V4_I_PAGE  (1 << 3)
70211 -#define TLB_V6_U_PAGE  (1 << 4)
70212 -#define TLB_V6_D_PAGE  (1 << 5)
70213 -#define TLB_V6_I_PAGE  (1 << 6)
70214 -
70215 -#define TLB_V3_FULL    (1 << 8)
70216 -#define TLB_V4_U_FULL  (1 << 9)
70217 -#define TLB_V4_D_FULL  (1 << 10)
70218 -#define TLB_V4_I_FULL  (1 << 11)
70219 -#define TLB_V6_U_FULL  (1 << 12)
70220 -#define TLB_V6_D_FULL  (1 << 13)
70221 -#define TLB_V6_I_FULL  (1 << 14)
70222 -
70223 -#define TLB_V6_U_ASID  (1 << 16)
70224 -#define TLB_V6_D_ASID  (1 << 17)
70225 -#define TLB_V6_I_ASID  (1 << 18)
70226 -
70227 -#define TLB_DCLEAN     (1 << 30)
70228 -#define TLB_WB         (1 << 31)
70229 -
70230 -/*
70231 - *     MMU TLB Model
70232 - *     =============
70233 - *
70234 - *     We have the following to choose from:
70235 - *       v3    - ARMv3
70236 - *       v4    - ARMv4 without write buffer
70237 - *       v4wb  - ARMv4 with write buffer without I TLB flush entry instruction
70238 - *       v4wbi - ARMv4 with write buffer with I TLB flush entry instruction
70239 - *       v6wbi - ARMv6 with write buffer with I TLB flush entry instruction
70240 - */
70241 -#undef _TLB
70242 -#undef MULTI_TLB
70243 -
70244 -#define v3_tlb_flags   (TLB_V3_FULL | TLB_V3_PAGE)
70245 -
70246 -#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
70247 -# define v3_possible_flags     v3_tlb_flags
70248 -# define v3_always_flags       v3_tlb_flags
70249 -# ifdef _TLB
70250 -#  define MULTI_TLB 1
70251 -# else
70252 -#  define _TLB v3
70253 -# endif
70254 -#else
70255 -# define v3_possible_flags     0
70256 -# define v3_always_flags       (-1UL)
70257 -#endif
70258 -
70259 -#define v4_tlb_flags   (TLB_V4_U_FULL | TLB_V4_U_PAGE)
70260 -
70261 -#if defined(CONFIG_CPU_ARM720T)
70262 -# define v4_possible_flags     v4_tlb_flags
70263 -# define v4_always_flags       v4_tlb_flags
70264 -# ifdef _TLB
70265 -#  define MULTI_TLB 1
70266 -# else
70267 -#  define _TLB v4
70268 -# endif
70269 -#else
70270 -# define v4_possible_flags     0
70271 -# define v4_always_flags       (-1UL)
70272 -#endif
70273 -
70274 -#define v4wbi_tlb_flags        (TLB_WB | TLB_DCLEAN | \
70275 -                        TLB_V4_I_FULL | TLB_V4_D_FULL | \
70276 -                        TLB_V4_I_PAGE | TLB_V4_D_PAGE)
70277 -
70278 -#if defined(CONFIG_CPU_ARM920T) || defined(CONFIG_CPU_ARM922T) || \
70279 -    defined(CONFIG_CPU_ARM926T) || defined(CONFIG_CPU_ARM1020) || \
70280 -    defined(CONFIG_CPU_XSCALE)
70281 -# define v4wbi_possible_flags  v4wbi_tlb_flags
70282 -# define v4wbi_always_flags    v4wbi_tlb_flags
70283 -# ifdef _TLB
70284 -#  define MULTI_TLB 1
70285 -# else
70286 -#  define _TLB v4wbi
70287 -# endif
70288 -#else
70289 -# define v4wbi_possible_flags  0
70290 -# define v4wbi_always_flags    (-1UL)
70291 -#endif
70292 -
70293 -#define v4wb_tlb_flags (TLB_WB | TLB_DCLEAN | \
70294 -                        TLB_V4_I_FULL | TLB_V4_D_FULL | \
70295 -                        TLB_V4_D_PAGE)
70296 -
70297 -#if defined(CONFIG_CPU_SA110) || defined(CONFIG_CPU_SA1100)
70298 -# define v4wb_possible_flags   v4wb_tlb_flags
70299 -# define v4wb_always_flags     v4wb_tlb_flags
70300 -# ifdef _TLB
70301 -#  define MULTI_TLB 1
70302 -# else
70303 -#  define _TLB v4wb
70304 -# endif
70305 -#else
70306 -# define v4wb_possible_flags   0
70307 -# define v4wb_always_flags     (-1UL)
70308 -#endif
70309 -
70310 -#define v6wbi_tlb_flags (TLB_WB | TLB_DCLEAN | \
70311 -                        TLB_V6_I_FULL | TLB_V6_D_FULL | \
70312 -                        TLB_V6_I_PAGE | TLB_V6_D_PAGE | \
70313 -                        TLB_V6_I_ASID | TLB_V6_D_ASID)
70314 -
70315 -#if defined(CONFIG_CPU_V6)
70316 -# define v6wbi_possible_flags  v6wbi_tlb_flags
70317 -# define v6wbi_always_flags    v6wbi_tlb_flags
70318 -# ifdef _TLB
70319 -#  define MULTI_TLB 1
70320 -# else
70321 -#  define _TLB v6wbi
70322 -# endif
70323 -#else
70324 -# define v6wbi_possible_flags  0
70325 -# define v6wbi_always_flags    (-1UL)
70326 -#endif
70327 -
70328 -#ifndef _TLB
70329 -#error Unknown TLB model
70330 -#endif
70331 -
70332 -#ifndef __ASSEMBLY__
70333 -
70334 -struct cpu_tlb_fns {
70335 -       void (*flush_user_range)(unsigned long, unsigned long, struct vm_area_struct *);
70336 -       void (*flush_kern_range)(unsigned long, unsigned long);
70337 -       unsigned long tlb_flags;
70338 -};
70339 -
70340 -/*
70341 - * Select the calling method
70342 - */
70343 -#ifdef MULTI_TLB
70344 -
70345 -#define __cpu_flush_user_tlb_range     cpu_tlb.flush_user_range
70346 -#define __cpu_flush_kern_tlb_range     cpu_tlb.flush_kern_range
70347 -
70348 -#else
70349 -
70350 -#define __cpu_flush_user_tlb_range     __glue(_TLB,_flush_user_tlb_range)
70351 -#define __cpu_flush_kern_tlb_range     __glue(_TLB,_flush_kern_tlb_range)
70352 -
70353 -extern void __cpu_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *);
70354 -extern void __cpu_flush_kern_tlb_range(unsigned long, unsigned long);
70355 -
70356 -#endif
70357 -
70358 -extern struct cpu_tlb_fns cpu_tlb;
70359 -
70360 -#define __cpu_tlb_flags                        cpu_tlb.tlb_flags
70361 -
70362 -/*
70363 - *     TLB Management
70364 - *     ==============
70365 - *
70366 - *     The arch/arm/mm/tlb-*.S files implement these methods.
70367 - *
70368 - *     The TLB specific code is expected to perform whatever tests it
70369 - *     needs to determine if it should invalidate the TLB for each
70370 - *     call.  Start addresses are inclusive and end addresses are
70371 - *     exclusive; it is safe to round these addresses down.
70372 - *
70373 - *     flush_tlb_all()
70374 - *
70375 - *             Invalidate the entire TLB.
70376 - *
70377 - *     flush_tlb_mm(mm)
70378 - *
70379 - *             Invalidate all TLB entries in a particular address
70380 - *             space.
70381 - *             - mm    - mm_struct describing address space
70382 - *
70383 - *     flush_tlb_range(mm,start,end)
70384 - *
70385 - *             Invalidate a range of TLB entries in the specified
70386 - *             address space.
70387 - *             - mm    - mm_struct describing address space
70388 - *             - start - start address (may not be aligned)
70389 - *             - end   - end address (exclusive, may not be aligned)
70390 - *
70391 - *     flush_tlb_page(vaddr,vma)
70392 - *
70393 - *             Invalidate the specified page in the specified address range.
70394 - *             - vaddr - virtual address (may not be aligned)
70395 - *             - vma   - vma_struct describing address range
70396 - *
70397 - *     flush_kern_tlb_page(kaddr)
70398 - *
70399 - *             Invalidate the TLB entry for the specified page.  The address
70400 - *             will be in the kernels virtual memory space.  Current uses
70401 - *             only require the D-TLB to be invalidated.
70402 - *             - kaddr - Kernel virtual memory address
70403 - */
70404 -
70405 -/*
70406 - * We optimise the code below by:
70407 - *  - building a set of TLB flags that might be set in __cpu_tlb_flags
70408 - *  - building a set of TLB flags that will always be set in __cpu_tlb_flags
70409 - *  - if we're going to need __cpu_tlb_flags, access it once and only once
70410 - *
70411 - * This allows us to build optimal assembly for the single-CPU type case,
70412 - * and as close to optimal given the compiler constrants for multi-CPU
70413 - * case.  We could do better for the multi-CPU case if the compiler
70414 - * implemented the "%?" method, but this has been discontinued due to too
70415 - * many people getting it wrong.
70416 - */
70417 -#define possible_tlb_flags     (v3_possible_flags | \
70418 -                                v4_possible_flags | \
70419 -                                v4wbi_possible_flags | \
70420 -                                v4wb_possible_flags | \
70421 -                                v6wbi_possible_flags)
70422 -
70423 -#define always_tlb_flags       (v3_always_flags & \
70424 -                                v4_always_flags & \
70425 -                                v4wbi_always_flags & \
70426 -                                v4wb_always_flags & \
70427 -                                v6wbi_always_flags)
70428 -
70429 -#define tlb_flag(f)    ((always_tlb_flags & (f)) || (__tlb_flag & possible_tlb_flags & (f)))
70430 -
70431 -static inline void flush_tlb_all(void)
70432 -{
70433 -       const int zero = 0;
70434 -       const unsigned int __tlb_flag = __cpu_tlb_flags;
70435 -
70436 -       if (tlb_flag(TLB_WB))
70437 -               asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
70438 -
70439 -       if (tlb_flag(TLB_V3_FULL))
70440 -               asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (zero));
70441 -       if (tlb_flag(TLB_V4_U_FULL | TLB_V6_U_FULL))
70442 -               asm("mcr%? p15, 0, %0, c8, c7, 0" : : "r" (zero));
70443 -       if (tlb_flag(TLB_V4_D_FULL | TLB_V6_D_FULL))
70444 -               asm("mcr%? p15, 0, %0, c8, c6, 0" : : "r" (zero));
70445 -       if (tlb_flag(TLB_V4_I_FULL | TLB_V6_I_FULL))
70446 -               asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
70447 -}
70448 -
70449 -static inline void flush_tlb_mm(struct mm_struct *mm)
70450 -{
70451 -       const int zero = 0;
70452 -       const int asid = ASID(mm);
70453 -       const unsigned int __tlb_flag = __cpu_tlb_flags;
70454 -
70455 -       if (tlb_flag(TLB_WB))
70456 -               asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
70457 -
70458 -       if (mm == current->active_mm) {
70459 -               if (tlb_flag(TLB_V3_FULL))
70460 -                       asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (zero));
70461 -               if (tlb_flag(TLB_V4_U_FULL))
70462 -                       asm("mcr%? p15, 0, %0, c8, c7, 0" : : "r" (zero));
70463 -               if (tlb_flag(TLB_V4_D_FULL))
70464 -                       asm("mcr%? p15, 0, %0, c8, c6, 0" : : "r" (zero));
70465 -               if (tlb_flag(TLB_V4_I_FULL))
70466 -                       asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
70467 -       }
70468 -
70469 -       if (tlb_flag(TLB_V6_U_ASID))
70470 -               asm("mcr%? p15, 0, %0, c8, c7, 2" : : "r" (asid));
70471 -       if (tlb_flag(TLB_V6_D_ASID))
70472 -               asm("mcr%? p15, 0, %0, c8, c6, 2" : : "r" (asid));
70473 -       if (tlb_flag(TLB_V6_I_ASID))
70474 -               asm("mcr%? p15, 0, %0, c8, c5, 2" : : "r" (asid));
70475 -}
70476 -
70477 -static inline void
70478 -flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
70479 -{
70480 -       const int zero = 0;
70481 -       const unsigned int __tlb_flag = __cpu_tlb_flags;
70482 -
70483 -       uaddr = (uaddr & PAGE_MASK) | ASID(vma->vm_mm);
70484 -
70485 -       if (tlb_flag(TLB_WB))
70486 -               asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
70487 -
70488 -       if (vma->vm_mm == current->active_mm) {
70489 -               if (tlb_flag(TLB_V3_PAGE))
70490 -                       asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (uaddr));
70491 -               if (tlb_flag(TLB_V4_U_PAGE))
70492 -                       asm("mcr%? p15, 0, %0, c8, c7, 1" : : "r" (uaddr));
70493 -               if (tlb_flag(TLB_V4_D_PAGE))
70494 -                       asm("mcr%? p15, 0, %0, c8, c6, 1" : : "r" (uaddr));
70495 -               if (tlb_flag(TLB_V4_I_PAGE))
70496 -                       asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (uaddr));
70497 -               if (!tlb_flag(TLB_V4_I_PAGE) && tlb_flag(TLB_V4_I_FULL))
70498 -                       asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
70499 -       }
70500 -
70501 -       if (tlb_flag(TLB_V6_U_PAGE))
70502 -               asm("mcr%? p15, 0, %0, c8, c7, 1" : : "r" (uaddr));
70503 -       if (tlb_flag(TLB_V6_D_PAGE))
70504 -               asm("mcr%? p15, 0, %0, c8, c6, 1" : : "r" (uaddr));
70505 -       if (tlb_flag(TLB_V6_I_PAGE))
70506 -               asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (uaddr));
70507 -}
70508 -
70509 -static inline void flush_tlb_kernel_page(unsigned long kaddr)
70510 -{
70511 -       const int zero = 0;
70512 -       const unsigned int __tlb_flag = __cpu_tlb_flags;
70513 -
70514 -       kaddr &= PAGE_MASK;
70515 -
70516 -       if (tlb_flag(TLB_WB))
70517 -               asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
70518 -
70519 -       if (tlb_flag(TLB_V3_PAGE))
70520 -               asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (kaddr));
70521 -       if (tlb_flag(TLB_V4_U_PAGE))
70522 -               asm("mcr%? p15, 0, %0, c8, c7, 1" : : "r" (kaddr));
70523 -       if (tlb_flag(TLB_V4_D_PAGE))
70524 -               asm("mcr%? p15, 0, %0, c8, c6, 1" : : "r" (kaddr));
70525 -       if (tlb_flag(TLB_V4_I_PAGE))
70526 -               asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (kaddr));
70527 -       if (!tlb_flag(TLB_V4_I_PAGE) && tlb_flag(TLB_V4_I_FULL))
70528 -               asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
70529 -
70530 -       if (tlb_flag(TLB_V6_U_PAGE))
70531 -               asm("mcr%? p15, 0, %0, c8, c7, 1" : : "r" (kaddr));
70532 -       if (tlb_flag(TLB_V6_D_PAGE))
70533 -               asm("mcr%? p15, 0, %0, c8, c6, 1" : : "r" (kaddr));
70534 -       if (tlb_flag(TLB_V6_I_PAGE))
70535 -               asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (kaddr));
70536 -}
70537 -
70538 -/*
70539 - *     flush_pmd_entry
70540 - *
70541 - *     Flush a PMD entry (word aligned, or double-word aligned) to
70542 - *     RAM if the TLB for the CPU we are running on requires this.
70543 - *     This is typically used when we are creating PMD entries.
70544 - *
70545 - *     clean_pmd_entry
70546 - *
70547 - *     Clean (but don't drain the write buffer) if the CPU requires
70548 - *     these operations.  This is typically used when we are removing
70549 - *     PMD entries.
70550 - */
70551 -static inline void flush_pmd_entry(pmd_t *pmd)
70552 -{
70553 -       const unsigned int zero = 0;
70554 -       const unsigned int __tlb_flag = __cpu_tlb_flags;
70555 -
70556 -       if (tlb_flag(TLB_DCLEAN))
70557 -               asm("mcr%?      p15, 0, %0, c7, c10, 1  @ flush_pmd"
70558 -                       : : "r" (pmd));
70559 -       if (tlb_flag(TLB_WB))
70560 -               asm("mcr%?      p15, 0, %0, c7, c10, 4  @ flush_pmd"
70561 -                       : : "r" (zero));
70562 -}
70563 -
70564 -static inline void clean_pmd_entry(pmd_t *pmd)
70565 -{
70566 -       const unsigned int __tlb_flag = __cpu_tlb_flags;
70567 -
70568 -       if (tlb_flag(TLB_DCLEAN))
70569 -               asm("mcr%?      p15, 0, %0, c7, c10, 1  @ flush_pmd"
70570 -                       : : "r" (pmd));
70571 -}
70572 -
70573 -#undef tlb_flag
70574 -#undef always_tlb_flags
70575 -#undef possible_tlb_flags
70576 -
70577 -/*
70578 - * Convert calls to our calling convention.
70579 - */
70580 -#define flush_tlb_range(vma,start,end) __cpu_flush_user_tlb_range(start,end,vma)
70581 -#define flush_tlb_kernel_range(s,e)    __cpu_flush_kern_tlb_range(s,e)
70582 -
70583 -/*
70584 - * if PG_dcache_dirty is set for the page, we need to ensure that any
70585 - * cache entries for the kernels virtual memory range are written
70586 - * back to the page.
70587 - */
70588 -extern void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t pte);
70589 -
70590 -/*
70591 - * ARM processors do not cache TLB tables in RAM.
70592 - */
70593 -#define flush_tlb_pgtables(mm,start,end)       do { } while (0)
70594 -
70595 -/*
70596 - * Old ARM MEMC stuff.  This supports the reversed mapping handling that
70597 - * we have on the older 26-bit machines.  We don't have a MEMC chip, so...
70598 - */
70599 -#define memc_update_all()              do { } while (0)
70600 -#define memc_update_mm(mm)             do { } while (0)
70601 -#define memc_update_addr(mm,pte,log)   do { } while (0)
70602 -#define memc_clear(mm,physaddr)                do { } while (0)
70603 -
70604 -#endif
70605 diff -Nru a/include/asm-arm/proc-armv/uaccess.h b/include/asm-arm/proc-armv/uaccess.h
70606 --- a/include/asm-arm/proc-armv/uaccess.h       Fri Jun 13 05:07:49 2003
70607 +++ /dev/null   Wed Dec 31 16:00:00 1969
70608 @@ -1,189 +0,0 @@
70609 -/*
70610 - *  linux/include/asm-arm/proc-armv/uaccess.h
70611 - *
70612 - * This program is free software; you can redistribute it and/or modify
70613 - * it under the terms of the GNU General Public License version 2 as
70614 - * published by the Free Software Foundation.
70615 - */
70616 -#include <asm/arch/memory.h>
70617 -#include <asm/proc/domain.h>
70618 -
70619 -/*
70620 - * Note that this is actually 0x1,0000,0000
70621 - */
70622 -#define KERNEL_DS      0x00000000
70623 -#define USER_DS                TASK_SIZE
70624 -
70625 -static inline void set_fs (mm_segment_t fs)
70626 -{
70627 -       current_thread_info()->addr_limit = fs;
70628 -       modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
70629 -}
70630 -
70631 -/* We use 33-bit arithmetic here... */
70632 -#define __range_ok(addr,size) ({ \
70633 -       unsigned long flag, sum; \
70634 -       __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
70635 -               : "=&r" (flag), "=&r" (sum) \
70636 -               : "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit) \
70637 -               : "cc"); \
70638 -       flag; })
70639 -
70640 -#define __addr_ok(addr) ({ \
70641 -       unsigned long flag; \
70642 -       __asm__("cmp %2, %0; movlo %0, #0" \
70643 -               : "=&r" (flag) \
70644 -               : "0" (current_thread_info()->addr_limit), "r" (addr) \
70645 -               : "cc"); \
70646 -       (flag == 0); })
70647 -
70648 -#define __put_user_asm_byte(x,__pu_addr,err)                   \
70649 -       __asm__ __volatile__(                                   \
70650 -       "1:     strbt   %1,[%2],#0\n"                           \
70651 -       "2:\n"                                                  \
70652 -       "       .section .fixup,\"ax\"\n"                       \
70653 -       "       .align  2\n"                                    \
70654 -       "3:     mov     %0, %3\n"                               \
70655 -       "       b       2b\n"                                   \
70656 -       "       .previous\n"                                    \
70657 -       "       .section __ex_table,\"a\"\n"                    \
70658 -       "       .align  3\n"                                    \
70659 -       "       .long   1b, 3b\n"                               \
70660 -       "       .previous"                                      \
70661 -       : "+r" (err)                                            \
70662 -       : "r" (x), "r" (__pu_addr), "i" (-EFAULT)               \
70663 -       : "cc")
70664 -
70665 -#ifndef __ARMEB__
70666 -#define __put_user_asm_half(x,__pu_addr,err)                   \
70667 -({                                                             \
70668 -       unsigned long __temp = (unsigned long)(x);              \
70669 -       __put_user_asm_byte(__temp, __pu_addr, err);            \
70670 -       __put_user_asm_byte(__temp >> 8, __pu_addr + 1, err);   \
70671 -})
70672 -#else
70673 -#define __put_user_asm_half(x,__pu_addr,err)                   \
70674 -({                                                             \
70675 -       unsigned long __temp = (unsigned long)(x);              \
70676 -       __put_user_asm_byte(__temp >> 8, __pu_addr, err);       \
70677 -       __put_user_asm_byte(__temp, __pu_addr + 1, err);        \
70678 -})
70679 -#endif
70680 -
70681 -#define __put_user_asm_word(x,__pu_addr,err)                   \
70682 -       __asm__ __volatile__(                                   \
70683 -       "1:     strt    %1,[%2],#0\n"                           \
70684 -       "2:\n"                                                  \
70685 -       "       .section .fixup,\"ax\"\n"                       \
70686 -       "       .align  2\n"                                    \
70687 -       "3:     mov     %0, %3\n"                               \
70688 -       "       b       2b\n"                                   \
70689 -       "       .previous\n"                                    \
70690 -       "       .section __ex_table,\"a\"\n"                    \
70691 -       "       .align  3\n"                                    \
70692 -       "       .long   1b, 3b\n"                               \
70693 -       "       .previous"                                      \
70694 -       : "+r" (err)                                            \
70695 -       : "r" (x), "r" (__pu_addr), "i" (-EFAULT)               \
70696 -       : "cc")
70697 -
70698 -#ifndef __ARMEB__
70699 -#define        __reg_oper0     "%R2"
70700 -#define        __reg_oper1     "%Q2"
70701 -#else
70702 -#define        __reg_oper0     "%Q2"
70703 -#define        __reg_oper1     "%R2"
70704 -#endif
70705 -
70706 -#define __put_user_asm_dword(x,__pu_addr,err)                  \
70707 -       __asm__ __volatile__(                                   \
70708 -       "1:     strt    " __reg_oper1 ", [%1], #4\n"            \
70709 -       "2:     strt    " __reg_oper0 ", [%1], #0\n"            \
70710 -       "3:\n"                                                  \
70711 -       "       .section .fixup,\"ax\"\n"                       \
70712 -       "       .align  2\n"                                    \
70713 -       "4:     mov     %0, %3\n"                               \
70714 -       "       b       3b\n"                                   \
70715 -       "       .previous\n"                                    \
70716 -       "       .section __ex_table,\"a\"\n"                    \
70717 -       "       .align  3\n"                                    \
70718 -       "       .long   1b, 4b\n"                               \
70719 -       "       .long   2b, 4b\n"                               \
70720 -       "       .previous"                                      \
70721 -       : "+r" (err), "+r" (__pu_addr)                          \
70722 -       : "r" (x), "i" (-EFAULT)                                \
70723 -       : "cc")
70724 -
70725 -#define __get_user_asm_byte(x,addr,err)                                \
70726 -       __asm__ __volatile__(                                   \
70727 -       "1:     ldrbt   %1,[%2],#0\n"                           \
70728 -       "2:\n"                                                  \
70729 -       "       .section .fixup,\"ax\"\n"                       \
70730 -       "       .align  2\n"                                    \
70731 -       "3:     mov     %0, %3\n"                               \
70732 -       "       mov     %1, #0\n"                               \
70733 -       "       b       2b\n"                                   \
70734 -       "       .previous\n"                                    \
70735 -       "       .section __ex_table,\"a\"\n"                    \
70736 -       "       .align  3\n"                                    \
70737 -       "       .long   1b, 3b\n"                               \
70738 -       "       .previous"                                      \
70739 -       : "+r" (err), "=&r" (x)                                 \
70740 -       : "r" (addr), "i" (-EFAULT)                             \
70741 -       : "cc")
70742 -
70743 -#ifndef __ARMEB__
70744 -#define __get_user_asm_half(x,__gu_addr,err)                   \
70745 -({                                                             \
70746 -       unsigned long __b1, __b2;                               \
70747 -       __get_user_asm_byte(__b1, __gu_addr, err);              \
70748 -       __get_user_asm_byte(__b2, __gu_addr + 1, err);          \
70749 -       (x) = __b1 | (__b2 << 8);                               \
70750 -})
70751 -#else
70752 -#define __get_user_asm_half(x,__gu_addr,err)                   \
70753 -({                                                             \
70754 -       unsigned long __b1, __b2;                               \
70755 -       __get_user_asm_byte(__b1, __gu_addr, err);              \
70756 -       __get_user_asm_byte(__b2, __gu_addr + 1, err);          \
70757 -       (x) = (__b1 << 8) | __b2;                               \
70758 -})
70759 -#endif
70760 -
70761 -#define __get_user_asm_word(x,addr,err)                                \
70762 -       __asm__ __volatile__(                                   \
70763 -       "1:     ldrt    %1,[%2],#0\n"                           \
70764 -       "2:\n"                                                  \
70765 -       "       .section .fixup,\"ax\"\n"                       \
70766 -       "       .align  2\n"                                    \
70767 -       "3:     mov     %0, %3\n"                               \
70768 -       "       mov     %1, #0\n"                               \
70769 -       "       b       2b\n"                                   \
70770 -       "       .previous\n"                                    \
70771 -       "       .section __ex_table,\"a\"\n"                    \
70772 -       "       .align  3\n"                                    \
70773 -       "       .long   1b, 3b\n"                               \
70774 -       "       .previous"                                      \
70775 -       : "+r" (err), "=&r" (x)                                 \
70776 -       : "r" (addr), "i" (-EFAULT)                             \
70777 -       : "cc")
70778 -
70779 -extern unsigned long __arch_copy_from_user(void *to, const void *from, unsigned long n);
70780 -#define __do_copy_from_user(to,from,n)                         \
70781 -       (n) = __arch_copy_from_user(to,from,n)
70782 -
70783 -extern unsigned long __arch_copy_to_user(void *to, const void *from, unsigned long n);
70784 -#define __do_copy_to_user(to,from,n)                           \
70785 -       (n) = __arch_copy_to_user(to,from,n)
70786 -
70787 -extern unsigned long __arch_clear_user(void *addr, unsigned long n);
70788 -#define __do_clear_user(addr,sz)                               \
70789 -       (sz) = __arch_clear_user(addr,sz)
70790 -
70791 -extern unsigned long __arch_strncpy_from_user(char *to, const char *from, unsigned long count);
70792 -#define __do_strncpy_from_user(dst,src,count,res)              \
70793 -       (res) = __arch_strncpy_from_user(dst,src,count)
70794 -
70795 -extern unsigned long __arch_strnlen_user(const char *s, long n);
70796 -#define __do_strnlen_user(s,n,res)                                     \
70797 -       (res) = __arch_strnlen_user(s,n)
70798 diff -Nru a/include/asm-arm/proc-fns.h b/include/asm-arm/proc-fns.h
70799 --- a/include/asm-arm/proc-fns.h        Thu Mar  6 06:06:19 2003
70800 +++ b/include/asm-arm/proc-fns.h        Wed Sep  3 01:25:59 2003
70801 @@ -21,11 +21,6 @@
70802  #undef MULTI_CPU
70803  #undef CPU_NAME
70804  
70805 -#ifdef CONFIG_CPU_26
70806 -# define CPU_INCLUDE_NAME "asm/cpu-multi26.h"
70807 -# define MULTI_CPU
70808 -#endif
70809 -
70810  /*
70811   * CPU_NAME - the prefix for CPU related functions
70812   */
70813 diff -Nru a/include/asm-arm/processor.h b/include/asm-arm/processor.h
70814 --- a/include/asm-arm/processor.h       Tue May 13 08:53:45 2003
70815 +++ b/include/asm-arm/processor.h       Wed Sep  3 10:17:58 2003
70816 @@ -1,7 +1,7 @@
70817  /*
70818   *  linux/include/asm-arm/processor.h
70819   *
70820 - *  Copyright (C) 1995 Russell King
70821 + *  Copyright (C) 1995-1999 Russell King
70822   *
70823   * This program is free software; you can redistribute it and/or modify
70824   * it under the terms of the GNU General Public License version 2 as
70825 @@ -27,9 +27,10 @@
70826  #include <asm/ptrace.h>
70827  #include <asm/procinfo.h>
70828  #include <asm/arch/memory.h>
70829 -#include <asm/proc/processor.h>
70830  #include <asm/types.h>
70831  
70832 +#define KERNEL_STACK_SIZE      PAGE_SIZE
70833 +
70834  union debug_insn {
70835         u32     arm;
70836         u16     thumb;
70837 @@ -56,6 +57,24 @@
70838  
70839  #define INIT_THREAD  { }
70840  
70841 +#define start_thread(regs,pc,sp)                                       \
70842 +({                                                                     \
70843 +       unsigned long *stack = (unsigned long *)sp;                     \
70844 +       set_fs(USER_DS);                                                \
70845 +       memzero(regs->uregs, sizeof(regs->uregs));                      \
70846 +       if (current->personality & ADDR_LIMIT_32BIT)                    \
70847 +               regs->ARM_cpsr = USR_MODE;                              \
70848 +       else                                                            \
70849 +               regs->ARM_cpsr = USR26_MODE;                            \
70850 +       if (elf_hwcap & HWCAP_THUMB && pc & 1)                          \
70851 +               regs->ARM_cpsr |= PSR_T_BIT;                            \
70852 +       regs->ARM_pc = pc & ~1;         /* pc */                        \
70853 +       regs->ARM_sp = sp;              /* sp */                        \
70854 +       regs->ARM_r2 = stack[2];        /* r2 (envp) */                 \
70855 +       regs->ARM_r1 = stack[1];        /* r1 (argv) */                 \
70856 +       regs->ARM_r0 = stack[0];        /* r0 (argc) */                 \
70857 +})
70858 +
70859  /* Forward declaration, a strange C thing */
70860  struct task_struct;
70861  
70862 @@ -73,6 +92,9 @@
70863   * Create a new kernel thread
70864   */
70865  extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
70866 +
70867 +#define KSTK_EIP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1019])
70868 +#define KSTK_ESP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1017])
70869  
70870  /*
70871   * Prefetching support - only ARMv5.
70872 diff -Nru a/include/asm-arm/ptrace.h b/include/asm-arm/ptrace.h
70873 --- a/include/asm-arm/ptrace.h  Tue Sep 17 16:50:30 2002
70874 +++ b/include/asm-arm/ptrace.h  Wed Sep  3 10:17:58 2003
70875 @@ -1,6 +1,17 @@
70876 +/*
70877 + *  linux/include/asm-arm/ptrace.h
70878 + *
70879 + *  Copyright (C) 1996-2003 Russell King
70880 + *
70881 + * This program is free software; you can redistribute it and/or modify
70882 + * it under the terms of the GNU General Public License version 2 as
70883 + * published by the Free Software Foundation.
70884 + */
70885  #ifndef __ASM_ARM_PTRACE_H
70886  #define __ASM_ARM_PTRACE_H
70887  
70888 +#include <linux/config.h>
70889 +
70890  #define PTRACE_GETREGS         12
70891  #define PTRACE_SETREGS         13
70892  #define PTRACE_GETFPREGS       14
70893 @@ -8,9 +19,112 @@
70894  
70895  #define PTRACE_OLDSETOPTIONS   21
70896  
70897 -#include <asm/proc/ptrace.h>
70898 +/*
70899 + * PSR bits
70900 + */
70901 +#define USR26_MODE     0x00000000
70902 +#define FIQ26_MODE     0x00000001
70903 +#define IRQ26_MODE     0x00000002
70904 +#define SVC26_MODE     0x00000003
70905 +#define USR_MODE       0x00000010
70906 +#define FIQ_MODE       0x00000011
70907 +#define IRQ_MODE       0x00000012
70908 +#define SVC_MODE       0x00000013
70909 +#define ABT_MODE       0x00000017
70910 +#define UND_MODE       0x0000001b
70911 +#define SYSTEM_MODE    0x0000001f
70912 +#define MODE32_BIT     0x00000010
70913 +#define MODE_MASK      0x0000001f
70914 +#define PSR_T_BIT      0x00000020
70915 +#define PSR_F_BIT      0x00000040
70916 +#define PSR_I_BIT      0x00000080
70917 +#define PSR_J_BIT      0x01000000
70918 +#define PSR_Q_BIT      0x08000000
70919 +#define PSR_V_BIT      0x10000000
70920 +#define PSR_C_BIT      0x20000000
70921 +#define PSR_Z_BIT      0x40000000
70922 +#define PSR_N_BIT      0x80000000
70923 +#define PCMASK         0
70924 +
70925 +/*
70926 + * Groups of PSR bits
70927 + */
70928 +#define PSR_f          0xff000000      /* Flags                */
70929 +#define PSR_s          0x00ff0000      /* Status               */
70930 +#define PSR_x          0x0000ff00      /* Extension            */
70931 +#define PSR_c          0x000000ff      /* Control              */
70932  
70933  #ifndef __ASSEMBLY__
70934 +
70935 +/* this struct defines the way the registers are stored on the
70936 +   stack during a system call. */
70937 +
70938 +struct pt_regs {
70939 +       long uregs[18];
70940 +};
70941 +
70942 +#define ARM_cpsr       uregs[16]
70943 +#define ARM_pc         uregs[15]
70944 +#define ARM_lr         uregs[14]
70945 +#define ARM_sp         uregs[13]
70946 +#define ARM_ip         uregs[12]
70947 +#define ARM_fp         uregs[11]
70948 +#define ARM_r10                uregs[10]
70949 +#define ARM_r9         uregs[9]
70950 +#define ARM_r8         uregs[8]
70951 +#define ARM_r7         uregs[7]
70952 +#define ARM_r6         uregs[6]
70953 +#define ARM_r5         uregs[5]
70954 +#define ARM_r4         uregs[4]
70955 +#define ARM_r3         uregs[3]
70956 +#define ARM_r2         uregs[2]
70957 +#define ARM_r1         uregs[1]
70958 +#define ARM_r0         uregs[0]
70959 +#define ARM_ORIG_r0    uregs[17]
70960 +
70961 +#ifdef __KERNEL__
70962 +
70963 +#define user_mode(regs)        \
70964 +       (((regs)->ARM_cpsr & 0xf) == 0)
70965 +
70966 +#ifdef CONFIG_ARM_THUMB
70967 +#define thumb_mode(regs) \
70968 +       (((regs)->ARM_cpsr & PSR_T_BIT))
70969 +#else
70970 +#define thumb_mode(regs) (0)
70971 +#endif
70972 +
70973 +#define processor_mode(regs) \
70974 +       ((regs)->ARM_cpsr & MODE_MASK)
70975 +
70976 +#define interrupts_enabled(regs) \
70977 +       (!((regs)->ARM_cpsr & PSR_I_BIT))
70978 +
70979 +#define fast_interrupts_enabled(regs) \
70980 +       (!((regs)->ARM_cpsr & PSR_F_BIT))
70981 +
70982 +#define condition_codes(regs) \
70983 +       ((regs)->ARM_cpsr & (PSR_V_BIT|PSR_C_BIT|PSR_Z_BIT|PSR_N_BIT))
70984 +       
70985 +/* Are the current registers suitable for user mode?
70986 + * (used to maintain security in signal handlers)
70987 + */
70988 +static inline int valid_user_regs(struct pt_regs *regs)
70989 +{
70990 +       if (user_mode(regs) &&
70991 +           (regs->ARM_cpsr & (PSR_F_BIT|PSR_I_BIT)) == 0)
70992 +               return 1;
70993 +
70994 +       /*
70995 +        * Force CPSR to something logical...
70996 +        */
70997 +       regs->ARM_cpsr &= PSR_f | PSR_s | PSR_x | PSR_T_BIT | MODE32_BIT;
70998 +
70999 +       return 0;
71000 +}
71001 +
71002 +#endif /* __KERNEL__ */
71003 +
71004  #define pc_pointer(v) \
71005         ((v) & ~PCMASK)
71006  
71007 diff -Nru a/include/asm-arm/semaphore.h b/include/asm-arm/semaphore.h
71008 --- a/include/asm-arm/semaphore.h       Wed Jan  1 02:27:46 2003
71009 +++ b/include/asm-arm/semaphore.h       Wed Sep  3 23:40:12 2003
71010 @@ -10,7 +10,7 @@
71011  #include <linux/rwsem.h>
71012  
71013  #include <asm/atomic.h>
71014 -#include <asm/proc/locks.h>
71015 +#include <asm/locks.h>
71016  
71017  struct semaphore {
71018         atomic_t count;
71019 @@ -88,7 +88,7 @@
71020  #if WAITQUEUE_DEBUG
71021         CHECK_MAGIC(sem->__magic);
71022  #endif
71023 -
71024 +       might_sleep();
71025         __down_op(sem, __down_failed);
71026  }
71027  
71028 @@ -101,7 +101,7 @@
71029  #if WAITQUEUE_DEBUG
71030         CHECK_MAGIC(sem->__magic);
71031  #endif
71032 -
71033 +       might_sleep();
71034         return __down_op_ret(sem, __down_interruptible_failed);
71035  }
71036  
71037 diff -Nru a/include/asm-arm/shmparam.h b/include/asm-arm/shmparam.h
71038 --- a/include/asm-arm/shmparam.h        Tue Feb  5 09:39:52 2002
71039 +++ b/include/asm-arm/shmparam.h        Wed Sep  3 10:17:58 2003
71040 @@ -1,8 +1,6 @@
71041  #ifndef _ASMARM_SHMPARAM_H
71042  #define _ASMARM_SHMPARAM_H
71043  
71044 -#include <asm/proc/shmparam.h>
71045 -
71046  /*
71047   * This should be the size of the virtually indexed cache/ways,
71048   * or page size, whichever is greater since the cache aliases
71049 diff -Nru a/include/asm-arm/system.h b/include/asm-arm/system.h
71050 --- a/include/asm-arm/system.h  Thu Aug 14 07:38:28 2003
71051 +++ b/include/asm-arm/system.h  Wed Sep  3 10:17:58 2003
71052 @@ -4,6 +4,45 @@
71053  #ifdef __KERNEL__
71054  
71055  #include <linux/config.h>
71056 +
71057 +#define CPU_ARCH_UNKNOWN       0
71058 +#define CPU_ARCH_ARMv3         1
71059 +#define CPU_ARCH_ARMv4         2
71060 +#define CPU_ARCH_ARMv4T                3
71061 +#define CPU_ARCH_ARMv5         4
71062 +#define CPU_ARCH_ARMv5T                5
71063 +#define CPU_ARCH_ARMv5TE       6
71064 +#define CPU_ARCH_ARMv6         7
71065 +
71066 +/*
71067 + * CR1 bits (CP#15 CR1)
71068 + */
71069 +#define CR_M   (1 << 0)        /* MMU enable                           */
71070 +#define CR_A   (1 << 1)        /* Alignment abort enable               */
71071 +#define CR_C   (1 << 2)        /* Dcache enable                        */
71072 +#define CR_W   (1 << 3)        /* Write buffer enable                  */
71073 +#define CR_P   (1 << 4)        /* 32-bit exception handler             */
71074 +#define CR_D   (1 << 5)        /* 32-bit data address range            */
71075 +#define CR_L   (1 << 6)        /* Implementation defined               */
71076 +#define CR_B   (1 << 7)        /* Big endian                           */
71077 +#define CR_S   (1 << 8)        /* System MMU protection                */
71078 +#define CR_R   (1 << 9)        /* ROM MMU protection                   */
71079 +#define CR_F   (1 << 10)       /* Implementation defined               */
71080 +#define CR_Z   (1 << 11)       /* Implementation defined               */
71081 +#define CR_I   (1 << 12)       /* Icache enable                        */
71082 +#define CR_V   (1 << 13)       /* Vectors relocated to 0xffff0000      */
71083 +#define CR_RR  (1 << 14)       /* Round Robin cache replacement        */
71084 +#define CR_L4  (1 << 15)       /* LDR pc can set T bit                 */
71085 +#define CR_DT  (1 << 16)
71086 +#define CR_IT  (1 << 18)
71087 +#define CR_ST  (1 << 19)
71088 +#define CR_FI  (1 << 21)
71089 +#define CR_U   (1 << 22)       /* Unaligned access operation           */
71090 +#define CR_XP  (1 << 23)       /* Extended page tables                 */
71091 +#define CR_VE  (1 << 24)       /* Vectored interrupts                  */
71092 +
71093 +#ifndef __ASSEMBLY__
71094 +
71095  #include <linux/kernel.h>
71096  
71097  struct thread_info;
71098 @@ -34,21 +73,30 @@
71099  
71100  extern asmlinkage void __backtrace(void);
71101  
71102 -#define CPU_ARCH_UNKNOWN       0
71103 -#define CPU_ARCH_ARMv3         1
71104 -#define CPU_ARCH_ARMv4         2
71105 -#define CPU_ARCH_ARMv4T                3
71106 -#define CPU_ARCH_ARMv5         4
71107 -#define CPU_ARCH_ARMv5T                5
71108 -#define CPU_ARCH_ARMv5TE       6
71109 -#define CPU_ARCH_ARMv6         7
71110 -
71111  extern int cpu_architecture(void);
71112  
71113 -/*
71114 - * Include processor dependent parts
71115 - */
71116 -#include <asm/proc/system.h>
71117 +#define set_cr(x)                                      \
71118 +       __asm__ __volatile__(                           \
71119 +       "mcr    p15, 0, %0, c1, c0, 0   @ set CR"       \
71120 +       : : "r" (x) : "cc")
71121 +
71122 +#define get_cr()                                       \
71123 +       ({                                              \
71124 +       unsigned int __val;                             \
71125 +       __asm__ __volatile__(                           \
71126 +       "mrc    p15, 0, %0, c1, c0, 0   @ get CR"       \
71127 +       : "=r" (__val) : : "cc");                       \
71128 +       __val;                                          \
71129 +       })
71130 +
71131 +extern unsigned long cr_no_alignment;  /* defined in entry-armv.S */
71132 +extern unsigned long cr_alignment;     /* defined in entry-armv.S */
71133 +
71134 +#if __LINUX_ARM_ARCH__ >= 4
71135 +#define vectors_base() ((cr_alignment & CR_V) ? 0xffff0000 : 0)
71136 +#else
71137 +#define vectors_base() (0)
71138 +#endif
71139  
71140  #define mb() __asm__ __volatile__ ("" : : : "memory")
71141  #define rmb() mb()
71142 @@ -75,6 +123,102 @@
71143                 mb();                                                           \
71144         } while (0)
71145  
71146 +/*
71147 + * Save the current interrupt enable state & disable IRQs
71148 + */
71149 +#define local_irq_save(x)                                      \
71150 +       ({                                                      \
71151 +               unsigned long temp;                             \
71152 +               (void) (&temp == &x);                           \
71153 +       __asm__ __volatile__(                                   \
71154 +       "mrs    %0, cpsr                @ local_irq_save\n"     \
71155 +"      orr     %1, %0, #128\n"                                 \
71156 +"      msr     cpsr_c, %1"                                     \
71157 +       : "=r" (x), "=r" (temp)                                 \
71158 +       :                                                       \
71159 +       : "memory", "cc");                                      \
71160 +       })
71161 +       
71162 +/*
71163 + * Enable IRQs
71164 + */
71165 +#define local_irq_enable()                                     \
71166 +       ({                                                      \
71167 +               unsigned long temp;                             \
71168 +       __asm__ __volatile__(                                   \
71169 +       "mrs    %0, cpsr                @ local_irq_enable\n"   \
71170 +"      bic     %0, %0, #128\n"                                 \
71171 +"      msr     cpsr_c, %0"                                     \
71172 +       : "=r" (temp)                                           \
71173 +       :                                                       \
71174 +       : "memory", "cc");                                      \
71175 +       })
71176 +
71177 +/*
71178 + * Disable IRQs
71179 + */
71180 +#define local_irq_disable()                                    \
71181 +       ({                                                      \
71182 +               unsigned long temp;                             \
71183 +       __asm__ __volatile__(                                   \
71184 +       "mrs    %0, cpsr                @ local_irq_disable\n"  \
71185 +"      orr     %0, %0, #128\n"                                 \
71186 +"      msr     cpsr_c, %0"                                     \
71187 +       : "=r" (temp)                                           \
71188 +       :                                                       \
71189 +       : "memory", "cc");                                      \
71190 +       })
71191 +
71192 +/*
71193 + * Enable FIQs
71194 + */
71195 +#define __stf()                                                        \
71196 +       ({                                                      \
71197 +               unsigned long temp;                             \
71198 +       __asm__ __volatile__(                                   \
71199 +       "mrs    %0, cpsr                @ stf\n"                \
71200 +"      bic     %0, %0, #64\n"                                  \
71201 +"      msr     cpsr_c, %0"                                     \
71202 +       : "=r" (temp)                                           \
71203 +       :                                                       \
71204 +       : "memory", "cc");                                      \
71205 +       })
71206 +
71207 +/*
71208 + * Disable FIQs
71209 + */
71210 +#define __clf()                                                        \
71211 +       ({                                                      \
71212 +               unsigned long temp;                             \
71213 +       __asm__ __volatile__(                                   \
71214 +       "mrs    %0, cpsr                @ clf\n"                \
71215 +"      orr     %0, %0, #64\n"                                  \
71216 +"      msr     cpsr_c, %0"                                     \
71217 +       : "=r" (temp)                                           \
71218 +       :                                                       \
71219 +       : "memory", "cc");                                      \
71220 +       })
71221 +
71222 +/*
71223 + * Save the current interrupt enable state.
71224 + */
71225 +#define local_save_flags(x)                                    \
71226 +       ({                                                      \
71227 +       __asm__ __volatile__(                                   \
71228 +       "mrs    %0, cpsr                @ local_save_flags"     \
71229 +       : "=r" (x) : : "memory", "cc");                         \
71230 +       })
71231 +
71232 +/*
71233 + * restore saved IRQ & FIQ state
71234 + */
71235 +#define local_irq_restore(x)                                   \
71236 +       __asm__ __volatile__(                                   \
71237 +       "msr    cpsr_c, %0              @ local_irq_restore\n"  \
71238 +       :                                                       \
71239 +       : "r" (x)                                               \
71240 +       : "memory", "cc")
71241 +
71242  #ifdef CONFIG_SMP
71243  #error SMP not supported
71244  
71245 @@ -100,7 +244,66 @@
71246         flags & PSR_I_BIT;              \
71247  })
71248  
71249 +#if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
71250 +/*
71251 + * On the StrongARM, "swp" is terminally broken since it bypasses the
71252 + * cache totally.  This means that the cache becomes inconsistent, and,
71253 + * since we use normal loads/stores as well, this is really bad.
71254 + * Typically, this causes oopsen in filp_close, but could have other,
71255 + * more disasterous effects.  There are two work-arounds:
71256 + *  1. Disable interrupts and emulate the atomic swap
71257 + *  2. Clean the cache, perform atomic swap, flush the cache
71258 + *
71259 + * We choose (1) since its the "easiest" to achieve here and is not
71260 + * dependent on the processor type.
71261 + */
71262 +#define swp_is_buggy
71263 +#endif
71264 +
71265 +static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
71266 +{
71267 +       extern void __bad_xchg(volatile void *, int);
71268 +       unsigned long ret;
71269 +#ifdef swp_is_buggy
71270 +       unsigned long flags;
71271 +#endif
71272 +
71273 +       switch (size) {
71274 +#ifdef swp_is_buggy
71275 +               case 1:
71276 +                       local_irq_save(flags);
71277 +                       ret = *(volatile unsigned char *)ptr;
71278 +                       *(volatile unsigned char *)ptr = x;
71279 +                       local_irq_restore(flags);
71280 +                       break;
71281 +
71282 +               case 4:
71283 +                       local_irq_save(flags);
71284 +                       ret = *(volatile unsigned long *)ptr;
71285 +                       *(volatile unsigned long *)ptr = x;
71286 +                       local_irq_restore(flags);
71287 +                       break;
71288 +#else
71289 +               case 1: __asm__ __volatile__ ("swpb %0, %1, [%2]"
71290 +                                       : "=&r" (ret)
71291 +                                       : "r" (x), "r" (ptr)
71292 +                                       : "memory", "cc");
71293 +                       break;
71294 +               case 4: __asm__ __volatile__ ("swp %0, %1, [%2]"
71295 +                                       : "=&r" (ret)
71296 +                                       : "r" (x), "r" (ptr)
71297 +                                       : "memory", "cc");
71298 +                       break;
71299 +#endif
71300 +               default: __bad_xchg(ptr, size), ret = 0;
71301 +       }
71302 +
71303 +       return ret;
71304 +}
71305 +
71306  #endif /* CONFIG_SMP */
71307 +
71308 +#endif /* __ASSEMBLY__ */
71309  
71310  #endif /* __KERNEL__ */
71311  
71312 diff -Nru a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
71313 --- a/include/asm-arm/thread_info.h     Wed Jun  4 06:42:26 2003
71314 +++ b/include/asm-arm/thread_info.h     Wed Sep  3 10:17:58 2003
71315 @@ -18,9 +18,9 @@
71316  struct exec_domain;
71317  
71318  #include <asm/fpstate.h>
71319 -#include <asm/proc/processor.h>
71320  #include <asm/ptrace.h>
71321  #include <asm/types.h>
71322 +#include <asm/domain.h>
71323  
71324  typedef unsigned long mm_segment_t;
71325  
71326 @@ -55,17 +55,19 @@
71327         union fp_state          fpstate;
71328  };
71329  
71330 -#define INIT_THREAD_INFO(tsk)                          \
71331 -{                                                      \
71332 -       .task           = &tsk,                         \
71333 -       .exec_domain    = &default_exec_domain,         \
71334 -       .flags          = 0,                            \
71335 -       .preempt_count  = 1,                            \
71336 -       .addr_limit     = KERNEL_DS,                    \
71337 -       .restart_block  = {                             \
71338 -               .fn     = do_no_restart_syscall,        \
71339 -       },                                              \
71340 -       INIT_EXTRA_THREAD_INFO,                         \
71341 +#define INIT_THREAD_INFO(tsk)                                          \
71342 +{                                                                      \
71343 +       .task           = &tsk,                                         \
71344 +       .exec_domain    = &default_exec_domain,                         \
71345 +       .flags          = 0,                                            \
71346 +       .preempt_count  = 1,                                            \
71347 +       .addr_limit     = KERNEL_DS,                                    \
71348 +       .cpu_domain     = domain_val(DOMAIN_USER, DOMAIN_MANAGER) |     \
71349 +                         domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) |   \
71350 +                         domain_val(DOMAIN_IO, DOMAIN_CLIENT),         \
71351 +       .restart_block  = {                                             \
71352 +               .fn     = do_no_restart_syscall,                        \
71353 +       },                                                              \
71354  }
71355  
71356  #define init_thread_info       (init_thread_union.thread_info)
71357 diff -Nru a/include/asm-arm/tlbflush.h b/include/asm-arm/tlbflush.h
71358 --- a/include/asm-arm/tlbflush.h        Wed Apr 17 11:47:51 2002
71359 +++ b/include/asm-arm/tlbflush.h        Wed Sep  3 10:17:59 2003
71360 @@ -1,7 +1,7 @@
71361  /*
71362   *  linux/include/asm-arm/tlbflush.h
71363   *
71364 - *  Copyright (C) 2000-2002 Russell King
71365 + *  Copyright (C) 1999-2003 Russell King
71366   *
71367   * This program is free software; you can redistribute it and/or modify
71368   * it under the terms of the GNU General Public License version 2 as
71369 @@ -10,6 +10,397 @@
71370  #ifndef _ASMARM_TLBFLUSH_H
71371  #define _ASMARM_TLBFLUSH_H
71372  
71373 -#include <asm-arm/proc/tlbflush.h>
71374 +#include <linux/config.h>
71375 +#include <asm/glue.h>
71376 +
71377 +#define TLB_V3_PAGE    (1 << 0)
71378 +#define TLB_V4_U_PAGE  (1 << 1)
71379 +#define TLB_V4_D_PAGE  (1 << 2)
71380 +#define TLB_V4_I_PAGE  (1 << 3)
71381 +#define TLB_V6_U_PAGE  (1 << 4)
71382 +#define TLB_V6_D_PAGE  (1 << 5)
71383 +#define TLB_V6_I_PAGE  (1 << 6)
71384 +
71385 +#define TLB_V3_FULL    (1 << 8)
71386 +#define TLB_V4_U_FULL  (1 << 9)
71387 +#define TLB_V4_D_FULL  (1 << 10)
71388 +#define TLB_V4_I_FULL  (1 << 11)
71389 +#define TLB_V6_U_FULL  (1 << 12)
71390 +#define TLB_V6_D_FULL  (1 << 13)
71391 +#define TLB_V6_I_FULL  (1 << 14)
71392 +
71393 +#define TLB_V6_U_ASID  (1 << 16)
71394 +#define TLB_V6_D_ASID  (1 << 17)
71395 +#define TLB_V6_I_ASID  (1 << 18)
71396 +
71397 +#define TLB_DCLEAN     (1 << 30)
71398 +#define TLB_WB         (1 << 31)
71399 +
71400 +/*
71401 + *     MMU TLB Model
71402 + *     =============
71403 + *
71404 + *     We have the following to choose from:
71405 + *       v3    - ARMv3
71406 + *       v4    - ARMv4 without write buffer
71407 + *       v4wb  - ARMv4 with write buffer without I TLB flush entry instruction
71408 + *       v4wbi - ARMv4 with write buffer with I TLB flush entry instruction
71409 + *       v6wbi - ARMv6 with write buffer with I TLB flush entry instruction
71410 + */
71411 +#undef _TLB
71412 +#undef MULTI_TLB
71413 +
71414 +#define v3_tlb_flags   (TLB_V3_FULL | TLB_V3_PAGE)
71415 +
71416 +#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
71417 +# define v3_possible_flags     v3_tlb_flags
71418 +# define v3_always_flags       v3_tlb_flags
71419 +# ifdef _TLB
71420 +#  define MULTI_TLB 1
71421 +# else
71422 +#  define _TLB v3
71423 +# endif
71424 +#else
71425 +# define v3_possible_flags     0
71426 +# define v3_always_flags       (-1UL)
71427 +#endif
71428 +
71429 +#define v4_tlb_flags   (TLB_V4_U_FULL | TLB_V4_U_PAGE)
71430 +
71431 +#if defined(CONFIG_CPU_ARM720T)
71432 +# define v4_possible_flags     v4_tlb_flags
71433 +# define v4_always_flags       v4_tlb_flags
71434 +# ifdef _TLB
71435 +#  define MULTI_TLB 1
71436 +# else
71437 +#  define _TLB v4
71438 +# endif
71439 +#else
71440 +# define v4_possible_flags     0
71441 +# define v4_always_flags       (-1UL)
71442 +#endif
71443 +
71444 +#define v4wbi_tlb_flags        (TLB_WB | TLB_DCLEAN | \
71445 +                        TLB_V4_I_FULL | TLB_V4_D_FULL | \
71446 +                        TLB_V4_I_PAGE | TLB_V4_D_PAGE)
71447 +
71448 +#if defined(CONFIG_CPU_ARM920T) || defined(CONFIG_CPU_ARM922T) || \
71449 +    defined(CONFIG_CPU_ARM926T) || defined(CONFIG_CPU_ARM1020) || \
71450 +    defined(CONFIG_CPU_XSCALE)
71451 +# define v4wbi_possible_flags  v4wbi_tlb_flags
71452 +# define v4wbi_always_flags    v4wbi_tlb_flags
71453 +# ifdef _TLB
71454 +#  define MULTI_TLB 1
71455 +# else
71456 +#  define _TLB v4wbi
71457 +# endif
71458 +#else
71459 +# define v4wbi_possible_flags  0
71460 +# define v4wbi_always_flags    (-1UL)
71461 +#endif
71462 +
71463 +#define v4wb_tlb_flags (TLB_WB | TLB_DCLEAN | \
71464 +                        TLB_V4_I_FULL | TLB_V4_D_FULL | \
71465 +                        TLB_V4_D_PAGE)
71466 +
71467 +#if defined(CONFIG_CPU_SA110) || defined(CONFIG_CPU_SA1100)
71468 +# define v4wb_possible_flags   v4wb_tlb_flags
71469 +# define v4wb_always_flags     v4wb_tlb_flags
71470 +# ifdef _TLB
71471 +#  define MULTI_TLB 1
71472 +# else
71473 +#  define _TLB v4wb
71474 +# endif
71475 +#else
71476 +# define v4wb_possible_flags   0
71477 +# define v4wb_always_flags     (-1UL)
71478 +#endif
71479 +
71480 +#define v6wbi_tlb_flags (TLB_WB | TLB_DCLEAN | \
71481 +                        TLB_V6_I_FULL | TLB_V6_D_FULL | \
71482 +                        TLB_V6_I_PAGE | TLB_V6_D_PAGE | \
71483 +                        TLB_V6_I_ASID | TLB_V6_D_ASID)
71484 +
71485 +#if defined(CONFIG_CPU_V6)
71486 +# define v6wbi_possible_flags  v6wbi_tlb_flags
71487 +# define v6wbi_always_flags    v6wbi_tlb_flags
71488 +# ifdef _TLB
71489 +#  define MULTI_TLB 1
71490 +# else
71491 +#  define _TLB v6wbi
71492 +# endif
71493 +#else
71494 +# define v6wbi_possible_flags  0
71495 +# define v6wbi_always_flags    (-1UL)
71496 +#endif
71497 +
71498 +#ifndef _TLB
71499 +#error Unknown TLB model
71500 +#endif
71501 +
71502 +#ifndef __ASSEMBLY__
71503 +
71504 +struct cpu_tlb_fns {
71505 +       void (*flush_user_range)(unsigned long, unsigned long, struct vm_area_struct *);
71506 +       void (*flush_kern_range)(unsigned long, unsigned long);
71507 +       unsigned long tlb_flags;
71508 +};
71509 +
71510 +/*
71511 + * Select the calling method
71512 + */
71513 +#ifdef MULTI_TLB
71514 +
71515 +#define __cpu_flush_user_tlb_range     cpu_tlb.flush_user_range
71516 +#define __cpu_flush_kern_tlb_range     cpu_tlb.flush_kern_range
71517 +
71518 +#else
71519 +
71520 +#define __cpu_flush_user_tlb_range     __glue(_TLB,_flush_user_tlb_range)
71521 +#define __cpu_flush_kern_tlb_range     __glue(_TLB,_flush_kern_tlb_range)
71522 +
71523 +extern void __cpu_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *);
71524 +extern void __cpu_flush_kern_tlb_range(unsigned long, unsigned long);
71525 +
71526 +#endif
71527 +
71528 +extern struct cpu_tlb_fns cpu_tlb;
71529 +
71530 +#define __cpu_tlb_flags                        cpu_tlb.tlb_flags
71531 +
71532 +/*
71533 + *     TLB Management
71534 + *     ==============
71535 + *
71536 + *     The arch/arm/mm/tlb-*.S files implement these methods.
71537 + *
71538 + *     The TLB specific code is expected to perform whatever tests it
71539 + *     needs to determine if it should invalidate the TLB for each
71540 + *     call.  Start addresses are inclusive and end addresses are
71541 + *     exclusive; it is safe to round these addresses down.
71542 + *
71543 + *     flush_tlb_all()
71544 + *
71545 + *             Invalidate the entire TLB.
71546 + *
71547 + *     flush_tlb_mm(mm)
71548 + *
71549 + *             Invalidate all TLB entries in a particular address
71550 + *             space.
71551 + *             - mm    - mm_struct describing address space
71552 + *
71553 + *     flush_tlb_range(mm,start,end)
71554 + *
71555 + *             Invalidate a range of TLB entries in the specified
71556 + *             address space.
71557 + *             - mm    - mm_struct describing address space
71558 + *             - start - start address (may not be aligned)
71559 + *             - end   - end address (exclusive, may not be aligned)
71560 + *
71561 + *     flush_tlb_page(vaddr,vma)
71562 + *
71563 + *             Invalidate the specified page in the specified address range.
71564 + *             - vaddr - virtual address (may not be aligned)
71565 + *             - vma   - vma_struct describing address range
71566 + *
71567 + *     flush_kern_tlb_page(kaddr)
71568 + *
71569 + *             Invalidate the TLB entry for the specified page.  The address
71570 + *             will be in the kernels virtual memory space.  Current uses
71571 + *             only require the D-TLB to be invalidated.
71572 + *             - kaddr - Kernel virtual memory address
71573 + */
71574 +
71575 +/*
71576 + * We optimise the code below by:
71577 + *  - building a set of TLB flags that might be set in __cpu_tlb_flags
71578 + *  - building a set of TLB flags that will always be set in __cpu_tlb_flags
71579 + *  - if we're going to need __cpu_tlb_flags, access it once and only once
71580 + *
71581 + * This allows us to build optimal assembly for the single-CPU type case,
71582 + * and as close to optimal given the compiler constrants for multi-CPU
71583 + * case.  We could do better for the multi-CPU case if the compiler
71584 + * implemented the "%?" method, but this has been discontinued due to too
71585 + * many people getting it wrong.
71586 + */
71587 +#define possible_tlb_flags     (v3_possible_flags | \
71588 +                                v4_possible_flags | \
71589 +                                v4wbi_possible_flags | \
71590 +                                v4wb_possible_flags | \
71591 +                                v6wbi_possible_flags)
71592 +
71593 +#define always_tlb_flags       (v3_always_flags & \
71594 +                                v4_always_flags & \
71595 +                                v4wbi_always_flags & \
71596 +                                v4wb_always_flags & \
71597 +                                v6wbi_always_flags)
71598 +
71599 +#define tlb_flag(f)    ((always_tlb_flags & (f)) || (__tlb_flag & possible_tlb_flags & (f)))
71600 +
71601 +static inline void flush_tlb_all(void)
71602 +{
71603 +       const int zero = 0;
71604 +       const unsigned int __tlb_flag = __cpu_tlb_flags;
71605 +
71606 +       if (tlb_flag(TLB_WB))
71607 +               asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
71608 +
71609 +       if (tlb_flag(TLB_V3_FULL))
71610 +               asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (zero));
71611 +       if (tlb_flag(TLB_V4_U_FULL | TLB_V6_U_FULL))
71612 +               asm("mcr%? p15, 0, %0, c8, c7, 0" : : "r" (zero));
71613 +       if (tlb_flag(TLB_V4_D_FULL | TLB_V6_D_FULL))
71614 +               asm("mcr%? p15, 0, %0, c8, c6, 0" : : "r" (zero));
71615 +       if (tlb_flag(TLB_V4_I_FULL | TLB_V6_I_FULL))
71616 +               asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
71617 +}
71618 +
71619 +static inline void flush_tlb_mm(struct mm_struct *mm)
71620 +{
71621 +       const int zero = 0;
71622 +       const int asid = ASID(mm);
71623 +       const unsigned int __tlb_flag = __cpu_tlb_flags;
71624 +
71625 +       if (tlb_flag(TLB_WB))
71626 +               asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
71627 +
71628 +       if (mm == current->active_mm) {
71629 +               if (tlb_flag(TLB_V3_FULL))
71630 +                       asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (zero));
71631 +               if (tlb_flag(TLB_V4_U_FULL))
71632 +                       asm("mcr%? p15, 0, %0, c8, c7, 0" : : "r" (zero));
71633 +               if (tlb_flag(TLB_V4_D_FULL))
71634 +                       asm("mcr%? p15, 0, %0, c8, c6, 0" : : "r" (zero));
71635 +               if (tlb_flag(TLB_V4_I_FULL))
71636 +                       asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
71637 +       }
71638 +
71639 +       if (tlb_flag(TLB_V6_U_ASID))
71640 +               asm("mcr%? p15, 0, %0, c8, c7, 2" : : "r" (asid));
71641 +       if (tlb_flag(TLB_V6_D_ASID))
71642 +               asm("mcr%? p15, 0, %0, c8, c6, 2" : : "r" (asid));
71643 +       if (tlb_flag(TLB_V6_I_ASID))
71644 +               asm("mcr%? p15, 0, %0, c8, c5, 2" : : "r" (asid));
71645 +}
71646 +
71647 +static inline void
71648 +flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
71649 +{
71650 +       const int zero = 0;
71651 +       const unsigned int __tlb_flag = __cpu_tlb_flags;
71652 +
71653 +       uaddr = (uaddr & PAGE_MASK) | ASID(vma->vm_mm);
71654 +
71655 +       if (tlb_flag(TLB_WB))
71656 +               asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
71657 +
71658 +       if (vma->vm_mm == current->active_mm) {
71659 +               if (tlb_flag(TLB_V3_PAGE))
71660 +                       asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (uaddr));
71661 +               if (tlb_flag(TLB_V4_U_PAGE))
71662 +                       asm("mcr%? p15, 0, %0, c8, c7, 1" : : "r" (uaddr));
71663 +               if (tlb_flag(TLB_V4_D_PAGE))
71664 +                       asm("mcr%? p15, 0, %0, c8, c6, 1" : : "r" (uaddr));
71665 +               if (tlb_flag(TLB_V4_I_PAGE))
71666 +                       asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (uaddr));
71667 +               if (!tlb_flag(TLB_V4_I_PAGE) && tlb_flag(TLB_V4_I_FULL))
71668 +                       asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
71669 +       }
71670 +
71671 +       if (tlb_flag(TLB_V6_U_PAGE))
71672 +               asm("mcr%? p15, 0, %0, c8, c7, 1" : : "r" (uaddr));
71673 +       if (tlb_flag(TLB_V6_D_PAGE))
71674 +               asm("mcr%? p15, 0, %0, c8, c6, 1" : : "r" (uaddr));
71675 +       if (tlb_flag(TLB_V6_I_PAGE))
71676 +               asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (uaddr));
71677 +}
71678 +
71679 +static inline void flush_tlb_kernel_page(unsigned long kaddr)
71680 +{
71681 +       const int zero = 0;
71682 +       const unsigned int __tlb_flag = __cpu_tlb_flags;
71683 +
71684 +       kaddr &= PAGE_MASK;
71685 +
71686 +       if (tlb_flag(TLB_WB))
71687 +               asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero));
71688 +
71689 +       if (tlb_flag(TLB_V3_PAGE))
71690 +               asm("mcr%? p15, 0, %0, c6, c0, 0" : : "r" (kaddr));
71691 +       if (tlb_flag(TLB_V4_U_PAGE))
71692 +               asm("mcr%? p15, 0, %0, c8, c7, 1" : : "r" (kaddr));
71693 +       if (tlb_flag(TLB_V4_D_PAGE))
71694 +               asm("mcr%? p15, 0, %0, c8, c6, 1" : : "r" (kaddr));
71695 +       if (tlb_flag(TLB_V4_I_PAGE))
71696 +               asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (kaddr));
71697 +       if (!tlb_flag(TLB_V4_I_PAGE) && tlb_flag(TLB_V4_I_FULL))
71698 +               asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero));
71699 +
71700 +       if (tlb_flag(TLB_V6_U_PAGE))
71701 +               asm("mcr%? p15, 0, %0, c8, c7, 1" : : "r" (kaddr));
71702 +       if (tlb_flag(TLB_V6_D_PAGE))
71703 +               asm("mcr%? p15, 0, %0, c8, c6, 1" : : "r" (kaddr));
71704 +       if (tlb_flag(TLB_V6_I_PAGE))
71705 +               asm("mcr%? p15, 0, %0, c8, c5, 1" : : "r" (kaddr));
71706 +}
71707 +
71708 +/*
71709 + *     flush_pmd_entry
71710 + *
71711 + *     Flush a PMD entry (word aligned, or double-word aligned) to
71712 + *     RAM if the TLB for the CPU we are running on requires this.
71713 + *     This is typically used when we are creating PMD entries.
71714 + *
71715 + *     clean_pmd_entry
71716 + *
71717 + *     Clean (but don't drain the write buffer) if the CPU requires
71718 + *     these operations.  This is typically used when we are removing
71719 + *     PMD entries.
71720 + */
71721 +static inline void flush_pmd_entry(pmd_t *pmd)
71722 +{
71723 +       const unsigned int zero = 0;
71724 +       const unsigned int __tlb_flag = __cpu_tlb_flags;
71725 +
71726 +       if (tlb_flag(TLB_DCLEAN))
71727 +               asm("mcr%?      p15, 0, %0, c7, c10, 1  @ flush_pmd"
71728 +                       : : "r" (pmd));
71729 +       if (tlb_flag(TLB_WB))
71730 +               asm("mcr%?      p15, 0, %0, c7, c10, 4  @ flush_pmd"
71731 +                       : : "r" (zero));
71732 +}
71733 +
71734 +static inline void clean_pmd_entry(pmd_t *pmd)
71735 +{
71736 +       const unsigned int __tlb_flag = __cpu_tlb_flags;
71737 +
71738 +       if (tlb_flag(TLB_DCLEAN))
71739 +               asm("mcr%?      p15, 0, %0, c7, c10, 1  @ flush_pmd"
71740 +                       : : "r" (pmd));
71741 +}
71742 +
71743 +#undef tlb_flag
71744 +#undef always_tlb_flags
71745 +#undef possible_tlb_flags
71746 +
71747 +/*
71748 + * Convert calls to our calling convention.
71749 + */
71750 +#define flush_tlb_range(vma,start,end) __cpu_flush_user_tlb_range(start,end,vma)
71751 +#define flush_tlb_kernel_range(s,e)    __cpu_flush_kern_tlb_range(s,e)
71752 +
71753 +/*
71754 + * if PG_dcache_dirty is set for the page, we need to ensure that any
71755 + * cache entries for the kernels virtual memory range are written
71756 + * back to the page.
71757 + */
71758 +extern void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t pte);
71759 +
71760 +/*
71761 + * ARM processors do not cache TLB tables in RAM.
71762 + */
71763 +#define flush_tlb_pgtables(mm,start,end)       do { } while (0)
71764 +
71765 +#endif
71766  
71767  #endif
71768 diff -Nru a/include/asm-arm/uaccess.h b/include/asm-arm/uaccess.h
71769 --- a/include/asm-arm/uaccess.h Wed May 28 06:17:24 2003
71770 +++ b/include/asm-arm/uaccess.h Wed Sep  3 10:17:58 2003
71771 @@ -1,3 +1,10 @@
71772 +/*
71773 + *  linux/include/asm-arm/uaccess.h
71774 + *
71775 + * This program is free software; you can redistribute it and/or modify
71776 + * it under the terms of the GNU General Public License version 2 as
71777 + * published by the Free Software Foundation.
71778 + */
71779  #ifndef _ASMARM_UACCESS_H
71780  #define _ASMARM_UACCESS_H
71781  
71782 @@ -6,6 +13,8 @@
71783   */
71784  #include <linux/sched.h>
71785  #include <asm/errno.h>
71786 +#include <asm/arch/memory.h>
71787 +#include <asm/domain.h>
71788  
71789  #define VERIFY_READ 0
71790  #define VERIFY_WRITE 1
71791 @@ -30,11 +39,39 @@
71792  
71793  extern int fixup_exception(struct pt_regs *regs);
71794  
71795 +/*
71796 + * Note that this is actually 0x1,0000,0000
71797 + */
71798 +#define KERNEL_DS      0x00000000
71799 +#define USER_DS                TASK_SIZE
71800 +
71801  #define get_ds()       (KERNEL_DS)
71802  #define get_fs()       (current_thread_info()->addr_limit)
71803 +
71804 +static inline void set_fs (mm_segment_t fs)
71805 +{
71806 +       current_thread_info()->addr_limit = fs;
71807 +       modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
71808 +}
71809 +
71810  #define segment_eq(a,b)        ((a) == (b))
71811  
71812 -#include <asm/proc/uaccess.h>
71813 +#define __addr_ok(addr) ({ \
71814 +       unsigned long flag; \
71815 +       __asm__("cmp %2, %0; movlo %0, #0" \
71816 +               : "=&r" (flag) \
71817 +               : "0" (current_thread_info()->addr_limit), "r" (addr) \
71818 +               : "cc"); \
71819 +       (flag == 0); })
71820 +
71821 +/* We use 33-bit arithmetic here... */
71822 +#define __range_ok(addr,size) ({ \
71823 +       unsigned long flag, sum; \
71824 +       __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
71825 +               : "=&r" (flag), "=&r" (sum) \
71826 +               : "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit) \
71827 +               : "cc"); \
71828 +       flag; })
71829  
71830  #define access_ok(type,addr,size)      (__range_ok(addr,size) == 0)
71831  
71832 @@ -125,17 +162,71 @@
71833         (x) = (__typeof__(*(ptr)))__gu_val;                             \
71834  } while (0)
71835  
71836 +#define __get_user_asm_byte(x,addr,err)                                \
71837 +       __asm__ __volatile__(                                   \
71838 +       "1:     ldrbt   %1,[%2],#0\n"                           \
71839 +       "2:\n"                                                  \
71840 +       "       .section .fixup,\"ax\"\n"                       \
71841 +       "       .align  2\n"                                    \
71842 +       "3:     mov     %0, %3\n"                               \
71843 +       "       mov     %1, #0\n"                               \
71844 +       "       b       2b\n"                                   \
71845 +       "       .previous\n"                                    \
71846 +       "       .section __ex_table,\"a\"\n"                    \
71847 +       "       .align  3\n"                                    \
71848 +       "       .long   1b, 3b\n"                               \
71849 +       "       .previous"                                      \
71850 +       : "+r" (err), "=&r" (x)                                 \
71851 +       : "r" (addr), "i" (-EFAULT)                             \
71852 +       : "cc")
71853 +
71854 +#ifndef __ARMEB__
71855 +#define __get_user_asm_half(x,__gu_addr,err)                   \
71856 +({                                                             \
71857 +       unsigned long __b1, __b2;                               \
71858 +       __get_user_asm_byte(__b1, __gu_addr, err);              \
71859 +       __get_user_asm_byte(__b2, __gu_addr + 1, err);          \
71860 +       (x) = __b1 | (__b2 << 8);                               \
71861 +})
71862 +#else
71863 +#define __get_user_asm_half(x,__gu_addr,err)                   \
71864 +({                                                             \
71865 +       unsigned long __b1, __b2;                               \
71866 +       __get_user_asm_byte(__b1, __gu_addr, err);              \
71867 +       __get_user_asm_byte(__b2, __gu_addr + 1, err);          \
71868 +       (x) = (__b1 << 8) | __b2;                               \
71869 +})
71870 +#endif
71871 +
71872 +#define __get_user_asm_word(x,addr,err)                                \
71873 +       __asm__ __volatile__(                                   \
71874 +       "1:     ldrt    %1,[%2],#0\n"                           \
71875 +       "2:\n"                                                  \
71876 +       "       .section .fixup,\"ax\"\n"                       \
71877 +       "       .align  2\n"                                    \
71878 +       "3:     mov     %0, %3\n"                               \
71879 +       "       mov     %1, #0\n"                               \
71880 +       "       b       2b\n"                                   \
71881 +       "       .previous\n"                                    \
71882 +       "       .section __ex_table,\"a\"\n"                    \
71883 +       "       .align  3\n"                                    \
71884 +       "       .long   1b, 3b\n"                               \
71885 +       "       .previous"                                      \
71886 +       : "+r" (err), "=&r" (x)                                 \
71887 +       : "r" (addr), "i" (-EFAULT)                             \
71888 +       : "cc")
71889 +
71890  extern int __put_user_1(void *, unsigned int);
71891  extern int __put_user_2(void *, unsigned int);
71892  extern int __put_user_4(void *, unsigned int);
71893  extern int __put_user_8(void *, unsigned long long);
71894  extern int __put_user_bad(void);
71895  
71896 -#define __put_user_x(__r1,__p,__e,__s,__i...)                          \
71897 +#define __put_user_x(__r1,__p,__e,__s)                                 \
71898            __asm__ __volatile__ ("bl    __put_user_" #__s               \
71899                 : "=&r" (__e)                                           \
71900                 : "0" (__p), "r" (__r1)                                 \
71901 -               : __i, "cc")
71902 +               : "ip", "lr", "cc")
71903  
71904  #define put_user(x,p)                                                  \
71905         ({                                                              \
71906 @@ -144,16 +235,16 @@
71907                 register int __e asm("r0");                             \
71908                 switch (sizeof(*(__p))) {                               \
71909                 case 1:                                                 \
71910 -                       __put_user_x(__r1, __p, __e, 1, "ip", "lr");    \
71911 +                       __put_user_x(__r1, __p, __e, 1);                \
71912                         break;                                          \
71913                 case 2:                                                 \
71914 -                       __put_user_x(__r1, __p, __e, 2, "ip", "lr");    \
71915 +                       __put_user_x(__r1, __p, __e, 2);                \
71916                         break;                                          \
71917                 case 4:                                                 \
71918 -                       __put_user_x(__r1, __p, __e, 4, "ip", "lr");    \
71919 +                       __put_user_x(__r1, __p, __e, 4);                \
71920                         break;                                          \
71921                 case 8:                                                 \
71922 -                       __put_user_x(__r1, __p, __e, 8, "ip", "lr");    \
71923 +                       __put_user_x(__r1, __p, __e, 8);                \
71924                         break;                                          \
71925                 default: __e = __put_user_bad(); break;                 \
71926                 }                                                       \
71927 @@ -186,10 +277,93 @@
71928         }                                                               \
71929  } while (0)
71930  
71931 +#define __put_user_asm_byte(x,__pu_addr,err)                   \
71932 +       __asm__ __volatile__(                                   \
71933 +       "1:     strbt   %1,[%2],#0\n"                           \
71934 +       "2:\n"                                                  \
71935 +       "       .section .fixup,\"ax\"\n"                       \
71936 +       "       .align  2\n"                                    \
71937 +       "3:     mov     %0, %3\n"                               \
71938 +       "       b       2b\n"                                   \
71939 +       "       .previous\n"                                    \
71940 +       "       .section __ex_table,\"a\"\n"                    \
71941 +       "       .align  3\n"                                    \
71942 +       "       .long   1b, 3b\n"                               \
71943 +       "       .previous"                                      \
71944 +       : "+r" (err)                                            \
71945 +       : "r" (x), "r" (__pu_addr), "i" (-EFAULT)               \
71946 +       : "cc")
71947 +
71948 +#ifndef __ARMEB__
71949 +#define __put_user_asm_half(x,__pu_addr,err)                   \
71950 +({                                                             \
71951 +       unsigned long __temp = (unsigned long)(x);              \
71952 +       __put_user_asm_byte(__temp, __pu_addr, err);            \
71953 +       __put_user_asm_byte(__temp >> 8, __pu_addr + 1, err);   \
71954 +})
71955 +#else
71956 +#define __put_user_asm_half(x,__pu_addr,err)                   \
71957 +({                                                             \
71958 +       unsigned long __temp = (unsigned long)(x);              \
71959 +       __put_user_asm_byte(__temp >> 8, __pu_addr, err);       \
71960 +       __put_user_asm_byte(__temp, __pu_addr + 1, err);        \
71961 +})
71962 +#endif
71963 +
71964 +#define __put_user_asm_word(x,__pu_addr,err)                   \
71965 +       __asm__ __volatile__(                                   \
71966 +       "1:     strt    %1,[%2],#0\n"                           \
71967 +       "2:\n"                                                  \
71968 +       "       .section .fixup,\"ax\"\n"                       \
71969 +       "       .align  2\n"                                    \
71970 +       "3:     mov     %0, %3\n"                               \
71971 +       "       b       2b\n"                                   \
71972 +       "       .previous\n"                                    \
71973 +       "       .section __ex_table,\"a\"\n"                    \
71974 +       "       .align  3\n"                                    \
71975 +       "       .long   1b, 3b\n"                               \
71976 +       "       .previous"                                      \
71977 +       : "+r" (err)                                            \
71978 +       : "r" (x), "r" (__pu_addr), "i" (-EFAULT)               \
71979 +       : "cc")
71980 +
71981 +#ifndef __ARMEB__
71982 +#define        __reg_oper0     "%R2"
71983 +#define        __reg_oper1     "%Q2"
71984 +#else
71985 +#define        __reg_oper0     "%Q2"
71986 +#define        __reg_oper1     "%R2"
71987 +#endif
71988 +
71989 +#define __put_user_asm_dword(x,__pu_addr,err)                  \
71990 +       __asm__ __volatile__(                                   \
71991 +       "1:     strt    " __reg_oper1 ", [%1], #4\n"            \
71992 +       "2:     strt    " __reg_oper0 ", [%1], #0\n"            \
71993 +       "3:\n"                                                  \
71994 +       "       .section .fixup,\"ax\"\n"                       \
71995 +       "       .align  2\n"                                    \
71996 +       "4:     mov     %0, %3\n"                               \
71997 +       "       b       3b\n"                                   \
71998 +       "       .previous\n"                                    \
71999 +       "       .section __ex_table,\"a\"\n"                    \
72000 +       "       .align  3\n"                                    \
72001 +       "       .long   1b, 4b\n"                               \
72002 +       "       .long   2b, 4b\n"                               \
72003 +       "       .previous"                                      \
72004 +       : "+r" (err), "+r" (__pu_addr)                          \
72005 +       : "r" (x), "i" (-EFAULT)                                \
72006 +       : "cc")
72007 +
72008 +extern unsigned long __arch_copy_from_user(void *to, const void *from, unsigned long n);
72009 +extern unsigned long __arch_copy_to_user(void *to, const void *from, unsigned long n);
72010 +extern unsigned long __arch_clear_user(void *addr, unsigned long n);
72011 +extern unsigned long __arch_strncpy_from_user(char *to, const char *from, unsigned long count);
72012 +extern unsigned long __arch_strnlen_user(const char *s, long n);
72013 +
72014  static __inline__ unsigned long copy_from_user(void *to, const void *from, unsigned long n)
72015  {
72016         if (access_ok(VERIFY_READ, from, n))
72017 -               __do_copy_from_user(to, from, n);
72018 +               n = __arch_copy_from_user(to, from, n);
72019         else /* security hole - plug it */
72020                 memzero(to, n);
72021         return n;
72022 @@ -197,49 +371,44 @@
72023  
72024  static __inline__ unsigned long __copy_from_user(void *to, const void *from, unsigned long n)
72025  {
72026 -       __do_copy_from_user(to, from, n);
72027 -       return n;
72028 +       return __arch_copy_from_user(to, from, n);
72029  }
72030  
72031  static __inline__ unsigned long copy_to_user(void *to, const void *from, unsigned long n)
72032  {
72033         if (access_ok(VERIFY_WRITE, to, n))
72034 -               __do_copy_to_user(to, from, n);
72035 +               n = __arch_copy_to_user(to, from, n);
72036         return n;
72037  }
72038  
72039  static __inline__ unsigned long __copy_to_user(void *to, const void *from, unsigned long n)
72040  {
72041 -       __do_copy_to_user(to, from, n);
72042 -       return n;
72043 +       return __arch_copy_to_user(to, from, n);
72044  }
72045  
72046  static __inline__ unsigned long clear_user (void *to, unsigned long n)
72047  {
72048         if (access_ok(VERIFY_WRITE, to, n))
72049 -               __do_clear_user(to, n);
72050 +               n = __arch_clear_user(to, n);
72051         return n;
72052  }
72053  
72054  static __inline__ unsigned long __clear_user (void *to, unsigned long n)
72055  {
72056 -       __do_clear_user(to, n);
72057 -       return n;
72058 +       return __arch_clear_user(to, n);
72059  }
72060  
72061  static __inline__ long strncpy_from_user (char *dst, const char *src, long count)
72062  {
72063         long res = -EFAULT;
72064         if (access_ok(VERIFY_READ, src, 1))
72065 -               __do_strncpy_from_user(dst, src, count, res);
72066 +               res = __arch_strncpy_from_user(dst, src, count);
72067         return res;
72068  }
72069  
72070  static __inline__ long __strncpy_from_user (char *dst, const char *src, long count)
72071  {
72072 -       long res;
72073 -       __do_strncpy_from_user(dst, src, count, res);
72074 -       return res;
72075 +       return __arch_strncpy_from_user(dst, src, count);
72076  }
72077  
72078  #define strlen_user(s) strnlen_user(s, ~0UL >> 1)
72079 @@ -249,7 +418,7 @@
72080         unsigned long res = 0;
72081  
72082         if (__addr_ok(s))
72083 -               __do_strnlen_user(s, n, res);
72084 +               res = __arch_strnlen_user(s, n);
72085  
72086         return res;
72087  }
72088 diff -Nru a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
72089 --- a/include/asm-arm/unistd.h  Tue Jan 14 15:28:43 2003
72090 +++ b/include/asm-arm/unistd.h  Tue Jul  8 09:40:32 2003
72091 @@ -303,7 +303,7 @@
72092         "swi    0\n\t"                                  \
72093         "pop    {r7}"
72094  #else
72095 -#define __syscall(name) "swi\t" __sys1(__NR_##name) "\n\t"
72096 +#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
72097  #endif
72098  #endif
72099  
72100 @@ -318,24 +318,28 @@
72101  
72102  #define _syscall0(type,name)                                           \
72103  type name(void) {                                                      \
72104 -  register long __res __asm__("r0");                                   \
72105 +  register long __res_r0 __asm__("r0");                                        \
72106 +  long __res;                                                          \
72107    __asm__ __volatile__ (                                               \
72108    __syscall(name)                                                      \
72109 -       :"=r" (__res)                                                   \
72110 +       : "=r" (__res_r0)                                               \
72111         :                                                               \
72112         : "lr");                                                        \
72113 +  __res = __res_r0;                                                    \
72114    __syscall_return(type,__res);                                                \
72115  }
72116  
72117  #define _syscall1(type,name,type1,arg1)                                \
72118  type name(type1 arg1) {                                                \
72119    register long __r0 __asm__("r0") = (long)arg1;                       \
72120 -  register long __res __asm__("r0");                                   \
72121 +  register long __res_r0 __asm__("r0");                                        \
72122 +  long __res;                                                          \
72123    __asm__ __volatile__ (                                               \
72124    __syscall(name)                                                      \
72125 -       : "=r" (__res)                                                  \
72126 +       : "=r" (__res_r0)                                               \
72127         : "r" (__r0)                                                    \
72128         : "lr");                                                        \
72129 +  __res = __res_r0;                                                    \
72130    __syscall_return(type,__res);                                                \
72131  }
72132  
72133 @@ -343,12 +347,14 @@
72134  type name(type1 arg1,type2 arg2) {                                     \
72135    register long __r0 __asm__("r0") = (long)arg1;                       \
72136    register long __r1 __asm__("r1") = (long)arg2;                       \
72137 -  register long __res __asm__("r0");                                   \
72138 +  register long __res_r0 __asm__("r0");                                        \
72139 +  long __res;                                                          \
72140    __asm__ __volatile__ (                                               \
72141    __syscall(name)                                                      \
72142 -       : "=r" (__res)                                                  \
72143 +       : "=r" (__res_r0)                                               \
72144         : "r" (__r0),"r" (__r1)                                         \
72145         : "lr");                                                        \
72146 +  __res = __res_r0;                                                    \
72147    __syscall_return(type,__res);                                                \
72148  }
72149  
72150 @@ -358,12 +364,14 @@
72151    register long __r0 __asm__("r0") = (long)arg1;                       \
72152    register long __r1 __asm__("r1") = (long)arg2;                       \
72153    register long __r2 __asm__("r2") = (long)arg3;                       \
72154 -  register long __res __asm__("r0");                                   \
72155 +  register long __res_r0 __asm__("r0");                                        \
72156 +  long __res;                                                          \
72157    __asm__ __volatile__ (                                               \
72158    __syscall(name)                                                      \
72159 -       : "=r" (__res)                                                  \
72160 +       : "=r" (__res_r0)                                               \
72161         : "r" (__r0),"r" (__r1),"r" (__r2)                              \
72162         : "lr");                                                        \
72163 +  __res = __res_r0;                                                    \
72164    __syscall_return(type,__res);                                                \
72165  }
72166  
72167 @@ -374,12 +382,14 @@
72168    register long __r1 __asm__("r1") = (long)arg2;                       \
72169    register long __r2 __asm__("r2") = (long)arg3;                       \
72170    register long __r3 __asm__("r3") = (long)arg4;                       \
72171 -  register long __res __asm__("r0");                                   \
72172 +  register long __res_r0 __asm__("r0");                                        \
72173 +  long __res;                                                          \
72174    __asm__ __volatile__ (                                               \
72175    __syscall(name)                                                      \
72176 -       : "=r" (__res)                                                  \
72177 +       : "=r" (__res_r0)                                               \
72178         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3)                   \
72179         : "lr");                                                        \
72180 +  __res = __res_r0;                                                    \
72181    __syscall_return(type,__res);                                                \
72182  }
72183    
72184 @@ -391,12 +401,14 @@
72185    register long __r2 __asm__("r2") = (long)arg3;                       \
72186    register long __r3 __asm__("r3") = (long)arg4;                       \
72187    register long __r4 __asm__("r4") = (long)arg5;                       \
72188 -  register long __res __asm__("r0");                                   \
72189 +  register long __res_r0 __asm__("r0");                                        \
72190 +  long __res;                                                          \
72191    __asm__ __volatile__ (                                               \
72192    __syscall(name)                                                      \
72193 -       : "=r" (__res)                                                  \
72194 +       : "=r" (__res_r0)                                               \
72195         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4)        \
72196         : "lr");                                                        \
72197 +  __res = __res_r0;                                                    \
72198    __syscall_return(type,__res);                                                \
72199  }
72200  
72201 @@ -408,12 +420,14 @@
72202    register long __r3 __asm__("r3") = (long)arg4;                       \
72203    register long __r4 __asm__("r4") = (long)arg5;                       \
72204    register long __r5 __asm__("r5") = (long)arg6;                       \
72205 -  register long __res __asm__("r0");                                   \
72206 +  register long __res_r0 __asm__("r0");                                        \
72207 +  long __res;                                                          \
72208    __asm__ __volatile__ (                                               \
72209    __syscall(name)                                                      \
72210 -       : "=r" (__res)                                                  \
72211 +       : "=r" (__res_r0)                                               \
72212         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5)            \
72213         : "lr");                                                        \
72214 +  __res = __res_r0;                                                    \
72215    __syscall_return(type,__res);                                                \
72216  }
72217  
72218 diff -Nru a/include/asm-arm/xor.h b/include/asm-arm/xor.h
72219 --- a/include/asm-arm/xor.h     Mon Feb  4 23:41:12 2002
72220 +++ b/include/asm-arm/xor.h     Sun Aug 31 16:14:08 2003
72221 @@ -125,11 +125,11 @@
72222  }
72223  
72224  static struct xor_block_template xor_block_arm4regs = {
72225 -       name:   "arm4regs",
72226 -       do_2:   xor_arm4regs_2,
72227 -       do_3:   xor_arm4regs_3,
72228 -       do_4:   xor_arm4regs_4,
72229 -       do_5:   xor_arm4regs_5,
72230 +       .name   = "arm4regs",
72231 +       .do_2   = xor_arm4regs_2,
72232 +       .do_3   = xor_arm4regs_3,
72233 +       .do_4   = xor_arm4regs_4,
72234 +       .do_5   = xor_arm4regs_5,
72235  };
72236  
72237  #undef XOR_TRY_TEMPLATES
72238 diff -Nru a/include/asm-arm26/processor.h b/include/asm-arm26/processor.h
72239 --- a/include/asm-arm26/processor.h     Thu Jun 26 03:24:47 2003
72240 +++ b/include/asm-arm26/processor.h     Sun Aug 31 16:14:08 2003
72241 @@ -51,7 +51,7 @@
72242          uaccess_t       *uaccess;         /* User access functions*/
72243  
72244  #define EXTRA_THREAD_STRUCT_INIT                \
72245 -        uaccess:        &uaccess_kernel,
72246 +        .uaccess        = &uaccess_kernel,
72247  
72248  // FIXME?!!
72249  
72250 diff -Nru a/include/asm-arm26/semaphore.h b/include/asm-arm26/semaphore.h
72251 --- a/include/asm-arm26/semaphore.h     Wed Jun  4 04:14:10 2003
72252 +++ b/include/asm-arm26/semaphore.h     Wed Sep  3 23:40:12 2003
72253 @@ -84,7 +84,7 @@
72254  #if WAITQUEUE_DEBUG
72255         CHECK_MAGIC(sem->__magic);
72256  #endif
72257 -
72258 +       might_sleep();
72259         __down_op(sem, __down_failed);
72260  }
72261  
72262 @@ -97,7 +97,7 @@
72263  #if WAITQUEUE_DEBUG
72264         CHECK_MAGIC(sem->__magic);
72265  #endif
72266 -
72267 +       might_sleep();
72268         return __down_op_ret(sem, __down_interruptible_failed);
72269  }
72270  
72271 diff -Nru a/include/asm-arm26/xor.h b/include/asm-arm26/xor.h
72272 --- a/include/asm-arm26/xor.h   Wed Jun  4 04:14:11 2003
72273 +++ b/include/asm-arm26/xor.h   Sun Aug 31 16:14:08 2003
72274 @@ -125,11 +125,11 @@
72275  }
72276  
72277  static struct xor_block_template xor_block_arm4regs = {
72278 -       name:   "arm4regs",
72279 -       do_2:   xor_arm4regs_2,
72280 -       do_3:   xor_arm4regs_3,
72281 -       do_4:   xor_arm4regs_4,
72282 -       do_5:   xor_arm4regs_5,
72283 +       .name   = "arm4regs",
72284 +       .do_2   = xor_arm4regs_2,
72285 +       .do_3   = xor_arm4regs_3,
72286 +       .do_4   = xor_arm4regs_4,
72287 +       .do_5   = xor_arm4regs_5,
72288  };
72289  
72290  #undef XOR_TRY_TEMPLATES
72291 diff -Nru a/include/asm-cris/semaphore.h b/include/asm-cris/semaphore.h
72292 --- a/include/asm-cris/semaphore.h      Thu Nov 21 00:16:33 2002
72293 +++ b/include/asm-cris/semaphore.h      Wed Sep  3 23:40:12 2003
72294 @@ -79,6 +79,7 @@
72295  #if WAITQUEUE_DEBUG
72296         CHECK_MAGIC(sem->__magic);
72297  #endif
72298 +       might_sleep();
72299  
72300         /* atomically decrement the semaphores count, and if its negative, we wait */
72301         local_save_flags(flags);
72302 @@ -104,6 +105,7 @@
72303  #if WAITQUEUE_DEBUG
72304         CHECK_MAGIC(sem->__magic);
72305  #endif
72306 +       might_sleep();
72307  
72308         /* atomically decrement the semaphores count, and if its negative, we wait */
72309         local_save_flags(flags);
72310 diff -Nru a/include/asm-h8300/aki3068net/ne.h b/include/asm-h8300/aki3068net/ne.h
72311 --- a/include/asm-h8300/aki3068net/ne.h Sat Jul 19 05:41:33 2003
72312 +++ /dev/null   Wed Dec 31 16:00:00 1969
72313 @@ -1,28 +0,0 @@
72314 -/* AE-3068 (aka. aki3068net) RTL8019AS Config */
72315 -
72316 -#ifndef __H8300_AKI3068NET_NE__
72317 -#define __H8300_AKI3068NET_NE__
72318 -
72319 -#define NE2000_ADDR            0x200000
72320 -#define NE2000_IRQ              5
72321 -#define NE2000_IRQ_VECTOR      (12 + NE2000_IRQ)
72322 -#define        NE2000_BYTE             volatile unsigned short
72323 -
72324 -#define IER                     0xfee015
72325 -#define ISR                    0xfee016
72326 -#define IRQ_MASK               (1 << NE2000_IRQ)
72327 -
72328 -#define WCRL                    0xfee023
72329 -#define MAR0A                   0xffff20
72330 -#define ETCR0A                  0xffff24
72331 -#define DTCR0A                  0xffff27
72332 -#define MAR0B                   0xffff28
72333 -#define DTCR0B                  0xffff2f
72334 -
72335 -#define H8300_INIT_NE()                  \
72336 -do {                                     \
72337 -       wordlength = 1;                  \
72338 -        outb_p(0x48, ioaddr + EN0_DCFG); \
72339 -} while(0)
72340 -
72341 -#endif
72342 diff -Nru a/include/asm-h8300/aki3068net/timer_rate.h b/include/asm-h8300/aki3068net/timer_rate.h
72343 --- a/include/asm-h8300/aki3068net/timer_rate.h Sat Jul 19 09:19:25 2003
72344 +++ /dev/null   Wed Dec 31 16:00:00 1969
72345 @@ -1,9 +0,0 @@
72346 -#ifndef __H8300_AKI3068NET_TIMER_RATE__
72347 -#define __H8300_AKI3068NET_TIMER_RATE__
72348 -
72349 -#include <linux/config.h>
72350 -
72351 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
72352 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
72353 -
72354 -#endif
72355 diff -Nru a/include/asm-h8300/edosk2674/timer_rate.h b/include/asm-h8300/edosk2674/timer_rate.h
72356 --- a/include/asm-h8300/edosk2674/timer_rate.h  Sat Jul 19 09:18:09 2003
72357 +++ /dev/null   Wed Dec 31 16:00:00 1969
72358 @@ -1,4 +0,0 @@
72359 -#include <linux/config.h>
72360 -
72361 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
72362 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
72363 diff -Nru a/include/asm-h8300/h8300_smsc.h b/include/asm-h8300/h8300_smsc.h
72364 --- /dev/null   Wed Dec 31 16:00:00 1969
72365 +++ b/include/asm-h8300/h8300_smsc.h    Sun Aug 31 14:01:50 2003
72366 @@ -0,0 +1,20 @@
72367 +/****************************************************************************/
72368 +
72369 +/*
72370 + *     h8300_smsc.h -- SMSC in H8/300H and H8S Evalution Board.
72371 + *      
72372 + *     (C) Copyright 2003, Yoshinori Sato <ysato@users.sourceforge.jp>
72373 + */
72374 +
72375 +/****************************************************************************/
72376 +#ifndef        h8300smsc_h
72377 +#define        h8300smsc_h
72378 +/****************************************************************************/
72379 +
72380 +/* Such a description is OK ? */
72381 +#define H8300_SMSC_DEFINE
72382 +#include <asm/machine-depend.h>
72383 +#undef  H8300_SMSC_DEFINE
72384 +
72385 +/****************************************************************************/
72386 +#endif /* h8300smsc_h */
72387 diff -Nru a/include/asm-h8300/h8max/machine-depend.h b/include/asm-h8300/h8max/machine-depend.h
72388 --- a/include/asm-h8300/h8max/machine-depend.h  Thu Aug 21 22:56:17 2003
72389 +++ b/include/asm-h8300/h8max/machine-depend.h  Wed Aug 27 07:02:04 2003
72390 @@ -101,67 +101,3 @@
72391  }
72392  
72393  #endif
72394 -
72395 -/* H8MAX IDE I/F Config */
72396 -#ifdef H8300_IDE_DEFINE
72397 -
72398 -#define H8300_IDE_BASE 0x200000
72399 -#define H8300_IDE_CTRL 0x60000c
72400 -#define H8300_IDE_IRQ  5
72401 -#define H8300_IDE_REG_OFFSET 2
72402 -
72403 -#undef outb
72404 -#undef inb
72405 -#undef outb_p
72406 -#undef inb_p
72407 -#undef outsw
72408 -#undef insw
72409 -
72410 -#define outb(d,a) h8max_outb(d,(unsigned short *)a)
72411 -#define inb(a) h8max_inb((unsigned char *)a)
72412 -#define outb_p(d,a) h8max_outb(d,(unsigned short *)a)
72413 -#define inb_p(a) h8max_inb((unsigned char *)a)
72414 -#define outsw(addr,buf,len) h8max_outsw(addr,buf,len);
72415 -#define insw(addr,buf,len) h8max_insw(addr,buf,len);
72416 -
72417 -static inline void h8max_outb(unsigned short d,unsigned short *a)
72418 -{
72419 -       *a = d;
72420 -}
72421 -
72422 -static inline unsigned char h8max_inb(unsigned char *a)
72423 -{
72424 -       return *(a+1);
72425 -}
72426 -
72427 -static inline void h8max_outsw(void *addr, void *buf, int len)
72428 -{
72429 -       unsigned volatile short *ap = (unsigned volatile short *)addr;
72430 -       unsigned short *bp = (unsigned short *)buf;
72431 -       unsigned short d;
72432 -       while(len--) {
72433 -               d = *bp++;
72434 -               *ap = (d >> 8) | (d << 8);
72435 -       }
72436 -}
72437 -
72438 -static inline void h8max_insw(void *addr, void *buf, int len)
72439 -{
72440 -       unsigned volatile short *ap = (unsigned volatile short *)addr;
72441 -       unsigned short *bp = (unsigned short *)buf;
72442 -       unsigned short d;
72443 -       while(len--) {
72444 -               d = *ap;
72445 -               *bp++ = (d >> 8) | (d << 8);
72446 -       }
72447 -}
72448 -
72449 -static inline void target_ide_fix_driveid(struct hd_driveid *id)
72450 -{
72451 -       int c;
72452 -       unsigned short *p = (unsigned short *)id;
72453 -       for (c = 0; c < SECTOR_WORDS; c++, p++)
72454 -               *p = (*p >> 8) | (*p << 8);
72455 -}
72456 -
72457 -#endif
72458 diff -Nru a/include/asm-h8300/h8max/ne.h b/include/asm-h8300/h8max/ne.h
72459 --- a/include/asm-h8300/h8max/ne.h      Sat Jul 19 05:41:33 2003
72460 +++ /dev/null   Wed Dec 31 16:00:00 1969
72461 @@ -1,97 +0,0 @@
72462 -/* H8MAX RTL8019AS Config */
72463 -
72464 -#ifndef __H8300_H8MAX_NE__
72465 -#define __H8300_H8MAX_NE__
72466 -
72467 -#define NE2000_ADDR            0x800600
72468 -#define NE2000_IRQ              4
72469 -#define NE2000_IRQ_VECTOR      (12 + NE2000_IRQ)
72470 -#define        NE2000_BYTE             volatile unsigned short
72471 -
72472 -#define IER                     0xfee015
72473 -#define ISR                    0xfee016
72474 -#define IRQ_MASK               (1 << NE2000_IRQ)
72475 -/* sorry quick hack */
72476 -#if defined(outb)
72477 -# undef outb
72478 -#endif
72479 -#define outb(d,a)               h8max_outb((d),(a) - NE2000_ADDR)
72480 -#if defined(inb)
72481 -# undef inb
72482 -#endif
72483 -#define inb(a)                  h8max_inb((a) - NE2000_ADDR)
72484 -#if defined(outb_p)
72485 -# undef outb_p
72486 -#endif
72487 -#define outb_p(d,a)             h8max_outb((d),(a) - NE2000_ADDR)
72488 -#if defined(inb_p)
72489 -# undef inb_p
72490 -#endif
72491 -#define inb_p(a)                h8max_inb((a) - NE2000_ADDR)
72492 -#if defined(outsw)
72493 -# undef outsw
72494 -#endif
72495 -#define outsw(a,p,l)            h8max_outsw((a) - NE2000_ADDR,(unsigned short *)p,l)
72496 -#if defined(insw)
72497 -# undef insw
72498 -#endif
72499 -#define insw(a,p,l)             h8max_insw((a) - NE2000_ADDR,(unsigned short *)p,l)
72500 -#if defined(outsb)
72501 -# undef outsb
72502 -#endif
72503 -#define outsb(a,p,l)            h8max_outsb((a) - NE2000_ADDR,(unsigned char *)p,l)
72504 -#if defined(insb)
72505 -# undef insb
72506 -#endif
72507 -#define insb(a,p,l)             h8max_insb((a) - NE2000_ADDR,(unsigned char *)p,l)
72508 -
72509 -#define H8300_INIT_NE()                  \
72510 -do {                                     \
72511 -       wordlength = 2;                  \
72512 -       h8max_outb(0x49, ioaddr + EN0_DCFG); \
72513 -       SA_prom[14] = SA_prom[15] = 0x57;\
72514 -} while(0)
72515 -
72516 -static inline void h8max_outb(unsigned char d,unsigned char a)
72517 -{
72518 -       *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
72519 -}
72520 -
72521 -static inline unsigned char h8max_inb(unsigned char a)
72522 -{
72523 -       return *(unsigned char *)(NE2000_ADDR + (a << 1) +1);
72524 -}
72525 -
72526 -static inline void h8max_outsw(unsigned char a,unsigned short *p,unsigned long l)
72527 -{
72528 -       unsigned short d;
72529 -       for (; l != 0; --l, p++) {
72530 -               d = (((*p) >> 8) & 0xff) | ((*p) << 8);
72531 -               *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
72532 -       }
72533 -}
72534 -
72535 -static inline void h8max_insw(unsigned char a,unsigned short *p,unsigned long l)
72536 -{
72537 -       unsigned short d;
72538 -       for (; l != 0; --l, p++) {
72539 -               d = *(unsigned short *)(NE2000_ADDR + (a << 1));
72540 -               *p = (d << 8)|((d >> 8) & 0xff);
72541 -       }
72542 -}
72543 -
72544 -static inline void h8max_outsb(unsigned char a,unsigned char *p,unsigned long l)
72545 -{
72546 -       for (; l != 0; --l, p++) {
72547 -               *(unsigned short *)(NE2000_ADDR + (a << 1)) = *p;
72548 -       }
72549 -}
72550 -
72551 -static inline void h8max_insb(unsigned char a,unsigned char *p,unsigned long l)
72552 -{
72553 -       for (; l != 0; --l, p++) {
72554 -               *p = *((unsigned char *)(NE2000_ADDR + (a << 1))+1);
72555 -       }
72556 -}
72557 -
72558 -#endif
72559 diff -Nru a/include/asm-h8300/h8max/timer_rate.h b/include/asm-h8300/h8max/timer_rate.h
72560 --- a/include/asm-h8300/h8max/timer_rate.h      Sat Jul 19 09:19:25 2003
72561 +++ /dev/null   Wed Dec 31 16:00:00 1969
72562 @@ -1,10 +0,0 @@
72563 -#ifndef __H8300_H8MAX_TIMER_RATE__
72564 -#define __H8300_H8MAX_TIMER_RATE__
72565 -
72566 -#include <linux/config.h>
72567 -
72568 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
72569 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
72570 -
72571 -#endif
72572 -
72573 diff -Nru a/include/asm-h8300/ide.h b/include/asm-h8300/ide.h
72574 --- a/include/asm-h8300/ide.h   Thu Aug 21 08:55:15 2003
72575 +++ b/include/asm-h8300/ide.h   Wed Aug 27 07:12:57 2003
72576 @@ -16,145 +16,26 @@
72577  #ifdef __KERNEL__
72578  /****************************************************************************/
72579  
72580 -#include <linux/config.h>
72581 -#include <linux/interrupt.h>
72582 +void h8300_ide_print_resource(char *name, hw_regs_t *hw);
72583 +static inline int ide_default_irq(unsigned long base) { return 0; };
72584 +static inline ide_ioreg_t ide_default_io_base(int index) { return 0; };
72585  
72586 -#include <asm/setup.h>
72587 -#include <asm/io.h>
72588 -#include <asm/irq.h>
72589 -
72590 -/*
72591 - *     Some coldfire specifics.
72592 - */
72593 -
72594 -/*
72595 - *     Save some space, only have 1 interface.
72596 - */
72597 -#define MAX_HWIFS      1
72598 -
72599 -/*
72600 - *     Fix up things that may not have been provided.
72601 - */
72602 -
72603 -#undef SUPPORT_SLOW_DATA_PORTS
72604 -#define SUPPORT_SLOW_DATA_PORTS 0
72605 -
72606 -#undef SUPPORT_VLB_SYNC
72607 -#define SUPPORT_VLB_SYNC 0
72608 -
72609 -/* this definition is used only on startup .. */
72610 -#undef HD_DATA
72611 -#define HD_DATA NULL
72612 -
72613 -#define        DBGIDE(fmt,a...)
72614 -// #define     DBGIDE(fmt,a...) printk(fmt, ##a)
72615 -#define IDE_INLINE __inline__
72616 -// #define IDE_INLINE
72617 -
72618 -#define ide__sti()     __sti()
72619 -
72620 -/****************************************************************************/
72621 -
72622 -typedef union {
72623 -       unsigned all                    : 8;    /* all of the bits together */
72624 -       struct {
72625 -               unsigned bit7           : 1;    /* always 1 */
72626 -               unsigned lba            : 1;    /* using LBA instead of CHS */
72627 -               unsigned bit5           : 1;    /* always 1 */
72628 -               unsigned unit           : 1;    /* drive select number, 0 or 1 */
72629 -               unsigned head           : 4;    /* always zeros here */
72630 -       } b;
72631 -} select_t;
72632 -
72633 -/*
72634 - *     Our list of ports/irq's for different boards.
72635 - */
72636 -
72637 -/* machine depend header include */
72638 -#define H8300_IDE_DEFINE
72639 -#include <asm/machine-depend.h>
72640 -#undef  H8300_IDE_DEFINE
72641 -
72642 -/****************************************************************************/
72643 -
72644 -static IDE_INLINE int ide_default_irq(ide_ioreg_t base)
72645 +static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
72646 +        unsigned long ctrl_port, int *irq)
72647  {
72648 -       return H8300_IDE_IRQ+12;
72649  }
72650  
72651 -static IDE_INLINE ide_ioreg_t ide_default_io_base(int index)
72652 -{
72653 -       return (ide_ioreg_t)H8300_IDE_BASE;
72654 -}
72655  
72656 -/*
72657 - * Set up a hw structure for a specified data port, control port and IRQ.
72658 - * This should follow whatever the default interface uses.
72659 - */
72660 -static IDE_INLINE void ide_init_hwif_ports(
72661 -       hw_regs_t *hw,
72662 -       ide_ioreg_t data_port,
72663 -       ide_ioreg_t ctrl_port,
72664 -       int *irq)
72665 +static inline void ide_init_default_hwifs(void)
72666  {
72667 -       ide_ioreg_t reg = data_port;
72668 -       int i;
72669 -
72670 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
72671 -               hw->io_ports[i] = reg;
72672 -               reg += H8300_IDE_REG_OFFSET;
72673 -       }
72674 -       if (ctrl_port) {
72675 -               hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
72676 -       } else {
72677 -               hw->io_ports[IDE_CONTROL_OFFSET] = (ide_ioreg_t)H8300_IDE_CTRL;
72678 -       }
72679  }
72680  
72681 +#define MAX_HWIFS      1
72682  
72683 -/*
72684 - * This registers the standard ports for this architecture with the IDE
72685 - * driver.
72686 - */
72687 -static IDE_INLINE void ide_init_default_hwifs(void)
72688 -{
72689 -       hw_regs_t hw;
72690 -       ide_ioreg_t base;
72691 -       int index;
72692 -
72693 -       for (index = 0; index < MAX_HWIFS; index++) {
72694 -               base = ide_default_io_base(index);
72695 -               if (!base)
72696 -                       continue;
72697 -               memset(&hw, 0, sizeof(hw));
72698 -               ide_init_hwif_ports(&hw, base, 0, NULL);
72699 -               hw.irq = ide_default_irq(base);
72700 -               ide_register_hw(&hw, NULL);
72701 -       }
72702 -}
72703 -
72704 -#define ide_request_irq(irq,hand,flg,dev,id)   request_irq((irq),(hand),(flg),(dev),(id))
72705 -#define ide_free_irq(irq,dev_id)               free_irq((irq), (dev_id))
72706 -#define ide_check_region(from,extent)          (0)
72707 -#define ide_request_region(from,extent,name)   do {} while(0)
72708 -#define ide_release_region(from,extent)                do {} while(0)
72709 -
72710 -/*
72711 - * The following are not needed for the non-m68k ports
72712 - */
72713 -#define ide_ack_intr(hwif)             (1)
72714 -#define ide_fix_driveid(id)            target_ide_fix_driveid(id)
72715 -#define ide_release_lock(lock)         do {} while (0)
72716 -#define ide_get_lock(lock, hdlr, data) do {} while (0)
72717 -
72718 -static IDE_INLINE void ide_print_resource(char *name,hw_regs_t *hw)
72719 -{
72720 -       printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
72721 -               (unsigned int)hw->io_ports[IDE_DATA_OFFSET],
72722 -               (unsigned int)hw->io_ports[IDE_DATA_OFFSET]+(8*H8300_IDE_REG_OFFSET)-1,
72723 -               (unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
72724 -               hw->irq);
72725 -}
72726 +#define __ide_mm_insw(port,addr,count)  do { } while(0)
72727 +#define __ide_mm_insl(port,addr,count)  do { } while(0)
72728 +#define __ide_mm_outsw(port,addr,count) do { } while(0)
72729 +#define __ide_mm_outsl(port,addr,count) do { } while(0)
72730  
72731  /****************************************************************************/
72732  #endif /* __KERNEL__ */
72733 diff -Nru a/include/asm-h8300/irq.h b/include/asm-h8300/irq.h
72734 --- a/include/asm-h8300/irq.h   Sun Jul 13 23:17:52 2003
72735 +++ b/include/asm-h8300/irq.h   Wed Aug 27 07:02:04 2003
72736 @@ -3,11 +3,35 @@
72737  
72738  #include <asm/ptrace.h>
72739  
72740 -#if defined(CONFIG_CPU_H8300H)
72741 +#if defined(__H8300H__)
72742  #define NR_IRQS 64
72743 +#define EXT_IRQ0 12
72744 +#define EXT_IRQ1 13
72745 +#define EXT_IRQ2 14
72746 +#define EXT_IRQ3 15
72747 +#define EXT_IRQ4 16
72748 +#define EXT_IRQ5 17
72749 +#define EXT_IRQ6 18
72750 +#define EXT_IRQ7 19
72751  #endif
72752  #if defined(CONFIG_CPU_H8S)
72753  #define NR_IRQS 128
72754 +#define EXT_IRQ0 16
72755 +#define EXT_IRQ1 17
72756 +#define EXT_IRQ2 18
72757 +#define EXT_IRQ3 19
72758 +#define EXT_IRQ4 20
72759 +#define EXT_IRQ5 21
72760 +#define EXT_IRQ6 22
72761 +#define EXT_IRQ7 23
72762 +#define EXT_IRQ8 24
72763 +#define EXT_IRQ9 25
72764 +#define EXT_IRQ10 26
72765 +#define EXT_IRQ11 27
72766 +#define EXT_IRQ12 28
72767 +#define EXT_IRQ13 29
72768 +#define EXT_IRQ14 30
72769 +#define EXT_IRQ15 31
72770  #endif
72771  
72772  static __inline__ int irq_canonicalize(int irq)
72773 diff -Nru a/include/asm-h8300/machine-depend.h b/include/asm-h8300/machine-depend.h
72774 --- a/include/asm-h8300/machine-depend.h        Thu Aug 21 22:56:18 2003
72775 +++ /dev/null   Wed Dec 31 16:00:00 1969
72776 @@ -1,70 +0,0 @@
72777 -/* EDOSK2674 board depend header */
72778 -
72779 -/* TIMER rate define */
72780 -#ifdef H8300_TIMER_DEFINE
72781 -#define H8300_TIMER_COUNT_DATA 33000*10/8192
72782 -#define H8300_TIMER_FREQ 33000*1000/8192
72783 -#endif
72784 -
72785 -/* EDOSK-2674R SMSC Network Controler Target Depend impliments */
72786 -#ifdef H8300_SMSC_DEFINE
72787 -
72788 -#define SMSC_BASE 0xf80000
72789 -#define SMSC_IRQ 16
72790 -
72791 -/* sorry quick hack */
72792 -#if defined(outw)
72793 -# undef outw
72794 -#endif
72795 -#define outw(d,a) edosk2674_smsc_outw(d,(volatile unsigned short *)(a))
72796 -#if defined(inw)
72797 -# undef inw
72798 -#endif
72799 -#define inw(a) edosk2674_smsc_inw((volatile unsigned short *)(a))
72800 -#if defined(outsw)
72801 -# undef outsw
72802 -#endif
72803 -#define outsw(a,p,l) edosk2674_smsc_outsw((volatile unsigned short *)(a),p,l)
72804 -#if defined(insw)
72805 -# undef insw
72806 -#endif
72807 -#define insw(a,p,l) edosk2674_smsc_insw((volatile unsigned short *)(a),p,l)
72808 -
72809 -static inline void edosk2674_smsc_outw(
72810 -       unsigned short d,
72811 -       volatile unsigned short *a
72812 -       )
72813 -{
72814 -       *a = (d >> 8) | (d << 8);
72815 -}
72816 -
72817 -static inline unsigned short edosk2674_smsc_inw(
72818 -       volatile unsigned short *a
72819 -       )
72820 -{
72821 -       unsigned short d;
72822 -       d = *a;
72823 -       return (d >> 8) | (d << 8);
72824 -}
72825 -
72826 -static inline void edosk2674_smsc_outsw(
72827 -       volatile unsigned short *a,
72828 -       unsigned short *p,
72829 -       unsigned long l
72830 -       )
72831 -{
72832 -       for (; l != 0; --l, p++)
72833 -               *a = *p;
72834 -}
72835 -
72836 -static inline void edosk2674_smsc_insw(
72837 -       volatile unsigned short *a,
72838 -       unsigned short *p,
72839 -       unsigned long l
72840 -       )
72841 -{
72842 -       for (; l != 0; --l, p++)
72843 -               *p = *a;
72844 -}
72845 -
72846 -#endif
72847 diff -Nru a/include/asm-h8300/pci.h b/include/asm-h8300/pci.h
72848 --- a/include/asm-h8300/pci.h   Mon Jun  9 09:25:52 2003
72849 +++ b/include/asm-h8300/pci.h   Wed Aug 27 07:02:04 2003
72850 @@ -19,4 +19,6 @@
72851         /* We don't do dynamic PCI IRQ allocation */
72852  }
72853  
72854 +#define PCI_DMA_BUS_IS_PHYS    (1)
72855 +
72856  #endif /* _ASM_H8300_PCI_H */
72857 diff -Nru a/include/asm-h8300/semaphore.h b/include/asm-h8300/semaphore.h
72858 --- a/include/asm-h8300/semaphore.h     Thu Aug 21 08:55:15 2003
72859 +++ b/include/asm-h8300/semaphore.h     Wed Sep  3 23:40:12 2003
72860 @@ -90,6 +90,7 @@
72861  #if WAITQUEUE_DEBUG
72862         CHECK_MAGIC(sem->__magic);
72863  #endif
72864 +       might_sleep();
72865  
72866         count = &(sem->count);
72867         __asm__ __volatile__(
72868 @@ -117,6 +118,7 @@
72869  #if WAITQUEUE_DEBUG
72870         CHECK_MAGIC(sem->__magic);
72871  #endif
72872 +       might_sleep();
72873  
72874         count = &(sem->count);
72875         __asm__ __volatile__(
72876 diff -Nru a/include/asm-i386/apic.h b/include/asm-i386/apic.h
72877 --- a/include/asm-i386/apic.h   Sun Jun 15 11:00:08 2003
72878 +++ b/include/asm-i386/apic.h   Fri Aug 29 03:51:17 2003
72879 @@ -64,6 +64,8 @@
72880         apic_write_around(APIC_EOI, 0);
72881  }
72882  
72883 +extern void (*wait_timer_tick)(void);
72884 +
72885  extern int get_maxlvt(void);
72886  extern void clear_local_APIC(void);
72887  extern void connect_bsp_APIC (void);
72888 diff -Nru a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h
72889 --- a/include/asm-i386/bugs.h   Sun Apr 20 12:24:22 2003
72890 +++ b/include/asm-i386/bugs.h   Sun Aug 31 16:14:48 2003
72891 @@ -193,11 +193,6 @@
72892             && (boot_cpu_data.x86_mask < 6 || boot_cpu_data.x86_mask == 11))
72893                 panic("Kernel compiled for PMMX+, assumes a local APIC without the read-before-write bug!");
72894  #endif
72895 -
72896 -#ifdef CONFIG_X86_SSE2
72897 -       if (!cpu_has_sse2)
72898 -               panic("Kernel compiled for SSE2, CPU doesn't have it.");
72899 -#endif
72900  }
72901  
72902  extern void alternative_instructions(void);
72903 diff -Nru a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h
72904 --- /dev/null   Wed Dec 31 16:00:00 1969
72905 +++ b/include/asm-i386/hpet.h   Wed Sep  3 23:40:07 2003
72906 @@ -0,0 +1,115 @@
72907 +
72908 +#ifndef _I386_HPET_H
72909 +#define _I386_HPET_H
72910 +
72911 +#ifdef CONFIG_HPET_TIMER
72912 +
72913 +#include <linux/errno.h>
72914 +#include <linux/module.h>
72915 +#include <linux/sched.h>
72916 +#include <linux/kernel.h>
72917 +#include <linux/param.h>
72918 +#include <linux/string.h>
72919 +#include <linux/mm.h>
72920 +#include <linux/interrupt.h>
72921 +#include <linux/time.h>
72922 +#include <linux/delay.h>
72923 +#include <linux/init.h>
72924 +#include <linux/smp.h>
72925 +
72926 +#include <asm/io.h>
72927 +#include <asm/smp.h>
72928 +#include <asm/irq.h>
72929 +#include <asm/msr.h>
72930 +#include <asm/delay.h>
72931 +#include <asm/mpspec.h>
72932 +#include <asm/uaccess.h>
72933 +#include <asm/processor.h>
72934 +
72935 +#include <linux/timex.h>
72936 +#include <linux/config.h>
72937 +
72938 +#include <asm/fixmap.h>
72939 +
72940 +/*
72941 + * Documentation on HPET can be found at:
72942 + *      http://www.intel.com/ial/home/sp/pcmmspec.htm
72943 + *      ftp://download.intel.com/ial/home/sp/mmts098.pdf
72944 + */
72945 +
72946 +#define HPET_MMAP_SIZE 1024
72947 +
72948 +#define HPET_ID                0x000
72949 +#define HPET_PERIOD    0x004
72950 +#define HPET_CFG       0x010
72951 +#define HPET_STATUS    0x020
72952 +#define HPET_COUNTER   0x0f0
72953 +#define HPET_T0_CFG    0x100
72954 +#define HPET_T0_CMP    0x108
72955 +#define HPET_T0_ROUTE  0x110
72956 +#define HPET_T1_CFG    0x120
72957 +#define HPET_T1_CMP    0x128
72958 +#define HPET_T1_ROUTE  0x130
72959 +#define HPET_T2_CFG    0x140
72960 +#define HPET_T2_CMP    0x148
72961 +#define HPET_T2_ROUTE  0x150
72962 +
72963 +#define HPET_ID_VENDOR 0xffff0000
72964 +#define HPET_ID_LEGSUP 0x00008000
72965 +#define HPET_ID_NUMBER 0x00001f00
72966 +#define HPET_ID_REV    0x000000ff
72967 +
72968 +#define HPET_ID_VENDOR_SHIFT   16
72969 +#define HPET_ID_VENDOR_8086    0x8086
72970 +
72971 +#define HPET_CFG_ENABLE        0x001
72972 +#define HPET_CFG_LEGACY        0x002
72973 +
72974 +#define HPET_TN_ENABLE         0x004
72975 +#define HPET_TN_PERIODIC       0x008
72976 +#define HPET_TN_PERIODIC_CAP   0x010
72977 +#define HPET_TN_SETVAL         0x040
72978 +#define HPET_TN_32BIT          0x100
72979 +
72980 +/* Use our own asm for 64 bit multiply/divide */
72981 +#define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in)                   \
72982 +               __asm__ __volatile__("mull %2"                          \
72983 +                               :"=a" (eax_out), "=d" (edx_out)         \
72984 +                               :"r" (reg_in), "0" (eax_in))
72985 +
72986 +#define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in)            \
72987 +               __asm__ __volatile__("divl %2"                          \
72988 +                               :"=a" (eax_out), "=d" (edx_out)         \
72989 +                               :"r" (reg_in), "0" (eax_in), "1" (edx_in))
72990 +
72991 +#define KERNEL_TICK_USEC       (1000000UL/HZ)  /* tick value in microsec */
72992 +/* Max HPET Period is 10^8 femto sec as in HPET spec */
72993 +#define HPET_MAX_PERIOD (100000000UL)
72994 +/*
72995 + * Min HPET period is 10^5 femto sec just for safety. If it is less than this,
72996 + * then 32 bit HPET counter wrapsaround in less than 0.5 sec.
72997 + */
72998 +#define HPET_MIN_PERIOD (100000UL)
72999 +
73000 +extern unsigned long hpet_period;      /* fsecs / HPET clock */
73001 +extern unsigned long hpet_tick;        /* hpet clks count per tick */
73002 +extern unsigned long hpet_address;     /* hpet memory map physical address */
73003 +
73004 +extern int hpet_rtc_timer_init(void);
73005 +extern int hpet_enable(void);
73006 +extern int is_hpet_enabled(void);
73007 +extern int is_hpet_capable(void);
73008 +extern int hpet_readl(unsigned long a);
73009 +extern void hpet_writel(unsigned long d, unsigned long a);
73010 +
73011 +#ifdef CONFIG_HPET_EMULATE_RTC
73012 +extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
73013 +extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
73014 +extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec);
73015 +extern int hpet_set_periodic_freq(unsigned long freq);
73016 +extern int hpet_rtc_dropped_irq(void);
73017 +extern int hpet_rtc_timer_init(void);
73018 +extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
73019 +#endif /* CONFIG_HPET_EMULATE_RTC */
73020 +#endif /* CONFIG_HPET_TIMER */
73021 +#endif /* _I386_HPET_H */
73022 diff -Nru a/include/asm-i386/i387.h b/include/asm-i386/i387.h
73023 --- a/include/asm-i386/i387.h   Fri May  9 14:22:55 2003
73024 +++ b/include/asm-i386/i387.h   Tue Sep  2 00:37:21 2003
73025 @@ -26,7 +26,9 @@
73026  extern void kernel_fpu_begin(void);
73027  #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
73028  
73029 -
73030 +/*
73031 + * These must be called with preempt disabled
73032 + */
73033  static inline void __save_init_fpu( struct task_struct *tsk )
73034  {
73035         if ( cpu_has_fxsr ) {
73036 @@ -39,19 +41,12 @@
73037         tsk->thread_info->status &= ~TS_USEDFPU;
73038  }
73039  
73040 -static inline void save_init_fpu( struct task_struct *tsk )
73041 -{
73042 -       __save_init_fpu(tsk);
73043 -       stts();
73044 -}
73045 -
73046 -
73047 -#define unlazy_fpu( tsk ) do { \
73048 +#define __unlazy_fpu( tsk ) do { \
73049         if ((tsk)->thread_info->status & TS_USEDFPU) \
73050                 save_init_fpu( tsk ); \
73051  } while (0)
73052  
73053 -#define clear_fpu( tsk )                                       \
73054 +#define __clear_fpu( tsk )                                     \
73055  do {                                                           \
73056         if ((tsk)->thread_info->status & TS_USEDFPU) {          \
73057                 asm volatile("fwait");                          \
73058 @@ -60,6 +55,30 @@
73059         }                                                       \
73060  } while (0)
73061  
73062 +
73063 +/*
73064 + * These disable preemption on their own and are safe
73065 + */
73066 +static inline void save_init_fpu( struct task_struct *tsk )
73067 +{
73068 +       preempt_disable();
73069 +       __save_init_fpu(tsk);
73070 +       stts();
73071 +       preempt_enable();
73072 +}
73073 +
73074 +#define unlazy_fpu( tsk ) do { \
73075 +       preempt_disable();      \
73076 +       __unlazy_fpu(tsk);      \
73077 +       preempt_enable();       \
73078 +} while (0)
73079 +
73080 +#define clear_fpu( tsk ) do {  \
73081 +       preempt_disable();      \
73082 +       __clear_fpu( tsk );     \
73083 +       preempt_enable();       \
73084 +} while (0)
73085 +                                       \
73086  /*
73087   * FPU state interaction...
73088   */
73089 diff -Nru a/include/asm-i386/processor.h b/include/asm-i386/processor.h
73090 --- a/include/asm-i386/processor.h      Wed Aug 20 11:14:51 2003
73091 +++ b/include/asm-i386/processor.h      Sun Aug 31 16:13:54 2003
73092 @@ -578,6 +578,8 @@
73093  #define ARCH_HAS_PREFETCH
73094  extern inline void prefetch(const void *x)
73095  {
73096 +       if (cpu_data[0].x86_vendor == X86_VENDOR_AMD)
73097 +               return;         /* Some athlons fault if the address is bad */
73098         alternative_input(ASM_NOP4,
73099                           "prefetchnta (%1)",
73100                           X86_FEATURE_XMM,
73101 diff -Nru a/include/asm-i386/smp.h b/include/asm-i386/smp.h
73102 --- a/include/asm-i386/smp.h    Mon Aug 18 19:46:23 2003
73103 +++ b/include/asm-i386/smp.h    Sun Aug 31 16:14:42 2003
73104 @@ -32,7 +32,6 @@
73105   */
73106   
73107  extern void smp_alloc_memory(void);
73108 -extern physid_mask_t phys_cpu_present_map;
73109  extern int pic_mode;
73110  extern int smp_num_siblings;
73111  extern int cpu_sibling_map[];
73112 diff -Nru a/include/asm-i386/termios.h b/include/asm-i386/termios.h
73113 --- a/include/asm-i386/termios.h        Mon Feb  4 23:41:04 2002
73114 +++ b/include/asm-i386/termios.h        Wed Sep  3 23:40:16 2003
73115 @@ -58,6 +58,7 @@
73116  #define N_HCI          15  /* Bluetooth HCI UART */
73117  
73118  #ifdef __KERNEL__
73119 +#include <linux/module.h>
73120  
73121  /*     intr=^C         quit=^\         erase=del       kill=^U
73122         eof=^D          vtime=\0        vmin=\1         sxtc=\0
73123 @@ -101,6 +102,8 @@
73124  #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
73125  #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
73126  
73127 +#define MODULE_ALIAS_LDISC(ldisc) \
73128 +       MODULE_ALIAS("tty-ldisc-" __stringify(ldisc))
73129  #endif /* __KERNEL__ */
73130  
73131  #endif /* _I386_TERMIOS_H */
73132 diff -Nru a/include/asm-i386/timer.h b/include/asm-i386/timer.h
73133 --- a/include/asm-i386/timer.h  Wed Jul  2 21:21:34 2003
73134 +++ b/include/asm-i386/timer.h  Sun Aug 31 16:15:21 2003
73135 @@ -38,4 +38,8 @@
73136  extern struct timer_opts timer_cyclone;
73137  #endif
73138  
73139 +#ifdef CONFIG_HPET_TIMER
73140 +extern struct timer_opts timer_hpet;
73141 +#endif
73142 +
73143  #endif
73144 diff -Nru a/include/asm-ia64/hw_irq.h b/include/asm-ia64/hw_irq.h
73145 --- a/include/asm-ia64/hw_irq.h Tue Jul 29 08:53:10 2003
73146 +++ b/include/asm-ia64/hw_irq.h Tue Aug 26 15:09:18 2003
73147 @@ -39,9 +39,9 @@
73148   * Vectors 0x10-0x1f are used for low priority interrupts, e.g. CMCI.
73149   */
73150  #define IA64_CPEP_VECTOR               0x1c    /* corrected platform error polling vector */
73151 -#define IA64_CMCP_VECTOR               0x1d    /* correctable machine-check polling vector */
73152 +#define IA64_CMCP_VECTOR               0x1d    /* corrected machine-check polling vector */
73153  #define IA64_CPE_VECTOR                        0x1e    /* corrected platform error interrupt vector */
73154 -#define IA64_CMC_VECTOR                        0x1f    /* correctable machine-check interrupt vector */
73155 +#define IA64_CMC_VECTOR                        0x1f    /* corrected machine-check interrupt vector */
73156  /*
73157   * Vectors 0x20-0x2f are reserved for legacy ISA IRQs.
73158   */
73159 diff -Nru a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
73160 --- a/include/asm-ia64/pci.h    Tue Jun 24 14:16:56 2003
73161 +++ b/include/asm-ia64/pci.h    Mon Aug 25 14:45:43 2003
73162 @@ -74,7 +74,7 @@
73163  #define pci_dac_dma_supported(pci_dev, mask)           (1)
73164  #define pci_dac_page_to_dma(dev,pg,off,dir)            ((dma_addr_t) page_to_bus(pg) + (off))
73165  #define pci_dac_dma_to_page(dev,dma_addr)              (virt_to_page(bus_to_virt(dma_addr)))
73166 -#define pci_dac_dma_to_offset(dev,dma_addr)            ((dma_addr) & ~PAGE_MASK)
73167 +#define pci_dac_dma_to_offset(dev,dma_addr)            offset_in_page(dma_addr)
73168  #define pci_dac_dma_sync_single(dev,dma_addr,len,dir)  do { mb(); } while (0)
73169  
73170  #define sg_dma_len(sg)         ((sg)->dma_length)
73171 diff -Nru a/include/asm-ia64/semaphore.h b/include/asm-ia64/semaphore.h
73172 --- a/include/asm-ia64/semaphore.h      Mon Feb  4 23:55:11 2002
73173 +++ b/include/asm-ia64/semaphore.h      Wed Sep  3 23:40:12 2003
73174 @@ -73,6 +73,7 @@
73175  #if WAITQUEUE_DEBUG
73176         CHECK_MAGIC(sem->__magic);
73177  #endif
73178 +       might_sleep();
73179         if (atomic_dec_return(&sem->count) < 0)
73180                 __down(sem);
73181  }
73182 @@ -89,6 +90,7 @@
73183  #if WAITQUEUE_DEBUG
73184         CHECK_MAGIC(sem->__magic);
73185  #endif
73186 +       might_sleep();
73187         if (atomic_dec_return(&sem->count) < 0)
73188                 ret = __down_interruptible(sem);
73189         return ret;
73190 diff -Nru a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
73191 --- a/include/asm-ia64/unistd.h Tue Aug 19 23:13:40 2003
73192 +++ b/include/asm-ia64/unistd.h Mon Aug 25 14:47:33 2003
73193 @@ -248,6 +248,7 @@
73194  #define __NR_sys_clock_nanosleep       1256
73195  #define __NR_sys_fstatfs64             1257
73196  #define __NR_sys_statfs64              1258
73197 +#define __NR_fadvises64_64             1259
73198  
73199  #ifdef __KERNEL__
73200  
73201 diff -Nru a/include/asm-m68k/local.h b/include/asm-m68k/local.h
73202 --- /dev/null   Wed Dec 31 16:00:00 1969
73203 +++ b/include/asm-m68k/local.h  Sun Jul 27 17:23:16 2003
73204 @@ -0,0 +1,6 @@
73205 +#ifndef _ASM_M68K_LOCAL_H
73206 +#define _ASM_M68K_LOCAL_H
73207 +
73208 +#include <asm-generic/local.h>
73209 +
73210 +#endif /* _ASM_M68K_LOCAL_H */
73211 diff -Nru a/include/asm-m68k/sections.h b/include/asm-m68k/sections.h
73212 --- /dev/null   Wed Dec 31 16:00:00 1969
73213 +++ b/include/asm-m68k/sections.h       Sun Jul 27 17:23:16 2003
73214 @@ -0,0 +1,6 @@
73215 +#ifndef _ASM_M68K_SECTIONS_H
73216 +#define _ASM_M68K_SECTIONS_H
73217 +
73218 +#include <asm-generic/sections.h>
73219 +
73220 +#endif /* _ASM_M68K_SECTIONS_H */
73221 diff -Nru a/include/asm-m68k/semaphore.h b/include/asm-m68k/semaphore.h
73222 --- a/include/asm-m68k/semaphore.h      Mon Feb  4 18:18:56 2002
73223 +++ b/include/asm-m68k/semaphore.h      Wed Sep  3 23:40:12 2003
73224 @@ -89,7 +89,7 @@
73225  #if WAITQUEUE_DEBUG
73226         CHECK_MAGIC(sem->__magic);
73227  #endif
73228 -
73229 +       might_sleep();
73230         __asm__ __volatile__(
73231                 "| atomic down operation\n\t"
73232                 "subql #1,%0@\n\t"
73233 @@ -112,7 +112,7 @@
73234  #if WAITQUEUE_DEBUG
73235         CHECK_MAGIC(sem->__magic);
73236  #endif
73237 -
73238 +       might_sleep();
73239         __asm__ __volatile__(
73240                 "| atomic interruptible down operation\n\t"
73241                 "subql #1,%1@\n\t"
73242 diff -Nru a/include/asm-m68k/system.h b/include/asm-m68k/system.h
73243 --- a/include/asm-m68k/system.h Wed Feb 26 10:53:19 2003
73244 +++ b/include/asm-m68k/system.h Tue Aug 12 05:48:28 2003
73245 @@ -36,9 +36,12 @@
73246  #define switch_to(prev,next,last) do { \
73247    register void *_prev __asm__ ("a0") = (prev); \
73248    register void *_next __asm__ ("a1") = (next); \
73249 +  register void *_last __asm__ ("d1"); \
73250    __asm__ __volatile__("jbsr resume" \
73251 -                      : : "a" (_prev), "a" (_next) \
73252 -                      : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1"); \
73253 +                      : "=a" (_prev), "=a" (_next), "=d" (_last) \
73254 +                      : "0" (_prev), "1" (_next) \
73255 +                      : "d0", "d2", "d3", "d4", "d5"); \
73256 +  (last) = _last; \
73257  } while (0)
73258  
73259  
73260 diff -Nru a/include/asm-m68knommu/irq.h b/include/asm-m68knommu/irq.h
73261 --- a/include/asm-m68knommu/irq.h       Fri Nov  1 08:37:46 2002
73262 +++ b/include/asm-m68knommu/irq.h       Sat Aug 23 06:08:54 2003
73263 @@ -2,6 +2,7 @@
73264  #define _M68K_IRQ_H_
73265  
73266  #include <linux/config.h>
73267 +#include <linux/interrupt.h>
73268  #include <asm/ptrace.h>
73269  
73270  #ifdef CONFIG_COLDFIRE
73271 @@ -62,7 +63,7 @@
73272  extern void (*mach_disable_irq)(unsigned int);
73273  
73274  extern int sys_request_irq(unsigned int, 
73275 -       void (*)(int, void *, struct pt_regs *), 
73276 +       irqreturn_t (*)(int, void *, struct pt_regs *), 
73277         unsigned long, const char *, void *);
73278  extern void sys_free_irq(unsigned int, void *);
73279  
73280 @@ -91,7 +92,7 @@
73281   * interrupt source (if it supports chaining).
73282   */
73283  typedef struct irq_node {
73284 -       void            (*handler)(int, void *, struct pt_regs *);
73285 +       irqreturn_t     (*handler)(int, void *, struct pt_regs *);
73286         unsigned long   flags;
73287         void            *dev_id;
73288         const char      *devname;
73289 @@ -102,7 +103,7 @@
73290   * This structure has only 4 elements for speed reasons
73291   */
73292  typedef struct irq_handler {
73293 -       void            (*handler)(int, void *, struct pt_regs *);
73294 +       irqreturn_t     (*handler)(int, void *, struct pt_regs *);
73295         unsigned long   flags;
73296         void            *dev_id;
73297         const char      *devname;
73298 diff -Nru a/include/asm-m68knommu/local.h b/include/asm-m68knommu/local.h
73299 --- /dev/null   Wed Dec 31 16:00:00 1969
73300 +++ b/include/asm-m68knommu/local.h     Sat Aug 23 06:08:54 2003
73301 @@ -0,0 +1,6 @@
73302 +#ifndef __M68KNOMMU_LOCAL_H
73303 +#define __M68KNOMMU_LOCAL_H
73304 +
73305 +#include <asm-generic/local.h>
73306 +
73307 +#endif /* __M68KNOMMU_LOCAL_H */
73308 diff -Nru a/include/asm-m68knommu/sections.h b/include/asm-m68knommu/sections.h
73309 --- /dev/null   Wed Dec 31 16:00:00 1969
73310 +++ b/include/asm-m68knommu/sections.h  Sat Aug 23 06:08:54 2003
73311 @@ -0,0 +1,7 @@
73312 +#ifndef _M68KNOMMU_SECTIONS_H
73313 +#define _M68KNOMMU_SECTIONS_H
73314 +
73315 +/* nothing to see, move along */
73316 +#include <asm-generic/sections.h>
73317 +
73318 +#endif
73319 diff -Nru a/include/asm-m68knommu/semaphore.h b/include/asm-m68knommu/semaphore.h
73320 --- a/include/asm-m68knommu/semaphore.h Wed Jul  2 18:18:30 2003
73321 +++ b/include/asm-m68knommu/semaphore.h Wed Sep  3 23:40:12 2003
73322 @@ -88,7 +88,7 @@
73323  #if WAITQUEUE_DEBUG
73324         CHECK_MAGIC(sem->__magic);
73325  #endif
73326 -
73327 +       might_sleep();
73328         __asm__ __volatile__(
73329                 "| atomic down operation\n\t"
73330                 "movel  %0, %%a1\n\t"
73331 @@ -108,7 +108,7 @@
73332  #if WAITQUEUE_DEBUG
73333         CHECK_MAGIC(sem->__magic);
73334  #endif
73335 -
73336 +       might_sleep();
73337         __asm__ __volatile__(
73338                 "| atomic down operation\n\t"
73339                 "movel  %1, %%a1\n\t"
73340 diff -Nru a/include/asm-mips/semaphore.h b/include/asm-mips/semaphore.h
73341 --- a/include/asm-mips/semaphore.h      Tue Apr 22 18:18:46 2003
73342 +++ b/include/asm-mips/semaphore.h      Wed Sep  3 23:40:12 2003
73343 @@ -88,6 +88,7 @@
73344  #if WAITQUEUE_DEBUG
73345         CHECK_MAGIC(sem->__magic);
73346  #endif
73347 +       might_sleep();
73348         if (atomic_dec_return(&sem->count) < 0)
73349                 __down(sem);
73350  }
73351 @@ -103,6 +104,7 @@
73352  #if WAITQUEUE_DEBUG
73353         CHECK_MAGIC(sem->__magic);
73354  #endif
73355 +       might_sleep();
73356         if (atomic_dec_return(&sem->count) < 0)
73357                 ret = __down_interruptible(sem);
73358         return ret;
73359 diff -Nru a/include/asm-parisc/semaphore.h b/include/asm-parisc/semaphore.h
73360 --- a/include/asm-parisc/semaphore.h    Sat Jul 20 02:52:25 2002
73361 +++ b/include/asm-parisc/semaphore.h    Wed Sep  3 23:40:12 2003
73362 @@ -84,7 +84,7 @@
73363  #if WAITQUEUE_DEBUG
73364         CHECK_MAGIC(sem->__magic);
73365  #endif
73366 -
73367 +       might_sleep();
73368         spin_lock_irq(&sem->sentry);
73369         if (sem->count > 0) {
73370                 sem->count--;
73371 @@ -100,7 +100,7 @@
73372  #if WAITQUEUE_DEBUG
73373         CHECK_MAGIC(sem->__magic);
73374  #endif
73375 -
73376 +       might_sleep();
73377         spin_lock_irq(&sem->sentry);
73378         if (sem->count > 0) {
73379                 sem->count--;
73380 diff -Nru a/include/asm-ppc/cpm_8260.h b/include/asm-ppc/cpm_8260.h
73381 --- a/include/asm-ppc/cpm_8260.h        Sun Sep 15 21:52:03 2002
73382 +++ b/include/asm-ppc/cpm_8260.h        Thu Aug 21 15:26:43 2003
73383 @@ -195,7 +195,7 @@
73384  
73385  /* SMC uart mode register (Internal memory map).
73386  */
73387 -#define        SMCMR_REN       ((ushort)0x0001)
73388 +#define SMCMR_REN      ((ushort)0x0001)
73389  #define SMCMR_TEN      ((ushort)0x0002)
73390  #define SMCMR_DM       ((ushort)0x000c)
73391  #define SMCMR_SM_GCI   ((ushort)0x0000)
73392 @@ -212,10 +212,12 @@
73393  
73394  /* SMC Event and Mask register.
73395  */
73396 -#define        SMCM_TXE        ((unsigned char)0x10)
73397 -#define        SMCM_BSY        ((unsigned char)0x04)
73398 -#define        SMCM_TX         ((unsigned char)0x02)
73399 -#define        SMCM_RX         ((unsigned char)0x01)
73400 +#define SMCM_BRKE       ((unsigned char)0x40)   /* When in UART Mode */
73401 +#define SMCM_BRK        ((unsigned char)0x10)   /* When in UART Mode */
73402 +#define SMCM_TXE       ((unsigned char)0x10)
73403 +#define SMCM_BSY       ((unsigned char)0x04)
73404 +#define SMCM_TX                ((unsigned char)0x02)
73405 +#define SMCM_RX                ((unsigned char)0x01)
73406  
73407  /* Baud rate generators.
73408  */
73409 @@ -314,10 +316,10 @@
73410  
73411  /* SCC Event and Mask register.
73412  */
73413 -#define        SCCM_TXE        ((unsigned char)0x10)
73414 -#define        SCCM_BSY        ((unsigned char)0x04)
73415 -#define        SCCM_TX         ((unsigned char)0x02)
73416 -#define        SCCM_RX         ((unsigned char)0x01)
73417 +#define SCCM_TXE       ((unsigned char)0x10)
73418 +#define SCCM_BSY       ((unsigned char)0x04)
73419 +#define SCCM_TX                ((unsigned char)0x02)
73420 +#define SCCM_RX                ((unsigned char)0x01)
73421  
73422  typedef struct scc_param {
73423         ushort  scc_rbase;      /* Rx Buffer descriptor base address */
73424 diff -Nru a/include/asm-ppc/ibm44x.h b/include/asm-ppc/ibm44x.h
73425 --- /dev/null   Wed Dec 31 16:00:00 1969
73426 +++ b/include/asm-ppc/ibm44x.h  Wed Sep  3 02:18:44 2003
73427 @@ -0,0 +1,435 @@
73428 +/*
73429 + * include/asm-ppc/ibm44x.h
73430 + *
73431 + * PPC44x definitions
73432 + *
73433 + * Matt Porter <mporter@mvista.com>
73434 + *
73435 + * Copyright 2002-2003 MontaVista Software Inc.
73436 + *
73437 + * This program is free software; you can redistribute  it and/or modify it
73438 + * under  the terms of  the GNU General  Public License as published by the
73439 + * Free Software Foundation;  either version 2 of the  License, or (at your
73440 + * option) any later version.
73441 + */
73442 +
73443 +#ifdef __KERNEL__
73444 +#ifndef __ASM_IBM44x_H__
73445 +#define __ASM_IBM44x_H__
73446 +
73447 +#include <linux/config.h>
73448 +
73449 +#ifndef __ASSEMBLY__
73450 +/*
73451 + * Data structure defining board information maintained by the boot
73452 + * ROM on IBM's "Ebony" evaluation board. An effort has been made to
73453 + * keep the field names consistent with the 8xx 'bd_t' board info
73454 + * structures.
73455 + *
73456 + * Ebony firmware stores MAC addresses in the F/W VPD area. The
73457 + * firmware must store the other dynamic values in NVRAM like on
73458 + * the previous 40x systems so they  should be accessible if we
73459 + * really want them.
73460 + */
73461 +typedef struct board_info {
73462 +       unsigned char   bi_enetaddr[2][6];      /* EMAC addresses */
73463 +       unsigned int    bi_opb_busfreq;         /* OPB clock in Hz */
73464 +       int             bi_iic_fast[2];         /* Use fast i2c mode */
73465 +} bd_t;
73466 +#endif /* __ASSEMBLY__ */
73467 +
73468 +#ifndef NR_BOARD_IRQS
73469 +#define NR_BOARD_IRQS 0
73470 +#endif
73471 +
73472 +#define _IO_BASE       isa_io_base
73473 +#define _ISA_MEM_BASE  isa_mem_base
73474 +#define PCI_DRAM_OFFSET        pci_dram_offset
73475 +
73476 +/* TLB entry offset/size used for pinning kernel lowmem */
73477 +#define PPC44x_PIN_SHIFT       28
73478 +#define PPC44x_PIN_SIZE                (1 << PPC44x_PIN_SHIFT)
73479 +
73480 +/* Lowest TLB slot consumed by the default pinned TLBs */
73481 +#define PPC44x_LOW_SLOT                62
73482 +
73483 +/*
73484 + * Standard 4GB "page" definitions
73485 + */
73486 +#define        PPC44x_IO_PAGE          0x0000000100000000ULL
73487 +#define        PPC44x_PCICFG_PAGE      0x0000000200000000ULL
73488 +#define        PPC44x_PCIIO_PAGE       PPC44x_PCICFG_PAGE
73489 +#define        PPC44x_PCIMEM_PAGE      0x0000000300000000ULL
73490 +
73491 +/*
73492 + * 36-bit trap ranges
73493 + */
73494 +#define PPC44x_IO_LO           0x40000000
73495 +#define PPC44x_IO_HI           0x40001000
73496 +#define PPC44x_PCICFG_LO       0x0ec00000
73497 +#define PPC44x_PCICFG_HI       0x0ec7ffff
73498 +#define PPC44x_PCIMEM_LO       0x80002000
73499 +#define PPC44x_PCIMEM_HI       0xffffffff
73500 +
73501 +/*
73502 + * The "residual" board information structure the boot loader passes
73503 + * into the kernel.
73504 + */
73505 +#ifndef __ASSEMBLY__
73506 +
73507 +/*
73508 + * SPRN definitions
73509 + */
73510 +#define SPRN_CPC0_GPIO         0xe5/BEARLRL
73511 +
73512 +/*
73513 + * DCRN definitions
73514 + */ 
73515 +
73516 +#ifdef CONFIG_440GX
73517 +/* SDRs */
73518 +#define DCRN_SDR_CONFIG_ADDR   0xe 
73519 +#define DCRN_SDR_CONFIG_DATA   0xf
73520 +#define DCRN_SDR_PFC0          0x4100
73521 +#define DCRN_SDR_PFC1          0x4101
73522 +#define DCRN_SDR_MFR           0x4300
73523 +#define DCRN_SDR_MFR_TAH0      0x80000000      /* TAHOE0 Enable */
73524 +#define DCRN_SDR_MFR_TAH1      0x40000000      /* TAHOE1 Enable */
73525 +#define DCRN_SDR_MFR_PCM       0x10000000      /* PPC440GP irq compat mode */
73526 +#define DCRN_SDR_MFR_ECS       0x08000000      /* EMAC int clk */
73527 +#define DCRN_SDR_MFR_T0TXFL    0x00080000
73528 +#define DCRN_SDR_MFR_T0TXFH    0x00040000
73529 +#define DCRN_SDR_MFR_T1TXFL    0x00020000
73530 +#define DCRN_SDR_MFR_T1TXFH    0x00010000
73531 +#define DCRN_SDR_MFR_E0TXFL    0x00008000
73532 +#define DCRN_SDR_MFR_E0TXFH    0x00004000
73533 +#define DCRN_SDR_MFR_E0RXFL    0x00002000
73534 +#define DCRN_SDR_MFR_E0RXFH    0x00001000
73535 +#define DCRN_SDR_MFR_E1TXFL    0x00000800
73536 +#define DCRN_SDR_MFR_E1TXFH    0x00000400
73537 +#define DCRN_SDR_MFR_E1RXFL    0x00000200 
73538 +#define DCRN_SDR_MFR_E1RXFH    0x00000100
73539 +#define DCRN_SDR_MFR_E2TXFL    0x00000080
73540 +#define DCRN_SDR_MFR_E2TXFH    0x00000040
73541 +#define DCRN_SDR_MFR_E2RXFL    0x00000020
73542 +#define DCRN_SDR_MFR_E2RXFH    0x00000010
73543 +#define DCRN_SDR_MFR_E3TXFL    0x00000008
73544 +#define DCRN_SDR_MFR_E3TXFH    0x00000004
73545 +#define DCRN_SDR_MFR_E3RXFL    0x00000002
73546 +#define DCRN_SDR_MFR_E3RXFH    0x00000001
73547 +
73548 +/* SDR read/write helper macros */
73549 +#define SDR_READ(offset) ({\
73550 +       mtdcr(DCRN_SDR_CONFIG_ADDR, offset); \
73551 +       mfdcr(DCRN_SDR_CONFIG_DATA);})
73552 +#define SDR_WRITE(offset, data) ({\
73553 +       mtdcr(DCRN_SDR_CONFIG_ADDR, offset); \
73554 +       mtdcr(DCRN_SDR_CONFIG_DATA,data);})
73555 +#endif /* CONFIG_440GX */
73556 +
73557 +/* Base DCRNs */
73558 +#define DCRN_DMA0_BASE         0x100
73559 +#define DCRN_DMA1_BASE         0x108
73560 +#define DCRN_DMA2_BASE         0x110
73561 +#define DCRN_DMA3_BASE         0x118
73562 +#define DCRN_DMASR_BASE                0x120
73563 +#define DCRNCAP_DMA_SG         1       /* have DMA scatter/gather capability */
73564 +#define DCRN_MAL_BASE          0x180
73565 +
73566 +/* UIC */
73567 +#define DCRN_UIC0_BASE 0xc0
73568 +#define DCRN_UIC1_BASE 0xd0
73569 +#define UIC0           DCRN_UIC0_BASE
73570 +#define UIC1           DCRN_UIC1_BASE
73571 +
73572 +#define DCRN_UIC_SR(base)       (base + 0x0)
73573 +#define DCRN_UIC_ER(base)       (base + 0x2)
73574 +#define DCRN_UIC_CR(base)       (base + 0x3)
73575 +#define DCRN_UIC_PR(base)       (base + 0x4)
73576 +#define DCRN_UIC_TR(base)       (base + 0x5)
73577 +#define DCRN_UIC_MSR(base)      (base + 0x6)
73578 +#define DCRN_UIC_VR(base)       (base + 0x7)
73579 +#define DCRN_UIC_VCR(base)      (base + 0x8)
73580 +
73581 +#define UIC0_UIC1NC      30    /* UIC1 non-critical interrupt */
73582 +#define UIC0_UIC1CR      31    /* UIC1 critical interrupt */
73583 +
73584 +/* 440GP MAL DCRs */
73585 +#define DCRN_MALCR(base)               (base + 0x0)    /* Configuration */
73586 +#define DCRN_MALESR(base)              (base + 0x1)    /* Error Status */
73587 +#define DCRN_MALIER(base)              (base + 0x2)    /* Interrupt Enable */
73588 +#define DCRN_MALTXCASR(base)           (base + 0x4)    /* Tx Channel Active Set */
73589 +#define DCRN_MALTXCARR(base)           (base + 0x5)    /* Tx Channel Active Reset */
73590 +#define DCRN_MALTXEOBISR(base)         (base + 0x6)    /* Tx End of Buffer Interrupt Status */
73591 +#define DCRN_MALTXDEIR(base)           (base + 0x7)    /* Tx Descriptor Error Interrupt */
73592 +#define DCRN_MALRXCASR(base)           (base + 0x10)   /* Rx Channel Active Set */
73593 +#define DCRN_MALRXCARR(base)           (base + 0x11)   /* Rx Channel Active Reset */
73594 +#define DCRN_MALRXEOBISR(base)         (base + 0x12)   /* Rx End of Buffer Interrupt Status */
73595 +#define DCRN_MALRXDEIR(base)           (base + 0x13)   /* Rx Descriptor Error Interrupt */
73596 +#define DCRN_MALTXCTP0R(base)          (base + 0x20)   /* Channel Tx 0 Channel Table Pointer */        
73597 +#define DCRN_MALTXCTP1R(base)          (base + 0x21)   /* Channel Tx 1 Channel Table Pointer */
73598 +#define DCRN_MALTXCTP2R(base)          (base + 0x22)   /* Channel Tx 2 Channel Table Pointer */
73599 +#define DCRN_MALTXCTP3R(base)          (base + 0x23)   /* Channel Tx 3 Channel Table Pointer */
73600 +#define DCRN_MALRXCTP0R(base)          (base + 0x40)   /* Channel Rx 0 Channel Table Pointer */        
73601 +#define DCRN_MALRXCTP1R(base)          (base + 0x41)   /* Channel Rx 1 Channel Table Pointer */        
73602 +#define DCRN_MALRCBS0(base)            (base + 0x60)   /* Channel Rx 0 Channel Buffer Size */  
73603 +#define DCRN_MALRCBS1(base)            (base + 0x61)   /* Channel Rx 1 Channel Buffer Size */  
73604 +
73605 +/* Compatibility DCRN's */
73606 +#define DCRN_MALRXCTP2R(base)  ((base) + 0x42) /* Channel Rx 2 Channel Table Pointer */
73607 +#define DCRN_MALRXCTP3R(base)  ((base) + 0x43) /* Channel Rx 3 Channel Table Pointer */
73608 +#define DCRN_MALTXCTP4R(base)  ((base) + 0x24) /* Channel Tx 4 Channel Table Pointer */
73609 +#define DCRN_MALTXCTP5R(base)  ((base) + 0x25) /* Channel Tx 5 Channel Table Pointer */
73610 +#define DCRN_MALTXCTP6R(base)  ((base) + 0x26) /* Channel Tx 6 Channel Table Pointer */
73611 +#define DCRN_MALTXCTP7R(base)  ((base) + 0x27) /* Channel Tx 7 Channel Table Pointer */
73612 +#define DCRN_MALRCBS2(base)    ((base) + 0x62) /* Channel Rx 2 Channel Buffer Size */
73613 +#define DCRN_MALRCBS3(base)    ((base) + 0x63) /* Channel Rx 3 Channel Buffer Size */
73614 +
73615 +
73616 +#define MALCR_MMSR             0x80000000      /* MAL Software reset */
73617 +#define MALCR_PLBP_1           0x00400000      /* MAL reqest priority: */
73618 +#define MALCR_PLBP_2           0x00800000      /* lowsest is 00 */
73619 +#define MALCR_PLBP_3           0x00C00000      /* highest */
73620 +#define MALCR_GA               0x00200000      /* Guarded Active Bit */
73621 +#define MALCR_OA               0x00100000      /* Ordered Active Bit */
73622 +#define MALCR_PLBLE            0x00080000      /* PLB Lock Error Bit */
73623 +#define MALCR_PLBLT_1          0x00040000      /* PLB Latency Timer */
73624 +#define MALCR_PLBLT_2          0x00020000
73625 +#define MALCR_PLBLT_3          0x00010000
73626 +#define MALCR_PLBLT_4          0x00008000
73627 +#ifdef CONFIG_440GP
73628 +#define MALCR_PLBLT_DEFAULT    0x00330000      /* PLB Latency Timer default */
73629 +#else
73630 +#define MALCR_PLBLT_DEFAULT    0x00ff0000      /* PLB Latency Timer default */
73631 +#endif
73632 +#define MALCR_PLBB             0x00004000      /* PLB Burst Deactivation Bit */
73633 +#define MALCR_OPBBL            0x00000080      /* OPB Lock Bit */
73634 +#define MALCR_EOPIE            0x00000004      /* End Of Packet Interrupt Enable */
73635 +#define MALCR_LEA              0x00000002      /* Locked Error Active */
73636 +#define MALCR_MSD              0x00000001      /* MAL Scroll Descriptor Bit */
73637 +/* DCRN_MALESR */
73638 +#define MALESR_EVB             0x80000000      /* Error Valid Bit */
73639 +#define MALESR_CIDRX           0x40000000      /* Channel ID Receive */
73640 +#define MALESR_DE              0x00100000      /* Descriptor Error */
73641 +#define MALESR_OEN             0x00080000      /* OPB Non-Fullword Error */
73642 +#define MALESR_OTE             0x00040000      /* OPB Timeout Error */
73643 +#define MALESR_OSE             0x00020000      /* OPB Slave Error */
73644 +#define MALESR_PEIN            0x00010000      /* PLB Bus Error Indication */
73645 +#define MALESR_DEI             0x00000010      /* Descriptor Error Interrupt */
73646 +#define MALESR_ONEI            0x00000008      /* OPB Non-Fullword Error Interrupt */
73647 +#define MALESR_OTEI            0x00000004      /* OPB Timeout Error Interrupt */
73648 +#define MALESR_OSEI            0x00000002      /* OPB Slace Error Interrupt */
73649 +#define MALESR_PBEI            0x00000001      /* PLB Bus Error Interrupt */
73650 +/* DCRN_MALIER */
73651 +#define MALIER_DE              0x00000010      /* Descriptor Error Interrupt Enable */
73652 +#define MALIER_NE              0x00000008      /* OPB Non-word Transfer Int Enable */
73653 +#define MALIER_TE              0x00000004      /* OPB Time Out Error Interrupt Enable */
73654 +#define MALIER_OPBE            0x00000002      /* OPB Slave Error Interrupt Enable */
73655 +#define MALIER_PLBE            0x00000001      /* PLB Error Interrupt Enable */
73656 +/* DCRN_MALTXEOBISR */
73657 +#define MALOBISR_CH0           0x80000000      /* EOB channel 1 bit */
73658 +#define MALOBISR_CH2           0x40000000      /* EOB channel 2 bit */
73659 +
73660 +/* 440GP PLB Arbiter DCRs */
73661 +#define DCRN_PLB0_REVID                0x082           /* PLB Arbiter Revision ID */
73662 +#define DCRN_PLB0_ACR          0x083           /* PLB Arbiter Control */
73663 +#define DCRN_PLB0_BESR         0x084           /* PLB Error Status */
73664 +#define DCRN_PLB0_BEARL                0x086           /* PLB Error Address Low */
73665 +#define DCRN_PLB0_BEAR         DCRN_PLB0_BEARL /* 40x compatibility */
73666 +#define DCRN_PLB0_BEARH                0x087           /* PLB Error Address High */
73667 +
73668 +/* 440GP Clock, PM, chip control */
73669 +#define DCRN_CPC0_SR           0x0b0
73670 +#define DCRN_CPC0_ER           0x0b1
73671 +#define DCRN_CPC0_FR           0x0b2
73672 +#define DCRN_CPC0_SYS0         0x0e0
73673 +#define DCRN_CPC0_SYS1         0x0e1
73674 +#define DCRN_CPC0_CUST0                0x0e2
73675 +#define DCRN_CPC0_CUST1                0x0e3
73676 +#define DCRN_CPC0_STRP0                0x0e4
73677 +#define DCRN_CPC0_STRP1                0x0e5
73678 +#define DCRN_CPC0_STRP2                0x0e6
73679 +#define DCRN_CPC0_STRP3                0x0e7
73680 +#define DCRN_CPC0_GPIO         0x0e8
73681 +#define DCRN_CPC0_PLB          0x0e9
73682 +#define DCRN_CPC0_CR1          0x0ea
73683 +#define DCRN_CPC0_CR0          0x0eb
73684 +#define DCRN_CPC0_MIRQ0                0x0ec
73685 +#define DCRN_CPC0_MIRQ1                0x0ed
73686 +#define DCRN_CPC0_JTAGID       0x0ef
73687 +
73688 +/* 440GP DMA controller DCRs */
73689 +#define DCRN_DMACR0    (DCRN_DMA0_BASE + 0x0)  /* DMA Channel Control 0 */
73690 +#define DCRN_DMACT0    (DCRN_DMA0_BASE + 0x1)  /* DMA Count 0 */
73691 +#define DCRN_DMASAH0   (DCRN_DMA0_BASE + 0x2)  /* DMA Src Addr High 0 */
73692 +#define DCRN_DMASA0    (DCRN_DMA0_BASE + 0x3)  /* DMA Src Addr Low 0 */
73693 +#define DCRN_DMADAH0   (DCRN_DMA0_BASE + 0x4)  /* DMA Dest Addr High 0 */
73694 +#define DCRN_DMADA0    (DCRN_DMA0_BASE + 0x5)  /* DMA Dest Addr Low 0 */
73695 +#define DCRN_ASGH0     (DCRN_DMA0_BASE + 0x6)  /* DMA SG Desc Addr High 0 */
73696 +#define DCRN_ASG0      (DCRN_DMA0_BASE + 0x7)  /* DMA SG Desc Addr Low 0 */
73697 +
73698 +#define DCRN_DMACR1    (DCRN_DMA1_BASE + 0x0)  /* DMA Channel Control 1 */
73699 +#define DCRN_DMACT1    (DCRN_DMA1_BASE + 0x1)  /* DMA Count 1 */
73700 +#define DCRN_DMASAH1   (DCRN_DMA1_BASE + 0x2)  /* DMA Src Addr High 1 */
73701 +#define DCRN_DMASA1    (DCRN_DMA1_BASE + 0x3)  /* DMA Src Addr Low 1 */
73702 +#define DCRN_DMADAH1   (DCRN_DMA1_BASE + 0x4)  /* DMA Dest Addr High 1 */
73703 +#define DCRN_DMADA1    (DCRN_DMA1_BASE + 0x5)  /* DMA Dest Addr Low 1 */
73704 +#define DCRN_ASGH1     (DCRN_DMA1_BASE + 0x6)  /* DMA SG Desc Addr High 1 */
73705 +#define DCRN_ASG1      (DCRN_DMA1_BASE + 0x7)  /* DMA SG Desc Addr Low 1 */
73706 +
73707 +#define DCRN_DMACR2    (DCRN_DMA2_BASE + 0x0)  /* DMA Channel Control 2 */
73708 +#define DCRN_DMACT2    (DCRN_DMA2_BASE + 0x1)  /* DMA Count 2 */
73709 +#define DCRN_DMASAH2   (DCRN_DMA2_BASE + 0x2)  /* DMA Src Addr High 2 */
73710 +#define DCRN_DMASA2    (DCRN_DMA2_BASE + 0x3)  /* DMA Src Addr Low 2 */
73711 +#define DCRN_DMADAH2   (DCRN_DMA2_BASE + 0x4)  /* DMA Dest Addr High 2 */
73712 +#define DCRN_DMADA2    (DCRN_DMA2_BASE + 0x5)  /* DMA Dest Addr Low 2 */
73713 +#define DCRN_ASGH2     (DCRN_DMA2_BASE + 0x6)  /* DMA SG Desc Addr High 2 */
73714 +#define DCRN_ASG2      (DCRN_DMA2_BASE + 0x7)  /* DMA SG Desc Addr Low 2 */
73715 +
73716 +#define DCRN_DMACR3    (DCRN_DMA3_BASE + 0x0)  /* DMA Channel Control 3 */
73717 +#define DCRN_DMACT3    (DCRN_DMA3_BASE + 0x1)  /* DMA Count 3 */
73718 +#define DCRN_DMASAH3   (DCRN_DMA3_BASE + 0x2)  /* DMA Src Addr High 3 */
73719 +#define DCRN_DMASA3    (DCRN_DMA3_BASE + 0x3)  /* DMA Src Addr Low 3 */
73720 +#define DCRN_DMADAH3   (DCRN_DMA3_BASE + 0x4)  /* DMA Dest Addr High 3 */
73721 +#define DCRN_DMADA3    (DCRN_DMA3_BASE + 0x5)  /* DMA Dest Addr Low 3 */
73722 +#define DCRN_ASGH3     (DCRN_DMA3_BASE + 0x6)  /* DMA SG Desc Addr High 3 */
73723 +#define DCRN_ASG3      (DCRN_DMA3_BASE + 0x7)  /* DMA SG Desc Addr Low 3 */
73724 +
73725 +#define DCRN_DMASR     (DCRN_DMASR_BASE + 0x0) /* DMA Status Register */
73726 +#define DCRN_ASGC      (DCRN_DMASR_BASE + 0x3) /* DMA Scatter/Gather Command */
73727 +#define DCRN_SLP       (DCRN_DMASR_BASE + 0x5) /* DMA Sleep Register */
73728 +#define DCRN_POL       (DCRN_DMASR_BASE + 0x6) /* DMA Polarity Register */
73729 +
73730 +/* 440GP DRAM controller DCRs */
73731 +#define DCRN_SDRAM0_CFGADDR            0x010
73732 +#define DCRN_SDRAM0_CFGDATA            0x011
73733 +
73734 +#define SDRAM0_B0CR    0x40
73735 +#define SDRAM0_B1CR    0x44
73736 +#define SDRAM0_B2CR    0x48
73737 +#define SDRAM0_B3CR    0x4c
73738 +
73739 +#define SDRAM_CONFIG_BANK_ENABLE       0x00000001
73740 +#define SDRAM_CONFIG_SIZE_MASK         0x000e0000
73741 +#define SDRAM_CONFIG_BANK_SIZE(reg)    ((reg & SDRAM_CONFIG_SIZE_MASK) >> 17)
73742 +#define SDRAM_CONFIG_SIZE_8M           0x00000001
73743 +#define SDRAM_CONFIG_SIZE_16M          0x00000002
73744 +#define SDRAM_CONFIG_SIZE_32M          0x00000003
73745 +#define SDRAM_CONFIG_SIZE_64M          0x00000004
73746 +#define SDRAM_CONFIG_SIZE_128M         0x00000005
73747 +#define SDRAM_CONFIG_SIZE_256M         0x00000006
73748 +#define SDRAM_CONFIG_SIZE_512M         0x00000007
73749 +#define PPC44x_MEM_SIZE_8M             0x00800000
73750 +#define PPC44x_MEM_SIZE_16M            0x01000000
73751 +#define PPC44x_MEM_SIZE_32M            0x02000000
73752 +#define PPC44x_MEM_SIZE_64M            0x04000000
73753 +#define PPC44x_MEM_SIZE_128M           0x08000000
73754 +#define PPC44x_MEM_SIZE_256M           0x10000000
73755 +#define PPC44x_MEM_SIZE_512M           0x20000000
73756 +
73757 +/*
73758 + * PCI-X definitions
73759 + */
73760 +#define PCIX0_REG_BASE         0x20ec80000ULL
73761 +#define PCIX0_REG_SIZE         0x200
73762 +
73763 +#define PCIX0_VENDID           0x000
73764 +#define PCIX0_DEVID            0x002
73765 +#define PCIX0_COMMAND          0x004
73766 +#define PCIX0_STATUS           0x006
73767 +#define PCIX0_REVID            0x008
73768 +#define PCIX0_CLS              0x009
73769 +#define PCIX0_CACHELS          0x00c
73770 +#define PCIX0_LATTIM           0x00d
73771 +#define PCIX0_HDTYPE           0x00e
73772 +#define PCIX0_BIST             0x00f
73773 +#define PCIX0_BAR0L            0x010
73774 +#define PCIX0_BAR0H            0x014
73775 +#define PCIX0_BAR1             0x018
73776 +#define PCIX0_BAR2L            0x01c
73777 +#define PCIX0_BAR2H            0x020
73778 +#define PCIX0_BAR3             0x024
73779 +#define PCIX0_CISPTR           0x028
73780 +#define PCIX0_SBSYSVID         0x02c
73781 +#define PCIX0_SBSYSID          0x02e
73782 +#define PCIX0_EROMBA           0x030
73783 +#define PCIX0_CAP              0x034
73784 +#define PCIX0_RES0             0x035
73785 +#define PCIX0_RES1             0x036
73786 +#define PCIX0_RES2             0x038
73787 +#define PCIX0_INTLN            0x03c
73788 +#define PCIX0_INTPN            0x03d
73789 +#define PCIX0_MINGNT           0x03e
73790 +#define PCIX0_MAXLTNCY         0x03f
73791 +#define PCIX0_BRDGOPT1         0x040
73792 +#define PCIX0_BRDGOPT2         0x044
73793 +#define PCIX0_ERREN            0x050
73794 +#define PCIX0_ERRSTS           0x054
73795 +#define PCIX0_PLBBESR          0x058
73796 +#define PCIX0_PLBBEARL         0x05c
73797 +#define PCIX0_PLBBEARH         0x060
73798 +#define PCIX0_POM0LAL          0x068
73799 +#define PCIX0_POM0LAH          0x06c
73800 +#define PCIX0_POM0SA           0x070
73801 +#define PCIX0_POM0PCIAL                0x074
73802 +#define PCIX0_POM0PCIAH                0x078
73803 +#define PCIX0_POM1LAL          0x07c
73804 +#define PCIX0_POM1LAH          0x080
73805 +#define PCIX0_POM1SA           0x084
73806 +#define PCIX0_POM1PCIAL                0x088
73807 +#define PCIX0_POM1PCIAH                0x08c
73808 +#define PCIX0_POM2SA           0x090
73809 +#define PCIX0_PIM0SAL          0x098
73810 +#define PCIX0_PIM0SA           PCIX0_PIM0SAL
73811 +#define PCIX0_PIM0LAL          0x09c
73812 +#define PCIX0_PIM0LAH          0x0a0
73813 +#define PCIX0_PIM1SA           0x0a4
73814 +#define PCIX0_PIM1LAL          0x0a8
73815 +#define PCIX0_PIM1LAH          0x0ac
73816 +#define PCIX0_PIM2SAL          0x0b0
73817 +#define PCIX0_PIM2SA           PCIX0_PIM2SAL
73818 +#define PCIX0_PIM2LAL          0x0b4
73819 +#define PCIX0_PIM2LAH          0x0b8
73820 +#define PCIX0_OMCAPID          0x0c0
73821 +#define PCIX0_OMNIPTR          0x0c1
73822 +#define PCIX0_OMMC             0x0c2
73823 +#define PCIX0_OMMA             0x0c4
73824 +#define PCIX0_OMMUA            0x0c8
73825 +#define PCIX0_OMMDATA          0x0cc
73826 +#define PCIX0_OMMEOI           0x0ce
73827 +#define PCIX0_PMCAPID          0x0d0
73828 +#define PCIX0_PMNIPTR          0x0d1
73829 +#define PCIX0_PMC              0x0d2
73830 +#define PCIX0_PMCSR            0x0d4
73831 +#define PCIX0_PMCSRBSE         0x0d6
73832 +#define PCIX0_PMDATA           0x0d7
73833 +#define PCIX0_PMSCRR           0x0d8
73834 +#define PCIX0_CAPID            0x0dc
73835 +#define PCIX0_NIPTR            0x0dd
73836 +#define PCIX0_CMD              0x0de
73837 +#define PCIX0_STS              0x0e0
73838 +#define PCIX0_IDR              0x0e4
73839 +#define PCIX0_CID              0x0e8
73840 +#define PCIX0_RID              0x0ec
73841 +#define PCIX0_PIM0SAH          0x0f8
73842 +#define PCIX0_PIM2SAH          0x0fc
73843 +#define PCIX0_MSGIL            0x100
73844 +#define PCIX0_MSGIH            0x104
73845 +#define PCIX0_MSGOL            0x108
73846 +#define PCIX0_MSGOH            0x10c
73847 +#define PCIX0_IM               0x1f8
73848 +
73849 +#define IIC_OWN                        0x55
73850 +#define IIC_CLOCK              50
73851 +
73852 +#undef NR_UICS
73853 +#define NR_UICS 2
73854 +#define UIC_CASCADE_MASK       0x0003          /* bits 30 & 31 */
73855 +
73856 +#define BD_EMAC_ADDR(e,i) bi_enetaddr[e][i]
73857 +
73858 +#include <asm/ibm4xx.h>
73859 +
73860 +#endif /* __ASSEMBLY__ */
73861 +#endif /* __ASM_IBM44x_H__ */
73862 +#endif /* __KERNEL__ */
73863 diff -Nru a/include/asm-ppc/ibm4xx.h b/include/asm-ppc/ibm4xx.h
73864 --- a/include/asm-ppc/ibm4xx.h  Tue Jan  7 22:11:45 2003
73865 +++ b/include/asm-ppc/ibm4xx.h  Wed Sep  3 05:16:34 2003
73866 @@ -122,7 +122,25 @@
73867  #define PCI_DRAM_OFFSET        0
73868  #endif
73869  
73870 +#elif CONFIG_44x
73871 +
73872 +#if defined(CONFIG_EBONY)
73873 +#include <platforms/4xx/ebony.h>
73874 +#endif
73875 +
73876 +#if defined(CONFIG_OCOTEA)
73877 +#include <platforms/4xx/ocotea.h>
73878 +#endif
73879  
73880  #endif /* CONFIG_40x */
73881 +
73882 +#ifndef __ASSEMBLY__
73883 +/*
73884 + * The "residual" board information structure the boot loader passes
73885 + * into the kernel.
73886 + */
73887 +extern bd_t __res;
73888 +#endif
73889 +
73890  #endif /* __ASM_IBM4XX_H__ */
73891  #endif /* __KERNEL__ */
73892 diff -Nru a/include/asm-ppc/io.h b/include/asm-ppc/io.h
73893 --- a/include/asm-ppc/io.h      Wed Jun  4 20:11:01 2003
73894 +++ b/include/asm-ppc/io.h      Wed Sep  3 05:16:34 2003
73895 @@ -4,9 +4,11 @@
73896  
73897  #include <linux/config.h>
73898  #include <linux/types.h>
73899 +#include <linux/mm.h>
73900  
73901  #include <asm/page.h>
73902  #include <asm/byteorder.h>
73903 +#include <asm/mmu.h>
73904  
73905  #define SIO_CONFIG_RA  0x398
73906  #define SIO_CONFIG_RD  0x399
73907 @@ -22,7 +24,7 @@
73908  #define PREP_ISA_MEM_BASE      0xc0000000
73909  #define PREP_PCI_DRAM_OFFSET   0x80000000
73910  
73911 -#if defined(CONFIG_40x)
73912 +#if defined(CONFIG_4xx)
73913  #include <asm/ibm4xx.h>
73914  #elif defined(CONFIG_8xx)
73915  #include <asm/mpc8xx.h>
73916 @@ -197,14 +199,17 @@
73917   * Map in an area of physical address space, for accessing
73918   * I/O devices etc.
73919   */
73920 -extern void *__ioremap(unsigned long address, unsigned long size,
73921 +extern void *__ioremap(phys_addr_t address, unsigned long size,
73922                        unsigned long flags);
73923 -extern void *ioremap(unsigned long address, unsigned long size);
73924 +extern void *ioremap(phys_addr_t address, unsigned long size);
73925 +#ifdef CONFIG_44x
73926 +extern void *ioremap64(unsigned long long address, unsigned long size);
73927 +#endif
73928  #define ioremap_nocache(addr, size)    ioremap((addr), (size))
73929  extern void iounmap(void *addr);
73930  extern unsigned long iopa(unsigned long addr);
73931  extern unsigned long mm_ptov(unsigned long addr) __attribute__ ((const));
73932 -extern void io_block_mapping(unsigned long virt, unsigned long phys,
73933 +extern void io_block_mapping(unsigned long virt, phys_addr_t phys,
73934                              unsigned int size, int flags);
73935  
73936  /*
73937 diff -Nru a/include/asm-ppc/irq.h b/include/asm-ppc/irq.h
73938 --- a/include/asm-ppc/irq.h     Wed Apr 23 00:49:34 2003
73939 +++ b/include/asm-ppc/irq.h     Wed Sep  3 05:16:34 2003
73940 @@ -71,11 +71,11 @@
73941         return (irq);
73942  }
73943  
73944 -#elif defined(CONFIG_440)
73945 -#include <asm/ibm440.h>
73946 +#elif defined(CONFIG_44x)
73947 +#include <asm/ibm44x.h>
73948  
73949 -#define        NR_UIC_IRQS     64
73950 -#define        NR_IRQS         (NR_UIC_IRQS + NR_BOARD_IRQS)
73951 +#define        NR_UIC_IRQS     32
73952 +#define        NR_IRQS         ((NR_UIC_IRQS * NR_UICS) + NR_BOARD_IRQS)
73953  
73954  static __inline__ int
73955  irq_canonicalize(int irq)
73956 diff -Nru a/include/asm-ppc/macio.h b/include/asm-ppc/macio.h
73957 --- a/include/asm-ppc/macio.h   Sat Aug  9 09:39:19 2003
73958 +++ b/include/asm-ppc/macio.h   Sun Aug 24 04:06:49 2003
73959 @@ -42,6 +42,9 @@
73960  #define        to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev)
73961  #define        of_to_macio_device(d) container_of(d, struct macio_dev, ofdev)
73962  
73963 +extern struct macio_dev *macio_dev_get(struct macio_dev *dev);
73964 +extern void macio_dev_put(struct macio_dev *dev);
73965 +
73966  /*
73967   * A driver for a mac-io chip based device
73968   */
73969 @@ -54,8 +57,8 @@
73970         int     (*probe)(struct macio_dev* dev, const struct of_match *match);
73971         int     (*remove)(struct macio_dev* dev);
73972  
73973 -       int     (*suspend)(struct macio_dev* dev, u32 state, u32 level);
73974 -       int     (*resume)(struct macio_dev* dev, u32 level);
73975 +       int     (*suspend)(struct macio_dev* dev, u32 state);
73976 +       int     (*resume)(struct macio_dev* dev);
73977         int     (*shutdown)(struct macio_dev* dev);
73978  
73979         struct device_driver    driver;
73980 diff -Nru a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h
73981 --- a/include/asm-ppc/mmu.h     Sun Sep 15 21:52:05 2002
73982 +++ b/include/asm-ppc/mmu.h     Wed Sep  3 05:16:34 2003
73983 @@ -10,6 +10,18 @@
73984  
73985  #ifndef __ASSEMBLY__
73986  
73987 +/*
73988 + * Define physical address type.  Machines using split size
73989 + * virtual/physical addressing like 32-bit virtual / 36-bit
73990 + * physical need a larger than native word size type. -Matt
73991 + */
73992 +#ifndef CONFIG_PTE_64BIT
73993 +typedef unsigned long phys_addr_t;
73994 +#else
73995 +typedef unsigned long long phys_addr_t;
73996 +extern phys_addr_t fixup_bigphys_addr(phys_addr_t, phys_addr_t);
73997 +#endif
73998 +
73999  /* Default "unsigned long" context */
74000  typedef unsigned long mm_context_t;
74001  
74002 @@ -319,6 +331,56 @@
74003  #define TLB_I           0x00000004      /* Caching is inhibited */
74004  #define TLB_M           0x00000002      /* Memory is coherent */
74005  #define TLB_G           0x00000001      /* Memory is guarded from prefetch */
74006 +
74007 +/*
74008 + * PPC440 support
74009 + */
74010 +#define PPC44x_MMUCR_TID       0x000000ff      
74011 +#define PPC44x_MMUCR_STS       0x00010000
74012 +
74013 +#define        PPC44x_TLB_PAGEID       0
74014 +#define        PPC44x_TLB_XLAT         1
74015 +#define        PPC44x_TLB_ATTRIB       2
74016 +
74017 +/* Page identification fields */
74018 +#define PPC44x_TLB_EPN_MASK    0xfffffc00      /* Effective Page Number */
74019 +#define        PPC44x_TLB_VALID        0x00000200      /* Valid flag */
74020 +#define PPC44x_TLB_TS          0x00000100      /* Translation address space */
74021 +#define PPC44x_TLB_PAGESZ_MASK 0x000000f0
74022 +#define PPC44x_TLB_PAGESZ(x)   (x << 4)
74023 +#define PPC44x_PAGESZ_1K       0
74024 +#define PPC44x_PAGESZ_4K       1
74025 +#define PPC44x_PAGESZ_16K      2
74026 +#define PPC44x_PAGESZ_64K      3
74027 +#define PPC44x_PAGESZ_256K     4
74028 +#define PPC44x_PAGESZ_1M       5
74029 +#define PPC44x_PAGESZ_16M      7
74030 +#define        PPC44x_PAGESZ_256M      9
74031 +
74032 +/* Translation fields */
74033 +#define PPC44x_TLB_RPN_MASK    0xfffffc00      /* Real Page Number */
74034 +#define        PPC44x_TLB_ERPN_MASK    0x0000000f
74035 +
74036 +/* Storage attribute and access control fields */
74037 +#define PPC44x_TLB_ATTR_MASK   0x0000ff80
74038 +#define PPC44x_TLB_U0          0x00008000      /* User 0 */
74039 +#define PPC44x_TLB_U1          0x00004000      /* User 1 */
74040 +#define PPC44x_TLB_U2          0x00002000      /* User 2 */
74041 +#define PPC44x_TLB_U3          0x00001000      /* User 3 */
74042 +#define PPC44x_TLB_W           0x00000800      /* Caching is write-through */
74043 +#define PPC44x_TLB_I           0x00000400      /* Caching is inhibited */
74044 +#define PPC44x_TLB_M           0x00000200      /* Memory is coherent */
74045 +#define PPC44x_TLB_G           0x00000100      /* Memory is guarded */
74046 +#define PPC44x_TLB_E           0x00000080      /* Memory is guarded */
74047 +
74048 +#define PPC44x_TLB_PERM_MASK   0x0000003f
74049 +#define PPC44x_TLB_UX          0x00000020      /* User execution */
74050 +#define PPC44x_TLB_UW          0x00000010      /* User write */
74051 +#define PPC44x_TLB_UR          0x00000008      /* User read */
74052 +#define PPC44x_TLB_SX          0x00000004      /* Super execution */
74053 +#define PPC44x_TLB_SW          0x00000002      /* Super write */
74054 +#define PPC44x_TLB_SR          0x00000001      /* Super read */
74055 +
74056  
74057  #endif /* _PPC_MMU_H_ */
74058  #endif /* __KERNEL__ */
74059 diff -Nru a/include/asm-ppc/of_device.h b/include/asm-ppc/of_device.h
74060 --- a/include/asm-ppc/of_device.h       Sat Aug  9 09:40:04 2003
74061 +++ b/include/asm-ppc/of_device.h       Sun Aug 24 04:06:49 2003
74062 @@ -39,6 +39,9 @@
74063  extern const struct of_match *of_match_device(
74064         const struct of_match *matches, const struct of_device *dev);
74065  
74066 +extern struct of_device *of_dev_get(struct of_device *dev);
74067 +extern void of_dev_put(struct of_device *dev);
74068 +
74069  /*
74070   * An of_platform_driver driver is attached to a basic of_device on
74071   * the "platform bus" (of_platform_bus_type)
74072 @@ -52,8 +55,8 @@
74073         int     (*probe)(struct of_device* dev, const struct of_match *match);
74074         int     (*remove)(struct of_device* dev);
74075  
74076 -       int     (*suspend)(struct of_device* dev, u32 state, u32 level);
74077 -       int     (*resume)(struct of_device* dev, u32 level);
74078 +       int     (*suspend)(struct of_device* dev, u32 state);
74079 +       int     (*resume)(struct of_device* dev);
74080         int     (*shutdown)(struct of_device* dev);
74081  
74082         struct device_driver    driver;
74083 @@ -65,6 +68,7 @@
74084  extern int of_device_register(struct of_device *ofdev);
74085  extern void of_device_unregister(struct of_device *ofdev);
74086  extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id);
74087 +extern void of_release_dev(struct device *dev);
74088  
74089  #endif /* __OF_DEVICE_H__ */
74090  
74091 diff -Nru a/include/asm-ppc/page.h b/include/asm-ppc/page.h
74092 --- a/include/asm-ppc/page.h    Tue Feb 25 09:57:21 2003
74093 +++ b/include/asm-ppc/page.h    Wed Sep  3 05:16:34 2003
74094 @@ -4,7 +4,12 @@
74095  /* PAGE_SHIFT determines the page size */
74096  #define PAGE_SHIFT     12
74097  #define PAGE_SIZE      (1UL << PAGE_SHIFT)
74098 -#define PAGE_MASK      (~(PAGE_SIZE-1))
74099 +
74100 +/*
74101 + * Subtle: this is an int (not an unsigned long) and so it
74102 + * gets extended to 64 bits the way want (i.e. with 1s).  -- paulus
74103 + */
74104 +#define PAGE_MASK      (~((1 << PAGE_SHIFT) - 1))
74105  
74106  #ifdef __KERNEL__
74107  #include <linux/config.h>
74108 @@ -15,13 +20,27 @@
74109  
74110  #ifndef __ASSEMBLY__
74111  
74112 -#define STRICT_MM_TYPECHECKS
74113 +/*
74114 + * The basic type of a PTE - 64 bits for those CPUs with > 32 bit
74115 + * physical addressing.  For now this just the IBM PPC440.
74116 + */
74117 +#ifdef CONFIG_PTE_64BIT
74118 +typedef unsigned long long pte_basic_t;
74119 +#define PTE_SHIFT      (PAGE_SHIFT - 3)        /* 512 ptes per page */
74120 +#define PTE_FMT                "%16Lx"
74121 +#else
74122 +typedef unsigned long pte_basic_t;
74123 +#define PTE_SHIFT      (PAGE_SHIFT - 2)        /* 1024 ptes per page */
74124 +#define PTE_FMT                "%.8lx"
74125 +#endif
74126 +
74127 +#undef STRICT_MM_TYPECHECKS
74128  
74129  #ifdef STRICT_MM_TYPECHECKS
74130  /*
74131   * These are used to make use of C type-checking..
74132   */
74133 -typedef struct { unsigned long pte; } pte_t;
74134 +typedef struct { pte_basic_t pte; } pte_t;
74135  typedef struct { unsigned long pmd; } pmd_t;
74136  typedef struct { unsigned long pgd; } pgd_t;
74137  typedef struct { unsigned long pgprot; } pgprot_t;
74138 @@ -40,7 +59,7 @@
74139  /*
74140   * .. while these make it easier on the compiler
74141   */
74142 -typedef unsigned long pte_t;
74143 +typedef pte_basic_t pte_t;
74144  typedef unsigned long pmd_t;
74145  typedef unsigned long pgd_t;
74146  typedef unsigned long pgprot_t;
74147 @@ -123,6 +142,7 @@
74148  #define pfn_to_page(pfn)       (mem_map + ((pfn) - PPC_PGSTART))
74149  #define page_to_pfn(page)      ((unsigned long)((page) - mem_map) + PPC_PGSTART)
74150  #define virt_to_page(kaddr)    pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
74151 +#define page_to_virt(page)     __va(page_to_pfn(page) << PAGE_SHIFT)
74152  
74153  #define pfn_valid(pfn)         (((pfn) - PPC_PGSTART) < max_mapnr)
74154  #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
74155 diff -Nru a/include/asm-ppc/pgalloc.h b/include/asm-ppc/pgalloc.h
74156 --- a/include/asm-ppc/pgalloc.h Mon Oct  7 15:51:14 2002
74157 +++ b/include/asm-ppc/pgalloc.h Wed Sep  3 05:16:34 2003
74158 @@ -20,10 +20,17 @@
74159  #define __pmd_free_tlb(tlb,x)          do { } while (0)
74160  #define pgd_populate(mm, pmd, pte)      BUG()
74161  
74162 +#ifndef CONFIG_BOOKE
74163  #define pmd_populate_kernel(mm, pmd, pte)      \
74164                 (pmd_val(*(pmd)) = __pa(pte) | _PMD_PRESENT)
74165  #define pmd_populate(mm, pmd, pte)     \
74166                 (pmd_val(*(pmd)) = (page_to_pfn(pte) << PAGE_SHIFT) | _PMD_PRESENT)
74167 +#else
74168 +#define pmd_populate_kernel(mm, pmd, pte)      \
74169 +               (pmd_val(*(pmd)) = (unsigned long)pte | _PMD_PRESENT)
74170 +#define pmd_populate(mm, pmd, pte)     \
74171 +               (pmd_val(*(pmd)) = (unsigned long)page_to_virt(pte) | _PMD_PRESENT)
74172 +#endif
74173  
74174  extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr);
74175  extern struct page *pte_alloc_one(struct mm_struct *mm, unsigned long addr);
74176 diff -Nru a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
74177 --- a/include/asm-ppc/pgtable.h Tue Jun 10 23:33:17 2003
74178 +++ b/include/asm-ppc/pgtable.h Wed Sep  3 05:16:34 2003
74179 @@ -65,13 +65,23 @@
74180   * and ITLB, respectively (see "mmu.h" for definitions).
74181   */
74182  
74183 -/* PMD_SHIFT determines the size of the area mapped by the second-level page tables */
74184 -#define PMD_SHIFT      22
74185 +/*
74186 + * The normal case is that PTEs are 32-bits and we have a 1-page
74187 + * 1024-entry pgdir pointing to 1-page 1024-entry PTE pages.  -- paulus
74188 + *
74189 + * For any >32-bit physical address platform, we can use the following
74190 + * two level page table layout where the pgdir is 8KB and the MS 13 bits
74191 + * are an index to the second level table.  The combined pgdir/pmd first
74192 + * level has 2048 entries and the second level has 512 64-bit PTE entries.
74193 + * -Matt
74194 + */
74195 +/* PMD_SHIFT determines the size of the area mapped by the PTE pages */
74196 +#define PMD_SHIFT      (PAGE_SHIFT + PTE_SHIFT)
74197  #define PMD_SIZE       (1UL << PMD_SHIFT)
74198  #define PMD_MASK       (~(PMD_SIZE-1))
74199  
74200 -/* PGDIR_SHIFT determines what a third-level page table entry can map */
74201 -#define PGDIR_SHIFT    22
74202 +/* PGDIR_SHIFT determines what a top-level page table entry can map */
74203 +#define PGDIR_SHIFT    PMD_SHIFT
74204  #define PGDIR_SIZE     (1UL << PGDIR_SHIFT)
74205  #define PGDIR_MASK     (~(PGDIR_SIZE-1))
74206  
74207 @@ -79,9 +89,10 @@
74208   * entries per page directory level: our page-table tree is two-level, so
74209   * we don't really have any PMD directory.
74210   */
74211 -#define PTRS_PER_PTE   1024
74212 +#define PTRS_PER_PTE   (1 << PTE_SHIFT)
74213  #define PTRS_PER_PMD   1
74214 -#define PTRS_PER_PGD   1024
74215 +#define PTRS_PER_PGD   (1 << (32 - PGDIR_SHIFT))
74216 +
74217  #define USER_PTRS_PER_PGD      (TASK_SIZE / PGDIR_SIZE)
74218  #define FIRST_USER_PGD_NR      0
74219  
74220 @@ -89,7 +100,7 @@
74221  #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
74222  
74223  #define pte_ERROR(e) \
74224 -       printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
74225 +       printk("%s:%d: bad pte "PTE_FMT".\n", __FILE__, __LINE__, pte_val(e))
74226  #define pmd_ERROR(e) \
74227         printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
74228  #define pgd_ERROR(e) \
74229 @@ -113,7 +124,11 @@
74230   * of RAM.  -- Cort
74231   */
74232  #define VMALLOC_OFFSET (0x1000000) /* 16M */
74233 +#ifdef CONFIG_44x
74234 +#define VMALLOC_START (((_ALIGN((long)high_memory, PPC44x_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
74235 +#else
74236  #define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
74237 +#endif
74238  #define VMALLOC_VMADDR(x) ((unsigned long)(x))
74239  #define VMALLOC_END    ioremap_bot
74240  
74241 @@ -170,6 +185,44 @@
74242  #define _PMD_SIZE_16M  0x0e0
74243  #define PMD_PAGE_SIZE(pmdval)  (1024 << (((pmdval) & _PMD_SIZE) >> 4))
74244  
74245 +#elif defined(CONFIG_44x)
74246 +/*
74247 + * Definitions for PPC440
74248 + *
74249 + * Because of the 3 word TLB entries to support 36-bit addressing,
74250 + * the attribute are difficult to map in such a fashion that they
74251 + * are easily loaded during exception processing.  I decided to
74252 + * organize the entry so the ERPN is the only portion in the
74253 + * upper word of the PTE and the attribute bits below are packed
74254 + * in as sensibly as they can be in the area below a 4KB page size
74255 + * oriented RPN.  This at least makes it easy to load the RPN and
74256 + * ERPN fields in the TLB. -Matt
74257 + *
74258 + * Note that these bits preclude future use of a page size
74259 + * less than 4KB.
74260 + */
74261 +#define _PAGE_PRESENT  0x00000001              /* S: PTE valid */
74262 +#define        _PAGE_RW        0x00000002              /* S: Write permission */
74263 +#define        _PAGE_DIRTY     0x00000004              /* S: Page dirty */
74264 +#define _PAGE_ACCESSED 0x00000008              /* S: Page referenced */
74265 +#define _PAGE_HWWRITE  0x00000010              /* H: Dirty & RW */
74266 +#define _PAGE_HWEXEC   0x00000020              /* H: Execute permission */
74267 +#define        _PAGE_USER      0x00000040              /* S: User page */
74268 +#define        _PAGE_ENDIAN    0x00000080              /* H: E bit */
74269 +#define        _PAGE_GUARDED   0x00000100              /* H: G bit */
74270 +#define        _PAGE_COHERENT  0x00000200              /* H: M bit */
74271 +#define _PAGE_FILE     0x00000400              /* S: nonlinear file mapping */
74272 +#define        _PAGE_NO_CACHE  0x00000400              /* H: I bit */
74273 +#define        _PAGE_WRITETHRU 0x00000800              /* H: W bit */
74274 +
74275 +/* TODO: Add large page lowmem mapping support */
74276 +#define _PMD_PRESENT   0
74277 +#define _PMD_PRESENT_MASK (PAGE_MASK)
74278 +#define _PMD_BAD       (~PAGE_MASK)
74279 +
74280 +/* ERPN in a PTE never gets cleared, ignore it */
74281 +#define _PTE_NONE_MASK 0xffffffff00000000ULL
74282 +
74283  #elif defined(CONFIG_8xx)
74284  /* Definitions for 8xx embedded chips. */
74285  #define _PAGE_PRESENT  0x0001  /* Page is valid */
74286 @@ -270,7 +323,11 @@
74287  
74288  #define _PAGE_BASE     (_PAGE_PRESENT | _PAGE_ACCESSED)
74289  #define _PAGE_WRENABLE (_PAGE_RW | _PAGE_DIRTY | _PAGE_HWWRITE)
74290 +#ifndef CONFIG_44x
74291  #define _PAGE_KERNEL   (_PAGE_BASE | _PAGE_SHARED | _PAGE_WRENABLE)
74292 +#else
74293 +#define _PAGE_KERNEL   (_PAGE_BASE | _PAGE_SHARED | _PAGE_WRENABLE | _PAGE_GUARDED)
74294 +#endif
74295  
74296  #ifdef CONFIG_PPC_STD_MMU
74297  /* On standard PPC MMU, no user access implies kernel read/write access,
74298 @@ -283,7 +340,7 @@
74299  #define _PAGE_IO       (_PAGE_KERNEL | _PAGE_NO_CACHE | _PAGE_GUARDED)
74300  #define _PAGE_RAM      (_PAGE_KERNEL | _PAGE_HWEXEC)
74301  
74302 -#if defined(CONFIG_KGDB) || defined(CONFIG_XMON)
74303 +#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH)
74304  /* We want the debuggers to be able to set breakpoints anywhere, so
74305   * don't write protect the kernel text */
74306  #define _PAGE_RAM_TEXT _PAGE_RAM
74307 @@ -420,6 +477,8 @@
74308   *
74309   * pte_update clears and sets bit atomically, and returns
74310   * the old pte value.
74311 + * The ((unsigned long)(p+1) - 4) hack is to get to the least-significant
74312 + * 32 bits of the PTE regardless of whether PTEs are 32 or 64 bits.
74313   */
74314  static inline unsigned long pte_update(pte_t *p, unsigned long clr,
74315                                        unsigned long set)
74316 @@ -434,7 +493,7 @@
74317  "      stwcx.  %1,0,%3\n\
74318         bne-    1b"
74319         : "=&r" (old), "=&r" (tmp), "=m" (*p)
74320 -       : "r" (p), "r" (clr), "r" (set), "m" (*p)
74321 +       : "r" ((unsigned long)(p+1) - 4), "r" (clr), "r" (set), "m" (*p)
74322         : "cc" );
74323         return old;
74324  }
74325 @@ -485,11 +544,25 @@
74326  
74327  #define pte_same(A,B)  (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HASHPTE) == 0)
74328  
74329 +/*
74330 + * Note that on Book E processors, the pmd contains the kernel virtual
74331 + * (lowmem) address of the pte page.  The physical address is less useful
74332 + * because everything runs with translation enabled (even the TLB miss
74333 + * handler).  On everything else the pmd contains the physical address
74334 + * of the pte page.  -- paulus
74335 + */
74336 +#ifndef CONFIG_BOOKE
74337  #define pmd_page_kernel(pmd)   \
74338         ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
74339  #define pmd_page(pmd)          \
74340         (mem_map + (pmd_val(pmd) >> PAGE_SHIFT))
74341 -
74342 +#else
74343 +#define pmd_page_kernel(pmd)   \
74344 +       ((unsigned long) (pmd_val(pmd) & PAGE_MASK))
74345 +#define pmd_page(pmd)          \
74346 +       (mem_map + (__pa(pmd_val(pmd)) >> PAGE_SHIFT))
74347 +#endif
74348 +       
74349  /* to find an entry in a kernel page-table-directory */
74350  #define pgd_offset_k(address) pgd_offset(&init_mm, address)
74351  
74352 @@ -516,7 +589,8 @@
74353  #define pte_unmap(pte)         kunmap_atomic(pte, KM_PTE0)
74354  #define pte_unmap_nested(pte)  kunmap_atomic(pte, KM_PTE1)
74355  
74356 -extern pgd_t swapper_pg_dir[1024];
74357 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
74358 +
74359  extern void paging_init(void);
74360  
74361  /*
74362 diff -Nru a/include/asm-ppc/ppc_asm.h b/include/asm-ppc/ppc_asm.h
74363 --- a/include/asm-ppc/ppc_asm.h Sat Jan  4 00:44:11 2003
74364 +++ b/include/asm-ppc/ppc_asm.h Wed Sep  3 05:16:34 2003
74365 @@ -107,7 +107,7 @@
74366         bdnz    0b
74367  #endif
74368  
74369 -#if !defined(CONFIG_440)
74370 +#if !defined(CONFIG_44x)
74371  /*
74372   * On APUS (Amiga PowerPC cpu upgrade board), we don't know the
74373   * physical base address of RAM at compile time.
74374 @@ -125,7 +125,7 @@
74375         .align  1;                              \
74376         .long   0b;                             \
74377         .previous
74378 -#else  /* CONFIG_440 */
74379 +#else  /* CONFIG_44x */
74380  
74381  #define tophys(rd,rs)                          \
74382         mr      rd,rs
74383 @@ -133,7 +133,7 @@
74384  #define tovirt(rd,rs)                          \
74385         mr      rd,rs
74386  
74387 -#endif /* CONFIG_440 */
74388 +#endif /* CONFIG_44x */
74389  
74390  /*
74391   * On 64-bit cpus, we use the rfid instruction instead of rfi, but
74392 diff -Nru a/include/asm-ppc/processor.h b/include/asm-ppc/processor.h
74393 --- a/include/asm-ppc/processor.h       Wed Jul 16 20:41:10 2003
74394 +++ b/include/asm-ppc/processor.h       Wed Sep  3 05:16:34 2003
74395 @@ -3,6 +3,12 @@
74396  #define __ASM_PPC_PROCESSOR_H
74397  
74398  /*
74399 + * The Book E definitions are hacked into here for 440 right
74400 + * now.  This whole thing needs regorganized (maybe two files)
74401 + * so that it becomes readable. -Matt
74402 + */
74403 +
74404 +/*
74405   * Default implementation of macro that returns current
74406   * instruction pointer ("program counter").
74407   */
74408 @@ -45,6 +51,11 @@
74409  #define MSR_RI         (1<<1)          /* Recoverable Exception */
74410  #define MSR_LE         (1<<0)          /* Little Endian */
74411  
74412 +#ifdef CONFIG_BOOKE
74413 +#define MSR_IS         MSR_IR          /* Instruction Space */
74414 +#define MSR_DS         MSR_DR          /* Data Space */
74415 +#endif
74416 +
74417  #ifdef CONFIG_APUS_FAST_EXCEPT
74418  #define MSR_           (MSR_ME|MSR_IP|MSR_RI)
74419  #else
74420 @@ -93,8 +104,13 @@
74421  #define        SPRN_CDBCR      0x3D7   /* Cache Debug Control Register */
74422  #define        SPRN_CTR        0x009   /* Count Register */
74423  #define        SPRN_DABR       0x3F5   /* Data Address Breakpoint Register */
74424 +#ifndef CONFIG_BOOKE
74425  #define        SPRN_DAC1       0x3F6   /* Data Address Compare 1 */
74426  #define        SPRN_DAC2       0x3F7   /* Data Address Compare 2 */
74427 +#else
74428 +#define        SPRN_DAC1       0x13C   /* Book E Data Address Compare 1 */
74429 +#define        SPRN_DAC2       0x13D   /* Book E Data Address Compare 2 */
74430 +#endif /* CONFIG_BOOKE */
74431  #define        SPRN_DAR        0x013   /* Data Address Register */
74432  #define        SPRN_DBAT0L     0x219   /* Data BAT 0 Lower Register */
74433  #define        SPRN_DBAT0U     0x218   /* Data BAT 0 Upper Register */
74434 @@ -146,7 +162,11 @@
74435  #define          DBCR_SDA      0x00000004      /* Second DAC Enable */
74436  #define          DBCR_JOI      0x00000002      /* JTAG Serial Outbound Int. Enable */
74437  #define          DBCR_JII      0x00000001      /* JTAG Serial Inbound Int. Enable */
74438 +#ifndef CONFIG_BOOKE
74439  #define        SPRN_DBCR0      0x3F2   /* Debug Control Register 0 */
74440 +#else
74441 +#define        SPRN_DBCR0      0x134           /* Book E Debug Control Register 0 */
74442 +#endif /* CONFIG_BOOKE */
74443  #define   DBCR0_EDM         0x80000000  /* External Debug Mode             */
74444  #define   DBCR0_IDM         0x40000000  /* Internal Debug Mode             */
74445  #define   DBCR0_RST         0x30000000  /* all the bits in the RST field   */
74446 @@ -169,11 +189,18 @@
74447  #define   DBCR0_IA12T       0x00008000  /* Instr Addr 1-2 range Toggle     */
74448  #define   DBCR0_IA34T       0x00004000  /* Instr Addr 3-4 range Toggle     */
74449  #define   DBCR0_FT          0x00000001  /* Freeze Timers on debug event    */
74450 +#ifndef CONFIG_BOOKE
74451  #define        SPRN_DBCR1      0x3BD   /* Debug Control Register 1 */            
74452  #define        SPRN_DBSR       0x3F0   /* Debug Status Register */               
74453  #define   DBSR_IC          0x80000000  /* Instruction Completion          */
74454  #define   DBSR_BT          0x40000000  /* Branch taken */
74455  #define   DBSR_TIE         0x10000000  /* Trap Instruction debug Event    */
74456 +#else
74457 +#define        SPRN_DBCR1      0x135           /* Book E Debug Control Register 1 */
74458 +#define        SPRN_DBSR       0x130           /* Book E Debug Status Register */
74459 +#define   DBSR_IC          0x08000000  /* Book E Instruction Completion  */
74460 +#define   DBSR_TIE         0x01000000  /* Book E Trap Instruction Event */
74461 +#endif /* CONFIG_BOOKE */
74462  #define        SPRN_DCCR       0x3FA   /* Data Cache Cacheability Register */
74463  #define          DCCR_NOCACHE          0       /* Noncacheable */
74464  #define          DCCR_CACHE            1       /* Cacheable */
74465 @@ -181,7 +208,11 @@
74466  #define        SPRN_DCWR       0x3BA   /* Data Cache Write-thru Register */
74467  #define          DCWR_COPY             0       /* Copy-back */
74468  #define          DCWR_WRITE            1       /* Write-through */
74469 +#ifndef CONFIG_BOOKE
74470  #define        SPRN_DEAR       0x3D5   /* Data Error Address Register */
74471 +#else
74472 +#define SPRN_DEAR      0x03D   /* Book E Data Error Address Register */
74473 +#endif /* CONFIG_BOOKE */
74474  #define        SPRN_DEC        0x016   /* Decrement Register */
74475  #define        SPRN_DER        0x095   /* Debug Enable Regsiter */
74476  #define   DER_RSTE     0x40000000      /* Reset Interrupt */
74477 @@ -206,12 +237,16 @@
74478  #define        SPRN_DMISS      0x3D0   /* Data TLB Miss Register */
74479  #define        SPRN_DSISR      0x012   /* Data Storage Interrupt Status Register */
74480  #define        SPRN_EAR        0x11A   /* External Address Register */
74481 +#ifndef CONFIG_BOOKE
74482  #define        SPRN_ESR        0x3D4   /* Exception Syndrome Register */
74483 +#else
74484 +#define SPRN_ESR       0x03E           /* Book E Exception Syndrome Register */
74485 +#endif /* CONFIG_BOOKE */
74486  #define          ESR_MCI       0x80000000      /* 405 Machine Check - Instruction */
74487 -#define          ESR_IMCP      0x80000000      /* 403 Inst. Mach. Check - Protection */
74488 -#define          ESR_IMCN      0x40000000      /* 403 Inst. Mach. Check - Non-config */
74489 -#define          ESR_IMCB      0x20000000      /* 403 Inst. Mach. Check - Bus error */
74490 -#define          ESR_IMCT      0x10000000      /* 403 Inst. Mach. Check - Timeout */
74491 +#define          ESR_IMCP      0x80000000      /* Instr. Machine Check - Protection */
74492 +#define          ESR_IMCN      0x40000000      /* Instr. Machine Check - Non-config */
74493 +#define          ESR_IMCB      0x20000000      /* Instr. Machine Check - Bus error */
74494 +#define          ESR_IMCT      0x10000000      /* Instr. Machine Check - Timeout */
74495  #define          ESR_PIL       0x08000000      /* Program Exception - Illegal */
74496  #define          ESR_PPR       0x04000000      /* Program Exception - Priveleged */
74497  #define          ESR_PTR       0x02000000      /* Program Exception - Trap */
74498 @@ -266,8 +301,13 @@
74499  #define          HID1_SYNCBE   (1<<11)         /* 7450 ABE for sync, eieio */
74500  #define          HID1_ABE      (1<<10)         /* 7450 Address Broadcast Enable */
74501  #define        SPRN_IABR       0x3F2   /* Instruction Address Breakpoint Register */
74502 +#ifndef CONFIG_BOOKE
74503  #define        SPRN_IAC1       0x3F4   /* Instruction Address Compare 1 */
74504  #define        SPRN_IAC2       0x3F5   /* Instruction Address Compare 2 */
74505 +#else
74506 +#define        SPRN_IAC1       0x138   /* Book E Instruction Address Compare 1 */
74507 +#define        SPRN_IAC2       0x139   /* Book E Instruction Address Compare 2 */
74508 +#endif /* CONFIG_BOOKE */
74509  #define        SPRN_IBAT0L     0x211   /* Instruction BAT 0 Lower Register */
74510  #define        SPRN_IBAT0U     0x210   /* Instruction BAT 0 Upper Register */
74511  #define        SPRN_IBAT1L     0x213   /* Instruction BAT 1 Lower Register */
74512 @@ -358,8 +398,13 @@
74513  #define        SPRN_PBL2       0x3FE   /* Protection Bound Lower 2 */
74514  #define        SPRN_PBU1       0x3FD   /* Protection Bound Upper 1 */
74515  #define        SPRN_PBU2       0x3FF   /* Protection Bound Upper 2 */
74516 +#ifndef CONFIG_BOOKE
74517  #define        SPRN_PID        0x3B1   /* Process ID */
74518  #define        SPRN_PIR        0x3FF   /* Processor Identification Register */
74519 +#else
74520 +#define        SPRN_PID        0x030   /* Book E Process ID */
74521 +#define        SPRN_PIR        0x11E   /* Book E Processor Identification Register */
74522 +#endif /* CONFIG_BOOKE */
74523  #define        SPRN_PIT        0x3DB   /* Programmable Interval Timer */
74524  #define        SPRN_PMC1       0x3B9   /* Performance Counter Register 1 */
74525  #define        SPRN_PMC2       0x3BA   /* Performance Counter Register 2 */
74526 @@ -375,6 +420,7 @@
74527  #define          SGR_NORMAL            0
74528  #define          SGR_GUARDED           1
74529  #define        SPRN_SIA        0x3BB   /* Sampled Instruction Address Register */
74530 +#define        SPRN_SLER       0x3BB   /* Little-endian real mode */
74531  #define        SPRN_SPRG0      0x110   /* Special Purpose Register General 0 */
74532  #define        SPRN_SPRG1      0x111   /* Special Purpose Register General 1 */
74533  #define        SPRN_SPRG2      0x112   /* Special Purpose Register General 2 */
74534 @@ -387,6 +433,7 @@
74535  #define        SPRN_SRR1       0x01B   /* Save/Restore Register 1 */
74536  #define        SPRN_SRR2       0x3DE   /* Save/Restore Register 2 */
74537  #define        SPRN_SRR3       0x3DF   /* Save/Restore Register 3 */
74538 +#define        SPRN_SU0R       0x3BC   /* "User 0" real mode */
74539  #define        SPRN_TBHI       0x3DC   /* Time Base High (4xx) */
74540  #define        SPRN_TBHU       0x3CC   /* Time Base High User-mode (4xx) */
74541  #define        SPRN_TBLO       0x3DD   /* Time Base Low (4xx) */
74542 @@ -395,7 +442,11 @@
74543  #define        SPRN_TBRU       0x10D   /* Time Base Read Upper Register (user, R/O) */
74544  #define        SPRN_TBWL       0x11C   /* Time Base Lower Register (super, R/W) */
74545  #define        SPRN_TBWU       0x11D   /* Time Base Upper Register (super, R/W) */
74546 +#ifndef CONFIG_BOOKE
74547  #define        SPRN_TCR        0x3DA   /* Timer Control Register */
74548 +#else
74549 +#define        SPRN_TCR        0x154   /* Book E Timer Control Register */
74550 +#endif
74551  #define          TCR_WP(x)             (((x)&0x3)<<30) /* WDT Period */
74552  #define     TCR_WP_MASK         TCR_WP(3)
74553  #define            WP_2_17             0               /* 2^17 clocks */
74554 @@ -410,6 +461,7 @@
74555  #define            WRC_SYSTEM          3               /* System reset will occur */
74556  #define          TCR_WIE               0x08000000      /* WDT Interrupt Enable */
74557  #define          TCR_PIE               0x04000000      /* PIT Interrupt Enable */
74558 +#define          TCR_DIE               TCR_PIE         /* DEC Interrupt Enable */
74559  #define          TCR_FP(x)             (((x)&0x3)<<24) /* FIT Period */
74560  #define     TCR_FP_MASK         TCR_FP(3)
74561  #define            FP_2_9              0               /* 2^9 clocks */
74562 @@ -431,7 +483,11 @@
74563  #define        SPRN_THRM3      0x3FE   /* Thermal Management Register 3 */
74564  #define          THRM3_E               (1<<0)
74565  #define        SPRN_TLBMISS    0x3D4   /* 980 7450 TLB Miss Register */
74566 +#ifndef CONFIG_BOOKE
74567  #define        SPRN_TSR        0x3D8   /* Timer Status Register */
74568 +#else
74569 +#define        SPRN_TSR        0x150   /* Book E Timer Status Register */
74570 +#endif /* CONFIG_BOOKE */
74571  #define          TSR_ENW               0x80000000      /* Enable Next Watchdog */
74572  #define          TSR_WIS               0x40000000      /* WDT Interrupt Status */
74573  #define          TSR_WRS(x)            (((x)&0x3)<<28) /* WDT Reset Status */
74574 @@ -440,6 +496,7 @@
74575  #define            WRS_CHIP            2               /* WDT forced chip reset */
74576  #define            WRS_SYSTEM          3               /* WDT forced system reset */
74577  #define          TSR_PIS               0x08000000      /* PIT Interrupt Status */
74578 +#define          TSR_DIS               TSR_PIS         /* DEC Interrupt Status */
74579  #define          TSR_FIS               0x04000000      /* FIT Interrupt Status */
74580  #define        SPRN_UMMCR0     0x3A8   /* User Monitor Mode Control Register 0 */
74581  #define        SPRN_UMMCR1     0x3AC   /* User Monitor Mode Control Register 0 */
74582 @@ -452,6 +509,45 @@
74583  #define        SPRN_XER        0x001   /* Fixed Point Exception Register */
74584  #define        SPRN_ZPR        0x3B0   /* Zone Protection Register */
74585  
74586 +/* Book E definitions */
74587 +#define SPRN_DECAR     0x036   /* Decrementer Auto Reload Register */
74588 +#define SPRN_CSRR0     0x03A   /* Critical Save and Restore Register 0 */
74589 +#define SPRN_CSRR1     0x03B   /* Critical Save and Restore Register 1 */
74590 +#define        SPRN_IVPR       0x03F   /* Interrupt Vector Prefix Register */
74591 +#define SPRN_USPRG0    0x100   /* User Special Purpose Register General 0 */
74592 +#define        SPRN_SPRG4R     0x104   /* Special Purpose Register General 4 Read */
74593 +#define        SPRN_SPRG5R     0x105   /* Special Purpose Register General 5 Read */
74594 +#define        SPRN_SPRG6R     0x106   /* Special Purpose Register General 6 Read */
74595 +#define        SPRN_SPRG7R     0x107   /* Special Purpose Register General 7 Read */
74596 +#define        SPRN_SPRG4W     0x114   /* Special Purpose Register General 4 Write */
74597 +#define        SPRN_SPRG5W     0x115   /* Special Purpose Register General 5 Write */
74598 +#define        SPRN_SPRG6W     0x116   /* Special Purpose Register General 6 Write */
74599 +#define        SPRN_SPRG7W     0x117   /* Special Purpose Register General 7 Write */
74600 +#define SPRN_DBCR2     0x136   /* Debug Control Register 2 */
74601 +#define        SPRN_IAC3       0x13A   /* Instruction Address Compare 3 */
74602 +#define        SPRN_IAC4       0x13B   /* Instruction Address Compare 4 */
74603 +#define SPRN_DVC1      0x13E   /* */
74604 +#define SPRN_DVC2      0x13F   /* */
74605 +#define SPRN_IVOR0     0x190   /* Interrupt Vector Offset Register 0 */
74606 +#define SPRN_IVOR1     0x191   /* Interrupt Vector Offset Register 1 */
74607 +#define SPRN_IVOR2     0x192   /* Interrupt Vector Offset Register 2 */
74608 +#define SPRN_IVOR3     0x193   /* Interrupt Vector Offset Register 3 */
74609 +#define SPRN_IVOR4     0x194   /* Interrupt Vector Offset Register 4 */
74610 +#define SPRN_IVOR5     0x195   /* Interrupt Vector Offset Register 5 */
74611 +#define SPRN_IVOR6     0x196   /* Interrupt Vector Offset Register 6 */
74612 +#define SPRN_IVOR7     0x197   /* Interrupt Vector Offset Register 7 */
74613 +#define SPRN_IVOR8     0x198   /* Interrupt Vector Offset Register 8 */
74614 +#define SPRN_IVOR9     0x199   /* Interrupt Vector Offset Register 9 */
74615 +#define SPRN_IVOR10    0x19a   /* Interrupt Vector Offset Register 10 */
74616 +#define SPRN_IVOR11    0x19b   /* Interrupt Vector Offset Register 11 */
74617 +#define SPRN_IVOR12    0x19c   /* Interrupt Vector Offset Register 12 */
74618 +#define SPRN_IVOR13    0x19d   /* Interrupt Vector Offset Register 13 */
74619 +#define SPRN_IVOR14    0x19e   /* Interrupt Vector Offset Register 14 */
74620 +#define SPRN_IVOR15    0x19f   /* Interrupt Vector Offset Register 15 */
74621 +#define SPRN_MMUCR     0x3b2   /* MMU Control Register */
74622 +
74623 +#define ESR_ST         0x00800000      /* Store Operation */
74624 +
74625  /* Short-hand versions for a number of the above SPRNs */
74626  
74627  #define        CTR     SPRN_CTR        /* Counter Register */
74628 @@ -524,6 +620,16 @@
74629  #define        SPRG5   SPRN_SPRG5
74630  #define        SPRG6   SPRN_SPRG6
74631  #define        SPRG7   SPRN_SPRG7
74632 +#define SPRG4R  SPRN_SPRG4R     /* Book E Supervisor Private Registers */
74633 +#define SPRG5R  SPRN_SPRG5R
74634 +#define SPRG6R  SPRN_SPRG6R
74635 +#define SPRG7R  SPRN_SPRG7R
74636 +#define SPRG4W  SPRN_SPRG4W
74637 +#define SPRG5W  SPRN_SPRG5W
74638 +#define SPRG6W  SPRN_SPRG6W
74639 +#define SPRG7W  SPRN_SPRG7W
74640 +#define CSRR0  SPRN_CSRR0      /* Critical Save and Restore Register 0 */
74641 +#define CSRR1  SPRN_CSRR1      /* Critical Save and Restore Register 1 */
74642  #define        SRR0    SPRN_SRR0       /* Save and Restore Register 0 */
74643  #define        SRR1    SPRN_SRR1       /* Save and Restore Register 1 */
74644  #define        SRR2    SPRN_SRR2       /* Save and Restore Register 2 */
74645 @@ -557,6 +663,51 @@
74646  #define        PVR_MAJ(pvr)    (((pvr) >>  4) & 0xF)   /* Major revision field */
74647  #define        PVR_MIN(pvr)    (((pvr) >>  0) & 0xF)   /* Minor revision field */
74648  
74649 +/* Processor Version Numbers */
74650 +
74651 +#define        PVR_403GA       0x00200000
74652 +#define        PVR_403GB       0x00200100
74653 +#define        PVR_403GC       0x00200200
74654 +#define        PVR_403GCX      0x00201400
74655 +#define        PVR_405GP       0x40110000
74656 +#define        PVR_STB03XXX    0x40310000
74657 +#define        PVR_NP405H      0x41410000
74658 +#define        PVR_NP405L      0x41610000
74659 +#define PVR_440GP_RB   0x40120440
74660 +#define PVR_440GP_RC1  0x40120481
74661 +#define PVR_440GP_RC2  0x40200481
74662 +#define PVR_440GX_RC1  0x51b21850
74663 +#define        PVR_601         0x00010000
74664 +#define        PVR_602         0x00050000
74665 +#define        PVR_603         0x00030000
74666 +#define        PVR_603e        0x00060000
74667 +#define        PVR_603ev       0x00070000
74668 +#define        PVR_603r        0x00071000
74669 +#define        PVR_604         0x00040000
74670 +#define        PVR_604e        0x00090000
74671 +#define        PVR_604r        0x000A0000
74672 +#define        PVR_620         0x00140000
74673 +#define        PVR_740         0x00080000
74674 +#define        PVR_750         PVR_740
74675 +#define        PVR_740P        0x10080000
74676 +#define        PVR_750P        PVR_740P
74677 +#define        PVR_7400        0x000C0000
74678 +#define        PVR_7410        0x800C0000
74679 +#define        PVR_7450        0x80000000
74680 +/*
74681 + * For the 8xx processors, all of them report the same PVR family for
74682 + * the PowerPC core. The various versions of these processors must be
74683 + * differentiated by the version number in the Communication Processor
74684 + * Module (CPM).
74685 + */
74686 +#define        PVR_821         0x00500000
74687 +#define        PVR_823         PVR_821
74688 +#define        PVR_850         PVR_821
74689 +#define        PVR_860         PVR_821
74690 +#define        PVR_8240        0x00810100
74691 +#define        PVR_8245        0x80811014
74692 +#define        PVR_8260        PVR_8240
74693 +
74694  /* We only need to define a new _MACH_xxx for machines which are part of
74695   * a configuration which supports more than one type of different machine.
74696   * This is currently limited to CONFIG_PPC_MULTIPLATFORM and CHRP/PReP/PMac. -- Tom
74697 @@ -654,6 +805,7 @@
74698   */
74699  #define EISA_bus 0
74700  #define MCA_bus 0
74701 +#define MCA_bus__is_a_macro
74702  
74703  /* Lazy FPU handling on uni-processor */
74704  extern struct task_struct *last_task_used_math;
74705 diff -Nru a/include/asm-ppc/prom.h b/include/asm-ppc/prom.h
74706 --- a/include/asm-ppc/prom.h    Sat Jan  4 03:31:26 2003
74707 +++ b/include/asm-ppc/prom.h    Sun Aug 24 03:57:52 2003
74708 @@ -62,18 +62,35 @@
74709  struct prom_args;
74710  typedef void (*prom_entry)(struct prom_args *);
74711  
74712 -/* Prototypes */
74713 -extern void abort(void);
74714 -extern unsigned long prom_init(int, int, prom_entry);
74715 -extern void prom_print(const char *msg);
74716 -extern void relocate_nodes(void);
74717 -extern void finish_device_tree(void);
74718 +/* OBSOLETE: Old style node lookup */
74719  extern struct device_node *find_devices(const char *name);
74720  extern struct device_node *find_type_devices(const char *type);
74721  extern struct device_node *find_path_device(const char *path);
74722  extern struct device_node *find_compatible_devices(const char *type,
74723                                                    const char *compat);
74724  extern struct device_node *find_all_nodes(void);
74725 +
74726 +/* New style node lookup */
74727 +extern struct device_node *of_find_node_by_name(struct device_node *from,
74728 +       const char *name);
74729 +extern struct device_node *of_find_node_by_type(struct device_node *from,
74730 +       const char *type);
74731 +extern struct device_node *of_find_compatible_node(struct device_node *from,
74732 +       const char *type, const char *compat);
74733 +extern struct device_node *of_find_node_by_path(const char *path);
74734 +extern struct device_node *of_find_all_nodes(struct device_node *prev);
74735 +extern struct device_node *of_get_parent(const struct device_node *node);
74736 +extern struct device_node *of_get_next_child(const struct device_node *node,
74737 +                                            struct device_node *prev);
74738 +extern struct device_node *of_node_get(struct device_node *node);
74739 +extern void of_node_put(struct device_node *node);
74740 +
74741 +/* Other Prototypes */
74742 +extern void abort(void);
74743 +extern unsigned long prom_init(int, int, prom_entry);
74744 +extern void prom_print(const char *msg);
74745 +extern void relocate_nodes(void);
74746 +extern void finish_device_tree(void);
74747  extern int device_is_compatible(struct device_node *device, const char *);
74748  extern int machine_is_compatible(const char *compat);
74749  extern unsigned char *get_property(struct device_node *node, const char *name,
74750 diff -Nru a/include/asm-ppc/serial.h b/include/asm-ppc/serial.h
74751 --- a/include/asm-ppc/serial.h  Wed Jul  2 17:44:15 2003
74752 +++ b/include/asm-ppc/serial.h  Wed Sep  3 05:16:34 2003
74753 @@ -28,7 +28,7 @@
74754  #include <platforms/sandpoint.h>
74755  #elif defined(CONFIG_SPRUCE)
74756  #include <platforms/spruce_serial.h>
74757 -#elif defined(CONFIG_40x)
74758 +#elif defined(CONFIG_4xx)
74759  #include <asm/ibm4xx.h>
74760  #else
74761  
74762 diff -Nru a/include/asm-ppc/tlbflush.h b/include/asm-ppc/tlbflush.h
74763 --- a/include/asm-ppc/tlbflush.h        Wed Nov  6 21:40:28 2002
74764 +++ b/include/asm-ppc/tlbflush.h        Wed Sep  3 05:16:34 2003
74765 @@ -19,17 +19,23 @@
74766  
74767  #if defined(CONFIG_4xx)
74768  
74769 +#ifndef CONFIG_44x
74770 +#define __tlbia()      asm volatile ("sync; tlbia; isync" : : : "memory")
74771 +#else
74772 +#define __tlbia                _tlbia
74773 +#endif
74774 +
74775  static inline void flush_tlb_mm(struct mm_struct *mm)
74776 -       { _tlbia(); }
74777 +       { __tlbia(); }
74778  static inline void flush_tlb_page(struct vm_area_struct *vma,
74779                                 unsigned long vmaddr)
74780         { _tlbie(vmaddr); }
74781  static inline void flush_tlb_range(struct vm_area_struct *vma,
74782                                 unsigned long start, unsigned long end)
74783 -       { _tlbia(); }
74784 +       { __tlbia(); }
74785  static inline void flush_tlb_kernel_range(unsigned long start,
74786                                 unsigned long end)
74787 -       { _tlbia(); }
74788 +       { __tlbia(); }
74789  
74790  #elif defined(CONFIG_8xx)
74791  #define __tlbia()      asm volatile ("tlbia; sync" : : : "memory")
74792 diff -Nru a/include/asm-ppc/unistd.h b/include/asm-ppc/unistd.h
74793 --- a/include/asm-ppc/unistd.h  Tue Jul 15 04:47:19 2003
74794 +++ b/include/asm-ppc/unistd.h  Fri Aug 22 19:15:18 2003
74795 @@ -258,8 +258,9 @@
74796  #define __NR_utimes            251
74797  #define __NR_statfs64          252
74798  #define __NR_fstatfs64         253
74799 +#define __NR_fadvise64_64      254
74800  
74801 -#define __NR_syscalls          254
74802 +#define __NR_syscalls          255
74803  
74804  #define __NR(n)        #n
74805  
74806 diff -Nru a/include/asm-s390/semaphore.h b/include/asm-s390/semaphore.h
74807 --- a/include/asm-s390/semaphore.h      Thu Jun  6 14:31:19 2002
74808 +++ b/include/asm-s390/semaphore.h      Wed Sep  3 23:40:12 2003
74809 @@ -60,6 +60,7 @@
74810  
74811  static inline void down(struct semaphore * sem)
74812  {
74813 +       might_sleep();
74814         if (atomic_dec_return(&sem->count) < 0)
74815                 __down(sem);
74816  }
74817 @@ -68,6 +69,7 @@
74818  {
74819         int ret = 0;
74820  
74821 +       might_sleep();
74822         if (atomic_dec_return(&sem->count) < 0)
74823                 ret = __down_interruptible(sem);
74824         return ret;
74825 diff -Nru a/include/asm-sh/semaphore.h b/include/asm-sh/semaphore.h
74826 --- a/include/asm-sh/semaphore.h        Tue May  6 12:28:51 2003
74827 +++ b/include/asm-sh/semaphore.h        Wed Sep  3 23:40:12 2003
74828 @@ -107,6 +107,7 @@
74829         CHECK_MAGIC(sem->__magic);
74830  #endif
74831  
74832 +       might_sleep();
74833         if (atomic_dec_return(&sem->count) < 0)
74834                 ret = __down_interruptible(sem);
74835         return ret;
74836 diff -Nru a/include/asm-sparc/pci.h b/include/asm-sparc/pci.h
74837 --- a/include/asm-sparc/pci.h   Mon Jun  9 09:27:29 2003
74838 +++ b/include/asm-sparc/pci.h   Thu Aug 28 01:15:54 2003
74839 @@ -78,6 +78,14 @@
74840  #define pci_unmap_len_set(PTR, LEN_NAME, VAL)          \
74841         (((PTR)->LEN_NAME) = (VAL))
74842  
74843 +/*
74844 + * Same as above, only with pages instead of mapped addresses.
74845 + */
74846 +extern dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
74847 +                       unsigned long offset, size_t size, int direction);
74848 +extern void pci_unmap_page(struct pci_dev *hwdev,
74849 +                       dma_addr_t dma_address, size_t size, int direction);
74850 +
74851  /* Map a set of buffers described by scatterlist in streaming
74852   * mode for DMA.  This is the scather-gather version of the
74853   * above pci_map_single interface.  Here the scatter gather list
74854 diff -Nru a/include/asm-sparc/semaphore.h b/include/asm-sparc/semaphore.h
74855 --- a/include/asm-sparc/semaphore.h     Mon Feb  4 23:53:56 2002
74856 +++ b/include/asm-sparc/semaphore.h     Wed Sep  3 23:40:12 2003
74857 @@ -71,6 +71,7 @@
74858  #if WAITQUEUE_DEBUG
74859         CHECK_MAGIC(sem->__magic);
74860  #endif
74861 +       might_sleep();
74862  
74863         ptr = &(sem->count.counter);
74864         increment = 1;
74865 @@ -107,6 +108,7 @@
74866  #if WAITQUEUE_DEBUG
74867         CHECK_MAGIC(sem->__magic);
74868  #endif
74869 +       might_sleep();
74870  
74871         ptr = &(sem->count.counter);
74872         increment = 1;
74873 diff -Nru a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
74874 --- a/include/asm-sparc/smp.h   Mon Aug 18 19:46:23 2003
74875 +++ b/include/asm-sparc/smp.h   Thu Aug 28 00:18:36 2003
74876 @@ -8,11 +8,13 @@
74877  
74878  #include <linux/config.h>
74879  #include <linux/threads.h>
74880 -#include <linux/cpumask.h>
74881  #include <asm/head.h>
74882  #include <asm/btfixup.h>
74883  
74884  #ifndef __ASSEMBLY__
74885 +
74886 +#include <linux/cpumask.h>
74887 +
74888  /* PROM provided per-processor information we need
74889   * to start them all up.
74890   */
74891 diff -Nru a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
74892 --- a/include/asm-sparc/unistd.h        Sat Aug 16 14:13:18 2003
74893 +++ b/include/asm-sparc/unistd.h        Wed Aug 27 23:52:25 2003
74894 @@ -282,10 +282,11 @@
74895  #define __NR_timer_gettime     263
74896  #define __NR_timer_getoverrun  264
74897  #define __NR_timer_delete      265
74898 -/* WARNING: You MAY NOT add syscall numbers larger than 265, since
74899 +#define __NR_timer_create      266
74900 +/* WARNING: You MAY NOT add syscall numbers larger than 266, since
74901   *          all of the syscall tables in the Sparc kernel are
74902 - *          sized to have 266 entries (starting at zero).  Therefore
74903 - *          find a free slot in the 0-265 range.
74904 + *          sized to have 267 entries (starting at zero).  Therefore
74905 + *          find a free slot in the 0-266 range.
74906   */
74907  
74908  #define _syscall0(type,name) \
74909 diff -Nru a/include/asm-sparc64/siginfo.h b/include/asm-sparc64/siginfo.h
74910 --- a/include/asm-sparc64/siginfo.h     Sun Jan  5 23:08:44 2003
74911 +++ b/include/asm-sparc64/siginfo.h     Thu Aug 28 01:31:51 2003
74912 @@ -83,7 +83,7 @@
74913  #ifdef __KERNEL__
74914  
74915  typedef struct sigevent32 {
74916 -       sigval_t sigev_value;
74917 +       sigval_t32 sigev_value;
74918         int sigev_signo;
74919         int sigev_notify;
74920         union {
74921 diff -Nru a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
74922 --- a/include/asm-sparc64/unistd.h      Sat Aug 16 14:13:18 2003
74923 +++ b/include/asm-sparc64/unistd.h      Wed Aug 27 23:52:25 2003
74924 @@ -284,10 +284,11 @@
74925  #define __NR_timer_gettime     263
74926  #define __NR_timer_getoverrun  264
74927  #define __NR_timer_delete      265
74928 -/* WARNING: You MAY NOT add syscall numbers larger than 265, since
74929 +#define __NR_timer_create      266
74930 +/* WARNING: You MAY NOT add syscall numbers larger than 266, since
74931   *          all of the syscall tables in the Sparc kernel are
74932 - *          sized to have 266 entries (starting at zero).  Therefore
74933 - *          find a free slot in the 0-265 range.
74934 + *          sized to have 267 entries (starting at zero).  Therefore
74935 + *          find a free slot in the 0-266 range.
74936   */
74937  
74938  #define _syscall0(type,name) \
74939 diff -Nru a/include/asm-v850/semaphore.h b/include/asm-v850/semaphore.h
74940 --- a/include/asm-v850/semaphore.h      Fri Nov  1 08:38:12 2002
74941 +++ b/include/asm-v850/semaphore.h      Wed Sep  3 23:40:12 2003
74942 @@ -57,6 +57,7 @@
74943  
74944  extern inline void down (struct semaphore * sem)
74945  {
74946 +       might_sleep();
74947         if (atomic_dec_return (&sem->count) < 0)
74948                 __down (sem);
74949  }
74950 @@ -64,6 +65,7 @@
74951  extern inline int down_interruptible (struct semaphore * sem)
74952  {
74953         int ret = 0;
74954 +       might_sleep();
74955         if (atomic_dec_return (&sem->count) < 0)
74956                 ret = __down_interruptible (sem);
74957         return ret;
74958 diff -Nru a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h
74959 --- a/include/asm-x86_64/bitops.h       Mon Aug 18 19:46:23 2003
74960 +++ b/include/asm-x86_64/bitops.h       Sat Aug 23 04:08:11 2003
74961 @@ -466,7 +466,7 @@
74962  
74963         __asm__("bsfl %1,%0\n\t"
74964                 "cmovzl %2,%0" 
74965 -               : "=r" (r) : "g" (x), "r" (32));
74966 +               : "=r" (r) : "g" (x), "r" (-1));
74967         return r+1;
74968  }
74969  
74970 diff -Nru a/include/asm-x86_64/ia32.h b/include/asm-x86_64/ia32.h
74971 --- a/include/asm-x86_64/ia32.h Fri May 23 03:22:07 2003
74972 +++ b/include/asm-x86_64/ia32.h Sun Aug 31 16:13:59 2003
74973 @@ -160,7 +160,6 @@
74974         char                    f_fpack[6];
74975  };
74976  
74977 -#define IA32_PAGE_OFFSET 0xffffe000
74978  #define IA32_STACK_TOP IA32_PAGE_OFFSET
74979  
74980  #ifdef __KERNEL__
74981 diff -Nru a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h
74982 --- a/include/asm-x86_64/mpspec.h       Mon Aug 18 19:46:23 2003
74983 +++ b/include/asm-x86_64/mpspec.h       Sat Aug 23 05:13:33 2003
74984 @@ -169,7 +169,6 @@
74985  extern cpumask_t mp_bus_to_cpumask [MAX_MP_BUSSES];
74986  
74987  extern unsigned int boot_cpu_physical_apicid;
74988 -extern cpumask_t phys_cpu_present_map;
74989  extern int smp_found_config;
74990  extern void find_smp_config (void);
74991  extern void get_smp_config (void);
74992 @@ -197,6 +196,50 @@
74993  extern void mp_config_ioapic_for_sci(int irq);
74994  
74995  extern int using_apic_timer;
74996 +
74997 +#define PHYSID_ARRAY_SIZE      BITS_TO_LONGS(MAX_APICS)
74998 +
74999 +struct physid_mask
75000 +{
75001 +       unsigned long mask[PHYSID_ARRAY_SIZE];
75002 +};
75003 +
75004 +typedef struct physid_mask physid_mask_t;
75005 +
75006 +#define physid_set(physid, map)                        set_bit(physid, (map).mask)
75007 +#define physid_clear(physid, map)              clear_bit(physid, (map).mask)
75008 +#define physid_isset(physid, map)              test_bit(physid, (map).mask)
75009 +#define physid_test_and_set(physid, map)       test_and_set_bit(physid, (map).mask)
75010 +
75011 +#define physids_and(dst, src1, src2)           bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
75012 +#define physids_or(dst, src1, src2)            bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
75013 +#define physids_clear(map)                     bitmap_clear((map).mask, MAX_APICS)
75014 +#define physids_complement(map)                        bitmap_complement((map).mask, MAX_APICS)
75015 +#define physids_empty(map)                     bitmap_empty((map).mask, MAX_APICS)
75016 +#define physids_equal(map1, map2)              bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
75017 +#define physids_weight(map)                    bitmap_weight((map).mask, MAX_APICS)
75018 +#define physids_shift_right(d, s, n)           bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
75019 +#define physids_shift_left(d, s, n)            bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
75020 +#define physids_coerce(map)                    ((map).mask[0])
75021 +
75022 +#define physids_promote(physids)                                               \
75023 +       ({                                                                      \
75024 +               physid_mask_t __physid_mask = PHYSID_MASK_NONE;                 \
75025 +               __physid_mask.mask[0] = physids;                                \
75026 +               __physid_mask;                                                  \
75027 +       })
75028 +
75029 +#define physid_mask_of_physid(physid)                                          \
75030 +       ({                                                                      \
75031 +               physid_mask_t __physid_mask = PHYSID_MASK_NONE;                 \
75032 +               physid_set(physid, __physid_mask);                              \
75033 +               __physid_mask;                                                  \
75034 +       })
75035 +
75036 +#define PHYSID_MASK_ALL                { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
75037 +#define PHYSID_MASK_NONE       { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
75038 +
75039 +extern physid_mask_t phys_cpu_present_map;
75040  
75041  #endif
75042  
75043 diff -Nru a/include/asm-x86_64/percpu.h b/include/asm-x86_64/percpu.h
75044 --- a/include/asm-x86_64/percpu.h       Fri Aug  8 13:06:56 2003
75045 +++ b/include/asm-x86_64/percpu.h       Sat Aug 23 05:29:54 2003
75046 @@ -31,6 +31,9 @@
75047                         memcpy((pcpudst)+__per_cpu_offset(__i), \
75048                                (src), (size));                  \
75049  } while (0)
75050 +
75051 +extern void setup_per_cpu_areas(void);
75052 +
75053  #else /* ! SMP */
75054  
75055  #define DEFINE_PER_CPU(type, name) \
75056 @@ -45,7 +48,5 @@
75057  
75058  #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
75059  #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
75060 -
75061 -extern void setup_per_cpu_areas(void);
75062  
75063  #endif /* _ASM_X8664_PERCPU_H_ */
75064 diff -Nru a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
75065 --- a/include/asm-x86_64/processor.h    Wed Aug 20 11:16:28 2003
75066 +++ b/include/asm-x86_64/processor.h    Sun Aug 31 16:13:59 2003
75067 @@ -18,6 +18,7 @@
75068  #include <asm/current.h>
75069  #include <asm/system.h>
75070  #include <asm/mmsegment.h>
75071 +#include <linux/personality.h>
75072  
75073  #define TF_MASK                0x00000100
75074  #define IF_MASK                0x00000200
75075 @@ -172,7 +173,8 @@
75076  /* This decides where the kernel will search for a free chunk of vm
75077   * space during mmap's.
75078   */
75079 -#define TASK_UNMAPPED_32 0xa0000000
75080 +#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
75081 +#define TASK_UNMAPPED_32 (IA32_PAGE_OFFSET / 3)
75082  #define TASK_UNMAPPED_64 PAGE_ALIGN(TASK_SIZE/3) 
75083  #define TASK_UNMAPPED_BASE     \
75084         (test_thread_flag(TIF_IA32) ? TASK_UNMAPPED_32 : TASK_UNMAPPED_64)  
75085 @@ -225,7 +227,6 @@
75086          * 8 bytes, for an extra "long" of ~0UL
75087          */
75088         unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
75089 -       u32 __cacheline_filler[4];      /* size is 0x100 */
75090  } __attribute__((packed)) ____cacheline_aligned;
75091  
75092  struct thread_struct {
75093 diff -Nru a/include/asm-x86_64/semaphore.h b/include/asm-x86_64/semaphore.h
75094 --- a/include/asm-x86_64/semaphore.h    Tue Feb 25 01:39:19 2003
75095 +++ b/include/asm-x86_64/semaphore.h    Wed Sep  3 23:40:12 2003
75096 @@ -118,6 +118,7 @@
75097  #if WAITQUEUE_DEBUG
75098         CHECK_MAGIC(sem->__magic);
75099  #endif
75100 +       might_sleep();
75101  
75102         __asm__ __volatile__(
75103                 "# atomic down operation\n\t"
75104 @@ -144,6 +145,7 @@
75105  #if WAITQUEUE_DEBUG
75106         CHECK_MAGIC(sem->__magic);
75107  #endif
75108 +       might_sleep();
75109  
75110         __asm__ __volatile__(
75111                 "# atomic interruptible down operation\n\t"
75112 diff -Nru a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
75113 --- a/include/asm-x86_64/smp.h  Mon Aug 18 19:46:23 2003
75114 +++ b/include/asm-x86_64/smp.h  Sat Aug 23 05:14:50 2003
75115 @@ -36,7 +36,6 @@
75116   */
75117   
75118  extern void smp_alloc_memory(void);
75119 -extern cpumask_t phys_cpu_present_map;
75120  extern cpumask_t cpu_online_map;
75121  extern volatile unsigned long smp_invalidate_needed;
75122  extern int pic_mode;
75123 diff -Nru a/include/asm-x86_64/suspend.h b/include/asm-x86_64/suspend.h
75124 --- a/include/asm-x86_64/suspend.h      Sat Jun  7 00:54:11 2003
75125 +++ b/include/asm-x86_64/suspend.h      Sat Aug 23 05:22:09 2003
75126 @@ -44,7 +44,7 @@
75127                         :"r" ((thread)->debugreg##register))
75128  
75129  extern void fix_processor_context(void);
75130 -extern void do_magic(int resume);
75131 +extern int do_magic(int resume);
75132  
75133  #ifdef CONFIG_ACPI_SLEEP
75134  extern unsigned long saved_eip;
75135 diff -Nru a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
75136 --- a/include/asm-x86_64/topology.h     Mon Aug 18 19:46:23 2003
75137 +++ b/include/asm-x86_64/topology.h     Sat Aug 23 04:00:02 2003
75138 @@ -10,21 +10,18 @@
75139  /* Map the K8 CPU local memory controllers to a simple 1:1 CPU:NODE topology */
75140  
75141  extern int fake_node;
75142 -extern cpumask_t cpu_online_map;
75143 +extern unsigned long cpu_online_map;
75144  
75145  #define cpu_to_node(cpu)               (fake_node ? 0 : (cpu))
75146  #define memblk_to_node(memblk)         (fake_node ? 0 : (memblk))
75147  #define parent_node(node)              (node)
75148  #define node_to_first_cpu(node)        (fake_node ? 0 : (node))
75149 -#define node_to_cpu_mask(node) (fake_node ? cpu_online_map : cpumask_of_cpu(node))
75150 +#define node_to_cpu_mask(node) (fake_node ? cpu_online_map : (1UL << (node)))
75151  #define node_to_memblk(node)           (node)
75152  
75153 -static inline cpumask_t pcibus_to_cpumask(int bus)
75154 +static inline unsigned long pcibus_to_cpumask(int bus)
75155  {
75156 -       cpumask_t ret;
75157 -
75158 -       cpus_and(ret, mp_bus_to_cpumask[bus], cpu_online_map);
75159 -       return ret;
75160 +       return mp_bus_to_cpumask[bus] & cpu_online_map; 
75161  }
75162  
75163  #define NODE_BALANCE_RATE 30   /* CHECKME */ 
75164 diff -Nru a/include/linux/blkdev.h b/include/linux/blkdev.h
75165 --- a/include/linux/blkdev.h    Thu Aug 14 18:16:17 2003
75166 +++ b/include/linux/blkdev.h    Wed Sep  3 23:40:13 2003
75167 @@ -12,6 +12,8 @@
75168  #include <linux/wait.h>
75169  #include <linux/mempool.h>
75170  #include <linux/bio.h>
75171 +#include <linux/module.h>
75172 +#include <linux/stringify.h>
75173  
75174  #include <asm/scatterlist.h>
75175  
75176 @@ -243,6 +245,7 @@
75177  
75178  struct bio_vec;
75179  typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *);
75180 +typedef void (activity_fn) (void *data, int rw);
75181  
75182  enum blk_queue_state {
75183         Queue_down,
75184 @@ -283,6 +286,7 @@
75185         prep_rq_fn              *prep_rq_fn;
75186         unplug_fn               *unplug_fn;
75187         merge_bvec_fn           *merge_bvec_fn;
75188 +       activity_fn             *activity_fn;
75189  
75190         /*
75191          * Auto-unplugging state
75192 @@ -300,6 +304,8 @@
75193          */
75194         void                    *queuedata;
75195  
75196 +       void                    *activity_data;
75197 +
75198         /*
75199          * queue needs bounce pages for pages above this limit
75200          */
75201 @@ -504,6 +510,7 @@
75202  extern void blk_stop_queue(request_queue_t *q);
75203  extern void __blk_stop_queue(request_queue_t *q);
75204  extern void blk_run_queue(request_queue_t *q);
75205 +extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *);
75206  
75207  static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
75208  {
75209 @@ -666,6 +673,11 @@
75210  } \
75211  )
75212  #endif 
75213
75214 +
75215 +#define MODULE_ALIAS_BLOCKDEV(major,minor) \
75216 +       MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
75217 +#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
75218 +       MODULE_ALIAS("block-major-" __stringify(major) "-*")
75219 +
75220  
75221  #endif
75222 diff -Nru a/include/linux/cyclomx.h b/include/linux/cyclomx.h
75223 --- a/include/linux/cyclomx.h   Tue May 20 07:19:38 2003
75224 +++ b/include/linux/cyclomx.h   Sat Aug 23 20:38:19 2003
75225 @@ -52,7 +52,7 @@
75226         char in_isr;                    /* interrupt-in-service flag */
75227         char buff_int_mode_unbusy;      /* flag for carrying out dev_tint */
75228         wait_queue_head_t wait_stats;  /* to wait for the STATS indication */
75229 -       u32 mbox;                       /* -> mailbox */
75230 +       void *mbox;                     /* -> mailbox */
75231         void (*isr)(struct cycx_device* card);  /* interrupt service routine */
75232         int (*exec)(struct cycx_device* card, void* u_cmd, void* u_data);
75233         union {
75234 diff -Nru a/include/linux/cycx_cfm.h b/include/linux/cycx_cfm.h
75235 --- a/include/linux/cycx_cfm.h  Thu May 15 19:24:05 2003
75236 +++ b/include/linux/cycx_cfm.h  Sat Aug 23 19:57:15 2003
75237 @@ -90,7 +90,7 @@
75238         unsigned short      reserved[6];
75239         char                descr[CFM_DESCR_LEN];
75240         struct cycx_fw_info info;
75241 -       unsigned char       image[1];
75242 +       unsigned char       image[0];
75243  };
75244  
75245  struct cycx_fw_header {
75246 diff -Nru a/include/linux/cycx_drv.h b/include/linux/cycx_drv.h
75247 --- a/include/linux/cycx_drv.h  Thu May 15 19:33:21 2003
75248 +++ b/include/linux/cycx_drv.h  Sat Aug 23 20:11:44 2003
75249 @@ -48,7 +48,7 @@
75250  struct cycx_hw {
75251         u32 fwid;
75252         int irq;
75253 -       u32 dpmbase;
75254 +       void *dpmbase;
75255         u32 dpmsize;
75256         u32 reserved[5];
75257  };
75258 @@ -58,7 +58,7 @@
75259  extern int cycx_down(struct cycx_hw *hw);
75260  extern int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
75261  extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
75262 -extern int cycx_exec(u32 addr);
75263 +extern int cycx_exec(void *addr);
75264  
75265  extern void cycx_inten(struct cycx_hw *hw);
75266  extern void cycx_intr(struct cycx_hw *hw);
75267 diff -Nru a/include/linux/device.h b/include/linux/device.h
75268 --- a/include/linux/device.h    Tue Aug 19 23:36:44 2003
75269 +++ b/include/linux/device.h    Wed Sep  3 23:40:14 2003
75270 @@ -398,4 +398,9 @@
75271  #define dev_warn(dev, format, arg...)          \
75272         dev_printk(KERN_WARNING , dev , format , ## arg)
75273  
75274 +/* Create alias, so I can be autoloaded. */
75275 +#define MODULE_ALIAS_CHARDEV(major,minor) \
75276 +       MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
75277 +#define MODULE_ALIAS_CHARDEV_MAJOR(major) \
75278 +       MODULE_ALIAS("char-major-" __stringify(major) "-*")
75279  #endif /* _DEVICE_H_ */
75280 diff -Nru a/include/linux/ethtool.h b/include/linux/ethtool.h
75281 --- a/include/linux/ethtool.h   Thu Aug  7 13:16:01 2003
75282 +++ b/include/linux/ethtool.h   Mon Sep  1 17:25:54 2003
75283 @@ -255,8 +255,11 @@
75284  /* Some generic methods drivers may use in their ethtool_ops */
75285  u32 ethtool_op_get_link(struct net_device *dev);
75286  u32 ethtool_op_get_tx_csum(struct net_device *dev);
75287 +int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
75288  u32 ethtool_op_get_sg(struct net_device *dev);
75289  int ethtool_op_set_sg(struct net_device *dev, u32 data);
75290 +u32 ethtool_op_get_tso(struct net_device *dev);
75291 +int ethtool_op_set_tso(struct net_device *dev, u32 data);
75292  
75293  /**
75294   * &ethtool_ops - Alter and report network device settings
75295 @@ -284,6 +287,8 @@
75296   * set_tx_csum: Turn transmit checksums on or off
75297   * get_sg: Report whether scatter-gather is enabled
75298   * set_sg: Turn scatter-gather on or off
75299 + * get_tso: Report whether TCP segmentation offload is enabled
75300 + * set_tso: Turn TCP segmentation offload on or off
75301   * self_test: Run specified self-tests
75302   * get_strings: Return a set of strings that describe the requested objects 
75303   * phys_id: Identify the device
75304 @@ -337,6 +342,8 @@
75305         int     (*set_tx_csum)(struct net_device *, u32);
75306         u32     (*get_sg)(struct net_device *);
75307         int     (*set_sg)(struct net_device *, u32);
75308 +       u32     (*get_tso)(struct net_device *);
75309 +       int     (*set_tso)(struct net_device *, u32);
75310         int     (*self_test_count)(struct net_device *);
75311         void    (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
75312         void    (*get_strings)(struct net_device *, u32 stringset, u8 *);
75313 diff -Nru a/include/linux/fs.h b/include/linux/fs.h
75314 --- a/include/linux/fs.h        Fri Jul 11 10:32:02 2003
75315 +++ b/include/linux/fs.h        Sun Aug 31 16:14:42 2003
75316 @@ -336,10 +336,8 @@
75317  };
75318  
75319  struct block_device {
75320 -       struct list_head        bd_hash;
75321 -       atomic_t                bd_count;
75322 -       struct inode *          bd_inode;
75323         dev_t                   bd_dev;  /* not a kdev_t - it's a search key */
75324 +       struct inode *          bd_inode;       /* will die */
75325         int                     bd_openers;
75326         struct semaphore        bd_sem; /* open/close mutex */
75327         struct list_head        bd_inodes;
75328 @@ -347,10 +345,11 @@
75329         int                     bd_holders;
75330         struct block_device *   bd_contains;
75331         unsigned                bd_block_size;
75332 -       sector_t                bd_offset;
75333 +       struct hd_struct *      bd_part;
75334         unsigned                bd_part_count;
75335         int                     bd_invalidated;
75336         struct gendisk *        bd_disk;
75337 +       struct list_head        bd_list;
75338  };
75339  
75340  /*
75341 @@ -468,6 +467,16 @@
75342  #endif
75343  }
75344  
75345 +static inline unsigned iminor(struct inode *inode)
75346 +{
75347 +       return minor(inode->i_rdev);
75348 +}
75349 +
75350 +static inline unsigned imajor(struct inode *inode)
75351 +{
75352 +       return major(inode->i_rdev);
75353 +}
75354 +
75355  struct fown_struct {
75356         rwlock_t lock;          /* protects pid, uid, euid fields */
75357         int pid;                /* pid or -pgrp where SIGIO should be sent */
75358 @@ -600,6 +609,10 @@
75359  extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 __user *);
75360  #endif
75361  
75362 +extern void send_sigio(struct fown_struct *fown, int fd, int band);
75363 +extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
75364 +extern int fcntl_getlease(struct file *filp);
75365 +
75366  /* fs/locks.c */
75367  extern void locks_init_lock(struct file_lock *);
75368  extern void locks_copy_lock(struct file_lock *, struct file_lock *);
75369 @@ -1176,6 +1189,12 @@
75370  unsigned long invalidate_mapping_pages(struct address_space *mapping,
75371                                         pgoff_t start, pgoff_t end);
75372  unsigned long invalidate_inode_pages(struct address_space *mapping);
75373 +static inline void invalidate_remote_inode(struct inode *inode)
75374 +{
75375 +       if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
75376 +           S_ISLNK(inode->i_mode))
75377 +               invalidate_inode_pages(inode->i_mapping);
75378 +}
75379  extern void invalidate_inode_pages2(struct address_space *mapping);
75380  extern void write_inode_now(struct inode *, int);
75381  extern int filemap_fdatawrite(struct address_space *);
75382 diff -Nru a/include/linux/genhd.h b/include/linux/genhd.h
75383 --- a/include/linux/genhd.h     Thu Jun  5 23:32:48 2003
75384 +++ b/include/linux/genhd.h     Wed Sep  3 23:40:17 2003
75385 @@ -75,7 +75,6 @@
75386         unsigned read_merges, write_merges;
75387         unsigned read_ticks, write_ticks;
75388         unsigned io_ticks;
75389 -       int in_flight;
75390         unsigned time_in_queue;
75391  };
75392         
75393 @@ -101,6 +100,7 @@
75394  
75395         unsigned sync_io;               /* RAID */
75396         unsigned long stamp, stamp_idle;
75397 +       int in_flight;
75398  #ifdef CONFIG_SMP
75399         struct disk_stats *dkstats;
75400  #else
75401 @@ -197,7 +197,7 @@
75402  
75403  static inline sector_t get_start_sect(struct block_device *bdev)
75404  {
75405 -       return bdev->bd_offset;
75406 +       return bdev->bd_contains == bdev ? 0 : bdev->bd_part->start_sect;
75407  }
75408  static inline sector_t get_capacity(struct gendisk *disk)
75409  {
75410 diff -Nru a/include/linux/ide.h b/include/linux/ide.h
75411 --- a/include/linux/ide.h       Wed Aug 20 09:01:03 2003
75412 +++ b/include/linux/ide.h       Tue Sep  2 07:18:29 2003
75413 @@ -22,6 +22,7 @@
75414  #include <asm/system.h>
75415  #include <asm/hdreg.h>
75416  #include <asm/io.h>
75417 +#include <asm/semaphore.h>
75418  
75419  #define DEBUG_PM
75420  
75421 @@ -774,6 +775,7 @@
75422         int             crc_count;      /* crc counter to reduce drive speed */
75423         struct list_head list;
75424         struct device   gendev;
75425 +       struct semaphore gendev_rel_sem;        /* to deal with device release() */
75426         struct gendisk *disk;
75427  } ide_drive_t;
75428  
75429 @@ -1040,10 +1042,13 @@
75430         unsigned        auto_poll  : 1; /* supports nop auto-poll */
75431  
75432         struct device   gendev;
75433 +       struct semaphore gendev_rel_sem; /* To deal with device release() */
75434  
75435         void            *hwif_data;     /* extra hwif data */
75436  
75437         unsigned dma;
75438 +
75439 +       void (*led_act)(void *data, int rw);
75440  } ide_hwif_t;
75441  
75442  /*
75443 @@ -1242,21 +1247,6 @@
75444  
75445  extern int generic_ide_ioctl(struct block_device *, unsigned, unsigned long);
75446  
75447 -/*
75448 - * IDE modules.
75449 - */
75450 -#define IDE_CHIPSET_MODULE             0       /* not supported yet */
75451 -#define IDE_PROBE_MODULE               1
75452 -
75453 -typedef int    (ide_module_init_proc)(void);
75454 -
75455 -typedef struct ide_module_s {
75456 -       int                             type;
75457 -       ide_module_init_proc            *init;
75458 -       void                            *info;
75459 -       struct ide_module_s             *next;
75460 -} ide_module_t;
75461 -
75462  typedef struct ide_devices_s {
75463         char                    name[4];                /* hdX */
75464         unsigned                attached        : 1;    /* native */
75465 @@ -1274,8 +1264,7 @@
75466   */
75467  #ifndef _IDE_C
75468  extern ide_hwif_t      ide_hwifs[];            /* master data repository */
75469 -extern ide_module_t    *ide_chipsets;
75470 -extern ide_module_t    *ide_probe;
75471 +extern int (*ide_probe)(void);
75472  
75473  extern ide_devices_t   *idedisk;
75474  extern ide_devices_t   *idecd;
75475 @@ -1772,8 +1761,6 @@
75476  extern void ide_hwif_release_regions(ide_hwif_t* hwif);
75477  extern void ide_unregister (unsigned int index);
75478  
75479 -extern int export_ide_init_queue(ide_drive_t *);
75480 -extern u8 export_probe_for_drive(ide_drive_t *);
75481  extern int probe_hwif_init(ide_hwif_t *);
75482  
75483  static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
75484 @@ -1793,6 +1780,24 @@
75485  extern char *ide_xfer_verbose(u8 xfer_rate);
75486  extern void ide_toggle_bounce(ide_drive_t *drive, int on);
75487  extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
75488 +
75489 +typedef struct ide_pio_timings_s {
75490 +       int     setup_time;     /* Address setup (ns) minimum */
75491 +       int     active_time;    /* Active pulse (ns) minimum */
75492 +       int     cycle_time;     /* Cycle time (ns) minimum = (setup + active + recovery) */
75493 +} ide_pio_timings_t;
75494 +
75495 +typedef struct ide_pio_data_s {
75496 +       u8 pio_mode;
75497 +       u8 use_iordy;
75498 +       u8 overridden;
75499 +       u8 blacklisted;
75500 +       unsigned int cycle_time;
75501 +} ide_pio_data_t;
75502 +
75503 +extern u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d);
75504 +extern const ide_pio_timings_t ide_pio_timings[6];
75505 +
75506  
75507  extern spinlock_t ide_lock;
75508  extern struct semaphore ide_cfg_sem;
75509 diff -Nru a/include/linux/ipv6_route.h b/include/linux/ipv6_route.h
75510 --- a/include/linux/ipv6_route.h        Wed Jul 23 02:57:57 2003
75511 +++ b/include/linux/ipv6_route.h        Sat Aug 30 21:26:12 2003
75512 @@ -24,6 +24,7 @@
75513  #define RTF_CACHE      0x01000000      /* cache entry                  */
75514  #define RTF_FLOW       0x02000000      /* flow significant route       */
75515  #define RTF_POLICY     0x04000000      /* policy route                 */
75516 +#define RTF_NDISC      0x08000000      /* ndisc route                  */
75517  
75518  #define RTF_LOCAL      0x80000000
75519  
75520 diff -Nru a/include/linux/isdn/capilli.h b/include/linux/isdn/capilli.h
75521 --- a/include/linux/isdn/capilli.h      Sun May 26 09:49:48 2002
75522 +++ b/include/linux/isdn/capilli.h      Wed Sep  3 03:17:15 2003
75523 @@ -54,7 +54,7 @@
75524                              int count, int *eof, struct capi_ctr *card);
75525  
75526         /* filled in before calling ready callback */
75527 -       u8 manu[CAPI_MANUFACTURER_LEN]; /* CAPI_GET_MANUFACTURER */
75528 +       u8 manu[CAPI_MANUFACTURER_LEN];         /* CAPI_GET_MANUFACTURER */
75529         capi_version version;                   /* CAPI_GET_VERSION */
75530         capi_profile profile;                   /* CAPI_GET_PROFILE */
75531         u8 serial[CAPI_SERIAL_LEN];             /* CAPI_GET_SERIAL */
75532 diff -Nru a/include/linux/isdn.h b/include/linux/isdn.h
75533 --- a/include/linux/isdn.h      Tue Jun 17 20:25:22 2003
75534 +++ b/include/linux/isdn.h      Wed Sep  3 03:17:15 2003
75535 @@ -258,13 +258,13 @@
75536   * variables. Of course, we need to check skb_headroom prior to
75537   * any access.
75538   */
75539 -typedef struct isdn_audio_skb {
75540 +typedef struct _isdnaudio_header {
75541    unsigned short dle_count;
75542    unsigned char  lock;
75543 -} isdn_audio_skb;
75544 +} isdnaudio_header;
75545  
75546 -#define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdn_audio_skb*)skb->head)->dle_count)
75547 -#define ISDN_AUDIO_SKB_LOCK(skb) (((isdn_audio_skb*)skb->head)->lock)
75548 +#define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdnaudio_header*)skb->head)->dle_count)
75549 +#define ISDN_AUDIO_SKB_LOCK(skb) (((isdnaudio_header*)skb->head)->lock)
75550  #endif
75551  
75552  /* Private data of AT-command-interpreter */
75553 @@ -291,6 +291,7 @@
75554  /* Private data (similar to async_struct in <linux/serial.h>) */
75555  typedef struct modem_info {
75556    int                  magic;
75557 +  struct module                *owner;
75558    int                  flags;           /* defined in tty.h               */
75559    int                  x_char;          /* xon/xoff character             */
75560    int                  mcr;             /* Modem control register         */
75561 diff -Nru a/include/linux/kdev_t.h b/include/linux/kdev_t.h
75562 --- a/include/linux/kdev_t.h    Fri Aug  1 02:22:20 2003
75563 +++ b/include/linux/kdev_t.h    Tue Aug 26 09:25:39 2003
75564 @@ -90,22 +90,7 @@
75565         return dev.value;
75566  }
75567  
75568 -static inline kdev_t val_to_kdev(unsigned int val)
75569 -{
75570 -       kdev_t dev;
75571 -       dev.value = val;
75572 -       return dev;
75573 -}
75574 -
75575 -#define HASHDEV(dev)   (kdev_val(dev))
75576  #define NODEV          (mk_kdev(0,0))
75577 -
75578 -static inline int kdev_same(kdev_t dev1, kdev_t dev2)
75579 -{
75580 -       return dev1.value == dev2.value;
75581 -}
75582 -
75583 -#define kdev_none(d1)  (!kdev_val(d1))
75584  
75585  /* Mask off the high bits for now.. */
75586  #define minor(dev)     ((dev).value & 0xff)
75587 diff -Nru a/include/linux/kernel.h b/include/linux/kernel.h
75588 --- a/include/linux/kernel.h    Wed Jun 11 07:54:10 2003
75589 +++ b/include/linux/kernel.h    Wed Sep  3 23:40:12 2003
75590 @@ -52,8 +52,10 @@
75591  #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
75592  void __might_sleep(char *file, int line);
75593  #define might_sleep() __might_sleep(__FILE__, __LINE__)
75594 +#define might_sleep_if(cond) do { if (unlikely(cond)) might_sleep(); } while (0)
75595  #else
75596  #define might_sleep() do {} while(0)
75597 +#define might_sleep_if(cond) do {} while (0)
75598  #endif
75599  
75600  extern struct notifier_block *panic_notifier_list;
75601 diff -Nru a/include/linux/miscdevice.h b/include/linux/miscdevice.h
75602 --- a/include/linux/miscdevice.h        Sun Apr 20 16:21:19 2003
75603 +++ b/include/linux/miscdevice.h        Wed Sep  3 23:40:14 2003
75604 @@ -1,5 +1,7 @@
75605  #ifndef _LINUX_MISCDEVICE_H
75606  #define _LINUX_MISCDEVICE_H
75607 +#include <linux/module.h>
75608 +#include <linux/major.h>
75609  
75610  #define BUSMOUSE_MINOR 0
75611  #define PSMOUSE_MINOR  1
75612 @@ -48,4 +50,7 @@
75613  extern int misc_register(struct miscdevice * misc);
75614  extern int misc_deregister(struct miscdevice * misc);
75615  
75616 +#define MODULE_ALIAS_MISCDEV(minor)                            \
75617 +       MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR)      \
75618 +       "-" __stringify(minor))
75619  #endif
75620 diff -Nru a/include/linux/mmzone.h b/include/linux/mmzone.h
75621 --- a/include/linux/mmzone.h    Fri Aug  1 03:02:10 2003
75622 +++ b/include/linux/mmzone.h    Sun Aug 31 16:14:47 2003
75623 @@ -89,17 +89,24 @@
75624  
75625         ZONE_PADDING(_pad2_)
75626  
75627 -       /*
75628 -        * measure of scanning intensity for this zone. It is calculated
75629 -        * as exponentially decaying average of the scanning priority
75630 -        * required to free enough pages in this zone
75631 -        * (zone_adj_pressure()).
75632 +       /*
75633 +        * prev_priority holds the scanning priority for this zone.  It is
75634 +        * defined as the scanning priority at which we achieved our reclaim
75635 +        * target at the previous try_to_free_pages() or balance_pgdat()
75636 +        * invokation.
75637          *
75638 -        *     0                    --- low pressure
75639 +        * We use prev_priority as a measure of how much stress page reclaim is
75640 +        * under - it drives the swappiness decision: whether to unmap mapped
75641 +        * pages.
75642          *
75643 -        *     (DEF_PRIORITY << 10) --- high pressure
75644 +        * temp_priority is used to remember the scanning priority at which
75645 +        * this zone was successfully refilled to free_pages == pages_high.
75646 +        *
75647 +        * Access to both these fields is quite racy even on uniprocessor.  But
75648 +        * it is expected to average out OK.
75649          */
75650 -       int pressure;
75651 +       int temp_priority;
75652 +       int prev_priority;
75653  
75654         /*
75655          * free areas of different sizes
75656 diff -Nru a/include/linux/net.h b/include/linux/net.h
75657 --- a/include/linux/net.h       Mon May 12 14:35:19 2003
75658 +++ b/include/linux/net.h       Tue Sep  2 04:38:09 2003
75659 @@ -20,6 +20,7 @@
75660  
75661  #include <linux/config.h>
75662  #include <linux/wait.h>
75663 +#include <linux/stringify.h>
75664  
75665  struct poll_table_struct;
75666  struct inode;
75667 @@ -243,6 +244,8 @@
75668  };
75669  #endif
75670  
75671 +#define MODULE_ALIAS_NETPROTO(proto) \
75672 +       MODULE_ALIAS("net-pf-" __stringify(proto))
75673  
75674  #endif /* __KERNEL__ */
75675  #endif /* _LINUX_NET_H */
75676 diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
75677 --- a/include/linux/netdevice.h Tue Aug 19 21:01:19 2003
75678 +++ b/include/linux/netdevice.h Mon Sep  1 12:14:20 2003
75679 @@ -168,9 +168,9 @@
75680         unsigned fastroute_deferred_out;
75681         unsigned fastroute_latency_reduction;
75682         unsigned cpu_collision;
75683 -} ____cacheline_aligned;
75684 +};
75685  
75686 -extern struct netif_rx_stats netdev_rx_stat[];
75687 +DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat);
75688  
75689  
75690  /*
75691 @@ -830,6 +830,38 @@
75692         smp_mb__before_clear_bit();
75693         clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
75694         local_irq_restore(flags);
75695 +}
75696 +
75697 +static inline void netif_poll_disable(struct net_device *dev)
75698 +{
75699 +       while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
75700 +               /* No hurry. */
75701 +               current->state = TASK_INTERRUPTIBLE;
75702 +               schedule_timeout(1);
75703 +       }
75704 +}
75705 +
75706 +static inline void netif_poll_enable(struct net_device *dev)
75707 +{
75708 +       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
75709 +}
75710 +
75711 +/* same as netif_rx_complete, except that local_irq_save(flags)
75712 + * has already been issued
75713 + */
75714 +static inline void __netif_rx_complete(struct net_device *dev)
75715 +{
75716 +       if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
75717 +       list_del(&dev->poll_list);
75718 +       smp_mb__before_clear_bit();
75719 +       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
75720 +}
75721 +
75722 +static inline void netif_tx_disable(struct net_device *dev)
75723 +{
75724 +       spin_lock_bh(&dev->xmit_lock);
75725 +       netif_stop_queue(dev);
75726 +       spin_unlock_bh(&dev->xmit_lock);
75727  }
75728  
75729  /* These functions live elsewhere (drivers/net/net_init.c, but related) */
75730 diff -Nru a/include/linux/netfilter_bridge/ebt_802_3.h b/include/linux/netfilter_bridge/ebt_802_3.h
75731 --- /dev/null   Wed Dec 31 16:00:00 1969
75732 +++ b/include/linux/netfilter_bridge/ebt_802_3.h        Sat Aug 30 20:40:29 2003
75733 @@ -0,0 +1,60 @@
75734 +#ifndef __LINUX_BRIDGE_EBT_802_3_H
75735 +#define __LINUX_BRIDGE_EBT_802_3_H
75736 +
75737 +#define EBT_802_3_SAP 0x01
75738 +#define EBT_802_3_TYPE 0x02
75739 +
75740 +#define EBT_802_3_MATCH "802_3"
75741 +
75742 +/*
75743 + * If frame has DSAP/SSAP value 0xaa you must check the SNAP type
75744 + * to discover what kind of packet we're carrying. 
75745 + */
75746 +#define CHECK_TYPE 0xaa
75747 +
75748 +/*
75749 + * Control field may be one or two bytes.  If the first byte has
75750 + * the value 0x03 then the entire length is one byte, otherwise it is two.
75751 + * One byte controls are used in Unnumbered Information frames.
75752 + * Two byte controls are used in Numbered Information frames.
75753 + */
75754 +#define IS_UI 0x03
75755 +
75756 +#define EBT_802_3_MASK (EBT_802_3_SAP | EBT_802_3_TYPE | EBT_802_3)
75757 +
75758 +/* ui has one byte ctrl, ni has two */
75759 +struct hdr_ui {
75760 +       uint8_t dsap;
75761 +       uint8_t ssap;
75762 +       uint8_t ctrl;
75763 +       uint8_t orig[3];
75764 +       uint16_t type;
75765 +};
75766 +
75767 +struct hdr_ni {
75768 +       uint8_t dsap;
75769 +       uint8_t ssap;
75770 +       uint16_t ctrl;
75771 +       uint8_t  orig[3];
75772 +       uint16_t type;
75773 +};
75774 +
75775 +struct ebt_802_3_hdr {
75776 +       uint8_t  daddr[6];
75777 +       uint8_t  saddr[6];
75778 +       uint16_t len;
75779 +       union {
75780 +               struct hdr_ui ui;
75781 +               struct hdr_ni ni;
75782 +       } llc;
75783 +};
75784 +
75785 +struct ebt_802_3_info 
75786 +{
75787 +       uint8_t  sap;
75788 +       uint16_t type;
75789 +       uint8_t  bitmask;
75790 +       uint8_t  invflags;
75791 +};
75792 +
75793 +#endif
75794 diff -Nru a/include/linux/netfilter_bridge/ebt_arpreply.h b/include/linux/netfilter_bridge/ebt_arpreply.h
75795 --- /dev/null   Wed Dec 31 16:00:00 1969
75796 +++ b/include/linux/netfilter_bridge/ebt_arpreply.h     Sun Aug 24 04:31:45 2003
75797 @@ -0,0 +1,11 @@
75798 +#ifndef __LINUX_BRIDGE_EBT_ARPREPLY_H
75799 +#define __LINUX_BRIDGE_EBT_ARPREPLY_H
75800 +
75801 +struct ebt_arpreply_info
75802 +{
75803 +       unsigned char mac[ETH_ALEN];
75804 +       int target;
75805 +};
75806 +#define EBT_ARPREPLY_TARGET "arpreply"
75807 +
75808 +#endif
75809 diff -Nru a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
75810 --- a/include/linux/netfilter_bridge.h  Sun Apr 27 18:39:57 2003
75811 +++ b/include/linux/netfilter_bridge.h  Mon Sep  1 01:44:26 2003
75812 @@ -6,7 +6,7 @@
75813  
75814  #include <linux/config.h>
75815  #include <linux/netfilter.h>
75816 -#if defined(__KERNEL__) && defined(CONFIG_NETFILTER)
75817 +#if defined(__KERNEL__) && defined(CONFIG_BRIDGE_NETFILTER)
75818  #include <asm/atomic.h>
75819  #endif
75820  
75821 @@ -27,11 +27,6 @@
75822  
75823  #ifdef __KERNEL__
75824  
75825 -#define BRNF_PKT_TYPE                  0x01
75826 -#define BRNF_BRIDGED_DNAT              0x02
75827 -#define BRNF_DONT_TAKE_PARENT          0x04
75828 -#define BRNF_BRIDGED                   0x08
75829 -
75830  enum nf_br_hook_priorities {
75831         NF_BR_PRI_FIRST = INT_MIN,
75832         NF_BR_PRI_NAT_DST_BRIDGED = -300,
75833 @@ -43,7 +38,13 @@
75834         NF_BR_PRI_LAST = INT_MAX,
75835  };
75836  
75837 -#ifdef CONFIG_NETFILTER
75838 +#ifdef CONFIG_BRIDGE_NETFILTER
75839 +
75840 +#define BRNF_PKT_TYPE                  0x01
75841 +#define BRNF_BRIDGED_DNAT              0x02
75842 +#define BRNF_DONT_TAKE_PARENT          0x04
75843 +#define BRNF_BRIDGED                   0x08
75844 +
75845  static inline
75846  struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
75847  {
75848 @@ -63,7 +64,7 @@
75849                 __u32 ipv4;
75850         } daddr;
75851  };
75852 -#endif /* CONFIG_NETFILTER */
75853 +#endif /* CONFIG_BRIDGE_NETFILTER */
75854  
75855  #endif /* __KERNEL__ */
75856  #endif
75857 diff -Nru a/include/linux/netfilter_ipv4/ipt_CLASSIFY.h b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h
75858 --- /dev/null   Wed Dec 31 16:00:00 1969
75859 +++ b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h       Sun Aug 24 17:25:17 2003
75860 @@ -0,0 +1,8 @@
75861 +#ifndef _IPT_CLASSIFY_H
75862 +#define _IPT_CLASSIFY_H
75863 +
75864 +struct ipt_classify_target_info {
75865 +       u_int32_t priority;
75866 +};
75867 +
75868 +#endif /*_IPT_CLASSIFY_H */
75869 diff -Nru a/include/linux/netfilter_ipv4/ipt_SAME.h b/include/linux/netfilter_ipv4/ipt_SAME.h
75870 --- /dev/null   Wed Dec 31 16:00:00 1969
75871 +++ b/include/linux/netfilter_ipv4/ipt_SAME.h   Sun Aug 24 17:25:18 2003
75872 @@ -0,0 +1,19 @@
75873 +#ifndef _IPT_SAME_H
75874 +#define _IPT_SAME_H
75875 +
75876 +#define IPT_SAME_MAX_RANGE     10
75877 +
75878 +#define IPT_SAME_NODST         0x01
75879 +
75880 +struct ipt_same_info
75881 +{
75882 +       unsigned char info;
75883 +       u_int32_t rangesize;
75884 +       u_int32_t ipnum;
75885 +       u_int32_t *iparray;
75886 +
75887 +       /* hangs off end. */
75888 +       struct ip_nat_range range[IPT_SAME_MAX_RANGE];
75889 +};
75890 +
75891 +#endif /*_IPT_SAME_H*/
75892 diff -Nru a/include/linux/netfilter_ipv4/ipt_iprange.h b/include/linux/netfilter_ipv4/ipt_iprange.h
75893 --- /dev/null   Wed Dec 31 16:00:00 1969
75894 +++ b/include/linux/netfilter_ipv4/ipt_iprange.h        Sun Aug 24 17:25:18 2003
75895 @@ -0,0 +1,23 @@
75896 +#ifndef _IPT_IPRANGE_H
75897 +#define _IPT_IPRANGE_H
75898 +
75899 +#define IPRANGE_SRC            0x01    /* Match source IP address */
75900 +#define IPRANGE_DST            0x02    /* Match destination IP address */
75901 +#define IPRANGE_SRC_INV                0x10    /* Negate the condition */
75902 +#define IPRANGE_DST_INV                0x20    /* Negate the condition */
75903 +
75904 +struct ipt_iprange {
75905 +       /* Inclusive: network order. */
75906 +       u_int32_t min_ip, max_ip;
75907 +};
75908 +
75909 +struct ipt_iprange_info
75910 +{
75911 +       struct ipt_iprange src;
75912 +       struct ipt_iprange dst;
75913 +
75914 +       /* Flags from above */
75915 +       u_int8_t flags;
75916 +};
75917 +
75918 +#endif /* _IPT_IPRANGE_H */
75919 diff -Nru a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
75920 --- a/include/linux/nfsd/nfsfh.h        Mon Feb 17 13:50:11 2003
75921 +++ b/include/linux/nfsd/nfsfh.h        Tue Aug 26 09:25:41 2003
75922 @@ -294,8 +294,8 @@
75923                 /* how much do we care for accuracy with MinixFS? */
75924                 fhp->fh_post_blocks     = (inode->i_size+511) >> 9;
75925         }
75926 -       fhp->fh_post_rdev[0]    = htonl((u32)major(inode->i_rdev));
75927 -       fhp->fh_post_rdev[1]    = htonl((u32)minor(inode->i_rdev));
75928 +       fhp->fh_post_rdev[0]    = htonl((u32)imajor(inode));
75929 +       fhp->fh_post_rdev[1]    = htonl((u32)iminor(inode));
75930         fhp->fh_post_atime      = inode->i_atime;
75931         fhp->fh_post_mtime      = inode->i_mtime;
75932         fhp->fh_post_ctime      = inode->i_ctime;
75933 diff -Nru a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
75934 --- a/include/linux/nfsd/state.h        Thu Jun 26 21:26:02 2003
75935 +++ b/include/linux/nfsd/state.h        Sat Aug 23 15:07:31 2003
75936 @@ -113,21 +113,15 @@
75937         int                     so_confirmed; /* successful OPEN_CONFIRM? */
75938  };
75939  
75940 -typedef struct {
75941 -       u32                     dev; /* super_block->s_dev */
75942 -       unsigned long           ino;
75943 -       u32                     generation;
75944 -} nfs4_ino_desc_t;
75945 -
75946  /*
75947  *  nfs4_file: a file opened by some number of (open) nfs4_stateowners.
75948  *    o fi_perfile list is used to search for conflicting 
75949  *      share_acces, share_deny on the file.
75950  */
75951  struct nfs4_file {
75952 -       struct list_head        fi_hash;    /* hash by nfs4_ino_desc_t fields */
75953 +       struct list_head        fi_hash;    /* hash by "struct inode *" */
75954         struct list_head        fi_perfile; /* list: nfs4_stateid */
75955 -       nfs4_ino_desc_t         fi_ino;
75956 +       struct inode            *fi_inode;
75957         u32                     fi_id;      /* used with stateowner->so_id 
75958                                              * for openstateid_hashtbl hash */
75959  };
75960 diff -Nru a/include/linux/page-flags.h b/include/linux/page-flags.h
75961 --- a/include/linux/page-flags.h        Tue Jun 17 23:04:16 2003
75962 +++ b/include/linux/page-flags.h        Wed Sep  3 23:40:11 2003
75963 @@ -191,6 +191,8 @@
75964  #define PageSlab(page)         test_bit(PG_slab, &(page)->flags)
75965  #define SetPageSlab(page)      set_bit(PG_slab, &(page)->flags)
75966  #define ClearPageSlab(page)    clear_bit(PG_slab, &(page)->flags)
75967 +#define TestClearPageSlab(page)        test_and_clear_bit(PG_slab, &(page)->flags)
75968 +#define TestSetPageSlab(page)  test_and_set_bit(PG_slab, &(page)->flags)
75969  
75970  #ifdef CONFIG_HIGHMEM
75971  #define PageHighMem(page)      test_bit(PG_highmem, &(page)->flags)
75972 diff -Nru a/include/linux/pci_ids.h b/include/linux/pci_ids.h
75973 --- a/include/linux/pci_ids.h   Wed Aug 20 14:33:08 2003
75974 +++ b/include/linux/pci_ids.h   Mon Sep  1 15:53:57 2003
75975 @@ -798,6 +798,7 @@
75976  #define PCI_DEVICE_ID_APPLE_UNI_N_FW2  0x0030
75977  #define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2        0x0032
75978  #define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034
75979 +#define PCI_DEVICE_ID_APPLE_KAUAI_ATA  0x003b
75980  #define PCI_DEVICE_ID_APPLE_KEYLARGO_I 0x003e
75981  #define PCI_DEVICE_ID_APPLE_TIGON3     0x1645
75982  
75983 @@ -877,6 +878,7 @@
75984  
75985  #define PCI_DEVICE_ID_SII_680          0x0680
75986  #define PCI_DEVICE_ID_SII_3112         0x3112
75987 +#define PCI_DEVICE_ID_SII_1210SA       0x0240
75988  
75989  #define PCI_VENDOR_ID_VISION           0x1098
75990  #define PCI_DEVICE_ID_VISION_QD8500    0x0001
75991 @@ -1115,7 +1117,9 @@
75992  #define PCI_DEVICE_ID_TTI_HPT374       0x0008
75993  
75994  #define PCI_VENDOR_ID_VIA              0x1106
75995 -#define PCI_DEVICE_ID_VIA_P4X600       0x0198
75996 +#define PCI_DEVICE_ID_VIA_8763_0       0x0198
75997 +#define PCI_DEVICE_ID_VIA_8380_0       0x0204
75998 +#define PCI_DEVICE_ID_VIA_PX8X0_0      0x0259
75999  #define PCI_DEVICE_ID_VIA_8363_0       0x0305 
76000  #define PCI_DEVICE_ID_VIA_8371_0       0x0391
76001  #define PCI_DEVICE_ID_VIA_8501_0       0x0501
76002 @@ -1130,10 +1134,10 @@
76003  #define PCI_DEVICE_ID_VIA_82C597_0     0x0597
76004  #define PCI_DEVICE_ID_VIA_82C598_0     0x0598
76005  #define PCI_DEVICE_ID_VIA_8601_0       0x0601
76006 -#define PCI_DEVICE_ID_VIA_82C694X_0    0x0605
76007 +#define PCI_DEVICE_ID_VIA_8605_0       0x0605
76008  #define PCI_DEVICE_ID_VIA_82C680       0x0680
76009  #define PCI_DEVICE_ID_VIA_82C686       0x0686
76010 -#define PCI_DEVICE_ID_VIA_82C691       0x0691
76011 +#define PCI_DEVICE_ID_VIA_82C691_0     0x0691
76012  #define PCI_DEVICE_ID_VIA_82C693       0x0693
76013  #define PCI_DEVICE_ID_VIA_82C693_1     0x0698
76014  #define PCI_DEVICE_ID_VIA_82C926       0x0926
76015 @@ -1156,19 +1160,21 @@
76016  #define PCI_DEVICE_ID_VIA_8622         0x3102 
76017  #define PCI_DEVICE_ID_VIA_8233C_0      0x3109
76018  #define PCI_DEVICE_ID_VIA_8361         0x3112
76019 -#define PCI_DEVICE_ID_VIA_KM266                0x3116
76020 -#define PCI_DEVICE_ID_VIA_CLE266       0x3123
76021 +#define PCI_DEVICE_ID_VIA_XM266                0x3116
76022 +#define PCI_DEVICE_ID_VIA_862X_0       0x3123
76023  #define PCI_DEVICE_ID_VIA_8753_0       0x3128
76024  #define PCI_DEVICE_ID_VIA_8233A                0x3147
76025 -#define PCI_DEVICE_ID_VIA_8752         0x3148
76026 +#define PCI_DEVICE_ID_VIA_8703_51_0    0x3148
76027  #define PCI_DEVICE_ID_VIA_8237_SATA    0x3149
76028 -#define PCI_DEVICE_ID_VIA_KN266                0x3156
76029 -#define PCI_DEVICE_ID_VIA_8754         0x3168
76030 +#define PCI_DEVICE_ID_VIA_XN266                0x3156
76031 +#define PCI_DEVICE_ID_VIA_8754C_0      0x3168
76032  #define PCI_DEVICE_ID_VIA_8235         0x3177
76033  #define PCI_DEVICE_ID_VIA_P4N333       0x3178
76034 -#define PCI_DEVICE_ID_VIA_K8T400M_0    0x3188
76035 +#define PCI_DEVICE_ID_VIA_8385_0       0x3188
76036  #define PCI_DEVICE_ID_VIA_8377_0       0x3189
76037 -#define PCI_DEVICE_ID_VIA_KM400                0x3205
76038 +#define PCI_DEVICE_ID_VIA_8378_0       0x3205
76039 +#define PCI_DEVICE_ID_VIA_8783_0       0x3208
76040 +#define PCI_DEVICE_ID_VIA_PT880                0x3258
76041  #define PCI_DEVICE_ID_VIA_P4M400       0x3209
76042  #define PCI_DEVICE_ID_VIA_8237         0x3227
76043  #define PCI_DEVICE_ID_VIA_86C100A      0x6100
76044 @@ -1183,7 +1189,12 @@
76045  #define PCI_DEVICE_ID_VIA_8505_1       0x8605
76046  #define PCI_DEVICE_ID_VIA_8633_1       0xB091
76047  #define PCI_DEVICE_ID_VIA_8367_1       0xB099
76048 -#define PCI_DEVICE_ID_VIA_8653_1       0xB101
76049 +#define PCI_DEVICE_ID_VIA_P4X266_1     0xB101
76050 +#define PCI_DEVICE_ID_VIA_8615_1       0xB103
76051 +#define PCI_DEVICE_ID_VIA_8361_1       0xB112
76052 +#define PCI_DEVICE_ID_VIA_8235_1       0xB168
76053 +#define PCI_DEVICE_ID_VIA_838X_1       0xB188
76054 +#define PCI_DEVICE_ID_VIA_83_87XX_1    0xB198
76055  
76056  #define PCI_VENDOR_ID_SIEMENS           0x110A
76057  #define PCI_DEVICE_ID_SIEMENS_DSCC4     0x2102
76058 @@ -1274,6 +1285,9 @@
76059  #define PCI_DEVICE_ID_SYSKONNECT_FP    0x4000
76060  #define PCI_DEVICE_ID_SYSKONNECT_TR    0x4200
76061  #define PCI_DEVICE_ID_SYSKONNECT_GE    0x4300
76062 +#define PCI_DEVICE_ID_SYSKONNECT_YU    0x4320
76063 +#define PCI_DEVICE_ID_SYSKONNECT_9DXX  0x4400
76064 +#define PCI_DEVICE_ID_SYSKONNECT_9MXX  0x4500
76065  
76066  #define PCI_VENDOR_ID_VMIC             0x114a
76067  #define PCI_DEVICE_ID_VMIC_VME         0x7587
76068 @@ -1332,7 +1346,10 @@
76069  #define PCI_VENDOR_ID_TOSHIBA          0x1179
76070  #define PCI_DEVICE_ID_TOSHIBA_601      0x0601
76071  #define PCI_DEVICE_ID_TOSHIBA_TOPIC95  0x060a
76072 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_A 0x0603
76073 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_B 0x060a
76074  #define PCI_DEVICE_ID_TOSHIBA_TOPIC97  0x060f
76075 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617
76076  
76077  #define PCI_VENDOR_ID_TOSHIBA_2                0x102f
76078  #define PCI_DEVICE_ID_TOSHIBA_TX3927   0x000a
76079 @@ -1758,11 +1775,19 @@
76080  #define PCI_DEVICE_ID_TIGON3_5703      0x1647
76081  #define PCI_DEVICE_ID_TIGON3_5704      0x1648
76082  #define PCI_DEVICE_ID_TIGON3_5702FE    0x164d
76083 +#define PCI_DEVICE_ID_TIGON3_5705      0x1653
76084 +#define PCI_DEVICE_ID_TIGON3_5705_2    0x1654
76085 +#define PCI_DEVICE_ID_TIGON3_5705M     0x165d
76086 +#define PCI_DEVICE_ID_TIGON3_5705M_2   0x165e
76087 +#define PCI_DEVICE_ID_TIGON3_5782      0x1696
76088 +#define PCI_DEVICE_ID_TIGON3_5788      0x169c
76089  #define PCI_DEVICE_ID_TIGON3_5702X     0x16a6
76090  #define PCI_DEVICE_ID_TIGON3_5703X     0x16a7
76091  #define PCI_DEVICE_ID_TIGON3_5704S     0x16a8
76092  #define PCI_DEVICE_ID_TIGON3_5702A3    0x16c6
76093  #define PCI_DEVICE_ID_TIGON3_5703A3    0x16c7
76094 +#define PCI_DEVICE_ID_TIGON3_5901      0x170d
76095 +#define PCI_DEVICE_ID_TIGON3_5901_2    0x170e
76096  #define PCI_DEVICE_ID_BCM4401          0x4401
76097  
76098  #define PCI_VENDOR_ID_SYBA             0x1592
76099 @@ -1790,6 +1815,7 @@
76100  #define PCI_DEVICE_ID_ALTIMA_AC1000    0x03e8
76101  #define PCI_DEVICE_ID_ALTIMA_AC1001    0x03e9
76102  #define PCI_DEVICE_ID_ALTIMA_AC9100    0x03ea
76103 +#define PCI_DEVICE_ID_ALTIMA_AC1003    0x03eb
76104  
76105  #define PCI_VENDOR_ID_SYMPHONY         0x1c1c
76106  #define PCI_DEVICE_ID_SYMPHONY_101     0x0001
76107 diff -Nru a/include/linux/personality.h b/include/linux/personality.h
76108 --- a/include/linux/personality.h       Sun Dec 29 15:44:39 2002
76109 +++ b/include/linux/personality.h       Sun Aug 31 16:13:59 2003
76110 @@ -34,6 +34,7 @@
76111         SHORT_INODE =           0x1000000,
76112         WHOLE_SECONDS =         0x2000000,
76113         STICKY_TIMEOUTS =       0x4000000,
76114 +       ADDR_LIMIT_3GB =        0x8000000,
76115  };
76116  
76117  /*
76118 @@ -56,6 +57,7 @@
76119         PER_SUNOS =             0x0006 | STICKY_TIMEOUTS,
76120         PER_XENIX =             0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
76121         PER_LINUX32 =           0x0008,
76122 +       PER_LINUX32_3GB =       0x0008 | ADDR_LIMIT_3GB,
76123         PER_IRIX32 =            0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
76124         PER_IRIXN32 =           0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
76125         PER_IRIX64 =            0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
76126 diff -Nru a/include/linux/pmu.h b/include/linux/pmu.h
76127 --- a/include/linux/pmu.h       Sun Feb  2 13:51:33 2003
76128 +++ b/include/linux/pmu.h       Mon Aug 25 10:06:34 2003
76129 @@ -33,6 +33,7 @@
76130  #define PMU_CPU_SPEED          0x7d    /* control CPU speed on some models */
76131  #define PMU_SLEEP              0x7f    /* put CPU to sleep */
76132  #define PMU_POWER_EVENTS       0x8f    /* Send power-event commands to PMU */
76133 +#define PMU_I2C_CMD            0x9a    /* I2C operations */
76134  #define PMU_RESET              0xd0    /* reset CPU */
76135  #define PMU_GET_BRIGHTBUTTON   0xd9    /* report brightness up/down pos */
76136  #define PMU_GET_COVER          0xdc    /* report cover open/closed */
76137 @@ -69,6 +70,20 @@
76138   * or via PMU_INT_ENVIRONMENT on core99 */
76139  #define PMU_ENV_LID_CLOSED     0x01    /* The lid is closed */
76140  
76141 +/* I2C related definitions */
76142 +#define PMU_I2C_MODE_SIMPLE    0
76143 +#define PMU_I2C_MODE_STDSUB    1
76144 +#define PMU_I2C_MODE_COMBINED  2
76145 +
76146 +#define PMU_I2C_BUS_STATUS     0
76147 +#define PMU_I2C_BUS_SYSCLK     1
76148 +#define PMU_I2C_BUS_POWER      2
76149 +
76150 +#define PMU_I2C_STATUS_OK      0
76151 +#define PMU_I2C_STATUS_DATAREAD        1
76152 +#define PMU_I2C_STATUS_BUSY    0xfe
76153 +
76154 +
76155  /* Kind of PMU (model) */
76156  enum {
76157         PMU_UNKNOWN,
76158 @@ -127,6 +142,8 @@
76159                 void (*done)(struct adb_request *), int nbytes, ...);
76160  
76161  extern void pmu_poll(void);
76162 +extern void pmu_poll_adb(void); /* For use by xmon */
76163 +extern void pmu_wait_complete(struct adb_request *req);
76164  
76165  /* For use before switching interrupts off for a long time;
76166   * warning: not stackable
76167 @@ -138,9 +155,16 @@
76168  
76169  extern void pmu_restart(void);
76170  extern void pmu_shutdown(void);
76171 +extern void pmu_unlock(void);
76172  
76173  extern int pmu_present(void);
76174  extern int pmu_get_model(void);
76175 +
76176 +extern int pmu_i2c_combined_read(int bus, int addr, int subaddr,  u8* data, int len);
76177 +extern int pmu_i2c_stdsub_write(int bus, int addr, int subaddr,  u8* data, int len);
76178 +extern int pmu_i2c_simple_read(int bus, int addr,  u8* data, int len);
76179 +extern int pmu_i2c_simple_write(int bus, int addr,  u8* data, int len);
76180 +
76181  
76182  #ifdef CONFIG_PMAC_PBOOK
76183  /*
76184 diff -Nru a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76185 --- a/include/linux/proc_fs.h   Thu Jul 10 22:22:53 2003
76186 +++ b/include/linux/proc_fs.h   Sun Aug 31 16:14:22 2003
76187 @@ -182,12 +182,6 @@
76188         remove_proc_entry(name,proc_net);
76189  }
76190  
76191 -/*
76192 - * fs/proc/kcore.c
76193 - */
76194 -extern void kclist_add(struct kcore_list *, void *, size_t);
76195 -extern struct kcore_list *kclist_del(void *);
76196 -
76197  #else
76198  
76199  #define proc_root_driver NULL
76200 @@ -223,6 +217,9 @@
76201  
76202  extern struct proc_dir_entry proc_root;
76203  
76204 +#endif /* CONFIG_PROC_FS */
76205 +
76206 +#if !defined(CONFIG_PROC_FS)
76207  static inline void kclist_add(struct kcore_list *new, void *addr, size_t size)
76208  {
76209  }
76210 @@ -230,8 +227,10 @@
76211  {
76212         return NULL;
76213  }
76214 -
76215 -#endif /* CONFIG_PROC_FS */
76216 +#else
76217 +extern void kclist_add(struct kcore_list *, void *, size_t);
76218 +extern struct kcore_list *kclist_del(void *);
76219 +#endif
76220  
76221  struct proc_inode {
76222         struct task_struct *task;
76223 diff -Nru a/include/linux/rtc.h b/include/linux/rtc.h
76224 --- a/include/linux/rtc.h       Sun Mar  2 08:31:53 2003
76225 +++ b/include/linux/rtc.h       Wed Sep  3 23:40:07 2003
76226 @@ -101,6 +101,7 @@
76227  int rtc_register(rtc_task_t *task);
76228  int rtc_unregister(rtc_task_t *task);
76229  int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg);
76230 +void rtc_get_rtc_time(struct rtc_time *rtc_tm);
76231  
76232  #endif /* __KERNEL__ */
76233  
76234 diff -Nru a/include/linux/sched.h b/include/linux/sched.h
76235 --- a/include/linux/sched.h     Wed Aug 20 22:32:07 2003
76236 +++ b/include/linux/sched.h     Sun Aug 31 16:14:26 2003
76237 @@ -391,6 +391,7 @@
76238         struct timer_list real_timer;
76239         struct list_head posix_timers; /* POSIX.1b Interval Timers */
76240         unsigned long utime, stime, cutime, cstime;
76241 +       unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; /* context switch counts */
76242         u64 start_time;
76243  /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
76244         unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
76245 diff -Nru a/include/linux/serial_core.h b/include/linux/serial_core.h
76246 --- a/include/linux/serial_core.h       Wed Jul 16 01:49:46 2003
76247 +++ b/include/linux/serial_core.h       Sun Aug 24 08:17:18 2003
76248 @@ -67,6 +67,9 @@
76249  #define PORT_PC9861    45
76250  #define PORT_PC9801_101        46
76251  
76252 +/* Macintosh Zilog type numbers */
76253 +#define PORT_MAC_ZILOG 50      /* m68k : not yet implemented */
76254 +#define PORT_PMAC_ZILOG        51
76255  
76256  #ifdef __KERNEL__
76257  
76258 diff -Nru a/include/linux/skbuff.h b/include/linux/skbuff.h
76259 --- a/include/linux/skbuff.h    Thu Aug  7 14:30:45 2003
76260 +++ b/include/linux/skbuff.h    Wed Sep  3 23:40:12 2003
76261 @@ -98,7 +98,7 @@
76262         struct nf_conntrack *master;
76263  };
76264  
76265 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
76266 +#ifdef CONFIG_BRIDGE_NETFILTER
76267  struct nf_bridge_info {
76268         atomic_t use;
76269         struct net_device *physindev;
76270 @@ -244,7 +244,7 @@
76271  #ifdef CONFIG_NETFILTER_DEBUG
76272          unsigned int           nf_debug;
76273  #endif
76274 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
76275 +#ifdef CONFIG_BRIDGE_NETFILTER
76276         struct nf_bridge_info   *nf_bridge;
76277  #endif
76278  #endif /* CONFIG_NETFILTER */
76279 @@ -389,6 +389,7 @@
76280   */
76281  static inline struct sk_buff *skb_share_check(struct sk_buff *skb, int pri)
76282  {
76283 +       might_sleep_if(pri & __GFP_WAIT);
76284         if (skb_shared(skb)) {
76285                 struct sk_buff *nskb = skb_clone(skb, pri);
76286                 kfree_skb(skb);
76287 @@ -419,6 +420,7 @@
76288   */
76289  static inline struct sk_buff *skb_unshare(struct sk_buff *skb, int pri)
76290  {
76291 +       might_sleep_if(pri & __GFP_WAIT);
76292         if (skb_cloned(skb)) {
76293                 struct sk_buff *nskb = skb_copy(skb, pri);
76294                 kfree_skb(skb); /* Free our shared copy */
76295 @@ -1195,7 +1197,7 @@
76296                 atomic_inc(&nfct->master->use);
76297  }
76298  
76299 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
76300 +#ifdef CONFIG_BRIDGE_NETFILTER
76301  static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge)
76302  {
76303         if (nf_bridge && atomic_dec_and_test(&nf_bridge->use))
76304 diff -Nru a/include/linux/sonypi.h b/include/linux/sonypi.h
76305 --- a/include/linux/sonypi.h    Tue Feb 18 03:32:56 2003
76306 +++ b/include/linux/sonypi.h    Fri Aug  1 05:36:45 2003
76307 @@ -94,6 +94,8 @@
76308  #define SONYPI_EVENT_MEMORYSTICK_INSERT                54
76309  #define SONYPI_EVENT_MEMORYSTICK_EJECT         55
76310  #define SONYPI_EVENT_ANYBUTTON_RELEASED                56
76311 +#define SONYPI_EVENT_BATTERY_INSERT            57
76312 +#define SONYPI_EVENT_BATTERY_REMOVE            58
76313  
76314  /* get/set brightness */
76315  #define SONYPI_IOCGBRT         _IOR('v', 0, __u8)
76316 diff -Nru a/include/linux/tpqic02.h b/include/linux/tpqic02.h
76317 --- a/include/linux/tpqic02.h   Mon May 12 20:10:40 2003
76318 +++ b/include/linux/tpqic02.h   Tue Aug 26 09:25:40 2003
76319 @@ -587,10 +587,10 @@
76320   *  |___________________ Reserved for diagnostics during debugging.
76321   */
76322  
76323 -#define        TP_REWCLOSE(d)  ((minor(d)&0x01) == 1)                  /* rewind bit */
76324 +#define        TP_REWCLOSE(d)  ((d)&1)                 /* rewind bit */
76325                            /* rewind is only done if data has been transferred */
76326 -#define        TP_DENS(dev)    ((minor(dev) >> 1) & 0x07)            /* tape density */
76327 -#define TP_UNIT(dev)   ((minor(dev) >> 4) & 0x07)             /* unit number */
76328 +#define        TP_DENS(d)      (((d) >> 1) & 0x07)           /* tape density */
76329 +#define TP_UNIT(d)     (((d) >> 4) & 0x07)            /* unit number */
76330  
76331  /* print excessive diagnostics */
76332  #define TP_DIAGS(dev)  (QIC02_TAPE_DEBUG & TPQD_DIAGS)
76333 diff -Nru a/include/linux/tty.h b/include/linux/tty.h
76334 --- a/include/linux/tty.h       Thu Jul 17 22:30:53 2003
76335 +++ b/include/linux/tty.h       Tue Aug 26 09:25:40 2003
76336 @@ -367,7 +367,7 @@
76337  extern int macserial_init(void);
76338  extern int a2232board_init(void);
76339  
76340 -extern int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
76341 +extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
76342                               const char *routine);
76343  extern char *tty_name(struct tty_struct *tty, char *buf);
76344  extern void tty_wait_until_sent(struct tty_struct * tty, long timeout);
76345 diff -Nru a/include/linux/usb.h b/include/linux/usb.h
76346 --- a/include/linux/usb.h       Wed Aug 13 06:35:23 2003
76347 +++ b/include/linux/usb.h       Wed Sep  3 03:17:15 2003
76348 @@ -329,7 +329,7 @@
76349  {
76350         int actual;
76351         actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, dev->devpath);
76352 -       return (actual >= size) ? -1 : actual;
76353 +       return (actual >= (int)size) ? -1 : actual;
76354  }
76355  
76356  /*-------------------------------------------------------------------------*/
76357 @@ -410,6 +410,8 @@
76358   *     the "usbfs" filesystem.  This lets devices provide ways to
76359   *     expose information to user space regardless of where they
76360   *     do (or don't) show up otherwise in the filesystem.
76361 + * @suspend: Called when the device is going to be suspended by the system.
76362 + * @resume: Called when the device is being resumed by the system.
76363   * @id_table: USB drivers use ID table to support hotplugging.
76364   *     Export this with MODULE_DEVICE_TABLE(usb,...).  This must be set
76365   *     or your driver's probe function will never get called.
76366 @@ -444,6 +446,9 @@
76367         void (*disconnect) (struct usb_interface *intf);
76368  
76369         int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf);
76370 +
76371 +       int (*suspend) (struct usb_interface *intf, u32 state);
76372 +       int (*resume) (struct usb_interface *intf);
76373  
76374         const struct usb_device_id *id_table;
76375  
76376 diff -Nru a/include/linux/usb_gadget.h b/include/linux/usb_gadget.h
76377 --- a/include/linux/usb_gadget.h        Thu Jul 31 04:09:33 2003
76378 +++ b/include/linux/usb_gadget.h        Sat Aug 23 02:56:23 2003
76379 @@ -313,8 +313,8 @@
76380   * arranges to poll once per interval, and the gadget driver usually will
76381   * have queued some data to transfer at that time.
76382   *
76383 - * Returns zero, or a negative error code.  Endpoints that are not enabled,
76384 - * or which are enabled but halted, report errors; errors will also be
76385 + * Returns zero, or a negative error code.  Endpoints that are not enabled
76386 + * report errors; errors will also be
76387   * reported when the usb peripheral is disconnected.
76388   */
76389  static inline int
76390 @@ -352,6 +352,11 @@
76391   * clears this feature; drivers may need to empty the endpoint's request
76392   * queue first, to make sure no inappropriate transfers happen.
76393   *
76394 + * Note that while an endpoint CLEAR_FEATURE will be invisible to the
76395 + * gadget driver, a SET_INTERFACE will not be.  To reset endpoints for the
76396 + * current altsetting, see usb_ep_clear_halt().  When switching altsettings,
76397 + * it's simplest to use usb_ep_enable() or usb_ep_disable() for the endpoints.
76398 + *
76399   * Returns zero, or a negative error code.  On success, this call sets
76400   * underlying hardware state that blocks data transfers.
76401   */
76402 @@ -365,12 +370,14 @@
76403   * usb_ep_clear_halt - clears endpoint halt, and resets toggle
76404   * @ep:the bulk or interrupt endpoint being reset
76405   *
76406 - * use this when responding to the standard usb "set interface" request,
76407 + * Use this when responding to the standard usb "set interface" request,
76408   * for endpoints that aren't reconfigured, after clearing any other state
76409   * in the endpoint's i/o queue.
76410   *
76411 - * returns zero, or a negative error code.  on success, this call clears
76412 + * Returns zero, or a negative error code.  On success, this call clears
76413   * the underlying hardware state reflecting endpoint halt and data toggle.
76414 + * Note that some hardware can't support this request (like pxa2xx_udc),
76415 + * and accordingly can't correctly implement interface altsettings.
76416   */
76417  static inline int
76418  usb_ep_clear_halt (struct usb_ep *ep)
76419 @@ -562,7 +569,8 @@
76420   *     queues a response to ep0, or returns negative to stall.
76421   * @disconnect: Invoked after all transfers have been stopped,
76422   *     when the host is disconnected.  May be called in_interrupt; this
76423 - *     may not sleep.
76424 + *     may not sleep.  Some devices can't detect disconnect, so this might
76425 + *     not be called except as part of controller shutdown.
76426   * @unbind: Invoked when the driver is unbound from a gadget,
76427   *     usually from rmmod (after a disconnect is reported).
76428   *     Called in a context that permits sleeping.
76429 @@ -603,7 +611,9 @@
76430   * not provide those callbacks.  However, some may need to change modes
76431   * when the host is not longer directing those activities.  For example,
76432   * local controls (buttons, dials, etc) may need to be re-enabled since
76433 - * the (remote) host can't do that any longer. 
76434 + * the (remote) host can't do that any longer; or an error state might
76435 + * be cleared, to make the device behave identically whether or not
76436 + * power is maintained.
76437   */
76438  struct usb_gadget_driver {
76439         char                    *function;
76440 diff -Nru a/include/linux/videodev.h b/include/linux/videodev.h
76441 --- a/include/linux/videodev.h  Wed Aug  6 02:51:26 2003
76442 +++ b/include/linux/videodev.h  Fri Aug 22 08:51:55 2003
76443 @@ -63,6 +63,12 @@
76444  {
76445         class_device_create_file(&vfd->class_dev, attr);
76446  }
76447 +static inline void
76448 +video_device_remove_file(struct video_device *vfd,
76449 +                        struct class_device_attribute *attr)
76450 +{
76451 +       class_device_remove_file(&vfd->class_dev, attr);
76452 +}
76453  
76454  /* helper functions to alloc / release struct video_device, the
76455     later can be used for video_device->release() */
76456 diff -Nru a/include/linux/wait.h b/include/linux/wait.h
76457 --- a/include/linux/wait.h      Sun May 18 17:00:00 2003
76458 +++ b/include/linux/wait.h      Sun Aug 31 16:14:00 2003
76459 @@ -220,22 +220,6 @@
76460         __remove_wait_queue(q,  wait);
76461  }
76462  
76463 -#define add_wait_queue_cond(q, wait, cond) \
76464 -       ({                                                      \
76465 -               unsigned long flags;                            \
76466 -               int _raced = 0;                                 \
76467 -               spin_lock_irqsave(&(q)->lock, flags);   \
76468 -               (wait)->flags = 0;                              \
76469 -               __add_wait_queue((q), (wait));                  \
76470 -               rmb();                                          \
76471 -               if (!(cond)) {                                  \
76472 -                       _raced = 1;                             \
76473 -                       __remove_wait_queue((q), (wait));       \
76474 -               }                                               \
76475 -               spin_lock_irqrestore(&(q)->lock, flags);        \
76476 -               _raced;                                         \
76477 -       })
76478 -
76479  /*
76480   * These are the old interfaces to sleep waiting for an event.
76481   * They are racy.  DO NOT use them, use the wait_event* interfaces above.  
76482 diff -Nru a/include/net/ax25.h b/include/net/ax25.h
76483 --- a/include/net/ax25.h        Thu Aug 21 11:59:08 2003
76484 +++ b/include/net/ax25.h        Sun Aug 24 04:34:01 2003
76485 @@ -314,7 +314,7 @@
76486  /* ax25_route.c */
76487  extern void ax25_rt_device_down(struct net_device *);
76488  extern int  ax25_rt_ioctl(unsigned int, void *);
76489 -extern int  ax25_rt_get_info(char *, char **, off_t, int);
76490 +extern struct file_operations ax25_route_fops;
76491  extern int  ax25_rt_autobind(ax25_cb *, ax25_address *);
76492  extern ax25_route *ax25_rt_find_route(ax25_route *, ax25_address *,
76493         struct net_device *);
76494 @@ -373,7 +373,7 @@
76495  extern int  ax25_uid_policy;
76496  extern ax25_address *ax25_findbyuid(uid_t);
76497  extern int  ax25_uid_ioctl(int, struct sockaddr_ax25 *);
76498 -extern int  ax25_uid_get_info(char *, char **, off_t, int);
76499 +extern struct file_operations ax25_uid_fops;
76500  extern void ax25_uid_free(void);
76501  
76502  /* sysctl_net_ax25.c */
76503 diff -Nru a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
76504 --- a/include/net/ip6_tunnel.h  Mon Jun  9 07:56:44 2003
76505 +++ b/include/net/ip6_tunnel.h  Mon Sep  1 01:55:01 2003
76506 @@ -25,6 +25,8 @@
76507         int recursion;          /* depth of hard_start_xmit recursion */
76508         struct ip6_tnl_parm parms;      /* tunnel configuration paramters */
76509         struct flowi fl;        /* flowi template for xmit */
76510 +       struct dst_entry *dst_cache;    /* cached dst */
76511 +       u32 dst_cookie;
76512  };
76513  
76514  /* Tunnel encapsulation limit destination sub-option */
76515 diff -Nru a/include/net/ipv6.h b/include/net/ipv6.h
76516 --- a/include/net/ipv6.h        Mon Aug 18 03:14:19 2003
76517 +++ b/include/net/ipv6.h        Mon Sep  1 07:33:05 2003
76518 @@ -193,7 +193,7 @@
76519         struct in6_addr         dst;
76520         struct ipv6_txoptions   *opt;
76521         atomic_t                users;
76522 -       u32                     linger;
76523 +       unsigned long           linger;
76524         u8                      share;
76525         u32                     owner;
76526         unsigned long           lastuse;
76527 diff -Nru a/include/net/irda/vlsi_ir.h b/include/net/irda/vlsi_ir.h
76528 --- a/include/net/irda/vlsi_ir.h        Tue Jun 10 16:16:15 2003
76529 +++ b/include/net/irda/vlsi_ir.h        Sun Aug 24 04:45:26 2003
76530 @@ -3,7 +3,7 @@
76531   *
76532   *     vlsi_ir.h:      VLSI82C147 PCI IrDA controller driver for Linux
76533   *
76534 - *     Version:        0.4a
76535 + *     Version:        0.5
76536   *
76537   *     Copyright (c) 2001-2003 Martin Diehl
76538   *
76539 @@ -27,18 +27,71 @@
76540  #ifndef IRDA_VLSI_FIR_H
76541  #define IRDA_VLSI_FIR_H
76542  
76543 -/*
76544 - * #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,xx)
76545 - *
76546 - * missing pci-dma api call to give streaming dma buffer back to hw
76547 - * patch floating on lkml - probably present in 2.5.26 or later
76548 - * otherwise defining it as noop is ok, since the vlsi-ir is only
76549 - * used on two oldish x86-based notebooks which are cache-coherent
76550 +/* ================================================================
76551 + * compatibility stuff
76552   */
76553 -#define pci_dma_prep_single(dev, addr, size, direction)        /* nothing */
76554 -/*
76555 - * #endif
76556 +
76557 +/* definitions not present in pci_ids.h */
76558 +
76559 +#ifndef PCI_CLASS_WIRELESS_IRDA
76560 +#define PCI_CLASS_WIRELESS_IRDA                0x0d00
76561 +#endif
76562 +
76563 +#ifndef PCI_CLASS_SUBCLASS_MASK
76564 +#define PCI_CLASS_SUBCLASS_MASK                0xffff
76565 +#endif
76566 +
76567 +/* missing pci-dma api call to give streaming dma buffer back to hw
76568 + * patch was floating on lkml around 2.5.2x and might be present later.
76569 + * Defining it this way is ok, since the vlsi-ir is only
76570 + * used on two oldish x86-based notebooks which are cache-coherent
76571 + * (and flush_write_buffers also handles PPro errata and C3 OOstore)
76572   */
76573 +#ifdef CONFIG_X86
76574 +#include <asm-i386/io.h>
76575 +#define pci_dma_prep_single(dev, addr, size, direction)        flush_write_buffers()
76576 +#else
76577 +#error missing pci dma api call
76578 +#endif
76579 +
76580 +/* in recent 2.5 interrupt handlers have non-void return value */
76581 +#ifndef IRQ_RETVAL
76582 +typedef void irqreturn_t;
76583 +#define IRQ_NONE
76584 +#define IRQ_HANDLED
76585 +#define IRQ_RETVAL(x)
76586 +#endif
76587 +
76588 +/* some stuff need to check kernelversion. Not all 2.5 stuff was present
76589 + * in early 2.5.x - the test is merely to separate 2.4 from 2.5
76590 + */
76591 +#include <linux/version.h>
76592 +
76593 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
76594 +
76595 +/* PDE() introduced in 2.5.4 */
76596 +#ifdef CONFIG_PROC_FS
76597 +#define PDE(inode) ((inode)->u.generic_ip)
76598 +#endif
76599 +
76600 +/* irda crc16 calculation exported in 2.5.42 */
76601 +#define irda_calc_crc16(fcs,buf,len)   (GOOD_FCS)
76602 +
76603 +/* we use this for unified pci device name access */
76604 +#define PCIDEV_NAME(pdev)      ((pdev)->name)
76605 +
76606 +#else /* 2.5 or later */
76607 +
76608 +/* recent 2.5/2.6 stores pci device names at varying places ;-) */
76609 +#ifdef CONFIG_PCI_NAMES
76610 +/* human readable name */
76611 +#define PCIDEV_NAME(pdev)      ((pdev)->pretty_name)
76612 +#else
76613 +/* whatever we get from the associated struct device - bus:slot:dev.fn id */
76614 +#define PCIDEV_NAME(pdev)      (pci_name(pdev))
76615 +#endif
76616 +
76617 +#endif
76618  
76619  /* ================================================================ */
76620  
76621 @@ -138,7 +191,7 @@
76622   *     - IRMISC_UARTSEL configured
76623   *     - IRCFG_MASTER must be cleared
76624   *     - IRCFG_SIR must be set
76625 - *     - IRENABLE_IREN must be asserted 0->1 (and hence IRENABLE_SIR_ON)
76626 + *     - IRENABLE_PHYANDCLOCK must be asserted 0->1 (and hence IRENABLE_SIR_ON)
76627   */
76628  
76629  enum vlsi_pci_irmisc {
76630 @@ -298,7 +351,7 @@
76631  /* notes:
76632   *     - not more than one SIR/MIR/FIR bit must be set at any time
76633   *     - SIR, MIR, FIR and CRC16 select the configuration which will
76634 - *       be applied on next 0->1 transition of IRENABLE_IREN (see below).
76635 + *       be applied on next 0->1 transition of IRENABLE_PHYANDCLOCK (see below).
76636   *     - besides allowing the PCI interface to execute busmaster cycles
76637   *       and therefore the ring SM to operate, the MSTR bit has side-effects:
76638   *       when MSTR is cleared, the RINGPTR's get reset and the legacy UART mode
76639 @@ -349,7 +402,7 @@
76640   */
76641  
76642  enum vlsi_pio_irenable {
76643 -       IRENABLE_IREN           = 0x8000,  /* enable IR phy and gate the mode config (rw) */
76644 +       IRENABLE_PHYANDCLOCK    = 0x8000,  /* enable IR phy and gate the mode config (rw) */
76645         IRENABLE_CFGER          = 0x4000,  /* mode configuration error (ro) */
76646         IRENABLE_FIR_ON         = 0x2000,  /* FIR on status (ro) */
76647         IRENABLE_MIR_ON         = 0x1000,  /* MIR on status (ro) */
76648 @@ -366,7 +419,7 @@
76649  /* VLSI_PIO_PHYCTL: IR Physical Layer Current Control Register (u16, ro) */
76650  
76651  /* read-back of the currently applied physical layer status.
76652 - * applied from VLSI_PIO_NPHYCTL at rising edge of IRENABLE_IREN
76653 + * applied from VLSI_PIO_NPHYCTL at rising edge of IRENABLE_PHYANDCLOCK
76654   * contents identical to VLSI_PIO_NPHYCTL (see below)
76655   */
76656  
76657 @@ -374,7 +427,7 @@
76658  
76659  /* VLSI_PIO_NPHYCTL: IR Physical Layer Next Control Register (u16, rw) */
76660  
76661 -/* latched during IRENABLE_IREN=0 and applied at 0-1 transition
76662 +/* latched during IRENABLE_PHYANDCLOCK=0 and applied at 0-1 transition
76663   *
76664   * consists of BAUD[15:10], PLSWID[9:5] and PREAMB[4:0] bits defined as follows:
76665   *
76666 @@ -616,21 +669,22 @@
76667          */
76668  
76669         if ((a & ~DMA_MASK_MSTRPAGE)>>24 != MSTRPAGE_VALUE) {
76670 -               BUG();
76671 +               ERROR("%s: pci busaddr inconsistency!\n", __FUNCTION__);
76672 +               dump_stack();
76673                 return;
76674         }
76675  
76676         a &= DMA_MASK_MSTRPAGE;  /* clear highbyte to make sure we won't write
76677                                   * to status - just in case MSTRPAGE_VALUE!=0
76678                                   */
76679 -       rd->hw->rd_addr = a;
76680 +       rd->hw->rd_addr = cpu_to_le32(a);
76681         wmb();
76682         rd_set_status(rd, s);    /* may pass ownership to the hardware */
76683  }
76684  
76685  static inline void rd_set_count(struct ring_descr *rd, u16 c)
76686  {
76687 -       rd->hw->rd_count = c;
76688 +       rd->hw->rd_count = cpu_to_le16(c);
76689  }
76690  
76691  static inline u8 rd_get_status(struct ring_descr *rd)
76692 @@ -642,13 +696,13 @@
76693  {
76694         dma_addr_t      a;
76695  
76696 -       a = (rd->hw->rd_addr & DMA_MASK_MSTRPAGE) | (MSTRPAGE_VALUE << 24);
76697 -       return a;
76698 +       a = le32_to_cpu(rd->hw->rd_addr);
76699 +       return (a & DMA_MASK_MSTRPAGE) | (MSTRPAGE_VALUE << 24);
76700  }
76701  
76702  static inline u16 rd_get_count(struct ring_descr *rd)
76703  {
76704 -       return rd->hw->rd_count;
76705 +       return le16_to_cpu(rd->hw->rd_count);
76706  }
76707  
76708  /******************************************************************/
76709 diff -Nru a/init/Kconfig b/init/Kconfig
76710 --- a/init/Kconfig      Wed Aug 20 22:30:10 2003
76711 +++ b/init/Kconfig      Wed Sep  3 10:51:31 2003
76712 @@ -32,16 +32,24 @@
76713           you say Y here, you will be offered the choice of using features or
76714           drivers that are currently considered to be in the alpha-test phase.
76715  
76716 -config BROKEN
76717 -       bool "Prompt for old and known-broken drivers"
76718 -       depends on EXPERIMENTAL
76719 -       default n
76720 +config CLEAN_COMPILE
76721 +       bool "Select only drivers expected to compile cleanly" if EXPERIMENTAL
76722 +       default y
76723         help
76724 -         This option allows you to choose whether you want to try to
76725 -         compile (and fix) old drivers that haven't been updated to
76726 -         new infrastructure.
76727 +         Select this option if you don't even want to see the option
76728 +         to configure known-broken drivers.
76729 +
76730 +         If unsure, say Y
76731 +
76732 +config BROKEN
76733 +       bool
76734 +       depends on !CLEAN_COMPILE
76735 +       default y
76736  
76737 -         If unsure, say N.
76738 +config BROKEN_ON_SMP
76739 +       bool
76740 +       depends on BROKEN || !SMP
76741 +       default y
76742  
76743  endmenu
76744  
76745 diff -Nru a/init/main.c b/init/main.c
76746 --- a/init/main.c       Fri May  2 11:15:48 2003
76747 +++ b/init/main.c       Sun Aug 31 16:14:48 2003
76748 @@ -89,10 +89,6 @@
76749  extern void tc_init(void);
76750  #endif
76751  
76752 -#if defined(CONFIG_SYSVIPC)
76753 -extern void ipc_init(void);
76754 -#endif
76755 -
76756  /*
76757   * Are we up and running (ie do we have all the infrastructure
76758   * set up)
76759 @@ -106,6 +102,8 @@
76760  #define MAX_INIT_ENVS 8
76761  
76762  extern void time_init(void);
76763 +/* Default late time init is NULL. archs can override this later. */
76764 +void (*late_time_init)(void) = NULL;
76765  extern void softirq_init(void);
76766  
76767  int rows, cols;
76768 @@ -421,7 +419,6 @@
76769         console_init();
76770         profile_init();
76771         local_irq_enable();
76772 -       calibrate_delay();
76773  #ifdef CONFIG_BLK_DEV_INITRD
76774         if (initrd_start && !initrd_below_start_ok &&
76775                         initrd_start < min_low_pfn << PAGE_SHIFT) {
76776 @@ -433,6 +430,9 @@
76777         page_address_init();
76778         mem_init();
76779         kmem_cache_init();
76780 +       if (late_time_init)
76781 +               late_time_init();
76782 +       calibrate_delay();
76783         pidmap_init();
76784         pgtable_cache_init();
76785         pte_chain_init();
76786 @@ -448,9 +448,6 @@
76787         populate_rootfs();
76788  #ifdef CONFIG_PROC_FS
76789         proc_root_init();
76790 -#endif
76791 -#if defined(CONFIG_SYSVIPC)
76792 -       ipc_init();
76793  #endif
76794         check_bugs();
76795         printk("POSIX conformance testing by UNIFIX\n");
76796 diff -Nru a/ipc/msg.c b/ipc/msg.c
76797 --- a/ipc/msg.c Mon May 12 21:23:19 2003
76798 +++ b/ipc/msg.c Thu Aug 28 10:07:51 2003
76799 @@ -707,7 +707,7 @@
76800                 goto retry;
76801         }
76802  
76803 -       msq->q_lspid = current->pid;
76804 +       msq->q_lspid = current->tgid;
76805         msq->q_stime = get_seconds();
76806  
76807         if(!pipelined_send(msq,msg)) {
76808 @@ -801,7 +801,7 @@
76809                 list_del(&msg->m_list);
76810                 msq->q_qnum--;
76811                 msq->q_rtime = get_seconds();
76812 -               msq->q_lrpid = current->pid;
76813 +               msq->q_lrpid = current->tgid;
76814                 msq->q_cbytes -= msg->m_ts;
76815                 atomic_sub(msg->m_ts,&msg_bytes);
76816                 atomic_dec(&msg_hdrs);
76817 diff -Nru a/ipc/sem.c b/ipc/sem.c
76818 --- a/ipc/sem.c Sun Jul 13 08:55:51 2003
76819 +++ b/ipc/sem.c Thu Aug 28 10:08:09 2003
76820 @@ -664,7 +664,7 @@
76821                 for (un = sma->undo; un; un = un->id_next)
76822                         un->semadj[semnum] = 0;
76823                 curr->semval = val;
76824 -               curr->sempid = current->pid;
76825 +               curr->sempid = current->tgid;
76826                 sma->sem_ctime = get_seconds();
76827                 /* maybe some queued-up processes were waiting for this */
76828                 update_queue(sma);
76829 @@ -1052,7 +1052,7 @@
76830         if (error)
76831                 goto out_unlock_free;
76832  
76833 -       error = try_atomic_semop (sma, sops, nsops, un, current->pid);
76834 +       error = try_atomic_semop (sma, sops, nsops, un, current->tgid);
76835         if (error <= 0)
76836                 goto update;
76837  
76838 @@ -1064,7 +1064,7 @@
76839         queue.sops = sops;
76840         queue.nsops = nsops;
76841         queue.undo = un;
76842 -       queue.pid = current->pid;
76843 +       queue.pid = current->tgid;
76844         queue.id = semid;
76845         if (alter)
76846                 append_to_queue(sma ,&queue);
76847 @@ -1206,7 +1206,7 @@
76848                                 sem->semval += u->semadj[i];
76849                                 if (sem->semval < 0)
76850                                         sem->semval = 0; /* shouldn't happen */
76851 -                               sem->sempid = current->pid;
76852 +                               sem->sempid = current->tgid;
76853                         }
76854                 }
76855                 sma->sem_otime = get_seconds();
76856 diff -Nru a/ipc/shm.c b/ipc/shm.c
76857 --- a/ipc/shm.c Thu Jul 10 22:22:59 2003
76858 +++ b/ipc/shm.c Thu Aug 28 10:08:22 2003
76859 @@ -89,7 +89,7 @@
76860         if(!(shp = shm_lock(id)))
76861                 BUG();
76862         shp->shm_atim = get_seconds();
76863 -       shp->shm_lprid = current->pid;
76864 +       shp->shm_lprid = current->tgid;
76865         shp->shm_nattch++;
76866         shm_unlock(shp);
76867  }
76868 @@ -136,7 +136,7 @@
76869         /* remove from the list of attaches of the shm segment */
76870         if(!(shp = shm_lock(id)))
76871                 BUG();
76872 -       shp->shm_lprid = current->pid;
76873 +       shp->shm_lprid = current->tgid;
76874         shp->shm_dtim = get_seconds();
76875         shp->shm_nattch--;
76876         if(shp->shm_nattch == 0 &&
76877 @@ -209,7 +209,7 @@
76878         if(id == -1) 
76879                 goto no_id;
76880  
76881 -       shp->shm_cprid = current->pid;
76882 +       shp->shm_cprid = current->tgid;
76883         shp->shm_lprid = 0;
76884         shp->shm_atim = shp->shm_dtim = 0;
76885         shp->shm_ctim = get_seconds();
76886 diff -Nru a/ipc/util.c b/ipc/util.c
76887 --- a/ipc/util.c        Tue Jul  1 06:04:38 2003
76888 +++ b/ipc/util.c        Sun Aug 31 16:14:46 2003
76889 @@ -36,13 +36,14 @@
76890   *     memory are initialised
76891   */
76892   
76893 -void __init ipc_init (void)
76894 +static int __init ipc_init(void)
76895  {
76896         sem_init();
76897         msg_init();
76898         shm_init();
76899 -       return;
76900 +       return 0;
76901  }
76902 +__initcall(ipc_init);
76903  
76904  /**
76905   *     ipc_init_ids            -       initialise IPC identifiers
76906 diff -Nru a/kernel/Makefile b/kernel/Makefile
76907 --- a/kernel/Makefile   Wed Aug  6 13:59:24 2003
76908 +++ b/kernel/Makefile   Sun Aug 31 16:13:58 2003
76909 @@ -20,9 +20,6 @@
76910  obj-$(CONFIG_COMPAT) += compat.o
76911  obj-$(CONFIG_IKCONFIG) += configs.o
76912  
76913 -# files to be removed upon make clean
76914 -clean-files := ikconfig.h
76915 -
76916  ifneq ($(CONFIG_IA64),y)
76917  # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
76918  # needed for x86 only.  Why this used to be enabled for all architectures is beyond
76919 @@ -32,8 +29,12 @@
76920  CFLAGS_sched.o := $(PROFILING) -fno-omit-frame-pointer
76921  endif
76922  
76923 -$(obj)/ikconfig.h: scripts/mkconfigs .config Makefile
76924 -       $(CONFIG_SHELL) scripts/mkconfigs .config Makefile > $(obj)/ikconfig.h
76925 +quiet_cmd_ikconfig = IKCFG   $@
76926 +      cmd_ikconfig = $(CONFIG_SHELL) $< .config $(srctree)/Makefile > $@
76927 +
76928 +targets += ikconfig.h
76929 +
76930 +$(obj)/ikconfig.h: scripts/mkconfigs .config Makefile FORCE
76931 +       $(call if_changed,ikconfig)
76932  
76933 -$(obj)/configs.o: $(obj)/ikconfig.h $(obj)/configs.c \
76934 -               include/linux/version.h include/linux/compile.h
76935 +$(obj)/configs.o: $(obj)/ikconfig.h
76936 diff -Nru a/kernel/compat.c b/kernel/compat.c
76937 --- a/kernel/compat.c   Sat Aug  9 07:50:24 2003
76938 +++ b/kernel/compat.c   Wed Aug 27 23:55:00 2003
76939 @@ -464,6 +464,7 @@
76940         if (get_compat_itimerspec(&newts, new))
76941                 return -EFAULT; 
76942         oldfs = get_fs();
76943 +       set_fs(KERNEL_DS);
76944         err = sys_timer_settime(timer_id, flags, &newts, &oldts);
76945         set_fs(oldfs); 
76946         if (!err && old && put_compat_itimerspec(old, &oldts))
76947 @@ -477,6 +478,7 @@
76948         mm_segment_t oldfs;
76949         struct itimerspec ts; 
76950         oldfs = get_fs();
76951 +       set_fs(KERNEL_DS);
76952         err = sys_timer_gettime(timer_id, &ts); 
76953         set_fs(oldfs); 
76954         if (!err && put_compat_itimerspec(setting, &ts))
76955 @@ -494,7 +496,8 @@
76956         struct timespec ts; 
76957         if (get_compat_timespec(&ts, tp))
76958                 return -EFAULT; 
76959 -       oldfs = get_fs(); 
76960 +       oldfs = get_fs();
76961 +       set_fs(KERNEL_DS);      
76962         err = sys_clock_settime(which_clock, &ts); 
76963         set_fs(oldfs);
76964         return err;
76965 @@ -508,7 +511,8 @@
76966         long err;
76967         mm_segment_t oldfs;
76968         struct timespec ts; 
76969 -       oldfs = get_fs(); 
76970 +       oldfs = get_fs();
76971 +       set_fs(KERNEL_DS);
76972         err = sys_clock_gettime(which_clock, &ts); 
76973         set_fs(oldfs);
76974         if (!err && put_compat_timespec(&ts, tp))
76975 @@ -524,7 +528,8 @@
76976         long err;
76977         mm_segment_t oldfs;
76978         struct timespec ts; 
76979 -       oldfs = get_fs(); 
76980 +       oldfs = get_fs();
76981 +       set_fs(KERNEL_DS);
76982         err = sys_clock_getres(which_clock, &ts); 
76983         set_fs(oldfs);
76984         if (!err && put_compat_timespec(&ts, tp))
76985 @@ -546,7 +551,8 @@
76986         struct timespec in, out; 
76987         if (get_compat_timespec(&in, rqtp)) 
76988                 return -EFAULT;
76989 -       oldfs = get_fs(); 
76990 +       oldfs = get_fs();
76991 +       set_fs(KERNEL_DS);      
76992         err = sys_clock_nanosleep(which_clock, flags, &in, &out);  
76993         set_fs(oldfs);
76994         if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
76995 diff -Nru a/kernel/exit.c b/kernel/exit.c
76996 --- a/kernel/exit.c     Tue Aug  5 23:04:02 2003
76997 +++ b/kernel/exit.c     Sun Aug 31 16:14:26 2003
76998 @@ -80,6 +80,8 @@
76999         p->parent->cmin_flt += p->min_flt + p->cmin_flt;
77000         p->parent->cmaj_flt += p->maj_flt + p->cmaj_flt;
77001         p->parent->cnswap += p->nswap + p->cnswap;
77002 +       p->parent->cnvcsw += p->nvcsw + p->cnvcsw;
77003 +       p->parent->cnivcsw += p->nivcsw + p->cnivcsw;
77004         sched_exit(p);
77005         write_unlock_irq(&tasklist_lock);
77006         spin_unlock(&p->proc_lock);
77007 diff -Nru a/kernel/fork.c b/kernel/fork.c
77008 --- a/kernel/fork.c     Wed Aug 20 22:32:07 2003
77009 +++ b/kernel/fork.c     Sun Aug 31 16:14:26 2003
77010 @@ -461,6 +461,7 @@
77011         tsk->min_flt = tsk->maj_flt = 0;
77012         tsk->cmin_flt = tsk->cmaj_flt = 0;
77013         tsk->nswap = tsk->cnswap = 0;
77014 +       tsk->nvcsw = tsk->nivcsw = tsk->cnvcsw = tsk->cnivcsw = 0;
77015  
77016         tsk->mm = NULL;
77017         tsk->active_mm = NULL;
77018 diff -Nru a/kernel/futex.c b/kernel/futex.c
77019 --- a/kernel/futex.c    Sun May 25 20:39:28 2003
77020 +++ b/kernel/futex.c    Sun Aug 31 16:14:42 2003
77021 @@ -28,6 +28,7 @@
77022   */
77023  #include <linux/slab.h>
77024  #include <linux/poll.h>
77025 +#include <linux/fs.h>
77026  #include <linux/file.h>
77027  #include <linux/hash.h>
77028  #include <linux/init.h>
77029 @@ -60,8 +61,6 @@
77030  /* The key for the hash is the address + index + offset within page */
77031  static struct list_head futex_queues[1<<FUTEX_HASHBITS];
77032  static spinlock_t futex_lock = SPIN_LOCK_UNLOCKED;
77033 -
77034 -extern void send_sigio(struct fown_struct *fown, int fd, int band);
77035  
77036  /* Futex-fs vfsmount entry: */
77037  static struct vfsmount *futex_mnt;
77038 diff -Nru a/kernel/kallsyms.c b/kernel/kallsyms.c
77039 --- a/kernel/kallsyms.c Tue Aug 19 04:58:04 2003
77040 +++ b/kernel/kallsyms.c Sun Aug 31 16:14:13 2003
77041 @@ -189,9 +189,11 @@
77042         if (pos < iter->pos)
77043                 reset_iter(iter);
77044  
77045 -       /* We need to iterate through the previous symbols. */
77046 -       for (; iter->pos <= pos; iter->pos++)
77047 +       /* We need to iterate through the previous symbols: can be slow */
77048 +       for (; iter->pos != pos; iter->pos++) {
77049                 get_ksymbol_core(iter);
77050 +               cond_resched();
77051 +       }
77052         return 1;
77053  }
77054  
77055 @@ -280,8 +282,7 @@
77056  {
77057         struct proc_dir_entry *entry;
77058  
77059 -       /* root-only: could chew up lots of cpu by read, seek back, read... */
77060 -       entry = create_proc_entry("kallsyms", 0400, NULL);
77061 +       entry = create_proc_entry("kallsyms", 0444, NULL);
77062         if (entry)
77063                 entry->proc_fops = &kallsyms_operations;
77064         return 0;
77065 diff -Nru a/kernel/ksyms.c b/kernel/ksyms.c
77066 --- a/kernel/ksyms.c    Tue Aug 19 09:33:08 2003
77067 +++ b/kernel/ksyms.c    Thu Aug 28 00:36:28 2003
77068 @@ -120,7 +120,6 @@
77069  EXPORT_SYMBOL(max_mapnr);
77070  #endif
77071  EXPORT_SYMBOL(high_memory);
77072 -EXPORT_SYMBOL_GPL(invalidate_mmap_range);
77073  EXPORT_SYMBOL(vmtruncate);
77074  EXPORT_SYMBOL(find_vma);
77075  EXPORT_SYMBOL(get_unmapped_area);
77076 @@ -198,7 +197,6 @@
77077  EXPORT_SYMBOL(invalidate_inode_pages);
77078  EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
77079  EXPORT_SYMBOL(truncate_inode_pages);
77080 -EXPORT_SYMBOL(install_page);
77081  EXPORT_SYMBOL(fsync_bdev);
77082  EXPORT_SYMBOL(permission);
77083  EXPORT_SYMBOL(vfs_permission);
77084 diff -Nru a/kernel/posix-timers.c b/kernel/posix-timers.c
77085 --- a/kernel/posix-timers.c     Sat Jun 14 16:15:58 2003
77086 +++ b/kernel/posix-timers.c     Sat Aug 30 22:24:41 2003
77087 @@ -948,11 +948,15 @@
77088   */
77089  static int do_posix_gettime(struct k_clock *clock, struct timespec *tp)
77090  {
77091 +       struct timeval tv;
77092 +
77093         if (clock->clock_get)
77094                 return clock->clock_get(tp);
77095  
77096 -       do_gettimeofday((struct timeval *) tp);
77097 -       tp->tv_nsec *= NSEC_PER_USEC;
77098 +       do_gettimeofday(&tv);
77099 +       tp->tv_sec = tv.tv_sec;
77100 +       tp->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
77101 +
77102         return 0;
77103  }
77104  
77105 diff -Nru a/kernel/sched.c b/kernel/sched.c
77106 --- a/kernel/sched.c    Mon Aug 18 19:46:23 2003
77107 +++ b/kernel/sched.c    Sun Aug 31 16:14:26 2003
77108 @@ -1325,8 +1325,10 @@
77109                 }
77110         default:
77111                 deactivate_task(prev, rq);
77112 +               prev->nvcsw++;
77113 +               break;
77114         case TASK_RUNNING:
77115 -               ;
77116 +               prev->nivcsw++;
77117         }
77118  pick_next_task:
77119         if (unlikely(!rq->nr_running)) {
77120 diff -Nru a/kernel/sys.c b/kernel/sys.c
77121 --- a/kernel/sys.c      Tue Aug 19 21:53:11 2003
77122 +++ b/kernel/sys.c      Sun Aug 31 16:14:26 2003
77123 @@ -1309,6 +1309,8 @@
77124                 case RUSAGE_SELF:
77125                         jiffies_to_timeval(p->utime, &r.ru_utime);
77126                         jiffies_to_timeval(p->stime, &r.ru_stime);
77127 +                       r.ru_nvcsw = p->nvcsw;
77128 +                       r.ru_nivcsw = p->nivcsw;
77129                         r.ru_minflt = p->min_flt;
77130                         r.ru_majflt = p->maj_flt;
77131                         r.ru_nswap = p->nswap;
77132 @@ -1316,6 +1318,8 @@
77133                 case RUSAGE_CHILDREN:
77134                         jiffies_to_timeval(p->cutime, &r.ru_utime);
77135                         jiffies_to_timeval(p->cstime, &r.ru_stime);
77136 +                       r.ru_nvcsw = p->cnvcsw;
77137 +                       r.ru_nivcsw = p->cnivcsw;
77138                         r.ru_minflt = p->cmin_flt;
77139                         r.ru_majflt = p->cmaj_flt;
77140                         r.ru_nswap = p->cnswap;
77141 @@ -1323,6 +1327,8 @@
77142                 default:
77143                         jiffies_to_timeval(p->utime + p->cutime, &r.ru_utime);
77144                         jiffies_to_timeval(p->stime + p->cstime, &r.ru_stime);
77145 +                       r.ru_nvcsw = p->nvcsw + p->cnvcsw;
77146 +                       r.ru_nivcsw = p->nivcsw + p->cnivcsw;
77147                         r.ru_minflt = p->min_flt + p->cmin_flt;
77148                         r.ru_majflt = p->maj_flt + p->cmaj_flt;
77149                         r.ru_nswap = p->nswap + p->cnswap;
77150 diff -Nru a/kernel/timer.c b/kernel/timer.c
77151 --- a/kernel/timer.c    Thu Aug 14 17:00:00 2003
77152 +++ b/kernel/timer.c    Tue Sep  2 00:05:52 2003
77153 @@ -338,6 +338,7 @@
77154                         break;
77155                 }
77156         }
77157 +       smp_rmb();
77158         if (timer_pending(timer))
77159                 goto del_again;
77160  
77161 diff -Nru a/mm/fremap.c b/mm/fremap.c
77162 --- a/mm/fremap.c       Sun May 25 14:08:24 2003
77163 +++ b/mm/fremap.c       Thu Aug 28 00:38:39 2003
77164 @@ -3,7 +3,7 @@
77165   * 
77166   * Explicit pagetable population and nonlinear (random) mappings support.
77167   *
77168 - * started by Ingo Molnar, Copyright (C) 2002
77169 + * started by Ingo Molnar, Copyright (C) 2002, 2003
77170   */
77171  
77172  #include <linux/mm.h>
77173 @@ -13,6 +13,8 @@
77174  #include <linux/pagemap.h>
77175  #include <linux/swapops.h>
77176  #include <linux/rmap-locking.h>
77177 +#include <linux/module.h>
77178 +
77179  #include <asm/mmu_context.h>
77180  #include <asm/cacheflush.h>
77181  #include <asm/tlbflush.h>
77182 @@ -95,6 +97,8 @@
77183  err:
77184         return err;
77185  }
77186 +EXPORT_SYMBOL(install_page);
77187 +
77188  
77189  /***
77190   * sys_remap_file_pages - remap arbitrary pages of a shared backing store
77191 diff -Nru a/mm/memory.c b/mm/memory.c
77192 --- a/mm/memory.c       Thu Aug 14 18:17:40 2003
77193 +++ b/mm/memory.c       Sun Aug 31 16:14:24 2003
77194 @@ -45,6 +45,7 @@
77195  #include <linux/pagemap.h>
77196  #include <linux/vcache.h>
77197  #include <linux/rmap-locking.h>
77198 +#include <linux/module.h>
77199  
77200  #include <asm/pgalloc.h>
77201  #include <asm/rmap.h>
77202 @@ -810,17 +811,18 @@
77203  static inline int zeromap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address,
77204                                      unsigned long size, pgprot_t prot)
77205  {
77206 -       unsigned long end;
77207 +       unsigned long base, end;
77208  
77209 +       base = address & PGDIR_MASK;
77210         address &= ~PGDIR_MASK;
77211         end = address + size;
77212         if (end > PGDIR_SIZE)
77213                 end = PGDIR_SIZE;
77214         do {
77215 -               pte_t * pte = pte_alloc_map(mm, pmd, address);
77216 +               pte_t * pte = pte_alloc_map(mm, pmd, base + address);
77217                 if (!pte)
77218                         return -ENOMEM;
77219 -               zeromap_pte_range(pte, address, end - address, prot);
77220 +               zeromap_pte_range(pte, base + address, end - address, prot);
77221                 pte_unmap(pte);
77222                 address = (address + PMD_SIZE) & PMD_MASK;
77223                 pmd++;
77224 @@ -1138,6 +1140,7 @@
77225                 invalidate_mmap_range_list(&mapping->i_mmap_shared, hba, hlen);
77226         up(&mapping->i_shared_sem);
77227  }
77228 +EXPORT_SYMBOL_GPL(invalidate_mmap_range);
77229  
77230  /*
77231   * Handle all mappings that got truncated by a "truncate()"
77232 @@ -1384,10 +1387,10 @@
77233         unsigned long address, int write_access, pte_t *page_table, pmd_t *pmd)
77234  {
77235         struct page * new_page;
77236 -       struct address_space *mapping;
77237 +       struct address_space *mapping = NULL;
77238         pte_t entry;
77239         struct pte_chain *pte_chain;
77240 -       int sequence;
77241 +       int sequence = 0;
77242         int ret;
77243  
77244         if (!vma->vm_ops || !vma->vm_ops->nopage)
77245 @@ -1396,8 +1399,10 @@
77246         pte_unmap(page_table);
77247         spin_unlock(&mm->page_table_lock);
77248  
77249 -       mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
77250 -       sequence = atomic_read(&mapping->truncate_count);
77251 +       if (vma->vm_file) {
77252 +               mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
77253 +               sequence = atomic_read(&mapping->truncate_count);
77254 +       }
77255         smp_rmb();  /* Prevent CPU from reordering lock-free ->nopage() */
77256  retry:
77257         new_page = vma->vm_ops->nopage(vma, address & PAGE_MASK, 0);
77258 @@ -1433,7 +1438,8 @@
77259          * invalidated this page.  If invalidate_mmap_range got called,
77260          * retry getting the page.
77261          */
77262 -       if (unlikely(sequence != atomic_read(&mapping->truncate_count))) {
77263 +       if (mapping &&
77264 +             (unlikely(sequence != atomic_read(&mapping->truncate_count)))) {
77265                 sequence = atomic_read(&mapping->truncate_count);
77266                 spin_unlock(&mm->page_table_lock);
77267                 page_cache_release(new_page);
77268 @@ -1453,7 +1459,8 @@
77269          */
77270         /* Only go through if we didn't race with anybody else... */
77271         if (pte_none(*page_table)) {
77272 -               ++mm->rss;
77273 +               if (!PageReserved(new_page))
77274 +                       ++mm->rss;
77275                 flush_icache_page(vma, new_page);
77276                 entry = mk_pte(new_page, vma->vm_page_prot);
77277                 if (write_access)
77278 diff -Nru a/mm/page_alloc.c b/mm/page_alloc.c
77279 --- a/mm/page_alloc.c   Thu Aug 21 11:57:47 2003
77280 +++ b/mm/page_alloc.c   Wed Sep  3 23:40:12 2003
77281 @@ -220,6 +220,7 @@
77282                         1 << PG_locked  |
77283                         1 << PG_active  |
77284                         1 << PG_reclaim |
77285 +                       1 << PG_slab    |
77286                         1 << PG_writeback )))
77287                 bad_page(function, page);
77288         if (PageDirty(page))
77289 @@ -542,8 +543,7 @@
77290         int do_retry;
77291         struct reclaim_state reclaim_state;
77292  
77293 -       if (wait)
77294 -               might_sleep();
77295 +       might_sleep_if(wait);
77296  
77297         cold = 0;
77298         if (gfp_mask & __GFP_COLD)
77299 diff -Nru a/mm/rmap.c b/mm/rmap.c
77300 --- a/mm/rmap.c Fri Jun 27 01:46:43 2003
77301 +++ b/mm/rmap.c Wed Sep  3 23:40:12 2003
77302 @@ -503,8 +503,7 @@
77303         struct pte_chain *ret;
77304         struct pte_chain **pte_chainp;
77305  
77306 -       if (gfp_flags & __GFP_WAIT)
77307 -               might_sleep();
77308 +       might_sleep_if(gfp_flags & __GFP_WAIT);
77309  
77310         pte_chainp = &get_cpu_var(local_pte_chain);
77311         if (*pte_chainp) {
77312 diff -Nru a/mm/slab.c b/mm/slab.c
77313 --- a/mm/slab.c Mon Aug 18 22:27:21 2003
77314 +++ b/mm/slab.c Wed Sep  3 23:40:12 2003
77315 @@ -787,7 +787,8 @@
77316          * vm_scan(). Shouldn't be a worry.
77317          */
77318         while (i--) {
77319 -               ClearPageSlab(page);
77320 +               if (!TestClearPageSlab(page))
77321 +                       BUG();
77322                 page++;
77323         }
77324         sub_page_state(nr_slab, nr_freed);
77325 @@ -1813,8 +1814,7 @@
77326  static inline void
77327  cache_alloc_debugcheck_before(kmem_cache_t *cachep, int flags)
77328  {
77329 -       if (flags & __GFP_WAIT)
77330 -               might_sleep();
77331 +       might_sleep_if(flags & __GFP_WAIT);
77332  #if DEBUG
77333         kmem_flagcheck(cachep, flags);
77334  #endif
77335 diff -Nru a/mm/swapfile.c b/mm/swapfile.c
77336 --- a/mm/swapfile.c     Thu Jul 31 16:52:11 2003
77337 +++ b/mm/swapfile.c     Sun Aug 31 16:15:45 2003
77338 @@ -1403,7 +1403,8 @@
77339         p->max = maxpages;
77340         p->pages = nr_good_pages;
77341  
77342 -       if (setup_swap_extents(p))
77343 +       error = setup_swap_extents(p);
77344 +       if (error)
77345                 goto bad_swap;
77346  
77347         swap_list_lock();
77348 diff -Nru a/mm/vmscan.c b/mm/vmscan.c
77349 --- a/mm/vmscan.c       Thu Aug 21 11:57:48 2003
77350 +++ b/mm/vmscan.c       Sun Aug 31 16:14:47 2003
77351 @@ -80,25 +80,6 @@
77352  #endif
77353  
77354  /*
77355 - * exponentially decaying average
77356 - */
77357 -static inline int expavg(int avg, int val)
77358 -{
77359 -       return ((val - avg) >> 1) + avg;
77360 -}
77361 -
77362 -static void zone_adj_pressure(struct zone *zone, int priority)
77363 -{
77364 -       zone->pressure = expavg(zone->pressure,
77365 -                       (DEF_PRIORITY - priority) << 10);
77366 -}
77367 -
77368 -static int pressure_to_priority(int pressure)
77369 -{
77370 -       return DEF_PRIORITY - (pressure >> 10);
77371 -}
77372 -
77373 -/*
77374   * The list of shrinker callbacks used by to apply pressure to
77375   * ageable caches.
77376   */
77377 @@ -646,7 +627,7 @@
77378          * `distress' is a measure of how much trouble we're having reclaiming
77379          * pages.  0 -> no problems.  100 -> great trouble.
77380          */
77381 -       distress = 100 >> pressure_to_priority(zone->pressure);
77382 +       distress = 100 >> zone->prev_priority;
77383  
77384         /*
77385          * The point of this algorithm is to decide when to start reclaiming
77386 @@ -830,6 +811,9 @@
77387                 int nr_mapped = 0;
77388                 int max_scan;
77389  
77390 +               if (zone->free_pages < zone->pages_high)
77391 +                       zone->temp_priority = priority;
77392 +
77393                 if (zone->all_unreclaimable && priority != DEF_PRIORITY)
77394                         continue;       /* Let kswapd poll it */
77395  
77396 @@ -843,10 +827,8 @@
77397                 ret += shrink_zone(zone, max_scan, gfp_mask,
77398                                 to_reclaim, &nr_mapped, ps, priority);
77399                 *total_scanned += max_scan + nr_mapped;
77400 -               if (ret >= nr_pages) {
77401 -                       zone_adj_pressure(zone, priority);
77402 +               if (ret >= nr_pages)
77403                         break;
77404 -               }
77405         }
77406         return ret;
77407  }
77408 @@ -880,6 +862,9 @@
77409  
77410         inc_page_state(allocstall);
77411  
77412 +       for (zone = cz; zone >= cz->zone_pgdat->node_zones; --zone)
77413 +               zone->temp_priority = DEF_PRIORITY;
77414 +
77415         for (priority = DEF_PRIORITY; priority >= 0; priority--) {
77416                 int total_scanned = 0;
77417                 struct page_state ps;
77418 @@ -912,9 +897,9 @@
77419         }
77420         if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY))
77421                 out_of_memory();
77422 -       for (zone = cz; zone >= cz->zone_pgdat->node_zones; -- zone)
77423 -               zone_adj_pressure(zone, -1);
77424  out:
77425 +       for (zone = cz; zone >= cz->zone_pgdat->node_zones; --zone)
77426 +               zone->prev_priority = zone->temp_priority;
77427         return ret;
77428  }
77429  
77430 @@ -945,6 +930,12 @@
77431  
77432         inc_page_state(pageoutrun);
77433  
77434 +       for (i = 0; i < pgdat->nr_zones; i++) {
77435 +               struct zone *zone = pgdat->node_zones + i;
77436 +
77437 +               zone->temp_priority = DEF_PRIORITY;
77438 +       }
77439 +
77440         for (priority = DEF_PRIORITY; priority; priority--) {
77441                 int all_zones_ok = 1;
77442  
77443 @@ -961,11 +952,10 @@
77444                                 to_reclaim = min(to_free, SWAP_CLUSTER_MAX*8);
77445                         } else {                        /* Zone balancing */
77446                                 to_reclaim = zone->pages_high-zone->free_pages;
77447 -                               if (to_reclaim <= 0) {
77448 -                                       zone_adj_pressure(zone, priority);
77449 +                               if (to_reclaim <= 0)
77450                                         continue;
77451 -                               }
77452                         }
77453 +                       zone->temp_priority = priority;
77454                         all_zones_ok = 0;
77455                         max_scan = zone->nr_inactive >> priority;
77456                         if (max_scan < to_reclaim * 2)
77457 @@ -989,13 +979,11 @@
77458                 if (to_free > 0)
77459                         blk_congestion_wait(WRITE, HZ/10);
77460         }
77461 -       if (priority < 0) {
77462 -               for (i = 0; i < pgdat->nr_zones; i++) {
77463 -                       struct zone *zone = pgdat->node_zones + i;
77464  
77465 -                       if (zone->free_pages < zone->pages_high)
77466 -                               zone_adj_pressure(zone, -1);
77467 -               }
77468 +       for (i = 0; i < pgdat->nr_zones; i++) {
77469 +               struct zone *zone = pgdat->node_zones + i;
77470 +
77471 +               zone->prev_priority = zone->temp_priority;
77472         }
77473         return nr_pages - to_free;
77474  }
77475 diff -Nru a/net/Kconfig b/net/Kconfig
77476 --- a/net/Kconfig       Tue Aug 19 21:12:36 2003
77477 +++ b/net/Kconfig       Mon Sep  1 01:44:26 2003
77478 @@ -191,9 +191,11 @@
77479           information.
77480  
77481           If you enable iptables support along with the bridge support then you
77482 -         turn your bridge into a bridging firewall.
77483 +         turn your bridge into a bridging IP firewall.
77484           iptables will then see the IP packets being bridged, so you need to
77485           take this into account when setting up your firewall rules.
77486 +         Enabling arptables support when bridging will let arptables see
77487 +         bridged ARP traffic in the arptables FORWARD chain.
77488  
77489           If you want to compile this code as a module ( = code which can be
77490           inserted in and removed from the running kernel whenever you want),
77491 @@ -243,6 +245,12 @@
77492           box can transparently forward the traffic to a local server,
77493           typically a caching proxy server.
77494  
77495 +         Yet another use of Netfilter is building a bridging firewall. Using
77496 +         a bridge with Network packet filtering enabled makes iptables "see"
77497 +         the bridged traffic. For filtering on the lower network and Ethernet
77498 +         protocols over the bridge, use ebtables (under bridge netfilter
77499 +         configuration).
77500 +
77501           Various modules exist for netfilter which replace the previous
77502           masquerading (ipmasqadm), packet filtering (ipchains), transparent
77503           proxying, and portforwarding mechanisms. Please see
77504 @@ -263,6 +271,19 @@
77505         help
77506           You can say Y here if you want to get additional messages useful in
77507           debugging the netfilter code.
77508 +
77509 +config BRIDGE_NETFILTER
77510 +       bool "Bridged IP/ARP packets filtering"
77511 +       depends on BRIDGE && NETFILTER && INET
77512 +       default y
77513 +       ---help---
77514 +         Enabling this option will let arptables resp. iptables see bridged
77515 +         ARP resp. IP traffic. If you want a bridging firewall, you probably
77516 +         want this option enabled.
77517 +         Enabling or disabling this option doesn't enable or disable
77518 +         ebtables.
77519 +
77520 +         If unsure, say N.
77521  
77522  source "net/ipv4/netfilter/Kconfig"
77523  source "net/ipv6/netfilter/Kconfig"
77524 diff -Nru a/net/appletalk/aarp.c b/net/appletalk/aarp.c
77525 --- a/net/appletalk/aarp.c      Wed Jun  4 17:57:07 2003
77526 +++ b/net/appletalk/aarp.c      Sat Aug 30 19:27:36 2003
77527 @@ -37,6 +37,7 @@
77528  #include <linux/atalk.h>
77529  #include <linux/init.h>
77530  #include <linux/proc_fs.h>
77531 +#include <linux/seq_file.h>
77532  
77533  int sysctl_aarp_expiry_time = AARP_EXPIRY_TIME;
77534  int sysctl_aarp_tick_time = AARP_TICK_TIME;
77535 @@ -145,6 +146,7 @@
77536         aarp_dl->request(aarp_dl, skb, aarp_eth_multicast);
77537         /* Update the sending count */
77538         a->xmit_count++;
77539 +       a->last_sent = jiffies;
77540  }
77541  
77542  /* This runs under aarp_lock and in softint context, so only atomic memory
77543 @@ -338,6 +340,32 @@
77544         return NOTIFY_DONE;
77545  }
77546  
77547 +/* Expire all entries in a hash chain */
77548 +static void __aarp_expire_all(struct aarp_entry **n)
77549 +{
77550 +       struct aarp_entry *t;
77551 +
77552 +       while (*n) {
77553 +               t = *n;
77554 +               *n = (*n)->next;
77555 +               __aarp_expire(t);
77556 +       }
77557 +}
77558 +
77559 +/* Cleanup all hash chains -- module unloading */
77560 +static void aarp_purge(void)
77561 +{
77562 +       int ct;
77563 +
77564 +       write_lock_bh(&aarp_lock);
77565 +       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
77566 +               __aarp_expire_all(&resolved[ct]);
77567 +               __aarp_expire_all(&unresolved[ct]);
77568 +               __aarp_expire_all(&proxies[ct]);
77569 +       }
77570 +       write_unlock_bh(&aarp_lock);
77571 +}
77572 +
77573  /*
77574   *     Create a new aarp entry.  This must use GFP_ATOMIC because it
77575   *     runs while holding spinlocks.
77576 @@ -861,112 +889,181 @@
77577         write_unlock_bh(&aarp_lock);
77578  }
77579  
77580 -/* Called from proc fs */
77581 -static int aarp_get_info(char *buffer, char **start, off_t offset, int length)
77582 +#ifdef CONFIG_PROC_FS
77583 +struct aarp_iter_state {
77584 +       int bucket;
77585 +       struct aarp_entry **table;
77586 +};
77587 +
77588 +/*
77589 + * Get the aarp entry that is in the chain described
77590 + * by the iterator. 
77591 + * If pos is set then skip till that index.
77592 + * pos = 1 is the first entry
77593 + */
77594 +static struct aarp_entry *iter_next(struct aarp_iter_state *iter, loff_t *pos)
77595  {
77596 -       /* we should dump all our AARP entries */
77597 +       int ct = iter->bucket;
77598 +       struct aarp_entry **table = iter->table;
77599 +       loff_t off = 0;
77600         struct aarp_entry *entry;
77601 -       int ct, len = sprintf(buffer,
77602 -                             "%-10.10s  %-10.10s%-18.18s%12.12s%12.12s "
77603 -                             "xmit_count  status\n",
77604 -                             "address", "device", "hw addr", "last_sent",
77605 -                             "expires");
77606 +       
77607 + rescan:
77608 +       while(ct < AARP_HASH_SIZE) {
77609 +               for (entry = table[ct]; entry; entry = entry->next) {
77610 +                       if (!pos || ++off == *pos) {
77611 +                               iter->table = table;
77612 +                               iter->bucket = ct;
77613 +                               return entry;
77614 +                       }
77615 +               }
77616 +               ++ct;
77617 +       }
77618 +
77619 +       if (table == resolved) {
77620 +               ct = 0;
77621 +               table = unresolved;
77622 +               goto rescan;
77623 +       }
77624 +       if (table == unresolved) {
77625 +               ct = 0;
77626 +               table = proxies;
77627 +               goto rescan;
77628 +       }
77629 +       return NULL;
77630 +}
77631 +
77632 +static void *aarp_seq_start(struct seq_file *seq, loff_t *pos)
77633 +{
77634 +       struct aarp_iter_state *iter = seq->private;
77635  
77636         read_lock_bh(&aarp_lock);
77637 +       iter->table     = resolved;
77638 +       iter->bucket    = 0;
77639  
77640 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
77641 -               for (entry = resolved[ct]; entry; entry = entry->next) {
77642 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
77643 -                               (unsigned int)ntohs(entry->target_addr.s_net),
77644 -                               (unsigned int)(entry->target_addr.s_node));
77645 -                       len += sprintf(buffer + len, "%-10.10s",
77646 -                                      entry->dev->name);
77647 -                       len += sprintf(buffer + len,
77648 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
77649 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
77650 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
77651 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
77652 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
77653 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
77654 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
77655 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
77656 -                                      (unsigned long)entry->last_sent,
77657 -                                      (unsigned long)entry->expires_at);
77658 -                       len += sprintf(buffer + len, "%10u",
77659 -                                      (unsigned int)entry->xmit_count);
77660 +       return *pos ? iter_next(iter, pos) : ((void *)1);
77661 +}
77662  
77663 -                       len += sprintf(buffer + len, "   resolved\n");
77664 -               }
77665 -       }
77666 +static void *aarp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
77667 +{
77668 +       struct aarp_entry *entry = v;
77669 +       struct aarp_iter_state *iter = seq->private;
77670  
77671 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
77672 -               for (entry = unresolved[ct]; entry; entry = entry->next) {
77673 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
77674 -                               (unsigned int)ntohs(entry->target_addr.s_net),
77675 -                               (unsigned int)(entry->target_addr.s_node));
77676 -                       len += sprintf(buffer + len, "%-10.10s",
77677 -                                      entry->dev->name);
77678 -                       len += sprintf(buffer + len,
77679 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
77680 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
77681 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
77682 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
77683 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
77684 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
77685 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
77686 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
77687 -                                      (unsigned long)entry->last_sent,
77688 -                                      (unsigned long)entry->expires_at);
77689 -                       len += sprintf(buffer + len, "%10u",
77690 -                                      (unsigned int)entry->xmit_count);
77691 -                       len += sprintf(buffer + len, " unresolved\n");
77692 -               }
77693 -       }
77694 +       ++*pos;
77695  
77696 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
77697 -               for (entry = proxies[ct]; entry; entry = entry->next) {
77698 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
77699 -                               (unsigned int)ntohs(entry->target_addr.s_net),
77700 -                               (unsigned int)(entry->target_addr.s_node));
77701 -                       len += sprintf(buffer + len, "%-10.10s",
77702 -                                      entry->dev->name);
77703 -                       len += sprintf(buffer + len,
77704 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
77705 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
77706 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
77707 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
77708 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
77709 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
77710 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
77711 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
77712 -                                      (unsigned long)entry->last_sent,
77713 -                                      (unsigned long)entry->expires_at);
77714 -                       len += sprintf(buffer + len, "%10u",
77715 -                                      (unsigned int)entry->xmit_count);
77716 -                       len += sprintf(buffer + len, "      proxy\n");
77717 -               }
77718 +       /* first line after header */
77719 +       if (v == ((void *)1)) 
77720 +               entry = iter_next(iter, NULL);
77721 +               
77722 +       /* next entry in current bucket */
77723 +       else if (entry->next)
77724 +               entry = entry->next;
77725 +
77726 +       /* next bucket or table */
77727 +       else {
77728 +               ++iter->bucket;
77729 +               entry = iter_next(iter, NULL);
77730         }
77731 +       return entry;
77732 +}
77733  
77734 +static void aarp_seq_stop(struct seq_file *seq, void *v)
77735 +{
77736         read_unlock_bh(&aarp_lock);
77737 -       return len;
77738  }
77739  
77740 -/* General module cleanup. Called from cleanup_module() in ddp.c. */
77741 -void aarp_cleanup_module(void)
77742 +static const char *dt2str(unsigned long ticks)
77743  {
77744 -       del_timer(&aarp_timer);
77745 -       unregister_netdevice_notifier(&aarp_notifier);
77746 -       unregister_snap_client(aarp_dl);
77747 +       static char buf[32];
77748 +
77749 +       sprintf(buf, "%ld.%02ld", ticks / HZ, ((ticks % HZ) * 100 ) / HZ);
77750 +
77751 +       return buf;
77752  }
77753  
77754 -#ifdef CONFIG_PROC_FS
77755 -void aarp_register_proc_fs(void)
77756 +static int aarp_seq_show(struct seq_file *seq, void *v)
77757  {
77758 -       proc_net_create("aarp", 0, aarp_get_info);
77759 +       struct aarp_iter_state *iter = seq->private;
77760 +       struct aarp_entry *entry = v;
77761 +       unsigned long now = jiffies;
77762 +
77763 +       if (v == ((void *)1))
77764 +               seq_puts(seq, 
77765 +                        "Address  Interface   Hardware Address"
77766 +                        "   Expires LastSend  Retry Status\n");
77767 +       else {
77768 +               seq_printf(seq, "%04X:%02X  %-12s",
77769 +                          ntohs(entry->target_addr.s_net),
77770 +                          (unsigned int) entry->target_addr.s_node,
77771 +                          entry->dev ? entry->dev->name : "????");
77772 +               seq_printf(seq, "%02X:%02X:%02X:%02X:%02X:%02X",
77773 +                          entry->hwaddr[0] & 0xFF,
77774 +                          entry->hwaddr[1] & 0xFF,
77775 +                          entry->hwaddr[2] & 0xFF,
77776 +                          entry->hwaddr[3] & 0xFF,
77777 +                          entry->hwaddr[4] & 0xFF,
77778 +                          entry->hwaddr[5] & 0xFF);
77779 +               seq_printf(seq, " %8s",
77780 +                          dt2str((long)entry->expires_at - (long)now));
77781 +               if (iter->table == unresolved)
77782 +                       seq_printf(seq, " %8s %6hu",
77783 +                                  dt2str(now - entry->last_sent),
77784 +                                  entry->xmit_count);
77785 +               else
77786 +                       seq_puts(seq, "                ");
77787 +               seq_printf(seq, " %s\n",
77788 +                          (iter->table == resolved) ? "resolved"
77789 +                          : (iter->table == unresolved) ? "unresolved"
77790 +                          : (iter->table == proxies) ? "proxies"
77791 +                          : "unknown");
77792 +       }                                
77793 +       return 0;
77794  }
77795  
77796 -void aarp_unregister_proc_fs(void)
77797 +static struct seq_operations aarp_seq_ops = {
77798 +       .start  = aarp_seq_start,
77799 +       .next   = aarp_seq_next,
77800 +       .stop   = aarp_seq_stop,
77801 +       .show   = aarp_seq_show,
77802 +};
77803 +
77804 +static int aarp_seq_open(struct inode *inode, struct file *file)
77805  {
77806 -       proc_net_remove("aarp");
77807 +       struct seq_file *seq;
77808 +       int rc = -ENOMEM;
77809 +       struct aarp_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
77810 +       
77811 +       if (!s)
77812 +               goto out;
77813 +
77814 +       rc = seq_open(file, &aarp_seq_ops);
77815 +       if (rc)
77816 +               goto out_kfree;
77817 +
77818 +       seq          = file->private_data;
77819 +       seq->private = s;
77820 +       memset(s, 0, sizeof(*s));
77821 +out:
77822 +       return rc;
77823 +out_kfree:
77824 +       kfree(s);
77825 +       goto out;
77826  }
77827 +
77828 +struct file_operations atalk_seq_arp_fops = {
77829 +       .owner          = THIS_MODULE,
77830 +       .open           = aarp_seq_open,
77831 +       .read           = seq_read,
77832 +       .llseek         = seq_lseek,
77833 +       .release        = seq_release_private,
77834 +};
77835  #endif
77836 +
77837 +/* General module cleanup. Called from cleanup_module() in ddp.c. */
77838 +void aarp_cleanup_module(void)
77839 +{
77840 +       del_timer_sync(&aarp_timer);
77841 +       unregister_netdevice_notifier(&aarp_notifier);
77842 +       unregister_snap_client(aarp_dl);
77843 +       aarp_purge();
77844 +}
77845 diff -Nru a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
77846 --- a/net/appletalk/atalk_proc.c        Mon Jun 16 08:11:36 2003
77847 +++ b/net/appletalk/atalk_proc.c        Sat Aug 30 19:27:36 2003
77848 @@ -16,6 +16,8 @@
77849  #include <linux/atalk.h>
77850  
77851  #ifdef CONFIG_PROC_FS
77852 +extern struct file_operations atalk_seq_arp_fops;
77853 +
77854  static __inline__ struct atalk_iface *atalk_get_interface_idx(loff_t pos)
77855  {
77856         struct atalk_iface *i;
77857 @@ -61,7 +63,7 @@
77858         struct atalk_iface *iface;
77859  
77860         if (v == (void *)1) {
77861 -               seq_puts(seq, "Interface          Address   Networks   "
77862 +               seq_puts(seq, "Interface        Address   Networks  "
77863                               "Status\n");
77864                 goto out;
77865         }
77866 @@ -275,6 +277,7 @@
77867         atalk_proc_dir = proc_mkdir("atalk", proc_net);
77868         if (!atalk_proc_dir)
77869                 goto out;
77870 +       atalk_proc_dir->owner = THIS_MODULE;
77871  
77872         p = create_proc_entry("interface", S_IRUGO, atalk_proc_dir);
77873         if (!p)
77874 @@ -291,9 +294,16 @@
77875                 goto out_socket;
77876         p->proc_fops = &atalk_seq_socket_fops;
77877  
77878 +       p = create_proc_entry("arp", S_IRUGO, atalk_proc_dir);
77879 +       if (!p) 
77880 +               goto out_arp;
77881 +       p->proc_fops = &atalk_seq_arp_fops;
77882 +
77883         rc = 0;
77884  out:
77885         return rc;
77886 +out_arp:
77887 +       remove_proc_entry("socket", atalk_proc_dir);
77888  out_socket:
77889         remove_proc_entry("route", atalk_proc_dir);
77890  out_route:
77891 @@ -308,6 +318,7 @@
77892         remove_proc_entry("interface", atalk_proc_dir);
77893         remove_proc_entry("route", atalk_proc_dir);
77894         remove_proc_entry("socket", atalk_proc_dir);
77895 +       remove_proc_entry("arp", atalk_proc_dir);
77896         remove_proc_entry("atalk", proc_net);
77897  }
77898  
77899 diff -Nru a/net/appletalk/ddp.c b/net/appletalk/ddp.c
77900 --- a/net/appletalk/ddp.c       Mon Jun 16 08:11:36 2003
77901 +++ b/net/appletalk/ddp.c       Tue Sep  2 04:38:10 2003
77902 @@ -61,11 +61,6 @@
77903  #include <net/route.h>
77904  #include <linux/atalk.h>
77905  
77906 -#ifdef CONFIG_PROC_FS
77907 -extern void aarp_register_proc_fs(void);
77908 -extern void aarp_unregister_proc_fs(void);
77909 -#endif
77910 -
77911  extern void aarp_cleanup_module(void);
77912  
77913  extern void aarp_probe_network(struct atalk_iface *atif);
77914 @@ -183,13 +178,12 @@
77915  {
77916         struct sock *sk = (struct sock *)data;
77917  
77918 -       if (!atomic_read(&sk->sk_wmem_alloc) &&
77919 -           !atomic_read(&sk->sk_rmem_alloc) && sock_flag(sk, SOCK_DEAD))
77920 -               sock_put(sk);
77921 -       else {
77922 +       if (atomic_read(&sk->sk_wmem_alloc) ||
77923 +           atomic_read(&sk->sk_rmem_alloc)) {
77924                 sk->sk_timer.expires = jiffies + SOCK_DESTROY_TIME;
77925                 add_timer(&sk->sk_timer);
77926 -       }
77927 +       } else
77928 +               sock_put(sk);
77929  }
77930  
77931  static inline void atalk_destroy_socket(struct sock *sk)
77932 @@ -197,16 +191,15 @@
77933         atalk_remove_socket(sk);
77934         skb_queue_purge(&sk->sk_receive_queue);
77935  
77936 -       if (!atomic_read(&sk->sk_wmem_alloc) &&
77937 -           !atomic_read(&sk->sk_rmem_alloc) && sock_flag(sk, SOCK_DEAD))
77938 -               sock_put(sk);
77939 -       else {
77940 +       if (atomic_read(&sk->sk_wmem_alloc) ||
77941 +           atomic_read(&sk->sk_rmem_alloc)) {
77942                 init_timer(&sk->sk_timer);
77943                 sk->sk_timer.expires    = jiffies + SOCK_DESTROY_TIME;
77944                 sk->sk_timer.function   = atalk_destroy_timer;
77945                 sk->sk_timer.data       = (unsigned long)sk;
77946                 add_timer(&sk->sk_timer);
77947 -       }
77948 +       } else
77949 +               sock_put(sk);
77950  }
77951  
77952  /**************************************************************************\
77953 @@ -239,6 +232,7 @@
77954         while ((tmp = *iface) != NULL) {
77955                 if (tmp->dev == dev) {
77956                         *iface = tmp->next;
77957 +                       dev_put(dev);
77958                         kfree(tmp);
77959                         dev->atalk_ptr = NULL;
77960                 } else
77961 @@ -255,6 +249,7 @@
77962         if (!iface)
77963                 goto out;
77964  
77965 +       dev_hold(dev);
77966         iface->dev = dev;
77967         dev->atalk_ptr = iface;
77968         iface->address = *sa;
77969 @@ -616,6 +611,7 @@
77970                     (!(tmp->flags&RTF_GATEWAY) ||
77971                      tmp->target.s_node == addr->s_node)) {
77972                         *r = tmp->next;
77973 +                       dev_put(tmp->dev);
77974                         kfree(tmp);
77975                         goto out;
77976                 }
77977 @@ -640,6 +636,7 @@
77978         while ((tmp = *r) != NULL) {
77979                 if (tmp->dev == dev) {
77980                         *r = tmp->next;
77981 +                       dev_put(dev);
77982                         kfree(tmp);
77983                 } else
77984                         r = &tmp->next;
77985 @@ -935,24 +932,95 @@
77986   * Checksum: This is 'optional'. It's quite likely also a good
77987   * candidate for assembler hackery 8)
77988   */
77989 -unsigned short atalk_checksum(struct ddpehdr *ddp, int len)
77990 +static unsigned long atalk_sum_partial(const unsigned char *data, 
77991 +                                      int len, unsigned long sum)
77992  {
77993 -       unsigned long sum = 0;  /* Assume unsigned long is >16 bits */
77994 -       unsigned char *data = (unsigned char *)ddp;
77995 -
77996 -       len  -= 4;              /* skip header 4 bytes */
77997 -       data += 4;
77998 -
77999         /* This ought to be unwrapped neatly. I'll trust gcc for now */
78000         while (len--) {
78001 -               sum += *data;
78002 +               sum += *data++;
78003                 sum <<= 1;
78004 -               if (sum & 0x10000) {
78005 -                       sum++;
78006 -                       sum &= 0xFFFF;
78007 +               sum = ((sum >> 16) + sum) & 0xFFFF;
78008 +       }
78009 +       return sum;
78010 +}
78011 +
78012 +/*  Checksum skb data --  similar to skb_checksum  */
78013 +static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
78014 +                                  int len, unsigned long sum)
78015 +{
78016 +       int start = skb_headlen(skb);
78017 +       int i, copy;
78018 +
78019 +       /* checksum stuff in header space */
78020 +       if ( (copy = start - offset) > 0) {
78021 +               if (copy > len)
78022 +                       copy = len;
78023 +               sum = atalk_sum_partial(skb->data + offset, copy, sum);
78024 +               if ( (len -= copy) == 0) 
78025 +                       return sum;
78026 +
78027 +               offset += copy;
78028 +       }
78029 +
78030 +       /* checksum stuff in frags */
78031 +       for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
78032 +               int end;
78033 +
78034 +               BUG_TRAP(start <= offset + len);
78035 +
78036 +               end = start + skb_shinfo(skb)->frags[i].size;
78037 +               if ((copy = end - offset) > 0) {
78038 +                       u8 *vaddr;
78039 +                       skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
78040 +
78041 +                       if (copy > len)
78042 +                               copy = len;
78043 +                       vaddr = kmap_skb_frag(frag);
78044 +                       sum = atalk_sum_partial(vaddr + frag->page_offset +
78045 +                                                 offset - start, copy, sum);
78046 +                       kunmap_skb_frag(vaddr);
78047 +
78048 +                       if (!(len -= copy))
78049 +                               return sum;
78050 +                       offset += copy;
78051 +               }
78052 +               start = end;
78053 +       }
78054 +
78055 +       if (skb_shinfo(skb)->frag_list) {
78056 +               struct sk_buff *list = skb_shinfo(skb)->frag_list;
78057 +
78058 +               for (; list; list = list->next) {
78059 +                       int end;
78060 +
78061 +                       BUG_TRAP(start <= offset + len);
78062 +
78063 +                       end = start + list->len;
78064 +                       if ((copy = end - offset) > 0) {
78065 +                               if (copy > len)
78066 +                                       copy = len;
78067 +                               sum = atalk_sum_skb(list, offset - start,
78068 +                                                   copy, sum);
78069 +                               if ((len -= copy) == 0)
78070 +                                       return sum;
78071 +                               offset += copy;
78072 +                       }
78073 +                       start = end;
78074                 }
78075 -               data++;
78076         }
78077 +
78078 +       BUG_ON(len > 0);
78079 +
78080 +       return sum;
78081 +}
78082 +
78083 +static unsigned short atalk_checksum(const struct sk_buff *skb, int len)
78084 +{
78085 +       unsigned long sum;
78086 +
78087 +       /* skip header 4 bytes */
78088 +       sum = atalk_sum_skb(skb, 4, len-4, 0);
78089 +
78090         /* Use 0xFFFF for 0. 0 itself means none */
78091         return sum ? htons((unsigned short)sum) : 0xFFFF;
78092  }
78093 @@ -983,6 +1051,8 @@
78094         rc = 0;
78095         sock->ops = &atalk_dgram_ops;
78096         sock_init_data(sock, sk);
78097 +       sk_set_owner(sk, THIS_MODULE);
78098 +
78099         /* Checksums on by default */
78100         sk->sk_zapped = 1;
78101  out:
78102 @@ -998,10 +1068,7 @@
78103         struct sock *sk = sock->sk;
78104  
78105         if (sk) {
78106 -               if (!sock_flag(sk, SOCK_DEAD)) {
78107 -                       sk->sk_state_change(sk);
78108 -                       sock_set_flag(sk, SOCK_DEAD);
78109 -               }
78110 +               sock_orphan(sk);
78111                 sock->sk = NULL;
78112                 atalk_destroy_socket(sk);
78113         }
78114 @@ -1335,25 +1402,27 @@
78115  static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
78116                      struct packet_type *pt)
78117  {
78118 -       struct ddpehdr *ddp = ddp_hdr(skb);
78119 +       struct ddpehdr *ddp;
78120         struct sock *sock;
78121         struct atalk_iface *atif;
78122         struct sockaddr_at tosat;
78123          int origlen;
78124          struct ddpebits ddphv;
78125  
78126 -       /* Size check */
78127 -       if (skb->len < sizeof(*ddp))
78128 +       /* Don't mangle buffer if shared */
78129 +       if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 
78130 +               goto out;
78131 +               
78132 +       /* Size check and make sure header is contiguous */
78133 +       if (!pskb_may_pull(skb, sizeof(*ddp)))
78134                 goto freeit;
78135  
78136 +       ddp = ddp_hdr(skb);
78137 +
78138         /*
78139          *      Fix up the length field [Ok this is horrible but otherwise
78140          *      I end up with unions of bit fields and messy bit field order
78141          *      compiler/endian dependencies..]
78142 -        *
78143 -        *      FIXME: This is a write to a shared object. Granted it
78144 -        *      happens to be safe BUT.. (Its safe as user space will not
78145 -        *      run until we put it back)
78146          */
78147         *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp));
78148  
78149 @@ -1374,7 +1443,7 @@
78150          * valid for net byte orders all over the networking code...
78151          */
78152         if (ddp->deh_sum &&
78153 -           atalk_checksum(ddp, ddphv.deh_len) != ddp->deh_sum)
78154 +           atalk_checksum(skb, ddphv.deh_len) != ddp->deh_sum)
78155                 /* Not a valid AppleTalk frame - dustbin time */
78156                 goto freeit;
78157  
78158 @@ -1433,14 +1502,16 @@
78159  
78160                 if (!ap || skb->len < sizeof(struct ddpshdr))
78161                         goto freeit;
78162 +
78163 +               /* Don't mangle buffer if shared */
78164 +               if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 
78165 +                       return 0;
78166 +
78167                 /*
78168                  * The push leaves us with a ddephdr not an shdr, and
78169                  * handily the port bytes in the right place preset.
78170                  */
78171 -
78172 -               skb_push(skb, sizeof(*ddp) - 4);
78173 -               /* FIXME: use skb->cb to be able to use shared skbs */
78174 -               ddp = (struct ddpehdr *)skb->data;
78175 +               ddp = (struct ddpehdr *) skb_push(skb, sizeof(*ddp) - 4);
78176  
78177                 /* Now fill in the long header */
78178  
78179 @@ -1592,7 +1663,7 @@
78180         if (sk->sk_no_check == 1)
78181                 ddp->deh_sum = 0;
78182         else
78183 -               ddp->deh_sum = atalk_checksum(ddp, len + sizeof(*ddp));
78184 +               ddp->deh_sum = atalk_checksum(skb, len + sizeof(*ddp));
78185  
78186         /*
78187          * Loopback broadcast packets to non gateway targets (ie routes
78188 @@ -1801,11 +1872,13 @@
78189  struct packet_type ltalk_packet_type = {
78190         .type           = __constant_htons(ETH_P_LOCALTALK),
78191         .func           = ltalk_rcv,
78192 +       .data           = (void *)1,
78193  };
78194  
78195  struct packet_type ppptalk_packet_type = {
78196         .type           = __constant_htons(ETH_P_PPPTALK),
78197         .func           = atalk_rcv,
78198 +       .data           = (void *)1,
78199  };
78200  
78201  static unsigned char ddp_snap_id[] = { 0x08, 0x00, 0x07, 0x80, 0x9B };
78202 @@ -1834,9 +1907,6 @@
78203         register_netdevice_notifier(&ddp_notifier);
78204         aarp_proto_init();
78205         atalk_proc_init();
78206 -#ifdef CONFIG_PROC_FS
78207 -       aarp_register_proc_fs();
78208 -#endif /* CONFIG_PROC_FS */
78209         atalk_register_sysctl();
78210         printk(atalk_banner);
78211         return 0;
78212 @@ -1844,13 +1914,10 @@
78213  module_init(atalk_init);
78214  
78215  /*
78216 - * Note on MOD_{INC,DEC}_USE_COUNT:
78217 - *
78218 - * Use counts are incremented/decremented when
78219 - * sockets are created/deleted.
78220 - *
78221 - * AppleTalk interfaces are not incremented until atalkd is run
78222 - * and are only decremented when they are downed.
78223 + * No explicit module reference count manipulation is needed in the
78224 + * protocol. Socket layer sets module reference count for us
78225 + * and interfaces reference counting is done
78226 + * by the network device layer.
78227   *
78228   * Ergo, before the AppleTalk module can be removed, all AppleTalk
78229   * sockets be closed from user space.
78230 @@ -1861,9 +1928,6 @@
78231         atalk_unregister_sysctl();
78232  #endif /* CONFIG_SYSCTL */
78233         atalk_proc_exit();
78234 -#ifdef CONFIG_PROC_FS
78235 -       aarp_unregister_proc_fs();
78236 -#endif /* CONFIG_PROC_FS */
78237         aarp_cleanup_module();  /* General aarp clean-up. */
78238         unregister_netdevice_notifier(&ddp_notifier);
78239         dev_remove_pack(&ltalk_packet_type);
78240 @@ -1876,3 +1940,4 @@
78241  MODULE_LICENSE("GPL");
78242  MODULE_AUTHOR("Alan Cox <Alan.Cox@linux.org>");
78243  MODULE_DESCRIPTION("AppleTalk 0.20 for Linux NET4.0\n");
78244 +MODULE_ALIAS_NETPROTO(PF_APPLETALK);
78245 diff -Nru a/net/atm/common.c b/net/atm/common.c
78246 --- a/net/atm/common.c  Tue Aug 19 21:10:45 2003
78247 +++ b/net/atm/common.c  Tue Sep  2 04:38:10 2003
78248 @@ -279,6 +279,7 @@
78249         if (!sk)
78250                 return -ENOMEM;
78251         sock_init_data(sock, sk);
78252 +       sk_set_owner(sk, THIS_MODULE);
78253         sk->sk_state_change = vcc_def_wakeup;
78254         sk->sk_write_space = vcc_write_space;
78255  
78256 @@ -1135,3 +1136,5 @@
78257  module_exit(atm_exit);
78258  
78259  MODULE_LICENSE("GPL");
78260 +MODULE_ALIAS_NETPROTO(PF_ATMPVC);
78261 +MODULE_ALIAS_NETPROTO(PF_ATMSVC);
78262 diff -Nru a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
78263 --- a/net/ax25/af_ax25.c        Thu Aug 21 11:59:08 2003
78264 +++ b/net/ax25/af_ax25.c        Tue Sep  2 04:38:10 2003
78265 @@ -1842,81 +1842,107 @@
78266         return res;
78267  }
78268  
78269 -static int ax25_get_info(char *buffer, char **start, off_t offset, int length)
78270 +#ifdef CONFIG_PROC_FS
78271 +
78272 +static void *ax25_info_start(struct seq_file *seq, loff_t *pos)
78273  {
78274 -       ax25_cb *ax25;
78275 -       int k;
78276 -       int len = 0;
78277 -       off_t pos = 0;
78278 -       off_t begin = 0;
78279 +       struct ax25_cb *ax25;
78280         struct hlist_node *node;
78281 +       int i = 0;
78282  
78283         spin_lock_bh(&ax25_list_lock);
78284 +       ax25_for_each(ax25, node, &ax25_list) {
78285 +               if (i == *pos)
78286 +                       return ax25;
78287 +               ++i;
78288 +       }
78289 +       return NULL;
78290 +}
78291 +
78292 +static void *ax25_info_next(struct seq_file *seq, void *v, loff_t *pos)
78293 +{
78294 +       ++*pos;
78295 +
78296 +       return hlist_entry( ((struct ax25_cb *)v)->ax25_node.next,
78297 +                           struct ax25_cb, ax25_node);
78298 +}
78299 +       
78300 +static void ax25_info_stop(struct seq_file *seq, void *v)
78301 +{
78302 +       spin_unlock_bh(&ax25_list_lock);
78303 +}
78304 +
78305 +static int ax25_info_show(struct seq_file *seq, void *v)
78306 +{
78307 +       ax25_cb *ax25 = v;
78308 +       int k;
78309 +
78310  
78311         /*
78312          * New format:
78313          * 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
78314          */
78315  
78316 -       ax25_for_each(ax25, node, &ax25_list) {
78317 -               len += sprintf(buffer+len, "%8.8lx %s %s%s ",
78318 -                               (long) ax25,
78319 -                               ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
78320 -                               ax2asc(&ax25->source_addr),
78321 -                               ax25->iamdigi? "*":"");
78322 -
78323 -               len += sprintf(buffer+len, "%s", ax2asc(&ax25->dest_addr));
78324 -
78325 -               for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) {
78326 -                       len += sprintf(buffer+len, ",%s%s",
78327 -                                       ax2asc(&ax25->digipeat->calls[k]),
78328 -                                       ax25->digipeat->repeated[k]? "*":"");
78329 -               }
78330 -
78331 -               len += sprintf(buffer+len, " %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %d %d",
78332 -                       ax25->state,
78333 -                       ax25->vs, ax25->vr, ax25->va,
78334 -                       ax25_display_timer(&ax25->t1timer) / HZ, ax25->t1 / HZ,
78335 -                       ax25_display_timer(&ax25->t2timer) / HZ, ax25->t2 / HZ,
78336 -                       ax25_display_timer(&ax25->t3timer) / HZ, ax25->t3 / HZ,
78337 -                       ax25_display_timer(&ax25->idletimer) / (60 * HZ),
78338 -                       ax25->idle / (60 * HZ),
78339 -                       ax25->n2count, ax25->n2,
78340 -                       ax25->rtt / HZ,
78341 -                       ax25->window,
78342 -                       ax25->paclen);
78343 -
78344 -               if (ax25->sk != NULL) {
78345 -                       bh_lock_sock(ax25->sk);
78346 -                       len += sprintf(buffer + len, " %d %d %ld\n",
78347 -                               atomic_read(&ax25->sk->sk_wmem_alloc),
78348 -                               atomic_read(&ax25->sk->sk_rmem_alloc),
78349 -                               ax25->sk->sk_socket != NULL ? SOCK_INODE(ax25->sk->sk_socket)->i_ino : 0L);
78350 -                       bh_unlock_sock(ax25->sk);
78351 -               } else {
78352 -                       len += sprintf(buffer + len, " * * *\n");
78353 -               }
78354 -
78355 -               pos = begin + len;
78356 -
78357 -               if (pos < offset) {
78358 -                       len   = 0;
78359 -                       begin = pos;
78360 -               }
78361 +       seq_printf(seq, "%8.8lx %s %s%s ",
78362 +                  (long) ax25,
78363 +                  ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
78364 +                  ax2asc(&ax25->source_addr),
78365 +                  ax25->iamdigi? "*":"");
78366 +       seq_printf(seq, "%s", ax2asc(&ax25->dest_addr));
78367 +
78368 +       for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) {
78369 +               seq_printf(seq, ",%s%s",
78370 +                          ax2asc(&ax25->digipeat->calls[k]),
78371 +                          ax25->digipeat->repeated[k]? "*":"");
78372 +       }
78373  
78374 -               if (pos > offset + length)
78375 -                       break;
78376 +       seq_printf(seq, " %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %d %d",
78377 +                  ax25->state,
78378 +                  ax25->vs, ax25->vr, ax25->va,
78379 +                  ax25_display_timer(&ax25->t1timer) / HZ, ax25->t1 / HZ,
78380 +                  ax25_display_timer(&ax25->t2timer) / HZ, ax25->t2 / HZ,
78381 +                  ax25_display_timer(&ax25->t3timer) / HZ, ax25->t3 / HZ,
78382 +                  ax25_display_timer(&ax25->idletimer) / (60 * HZ),
78383 +                  ax25->idle / (60 * HZ),
78384 +                  ax25->n2count, ax25->n2,
78385 +                  ax25->rtt / HZ,
78386 +                  ax25->window,
78387 +                  ax25->paclen);
78388 +
78389 +       if (ax25->sk != NULL) {
78390 +               bh_lock_sock(ax25->sk);
78391 +               seq_printf(seq," %d %d %ld\n",
78392 +                          atomic_read(&ax25->sk->sk_wmem_alloc),
78393 +                          atomic_read(&ax25->sk->sk_rmem_alloc),
78394 +                          ax25->sk->sk_socket != NULL ? SOCK_INODE(ax25->sk->sk_socket)->i_ino : 0L);
78395 +               bh_unlock_sock(ax25->sk);
78396 +       } else {
78397 +               seq_puts(seq, " * * *\n");
78398         }
78399 +       return 0;
78400 +}
78401  
78402 -       spin_unlock_bh(&ax25_list_lock);
78403 +static struct seq_operations ax25_info_seqops = {
78404 +       .start = ax25_info_start,
78405 +       .next = ax25_info_next,
78406 +       .stop = ax25_info_stop,
78407 +       .show = ax25_info_show,
78408 +};
78409  
78410 -       *start = buffer + (offset - begin);
78411 -       len   -= (offset - begin);
78412 +static int ax25_info_open(struct inode *inode, struct file *file)
78413 +{
78414 +       return seq_open(file, &ax25_info_seqops);
78415 +}
78416  
78417 -       if (len > length) len = length;
78418 +static struct file_operations ax25_info_fops = {
78419 +       .owner = THIS_MODULE,
78420 +       .open = ax25_info_open,
78421 +       .read = seq_read,
78422 +       .llseek = seq_lseek,
78423 +       .release = seq_release,
78424 +};
78425  
78426 -       return(len);
78427 -}
78428 +#endif
78429  
78430  static struct net_proto_family ax25_family_ops = {
78431         .family =       PF_AX25,
78432 @@ -1986,9 +2012,9 @@
78433         register_netdevice_notifier(&ax25_dev_notifier);
78434         ax25_register_sysctl();
78435  
78436 -       proc_net_create("ax25_route", 0, ax25_rt_get_info);
78437 -       proc_net_create("ax25", 0, ax25_get_info);
78438 -       proc_net_create("ax25_calls", 0, ax25_uid_get_info);
78439 +       proc_net_fops_create("ax25_route", S_IRUGO, &ax25_route_fops);
78440 +       proc_net_fops_create("ax25", S_IRUGO, &ax25_info_fops);
78441 +       proc_net_fops_create("ax25_calls", S_IRUGO, &ax25_uid_fops);
78442  
78443         printk(banner);
78444         return 0;
78445 @@ -1999,6 +2025,7 @@
78446  MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>");
78447  MODULE_DESCRIPTION("The amateur radio AX.25 link layer protocol");
78448  MODULE_LICENSE("GPL");
78449 +MODULE_ALIAS_NETPROTO(PF_AX25);
78450  
78451  static void __exit ax25_exit(void)
78452  {
78453 diff -Nru a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
78454 --- a/net/ax25/ax25_dev.c       Thu Jun  5 01:01:36 2003
78455 +++ b/net/ax25/ax25_dev.c       Sun Aug 24 04:32:46 2003
78456 @@ -67,6 +67,7 @@
78457  
78458         dev->ax25_ptr     = ax25_dev;
78459         ax25_dev->dev     = dev;
78460 +       dev_hold(dev);
78461         ax25_dev->forward = NULL;
78462  
78463         ax25_dev->values[AX25_VALUES_IPDEFMODE] = AX25_DEF_IPDEFMODE;
78464 @@ -121,6 +122,7 @@
78465         if ((s = ax25_dev_list) == ax25_dev) {
78466                 ax25_dev_list = s->next;
78467                 spin_unlock_bh(&ax25_dev_lock);
78468 +               dev_put(dev);
78469                 kfree(ax25_dev);
78470                 ax25_register_sysctl();
78471                 return;
78472 @@ -130,6 +132,7 @@
78473                 if (s->next == ax25_dev) {
78474                         s->next = ax25_dev->next;
78475                         spin_unlock_bh(&ax25_dev_lock);
78476 +                       dev_put(dev);
78477                         kfree(ax25_dev);
78478                         ax25_register_sysctl();
78479                         return;
78480 @@ -196,8 +199,8 @@
78481         ax25_dev = ax25_dev_list;
78482         while (ax25_dev != NULL) {
78483                 s        = ax25_dev;
78484 +               dev_put(ax25_dev->dev);
78485                 ax25_dev = ax25_dev->next;
78486 -
78487                 kfree(s);
78488         }
78489         ax25_dev_list = NULL;
78490 diff -Nru a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
78491 --- a/net/ax25/ax25_route.c     Thu Aug 21 11:59:08 2003
78492 +++ b/net/ax25/ax25_route.c     Sun Aug 24 04:34:01 2003
78493 @@ -34,6 +34,7 @@
78494  #include <linux/mm.h>
78495  #include <linux/interrupt.h>
78496  #include <linux/init.h>
78497 +#include <linux/seq_file.h>
78498  
78499  static ax25_route *ax25_route_list;
78500  static rwlock_t ax25_route_lock = RW_LOCK_UNLOCKED;
78501 @@ -278,66 +279,100 @@
78502         }
78503  }
78504  
78505 -int ax25_rt_get_info(char *buffer, char **start, off_t offset, int length)
78506 -{
78507 -       ax25_route *ax25_rt;
78508 -       int len     = 0;
78509 -       off_t pos   = 0;
78510 -       off_t begin = 0;
78511 -       char *callsign;
78512 -       int i;
78513 +#ifdef CONFIG_PROC_FS
78514  
78515 -       read_lock(&ax25_route_lock);
78516 +#define AX25_PROC_START        ((void *)1)
78517  
78518 -       len += sprintf(buffer, "callsign  dev  mode digipeaters\n");
78519 +static void *ax25_rt_seq_start(struct seq_file *seq, loff_t *pos)
78520 +{
78521 +       struct ax25_route *ax25_rt;
78522 +       int i = 1;
78523
78524 +       read_lock(&ax25_route_lock);
78525 +       if (*pos == 0)
78526 +               return AX25_PROC_START;
78527  
78528         for (ax25_rt = ax25_route_list; ax25_rt != NULL; ax25_rt = ax25_rt->next) {
78529 +               if (i == *pos)
78530 +                       return ax25_rt;
78531 +               ++i;
78532 +       }
78533 +
78534 +       return NULL;
78535 +}
78536 +
78537 +static void *ax25_rt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
78538 +{
78539 +       ++*pos;
78540 +       return (v == AX25_PROC_START) ? ax25_route_list : 
78541 +               ((struct ax25_route *) v)->next;
78542 +}
78543 +
78544 +static void ax25_rt_seq_stop(struct seq_file *seq, void *v)
78545 +{
78546 +       read_unlock(&ax25_route_lock);
78547 +}
78548 +
78549 +static int ax25_rt_seq_show(struct seq_file *seq, void *v)
78550 +{
78551 +       if (v == AX25_PROC_START)
78552 +               seq_puts(seq, "callsign  dev  mode digipeaters\n");
78553 +       else {
78554 +               struct ax25_route *ax25_rt = v;
78555 +               const char *callsign;
78556 +               int i;
78557 +
78558                 if (ax25cmp(&ax25_rt->callsign, &null_ax25_address) == 0)
78559                         callsign = "default";
78560                 else
78561                         callsign = ax2asc(&ax25_rt->callsign);
78562 -               len += sprintf(buffer + len, "%-9s %-4s",
78563 +
78564 +               seq_printf(seq, "%-9s %-4s",
78565                         callsign,
78566                         ax25_rt->dev ? ax25_rt->dev->name : "???");
78567  
78568                 switch (ax25_rt->ip_mode) {
78569                 case 'V':
78570 -                       len += sprintf(buffer + len, "   vc");
78571 +                       seq_puts(seq, "   vc");
78572                         break;
78573                 case 'D':
78574 -                       len += sprintf(buffer + len, "   dg");
78575 +                       seq_puts(seq, "   dg");
78576                         break;
78577                 default:
78578 -                       len += sprintf(buffer + len, "    *");
78579 +                       seq_puts(seq, "    *");
78580                         break;
78581                 }
78582  
78583                 if (ax25_rt->digipeat != NULL)
78584                         for (i = 0; i < ax25_rt->digipeat->ndigi; i++)
78585 -                               len += sprintf(buffer + len, " %s", ax2asc(&ax25_rt->digipeat->calls[i]));
78586 -
78587 -               len += sprintf(buffer + len, "\n");
78588 +                               seq_printf(seq, " %s", ax2asc(&ax25_rt->digipeat->calls[i]));
78589  
78590 -               pos = begin + len;
78591 -
78592 -               if (pos < offset) {
78593 -                       len   = 0;
78594 -                       begin = pos;
78595 -               }
78596 -
78597 -               if (pos > offset + length)
78598 -                       break;
78599 +               seq_puts(seq, "\n");
78600         }
78601 -       read_unlock(&ax25_route_lock);
78602 -
78603 -       *start = buffer + (offset - begin);
78604 -       len   -= (offset - begin);
78605 +       return 0;
78606 +}
78607  
78608 -       if (len > length)
78609 -               len = length;
78610 +static struct seq_operations ax25_rt_seqops = {
78611 +       .start = ax25_rt_seq_start,
78612 +       .next = ax25_rt_seq_next,
78613 +       .stop = ax25_rt_seq_stop,
78614 +       .show = ax25_rt_seq_show,
78615 +};
78616  
78617 -       return len;
78618 +static int ax25_rt_info_open(struct inode *inode, struct file *file)
78619 +{
78620 +       return seq_open(file, &ax25_rt_seqops);
78621  }
78622 +
78623 +struct file_operations ax25_route_fops = {
78624 +       .owner = THIS_MODULE,
78625 +       .open = ax25_rt_info_open,
78626 +       .read = seq_read,
78627 +       .llseek = seq_lseek,
78628 +       .release = seq_release,
78629 +};
78630 +
78631 +#endif
78632  
78633  /*
78634   *     Find AX.25 route
78635 diff -Nru a/net/ax25/ax25_uid.c b/net/ax25/ax25_uid.c
78636 --- a/net/ax25/ax25_uid.c       Mon Aug  5 06:20:38 2002
78637 +++ b/net/ax25/ax25_uid.c       Sun Aug 24 04:34:01 2003
78638 @@ -30,6 +30,7 @@
78639  #include <linux/interrupt.h>
78640  #include <linux/notifier.h>
78641  #include <linux/proc_fs.h>
78642 +#include <linux/seq_file.h>
78643  #include <linux/stat.h>
78644  #include <linux/netfilter.h>
78645  #include <linux/sysctl.h>
78646 @@ -141,39 +142,73 @@
78647         return -EINVAL; /*NOTREACHED */
78648  }
78649  
78650 -int ax25_uid_get_info(char *buffer, char **start, off_t offset, int length)
78651 +#ifdef CONFIG_PROC_FS
78652 +
78653 +#define AX25_PROC_START        ((void *)1)
78654 +
78655 +static void *ax25_uid_seq_start(struct seq_file *seq, loff_t *pos)
78656  {
78657 -       ax25_uid_assoc *pt;
78658 -       int len     = 0;
78659 -       off_t pos   = 0;
78660 -       off_t begin = 0;
78661 +       struct ax25_uid_assoc *pt;
78662 +       int i = 1;
78663  
78664         read_lock(&ax25_uid_lock);
78665 -       len += sprintf(buffer, "Policy: %d\n", ax25_uid_policy);
78666 +       if (*pos == 0)
78667 +               return AX25_PROC_START;
78668  
78669         for (pt = ax25_uid_list; pt != NULL; pt = pt->next) {
78670 -               len += sprintf(buffer + len, "%6d %s\n", pt->uid, ax2asc(&pt->call));
78671 -
78672 -               pos = begin + len;
78673 +               if (i == *pos)
78674 +                       return pt;
78675 +               ++i;
78676 +       }
78677 +       return NULL;
78678 +}
78679  
78680 -               if (pos < offset) {
78681 -                       len = 0;
78682 -                       begin = pos;
78683 -               }
78684 +static void *ax25_uid_seq_next(struct seq_file *seq, void *v, loff_t *pos)
78685 +{
78686 +       ++*pos;
78687 +       return (v == AX25_PROC_START) ? ax25_uid_list : 
78688 +               ((struct ax25_uid_assoc *) v)->next;
78689 +}
78690  
78691 -               if (pos > offset + length)
78692 -                       break;
78693 -       }
78694 +static void ax25_uid_seq_stop(struct seq_file *seq, void *v)
78695 +{
78696         read_unlock(&ax25_uid_lock);
78697 +}
78698 +
78699 +static int ax25_uid_seq_show(struct seq_file *seq, void *v)
78700 +{
78701 +       if (v == AX25_PROC_START)
78702 +               seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
78703 +       else {
78704 +               struct ax25_uid_assoc *pt = v;
78705 +               
78706  
78707 -       *start = buffer + (offset - begin);
78708 -       len   -= offset - begin;
78709 +               seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(&pt->call));
78710 +       }
78711 +       return 0;
78712 +}
78713  
78714 -       if (len > length)
78715 -               len = length;
78716 +static struct seq_operations ax25_uid_seqops = {
78717 +       .start = ax25_uid_seq_start,
78718 +       .next = ax25_uid_seq_next,
78719 +       .stop = ax25_uid_seq_stop,
78720 +       .show = ax25_uid_seq_show,
78721 +};
78722  
78723 -       return len;
78724 +static int ax25_uid_info_open(struct inode *inode, struct file *file)
78725 +{
78726 +       return seq_open(file, &ax25_uid_seqops);
78727  }
78728 +
78729 +struct file_operations ax25_uid_fops = {
78730 +       .owner = THIS_MODULE,
78731 +       .open = ax25_uid_info_open,
78732 +       .read = seq_read,
78733 +       .llseek = seq_lseek,
78734 +       .release = seq_release,
78735 +};
78736 +
78737 +#endif
78738  
78739  /*
78740   *     Free all memory associated with UID/Callsign structures.
78741 diff -Nru a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
78742 --- a/net/bluetooth/af_bluetooth.c      Wed Jun 18 13:59:01 2003
78743 +++ b/net/bluetooth/af_bluetooth.c      Sat Aug 30 19:30:42 2003
78744 @@ -130,6 +130,7 @@
78745         }
78746  
78747         sock_init_data(sock, sk);
78748 +       sk_set_owner(sk, THIS_MODULE);
78749         INIT_LIST_HEAD(&bt_sk(sk)->accept_q);
78750         
78751         sk->sk_zapped   = 0;
78752 diff -Nru a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
78753 --- a/net/bluetooth/bnep/core.c Wed Jun  4 17:57:08 2003
78754 +++ b/net/bluetooth/bnep/core.c Tue Sep  2 06:40:45 2003
78755 @@ -711,3 +711,4 @@
78756  MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION);
78757  MODULE_AUTHOR("David Libault <david.libault@inventel.fr>, Maxim Krasnyanskiy <maxk@qualcomm.com>");
78758  MODULE_LICENSE("GPL");
78759 +MODULE_ALIAS_NETPROTO(PF_BLUETOOTH);
78760 diff -Nru a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
78761 --- a/net/bluetooth/l2cap.c     Mon Jun 16 08:11:36 2003
78762 +++ b/net/bluetooth/l2cap.c     Sun Aug 31 16:14:24 2003
78763 @@ -200,7 +200,7 @@
78764   */
78765  static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src)
78766  {
78767 -       struct sock *sk, *sk1 = NULL;
78768 +       struct sock *sk = NULL, *sk1 = NULL;
78769         struct hlist_node *node;
78770  
78771         sk_for_each(sk, node, &l2cap_sk_list.head) {
78772 diff -Nru a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
78773 --- a/net/bluetooth/rfcomm/sock.c       Fri Jul  4 23:52:58 2003
78774 +++ b/net/bluetooth/rfcomm/sock.c       Sun Aug 31 16:14:24 2003
78775 @@ -114,7 +114,7 @@
78776  /* ---- Socket functions ---- */
78777  static struct sock *__rfcomm_get_sock_by_addr(u8 channel, bdaddr_t *src)
78778  {
78779 -       struct sock *sk;
78780 +       struct sock *sk = NULL;
78781         struct hlist_node *node;
78782  
78783         sk_for_each(sk, node, &rfcomm_sk_list.head) {
78784 @@ -131,7 +131,7 @@
78785   */
78786  static struct sock *__rfcomm_get_sock_by_channel(int state, u8 channel, bdaddr_t *src)
78787  {
78788 -       struct sock *sk, *sk1 = NULL;
78789 +       struct sock *sk = NULL, *sk1 = NULL;
78790         struct hlist_node *node;
78791  
78792         sk_for_each(sk, node, &rfcomm_sk_list.head) {
78793 diff -Nru a/net/bridge/Makefile b/net/bridge/Makefile
78794 --- a/net/bridge/Makefile       Sun Aug  3 15:08:32 2003
78795 +++ b/net/bridge/Makefile       Mon Sep  1 01:44:26 2003
78796 @@ -8,9 +8,6 @@
78797                         br_ioctl.o br_notify.o br_stp.o br_stp_bpdu.o \
78798                         br_stp_if.o br_stp_timer.o
78799  
78800 -# br_netfilter only deals with IPv4 and ARP filtering, both are INET protocols
78801 -ifeq ($(CONFIG_INET),y)
78802 -bridge-$(CONFIG_NETFILTER)     += br_netfilter.o
78803 -endif
78804 +bridge-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.o
78805  
78806  obj-$(CONFIG_BRIDGE_NF_EBTABLES) += netfilter/
78807 diff -Nru a/net/bridge/br_forward.c b/net/bridge/br_forward.c
78808 --- a/net/bridge/br_forward.c   Sun May 25 20:10:58 2003
78809 +++ b/net/bridge/br_forward.c   Mon Sep  1 01:44:26 2003
78810 @@ -33,7 +33,7 @@
78811  
78812  int br_dev_queue_push_xmit(struct sk_buff *skb)
78813  {
78814 -#ifdef CONFIG_NETFILTER
78815 +#ifdef CONFIG_BRIDGE_NETFILTER
78816         /* ip_refrag calls ip_fragment, which doesn't copy the MAC header. */
78817         if (skb->nf_bridge)
78818                 memcpy(skb->data - 16, skb->nf_bridge->hh, 16);
78819 diff -Nru a/net/bridge/netfilter/Kconfig b/net/bridge/netfilter/Kconfig
78820 --- a/net/bridge/netfilter/Kconfig      Thu Jul 17 23:40:19 2003
78821 +++ b/net/bridge/netfilter/Kconfig      Sat Aug 30 20:40:35 2003
78822 @@ -1,9 +1,30 @@
78823  #
78824  # Bridge netfilter configuration
78825  #
78826 +
78827 +menu "Bridge: Netfilter Configuration"
78828 +       depends on BRIDGE && NETFILTER
78829 +
78830  config BRIDGE_NF_EBTABLES
78831 -       tristate "Bridge: ebtables"
78832 -       depends on NETFILTER && BRIDGE
78833 +       tristate "Ethernet Bridge tables (ebtables) support"
78834 +       help
78835 +         ebtables is a general, extensible frame/packet identification
78836 +         framework. Say 'Y' or 'M' here if you want to do Ethernet
78837 +         filtering/NAT/brouting on the Ethernet bridge.
78838 +#
78839 +# tables
78840 +#
78841 +config BRIDGE_EBT_BROUTE
78842 +       tristate "ebt: broute table support"
78843 +       depends on BRIDGE_NF_EBTABLES
78844 +       help
78845 +         The ebtables broute table is used to define rules that decide between
78846 +         bridging and routing frames, giving Linux the functionality of a
78847 +         brouter. See the man page for ebtables(8) and examples on the ebtables
78848 +         website.
78849 +
78850 +         If you want to compile it as a module, say M here and read
78851 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
78852  
78853  config BRIDGE_EBT_T_FILTER
78854         tristate "ebt: filter table support"
78855 @@ -26,35 +47,14 @@
78856  
78857           If you want to compile it as a module, say M here and read
78858           <file:Documentation/modules.txt>.  If unsure, say `N'.
78859 -
78860 -config BRIDGE_EBT_BROUTE
78861 -       tristate "ebt: broute table support"
78862 +#
78863 +# matches
78864 +#
78865 +config BRIDGE_EBT_802_3
78866 +       tristate "ebt: 802.3 filter support"
78867         depends on BRIDGE_NF_EBTABLES
78868         help
78869 -         The ebtables broute table is used to define rules that decide between
78870 -         bridging and routing frames, giving Linux the functionality of a
78871 -         brouter. See the man page for ebtables(8) and examples on the ebtables
78872 -         website.
78873 -
78874 -         If you want to compile it as a module, say M here and read
78875 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
78876 -
78877 -config BRIDGE_EBT_LOG
78878 -       tristate "ebt: log support"
78879 -       depends on BRIDGE_NF_EBTABLES
78880 -       help
78881 -         This option adds the log target, that you can use in any rule in
78882 -         any ebtables table. It records the frame header to the syslog.
78883 -
78884 -         If you want to compile it as a module, say M here and read
78885 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
78886 -
78887 -config BRIDGE_EBT_IP
78888 -       tristate "ebt: IP filter support"
78889 -       depends on BRIDGE_NF_EBTABLES
78890 -       help
78891 -         This option adds the IP match, which allows basic IP header field
78892 -         filtering.
78893 +         This option adds matching support for 802.3 Ethernet frames.
78894  
78895           If you want to compile it as a module, say M here and read
78896           <file:Documentation/modules.txt>.  If unsure, say `N'.
78897 @@ -69,12 +69,12 @@
78898           If you want to compile it as a module, say M here and read
78899           <file:Documentation/modules.txt>.  If unsure, say `N'.
78900  
78901 -config BRIDGE_EBT_VLAN
78902 -       tristate "ebt: 802.1Q VLAN filter support"
78903 +config BRIDGE_EBT_IP
78904 +       tristate "ebt: IP filter support"
78905         depends on BRIDGE_NF_EBTABLES
78906         help
78907 -         This option adds the 802.1Q vlan match, which allows the filtering of
78908 -         802.1Q vlan fields.
78909 +         This option adds the IP match, which allows basic IP header field
78910 +         filtering.
78911  
78912           If you want to compile it as a module, say M here and read
78913           <file:Documentation/modules.txt>.  If unsure, say `N'.
78914 @@ -113,12 +113,24 @@
78915           If you want to compile it as a module, say M here and read
78916           <file:Documentation/modules.txt>.  If unsure, say `N'.
78917  
78918 -config BRIDGE_EBT_SNAT
78919 -       tristate "ebt: snat target support"
78920 +config BRIDGE_EBT_VLAN
78921 +       tristate "ebt: 802.1Q VLAN filter support"
78922         depends on BRIDGE_NF_EBTABLES
78923         help
78924 -         This option adds the MAC SNAT target, which allows altering the MAC
78925 -         source address of frames.
78926 +         This option adds the 802.1Q vlan match, which allows the filtering of
78927 +         802.1Q vlan fields.
78928 +
78929 +         If you want to compile it as a module, say M here and read
78930 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
78931 +#
78932 +# targets
78933 +#
78934 +config BRIDGE_EBT_ARPREPLY
78935 +       tristate "ebt: arp reply target support"
78936 +       depends on BRIDGE_NF_EBTABLES
78937 +       help
78938 +         This option adds the arp reply target, which allows
78939 +         automatically sending arp replies to arp requests.
78940  
78941           If you want to compile it as a module, say M here and read
78942           <file:Documentation/modules.txt>.  If unsure, say `N'.
78943 @@ -133,6 +145,18 @@
78944           If you want to compile it as a module, say M here and read
78945           <file:Documentation/modules.txt>.  If unsure, say `N'.
78946  
78947 +config BRIDGE_EBT_MARK_T
78948 +       tristate "ebt: mark target support"
78949 +       depends on BRIDGE_NF_EBTABLES
78950 +       help
78951 +         This option adds the mark target, which allows marking frames by
78952 +         setting the 'nfmark' value in the frame.
78953 +         This value is the same as the one used in the iptables mark match and
78954 +         target.
78955 +
78956 +         If you want to compile it as a module, say M here and read
78957 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
78958 +
78959  config BRIDGE_EBT_REDIRECT
78960         tristate "ebt: redirect target support"
78961         depends on BRIDGE_NF_EBTABLES
78962 @@ -143,15 +167,26 @@
78963           If you want to compile it as a module, say M here and read
78964           <file:Documentation/modules.txt>.  If unsure, say `N'.
78965  
78966 -config BRIDGE_EBT_MARK_T
78967 -       tristate "ebt: mark target support"
78968 +config BRIDGE_EBT_SNAT
78969 +       tristate "ebt: snat target support"
78970         depends on BRIDGE_NF_EBTABLES
78971         help
78972 -         This option adds the mark target, which allows marking frames by
78973 -         setting the 'nfmark' value in the frame.
78974 -         This value is the same as the one used in the iptables mark match and
78975 -         target.
78976 +         This option adds the MAC SNAT target, which allows altering the MAC
78977 +         source address of frames.
78978 +
78979 +         If you want to compile it as a module, say M here and read
78980 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
78981 +#
78982 +# watchers
78983 +#
78984 +config BRIDGE_EBT_LOG
78985 +       tristate "ebt: log support"
78986 +       depends on BRIDGE_NF_EBTABLES
78987 +       help
78988 +         This option adds the log target, that you can use in any rule in
78989 +         any ebtables table. It records the frame header to the syslog.
78990  
78991           If you want to compile it as a module, say M here and read
78992           <file:Documentation/modules.txt>.  If unsure, say `N'.
78993  
78994 +endmenu
78995 diff -Nru a/net/bridge/netfilter/Makefile b/net/bridge/netfilter/Makefile
78996 --- a/net/bridge/netfilter/Makefile     Thu Jul 17 23:40:19 2003
78997 +++ b/net/bridge/netfilter/Makefile     Sat Aug 30 20:40:35 2003
78998 @@ -3,17 +3,27 @@
78999  #
79000  
79001  obj-$(CONFIG_BRIDGE_NF_EBTABLES) += ebtables.o
79002 +
79003 +# tables
79004 +obj-$(CONFIG_BRIDGE_EBT_BROUTE) += ebtable_broute.o
79005  obj-$(CONFIG_BRIDGE_EBT_T_FILTER) += ebtable_filter.o
79006  obj-$(CONFIG_BRIDGE_EBT_T_NAT) += ebtable_nat.o
79007 -obj-$(CONFIG_BRIDGE_EBT_BROUTE) += ebtable_broute.o
79008 -obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o
79009 +
79010 +#matches
79011 +obj-$(CONFIG_BRIDGE_EBT_802_3) += ebt_802_3.o
79012  obj-$(CONFIG_BRIDGE_EBT_ARP) += ebt_arp.o
79013 -obj-$(CONFIG_BRIDGE_EBT_VLAN) += ebt_vlan.o
79014 +obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o
79015  obj-$(CONFIG_BRIDGE_EBT_MARK) += ebt_mark_m.o
79016  obj-$(CONFIG_BRIDGE_EBT_PKTTYPE) += ebt_pkttype.o
79017  obj-$(CONFIG_BRIDGE_EBT_STP) += ebt_stp.o
79018 -obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o
79019 -obj-$(CONFIG_BRIDGE_EBT_SNAT) += ebt_snat.o
79020 +obj-$(CONFIG_BRIDGE_EBT_VLAN) += ebt_vlan.o
79021 +
79022 +# targets
79023 +obj-$(CONFIG_BRIDGE_EBT_ARPREPLY) += ebt_arpreply.o
79024 +obj-$(CONFIG_BRIDGE_EBT_MARK_T) += ebt_mark.o
79025  obj-$(CONFIG_BRIDGE_EBT_DNAT) += ebt_dnat.o
79026  obj-$(CONFIG_BRIDGE_EBT_REDIRECT) += ebt_redirect.o
79027 -obj-$(CONFIG_BRIDGE_EBT_MARK_T) += ebt_mark.o
79028 +obj-$(CONFIG_BRIDGE_EBT_SNAT) += ebt_snat.o
79029 +
79030 +# watchers
79031 +obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o
79032 diff -Nru a/net/bridge/netfilter/ebt_802_3.c b/net/bridge/netfilter/ebt_802_3.c
79033 --- /dev/null   Wed Dec 31 16:00:00 1969
79034 +++ b/net/bridge/netfilter/ebt_802_3.c  Sat Aug 30 20:40:29 2003
79035 @@ -0,0 +1,73 @@
79036 +/*
79037 + * 802_3
79038 + *
79039 + * Author:
79040 + * Chris Vitale csv@bluetail.com
79041 + *
79042 + * May 2003
79043 + * 
79044 + */
79045 +
79046 +#include <linux/netfilter_bridge/ebtables.h>
79047 +#include <linux/netfilter_bridge/ebt_802_3.h>
79048 +#include <linux/module.h>
79049 +
79050 +static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *in,
79051 +   const struct net_device *out, const void *data, unsigned int datalen)
79052 +{
79053 +       struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
79054 +       struct ebt_802_3_hdr *hdr = (struct ebt_802_3_hdr *)skb->mac.ethernet;
79055 +       uint16_t type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
79056 +
79057 +       if (info->bitmask & EBT_802_3_SAP) {
79058 +               if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP)) 
79059 +                               return EBT_NOMATCH;
79060 +               if (FWINV(info->sap != hdr->llc.ui.dsap, EBT_802_3_SAP))
79061 +                               return EBT_NOMATCH;
79062 +       }
79063 +
79064 +       if (info->bitmask & EBT_802_3_TYPE) {
79065 +               if (!(hdr->llc.ui.dsap == CHECK_TYPE && hdr->llc.ui.ssap == CHECK_TYPE))
79066 +                       return EBT_NOMATCH;
79067 +               if (FWINV(info->type != type, EBT_802_3_TYPE)) 
79068 +                       return EBT_NOMATCH;
79069 +       }
79070 +
79071 +       return EBT_MATCH;
79072 +}
79073 +
79074 +static struct ebt_match filter_802_3;
79075 +static int ebt_802_3_check(const char *tablename, unsigned int hookmask,
79076 +   const struct ebt_entry *e, void *data, unsigned int datalen)
79077 +{
79078 +       struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
79079 +
79080 +       if (datalen < sizeof(struct ebt_802_3_info))
79081 +               return -EINVAL;
79082 +       if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
79083 +               return -EINVAL;
79084 +
79085 +       return 0;
79086 +}
79087 +
79088 +static struct ebt_match filter_802_3 =
79089 +{
79090 +       .name           = EBT_802_3_MATCH,
79091 +       .match          = ebt_filter_802_3,
79092 +       .check          = ebt_802_3_check,
79093 +       .me             = THIS_MODULE,
79094 +};
79095 +
79096 +static int __init init(void)
79097 +{
79098 +       return ebt_register_match(&filter_802_3);
79099 +}
79100 +
79101 +static void __exit fini(void)
79102 +{
79103 +       ebt_unregister_match(&filter_802_3);
79104 +}
79105 +
79106 +module_init(init);
79107 +module_exit(fini);
79108 +MODULE_LICENSE("GPL");
79109 diff -Nru a/net/bridge/netfilter/ebt_arpreply.c b/net/bridge/netfilter/ebt_arpreply.c
79110 --- /dev/null   Wed Dec 31 16:00:00 1969
79111 +++ b/net/bridge/netfilter/ebt_arpreply.c       Sun Aug 24 04:31:46 2003
79112 @@ -0,0 +1,89 @@
79113 +/*
79114 + *  ebt_arpreply
79115 + *
79116 + *     Authors:
79117 + *     Grzegorz Borowiak <grzes@gnu.univ.gda.pl>
79118 + *     Bart De Schuymer <bdschuym@pandora.be>
79119 + *
79120 + *  August, 2003
79121 + *
79122 + */
79123 +
79124 +#include <linux/netfilter_bridge/ebtables.h>
79125 +#include <linux/netfilter_bridge/ebt_arpreply.h>
79126 +#include <linux/if_arp.h>
79127 +#include <net/arp.h>
79128 +#include <linux/module.h>
79129 +
79130 +static int ebt_target_reply(struct sk_buff **pskb, unsigned int hooknr,
79131 +   const struct net_device *in, const struct net_device *out,
79132 +   const void *data, unsigned int datalen)
79133 +{
79134 +       struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
79135 +       u32 sip, dip;
79136 +       struct arphdr ah;
79137 +       unsigned char sha[ETH_ALEN];
79138 +       struct sk_buff *skb = *pskb;
79139 +
79140 +       if (skb_copy_bits(skb, 0, &ah, sizeof(ah)))
79141 +               return EBT_DROP;
79142 +
79143 +       if (ah.ar_op != __constant_htons(ARPOP_REQUEST) || ah.ar_hln != ETH_ALEN
79144 +           || ah.ar_pro != __constant_htons(ETH_P_IP) || ah.ar_pln != 4)
79145 +               return EBT_CONTINUE;
79146 +
79147 +       if (skb_copy_bits(skb, sizeof(ah), &sha, ETH_ALEN))
79148 +               return EBT_DROP;
79149 +
79150 +       if (skb_copy_bits(skb, sizeof(ah) + ETH_ALEN, &sip, sizeof(sip)))
79151 +               return EBT_DROP;
79152 +
79153 +       if (skb_copy_bits(skb, sizeof(ah) + 2 * ETH_ALEN + sizeof(sip),
79154 +           &dip, sizeof(dip)))
79155 +               return EBT_DROP;
79156 +
79157 +       arp_send(ARPOP_REPLY, ETH_P_ARP, sip, (struct net_device *)in,
79158 +                dip, sha, info->mac, sha);
79159 +
79160 +       return info->target;
79161 +}
79162 +
79163 +static int ebt_target_reply_check(const char *tablename, unsigned int hookmask,
79164 +   const struct ebt_entry *e, void *data, unsigned int datalen)
79165 +{
79166 +       struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
79167 +
79168 +       if (datalen != EBT_ALIGN(sizeof(struct ebt_arpreply_info)))
79169 +               return -EINVAL;
79170 +       if (BASE_CHAIN && info->target == EBT_RETURN)
79171 +               return -EINVAL;
79172 +       if (e->ethproto != __constant_htons(ETH_P_ARP) ||
79173 +           e->invflags & EBT_IPROTO)
79174 +               return -EINVAL;
79175 +       CLEAR_BASE_CHAIN_BIT;
79176 +       if (strcmp(tablename, "nat") || hookmask & ~(1 << NF_BR_PRE_ROUTING))
79177 +               return -EINVAL;
79178 +       return 0;
79179 +}
79180 +
79181 +static struct ebt_target reply_target =
79182 +{
79183 +       .name           = EBT_ARPREPLY_TARGET,
79184 +       .target         = ebt_target_reply,
79185 +       .check          = ebt_target_reply_check,
79186 +       .me             = THIS_MODULE,
79187 +};
79188 +
79189 +static int __init init(void)
79190 +{
79191 +       return ebt_register_target(&reply_target);
79192 +}
79193 +
79194 +static void __exit fini(void)
79195 +{
79196 +       ebt_unregister_target(&reply_target);
79197 +}
79198 +
79199 +module_init(init);
79200 +module_exit(fini);
79201 +MODULE_LICENSE("GPL");
79202 diff -Nru a/net/core/dev.c b/net/core/dev.c
79203 --- a/net/core/dev.c    Tue Aug 19 21:04:26 2003
79204 +++ b/net/core/dev.c    Mon Sep  1 12:14:20 2003
79205 @@ -845,11 +845,7 @@
79206          * engine, but this requires more changes in devices. */
79207  
79208         smp_mb__after_clear_bit(); /* Commit netif_running(). */
79209 -       while (test_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
79210 -               /* No hurry. */
79211 -               current->state = TASK_INTERRUPTIBLE;
79212 -               schedule_timeout(1);
79213 -       }
79214 +       netif_poll_disable(dev);
79215  
79216         /*
79217          *      Call the device specific close. This cannot fail.
79218 @@ -1210,7 +1206,7 @@
79219  int lo_cong = 100;
79220  int mod_cong = 290;
79221  
79222 -struct netif_rx_stats netdev_rx_stat[NR_CPUS];
79223 +DEFINE_PER_CPU(struct netif_rx_stats, netdev_rx_stat) = { 0, };
79224  
79225  
79226  #ifdef CONFIG_NET_HW_FLOWCONTROL
79227 @@ -1359,7 +1355,7 @@
79228         this_cpu = smp_processor_id();
79229         queue = &__get_cpu_var(softnet_data);
79230  
79231 -       netdev_rx_stat[this_cpu].total++;
79232 +       __get_cpu_var(netdev_rx_stat).total++;
79233         if (queue->input_pkt_queue.qlen <= netdev_max_backlog) {
79234                 if (queue->input_pkt_queue.qlen) {
79235                         if (queue->throttle)
79236 @@ -1389,14 +1385,14 @@
79237  
79238         if (!queue->throttle) {
79239                 queue->throttle = 1;
79240 -               netdev_rx_stat[this_cpu].throttled++;
79241 +               __get_cpu_var(netdev_rx_stat).throttled++;
79242  #ifdef CONFIG_NET_HW_FLOWCONTROL
79243                 atomic_inc(&netdev_dropping);
79244  #endif
79245         }
79246  
79247  drop:
79248 -       netdev_rx_stat[this_cpu].dropped++;
79249 +       __get_cpu_var(netdev_rx_stat).dropped++;
79250         local_irq_restore(flags);
79251  
79252         kfree_skb(skb);
79253 @@ -1537,11 +1533,11 @@
79254  
79255         skb_bond(skb);
79256  
79257 -       netdev_rx_stat[smp_processor_id()].total++;
79258 +       __get_cpu_var(netdev_rx_stat).total++;
79259  
79260  #ifdef CONFIG_NET_FASTROUTE
79261         if (skb->pkt_type == PACKET_FASTROUTE) {
79262 -               netdev_rx_stat[smp_processor_id()].fastroute_deferred_out++;
79263 +               __get_cpu_var(netdev_rx_stat).fastroute_deferred_out++;
79264                 return dev_queue_xmit(skb);
79265         }
79266  #endif
79267 @@ -1657,7 +1653,7 @@
79268  
79269         list_del(&backlog_dev->poll_list);
79270         smp_mb__before_clear_bit();
79271 -       clear_bit(__LINK_STATE_RX_SCHED, &backlog_dev->state);
79272 +       netif_poll_enable(backlog_dev);
79273  
79274         if (queue->throttle) {
79275                 queue->throttle = 0;
79276 @@ -1672,7 +1668,6 @@
79277  
79278  static void net_rx_action(struct softirq_action *h)
79279  {
79280 -       int this_cpu = smp_processor_id();
79281         struct softnet_data *queue = &__get_cpu_var(softnet_data);
79282         unsigned long start_time = jiffies;
79283         int budget = netdev_max_backlog;
79284 @@ -1711,7 +1706,7 @@
79285         return;
79286  
79287  softnet_break:
79288 -       netdev_rx_stat[this_cpu].time_squeeze++;
79289 +       __get_cpu_var(netdev_rx_stat).time_squeeze++;
79290         __raise_softirq_irqoff(NET_RX_SOFTIRQ);
79291         goto out;
79292  }
79293 @@ -1912,7 +1907,7 @@
79294  
79295         while (*pos < NR_CPUS)
79296                 if (cpu_online(*pos)) {
79297 -                       rc = &netdev_rx_stat[*pos];
79298 +                       rc = &per_cpu(netdev_rx_stat, *pos);
79299                         break;
79300                 } else
79301                         ++*pos;
79302 diff -Nru a/net/core/ethtool.c b/net/core/ethtool.c
79303 --- a/net/core/ethtool.c        Thu Aug  7 13:16:02 2003
79304 +++ b/net/core/ethtool.c        Mon Sep  1 17:25:54 2003
79305 @@ -13,6 +13,7 @@
79306  #include <linux/errno.h>
79307  #include <linux/ethtool.h>
79308  #include <linux/netdevice.h>
79309 +#include <asm/uaccess.h>
79310  
79311  /* 
79312   * Some useful ethtool_ops methods that're device independent.
79313 @@ -30,6 +31,16 @@
79314         return (dev->features & NETIF_F_IP_CSUM) != 0;
79315  }
79316  
79317 +int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
79318 +{
79319 +       if (data)
79320 +               dev->features |= NETIF_F_IP_CSUM;
79321 +       else
79322 +               dev->features &= ~NETIF_F_IP_CSUM;
79323 +
79324 +       return 0;
79325 +}
79326 +
79327  u32 ethtool_op_get_sg(struct net_device *dev)
79328  {
79329         return (dev->features & NETIF_F_SG) != 0;
79330 @@ -45,6 +56,21 @@
79331         return 0;
79332  }
79333  
79334 +u32 ethtool_op_get_tso(struct net_device *dev)
79335 +{
79336 +       return (dev->features & NETIF_F_TSO) != 0;
79337 +}
79338 +
79339 +int ethtool_op_set_tso(struct net_device *dev, u32 data)
79340 +{
79341 +       if (data)
79342 +               dev->features |= NETIF_F_TSO;
79343 +       else
79344 +               dev->features &= ~NETIF_F_TSO;
79345 +
79346 +       return 0;
79347 +}
79348 +
79349  /* Handlers for each ethtool command */
79350  
79351  static int ethtool_get_settings(struct net_device *dev, void *useraddr)
79352 @@ -454,6 +480,33 @@
79353         return dev->ethtool_ops->set_sg(dev, edata.data);
79354  }
79355  
79356 +static int ethtool_get_tso(struct net_device *dev, char *useraddr)
79357 +{
79358 +       struct ethtool_value edata = { ETHTOOL_GTSO };
79359 +
79360 +       if (!dev->ethtool_ops->get_tso)
79361 +               return -EOPNOTSUPP;
79362 +
79363 +       edata.data = dev->ethtool_ops->get_tso(dev);
79364 +
79365 +       if (copy_to_user(useraddr, &edata, sizeof(edata)))
79366 +               return -EFAULT;
79367 +       return 0;
79368 +}
79369 +
79370 +static int ethtool_set_tso(struct net_device *dev, char *useraddr)
79371 +{
79372 +       struct ethtool_value edata;
79373 +
79374 +       if (!dev->ethtool_ops->set_tso)
79375 +               return -EOPNOTSUPP;
79376 +
79377 +       if (copy_from_user(&edata, useraddr, sizeof(edata)))
79378 +               return -EFAULT;
79379 +
79380 +       return dev->ethtool_ops->set_tso(dev, edata.data);
79381 +}
79382 +
79383  static int ethtool_self_test(struct net_device *dev, char *useraddr)
79384  {
79385         struct ethtool_test test;
79386 @@ -502,15 +555,15 @@
79387  
79388         switch (gstrings.string_set) {
79389         case ETH_SS_TEST:
79390 -               if (ops->self_test_count)
79391 -                       gstrings.len = ops->self_test_count(dev);
79392 -               else
79393 +               if (!ops->self_test_count)
79394                         return -EOPNOTSUPP;
79395 +               gstrings.len = ops->self_test_count(dev);
79396 +               break;
79397         case ETH_SS_STATS:
79398 -               if (ops->get_stats_count)
79399 -                       gstrings.len = ops->get_stats_count(dev);
79400 -               else
79401 +               if (!ops->get_stats_count)
79402                         return -EOPNOTSUPP;
79403 +               gstrings.len = ops->get_stats_count(dev);
79404 +               break;
79405         default:
79406                 return -EINVAL;
79407         }
79408 @@ -653,6 +706,10 @@
79409                 return ethtool_get_sg(dev, useraddr);
79410         case ETHTOOL_SSG:
79411                 return ethtool_set_sg(dev, useraddr);
79412 +       case ETHTOOL_GTSO:
79413 +               return ethtool_get_tso(dev, useraddr);
79414 +       case ETHTOOL_STSO:
79415 +               return ethtool_set_tso(dev, useraddr);
79416         case ETHTOOL_TEST:
79417                 return ethtool_self_test(dev, useraddr);
79418         case ETHTOOL_GSTRINGS:
79419 diff -Nru a/net/core/netfilter.c b/net/core/netfilter.c
79420 --- a/net/core/netfilter.c      Wed Jul 30 16:57:26 2003
79421 +++ b/net/core/netfilter.c      Mon Sep  1 01:44:26 2003
79422 @@ -430,7 +430,7 @@
79423  {
79424         int status;
79425         struct nf_info *info;
79426 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
79427 +#ifdef CONFIG_BRIDGE_NETFILTER
79428         struct net_device *physindev = NULL;
79429         struct net_device *physoutdev = NULL;
79430  #endif
79431 @@ -467,7 +467,7 @@
79432         if (indev) dev_hold(indev);
79433         if (outdev) dev_hold(outdev);
79434  
79435 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
79436 +#ifdef CONFIG_BRIDGE_NETFILTER
79437         if (skb->nf_bridge) {
79438                 physindev = skb->nf_bridge->physindev;
79439                 if (physindev) dev_hold(physindev);
79440 @@ -483,7 +483,7 @@
79441                 /* James M doesn't say fuck enough. */
79442                 if (indev) dev_put(indev);
79443                 if (outdev) dev_put(outdev);
79444 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
79445 +#ifdef CONFIG_BRIDGE_NETFILTER
79446                 if (physindev) dev_put(physindev);
79447                 if (physoutdev) dev_put(physoutdev);
79448  #endif
79449 @@ -560,7 +560,7 @@
79450         /* Release those devices we held, or Alexey will kill me. */
79451         if (info->indev) dev_put(info->indev);
79452         if (info->outdev) dev_put(info->outdev);
79453 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
79454 +#ifdef CONFIG_BRIDGE_NETFILTER
79455         if (skb->nf_bridge) {
79456                 if (skb->nf_bridge->physindev)
79457                         dev_put(skb->nf_bridge->physindev);
79458 diff -Nru a/net/core/scm.c b/net/core/scm.c
79459 --- a/net/core/scm.c    Sun Mar 23 22:06:53 2003
79460 +++ b/net/core/scm.c    Sun Aug 24 05:14:27 2003
79461 @@ -41,7 +41,7 @@
79462  
79463  static __inline__ int scm_check_creds(struct ucred *creds)
79464  {
79465 -       if ((creds->pid == current->pid || capable(CAP_SYS_ADMIN)) &&
79466 +       if ((creds->pid == current->tgid || capable(CAP_SYS_ADMIN)) &&
79467             ((creds->uid == current->uid || creds->uid == current->euid ||
79468               creds->uid == current->suid) || capable(CAP_SETUID)) &&
79469             ((creds->gid == current->gid || creds->gid == current->egid ||
79470 diff -Nru a/net/core/skbuff.c b/net/core/skbuff.c
79471 --- a/net/core/skbuff.c Sat Aug  9 02:14:55 2003
79472 +++ b/net/core/skbuff.c Mon Sep  1 01:44:26 2003
79473 @@ -236,7 +236,7 @@
79474         }
79475  #ifdef CONFIG_NETFILTER
79476         nf_conntrack_put(skb->nfct);
79477 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
79478 +#ifdef CONFIG_BRIDGE_NETFILTER
79479         nf_bridge_put(skb->nf_bridge);
79480  #endif
79481  #endif
79482 @@ -301,7 +301,7 @@
79483  #ifdef CONFIG_NETFILTER_DEBUG
79484         C(nf_debug);
79485  #endif
79486 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
79487 +#ifdef CONFIG_BRIDGE_NETFILTER
79488         C(nf_bridge);
79489         nf_bridge_get(skb->nf_bridge);
79490  #endif
79491 @@ -359,7 +359,7 @@
79492  #ifdef CONFIG_NETFILTER_DEBUG
79493         new->nf_debug   = old->nf_debug;
79494  #endif
79495 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
79496 +#ifdef CONFIG_BRIDGE_NETFILTER
79497         new->nf_bridge  = old->nf_bridge;
79498         nf_bridge_get(old->nf_bridge);
79499  #endif
79500 diff -Nru a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
79501 --- a/net/decnet/af_decnet.c    Tue Jul 22 23:33:06 2003
79502 +++ b/net/decnet/af_decnet.c    Tue Sep  2 04:38:10 2003
79503 @@ -2349,6 +2349,7 @@
79504  MODULE_DESCRIPTION("The Linux DECnet Network Protocol");
79505  MODULE_AUTHOR("Linux DECnet Project Team");
79506  MODULE_LICENSE("GPL");
79507 +MODULE_ALIAS_NETPROTO(PF_DECnet);
79508  
79509  static char banner[] __initdata = KERN_INFO "NET4: DECnet for Linux: V.2.5.68s (C) 1995-2003 Linux DECnet Project Team\n";
79510  
79511 diff -Nru a/net/econet/af_econet.c b/net/econet/af_econet.c
79512 --- a/net/econet/af_econet.c    Wed Jun 18 13:59:01 2003
79513 +++ b/net/econet/af_econet.c    Tue Sep  2 04:38:10 2003
79514 @@ -562,6 +562,7 @@
79515         sk->sk_reuse = 1;
79516         sock->ops = &econet_ops;
79517         sock_init_data(sock,sk);
79518 +       sk_set_owner(sk, THIS_MODULE);
79519  
79520         eo = ec_sk(sk) = kmalloc(sizeof(*eo), GFP_KERNEL);
79521         if (!eo)
79522 @@ -1115,3 +1116,4 @@
79523  module_exit(econet_proto_exit);
79524  
79525  MODULE_LICENSE("GPL");
79526 +MODULE_ALIAS_NETPROTO(PF_ECONET);
79527 diff -Nru a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
79528 --- a/net/ipv4/af_inet.c        Sun Jul 27 16:03:33 2003
79529 +++ b/net/ipv4/af_inet.c        Tue Sep  2 04:38:10 2003
79530 @@ -1248,3 +1248,4 @@
79531         return 0;
79532  }
79533  #endif /* CONFIG_PROC_FS */
79534 +MODULE_ALIAS_NETPROTO(PF_INET);
79535 diff -Nru a/net/ipv4/icmp.c b/net/ipv4/icmp.c
79536 --- a/net/ipv4/icmp.c   Fri Jun 27 09:43:50 2003
79537 +++ b/net/ipv4/icmp.c   Tue Sep  2 14:34:13 2003
79538 @@ -230,12 +230,18 @@
79539  static DEFINE_PER_CPU(struct socket *, __icmp_socket) = NULL;
79540  #define icmp_socket    __get_cpu_var(__icmp_socket)
79541  
79542 -static __inline__ void icmp_xmit_lock(void)
79543 +static __inline__ int icmp_xmit_lock(void)
79544  {
79545         local_bh_disable();
79546  
79547 -       if (unlikely(!spin_trylock(&icmp_socket->sk->sk_lock.slock)))
79548 -               BUG();
79549 +       if (unlikely(!spin_trylock(&icmp_socket->sk->sk_lock.slock))) {
79550 +               /* This can happen if the output path signals a
79551 +                * dst_link_failure() for an outgoing ICMP packet.
79552 +                */
79553 +               local_bh_enable();
79554 +               return 1;
79555 +       }
79556 +       return 0;
79557  }
79558  
79559  static void icmp_xmit_unlock(void)
79560 @@ -376,7 +382,8 @@
79561         if (ip_options_echo(&icmp_param->replyopts, skb))
79562                 goto out;
79563  
79564 -       icmp_xmit_lock();
79565 +       if (icmp_xmit_lock())
79566 +               return;
79567  
79568         icmp_param->data.icmph.checksum = 0;
79569         icmp_out_count(icmp_param->data.icmph.type);
79570 @@ -488,7 +495,8 @@
79571                 }
79572         }
79573  
79574 -       icmp_xmit_lock();
79575 +       if (icmp_xmit_lock())
79576 +               return;
79577  
79578         /*
79579          *      Construct source address and options.
79580 diff -Nru a/net/ipv4/igmp.c b/net/ipv4/igmp.c
79581 --- a/net/ipv4/igmp.c   Wed Aug 20 10:42:42 2003
79582 +++ b/net/ipv4/igmp.c   Wed Aug 27 23:45:13 2003
79583 @@ -2122,6 +2122,7 @@
79584                         break;
79585                 }
79586                 read_unlock(&in_dev->lock);
79587 +               in_dev_put(in_dev);
79588         }
79589         return im;
79590  }
79591 @@ -2181,7 +2182,9 @@
79592         if (likely(state->in_dev != NULL)) {
79593                 read_unlock(&state->in_dev->lock);
79594                 in_dev_put(state->in_dev);
79595 +               state->in_dev = NULL;
79596         }
79597 +       state->dev = NULL;
79598         read_unlock(&dev_base_lock);
79599  }
79600  
79601 @@ -2284,6 +2287,7 @@
79602                         spin_unlock_bh(&im->lock);
79603                 }
79604                 read_unlock_bh(&idev->lock);
79605 +               in_dev_put(idev);
79606         }
79607         return psf;
79608  }
79609 @@ -2350,12 +2354,16 @@
79610  static void igmp_mcf_seq_stop(struct seq_file *seq, void *v)
79611  {
79612         struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
79613 -       if (likely(state->im != NULL))
79614 +       if (likely(state->im != NULL)) {
79615                 spin_unlock_bh(&state->im->lock);
79616 +               state->im = NULL;
79617 +       }
79618         if (likely(state->idev != NULL)) {
79619                 read_unlock_bh(&state->idev->lock);
79620                 in_dev_put(state->idev);
79621 +               state->idev = NULL;
79622         }
79623 +       state->dev = NULL;
79624         read_unlock(&dev_base_lock);
79625  }
79626  
79627 diff -Nru a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
79628 --- a/net/ipv4/ip_output.c      Fri Jul 25 13:42:43 2003
79629 +++ b/net/ipv4/ip_output.c      Mon Sep  1 01:44:26 2003
79630 @@ -414,7 +414,7 @@
79631         /* Connection association is same as pre-frag packet */
79632         to->nfct = from->nfct;
79633         nf_conntrack_get(to->nfct);
79634 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
79635 +#ifdef CONFIG_BRIDGE_NETFILTER
79636         to->nf_bridge = from->nf_bridge;
79637         nf_bridge_get(to->nf_bridge);
79638  #endif
79639 diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
79640 --- a/net/ipv4/ipvs/ip_vs_conn.c        Mon Jul 21 02:35:25 2003
79641 +++ b/net/ipv4/ipvs/ip_vs_conn.c        Thu Aug 28 01:21:50 2003
79642 @@ -837,7 +837,7 @@
79643                    "(size=%d, memory=%ldKbytes)\n",
79644                    IP_VS_CONN_TAB_SIZE,
79645                    (long)(IP_VS_CONN_TAB_SIZE*sizeof(struct list_head))/1024);
79646 -       IP_VS_DBG(0, "Each connection entry needs %d bytes at least\n",
79647 +       IP_VS_DBG(0, "Each connection entry needs %Zd bytes at least\n",
79648                   sizeof(struct ip_vs_conn));
79649  
79650         for (idx = 0; idx < IP_VS_CONN_TAB_SIZE; idx++) {
79651 diff -Nru a/net/ipv4/ipvs/ip_vs_dh.c b/net/ipv4/ipvs/ip_vs_dh.c
79652 --- a/net/ipv4/ipvs/ip_vs_dh.c  Sat Jul 12 22:20:28 2003
79653 +++ b/net/ipv4/ipvs/ip_vs_dh.c  Thu Aug 28 01:21:50 2003
79654 @@ -147,7 +147,7 @@
79655                 return -ENOMEM;
79656         }
79657         svc->sched_data = tbl;
79658 -       IP_VS_DBG(6, "DH hash table (memory=%dbytes) allocated for "
79659 +       IP_VS_DBG(6, "DH hash table (memory=%Zdbytes) allocated for "
79660                   "current service\n",
79661                   sizeof(struct ip_vs_dh_bucket)*IP_VS_DH_TAB_SIZE);
79662  
79663 @@ -167,7 +167,7 @@
79664  
79665         /* release the table itself */
79666         kfree(svc->sched_data);
79667 -       IP_VS_DBG(6, "DH hash table (memory=%dbytes) released\n",
79668 +       IP_VS_DBG(6, "DH hash table (memory=%Zdbytes) released\n",
79669                   sizeof(struct ip_vs_dh_bucket)*IP_VS_DH_TAB_SIZE);
79670  
79671         return 0;
79672 diff -Nru a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
79673 --- a/net/ipv4/ipvs/ip_vs_lblc.c        Sat Jul 12 22:20:28 2003
79674 +++ b/net/ipv4/ipvs/ip_vs_lblc.c        Thu Aug 28 01:21:50 2003
79675 @@ -396,7 +396,7 @@
79676                 return -ENOMEM;
79677         }
79678         svc->sched_data = tbl;
79679 -       IP_VS_DBG(6, "LBLC hash table (memory=%dbytes) allocated for "
79680 +       IP_VS_DBG(6, "LBLC hash table (memory=%Zdbytes) allocated for "
79681                   "current service\n",
79682                   sizeof(struct ip_vs_lblc_table));
79683  
79684 @@ -436,7 +436,7 @@
79685  
79686         /* release the table itself */
79687         kfree(svc->sched_data);
79688 -       IP_VS_DBG(6, "LBLC hash table (memory=%dbytes) released\n",
79689 +       IP_VS_DBG(6, "LBLC hash table (memory=%Zdbytes) released\n",
79690                   sizeof(struct ip_vs_lblc_table));
79691  
79692         return 0;
79693 diff -Nru a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
79694 --- a/net/ipv4/ipvs/ip_vs_lblcr.c       Sat Jul 12 22:20:28 2003
79695 +++ b/net/ipv4/ipvs/ip_vs_lblcr.c       Thu Aug 28 01:21:50 2003
79696 @@ -649,7 +649,7 @@
79697                 return -ENOMEM;
79698         }
79699         svc->sched_data = tbl;
79700 -       IP_VS_DBG(6, "LBLCR hash table (memory=%dbytes) allocated for "
79701 +       IP_VS_DBG(6, "LBLCR hash table (memory=%Zdbytes) allocated for "
79702                   "current service\n",
79703                   sizeof(struct ip_vs_lblcr_table));
79704  
79705 @@ -692,7 +692,7 @@
79706  
79707         /* release the table itself */
79708         kfree(svc->sched_data);
79709 -       IP_VS_DBG(6, "LBLCR hash table (memory=%dbytes) released\n",
79710 +       IP_VS_DBG(6, "LBLCR hash table (memory=%Zdbytes) released\n",
79711                   sizeof(struct ip_vs_lblcr_table));
79712  
79713         return 0;
79714 diff -Nru a/net/ipv4/ipvs/ip_vs_sh.c b/net/ipv4/ipvs/ip_vs_sh.c
79715 --- a/net/ipv4/ipvs/ip_vs_sh.c  Sat Jul 12 22:20:28 2003
79716 +++ b/net/ipv4/ipvs/ip_vs_sh.c  Thu Aug 28 01:21:50 2003
79717 @@ -144,7 +144,7 @@
79718                 return -ENOMEM;
79719         }
79720         svc->sched_data = tbl;
79721 -       IP_VS_DBG(6, "SH hash table (memory=%dbytes) allocated for "
79722 +       IP_VS_DBG(6, "SH hash table (memory=%Zdbytes) allocated for "
79723                   "current service\n",
79724                   sizeof(struct ip_vs_sh_bucket)*IP_VS_SH_TAB_SIZE);
79725  
79726 @@ -164,7 +164,7 @@
79727  
79728         /* release the table itself */
79729         kfree(svc->sched_data);
79730 -       IP_VS_DBG(6, "SH hash table (memory=%dbytes) released\n",
79731 +       IP_VS_DBG(6, "SH hash table (memory=%Zdbytes) released\n",
79732                   sizeof(struct ip_vs_sh_bucket)*IP_VS_SH_TAB_SIZE);
79733  
79734         return 0;
79735 diff -Nru a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
79736 --- a/net/ipv4/ipvs/ip_vs_sync.c        Sat Jul 12 22:20:28 2003
79737 +++ b/net/ipv4/ipvs/ip_vs_sync.c        Thu Aug 28 01:21:50 2003
79738 @@ -851,7 +851,7 @@
79739                 return -EEXIST;
79740  
79741         IP_VS_DBG(7, "%s: pid %d\n", __FUNCTION__, current->pid);
79742 -       IP_VS_DBG(7, "Each ip_vs_sync_conn entry need %d bytes\n",
79743 +       IP_VS_DBG(7, "Each ip_vs_sync_conn entry need %Zd bytes\n",
79744                   sizeof(struct ip_vs_sync_conn));
79745  
79746         ip_vs_sync_state |= state;
79747 diff -Nru a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
79748 --- a/net/ipv4/netfilter/Kconfig        Wed Jun 25 23:28:43 2003
79749 +++ b/net/ipv4/netfilter/Kconfig        Mon Sep  1 01:44:26 2003
79750 @@ -74,8 +74,7 @@
79751           <file:Documentation/modules.txt>.  If unsure, say `Y'.
79752  
79753  config IP_NF_QUEUE
79754 -       tristate "Userspace queueing via NETLINK (EXPERIMENTAL)"
79755 -       depends on EXPERIMENTAL
79756 +       tristate "Userspace queueing via NETLINK"
79757         help
79758           Netfilter has the ability to queue packets to user space: the
79759           netlink device can be used to access them using this driver.
79760 @@ -106,6 +105,16 @@
79761           If you want to compile it as a module, say M here and read
79762           <file:Documentation/modules.txt>.  If unsure, say `N'.
79763  
79764 +config IP_NF_MATCH_IPRANGE
79765 +       tristate "IP range match support"
79766 +       depends on IP_NF_IPTABLES
79767 +       help
79768 +         This option makes possible to match IP addresses against IP address
79769 +         ranges.
79770 +
79771 +         If you want to compile it as a module, say M here and read
79772 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
79773 +
79774  config IP_NF_MATCH_MAC
79775         tristate "MAC address match support"
79776         depends on IP_NF_IPTABLES
79777 @@ -239,7 +248,7 @@
79778  
79779  config IP_NF_MATCH_HELPER
79780         tristate "Helper match support"
79781 -       depends on IP_NF_CONNTRACK!=n && IP_NF_IPTABLES
79782 +       depends on IP_NF_CONNTRACK && IP_NF_IPTABLES
79783         help
79784           Helper matching allows you to match packets in dynamic connections
79785           tracked by a conntrack-helper, ie. ip_conntrack_ftp
79786 @@ -271,19 +280,9 @@
79787           If you want to compile it as a module, say M here and read
79788           Documentation/modules.txt.  If unsure, say `N'.
79789  
79790 -config IP_NF_MATCH_UNCLEAN
79791 -       tristate "Unclean match support (EXPERIMENTAL)"
79792 -       depends on EXPERIMENTAL && IP_NF_IPTABLES
79793 -       help
79794 -         Unclean packet matching matches any strange or invalid packets, by
79795 -         looking at a series of fields in the IP, TCP, UDP and ICMP headers.
79796 -
79797 -         If you want to compile it as a module, say M here and read
79798 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
79799 -
79800  config IP_NF_MATCH_OWNER
79801 -       tristate "Owner match support (EXPERIMENTAL)"
79802 -       depends on EXPERIMENTAL && IP_NF_IPTABLES
79803 +       tristate "Owner match support"
79804 +       depends on IP_NF_IPTABLES
79805         help
79806           Packet owner matching allows you to match locally-generated packets
79807           based on who created them: the user, group, process or session.
79808 @@ -293,7 +292,7 @@
79809  
79810  config IP_NF_MATCH_PHYSDEV
79811         tristate "Physdev match support"
79812 -       depends on IP_NF_IPTABLES!=n && BRIDGE!=n
79813 +       depends on IP_NF_IPTABLES!=n && BRIDGE_NETFILTER
79814         help
79815           Physdev packet matching matches against the physical bridge ports
79816           the IP packet arrived on or will leave by.
79817 @@ -324,16 +323,6 @@
79818           If you want to compile it as a module, say M here and read
79819           <file:Documentation/modules.txt>.  If unsure, say `N'.
79820  
79821 -config IP_NF_TARGET_MIRROR
79822 -       tristate "MIRROR target support (EXPERIMENTAL)"
79823 -       depends on EXPERIMENTAL && IP_NF_FILTER
79824 -       help
79825 -         The MIRROR target allows a filtering rule to specify that an
79826 -         incoming packet should be bounced back to the sender.
79827 -
79828 -         If you want to compile it as a module, say M here and read
79829 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
79830 -
79831  config IP_NF_NAT
79832         tristate "Full NAT"
79833         depends on IP_NF_IPTABLES && IP_NF_CONNTRACK
79834 @@ -375,6 +364,28 @@
79835           If you want to compile it as a module, say M here and read
79836           <file:Documentation/modules.txt>.  If unsure, say `N'.
79837  
79838 +config IP_NF_TARGET_NETMAP
79839 +       tristate "NETMAP target support"
79840 +       depends on IP_NF_NAT
79841 +       help
79842 +         NETMAP is an implementation of static 1:1 NAT mapping of network
79843 +         addresses. It maps the network address part, while keeping the host
79844 +         address part intact. It is similar to Fast NAT, except that
79845 +         Netfilter's connection tracking doesn't work well with Fast NAT.
79846 +
79847 +         If you want to compile it as a module, say M here and read
79848 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
79849 +
79850 +config IP_NF_TARGET_SAME
79851 +       tristate "SAME target support"
79852 +       depends on IP_NF_NAT
79853 +       help
79854 +         This option adds a `SAME' target, which works like the standard SNAT
79855 +         target, but attempts to give clients the same IP for all connections.
79856 +
79857 +         If you want to compile it as a module, say M here and read
79858 +         Documentation/modules.txt.  If unsure, say `N'.
79859 +
79860  config IP_NF_NAT_LOCAL
79861         bool "NAT of local connections (READ HELP)"
79862         depends on IP_NF_NAT
79863 @@ -490,6 +501,19 @@
79864           the routing method (see `Use netfilter MARK value as routing
79865           key') and can also be used by other subsystems to change their
79866           behavior.
79867 +
79868 +         If you want to compile it as a module, say M here and read
79869 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
79870 +
79871 +config IP_NF_TARGET_CLASSIFY
79872 +       tristate "CLASSIFY target support"
79873 +       depends on IP_NF_MANGLE
79874 +       help
79875 +         This option adds a `CLASSIFY' target, which enables the user to set
79876 +         the priority of a packet. Some qdiscs can use this value for
79877 +         classification, among these are:
79878 +
79879 +         atm, cbq, dsmark, pfifo_fast, htb, prio
79880  
79881           If you want to compile it as a module, say M here and read
79882           <file:Documentation/modules.txt>.  If unsure, say `N'.
79883 diff -Nru a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
79884 --- a/net/ipv4/netfilter/Makefile       Wed Jun 25 23:28:43 2003
79885 +++ b/net/ipv4/netfilter/Makefile       Sun Aug 24 17:25:23 2003
79886 @@ -44,6 +44,7 @@
79887  obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o
79888  obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o
79889  obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o
79890 +obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o
79891  
79892  obj-$(CONFIG_IP_NF_MATCH_PKTTYPE) += ipt_pkttype.o
79893  obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o
79894 @@ -61,20 +62,21 @@
79895  obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
79896  obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o
79897  obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o
79898 -obj-$(CONFIG_IP_NF_MATCH_UNCLEAN) += ipt_unclean.o
79899  obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o
79900  
79901  obj-$(CONFIG_IP_NF_MATCH_PHYSDEV) += ipt_physdev.o
79902  
79903  # targets
79904  obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
79905 -obj-$(CONFIG_IP_NF_TARGET_MIRROR) += ipt_MIRROR.o
79906  obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
79907  obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
79908  obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o
79909  obj-$(CONFIG_IP_NF_TARGET_MARK) += ipt_MARK.o
79910  obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
79911  obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
79912 +obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
79913 +obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o
79914 +obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o
79915  obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
79916  obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
79917  obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
79918 diff -Nru a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
79919 --- a/net/ipv4/netfilter/arp_tables.c   Sat Aug  2 18:29:28 2003
79920 +++ b/net/ipv4/netfilter/arp_tables.c   Sun Aug 24 05:00:28 2003
79921 @@ -25,6 +25,10 @@
79922  
79923  #include <linux/netfilter_arp/arp_tables.h>
79924  
79925 +MODULE_LICENSE("GPL");
79926 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
79927 +MODULE_DESCRIPTION("arptables core");
79928 +
79929  /*#define DEBUG_ARP_TABLES*/
79930  /*#define DEBUG_ARP_TABLES_USER*/
79931  
79932 @@ -1324,4 +1328,3 @@
79933  
79934  module_init(init);
79935  module_exit(fini);
79936 -MODULE_LICENSE("GPL");
79937 diff -Nru a/net/ipv4/netfilter/arpt_mangle.c b/net/ipv4/netfilter/arpt_mangle.c
79938 --- a/net/ipv4/netfilter/arpt_mangle.c  Wed Jun 25 23:28:48 2003
79939 +++ b/net/ipv4/netfilter/arpt_mangle.c  Sun Aug 24 05:00:28 2003
79940 @@ -3,6 +3,10 @@
79941  #include <linux/netfilter_arp/arpt_mangle.h>
79942  #include <net/sock.h>
79943  
79944 +MODULE_LICENSE("GPL");
79945 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
79946 +MODULE_DESCRIPTION("arptables mangle table");
79947 +
79948  static unsigned int
79949  target(struct sk_buff **pskb, unsigned int hooknum, const struct net_device *in,
79950     const struct net_device *out, const void *targinfo, void *userinfo)
79951 @@ -98,4 +102,3 @@
79952  
79953  module_init(init);
79954  module_exit(fini);
79955 -MODULE_LICENSE("GPL");
79956 diff -Nru a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
79957 --- a/net/ipv4/netfilter/arptable_filter.c      Thu Jun 19 12:42:06 2003
79958 +++ b/net/ipv4/netfilter/arptable_filter.c      Sun Aug 24 05:00:28 2003
79959 @@ -8,6 +8,10 @@
79960  #include <linux/module.h>
79961  #include <linux/netfilter_arp/arp_tables.h>
79962  
79963 +MODULE_LICENSE("GPL");
79964 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
79965 +MODULE_DESCRIPTION("arptables filter table");
79966 +
79967  #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \
79968                            (1 << NF_ARP_FORWARD))
79969  
79970 @@ -209,4 +213,3 @@
79971  
79972  module_init(init);
79973  module_exit(fini);
79974 -MODULE_LICENSE("GPL");
79975 diff -Nru a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
79976 --- a/net/ipv4/netfilter/ip_conntrack_core.c    Sat Aug  2 18:29:28 2003
79977 +++ b/net/ipv4/netfilter/ip_conntrack_core.c    Sat Aug 30 20:35:04 2003
79978 @@ -13,7 +13,6 @@
79979   *     - export ip_conntrack[_expect]_{find_get,put} functions
79980   * */
79981  
79982 -#include <linux/version.h>
79983  #include <linux/config.h>
79984  #include <linux/types.h>
79985  #include <linux/icmp.h>
79986 @@ -285,14 +284,15 @@
79987  static void
79988  clean_from_lists(struct ip_conntrack *ct)
79989  {
79990 +       unsigned int ho, hr;
79991 +       
79992         DEBUGP("clean_from_lists(%p)\n", ct);
79993         MUST_BE_WRITE_LOCKED(&ip_conntrack_lock);
79994 -       LIST_DELETE(&ip_conntrack_hash
79995 -                   [hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple)],
79996 -                   &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
79997 -       LIST_DELETE(&ip_conntrack_hash
79998 -                   [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)],
79999 -                   &ct->tuplehash[IP_CT_DIR_REPLY]);
80000 +
80001 +       ho = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
80002 +       hr = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
80003 +       LIST_DELETE(&ip_conntrack_hash[ho], &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
80004 +       LIST_DELETE(&ip_conntrack_hash[hr], &ct->tuplehash[IP_CT_DIR_REPLY]);
80005  
80006         /* Destroy all un-established, pending expectations */
80007         remove_expectations(ct, 1);
80008 @@ -364,9 +364,10 @@
80009                     const struct ip_conntrack *ignored_conntrack)
80010  {
80011         struct ip_conntrack_tuple_hash *h;
80012 +       unsigned int hash = hash_conntrack(tuple);
80013  
80014         MUST_BE_READ_LOCKED(&ip_conntrack_lock);
80015 -       h = LIST_FIND(&ip_conntrack_hash[hash_conntrack(tuple)],
80016 +       h = LIST_FIND(&ip_conntrack_hash[hash],
80017                       conntrack_tuple_cmp,
80018                       struct ip_conntrack_tuple_hash *,
80019                       tuple, ignored_conntrack);
80020 diff -Nru a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
80021 --- a/net/ipv4/netfilter/ip_conntrack_ftp.c     Sat Aug  2 18:29:28 2003
80022 +++ b/net/ipv4/netfilter/ip_conntrack_ftp.c     Sun Aug 24 05:00:28 2003
80023 @@ -11,6 +11,10 @@
80024  #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
80025  #include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
80026  
80027 +MODULE_LICENSE("GPL");
80028 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
80029 +MODULE_DESCRIPTION("ftp connection tracking helper");
80030 +
80031  /* This is slow, but it's simple. --RR */
80032  static char ftp_buffer[65536];
80033  
80034 @@ -439,6 +443,5 @@
80035  PROVIDES_CONNTRACK(ftp);
80036  EXPORT_SYMBOL(ip_ftp_lock);
80037  
80038 -MODULE_LICENSE("GPL");
80039  module_init(init);
80040  module_exit(fini);
80041 diff -Nru a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
80042 --- a/net/ipv4/netfilter/ip_conntrack_irc.c     Sat Aug  2 18:29:28 2003
80043 +++ b/net/ipv4/netfilter/ip_conntrack_irc.c     Sun Aug 24 05:00:28 2003
80044 @@ -41,8 +41,8 @@
80045  /* This is slow, but it's simple. --RR */
80046  static char irc_buffer[65536];
80047  
80048 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
80049 -MODULE_DESCRIPTION("IRC (DCC) connection tracking module");
80050 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
80051 +MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
80052  MODULE_LICENSE("GPL");
80053  #ifdef MODULE_PARM
80054  MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
80055 diff -Nru a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
80056 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c      Mon Apr 28 02:27:56 2003
80057 +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c      Sat Aug 30 20:35:04 2003
80058 @@ -14,7 +14,6 @@
80059  #include <linux/module.h>
80060  #include <linux/skbuff.h>
80061  #include <linux/proc_fs.h>
80062 -#include <linux/version.h>
80063  #include <net/checksum.h>
80064  
80065  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock)
80066 diff -Nru a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
80067 --- a/net/ipv4/netfilter/ip_conntrack_tftp.c    Sat Aug  2 18:29:28 2003
80068 +++ b/net/ipv4/netfilter/ip_conntrack_tftp.c    Sun Aug 24 05:00:28 2003
80069 @@ -17,7 +17,7 @@
80070  #include <linux/netfilter_ipv4/ip_conntrack_tftp.h>
80071  
80072  MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
80073 -MODULE_DESCRIPTION("Netfilter connection tracking module for tftp");
80074 +MODULE_DESCRIPTION("tftp connection tracking helper");
80075  MODULE_LICENSE("GPL");
80076  
80077  #define MAX_PORTS 8
80078 @@ -44,7 +44,7 @@
80079  
80080         if (skb_copy_bits(skb, skb->nh.iph->ihl * 4 + sizeof(struct udphdr),
80081                           &tftph, sizeof(tftph)) != 0)
80082 -               return -1;
80083 +               return NF_ACCEPT;
80084  
80085         switch (ntohs(tftph.opcode)) {
80086         /* RRQ and WRQ works the same way */
80087 diff -Nru a/net/ipv4/netfilter/ip_fw_compat_masq.c b/net/ipv4/netfilter/ip_fw_compat_masq.c
80088 --- a/net/ipv4/netfilter/ip_fw_compat_masq.c    Sun May 11 22:12:07 2003
80089 +++ b/net/ipv4/netfilter/ip_fw_compat_masq.c    Sat Aug 30 20:35:04 2003
80090 @@ -13,7 +13,6 @@
80091  #include <linux/netdevice.h>
80092  #include <linux/inetdevice.h>
80093  #include <linux/proc_fs.h>
80094 -#include <linux/version.h>
80095  #include <linux/module.h>
80096  #include <net/route.h>
80097  
80098 diff -Nru a/net/ipv4/netfilter/ip_nat_amanda.c b/net/ipv4/netfilter/ip_nat_amanda.c
80099 --- a/net/ipv4/netfilter/ip_nat_amanda.c        Tue Jun 24 15:34:39 2003
80100 +++ b/net/ipv4/netfilter/ip_nat_amanda.c        Sun Aug 24 05:00:28 2003
80101 @@ -35,7 +35,7 @@
80102  #endif
80103  
80104  MODULE_AUTHOR("Brian J. Murrell <netfilter@interlinx.bc.ca>");
80105 -MODULE_DESCRIPTION("Amanda network address translation module");
80106 +MODULE_DESCRIPTION("Amanda NAT helper");
80107  MODULE_LICENSE("GPL");
80108  
80109  /* protects amanda part of conntracks */
80110 diff -Nru a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
80111 --- a/net/ipv4/netfilter/ip_nat_core.c  Sat Aug  2 18:29:28 2003
80112 +++ b/net/ipv4/netfilter/ip_nat_core.c  Sat Aug 30 20:35:04 2003
80113 @@ -2,7 +2,6 @@
80114  
80115  /* (c) 1999 Paul `Rusty' Russell.  Licenced under the GNU General
80116     Public Licence. */
80117 -#include <linux/version.h>
80118  #include <linux/module.h>
80119  #include <linux/types.h>
80120  #include <linux/timer.h>
80121 @@ -68,6 +67,7 @@
80122  static void ip_nat_cleanup_conntrack(struct ip_conntrack *conn)
80123  {
80124         struct ip_nat_info *info = &conn->nat.info;
80125 +       unsigned int hs, hp;
80126  
80127         if (!info->initialized)
80128                 return;
80129 @@ -75,21 +75,18 @@
80130         IP_NF_ASSERT(info->bysource.conntrack);
80131         IP_NF_ASSERT(info->byipsproto.conntrack);
80132  
80133 +       hs = hash_by_src(&conn->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src,
80134 +                        conn->tuplehash[IP_CT_DIR_ORIGINAL]
80135 +                        .tuple.dst.protonum);
80136 +
80137 +       hp = hash_by_ipsproto(conn->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip,
80138 +                             conn->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip,
80139 +                             conn->tuplehash[IP_CT_DIR_REPLY]
80140 +                             .tuple.dst.protonum);
80141 +
80142         WRITE_LOCK(&ip_nat_lock);
80143 -       LIST_DELETE(&bysource[hash_by_src(&conn->tuplehash[IP_CT_DIR_ORIGINAL]
80144 -                                         .tuple.src,
80145 -                                         conn->tuplehash[IP_CT_DIR_ORIGINAL]
80146 -                                         .tuple.dst.protonum)],
80147 -                   &info->bysource);
80148 -
80149 -       LIST_DELETE(&byipsproto
80150 -                   [hash_by_ipsproto(conn->tuplehash[IP_CT_DIR_REPLY]
80151 -                                     .tuple.src.ip,
80152 -                                     conn->tuplehash[IP_CT_DIR_REPLY]
80153 -                                     .tuple.dst.ip,
80154 -                                     conn->tuplehash[IP_CT_DIR_REPLY]
80155 -                                     .tuple.dst.protonum)],
80156 -                   &info->byipsproto);
80157 +       LIST_DELETE(&bysource[hs], &info->bysource);
80158 +       LIST_DELETE(&byipsproto[hp], &info->byipsproto);
80159         WRITE_UNLOCK(&ip_nat_lock);
80160  }
80161  
80162 @@ -246,11 +243,12 @@
80163            const struct ip_conntrack *conntrack)
80164  {
80165         unsigned int score = 0;
80166 +       unsigned int h;
80167  
80168         MUST_BE_READ_LOCKED(&ip_nat_lock);
80169 -       LIST_FIND(&byipsproto[hash_by_ipsproto(src, dst, protonum)],
80170 -                 fake_cmp, struct ip_nat_hash *, src, dst, protonum, &score,
80171 -                 conntrack);
80172 +       h = hash_by_ipsproto(src, dst, protonum);
80173 +       LIST_FIND(&byipsproto[h], fake_cmp, struct ip_nat_hash *,
80174 +                 src, dst, protonum, &score, conntrack);
80175  
80176         return score;
80177  }
80178 diff -Nru a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c
80179 --- a/net/ipv4/netfilter/ip_nat_ftp.c   Sat Aug  2 18:29:28 2003
80180 +++ b/net/ipv4/netfilter/ip_nat_ftp.c   Sun Aug 24 05:00:28 2003
80181 @@ -10,6 +10,10 @@
80182  #include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
80183  #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
80184  
80185 +MODULE_LICENSE("GPL");
80186 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
80187 +MODULE_DESCRIPTION("ftp NAT helper");
80188 +
80189  #if 0
80190  #define DEBUGP printk
80191  #else
80192 @@ -342,4 +346,3 @@
80193  
80194  module_init(init);
80195  module_exit(fini);
80196 -MODULE_LICENSE("GPL");
80197 diff -Nru a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c
80198 --- a/net/ipv4/netfilter/ip_nat_helper.c        Thu Jul 17 14:50:26 2003
80199 +++ b/net/ipv4/netfilter/ip_nat_helper.c        Sat Aug 30 20:35:04 2003
80200 @@ -12,7 +12,6 @@
80201   *             - make ip_nat_resize_packet more generic (TCP and UDP)
80202   *             - add ip_nat_mangle_udp_packet
80203   */
80204 -#include <linux/version.h>
80205  #include <linux/config.h>
80206  #include <linux/module.h>
80207  #include <linux/kmod.h>
80208 diff -Nru a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc.c
80209 --- a/net/ipv4/netfilter/ip_nat_irc.c   Sat Aug  2 18:29:28 2003
80210 +++ b/net/ipv4/netfilter/ip_nat_irc.c   Sun Aug 24 05:00:28 2003
80211 @@ -39,7 +39,7 @@
80212  static int ports_c;
80213  
80214  MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
80215 -MODULE_DESCRIPTION("IRC (DCC) network address translation module");
80216 +MODULE_DESCRIPTION("IRC (DCC) NAT helper");
80217  MODULE_LICENSE("GPL");
80218  #ifdef MODULE_PARM
80219  MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
80220 diff -Nru a/net/ipv4/netfilter/ip_nat_rule.c b/net/ipv4/netfilter/ip_nat_rule.c
80221 --- a/net/ipv4/netfilter/ip_nat_rule.c  Wed May 21 16:29:38 2003
80222 +++ b/net/ipv4/netfilter/ip_nat_rule.c  Sat Aug 30 20:35:04 2003
80223 @@ -9,7 +9,6 @@
80224  #include <linux/proc_fs.h>
80225  #include <net/checksum.h>
80226  #include <linux/bitops.h>
80227 -#include <linux/version.h>
80228  
80229  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock)
80230  #define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock)
80231 diff -Nru a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
80232 --- a/net/ipv4/netfilter/ip_nat_snmp_basic.c    Sat Aug  2 18:29:28 2003
80233 +++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c    Sun Aug 24 05:00:28 2003
80234 @@ -56,7 +56,9 @@
80235  #include <asm/uaccess.h>
80236  #include <asm/checksum.h>
80237  
80238 -
80239 +MODULE_LICENSE("GPL");
80240 +MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
80241 +MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
80242  
80243  #define SNMP_PORT 161
80244  #define SNMP_TRAP_PORT 162
80245 @@ -1357,5 +1359,3 @@
80246  module_exit(fini);
80247  
80248  MODULE_PARM(debug, "i");
80249 -MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
80250 -MODULE_LICENSE("GPL");
80251 diff -Nru a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
80252 --- a/net/ipv4/netfilter/ip_nat_standalone.c    Sat May 17 22:10:44 2003
80253 +++ b/net/ipv4/netfilter/ip_nat_standalone.c    Sat Aug 30 20:35:04 2003
80254 @@ -23,7 +23,6 @@
80255  #include <linux/proc_fs.h>
80256  #include <net/checksum.h>
80257  #include <linux/spinlock.h>
80258 -#include <linux/version.h>
80259  
80260  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock)
80261  #define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock)
80262 diff -Nru a/net/ipv4/netfilter/ip_nat_tftp.c b/net/ipv4/netfilter/ip_nat_tftp.c
80263 --- a/net/ipv4/netfilter/ip_nat_tftp.c  Tue May  6 01:04:01 2003
80264 +++ b/net/ipv4/netfilter/ip_nat_tftp.c  Sun Aug 24 05:00:28 2003
80265 @@ -30,7 +30,7 @@
80266  #include <linux/netfilter_ipv4/ip_nat_rule.h>
80267  
80268  MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
80269 -MODULE_DESCRIPTION("Netfilter NAT helper for tftp");
80270 +MODULE_DESCRIPTION("tfpt NAT helper");
80271  MODULE_LICENSE("GPL");
80272  
80273  #define MAX_PORTS 8
80274 diff -Nru a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
80275 --- a/net/ipv4/netfilter/ip_tables.c    Sat Aug  2 18:29:28 2003
80276 +++ b/net/ipv4/netfilter/ip_tables.c    Sun Aug 24 05:00:28 2003
80277 @@ -25,6 +25,10 @@
80278  
80279  #include <linux/netfilter_ipv4/ip_tables.h>
80280  
80281 +MODULE_LICENSE("GPL");
80282 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
80283 +MODULE_DESCRIPTION("IPv4 packet filter");
80284 +
80285  /*#define DEBUG_IP_FIREWALL*/
80286  /*#define DEBUG_ALLOW_ALL*/ /* Useful for remote debugging */
80287  /*#define DEBUG_IP_FIREWALL_USER*/
80288 @@ -1845,4 +1849,3 @@
80289  
80290  module_init(init);
80291  module_exit(fini);
80292 -MODULE_LICENSE("GPL");
80293 diff -Nru a/net/ipv4/netfilter/ipchains_core.c b/net/ipv4/netfilter/ipchains_core.c
80294 --- a/net/ipv4/netfilter/ipchains_core.c        Wed Jun  4 17:57:08 2003
80295 +++ b/net/ipv4/netfilter/ipchains_core.c        Sun Aug 24 05:00:28 2003
80296 @@ -100,6 +100,9 @@
80297  #include <linux/proc_fs.h>
80298  #include <linux/stat.h>
80299  
80300 +MODULE_LICENSE("Dual BSD/GPL");
80301 +MODULE_DESCRIPTION("ipchains backwards compatibility layer");
80302 +
80303  /* Understanding locking in this code: (thanks to Alan Cox for using
80304   * little words to explain this to me). -- PR
80305   *
80306 @@ -1842,4 +1845,3 @@
80307  #endif
80308         return ret;
80309  }
80310 -MODULE_LICENSE("Dual BSD/GPL");
80311 diff -Nru a/net/ipv4/netfilter/ipfwadm_core.c b/net/ipv4/netfilter/ipfwadm_core.c
80312 --- a/net/ipv4/netfilter/ipfwadm_core.c Wed Jun  4 17:57:08 2003
80313 +++ b/net/ipv4/netfilter/ipfwadm_core.c Sat Aug 30 20:35:04 2003
80314 @@ -131,9 +131,9 @@
80315  #include <net/checksum.h>
80316  #include <linux/proc_fs.h>
80317  #include <linux/stat.h>
80318 -#include <linux/version.h>
80319  
80320  MODULE_LICENSE("Dual BSD/GPL");
80321 +MODULE_DESCRIPTION("ipfwadm backwards compatibility layer");
80322  
80323  /*
80324   *     Implement IP packet firewall
80325 diff -Nru a/net/ipv4/netfilter/ipt_CLASSIFY.c b/net/ipv4/netfilter/ipt_CLASSIFY.c
80326 --- /dev/null   Wed Dec 31 16:00:00 1969
80327 +++ b/net/ipv4/netfilter/ipt_CLASSIFY.c Sun Aug 24 19:51:27 2003
80328 @@ -0,0 +1,86 @@
80329 +/*
80330 + * This is a module which is used for setting the skb->priority field
80331 + * of an skb for qdisc classification.
80332 + */
80333 +
80334 +#include <linux/module.h>
80335 +#include <linux/skbuff.h>
80336 +#include <linux/ip.h>
80337 +#include <net/checksum.h>
80338 +
80339 +#include <linux/netfilter_ipv4/ip_tables.h>
80340 +#include <linux/netfilter_ipv4/ipt_CLASSIFY.h>
80341 +
80342 +MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
80343 +MODULE_LICENSE("GPL");
80344 +MODULE_DESCRIPTION("iptables qdisc classification target module");
80345 +
80346 +static unsigned int
80347 +target(struct sk_buff **pskb,
80348 +       const struct net_device *in,
80349 +       const struct net_device *out,
80350 +       unsigned int hooknum,
80351 +       const void *targinfo,
80352 +       void *userinfo)
80353 +{
80354 +       const struct ipt_classify_target_info *clinfo = targinfo;
80355 +
80356 +       if((*pskb)->priority != clinfo->priority) {
80357 +               (*pskb)->priority = clinfo->priority;
80358 +               (*pskb)->nfcache |= NFC_ALTERED;
80359 +       }
80360 +
80361 +       return IPT_CONTINUE;
80362 +}
80363 +
80364 +static int
80365 +checkentry(const char *tablename,
80366 +           const struct ipt_entry *e,
80367 +           void *targinfo,
80368 +           unsigned int targinfosize,
80369 +           unsigned int hook_mask)
80370 +{
80371 +       if (targinfosize != IPT_ALIGN(sizeof(struct ipt_classify_target_info))){
80372 +               printk(KERN_ERR "CLASSIFY: invalid size (%u != %Zu).\n",
80373 +                      targinfosize,
80374 +                      IPT_ALIGN(sizeof(struct ipt_classify_target_info)));
80375 +               return 0;
80376 +       }
80377 +       
80378 +       if (hook_mask & ~(1 << NF_IP_POST_ROUTING)) {
80379 +               printk(KERN_ERR "CLASSIFY: only valid in POST_ROUTING.\n");
80380 +               return 0;
80381 +       }
80382 +
80383 +       if (strcmp(tablename, "mangle") != 0) {
80384 +               printk(KERN_WARNING "CLASSIFY: can only be called from "
80385 +                                   "\"mangle\" table, not \"%s\".\n",
80386 +                                   tablename);
80387 +               return 0;
80388 +       }
80389 +
80390 +       return 1;
80391 +}
80392 +
80393 +static struct ipt_target ipt_classify_reg = { 
80394 +       .name           = "CLASSIFY", 
80395 +       .target         = target,
80396 +       .checkentry     = checkentry,
80397 +       .me             = THIS_MODULE,
80398 +};
80399 +
80400 +static int __init init(void)
80401 +{
80402 +       if (ipt_register_target(&ipt_classify_reg))
80403 +               return -EINVAL;
80404 +
80405 +       return 0;
80406 +}
80407 +
80408 +static void __exit fini(void)
80409 +{
80410 +       ipt_unregister_target(&ipt_classify_reg);
80411 +}
80412 +
80413 +module_init(init);
80414 +module_exit(fini);
80415 diff -Nru a/net/ipv4/netfilter/ipt_DSCP.c b/net/ipv4/netfilter/ipt_DSCP.c
80416 --- a/net/ipv4/netfilter/ipt_DSCP.c     Wed May 21 16:36:54 2003
80417 +++ b/net/ipv4/netfilter/ipt_DSCP.c     Sun Aug 24 05:00:28 2003
80418 @@ -17,8 +17,8 @@
80419  #include <linux/netfilter_ipv4/ip_tables.h>
80420  #include <linux/netfilter_ipv4/ipt_DSCP.h>
80421  
80422 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
80423 -MODULE_DESCRIPTION("IP tables DSCP modification module");
80424 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
80425 +MODULE_DESCRIPTION("iptables DSCP modification module");
80426  MODULE_LICENSE("GPL");
80427  
80428  static unsigned int
80429 diff -Nru a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c
80430 --- a/net/ipv4/netfilter/ipt_ECN.c      Wed May 21 16:36:54 2003
80431 +++ b/net/ipv4/netfilter/ipt_ECN.c      Sun Aug 24 05:00:28 2003
80432 @@ -17,6 +17,8 @@
80433  #include <linux/netfilter_ipv4/ipt_ECN.h>
80434  
80435  MODULE_LICENSE("GPL");
80436 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
80437 +MODULE_DESCRIPTION("iptables ECN modification module");
80438  
80439  /* set ECT codepoint from IP header.
80440   *     return 0 if there was an error. */
80441 diff -Nru a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
80442 --- a/net/ipv4/netfilter/ipt_LOG.c      Sat Aug  2 22:47:01 2003
80443 +++ b/net/ipv4/netfilter/ipt_LOG.c      Mon Sep  1 01:44:26 2003
80444 @@ -13,6 +13,10 @@
80445  #include <linux/netfilter_ipv4/ip_tables.h>
80446  #include <linux/netfilter_ipv4/ipt_LOG.h>
80447  
80448 +MODULE_LICENSE("GPL");
80449 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
80450 +MODULE_DESCRIPTION("iptables syslog logging module");
80451 +
80452  #if 0
80453  #define DEBUGP printk
80454  #else
80455 @@ -329,7 +333,7 @@
80456                loginfo->prefix,
80457                in ? in->name : "",
80458                out ? out->name : "");
80459 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
80460 +#ifdef CONFIG_BRIDGE_NETFILTER
80461         if ((*pskb)->nf_bridge) {
80462                 struct net_device *physindev = (*pskb)->nf_bridge->physindev;
80463                 struct net_device *physoutdev = (*pskb)->nf_bridge->physoutdev;
80464 @@ -413,4 +417,3 @@
80465  
80466  module_init(init);
80467  module_exit(fini);
80468 -MODULE_LICENSE("GPL");
80469 diff -Nru a/net/ipv4/netfilter/ipt_MARK.c b/net/ipv4/netfilter/ipt_MARK.c
80470 --- a/net/ipv4/netfilter/ipt_MARK.c     Wed May 21 16:36:54 2003
80471 +++ b/net/ipv4/netfilter/ipt_MARK.c     Sun Aug 24 05:00:28 2003
80472 @@ -7,6 +7,10 @@
80473  #include <linux/netfilter_ipv4/ip_tables.h>
80474  #include <linux/netfilter_ipv4/ipt_MARK.h>
80475  
80476 +MODULE_LICENSE("GPL");
80477 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
80478 +MODULE_DESCRIPTION("iptables MARK modification module");
80479 +
80480  static unsigned int
80481  target(struct sk_buff **pskb,
80482         const struct net_device *in,
80483 @@ -68,4 +72,3 @@
80484  
80485  module_init(init);
80486  module_exit(fini);
80487 -MODULE_LICENSE("GPL");
80488 diff -Nru a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
80489 --- a/net/ipv4/netfilter/ipt_MASQUERADE.c       Mon Aug 11 22:46:31 2003
80490 +++ b/net/ipv4/netfilter/ipt_MASQUERADE.c       Sun Aug 24 05:00:28 2003
80491 @@ -12,6 +12,10 @@
80492  #include <linux/netfilter_ipv4/ip_nat_rule.h>
80493  #include <linux/netfilter_ipv4/ip_tables.h>
80494  
80495 +MODULE_LICENSE("GPL");
80496 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
80497 +MODULE_DESCRIPTION("iptables MASQUERADE target module");
80498 +
80499  #if 0
80500  #define DEBUGP printk
80501  #else
80502 @@ -213,4 +217,3 @@
80503  
80504  module_init(init);
80505  module_exit(fini);
80506 -MODULE_LICENSE("GPL");
80507 diff -Nru a/net/ipv4/netfilter/ipt_MIRROR.c b/net/ipv4/netfilter/ipt_MIRROR.c
80508 --- a/net/ipv4/netfilter/ipt_MIRROR.c   Fri Jul 25 15:22:30 2003
80509 +++ /dev/null   Wed Dec 31 16:00:00 1969
80510 @@ -1,222 +0,0 @@
80511 -/*
80512 -  This is a module which is used for resending packets with inverted src and dst.
80513 -
80514 -  Based on code from: ip_nat_dumb.c,v 1.9 1999/08/20
80515 -  and various sources.
80516 -
80517 -  Copyright (C) 2000 Emmanuel Roger <winfield@freegates.be>
80518 -
80519 -  Changes:
80520 -       25 Aug 2001 Harald Welte <laforge@gnumonks.org>
80521 -               - decrement and check TTL if not called from FORWARD hook
80522 -       18 Jul 2003 Harald Welte <laforge@netfilter.org>
80523 -               - merge Patrick McHardy's mirror fixes from 2.4.22 to
80524 -                 2.6.0-test1
80525 -       19 Jul 2003 Harald Welte <laforge@netfilter.org>
80526 -               - merge Patrick McHardy's rp_filter fixes from 2.4.22 to
80527 -                 2.6.0-test1
80528 -
80529 -  This program is free software; you can redistribute it and/or modify it
80530 -  under the terms of the GNU General Public License as published by the
80531 -  Free Software Foundation; either version 2 of the License, or (at your
80532 -  option) any later version.
80533 -
80534 -  This program is distributed in the hope that it will be useful, but
80535 -  WITHOUT ANY WARRANTY; without even the implied warranty of
80536 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
80537 -  General Public License for more details.
80538 -
80539 -  You should have received a copy of the GNU General Public License
80540 -  along with this program; if not, write to the Free Software Foundation,
80541 -  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
80542 - */
80543 -#include <linux/module.h>
80544 -#include <linux/skbuff.h>
80545 -#include <linux/ip.h>
80546 -#include <net/ip.h>
80547 -#include <net/icmp.h>
80548 -#include <linux/netfilter_ipv4/ip_tables.h>
80549 -#include <linux/netdevice.h>
80550 -#include <linux/route.h>
80551 -#include <net/route.h>
80552 -
80553 -#if 0
80554 -#define DEBUGP printk
80555 -#else
80556 -#define DEBUGP(format, args...)
80557 -#endif
80558 -
80559 -static inline struct rtable *route_mirror(struct sk_buff *skb, int local)
80560 -{
80561 -        struct iphdr *iph = skb->nh.iph;
80562 -       struct dst_entry *odst;
80563 -       struct flowi fl = {};
80564 -       struct rtable *rt;
80565 -
80566 -       if (local) {
80567 -               fl.nl_u.ip4_u.daddr = iph->saddr;
80568 -               fl.nl_u.ip4_u.saddr = iph->daddr;
80569 -               fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
80570 -
80571 -               if (ip_route_output_key(&rt, &fl) != 0)
80572 -                       return NULL;
80573 -       } else {
80574 -               /* non-local src, find valid iif to satisfy
80575 -                * rp-filter when calling ip_route_input(). */
80576 -               fl.nl_u.ip4_u.daddr = iph->daddr;
80577 -               if (ip_route_output_key(&rt, &fl) != 0)
80578 -                       return NULL;
80579 -
80580 -               odst = skb->dst;
80581 -               if (ip_route_input(skb, iph->saddr, iph->daddr,
80582 -                                       RT_TOS(iph->tos), rt->u.dst.dev) != 0) {
80583 -                       dst_release(&rt->u.dst);
80584 -                       return NULL;
80585 -               }
80586 -               dst_release(&rt->u.dst);
80587 -               rt = (struct rtable *)skb->dst;
80588 -               skb->dst = odst;
80589 -       }
80590 -
80591 -       if (rt->u.dst.error) {
80592 -               dst_release(&rt->u.dst);
80593 -               rt = NULL;
80594 -       }
80595 -
80596 -       return rt;
80597 -}
80598 -
80599 -static inline void ip_rewrite(struct sk_buff *skb)
80600 -{
80601 -       u32 odaddr, osaddr;
80602 -
80603 -       odaddr = skb->nh.iph->saddr;
80604 -       osaddr = skb->nh.iph->daddr;
80605 -
80606 -       skb->nfcache |= NFC_ALTERED;
80607 -
80608 -       /* Rewrite IP header */
80609 -       skb->nh.iph->daddr = odaddr;
80610 -       skb->nh.iph->saddr = osaddr;
80611 -}
80612 -
80613 -/* Stolen from ip_finish_output2 */
80614 -static void ip_direct_send(struct sk_buff *skb)
80615 -{
80616 -       struct dst_entry *dst = skb->dst;
80617 -       struct hh_cache *hh = dst->hh;
80618 -
80619 -       if (hh) {
80620 -               int hh_alen;
80621 -
80622 -               read_lock_bh(&hh->hh_lock);
80623 -               hh_alen = HH_DATA_ALIGN(hh->hh_len);
80624 -               memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
80625 -               read_unlock_bh(&hh->hh_lock);
80626 -               skb_push(skb, hh->hh_len);
80627 -               hh->hh_output(skb);
80628 -       } else if (dst->neighbour)
80629 -               dst->neighbour->output(skb);
80630 -       else {
80631 -               printk(KERN_DEBUG "khm in MIRROR\n");
80632 -               kfree_skb(skb);
80633 -       }
80634 -}
80635 -
80636 -static unsigned int ipt_mirror_target(struct sk_buff **pskb,
80637 -                                     const struct net_device *in,
80638 -                                     const struct net_device *out,
80639 -                                     unsigned int hooknum,
80640 -                                     const void *targinfo,
80641 -                                     void *userinfo)
80642 -{
80643 -       struct rtable *rt;
80644 -       struct sk_buff *nskb;
80645 -       unsigned int hh_len;
80646 -
80647 -       /* Make skb writable */
80648 -       if (!skb_ip_make_writable(pskb, sizeof(struct iphdr)))
80649 -               return 0;
80650 -
80651 -       /* If we are not at FORWARD hook (INPUT/PREROUTING),
80652 -        * the TTL isn't decreased by the IP stack */
80653 -       if (hooknum != NF_IP_FORWARD) {
80654 -               if ((*pskb)->nh.iph->ttl <= 1) {
80655 -                       /* this will traverse normal stack, and 
80656 -                        * thus call conntrack on the icmp packet */
80657 -                       icmp_send(*pskb, ICMP_TIME_EXCEEDED, 
80658 -                                 ICMP_EXC_TTL, 0);
80659 -                       return NF_DROP;
80660 -               }
80661 -               ip_decrease_ttl((*pskb)->nh.iph);
80662 -       }
80663 -
80664 -       if ((rt = route_mirror(*pskb, hooknum == NF_IP_LOCAL_IN)) == NULL)
80665 -               return NF_DROP;
80666 -
80667 -       hh_len = (rt->u.dst.dev->hard_header_len + 15) & ~15;
80668 -
80669 -       /* Copy skb (even if skb is about to be dropped, we can't just
80670 -        * clone it because there may be other things, such as tcpdump,
80671 -        * interested in it). We also need to expand headroom in case
80672 -        * hh_len of incoming interface < hh_len of outgoing interface */
80673 -       nskb = skb_copy_expand(*pskb, hh_len, skb_tailroom(*pskb), GFP_ATOMIC);
80674 -       if (nskb == NULL) {
80675 -               dst_release(&rt->u.dst);
80676 -               return NF_DROP;
80677 -       }
80678 -
80679 -       dst_release(nskb->dst);
80680 -       nskb->dst = &rt->u.dst;
80681 -
80682 -       ip_rewrite(nskb);
80683 -       /* Don't let conntrack code see this packet:
80684 -        * it will think we are starting a new
80685 -        * connection! --RR */
80686 -       ip_direct_send(nskb);
80687 -
80688 -       return NF_DROP;
80689 -}
80690 -
80691 -static int ipt_mirror_checkentry(const char *tablename,
80692 -                                const struct ipt_entry *e,
80693 -                                void *targinfo,
80694 -                                unsigned int targinfosize,
80695 -                                unsigned int hook_mask)
80696 -{
80697 -       /* Only on INPUT, FORWARD or PRE_ROUTING, otherwise loop danger. */
80698 -       if (hook_mask & ~((1 << NF_IP_PRE_ROUTING)
80699 -                         | (1 << NF_IP_FORWARD)
80700 -                         | (1 << NF_IP_LOCAL_IN))) {
80701 -               DEBUGP("MIRROR: bad hook\n");
80702 -               return 0;
80703 -       }
80704 -
80705 -       if (targinfosize != IPT_ALIGN(0)) {
80706 -               DEBUGP("MIRROR: targinfosize %u != 0\n", targinfosize);
80707 -               return 0;
80708 -       }
80709 -
80710 -       return 1;
80711 -}
80712 -
80713 -static struct ipt_target ipt_mirror_reg = {
80714 -       .name           = "MIRROR",
80715 -       .target         = ipt_mirror_target,
80716 -       .checkentry     = ipt_mirror_checkentry,
80717 -       .me             = THIS_MODULE,
80718 -};
80719 -
80720 -static int __init init(void)
80721 -{
80722 -       return ipt_register_target(&ipt_mirror_reg);
80723 -}
80724 -
80725 -static void __exit fini(void)
80726 -{
80727 -       ipt_unregister_target(&ipt_mirror_reg);
80728 -}
80729 -
80730 -module_init(init);
80731 -module_exit(fini);
80732 -MODULE_LICENSE("GPL");
80733 diff -Nru a/net/ipv4/netfilter/ipt_NETMAP.c b/net/ipv4/netfilter/ipt_NETMAP.c
80734 --- /dev/null   Wed Dec 31 16:00:00 1969
80735 +++ b/net/ipv4/netfilter/ipt_NETMAP.c   Sun Aug 24 17:25:18 2003
80736 @@ -0,0 +1,112 @@
80737 +/* NETMAP - static NAT mapping of IP network addresses (1:1).
80738 +   The mapping can be applied to source (POSTROUTING),
80739 +   destination (PREROUTING), or both (with separate rules).
80740 +
80741 +   Author: Svenning Soerensen <svenning@post5.tele.dk>
80742 +*/
80743 +
80744 +#include <linux/config.h>
80745 +#include <linux/ip.h>
80746 +#include <linux/module.h>
80747 +#include <linux/netdevice.h>
80748 +#include <linux/netfilter.h>
80749 +#include <linux/netfilter_ipv4.h>
80750 +#include <linux/netfilter_ipv4/ip_nat_rule.h>
80751 +
80752 +#define MODULENAME "NETMAP"
80753 +MODULE_LICENSE("GPL");
80754 +MODULE_AUTHOR("Svenning Soerensen <svenning@post5.tele.dk>");
80755 +MODULE_DESCRIPTION("iptables 1:1 NAT mapping of IP networks target");
80756 +
80757 +#if 0
80758 +#define DEBUGP printk
80759 +#else
80760 +#define DEBUGP(format, args...)
80761 +#endif
80762 +
80763 +static int
80764 +check(const char *tablename,
80765 +      const struct ipt_entry *e,
80766 +      void *targinfo,
80767 +      unsigned int targinfosize,
80768 +      unsigned int hook_mask)
80769 +{
80770 +       const struct ip_nat_multi_range *mr = targinfo;
80771 +
80772 +       if (strcmp(tablename, "nat") != 0) {
80773 +               DEBUGP(MODULENAME":check: bad table `%s'.\n", tablename);
80774 +               return 0;
80775 +       }
80776 +       if (targinfosize != IPT_ALIGN(sizeof(*mr))) {
80777 +               DEBUGP(MODULENAME":check: size %u.\n", targinfosize);
80778 +               return 0;
80779 +       }
80780 +       if (hook_mask & ~((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_POST_ROUTING))) {
80781 +               DEBUGP(MODULENAME":check: bad hooks %x.\n", hook_mask);
80782 +               return 0;
80783 +       }
80784 +       if (!(mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)) {
80785 +               DEBUGP(MODULENAME":check: bad MAP_IPS.\n");
80786 +               return 0;
80787 +       }
80788 +       if (mr->rangesize != 1) {
80789 +               DEBUGP(MODULENAME":check: bad rangesize %u.\n", mr->rangesize);
80790 +               return 0;
80791 +       }
80792 +       return 1;
80793 +}
80794 +
80795 +static unsigned int
80796 +target(struct sk_buff **pskb,
80797 +       const struct net_device *in,
80798 +       const struct net_device *out,
80799 +       unsigned int hooknum,
80800 +       const void *targinfo,
80801 +       void *userinfo)
80802 +{
80803 +       struct ip_conntrack *ct;
80804 +       enum ip_conntrack_info ctinfo;
80805 +       u_int32_t new_ip, netmask;
80806 +       const struct ip_nat_multi_range *mr = targinfo;
80807 +       struct ip_nat_multi_range newrange;
80808 +
80809 +       IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING
80810 +                    || hooknum == NF_IP_POST_ROUTING);
80811 +       ct = ip_conntrack_get(*pskb, &ctinfo);
80812 +
80813 +       netmask = ~(mr->range[0].min_ip ^ mr->range[0].max_ip);
80814 +
80815 +       if (hooknum == NF_IP_PRE_ROUTING)
80816 +               new_ip = (*pskb)->nh.iph->daddr & ~netmask;
80817 +       else
80818 +               new_ip = (*pskb)->nh.iph->saddr & ~netmask;
80819 +       new_ip |= mr->range[0].min_ip & netmask;
80820 +
80821 +       newrange = ((struct ip_nat_multi_range)
80822 +       { 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
80823 +                new_ip, new_ip,
80824 +                mr->range[0].min, mr->range[0].max } } });
80825 +
80826 +       /* Hand modified range to generic setup. */
80827 +       return ip_nat_setup_info(ct, &newrange, hooknum);
80828 +}
80829 +
80830 +static struct ipt_target target_module = { 
80831 +       .name           = MODULENAME,
80832 +       .target         = target, 
80833 +       .checkentry     = check,
80834 +       .me             = THIS_MODULE 
80835 +};
80836 +
80837 +static int __init init(void)
80838 +{
80839 +       return ipt_register_target(&target_module);
80840 +}
80841 +
80842 +static void __exit fini(void)
80843 +{
80844 +       ipt_unregister_target(&target_module);
80845 +}
80846 +
80847 +module_init(init);
80848 +module_exit(fini);
80849 diff -Nru a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
80850 --- a/net/ipv4/netfilter/ipt_REDIRECT.c Wed May 21 16:36:54 2003
80851 +++ b/net/ipv4/netfilter/ipt_REDIRECT.c Sun Aug 24 05:00:28 2003
80852 @@ -12,6 +12,10 @@
80853  #include <linux/netfilter_ipv4.h>
80854  #include <linux/netfilter_ipv4/ip_nat_rule.h>
80855  
80856 +MODULE_LICENSE("GPL");
80857 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
80858 +MODULE_DESCRIPTION("iptables REDIRECT target module");
80859 +
80860  #if 0
80861  #define DEBUGP printk
80862  #else
80863 @@ -115,4 +119,3 @@
80864  
80865  module_init(init);
80866  module_exit(fini);
80867 -MODULE_LICENSE("GPL");
80868 diff -Nru a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
80869 --- a/net/ipv4/netfilter/ipt_REJECT.c   Sun Jul 27 16:03:33 2003
80870 +++ b/net/ipv4/netfilter/ipt_REJECT.c   Tue Sep  2 11:21:51 2003
80871 @@ -16,6 +16,10 @@
80872  #include <linux/netfilter_ipv4/ip_tables.h>
80873  #include <linux/netfilter_ipv4/ipt_REJECT.h>
80874  
80875 +MODULE_LICENSE("GPL");
80876 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
80877 +MODULE_DESCRIPTION("iptables REJECT target module");
80878 +
80879  #if 0
80880  #define DEBUGP printk
80881  #else
80882 @@ -137,6 +141,10 @@
80883         nskb->nf_debug = 0;
80884  #endif
80885         nskb->nfmark = 0;
80886 +#ifdef CONFIG_BRIDGE_NETFILTER
80887 +       nf_bridge_put(nskb->nf_bridge);
80888 +       nskb->nf_bridge = NULL;
80889 +#endif
80890  
80891         tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
80892  
80893 @@ -462,4 +470,3 @@
80894  
80895  module_init(init);
80896  module_exit(fini);
80897 -MODULE_LICENSE("GPL");
80898 diff -Nru a/net/ipv4/netfilter/ipt_SAME.c b/net/ipv4/netfilter/ipt_SAME.c
80899 --- /dev/null   Wed Dec 31 16:00:00 1969
80900 +++ b/net/ipv4/netfilter/ipt_SAME.c     Sun Aug 24 17:25:18 2003
80901 @@ -0,0 +1,206 @@
80902 +/* Same.  Just like SNAT, only try to make the connections
80903 + *       between client A and server B always have the same source ip.
80904 + *
80905 + * (C) 2000 Rusty Russell.  GPL.
80906 + *
80907 + * 010320 Martin Josefsson <gandalf@wlug.westbo.se>
80908 + *     * copied ipt_BALANCE.c to ipt_SAME.c and changed a few things.
80909 + * 010728 Martin Josefsson <gandalf@wlug.westbo.se>
80910 + *     * added --nodst to not include destination-ip in new source
80911 + *       calculations.
80912 + *     * added some more sanity-checks.
80913 + * 010729 Martin Josefsson <gandalf@wlug.westbo.se>
80914 + *     * fixed a buggy if-statement in same_check(), should have
80915 + *       used ntohl() but didn't.
80916 + *     * added support for multiple ranges. IPT_SAME_MAX_RANGE is
80917 + *       defined in linux/include/linux/netfilter_ipv4/ipt_SAME.h
80918 + *       and is currently set to 10.
80919 + *     * added support for 1-address range, nice to have now that
80920 + *       we have multiple ranges.
80921 + */
80922 +#include <linux/types.h>
80923 +#include <linux/ip.h>
80924 +#include <linux/timer.h>
80925 +#include <linux/module.h>
80926 +#include <linux/netfilter.h>
80927 +#include <linux/netdevice.h>
80928 +#include <linux/if.h>
80929 +#include <linux/inetdevice.h>
80930 +#include <net/protocol.h>
80931 +#include <net/checksum.h>
80932 +#include <linux/netfilter_ipv4.h>
80933 +#include <linux/netfilter_ipv4/ip_nat_rule.h>
80934 +#include <linux/netfilter_ipv4/ipt_SAME.h>
80935 +
80936 +MODULE_LICENSE("GPL");
80937 +MODULE_AUTHOR("Martin Josefsson <gandalf@wlug.westbo.se>");
80938 +MODULE_DESCRIPTION("iptables special SNAT module for consistent sourceip");
80939 +
80940 +#if 0
80941 +#define DEBUGP printk
80942 +#else
80943 +#define DEBUGP(format, args...)
80944 +#endif
80945 +
80946 +static int
80947 +same_check(const char *tablename,
80948 +             const struct ipt_entry *e,
80949 +             void *targinfo,
80950 +             unsigned int targinfosize,
80951 +             unsigned int hook_mask)
80952 +{
80953 +       unsigned int count, countess, rangeip, index = 0;
80954 +       struct ipt_same_info *mr = targinfo;
80955 +
80956 +       mr->ipnum = 0;
80957 +
80958 +       if (strcmp(tablename, "nat") != 0) {
80959 +               DEBUGP("same_check: bad table `%s'.\n", tablename);
80960 +               return 0;
80961 +       }
80962 +       if (targinfosize != IPT_ALIGN(sizeof(*mr))) {
80963 +               DEBUGP("same_check: size %u.\n", targinfosize);
80964 +               return 0;
80965 +       }
80966 +       if (hook_mask & ~(1 << NF_IP_PRE_ROUTING | 1 << NF_IP_POST_ROUTING)) {
80967 +               DEBUGP("same_check: bad hooks %x.\n", hook_mask);
80968 +               return 0;
80969 +       }
80970 +       if (mr->rangesize < 1) {
80971 +               DEBUGP("same_check: need at least one dest range.\n");
80972 +               return 0;
80973 +       }
80974 +       if (mr->rangesize > IPT_SAME_MAX_RANGE) {
80975 +               DEBUGP("same_check: too many ranges specified, maximum "
80976 +                               "is %u ranges\n",
80977 +                               IPT_SAME_MAX_RANGE);
80978 +               return 0;
80979 +       }
80980 +       for (count = 0; count < mr->rangesize; count++) {
80981 +               if (ntohl(mr->range[count].min_ip) >
80982 +                               ntohl(mr->range[count].max_ip)) {
80983 +                       DEBUGP("same_check: min_ip is larger than max_ip in "
80984 +                               "range `%u.%u.%u.%u-%u.%u.%u.%u'.\n",
80985 +                               NIPQUAD(mr->range[count].min_ip),
80986 +                               NIPQUAD(mr->range[count].max_ip));
80987 +                       return 0;
80988 +               }
80989 +               if (!(mr->range[count].flags & IP_NAT_RANGE_MAP_IPS)) {
80990 +                       DEBUGP("same_check: bad MAP_IPS.\n");
80991 +                       return 0;
80992 +               }
80993 +               rangeip = (ntohl(mr->range[count].max_ip) - 
80994 +                                       ntohl(mr->range[count].min_ip) + 1);
80995 +               mr->ipnum += rangeip;
80996 +               
80997 +               DEBUGP("same_check: range %u, ipnum = %u\n", count, rangeip);
80998 +       }
80999 +       DEBUGP("same_check: total ipaddresses = %u\n", mr->ipnum);
81000 +       
81001 +       mr->iparray = kmalloc((sizeof(u_int32_t) * mr->ipnum), GFP_KERNEL);
81002 +       if (!mr->iparray) {
81003 +               DEBUGP("same_check: Couldn't allocate %u bytes "
81004 +                       "for %u ipaddresses!\n", 
81005 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
81006 +               return 0;
81007 +       }
81008 +       DEBUGP("same_check: Allocated %u bytes for %u ipaddresses.\n",
81009 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
81010 +       
81011 +       for (count = 0; count < mr->rangesize; count++) {
81012 +               for (countess = ntohl(mr->range[count].min_ip);
81013 +                               countess <= ntohl(mr->range[count].max_ip);
81014 +                                       countess++) {
81015 +                       mr->iparray[index] = countess;
81016 +                       DEBUGP("same_check: Added ipaddress `%u.%u.%u.%u' "
81017 +                               "in index %u.\n",
81018 +                               HIPQUAD(countess), index);
81019 +                       index++;
81020 +               }
81021 +       }
81022 +       return 1;
81023 +}
81024 +
81025 +static void 
81026 +same_destroy(void *targinfo,
81027 +               unsigned int targinfosize)
81028 +{
81029 +       struct ipt_same_info *mr = targinfo;
81030 +
81031 +       kfree(mr->iparray);
81032 +       
81033 +       DEBUGP("same_destroy: Deallocated %u bytes for %u ipaddresses.\n",
81034 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
81035 +}
81036 +
81037 +static unsigned int
81038 +same_target(struct sk_buff **pskb,
81039 +               const struct net_device *in,
81040 +               const struct net_device *out,
81041 +               unsigned int hooknum,
81042 +               const void *targinfo,
81043 +               void *userinfo)
81044 +{
81045 +       struct ip_conntrack *ct;
81046 +       enum ip_conntrack_info ctinfo;
81047 +       u_int32_t tmpip, aindex, new_ip;
81048 +       const struct ipt_same_info *mr = targinfo;
81049 +       struct ip_nat_multi_range newrange;
81050 +       const struct ip_conntrack_tuple *t;
81051 +
81052 +       IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
81053 +                       hooknum == NF_IP_POST_ROUTING);
81054 +       ct = ip_conntrack_get(*pskb, &ctinfo);
81055 +
81056 +       t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
81057 +
81058 +       /* Base new source on real src ip and optionally dst ip,
81059 +          giving some hope for consistency across reboots.
81060 +          Here we calculate the index in mr->iparray which
81061 +          holds the ipaddress we should use */
81062 +       
81063 +       tmpip = ntohl(t->src.ip);
81064 +
81065 +       if (!(mr->info & IPT_SAME_NODST))
81066 +               tmpip += ntohl(t->dst.ip);
81067 +       
81068 +       aindex = tmpip % mr->ipnum;
81069 +               
81070 +       new_ip = htonl(mr->iparray[aindex]);
81071 +
81072 +       DEBUGP("ipt_SAME: src=%u.%u.%u.%u dst=%u.%u.%u.%u, "
81073 +                       "new src=%u.%u.%u.%u\n",
81074 +                       NIPQUAD(t->src.ip), NIPQUAD(t->dst.ip),
81075 +                       NIPQUAD(new_ip));
81076 +
81077 +       /* Transfer from original range. */
81078 +       newrange = ((struct ip_nat_multi_range)
81079 +               { 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
81080 +                        new_ip, new_ip,
81081 +                        mr->range[0].min, mr->range[0].max } } });
81082 +
81083 +       /* Hand modified range to generic setup. */
81084 +       return ip_nat_setup_info(ct, &newrange, hooknum);
81085 +}
81086 +
81087 +static struct ipt_target same_reg = { 
81088 +       .name           = "SAME",
81089 +       .target         = same_target,
81090 +       .checkentry     = same_check,
81091 +       .destroy        = same_destroy,
81092 +       .me             = THIS_MODULE,
81093 +};
81094 +
81095 +static int __init init(void)
81096 +{
81097 +       return ipt_register_target(&same_reg);
81098 +}
81099 +
81100 +static void __exit fini(void)
81101 +{
81102 +       ipt_unregister_target(&same_reg);
81103 +}
81104 +
81105 +module_init(init);
81106 +module_exit(fini);
81107 +
81108 diff -Nru a/net/ipv4/netfilter/ipt_TCPMSS.c b/net/ipv4/netfilter/ipt_TCPMSS.c
81109 --- a/net/ipv4/netfilter/ipt_TCPMSS.c   Wed May 21 16:36:54 2003
81110 +++ b/net/ipv4/netfilter/ipt_TCPMSS.c   Sun Aug 24 05:00:28 2003
81111 @@ -12,6 +12,10 @@
81112  #include <linux/netfilter_ipv4/ip_tables.h>
81113  #include <linux/netfilter_ipv4/ipt_TCPMSS.h>
81114  
81115 +MODULE_LICENSE("GPL");
81116 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
81117 +MODULE_DESCRIPTION("iptables TCP MSS modification module");
81118 +
81119  #if 0
81120  #define DEBUGP printk
81121  #else
81122 @@ -250,4 +254,3 @@
81123  
81124  module_init(init);
81125  module_exit(fini);
81126 -MODULE_LICENSE("GPL");
81127 diff -Nru a/net/ipv4/netfilter/ipt_TOS.c b/net/ipv4/netfilter/ipt_TOS.c
81128 --- a/net/ipv4/netfilter/ipt_TOS.c      Wed May 21 16:36:54 2003
81129 +++ b/net/ipv4/netfilter/ipt_TOS.c      Sun Aug 24 05:00:28 2003
81130 @@ -7,6 +7,10 @@
81131  #include <linux/netfilter_ipv4/ip_tables.h>
81132  #include <linux/netfilter_ipv4/ipt_TOS.h>
81133  
81134 +MODULE_LICENSE("GPL");
81135 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
81136 +MODULE_DESCRIPTION("iptables TOS mangling module");
81137 +
81138  static unsigned int
81139  target(struct sk_buff **pskb,
81140         const struct net_device *in,
81141 @@ -93,4 +97,3 @@
81142  
81143  module_init(init);
81144  module_exit(fini);
81145 -MODULE_LICENSE("GPL");
81146 diff -Nru a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
81147 --- a/net/ipv4/netfilter/ipt_ULOG.c     Tue Jun 24 15:36:11 2003
81148 +++ b/net/ipv4/netfilter/ipt_ULOG.c     Sat Aug 30 20:35:04 2003
81149 @@ -36,7 +36,6 @@
81150   */
81151  
81152  #include <linux/module.h>
81153 -#include <linux/version.h>
81154  #include <linux/config.h>
81155  #include <linux/spinlock.h>
81156  #include <linux/socket.h>
81157 @@ -55,7 +54,7 @@
81158  
81159  MODULE_LICENSE("GPL");
81160  MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
81161 -MODULE_DESCRIPTION("IP tables userspace logging module");
81162 +MODULE_DESCRIPTION("iptables userspace logging module");
81163  
81164  #define ULOG_NL_EVENT          111             /* Harald's favorite number */
81165  #define ULOG_MAXNLGROUPS       32              /* numer of nlgroups */
81166 diff -Nru a/net/ipv4/netfilter/ipt_ah.c b/net/ipv4/netfilter/ipt_ah.c
81167 --- a/net/ipv4/netfilter/ipt_ah.c       Sat Aug  2 22:49:54 2003
81168 +++ b/net/ipv4/netfilter/ipt_ah.c       Sun Aug 24 05:00:28 2003
81169 @@ -7,6 +7,8 @@
81170  #include <linux/netfilter_ipv4/ip_tables.h>
81171  
81172  MODULE_LICENSE("GPL");
81173 +MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>");
81174 +MODULE_DESCRIPTION("iptables AH SPI match module");
81175  
81176  #ifdef DEBUG_CONNTRACK
81177  #define duprintf(format, args...) printk(format , ## args)
81178 diff -Nru a/net/ipv4/netfilter/ipt_conntrack.c b/net/ipv4/netfilter/ipt_conntrack.c
81179 --- a/net/ipv4/netfilter/ipt_conntrack.c        Wed May 21 16:35:36 2003
81180 +++ b/net/ipv4/netfilter/ipt_conntrack.c        Sun Aug 24 05:00:28 2003
81181 @@ -8,6 +8,10 @@
81182  #include <linux/netfilter_ipv4/ip_tables.h>
81183  #include <linux/netfilter_ipv4/ipt_conntrack.h>
81184  
81185 +MODULE_LICENSE("GPL");
81186 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
81187 +MODULE_DESCRIPTION("iptables connection tracking match module");
81188 +
81189  static int
81190  match(const struct sk_buff *skb,
81191        const struct net_device *in,
81192 @@ -122,4 +126,3 @@
81193  
81194  module_init(init);
81195  module_exit(fini);
81196 -MODULE_LICENSE("GPL");
81197 diff -Nru a/net/ipv4/netfilter/ipt_dscp.c b/net/ipv4/netfilter/ipt_dscp.c
81198 --- a/net/ipv4/netfilter/ipt_dscp.c     Wed May 21 16:35:36 2003
81199 +++ b/net/ipv4/netfilter/ipt_dscp.c     Sun Aug 24 05:00:28 2003
81200 @@ -13,8 +13,8 @@
81201  #include <linux/netfilter_ipv4/ipt_dscp.h>
81202  #include <linux/netfilter_ipv4/ip_tables.h>
81203  
81204 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
81205 -MODULE_DESCRIPTION("IP tables DSCP matching module");
81206 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
81207 +MODULE_DESCRIPTION("iptables DSCP matching module");
81208  MODULE_LICENSE("GPL");
81209  
81210  static int match(const struct sk_buff *skb, const struct net_device *in,
81211 diff -Nru a/net/ipv4/netfilter/ipt_ecn.c b/net/ipv4/netfilter/ipt_ecn.c
81212 --- a/net/ipv4/netfilter/ipt_ecn.c      Wed May 21 16:35:36 2003
81213 +++ b/net/ipv4/netfilter/ipt_ecn.c      Sun Aug 24 05:00:28 2003
81214 @@ -14,8 +14,8 @@
81215  #include <linux/netfilter_ipv4/ip_tables.h>
81216  #include <linux/netfilter_ipv4/ipt_ecn.h>
81217  
81218 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
81219 -MODULE_DESCRIPTION("IP tables ECN matching module");
81220 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
81221 +MODULE_DESCRIPTION("iptables ECN matching module");
81222  MODULE_LICENSE("GPL");
81223  
81224  static inline int match_ip(const struct sk_buff *skb,
81225 diff -Nru a/net/ipv4/netfilter/ipt_esp.c b/net/ipv4/netfilter/ipt_esp.c
81226 --- a/net/ipv4/netfilter/ipt_esp.c      Sat Aug  2 22:51:04 2003
81227 +++ b/net/ipv4/netfilter/ipt_esp.c      Sun Aug 24 05:00:28 2003
81228 @@ -7,6 +7,8 @@
81229  #include <linux/netfilter_ipv4/ip_tables.h>
81230  
81231  MODULE_LICENSE("GPL");
81232 +MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>");
81233 +MODULE_DESCRIPTION("iptables ESP SPI match module");
81234  
81235  #ifdef DEBUG_CONNTRACK
81236  #define duprintf(format, args...) printk(format , ## args)
81237 diff -Nru a/net/ipv4/netfilter/ipt_helper.c b/net/ipv4/netfilter/ipt_helper.c
81238 --- a/net/ipv4/netfilter/ipt_helper.c   Fri Aug  1 03:02:18 2003
81239 +++ b/net/ipv4/netfilter/ipt_helper.c   Sun Aug 24 05:00:28 2003
81240 @@ -17,6 +17,8 @@
81241  #include <linux/netfilter_ipv4/ipt_helper.h>
81242  
81243  MODULE_LICENSE("GPL");
81244 +MODULE_AUTHOR("Martin Josefsson <gandalf@netfilter.org>");
81245 +MODULE_DESCRIPTION("iptables helper match module");
81246  
81247  #if 0
81248  #define DEBUGP printk
81249 diff -Nru a/net/ipv4/netfilter/ipt_iprange.c b/net/ipv4/netfilter/ipt_iprange.c
81250 --- /dev/null   Wed Dec 31 16:00:00 1969
81251 +++ b/net/ipv4/netfilter/ipt_iprange.c  Sun Aug 24 17:25:18 2003
81252 @@ -0,0 +1,97 @@
81253 +/*
81254 + * iptables module to match IP address ranges
81255 + *   (c) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
81256 + *
81257 + * Released under the terms of GNU GPLv2.
81258 + *
81259 + */
81260 +#include <linux/module.h>
81261 +#include <linux/skbuff.h>
81262 +#include <linux/ip.h>
81263 +#include <linux/netfilter_ipv4/ip_tables.h>
81264 +#include <linux/netfilter_ipv4/ipt_iprange.h>
81265 +
81266 +MODULE_LICENSE("GPL");
81267 +MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
81268 +MODULE_DESCRIPTION("iptables arbitrary IP range match module");
81269 +
81270 +#if 0
81271 +#define DEBUGP printk
81272 +#else
81273 +#define DEBUGP(format, args...)
81274 +#endif
81275 +
81276 +static int
81277 +match(const struct sk_buff *skb,
81278 +      const struct net_device *in,
81279 +      const struct net_device *out,
81280 +      const void *matchinfo,
81281 +      int offset, int *hotdrop)
81282 +{
81283 +       const struct ipt_iprange_info *info = matchinfo;
81284 +       const struct iphdr *iph = skb->nh.iph;
81285 +
81286 +       if (info->flags & IPRANGE_SRC) {
81287 +               if (((ntohl(iph->saddr) < ntohl(info->src.min_ip))
81288 +                         || (ntohl(iph->saddr) > ntohl(info->src.max_ip)))
81289 +                        ^ !!(info->flags & IPRANGE_SRC_INV)) {
81290 +                       DEBUGP("src IP %u.%u.%u.%u NOT in range %s"
81291 +                              "%u.%u.%u.%u-%u.%u.%u.%u\n",
81292 +                               NIPQUAD(iph->saddr),
81293 +                               info->flags & IPRANGE_SRC_INV ? "(INV) " : "",
81294 +                               NIPQUAD(info->src.min_ip),
81295 +                               NIPQUAD(info->src.max_ip));
81296 +                       return 0;
81297 +               }
81298 +       }
81299 +       if (info->flags & IPRANGE_DST) {
81300 +               if (((ntohl(iph->daddr) < ntohl(info->dst.min_ip))
81301 +                         || (ntohl(iph->daddr) > ntohl(info->dst.max_ip)))
81302 +                        ^ !!(info->flags & IPRANGE_DST_INV)) {
81303 +                       DEBUGP("dst IP %u.%u.%u.%u NOT in range %s"
81304 +                              "%u.%u.%u.%u-%u.%u.%u.%u\n",
81305 +                               NIPQUAD(iph->daddr),
81306 +                               info->flags & IPRANGE_DST_INV ? "(INV) " : "",
81307 +                               NIPQUAD(info->dst.min_ip),
81308 +                               NIPQUAD(info->dst.max_ip));
81309 +                       return 0;
81310 +               }
81311 +       }
81312 +       return 1;
81313 +}
81314 +
81315 +static int check(const char *tablename,
81316 +                const struct ipt_ip *ip,
81317 +                void *matchinfo,
81318 +                unsigned int matchsize,
81319 +                unsigned int hook_mask)
81320 +{
81321 +       /* verify size */
81322 +       if (matchsize != IPT_ALIGN(sizeof(struct ipt_iprange_info)))
81323 +               return 0;
81324 +
81325 +       return 1;
81326 +}
81327 +
81328 +static struct ipt_match iprange_match = 
81329 +{ 
81330 +       .list = { NULL, NULL }, 
81331 +       .name = "iprange", 
81332 +       .match = &match, 
81333 +       .checkentry = &check, 
81334 +       .destroy = NULL, 
81335 +       .me = THIS_MODULE
81336 +};
81337 +
81338 +static int __init init(void)
81339 +{
81340 +       return ipt_register_match(&iprange_match);
81341 +}
81342 +
81343 +static void __exit fini(void)
81344 +{
81345 +       ipt_unregister_match(&iprange_match);
81346 +}
81347 +
81348 +module_init(init);
81349 +module_exit(fini);
81350 diff -Nru a/net/ipv4/netfilter/ipt_limit.c b/net/ipv4/netfilter/ipt_limit.c
81351 --- a/net/ipv4/netfilter/ipt_limit.c    Wed May 21 16:35:36 2003
81352 +++ b/net/ipv4/netfilter/ipt_limit.c    Sun Aug 24 05:00:28 2003
81353 @@ -15,6 +15,10 @@
81354  #include <linux/netfilter_ipv4/ip_tables.h>
81355  #include <linux/netfilter_ipv4/ipt_limit.h>
81356  
81357 +MODULE_LICENSE("GPL");
81358 +MODULE_AUTHOR("Herve Eychenne <rv@wallfire.org>");
81359 +MODULE_DESCRIPTION("iptables rate limit match");
81360 +
81361  /* The algorithm used is the Simple Token Bucket Filter (TBF)
81362   * see net/sched/sch_tbf.c in the linux source tree
81363   */
81364 @@ -134,4 +138,3 @@
81365  
81366  module_init(init);
81367  module_exit(fini);
81368 -MODULE_LICENSE("GPL");
81369 diff -Nru a/net/ipv4/netfilter/ipt_mac.c b/net/ipv4/netfilter/ipt_mac.c
81370 --- a/net/ipv4/netfilter/ipt_mac.c      Wed May 21 16:35:36 2003
81371 +++ b/net/ipv4/netfilter/ipt_mac.c      Sun Aug 24 05:00:28 2003
81372 @@ -6,6 +6,10 @@
81373  #include <linux/netfilter_ipv4/ipt_mac.h>
81374  #include <linux/netfilter_ipv4/ip_tables.h>
81375  
81376 +MODULE_LICENSE("GPL");
81377 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
81378 +MODULE_DESCRIPTION("iptables mac matching module");
81379 +
81380  static int
81381  match(const struct sk_buff *skb,
81382        const struct net_device *in,
81383 @@ -64,4 +68,3 @@
81384  
81385  module_init(init);
81386  module_exit(fini);
81387 -MODULE_LICENSE("GPL");
81388 diff -Nru a/net/ipv4/netfilter/ipt_mark.c b/net/ipv4/netfilter/ipt_mark.c
81389 --- a/net/ipv4/netfilter/ipt_mark.c     Wed May 21 16:35:36 2003
81390 +++ b/net/ipv4/netfilter/ipt_mark.c     Sun Aug 24 05:00:28 2003
81391 @@ -5,6 +5,10 @@
81392  #include <linux/netfilter_ipv4/ipt_mark.h>
81393  #include <linux/netfilter_ipv4/ip_tables.h>
81394  
81395 +MODULE_LICENSE("GPL");
81396 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
81397 +MODULE_DESCRIPTION("iptables mark matching module");
81398 +
81399  static int
81400  match(const struct sk_buff *skb,
81401        const struct net_device *in,
81402 @@ -50,4 +54,3 @@
81403  
81404  module_init(init);
81405  module_exit(fini);
81406 -MODULE_LICENSE("GPL");
81407 diff -Nru a/net/ipv4/netfilter/ipt_multiport.c b/net/ipv4/netfilter/ipt_multiport.c
81408 --- a/net/ipv4/netfilter/ipt_multiport.c        Wed May 21 16:35:36 2003
81409 +++ b/net/ipv4/netfilter/ipt_multiport.c        Sun Aug 24 05:00:28 2003
81410 @@ -8,6 +8,10 @@
81411  #include <linux/netfilter_ipv4/ipt_multiport.h>
81412  #include <linux/netfilter_ipv4/ip_tables.h>
81413  
81414 +MODULE_LICENSE("GPL");
81415 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
81416 +MODULE_DESCRIPTION("iptables multiple port match module");
81417 +
81418  #if 0
81419  #define duprintf(format, args...) printk(format , ## args)
81420  #else
81421 @@ -106,4 +110,3 @@
81422  
81423  module_init(init);
81424  module_exit(fini);
81425 -MODULE_LICENSE("GPL");
81426 diff -Nru a/net/ipv4/netfilter/ipt_owner.c b/net/ipv4/netfilter/ipt_owner.c
81427 --- a/net/ipv4/netfilter/ipt_owner.c    Wed Jun  4 17:57:08 2003
81428 +++ b/net/ipv4/netfilter/ipt_owner.c    Sun Aug 24 05:00:28 2003
81429 @@ -11,6 +11,10 @@
81430  #include <linux/netfilter_ipv4/ipt_owner.h>
81431  #include <linux/netfilter_ipv4/ip_tables.h>
81432  
81433 +MODULE_LICENSE("GPL");
81434 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
81435 +MODULE_DESCRIPTION("iptables owner match");
81436 +
81437  static int
81438  match_comm(const struct sk_buff *skb, const char *comm)
81439  {
81440 @@ -198,4 +202,3 @@
81441  
81442  module_init(init);
81443  module_exit(fini);
81444 -MODULE_LICENSE("GPL");
81445 diff -Nru a/net/ipv4/netfilter/ipt_physdev.c b/net/ipv4/netfilter/ipt_physdev.c
81446 --- a/net/ipv4/netfilter/ipt_physdev.c  Sat Aug  2 18:29:28 2003
81447 +++ b/net/ipv4/netfilter/ipt_physdev.c  Sat Aug 30 20:47:18 2003
81448 @@ -8,6 +8,10 @@
81449  #define MATCH   1
81450  #define NOMATCH 0
81451  
81452 +MODULE_LICENSE("GPL");
81453 +MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
81454 +MODULE_DESCRIPTION("iptables bridge physical device match module");
81455 +
81456  static int
81457  match(const struct sk_buff *skb,
81458        const struct net_device *in,
81459 @@ -120,4 +124,3 @@
81460  
81461  module_init(init);
81462  module_exit(fini);
81463 -MODULE_LICENSE("GPL");
81464 diff -Nru a/net/ipv4/netfilter/ipt_state.c b/net/ipv4/netfilter/ipt_state.c
81465 --- a/net/ipv4/netfilter/ipt_state.c    Wed May 21 16:35:36 2003
81466 +++ b/net/ipv4/netfilter/ipt_state.c    Sun Aug 24 05:00:28 2003
81467 @@ -7,6 +7,10 @@
81468  #include <linux/netfilter_ipv4/ip_tables.h>
81469  #include <linux/netfilter_ipv4/ipt_state.h>
81470  
81471 +MODULE_LICENSE("GPL");
81472 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
81473 +MODULE_DESCRIPTION("iptables connection tracking state match module");
81474 +
81475  static int
81476  match(const struct sk_buff *skb,
81477        const struct net_device *in,
81478 @@ -59,4 +63,3 @@
81479  
81480  module_init(init);
81481  module_exit(fini);
81482 -MODULE_LICENSE("GPL");
81483 diff -Nru a/net/ipv4/netfilter/ipt_tcpmss.c b/net/ipv4/netfilter/ipt_tcpmss.c
81484 --- a/net/ipv4/netfilter/ipt_tcpmss.c   Wed May 21 16:35:36 2003
81485 +++ b/net/ipv4/netfilter/ipt_tcpmss.c   Sun Aug 24 05:00:28 2003
81486 @@ -8,6 +8,10 @@
81487  
81488  #define TH_SYN 0x02
81489  
81490 +MODULE_LICENSE("GPL");
81491 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
81492 +MODULE_DESCRIPTION("iptables TCP MSS match module");
81493 +
81494  /* Returns 1 if the mss option is set and matched by the range, 0 otherwise */
81495  static inline int
81496  mssoption_match(u_int16_t min, u_int16_t max,
81497 @@ -117,4 +121,3 @@
81498  
81499  module_init(init);
81500  module_exit(fini);
81501 -MODULE_LICENSE("GPL");
81502 diff -Nru a/net/ipv4/netfilter/ipt_tos.c b/net/ipv4/netfilter/ipt_tos.c
81503 --- a/net/ipv4/netfilter/ipt_tos.c      Wed May 21 16:35:36 2003
81504 +++ b/net/ipv4/netfilter/ipt_tos.c      Sun Aug 24 05:00:28 2003
81505 @@ -5,6 +5,9 @@
81506  #include <linux/netfilter_ipv4/ipt_tos.h>
81507  #include <linux/netfilter_ipv4/ip_tables.h>
81508  
81509 +MODULE_LICENSE("GPL");
81510 +MODULE_DESCRIPTION("iptables TOS match module");
81511 +
81512  static int
81513  match(const struct sk_buff *skb,
81514        const struct net_device *in,
81515 @@ -50,4 +53,3 @@
81516  
81517  module_init(init);
81518  module_exit(fini);
81519 -MODULE_LICENSE("GPL");
81520 diff -Nru a/net/ipv4/netfilter/ipt_unclean.c b/net/ipv4/netfilter/ipt_unclean.c
81521 --- a/net/ipv4/netfilter/ipt_unclean.c  Wed May 21 16:35:36 2003
81522 +++ /dev/null   Wed Dec 31 16:00:00 1969
81523 @@ -1,610 +0,0 @@
81524 -/* Kernel module to match suspect packets. */
81525 -#include <linux/module.h>
81526 -#include <linux/skbuff.h>
81527 -#include <linux/ip.h>
81528 -#include <linux/udp.h>
81529 -#include <linux/tcp.h>
81530 -#include <linux/icmp.h>
81531 -#include <net/checksum.h>
81532 -
81533 -#include <linux/netfilter_ipv4/ip_tables.h>
81534 -
81535 -#define limpk(format, args...)                                          \
81536 -do {                                                                    \
81537 -       if (net_ratelimit())                                             \
81538 -               printk("ipt_unclean: %s" format,                         \
81539 -                      embedded ? "(embedded packet) " : "" , ## args);  \
81540 -} while(0)
81541 -
81542 -enum icmp_error_status
81543 -{
81544 -       ICMP_MAY_BE_ERROR,
81545 -       ICMP_IS_ERROR,
81546 -       ICMP_NOT_ERROR
81547 -};
81548 -
81549 -struct icmp_info
81550 -{
81551 -       size_t min_len, max_len;
81552 -       enum icmp_error_status err;
81553 -       u_int8_t min_code, max_code;
81554 -};
81555 -
81556 -static int
81557 -check_ip(const struct sk_buff *skb, unsigned int offset);
81558 -
81559 -/* ICMP-specific checks. */
81560 -static int
81561 -check_icmp(const struct sk_buff *skb,
81562 -          unsigned int offset,
81563 -          unsigned int fragoff,
81564 -          int more_frags,
81565 -          int embedded)
81566 -{
81567 -       struct icmphdr icmph;
81568 -       static struct icmp_info info[]
81569 -               = { [ICMP_ECHOREPLY]
81570 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
81571 -                   [ICMP_DEST_UNREACH]
81572 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 15 },
81573 -                   [ICMP_SOURCE_QUENCH]
81574 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 0 },
81575 -                   [ICMP_REDIRECT]
81576 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 3 },
81577 -                   [ICMP_ECHO]
81578 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0  },
81579 -                   /* Router advertisement. */
81580 -                   [9]
81581 -                   = { 8, 8 + 255 * 8, ICMP_NOT_ERROR, 0, 0 },
81582 -                   /* Router solicitation. */
81583 -                   [10]
81584 -                   = { 8, 8, ICMP_NOT_ERROR, 0, 0 },
81585 -                   [ICMP_TIME_EXCEEDED]
81586 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 1  },
81587 -                   [ICMP_PARAMETERPROB]
81588 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 1 },
81589 -                   [ICMP_TIMESTAMP]
81590 -                   = { 20, 20, ICMP_NOT_ERROR, 0, 0 },
81591 -                   [ICMP_TIMESTAMPREPLY]
81592 -                   = { 20, 20, ICMP_NOT_ERROR, 0, 0 },
81593 -                   [ICMP_INFO_REQUEST]
81594 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
81595 -                   [ICMP_INFO_REPLY]
81596 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
81597 -                   [ICMP_ADDRESS]
81598 -                   = { 12, 12, ICMP_NOT_ERROR, 0, 0 },
81599 -                   [ICMP_ADDRESSREPLY]
81600 -                   = { 12, 12, ICMP_NOT_ERROR, 0, 0 } };
81601 -
81602 -       /* Can't do anything if it's a fragment. */
81603 -       if (fragoff)
81604 -               return 1;
81605 -
81606 -       /* CHECK: Must have whole header.. */
81607 -       if (skb_copy_bits(skb, offset, &icmph, sizeof(icmph)) < 0) {
81608 -               limpk("ICMP len=%u too short\n", skb->len - offset);
81609 -               return 0;
81610 -       }
81611 -
81612 -       /* If not embedded in an ICMP error already. */
81613 -       if (!embedded) {
81614 -               /* CHECK: Truncated ICMP (even if first fragment). */
81615 -               if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
81616 -                   && info[icmph.type].min_len != 0
81617 -                   && skb->len - offset < info[icmph.type].min_len) {
81618 -                       limpk("ICMP type %u len %u too short\n",
81619 -                             icmph.type, skb->len - offset);
81620 -                       return 0;
81621 -               }
81622 -
81623 -               /* CHECK: Check within known error ICMPs. */
81624 -               if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
81625 -                   && info[icmph.type].err == ICMP_IS_ERROR) {
81626 -                       /* Max IP header size = 60 */
81627 -                       char inner[60 + 8];
81628 -                       struct iphdr *inner_ip = (struct iphdr *)inner;
81629 -
81630 -                       /* CHECK: Embedded packet must be at least
81631 -                          length of iph + 8 bytes. */
81632 -                       if (skb_copy_bits(skb, offset + sizeof(icmph),
81633 -                                         inner, sizeof(struct iphdr)+8) < 0) {
81634 -                               limpk("ICMP error internal way too short\n");
81635 -                               return 0;
81636 -                       }
81637 -
81638 -                       /* iphhdr may actually be longer: still need 8
81639 -                           actual protocol bytes. */
81640 -                       if (offset + sizeof(icmph) + inner_ip->ihl*4 + 8
81641 -                           > skb->len) {
81642 -                               limpk("ICMP error internal too short\n");
81643 -                               return 0;
81644 -                       }
81645 -                       if (!check_ip(skb, offset + sizeof(icmph)))
81646 -                               return 0;
81647 -               }
81648 -       } else {
81649 -               /* CHECK: Can't embed ICMP unless known non-error. */
81650 -               if (icmph.type >= sizeof(info)/sizeof(struct icmp_info)
81651 -                   || info[icmph.type].err != ICMP_NOT_ERROR) {
81652 -                       limpk("ICMP type %u not embeddable\n",
81653 -                             icmph.type);
81654 -                       return 0;
81655 -               }
81656 -       }
81657 -
81658 -       /* CHECK: Invalid ICMP codes. */
81659 -       if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
81660 -           && (icmph.code < info[icmph.type].min_code
81661 -               || icmph.code > info[icmph.type].max_code)) {
81662 -               limpk("ICMP type=%u code=%u\n",
81663 -                     icmph.type, icmph.code);
81664 -               return 0;
81665 -       }
81666 -
81667 -       /* CHECK: Above maximum length. */
81668 -       if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
81669 -           && info[icmph.type].max_len != 0
81670 -           && skb->len - offset > info[icmph.type].max_len) {
81671 -               limpk("ICMP type=%u too long: %u bytes\n",
81672 -                     icmph.type, skb->len - offset);
81673 -               return 0;
81674 -       }
81675 -
81676 -       switch (icmph.type) {
81677 -       case ICMP_PARAMETERPROB: {
81678 -               /* CHECK: Problem param must be within error packet's
81679 -                * IP header. */
81680 -               u_int32_t arg = ntohl(icmph.un.gateway);
81681 -
81682 -               if (icmph.code == 0) {
81683 -                       /* We've already made sure it's long enough. */
81684 -                       struct iphdr iph;
81685 -                       skb_copy_bits(skb, offset + sizeof(icmph), &iph,
81686 -                                     sizeof(iph));
81687 -                       /* Code 0 means that upper 8 bits is pointer
81688 -                           to problem. */
81689 -                       if ((arg >> 24) >= iph.ihl*4) {
81690 -                               limpk("ICMP PARAMETERPROB ptr = %u\n",
81691 -                                     ntohl(icmph.un.gateway) >> 24);
81692 -                               return 0;
81693 -                       }
81694 -                       arg &= 0x00FFFFFF;
81695 -               }
81696 -
81697 -               /* CHECK: Rest must be zero. */
81698 -               if (arg) {
81699 -                       limpk("ICMP PARAMETERPROB nonzero arg = %u\n",
81700 -                             arg);
81701 -                       return 0;
81702 -               }
81703 -               break;
81704 -       }
81705 -
81706 -       case ICMP_TIME_EXCEEDED:
81707 -       case ICMP_SOURCE_QUENCH:
81708 -               /* CHECK: Unused must be zero. */
81709 -               if (icmph.un.gateway != 0) {
81710 -                       limpk("ICMP type=%u unused = %u\n",
81711 -                             icmph.type, ntohl(icmph.un.gateway));
81712 -                       return 0;
81713 -               }
81714 -               break;
81715 -       }
81716 -
81717 -       return 1;
81718 -}
81719 -
81720 -/* UDP-specific checks. */
81721 -static int
81722 -check_udp(const struct sk_buff *skb,
81723 -         unsigned int offset,
81724 -         unsigned int fragoff,
81725 -         int more_frags,
81726 -         int embedded)
81727 -{
81728 -       struct udphdr udph;
81729 -
81730 -       /* Can't do anything if it's a fragment. */
81731 -       if (fragoff)
81732 -               return 1;
81733 -
81734 -       /* CHECK: Must cover UDP header. */
81735 -       if (skb_copy_bits(skb, offset, &udph, sizeof(udph)) < 0) {
81736 -               limpk("UDP len=%u too short\n", skb->len - offset);
81737 -               return 0;
81738 -       }
81739 -
81740 -       /* CHECK: Destination port can't be zero. */
81741 -       if (!udph.dest) {
81742 -               limpk("UDP zero destination port\n");
81743 -               return 0;
81744 -       }
81745 -
81746 -       if (!more_frags) {
81747 -               if (!embedded) {
81748 -                       /* CHECK: UDP length must match. */
81749 -                       if (ntohs(udph.len) != skb->len - offset) {
81750 -                               limpk("UDP len too short %u vs %u\n",
81751 -                                     ntohs(udph.len), skb->len - offset);
81752 -                               return 0;
81753 -                       }
81754 -               } else {
81755 -                       /* CHECK: UDP length be >= this truncated pkt. */
81756 -                       if (ntohs(udph.len) < skb->len - offset) {
81757 -                               limpk("UDP len too long %u vs %u\n",
81758 -                                     ntohs(udph.len), skb->len - offset);
81759 -                               return 0;
81760 -                       }
81761 -               }
81762 -       } else {
81763 -               /* CHECK: UDP length must be > this frag's length. */
81764 -               if (ntohs(udph.len) <= skb->len - offset) {
81765 -                       limpk("UDP fragment len too short %u vs %u\n",
81766 -                             ntohs(udph.len), skb->len - offset);
81767 -                       return 0;
81768 -               }
81769 -       }
81770 -
81771 -       return 1;
81772 -}
81773 -
81774 -/* TCP-specific checks. */
81775 -static int
81776 -check_tcp(const struct sk_buff *skb,
81777 -         unsigned int offset,
81778 -         unsigned int fragoff,
81779 -         int more_frags,
81780 -         int embedded)
81781 -{
81782 -       struct tcphdr tcph; 
81783 -       unsigned char opt[15 * 4 - sizeof(struct tcphdr)];
81784 -       u32 tcpflags;
81785 -       int end_of_options = 0;
81786 -       unsigned int i, optlen;
81787 -
81788 -       /* CHECK: Can't have offset=1: used to override TCP syn-checks. */
81789 -       /* In fact, this is caught below (offset < 516). */
81790 -
81791 -       /* Can't do anything if it's a fragment. */
81792 -       if (fragoff)
81793 -               return 1;
81794 -
81795 -       /* CHECK: Smaller than minimal TCP hdr. */
81796 -       if (skb_copy_bits(skb, offset, &tcph, sizeof(tcph)) < 0) {
81797 -               u16 ports[2];
81798 -
81799 -               if (!embedded) {
81800 -                       limpk("Packet length %u < TCP header.\n",
81801 -                             skb->len - offset);
81802 -                       return 0;
81803 -               }
81804 -
81805 -               /* Must have ports available (datalen >= 8), from
81806 -                   check_icmp which set embedded = 1 */
81807 -               /* CHECK: TCP ports inside ICMP error */
81808 -               skb_copy_bits(skb, offset, ports, sizeof(ports));
81809 -               if (!ports[0] || !ports[1]) {
81810 -                       limpk("Zero TCP ports %u/%u.\n",
81811 -                             htons(ports[0]), htons(ports[1]));
81812 -                       return 0;
81813 -               }
81814 -               return 1;
81815 -       }
81816 -
81817 -       /* CHECK: TCP header claims tiny size. */
81818 -       if (tcph.doff * 4 < sizeof(tcph)) {
81819 -               limpk("TCP header claims tiny size %u\n", tcph.doff * 4);
81820 -               return 0;
81821 -       }
81822 -
81823 -       /* CHECK: Packet smaller than actual TCP hdr. */
81824 -       optlen = tcph.doff*4 - sizeof(tcph);
81825 -       if (skb_copy_bits(skb, offset + sizeof(tcph), opt, optlen) < 0) {
81826 -               if (!embedded) {
81827 -                       limpk("Packet length %u < actual TCP header.\n",
81828 -                             skb->len - offset);
81829 -                       return 0;
81830 -               } else
81831 -                       return 1;
81832 -       }
81833 -
81834 -       /* CHECK: TCP ports non-zero */
81835 -       if (!tcph.source || !tcph.dest) {
81836 -               limpk("Zero TCP ports %u/%u.\n",
81837 -                     htons(tcph.source), htons(tcph.dest));
81838 -               return 0;
81839 -       }
81840 -
81841 -       tcpflags = tcp_flag_word(&tcph);
81842 -
81843 -       /* CHECK: TCP reserved bits zero. */
81844 -       if (tcpflags & TCP_RESERVED_BITS) {
81845 -               limpk("TCP reserved bits not zero\n");
81846 -               return 0;
81847 -       }
81848 -
81849 -       tcpflags &= ~(TCP_DATA_OFFSET | TCP_FLAG_CWR | TCP_FLAG_ECE
81850 -                     | __constant_htonl(0x0000FFFF));
81851 -
81852 -       /* CHECK: TCP flags. */
81853 -       if (tcpflags != TCP_FLAG_SYN
81854 -           && tcpflags != (TCP_FLAG_SYN|TCP_FLAG_ACK)
81855 -           && tcpflags != TCP_FLAG_RST
81856 -           && tcpflags != (TCP_FLAG_RST|TCP_FLAG_ACK)
81857 -           && tcpflags != (TCP_FLAG_RST|TCP_FLAG_ACK|TCP_FLAG_PSH)
81858 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK)
81859 -           && tcpflags != TCP_FLAG_ACK
81860 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_PSH)
81861 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_URG)
81862 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_URG|TCP_FLAG_PSH)
81863 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_PSH)
81864 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_URG)
81865 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_URG
81866 -                           |TCP_FLAG_PSH)) {
81867 -               limpk("TCP flags bad: 0x%04X\n", ntohl(tcpflags) >> 16);
81868 -               return 0;
81869 -       }
81870 -
81871 -       for (i = 0; i < optlen; ) {
81872 -               switch (opt[i]) {
81873 -               case 0:
81874 -                       end_of_options = 1;
81875 -                       i++;
81876 -                       break;
81877 -               case 1:
81878 -                       i++;
81879 -                       break;
81880 -               default:
81881 -                       /* CHECK: options after EOO. */
81882 -                       if (end_of_options) {
81883 -                               limpk("TCP option %u after end\n",
81884 -                                     opt[i]);
81885 -                               return 0;
81886 -                       }
81887 -                       /* CHECK: options at tail. */
81888 -                       else if (i+1 >= optlen) {
81889 -                               limpk("TCP option %u at tail\n",
81890 -                                     opt[i]);
81891 -                               return 0;
81892 -                       }
81893 -                       /* CHECK: zero-length options. */
81894 -                       else if (opt[i+1] == 0) {
81895 -                               limpk("TCP option %u 0 len\n",
81896 -                                     opt[i]);
81897 -                               return 0;
81898 -                       }
81899 -                       /* CHECK: oversize options. */
81900 -                       else if (i + opt[i+1] > optlen) {
81901 -                               limpk("TCP option %u at %u too long\n",
81902 -                                     (unsigned int) opt[i], i);
81903 -                               return 0;
81904 -                       }
81905 -                       /* Move to next option */
81906 -                       i += opt[i+1];
81907 -               }
81908 -       }
81909 -
81910 -       return 1;
81911 -}
81912 -
81913 -/* Returns 1 if ok */
81914 -/* Standard IP checks. */
81915 -static int
81916 -check_ip(const struct sk_buff *skb, unsigned int offset)
81917 -{
81918 -       int end_of_options = 0;
81919 -       unsigned int datalen, optlen;
81920 -       unsigned int i;
81921 -       unsigned int fragoff;
81922 -       struct iphdr iph;
81923 -       unsigned char opt[15 * 4 - sizeof(struct iphdr)];
81924 -       int embedded = offset;
81925 -
81926 -       /* Should only happen for local outgoing raw-socket packets. */
81927 -       /* CHECK: length >= ip header. */
81928 -       if (skb_copy_bits(skb, offset, &iph, sizeof(iph)) < 0) {
81929 -               limpk("Packet length %u < IP header.\n", skb->len - offset);
81930 -               return 0;
81931 -       }
81932 -       if (iph.ihl * 4 < sizeof(iph)) {
81933 -               limpk("IP len %u < minimum IP header.\n", iph.ihl*4);
81934 -               return 0;
81935 -       }
81936 -
81937 -       optlen = iph.ihl * 4 - sizeof(iph);
81938 -       if (skb_copy_bits(skb, offset+sizeof(struct iphdr), opt, optlen)<0) {
81939 -               limpk("Packet length %u < IP header %u.\n",
81940 -                     skb->len - offset, iph.ihl * 4);
81941 -               return 0;
81942 -       }
81943 -
81944 -       fragoff = (ntohs(iph.frag_off) & IP_OFFSET);
81945 -       datalen = skb->len - (offset + sizeof(struct iphdr) + optlen);
81946 -
81947 -       /* CHECK: Embedded fragment. */
81948 -       if (offset && fragoff) {
81949 -               limpk("Embedded fragment.\n");
81950 -               return 0;
81951 -       }
81952 -
81953 -       for (i = 0; i < optlen; ) {
81954 -               switch (opt[i]) {
81955 -               case 0:
81956 -                       end_of_options = 1;
81957 -                       i++;
81958 -                       break;
81959 -               case 1:
81960 -                       i++;
81961 -                       break;
81962 -               default:
81963 -                       /* CHECK: options after EOO. */
81964 -                       if (end_of_options) {
81965 -                               limpk("IP option %u after end\n",
81966 -                                     opt[i]);
81967 -                               return 0;
81968 -                       }
81969 -                       /* CHECK: options at tail. */
81970 -                       else if (i+1 >= optlen) {
81971 -                               limpk("IP option %u at tail\n",
81972 -                                     opt[i]);
81973 -                               return 0;
81974 -                       }
81975 -                       /* CHECK: zero-length or one-length options. */
81976 -                       else if (opt[i+1] < 2) {
81977 -                               limpk("IP option %u %u len\n",
81978 -                                     opt[i], opt[i+1]);
81979 -                               return 0;
81980 -                       }
81981 -                       /* CHECK: oversize options. */
81982 -                       else if (i + opt[i+1] > optlen) {
81983 -                               limpk("IP option %u at %u too long\n",
81984 -                                     opt[i], i);
81985 -                               return 0;
81986 -                       }
81987 -                       /* Move to next option */
81988 -                       i += opt[i+1];
81989 -               }
81990 -       }
81991 -
81992 -       /* Fragment checks. */
81993 -
81994 -       /* CHECK: More fragments, but doesn't fill 8-byte boundary. */
81995 -       if ((ntohs(iph.frag_off) & IP_MF)
81996 -           && (ntohs(iph.tot_len) % 8) != 0) {
81997 -               limpk("Truncated fragment %u long.\n", ntohs(iph.tot_len));
81998 -               return 0;
81999 -       }
82000 -
82001 -       /* CHECK: Oversize fragment a-la Ping of Death. */
82002 -       if (fragoff * 8 + datalen > 65535) {
82003 -               limpk("Oversize fragment to %u.\n", fragoff * 8);
82004 -               return 0;
82005 -       }
82006 -
82007 -       /* CHECK: DF set and fragoff or MF set. */
82008 -       if ((ntohs(iph.frag_off) & IP_DF)
82009 -           && (fragoff || (ntohs(iph.frag_off) & IP_MF))) {
82010 -               limpk("DF set and offset=%u, MF=%u.\n",
82011 -                     fragoff, ntohs(iph.frag_off) & IP_MF);
82012 -               return 0;
82013 -       }
82014 -
82015 -       /* CHECK: Zero-sized fragments. */
82016 -       if ((fragoff || (ntohs(iph.frag_off) & IP_MF))
82017 -           && datalen == 0) {
82018 -               limpk("Zero size fragment offset=%u\n", fragoff);
82019 -               return 0;
82020 -       }
82021 -
82022 -       /* Note: we can have even middle fragments smaller than this:
82023 -          consider a large packet passing through a 600MTU then
82024 -          576MTU link: this gives a fragment of 24 data bytes.  But
82025 -          everyone packs fragments largest first, hence a fragment
82026 -          can't START before 576 - MAX_IP_HEADER_LEN. */
82027 -
82028 -       /* Used to be min-size 576: I recall Alan Cox saying ax25 goes
82029 -          down to 128 (576 taken from RFC 791: All hosts must be
82030 -          prepared to accept datagrams of up to 576 octets).  Use 128
82031 -          here. */
82032 -#define MIN_LIKELY_MTU 128
82033 -       /* CHECK: Min size of first frag = 128. */
82034 -       if ((ntohs(iph.frag_off) & IP_MF)
82035 -           && fragoff == 0
82036 -           && ntohs(iph.tot_len) < MIN_LIKELY_MTU) {
82037 -               limpk("First fragment size %u < %u\n", ntohs(iph.tot_len),
82038 -                     MIN_LIKELY_MTU);
82039 -               return 0;
82040 -       }
82041 -
82042 -       /* CHECK: Min offset of frag = 128 - IP hdr len. */
82043 -       if (fragoff && fragoff * 8 < MIN_LIKELY_MTU - iph.ihl * 4) {
82044 -               limpk("Fragment starts at %u < %u\n", fragoff * 8,
82045 -                     MIN_LIKELY_MTU - iph.ihl * 4);
82046 -               return 0;
82047 -       }
82048 -
82049 -       /* CHECK: Protocol specification non-zero. */
82050 -       if (iph.protocol == 0) {
82051 -               limpk("Zero protocol\n");
82052 -               return 0;
82053 -       }
82054 -
82055 -       /* FIXME: This is already checked for in "Oversize fragment"
82056 -           above --RR */
82057 -       /* CHECK: Do not use what is unused.
82058 -        * First bit of fragmentation flags should be unused.
82059 -        * May be used by OS fingerprinting tools.
82060 -        * 04 Jun 2002, Maciej Soltysiak, solt@dns.toxicfilms.tv
82061 -        */
82062 -       if (ntohs(iph.frag_off)>>15) {
82063 -               limpk("IP unused bit set\n");
82064 -               return 0;
82065 -       }
82066 -
82067 -       /* Per-protocol checks. */
82068 -       switch (iph.protocol) {
82069 -       case IPPROTO_ICMP:
82070 -               return check_icmp(skb, offset + iph.ihl*4, fragoff,
82071 -                                 (ntohs(iph.frag_off) & IP_MF),
82072 -                                 embedded);
82073 -
82074 -       case IPPROTO_UDP:
82075 -               return check_udp(skb, offset + iph.ihl*4, fragoff,
82076 -                                (ntohs(iph.frag_off) & IP_MF),
82077 -                                embedded);
82078 -
82079 -       case IPPROTO_TCP:
82080 -               return check_tcp(skb, offset + iph.ihl*4, fragoff,
82081 -                                (ntohs(iph.frag_off) & IP_MF),
82082 -                                embedded);
82083 -       default:
82084 -               /* Ignorance is bliss. */
82085 -               return 1;
82086 -       }
82087 -}
82088 -
82089 -static int
82090 -match(const struct sk_buff *skb,
82091 -      const struct net_device *in,
82092 -      const struct net_device *out,
82093 -      const void *matchinfo,
82094 -      int offset,
82095 -      int *hotdrop)
82096 -{
82097 -       return !check_ip(skb, 0);
82098 -}
82099 -
82100 -/* Called when user tries to insert an entry of this type. */
82101 -static int
82102 -checkentry(const char *tablename,
82103 -          const struct ipt_ip *ip,
82104 -          void *matchinfo,
82105 -          unsigned int matchsize,
82106 -          unsigned int hook_mask)
82107 -{
82108 -       if (matchsize != IPT_ALIGN(0))
82109 -               return 0;
82110 -
82111 -       return 1;
82112 -}
82113 -
82114 -static struct ipt_match unclean_match = {
82115 -       .name           = "unclean",
82116 -       .match          = &match,
82117 -       .checkentry     = &checkentry,
82118 -       .me             = THIS_MODULE,
82119 -};
82120 -
82121 -static int __init init(void)
82122 -{
82123 -       return ipt_register_match(&unclean_match);
82124 -}
82125 -
82126 -static void __exit fini(void)
82127 -{
82128 -       ipt_unregister_match(&unclean_match);
82129 -}
82130 -
82131 -module_init(init);
82132 -module_exit(fini);
82133 -MODULE_LICENSE("GPL");
82134 diff -Nru a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
82135 --- a/net/ipv4/netfilter/iptable_filter.c       Wed Jun 11 23:34:58 2003
82136 +++ b/net/ipv4/netfilter/iptable_filter.c       Sun Aug 24 05:00:28 2003
82137 @@ -6,6 +6,10 @@
82138  #include <linux/module.h>
82139  #include <linux/netfilter_ipv4/ip_tables.h>
82140  
82141 +MODULE_LICENSE("GPL");
82142 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
82143 +MODULE_DESCRIPTION("iptables filter table");
82144 +
82145  #define FILTER_VALID_HOOKS ((1 << NF_IP_LOCAL_IN) | (1 << NF_IP_FORWARD) | (1 << NF_IP_LOCAL_OUT))
82146  
82147  /* Standard entry. */
82148 @@ -200,4 +204,3 @@
82149  
82150  module_init(init);
82151  module_exit(fini);
82152 -MODULE_LICENSE("GPL");
82153 diff -Nru a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
82154 --- a/net/ipv4/netfilter/iptable_mangle.c       Wed Jun 11 23:34:58 2003
82155 +++ b/net/ipv4/netfilter/iptable_mangle.c       Sun Aug 24 05:00:28 2003
82156 @@ -14,6 +14,10 @@
82157  #include <net/route.h>
82158  #include <linux/ip.h>
82159  
82160 +MODULE_LICENSE("GPL");
82161 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
82162 +MODULE_DESCRIPTION("iptables mangle table");
82163 +
82164  #define MANGLE_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | \
82165                             (1 << NF_IP_LOCAL_IN) | \
82166                             (1 << NF_IP_FORWARD) | \
82167 @@ -267,4 +271,3 @@
82168  
82169  module_init(init);
82170  module_exit(fini);
82171 -MODULE_LICENSE("GPL");
82172 diff -Nru a/net/ipv4/route.c b/net/ipv4/route.c
82173 --- a/net/ipv4/route.c  Sat Aug 16 12:08:34 2003
82174 +++ b/net/ipv4/route.c  Thu Aug 28 00:02:15 2003
82175 @@ -312,49 +312,6 @@
82176         return 0;
82177  }
82178  
82179 -static int rt_cache_stat_get_info(char *buffer, char **start, off_t offset, int length)
82180 -{
82181 -       unsigned int dst_entries = atomic_read(&ipv4_dst_ops.entries);
82182 -       int i;
82183 -       int len = 0;
82184 -
82185 -       for (i = 0; i < NR_CPUS; i++) {
82186 -               if (!cpu_possible(i))
82187 -                       continue;
82188 -               len += sprintf(buffer+len, "%08x  %08x %08x %08x %08x %08x %08x %08x  %08x %08x %08x %08x %08x %08x %08x %08x %08x \n",
82189 -                              dst_entries,                    
82190 -                              per_cpu_ptr(rt_cache_stat, i)->in_hit,
82191 -                              per_cpu_ptr(rt_cache_stat, i)->in_slow_tot,
82192 -                              per_cpu_ptr(rt_cache_stat, i)->in_slow_mc,
82193 -                              per_cpu_ptr(rt_cache_stat, i)->in_no_route,
82194 -                              per_cpu_ptr(rt_cache_stat, i)->in_brd,
82195 -                              per_cpu_ptr(rt_cache_stat, i)->in_martian_dst,
82196 -                              per_cpu_ptr(rt_cache_stat, i)->in_martian_src,
82197 -
82198 -                              per_cpu_ptr(rt_cache_stat, i)->out_hit,
82199 -                              per_cpu_ptr(rt_cache_stat, i)->out_slow_tot,
82200 -                              per_cpu_ptr(rt_cache_stat, i)->out_slow_mc, 
82201 -
82202 -                              per_cpu_ptr(rt_cache_stat, i)->gc_total,
82203 -                              per_cpu_ptr(rt_cache_stat, i)->gc_ignored,
82204 -                              per_cpu_ptr(rt_cache_stat, i)->gc_goal_miss,
82205 -                              per_cpu_ptr(rt_cache_stat, i)->gc_dst_overflow,
82206 -                              per_cpu_ptr(rt_cache_stat, i)->in_hlist_search,
82207 -                              per_cpu_ptr(rt_cache_stat, i)->out_hlist_search
82208 -
82209 -                       );
82210 -       }
82211 -       len -= offset;
82212 -
82213 -       if (len > length)
82214 -               len = length;
82215 -       if (len < 0)
82216 -               len = 0;
82217 -
82218 -       *start = buffer + offset;
82219 -       return len;
82220 -}
82221 -
82222  static struct seq_operations rt_cache_seq_ops = {
82223         .start  = rt_cache_seq_start,
82224         .next   = rt_cache_seq_next,
82225 @@ -391,22 +348,89 @@
82226         .release = seq_release_private,
82227  };
82228  
82229 -int __init rt_cache_proc_init(void)
82230 +
82231 +static void *rt_cpu_seq_start(struct seq_file *seq, loff_t *pos)
82232  {
82233 -       int rc = 0;
82234 -       struct proc_dir_entry *p = create_proc_entry("rt_cache", S_IRUGO,
82235 -                                                    proc_net);
82236 -       if (p)
82237 -               p->proc_fops = &rt_cache_seq_fops;
82238 -       else
82239 -               rc = -ENOMEM;
82240 -       return rc;
82241 +       int cpu;
82242 +
82243 +       for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
82244 +               if (!cpu_possible(cpu))
82245 +                       continue;
82246 +               *pos = cpu;
82247 +               return per_cpu_ptr(rt_cache_stat, cpu);
82248 +       }
82249 +       return NULL;
82250 +}
82251 +
82252 +static void *rt_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
82253 +{
82254 +       int cpu;
82255 +
82256 +       for (cpu = *pos + 1; cpu < NR_CPUS; ++cpu) {
82257 +               if (!cpu_possible(cpu))
82258 +                       continue;
82259 +               *pos = cpu;
82260 +               return per_cpu_ptr(rt_cache_stat, cpu);
82261 +       }
82262 +       return NULL;
82263 +       
82264  }
82265  
82266 -void __init rt_cache_proc_exit(void)
82267 +static void rt_cpu_seq_stop(struct seq_file *seq, void *v)
82268  {
82269 -       remove_proc_entry("rt_cache", proc_net);
82270 +
82271  }
82272 +
82273 +static int rt_cpu_seq_show(struct seq_file *seq, void *v)
82274 +{
82275 +       struct rt_cache_stat *st = v;
82276 +       
82277 +       seq_printf(seq,"%08x  %08x %08x %08x %08x %08x %08x %08x "
82278 +                  " %08x %08x %08x %08x %08x %08x %08x %08x %08x \n",
82279 +                  atomic_read(&ipv4_dst_ops.entries),
82280 +                  st->in_hit,
82281 +                  st->in_slow_tot,
82282 +                  st->in_slow_mc,
82283 +                  st->in_no_route,
82284 +                  st->in_brd,
82285 +                  st->in_martian_dst,
82286 +                  st->in_martian_src,
82287 +
82288 +                  st->out_hit,
82289 +                  st->out_slow_tot,
82290 +                  st->out_slow_mc, 
82291 +
82292 +                  st->gc_total,
82293 +                  st->gc_ignored,
82294 +                  st->gc_goal_miss,
82295 +                  st->gc_dst_overflow,
82296 +                  st->in_hlist_search,
82297 +                  st->out_hlist_search
82298 +               );
82299 +       return 0;
82300 +}
82301 +
82302 +static struct seq_operations rt_cpu_seq_ops = {
82303 +       .start  = rt_cpu_seq_start,
82304 +       .next   = rt_cpu_seq_next,
82305 +       .stop   = rt_cpu_seq_stop,
82306 +       .show   = rt_cpu_seq_show,
82307 +};
82308 +
82309 +
82310 +static int rt_cpu_seq_open(struct inode *inode, struct file *file)
82311 +{
82312 +       return seq_open(file, &rt_cpu_seq_ops);
82313 +}
82314 +
82315 +static struct file_operations rt_cpu_seq_fops = {
82316 +       .owner   = THIS_MODULE,
82317 +       .open    = rt_cpu_seq_open,
82318 +       .read    = seq_read,
82319 +       .llseek  = seq_lseek,
82320 +       .release = seq_release_private,
82321 +};
82322 +
82323  #endif /* CONFIG_PROC_FS */
82324    
82325  static __inline__ void rt_free(struct rtable *rt)
82326 @@ -2779,11 +2803,12 @@
82327         add_timer(&rt_secret_timer);
82328  
82329  #ifdef CONFIG_PROC_FS
82330 -       if (rt_cache_proc_init())
82331 +       if (!proc_net_fops_create("rt_cache", S_IRUGO, &rt_cache_seq_fops) ||
82332 +           !proc_net_fops_create("rt_cache_stat", S_IRUGO, &rt_cpu_seq_fops))
82333                 goto out_enomem;
82334 -       proc_net_create ("rt_cache_stat", 0, rt_cache_stat_get_info);
82335 +
82336  #ifdef CONFIG_NET_CLS_ROUTE
82337 -       create_proc_read_entry("net/rt_acct", 0, 0, ip_rt_acct_read, NULL);
82338 +       create_proc_read_entry("rt_acct", 0, proc_net, ip_rt_acct_read, NULL);
82339  #endif
82340  #endif
82341  #ifdef CONFIG_XFRM
82342 diff -Nru a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
82343 --- a/net/ipv6/af_inet6.c       Sat Aug  2 18:29:28 2003
82344 +++ b/net/ipv6/af_inet6.c       Tue Sep  2 04:38:10 2003
82345 @@ -893,3 +893,5 @@
82346  }
82347  module_exit(inet6_exit);
82348  #endif /* MODULE */
82349 +
82350 +MODULE_ALIAS_NETPROTO(PF_INET6);
82351 diff -Nru a/net/ipv6/icmp.c b/net/ipv6/icmp.c
82352 --- a/net/ipv6/icmp.c   Mon Aug 18 03:38:34 2003
82353 +++ b/net/ipv6/icmp.c   Mon Sep  1 01:38:00 2003
82354 @@ -70,12 +70,14 @@
82355  DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
82356  
82357  /*
82358 - *     ICMP socket(s) for flow control.
82359 + *     The ICMP socket(s). This is the most convenient way to flow control
82360 + *     our ICMP output as well as maintain a clean interface throughout
82361 + *     all layers. All Socketless IP sends will soon be gone.
82362 + *
82363 + *     On SMP we have one ICMP socket per-cpu.
82364   */
82365 -
82366 -/* XXX We can't use per_cpu because this can be modular... */
82367 -static struct socket *__icmpv6_socket[NR_CPUS];
82368 -#define icmpv6_socket  __icmpv6_socket[smp_processor_id()]
82369 +static DEFINE_PER_CPU(struct socket *, __icmpv6_socket) = NULL;
82370 +#define icmpv6_socket  __get_cpu_var(__icmpv6_socket)
82371  
82372  static int icmpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp);
82373  
82374 @@ -93,11 +95,19 @@
82375         __u32                   csum;
82376  };
82377  
82378 -static __inline__ void icmpv6_xmit_lock(void)
82379 +static __inline__ int icmpv6_xmit_lock(void)
82380  {
82381         local_bh_disable();
82382 -       if (unlikely(!spin_trylock(&icmpv6_socket->sk->sk_lock.slock)))
82383 -               BUG();
82384 +
82385 +       if (unlikely(!spin_trylock(&icmpv6_socket->sk->sk_lock.slock))) {
82386 +               /* This can happen if the output path (f.e. SIT or
82387 +                * ip6ip6 tunnel) signals dst_link_failure() for an
82388 +                * outgoing ICMP6 packet.
82389 +                */
82390 +               local_bh_enable();
82391 +               return 1;
82392 +       }
82393 +       return 0;
82394  }
82395  
82396  static __inline__ void icmpv6_xmit_unlock(void)
82397 @@ -342,7 +352,8 @@
82398         fl.fl_icmp_type = type;
82399         fl.fl_icmp_code = code;
82400  
82401 -       icmpv6_xmit_lock();
82402 +       if (icmpv6_xmit_lock())
82403 +               return;
82404  
82405         if (!icmpv6_xrlim_allow(sk, type, &fl))
82406                 goto out;
82407 @@ -432,7 +443,8 @@
82408         fl.oif = skb->dev->ifindex;
82409         fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
82410  
82411 -       icmpv6_xmit_lock();
82412 +       if (icmpv6_xmit_lock())
82413 +               return;
82414  
82415         if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))
82416                 fl.oif = np->mcast_oif;
82417 @@ -657,33 +669,23 @@
82418  int __init icmpv6_init(struct net_proto_family *ops)
82419  {
82420         struct sock *sk;
82421 -       int i;
82422 +       int err, i, j;
82423  
82424         for (i = 0; i < NR_CPUS; i++) {
82425 -               int err;
82426 -
82427                 if (!cpu_possible(i))
82428                         continue;
82429  
82430                 err = sock_create(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6,
82431 -                                 &__icmpv6_socket[i]);
82432 +                                 &per_cpu(__icmpv6_socket, i));
82433                 if (err < 0) {
82434 -                       int j;
82435 -
82436                         printk(KERN_ERR
82437                                "Failed to initialize the ICMP6 control socket "
82438                                "(err %d).\n",
82439                                err);
82440 -                       for (j = 0; j < i; j++) {
82441 -                               if (!cpu_possible(j))
82442 -                                       continue;
82443 -                               sock_release(__icmpv6_socket[j]);
82444 -                               __icmpv6_socket[j] = NULL; /* for safety */
82445 -                       }
82446 -                       return err;
82447 +                       goto fail;
82448                 }
82449  
82450 -               sk = __icmpv6_socket[i]->sk;
82451 +               sk = per_cpu(__icmpv6_socket, i)->sk;
82452                 sk->sk_allocation = GFP_ATOMIC;
82453                 sk->sk_sndbuf = SK_WMEM_MAX * 2;
82454                 sk->sk_prot->unhash(sk);
82455 @@ -692,16 +694,20 @@
82456  
82457         if (inet6_add_protocol(&icmpv6_protocol, IPPROTO_ICMPV6) < 0) {
82458                 printk(KERN_ERR "Failed to register ICMP6 protocol\n");
82459 -               for (i = 0; i < NR_CPUS; i++) {
82460 -                       if (!cpu_possible(i))
82461 -                               continue;
82462 -                       sock_release(__icmpv6_socket[i]);
82463 -                       __icmpv6_socket[i] = NULL;
82464 -               }
82465 -               return -EAGAIN;
82466 +               err = -EAGAIN;
82467 +               goto fail;
82468         }
82469  
82470         return 0;
82471 +
82472 + fail:
82473 +       for (j = 0; j < i; j++) {
82474 +               if (!cpu_possible(j))
82475 +                       continue;
82476 +               sock_release(per_cpu(__icmpv6_socket, j));
82477 +       }
82478 +
82479 +       return err;
82480  }
82481  
82482  void icmpv6_cleanup(void)
82483 @@ -711,8 +717,7 @@
82484         for (i = 0; i < NR_CPUS; i++) {
82485                 if (!cpu_possible(i))
82486                         continue;
82487 -               sock_release(__icmpv6_socket[i]);
82488 -               __icmpv6_socket[i] = NULL; /* For safety. */
82489 +               sock_release(per_cpu(__icmpv6_socket, i));
82490         }
82491         inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
82492  }
82493 diff -Nru a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
82494 --- a/net/ipv6/ip6_flowlabel.c  Tue Jul  8 17:51:54 2003
82495 +++ b/net/ipv6/ip6_flowlabel.c  Mon Sep  1 07:38:18 2003
82496 @@ -49,7 +49,8 @@
82497  static atomic_t fl_size = ATOMIC_INIT(0);
82498  static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1];
82499  
82500 -static struct timer_list ip6_fl_gc_timer;
82501 +static void ip6_fl_gc(unsigned long dummy);
82502 +static struct timer_list ip6_fl_gc_timer = TIMER_INITIALIZER(ip6_fl_gc, 0, 0);
82503  
82504  /* FL hash table lock: it protects only of GC */
82505  
82506 @@ -93,10 +94,12 @@
82507  
82508  static void fl_release(struct ip6_flowlabel *fl)
82509  {
82510 +       write_lock_bh(&ip6_fl_lock);
82511 +
82512         fl->lastuse = jiffies;
82513         if (atomic_dec_and_test(&fl->users)) {
82514                 unsigned long ttd = fl->lastuse + fl->linger;
82515 -               if ((long)(ttd - fl->expires) > 0)
82516 +               if (time_after(ttd, fl->expires))
82517                         fl->expires = ttd;
82518                 ttd = fl->expires;
82519                 if (fl->opt && fl->share == IPV6_FL_S_EXCL) {
82520 @@ -104,11 +107,12 @@
82521                         fl->opt = NULL;
82522                         kfree(opt);
82523                 }
82524 -               if (!del_timer(&ip6_fl_gc_timer) ||
82525 -                   (long)(ip6_fl_gc_timer.expires - ttd) > 0)
82526 -                       ip6_fl_gc_timer.expires = ttd;
82527 -               add_timer(&ip6_fl_gc_timer);
82528 +               if (!timer_pending(&ip6_fl_gc_timer) ||
82529 +                   time_after(ip6_fl_gc_timer.expires, ttd))
82530 +                       mod_timer(&ip6_fl_gc_timer, ttd);
82531         }
82532 +
82533 +       write_unlock_bh(&ip6_fl_lock);
82534  }
82535  
82536  static void ip6_fl_gc(unsigned long dummy)
82537 @@ -125,16 +129,16 @@
82538                 while ((fl=*flp) != NULL) {
82539                         if (atomic_read(&fl->users) == 0) {
82540                                 unsigned long ttd = fl->lastuse + fl->linger;
82541 -                               if ((long)(ttd - fl->expires) > 0)
82542 +                               if (time_after(ttd, fl->expires))
82543                                         fl->expires = ttd;
82544                                 ttd = fl->expires;
82545 -                               if ((long)(now - ttd) >= 0) {
82546 +                               if (time_after_eq(now, ttd)) {
82547                                         *flp = fl->next;
82548                                         fl_free(fl);
82549                                         atomic_dec(&fl_size);
82550                                         continue;
82551                                 }
82552 -                               if (!sched || (long)(ttd - sched) < 0)
82553 +                               if (!sched || time_before(ttd, sched))
82554                                         sched = ttd;
82555                         }
82556                         flp = &fl->next;
82557 @@ -245,7 +249,7 @@
82558         return opt_space;
82559  }
82560  
82561 -static __u32 check_linger(__u16 ttl)
82562 +static unsigned long check_linger(unsigned long ttl)
82563  {
82564         if (ttl < FL_MIN_LINGER)
82565                 return FL_MIN_LINGER*HZ;
82566 @@ -254,7 +258,7 @@
82567         return ttl*HZ;
82568  }
82569  
82570 -static int fl6_renew(struct ip6_flowlabel *fl, unsigned linger, unsigned expires)
82571 +static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned long expires)
82572  {
82573         linger = check_linger(linger);
82574         if (!linger)
82575 @@ -263,11 +267,11 @@
82576         if (!expires)
82577                 return -EPERM;
82578         fl->lastuse = jiffies;
82579 -       if (fl->linger < linger)
82580 +       if (time_before(fl->linger, linger))
82581                 fl->linger = linger;
82582 -       if (expires < fl->linger)
82583 +       if (time_before(expires, fl->linger))
82584                 expires = fl->linger;
82585 -       if ((long)(fl->expires - (fl->lastuse+expires)) < 0)
82586 +       if (time_before(fl->expires, fl->lastuse + expires))
82587                 fl->expires = fl->lastuse + expires;
82588         return 0;
82589  }
82590 @@ -623,7 +627,7 @@
82591  {
82592         while(fl) {
82593                 seq_printf(seq,
82594 -                          "%05X %-1d %-6d %-6d %-6d %-8ld "
82595 +                          "%05X %-1d %-6d %-6d %-6ld %-8ld "
82596                            "%02x%02x%02x%02x%02x%02x%02x%02x "
82597                            "%-4d\n",
82598                            (unsigned)ntohl(fl->label),
82599 @@ -693,8 +697,6 @@
82600  #ifdef CONFIG_PROC_FS
82601         struct proc_dir_entry *p;
82602  #endif
82603 -       init_timer(&ip6_fl_gc_timer);
82604 -       ip6_fl_gc_timer.function = ip6_fl_gc;
82605  #ifdef CONFIG_PROC_FS
82606         p = create_proc_entry("ip6_flowlabel", S_IRUGO, proc_net);
82607         if (p)
82608 diff -Nru a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
82609 --- a/net/ipv6/ip6_output.c     Mon Aug 18 03:38:34 2003
82610 +++ b/net/ipv6/ip6_output.c     Mon Sep  1 01:44:26 2003
82611 @@ -876,7 +876,7 @@
82612         /* Connection association is same as pre-frag packet */
82613         to->nfct = from->nfct;
82614         nf_conntrack_get(to->nfct);
82615 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
82616 +#ifdef CONFIG_BRIDGE_NETFILTER
82617         to->nf_bridge = from->nf_bridge;
82618         nf_bridge_get(to->nf_bridge);
82619  #endif
82620 diff -Nru a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
82621 --- a/net/ipv6/ip6_tunnel.c     Mon Aug 18 04:52:14 2003
82622 +++ b/net/ipv6/ip6_tunnel.c     Mon Sep  1 01:55:01 2003
82623 @@ -23,7 +23,6 @@
82624  #include <linux/module.h>
82625  #include <linux/errno.h>
82626  #include <linux/types.h>
82627 -#include <linux/socket.h>
82628  #include <linux/sockios.h>
82629  #include <linux/if.h>
82630  #include <linux/in.h>
82631 @@ -37,12 +36,12 @@
82632  #include <linux/init.h>
82633  #include <linux/route.h>
82634  #include <linux/rtnetlink.h>
82635 +#include <linux/netfilter_ipv6.h>
82636  
82637  #include <asm/uaccess.h>
82638  #include <asm/atomic.h>
82639  
82640  #include <net/ip.h>
82641 -#include <net/sock.h>
82642  #include <net/ipv6.h>
82643  #include <net/protocol.h>
82644  #include <net/ip6_route.h>
82645 @@ -63,22 +62,6 @@
82646  
82647  #define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
82648  
82649 -/* socket(s) used by ip6ip6_tnl_xmit() for resending packets */
82650 -static struct socket *__ip6_socket[NR_CPUS];
82651 -#define ip6_socket __ip6_socket[smp_processor_id()]
82652 -
82653 -static void ip6_xmit_lock(void)
82654 -{
82655 -       local_bh_disable();
82656 -       if (unlikely(!spin_trylock(&ip6_socket->sk->sk_lock.slock)))
82657 -               BUG();
82658 -}
82659 -
82660 -static void ip6_xmit_unlock(void)
82661 -{
82662 -       spin_unlock_bh(&ip6_socket->sk->sk_lock.slock);
82663 -}
82664 -
82665  #define HASH_SIZE  32
82666  
82667  #define HASH(addr) (((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \
82668 @@ -101,6 +84,33 @@
82669  /* lock for the tunnel lists */
82670  static rwlock_t ip6ip6_lock = RW_LOCK_UNLOCKED;
82671  
82672 +static inline struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t)
82673 +{
82674 +       struct dst_entry *dst = t->dst_cache;
82675 +
82676 +       if (dst && dst->obsolete && 
82677 +           dst->ops->check(dst, t->dst_cookie) == NULL) {
82678 +               t->dst_cache = NULL;
82679 +               return NULL;
82680 +       }
82681 +
82682 +       return dst;
82683 +}
82684 +
82685 +static inline void ip6_tnl_dst_reset(struct ip6_tnl *t)
82686 +{
82687 +       dst_release(t->dst_cache);
82688 +       t->dst_cache = NULL;
82689 +}
82690 +
82691 +static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
82692 +{
82693 +       struct rt6_info *rt = (struct rt6_info *) dst;
82694 +       t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
82695 +       dst_release(t->dst_cache);
82696 +       t->dst_cache = dst;
82697 +}
82698 +
82699  /**
82700   * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses
82701   *   @remote: the address of the tunnel exit-point 
82702 @@ -294,13 +304,16 @@
82703  static void
82704  ip6ip6_tnl_dev_uninit(struct net_device *dev)
82705  {
82706 +       struct ip6_tnl *t = dev->priv;
82707 +
82708         if (dev == ip6ip6_fb_tnl_dev) {
82709                 write_lock_bh(&ip6ip6_lock);
82710                 tnls_wc[0] = NULL;
82711                 write_unlock_bh(&ip6ip6_lock);
82712         } else {
82713 -               ip6ip6_tnl_unlink((struct ip6_tnl *) dev->priv);
82714 +               ip6ip6_tnl_unlink(t);
82715         }
82716 +       ip6_tnl_dst_reset(t);
82717         dev_put(dev);
82718  }
82719  
82720 @@ -421,7 +434,7 @@
82721                 }
82722                 teli = parse_tlv_tnl_enc_lim(skb, skb->data);
82723  
82724 -               if (teli && teli == info - 2) {
82725 +               if (teli && teli == ntohl(info) - 2) {
82726                         tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
82727                         if (tel->encap_limit == 0) {
82728                                 if (net_ratelimit())
82729 @@ -434,10 +447,9 @@
82730                 }
82731                 break;
82732         case ICMPV6_PKT_TOOBIG:
82733 -               mtu = info - offset;
82734 -               if (mtu <= IPV6_MIN_MTU) {
82735 +               mtu = ntohl(info) - offset;
82736 +               if (mtu < IPV6_MIN_MTU)
82737                         mtu = IPV6_MIN_MTU;
82738 -               }
82739                 t->dev->mtu = mtu;
82740  
82741                 if ((len = sizeof (*ipv6h) + ipv6h->payload_len) > mtu) {
82742 @@ -523,112 +535,34 @@
82743         return 0;
82744  }
82745  
82746 -/**
82747 - * txopt_len - get necessary size for new &struct ipv6_txoptions
82748 - *   @orig_opt: old options
82749 - *
82750 - * Return:
82751 - *   Size of old one plus size of tunnel encapsulation limit option
82752 - **/
82753 -
82754 -static inline int
82755 -txopt_len(struct ipv6_txoptions *orig_opt)
82756 -{
82757 -       int len = sizeof (*orig_opt) + 8;
82758 -
82759 -       if (orig_opt && orig_opt->dst0opt)
82760 -               len += ipv6_optlen(orig_opt->dst0opt);
82761 -       return len;
82762 -}
82763 -
82764 -/**
82765 - * merge_options - add encapsulation limit to original options
82766 - *   @encap_limit: number of allowed encapsulation limits
82767 - *   @orig_opt: original options
82768 - * 
82769 - * Return:
82770 - *   Pointer to new &struct ipv6_txoptions containing the tunnel
82771 - *   encapsulation limit
82772 - **/
82773 -
82774 -static struct ipv6_txoptions *
82775 -merge_options(struct sock *sk, __u8 encap_limit,
82776 -             struct ipv6_txoptions *orig_opt)
82777 +static inline struct ipv6_txoptions *create_tel(__u8 encap_limit)
82778  {
82779         struct ipv6_tlv_tnl_enc_lim *tel;
82780         struct ipv6_txoptions *opt;
82781         __u8 *raw;
82782 -       __u8 pad_to = 8;
82783 -       int opt_len = txopt_len(orig_opt);
82784  
82785 -       if (!(opt = sock_kmalloc(sk, opt_len, GFP_ATOMIC))) {
82786 +       int opt_len = sizeof(*opt) + 8;
82787 +
82788 +       if (!(opt = kmalloc(opt_len, GFP_ATOMIC))) {
82789                 return NULL;
82790         }
82791 -
82792         memset(opt, 0, opt_len);
82793         opt->tot_len = opt_len;
82794         opt->dst0opt = (struct ipv6_opt_hdr *) (opt + 1);
82795         opt->opt_nflen = 8;
82796  
82797 -       raw = (__u8 *) opt->dst0opt;
82798 -
82799         tel = (struct ipv6_tlv_tnl_enc_lim *) (opt->dst0opt + 1);
82800         tel->type = IPV6_TLV_TNL_ENCAP_LIMIT;
82801         tel->length = 1;
82802         tel->encap_limit = encap_limit;
82803  
82804 -       if (orig_opt) {
82805 -               __u8 *orig_raw;
82806 -
82807 -               opt->hopopt = orig_opt->hopopt;
82808 -
82809 -               /* Keep the original destination options properly
82810 -                  aligned and merge possible old paddings to the
82811 -                  new padding option */
82812 -               if ((orig_raw = (__u8 *) orig_opt->dst0opt) != NULL) {
82813 -                       __u8 type;
82814 -                       int i = sizeof (struct ipv6_opt_hdr);
82815 -                       pad_to += sizeof (struct ipv6_opt_hdr);
82816 -                       while (i < ipv6_optlen(orig_opt->dst0opt)) {
82817 -                               type = orig_raw[i++];
82818 -                               if (type == IPV6_TLV_PAD0)
82819 -                                       pad_to++;
82820 -                               else if (type == IPV6_TLV_PADN) {
82821 -                                       int len = orig_raw[i++];
82822 -                                       i += len;
82823 -                                       pad_to += len + 2;
82824 -                               } else {
82825 -                                       break;
82826 -                               }
82827 -                       }
82828 -                       opt->dst0opt->hdrlen = orig_opt->dst0opt->hdrlen + 1;
82829 -                       memcpy(raw + pad_to, orig_raw + pad_to - 8,
82830 -                              opt_len - sizeof (*opt) - pad_to);
82831 -               }
82832 -               opt->srcrt = orig_opt->srcrt;
82833 -               opt->opt_nflen += orig_opt->opt_nflen;
82834 -
82835 -               opt->dst1opt = orig_opt->dst1opt;
82836 -               opt->auth = orig_opt->auth;
82837 -               opt->opt_flen = orig_opt->opt_flen;
82838 -       }
82839 +       raw = (__u8 *) opt->dst0opt;
82840         raw[5] = IPV6_TLV_PADN;
82841 -
82842 -       /* subtract lengths of destination suboption header,
82843 -          tunnel encapsulation limit and pad N header */
82844 -       raw[6] = pad_to - 7;
82845 +       raw[6] = 1;
82846  
82847         return opt;
82848  }
82849  
82850 -static int 
82851 -ip6ip6_getfrag(void *from, char *to, int offset, int len, int odd, 
82852 -               struct sk_buff *skb)
82853 -{
82854 -       memcpy(to, (char *) from + offset, len);
82855 -       return 0;
82856 -}
82857 -
82858  /**
82859   * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own
82860   *   @t: the outgoing tunnel device
82861 @@ -656,7 +590,7 @@
82862   *
82863   * Description:
82864   *   Build new header and do some sanity checks on the packet before sending
82865 - *   it to ip6_build_xmit().
82866 + *   it.
82867   *
82868   * Return: 
82869   *   0
82870 @@ -667,18 +601,17 @@
82871         struct ip6_tnl *t = (struct ip6_tnl *) dev->priv;
82872         struct net_device_stats *stats = &t->stat;
82873         struct ipv6hdr *ipv6h = skb->nh.ipv6h;
82874 -       struct ipv6_txoptions *orig_opt = NULL;
82875         struct ipv6_txoptions *opt = NULL;
82876         int encap_limit = -1;
82877         __u16 offset;
82878         struct flowi fl;
82879 -       struct ip6_flowlabel *fl_lbl = NULL;
82880 -       int err = 0;
82881         struct dst_entry *dst;
82882 -       int link_failure = 0;
82883 -       struct sock *sk = ip6_socket->sk;
82884 -       struct ipv6_pinfo *np = inet6_sk(sk);
82885 +       struct net_device *tdev;
82886         int mtu;
82887 +       int max_headroom = sizeof(struct ipv6hdr);
82888 +       u8 proto;
82889 +       int err;
82890 +       int pkt_len;
82891  
82892         if (t->recursion++) {
82893                 stats->collisions++;
82894 @@ -701,58 +634,39 @@
82895         } else if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) {
82896                 encap_limit = t->parms.encap_limit;
82897         }
82898 -       ip6_xmit_lock();
82899 -
82900         memcpy(&fl, &t->fl, sizeof (fl));
82901 +       proto = fl.proto;
82902  
82903         if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
82904                 fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_TCLASS_MASK);
82905         if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL))
82906                 fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_FLOWLABEL_MASK);
82907  
82908 -       if (fl.fl6_flowlabel) {
82909 -               fl_lbl = fl6_sock_lookup(sk, fl.fl6_flowlabel);
82910 -               if (fl_lbl)
82911 -                       orig_opt = fl_lbl->opt;
82912 -       }
82913 -       if (encap_limit >= 0) {
82914 -               if (!(opt = merge_options(sk, encap_limit, orig_opt))) {
82915 -                       goto tx_err_free_fl_lbl;
82916 -               }
82917 -       } else {
82918 -               opt = orig_opt;
82919 -       }
82920 -       dst = __sk_dst_check(sk, np->dst_cookie);
82921 +       if (encap_limit >= 0 && (opt = create_tel(encap_limit)) == NULL)
82922 +               goto tx_err;
82923  
82924 -       if (dst) {
82925 -               if (np->daddr_cache == NULL ||
82926 -                   ipv6_addr_cmp(&fl.fl6_dst, np->daddr_cache) ||
82927 -                   (fl.oif && fl.oif != dst->dev->ifindex)) {
82928 -                       dst = NULL;
82929 -               }
82930 -       }
82931 -       if (dst == NULL) {
82932 -               dst = ip6_route_output(sk, &fl);
82933 -               if (dst->error) {
82934 -                       stats->tx_carrier_errors++;
82935 -                       link_failure = 1;
82936 -                       goto tx_err_dst_release;
82937 -               }
82938 -               /* local routing loop */
82939 -               if (dst->dev == dev) {
82940 -                       stats->collisions++;
82941 -                       if (net_ratelimit())
82942 -                               printk(KERN_WARNING 
82943 -                                      "%s: Local routing loop detected!\n",
82944 -                                      t->parms.name);
82945 -                       goto tx_err_dst_release;
82946 -               }
82947 -               ipv6_addr_copy(&np->daddr, &fl.fl6_dst);
82948 -               ipv6_addr_copy(&np->saddr, &fl.fl6_src);
82949 +       if ((dst = ip6_tnl_dst_check(t)) != NULL)
82950 +               dst_hold(dst);
82951 +       else
82952 +               dst = ip6_route_output(NULL, &fl);
82953 +
82954 +       if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0)
82955 +               goto tx_err_link_failure;
82956 +
82957 +       tdev = dst->dev;
82958 +
82959 +       if (tdev == dev) {
82960 +               stats->collisions++;
82961 +               if (net_ratelimit())
82962 +                       printk(KERN_WARNING 
82963 +                              "%s: Local routing loop detected!\n",
82964 +                              t->parms.name);
82965 +               goto tx_err_dst_release;
82966         }
82967         mtu = dst_pmtu(dst) - sizeof (*ipv6h);
82968         if (opt) {
82969 -               mtu -= (opt->opt_nflen + opt->opt_flen);
82970 +               max_headroom += 8;
82971 +               mtu -= 8;
82972         }
82973         if (mtu < IPV6_MIN_MTU)
82974                 mtu = IPV6_MIN_MTU;
82975 @@ -765,41 +679,71 @@
82976                 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, dev);
82977                 goto tx_err_dst_release;
82978         }
82979 -       err = ip6_append_data(sk, ip6ip6_getfrag, skb->nh.raw, skb->len, 0,
82980 -                             t->parms.hop_limit, opt, &fl, 
82981 -                             (struct rt6_info *)dst, MSG_DONTWAIT);
82982 +       skb->h.raw = skb->nh.raw;
82983  
82984 -       if (err) {
82985 -               ip6_flush_pending_frames(sk);
82986 -       } else {
82987 -               err = ip6_push_pending_frames(sk);
82988 -               err = (err < 0 ? err : 0);
82989 +       /*
82990 +        * Okay, now see if we can stuff it in the buffer as-is.
82991 +        */
82992 +       max_headroom += LL_RESERVED_SPACE(tdev);
82993 +       
82994 +       if (skb_headroom(skb) < max_headroom || 
82995 +           skb_cloned(skb) || skb_shared(skb)) {
82996 +               struct sk_buff *new_skb;
82997 +               
82998 +               if (!(new_skb = skb_realloc_headroom(skb, max_headroom)))
82999 +                       goto tx_err_dst_release;
83000 +
83001 +               if (skb->sk)
83002 +                       skb_set_owner_w(new_skb, skb->sk);
83003 +               kfree_skb(skb);
83004 +               skb = new_skb;
83005         }
83006 -       if (!err) {
83007 -               stats->tx_bytes += skb->len;
83008 +       dst_release(skb->dst);
83009 +       skb->dst = dst_clone(dst);
83010 +
83011 +       if (opt)
83012 +               ipv6_push_nfrag_opts(skb, opt, &proto, NULL);
83013 +
83014 +       skb->nh.raw = skb_push(skb, sizeof(struct ipv6hdr));
83015 +       ipv6h = skb->nh.ipv6h;
83016 +       *(u32*)ipv6h = fl.fl6_flowlabel | htonl(0x60000000);
83017 +       ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
83018 +       ipv6h->hop_limit = t->parms.hop_limit;
83019 +       ipv6h->nexthdr = proto;
83020 +       ipv6_addr_copy(&ipv6h->saddr, &fl.fl6_src);
83021 +       ipv6_addr_copy(&ipv6h->daddr, &fl.fl6_dst);
83022 +#ifdef CONFIG_NETFILTER
83023 +       nf_conntrack_put(skb->nfct);
83024 +       skb->nfct = NULL;
83025 +#ifdef CONFIG_NETFILTER_DEBUG
83026 +       skb->nf_debug = 0;
83027 +#endif
83028 +#endif
83029 +       pkt_len = skb->len;
83030 +       err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, 
83031 +                     skb->dst->dev, dst_output);
83032 +
83033 +       if (err == NET_XMIT_SUCCESS || err == NET_XMIT_CN) {
83034 +               stats->tx_bytes += pkt_len;
83035                 stats->tx_packets++;
83036         } else {
83037                 stats->tx_errors++;
83038                 stats->tx_aborted_errors++;
83039         }
83040 -       if (opt && opt != orig_opt)
83041 -               sock_kfree_s(sk, opt, opt->tot_len);
83042 +       ip6_tnl_dst_store(t, dst);
83043 +
83044 +       if (opt)
83045 +               kfree(opt);
83046  
83047 -       fl6_sock_release(fl_lbl);
83048 -       ip6_dst_store(sk, dst, &np->daddr);
83049 -       ip6_xmit_unlock();
83050 -       kfree_skb(skb);
83051         t->recursion--;
83052         return 0;
83053 +tx_err_link_failure:
83054 +       stats->tx_carrier_errors++;
83055 +       dst_link_failure(skb);
83056  tx_err_dst_release:
83057         dst_release(dst);
83058 -       if (opt && opt != orig_opt)
83059 -               sock_kfree_s(sk, opt, opt->tot_len);
83060 -tx_err_free_fl_lbl:
83061 -       fl6_sock_release(fl_lbl);
83062 -       ip6_xmit_unlock();
83063 -       if (link_failure)
83064 -               dst_link_failure(skb);
83065 +       if (opt)
83066 +               kfree(opt);
83067  tx_err:
83068         stats->tx_errors++;
83069         stats->tx_dropped++;
83070 @@ -851,9 +795,12 @@
83071  {
83072         struct net_device *dev = t->dev;
83073         struct ip6_tnl_parm *p = &t->parms;
83074 -       struct flowi *fl;
83075 +       struct flowi *fl = &t->fl;
83076 +
83077 +       memcpy(&dev->dev_addr, &p->laddr, sizeof(struct in6_addr));
83078 +       memcpy(&dev->broadcast, &p->raddr, sizeof(struct in6_addr));
83079 +
83080         /* Set up flowi template */
83081 -       fl = &t->fl;
83082         ipv6_addr_copy(&fl->fl6_src, &p->laddr);
83083         ipv6_addr_copy(&fl->fl6_dst, &p->raddr);
83084         fl->oif = p->link;
83085 @@ -878,10 +825,7 @@
83086                 if (rt == NULL)
83087                         return;
83088  
83089 -               /* as long as tunnels use the same socket for transmission,
83090 -                  locally nested tunnels won't work */
83091 -               
83092 -               if (rt->rt6i_dev && rt->rt6i_dev->type != ARPHRD_TUNNEL6) {
83093 +               if (rt->rt6i_dev) {
83094                         dev->iflink = rt->rt6i_dev->ifindex;
83095  
83096                         dev->hard_header_len = rt->rt6i_dev->hard_header_len +
83097 @@ -1083,7 +1027,7 @@
83098  {
83099         SET_MODULE_OWNER(dev);
83100         dev->uninit = ip6ip6_tnl_dev_uninit;
83101 -       dev->destructor = (void (*)(struct net_device *))kfree;
83102 +       dev->destructor = free_netdev;
83103         dev->hard_start_xmit = ip6ip6_tnl_xmit;
83104         dev->get_stats = ip6ip6_tnl_get_stats;
83105         dev->do_ioctl = ip6ip6_tnl_ioctl;
83106 @@ -1094,10 +1038,7 @@
83107         dev->mtu = ETH_DATA_LEN - sizeof (struct ipv6hdr);
83108         dev->flags |= IFF_NOARP;
83109         dev->iflink = 0;
83110 -       /* Hmm... MAX_ADDR_LEN is 8, so the ipv6 addresses can't be
83111 -          copied to dev->dev_addr and dev->broadcast, like the ipv4
83112 -          addresses were in ipip.c, ip_gre.c and sit.c. */
83113 -       dev->addr_len = 0;
83114 +       dev->addr_len = sizeof(struct in6_addr);
83115  }
83116  
83117  
83118 @@ -1139,7 +1080,7 @@
83119  int ip6ip6_fb_tnl_dev_init(struct net_device *dev)
83120  {
83121         struct ip6_tnl *t = dev->priv;
83122 -       ip6ip6_tnl_dev_init_gen(dev); 
83123 +       ip6ip6_tnl_dev_init_gen(dev);
83124         dev_hold(dev);
83125         tnls_wc[0] = t;
83126         return 0;
83127 @@ -1159,61 +1100,28 @@
83128  
83129  int __init ip6_tunnel_init(void)
83130  {
83131 -       int i, j, err;
83132 -       struct sock *sk;
83133 -       struct ipv6_pinfo *np;
83134 -
83135 -       for (i = 0; i < NR_CPUS; i++) {
83136 -               if (!cpu_possible(i))
83137 -                       continue;
83138 -
83139 -               err = sock_create(PF_INET6, SOCK_RAW, IPPROTO_IPV6, 
83140 -                                 &__ip6_socket[i]);
83141 -               if (err < 0) {
83142 -                       printk(KERN_ERR 
83143 -                              "Failed to create the IPv6 tunnel socket "
83144 -                              "(err %d).\n", 
83145 -                              err);
83146 -                       goto fail;
83147 -               }
83148 -               sk = __ip6_socket[i]->sk;
83149 -               sk->sk_allocation = GFP_ATOMIC;
83150 -
83151 -               np = inet6_sk(sk);
83152 -               np->hop_limit = 255;
83153 -               np->mc_loop = 0;
83154 +       int  err;
83155  
83156 -               sk->sk_prot->unhash(sk);
83157 -       }
83158         if ((err = inet6_add_protocol(&ip6ip6_protocol, IPPROTO_IPV6)) < 0) {
83159                 printk(KERN_ERR "Failed to register IPv6 protocol\n");
83160 -               goto fail;
83161 +               return err;
83162         }
83163 -
83164 -       
83165         ip6ip6_fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
83166                                          ip6ip6_tnl_dev_setup);
83167  
83168         if (!ip6ip6_fb_tnl_dev) {
83169                 err = -ENOMEM;
83170 -               goto tnl_fail;
83171 +               goto fail;
83172         }
83173         ip6ip6_fb_tnl_dev->init = ip6ip6_fb_tnl_dev_init;
83174  
83175         if ((err = register_netdev(ip6ip6_fb_tnl_dev))) {
83176                 kfree(ip6ip6_fb_tnl_dev);
83177 -               goto tnl_fail;
83178 +               goto fail;
83179         }
83180         return 0;
83181 -tnl_fail:
83182 -       inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
83183  fail:
83184 -       for (j = 0; j < i; j++) {
83185 -               if (!cpu_possible(j))
83186 -                       continue;
83187 -               sock_release(__ip6_socket[j]);
83188 -               __ip6_socket[j] = NULL;
83189 -       }
83190 +       inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
83191         return err;
83192  }
83193  
83194 @@ -1223,18 +1131,8 @@
83195  
83196  void ip6_tunnel_cleanup(void)
83197  {
83198 -       int i;
83199 -
83200         unregister_netdev(ip6ip6_fb_tnl_dev);
83201 -
83202         inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
83203 -
83204 -       for (i = 0; i < NR_CPUS; i++) {
83205 -               if (!cpu_possible(i))
83206 -                       continue;
83207 -               sock_release(__ip6_socket[i]);
83208 -               __ip6_socket[i] = NULL;
83209 -       }
83210  }
83211  
83212  #ifdef MODULE
83213 diff -Nru a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c
83214 --- a/net/ipv6/ipv6_syms.c      Sat Aug  9 02:14:55 2003
83215 +++ b/net/ipv6/ipv6_syms.c      Mon Sep  1 01:55:02 2003
83216 @@ -45,3 +45,4 @@
83217  EXPORT_SYMBOL(ip6_append_data);
83218  EXPORT_SYMBOL(ip6_flush_pending_frames);
83219  EXPORT_SYMBOL(ip6_push_pending_frames);
83220 +EXPORT_SYMBOL(ipv6_push_nfrag_opts);
83221 diff -Nru a/net/ipv6/mcast.c b/net/ipv6/mcast.c
83222 --- a/net/ipv6/mcast.c  Thu Aug 21 14:48:55 2003
83223 +++ b/net/ipv6/mcast.c  Wed Aug 27 23:45:13 2003
83224 @@ -2078,6 +2078,7 @@
83225                         break;
83226                 }
83227                 read_unlock_bh(&idev->lock);
83228 +               in6_dev_put(idev);
83229         }
83230         return im;
83231  }
83232 @@ -2135,7 +2136,9 @@
83233         if (likely(state->idev != NULL)) {
83234                 read_unlock_bh(&state->idev->lock);
83235                 in6_dev_put(state->idev);
83236 +               state->idev = NULL;
83237         }
83238 +       state->dev = NULL;
83239         read_unlock(&dev_base_lock);
83240  }
83241  
83242 @@ -2225,6 +2228,7 @@
83243                         spin_unlock_bh(&im->mca_lock);
83244                 }
83245                 read_unlock_bh(&idev->lock);
83246 +               in6_dev_put(idev);
83247         }
83248         return psf;
83249  }
83250 @@ -2291,12 +2295,16 @@
83251  static void igmp6_mcf_seq_stop(struct seq_file *seq, void *v)
83252  {
83253         struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
83254 -       if (likely(state->im != NULL))
83255 +       if (likely(state->im != NULL)) {
83256                 spin_unlock_bh(&state->im->mca_lock);
83257 +               state->im = NULL;
83258 +       }
83259         if (likely(state->idev != NULL)) {
83260                 read_unlock_bh(&state->idev->lock);
83261                 in6_dev_put(state->idev);
83262 +               state->idev = NULL;
83263         }
83264 +       state->dev = NULL;
83265         read_unlock(&dev_base_lock);
83266  }
83267  
83268 diff -Nru a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
83269 --- a/net/ipv6/netfilter/Kconfig        Mon Mar  3 01:40:45 2003
83270 +++ b/net/ipv6/netfilter/Kconfig        Sun Aug 24 04:58:54 2003
83271 @@ -3,14 +3,14 @@
83272  #
83273  
83274  menu "IPv6: Netfilter Configuration"
83275 -       depends on INET && EXPERIMENTAL && IPV6!=n && NETFILTER
83276 +       depends on INET && IPV6!=n && NETFILTER
83277  
83278  #tristate 'Connection tracking (required for masq/NAT)' CONFIG_IP6_NF_CONNTRACK
83279  #if [ "$CONFIG_IP6_NF_CONNTRACK" != "n" ]; then
83280  #  dep_tristate '  FTP protocol support' CONFIG_IP6_NF_FTP $CONFIG_IP6_NF_CONNTRACK
83281  #fi
83282  config IP6_NF_QUEUE
83283 -       tristate "Userspace queueing via NETLINK (EXPERIMENTAL)"
83284 +       tristate "Userspace queueing via NETLINK"
83285         ---help---
83286  
83287           This option adds a queue handler to the kernel for IPv6
83288 @@ -62,7 +62,7 @@
83289  
83290  config IP6_NF_MATCH_RT
83291         tristate "Routing header match support"
83292 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
83293 +       depends on IP6_NF_IPTABLES
83294         help
83295           rt matching allows you to match packets based on the routing
83296           header of the packet.
83297 @@ -72,7 +72,7 @@
83298  
83299  config IP6_NF_MATCH_OPTS
83300         tristate "Hop-by-hop and Dst opts header match support"
83301 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
83302 +       depends on IP6_NF_IPTABLES
83303         help
83304           This allows one to match packets based on the hop-by-hop
83305           and destination options headers of a packet.
83306 @@ -82,7 +82,7 @@
83307  
83308  config IP6_NF_MATCH_FRAG
83309         tristate "Fragmentation header match support"
83310 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
83311 +       depends on IP6_NF_IPTABLES
83312         help
83313           frag matching allows you to match packets based on the fragmentation
83314           header of the packet.
83315 @@ -112,7 +112,7 @@
83316           <file:Documentation/modules.txt>.  If unsure, say `N'.
83317  
83318  config IP6_NF_MATCH_OWNER
83319 -       tristate "Owner match support (EXPERIMENTAL)"
83320 +       tristate "Owner match support"
83321         depends on IP6_NF_IPTABLES
83322         help
83323           Packet owner matching allows you to match locally-generated packets
83324 @@ -134,8 +134,8 @@
83325           <file:Documentation/modules.txt>.  If unsure, say `N'.
83326  
83327  config IP6_NF_MATCH_IPV6HEADER
83328 -       tristate "IPv6 Extension Headers Match (EXPERIMENTAL)"
83329 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
83330 +       tristate "IPv6 Extension Headers Match"
83331 +       depends on IP6_NF_IPTABLES
83332         help
83333           This module allows one to match packets based upon
83334           the ipv6 extension headers.
83335 @@ -144,8 +144,8 @@
83336           <file:Documentation/modules.txt>.  If unsure, say `N'.
83337  
83338  config IP6_NF_MATCH_AHESP
83339 -       tristate "AH/ESP match support (EXPERIMENTAL)"
83340 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
83341 +       tristate "AH/ESP match support"
83342 +       depends on IP6_NF_IPTABLES
83343         help
83344           This module allows one to match AH and ESP packets.
83345  
83346 @@ -163,7 +163,7 @@
83347           Documentation/modules.txt.  If unsure, say `N'.
83348  
83349  config IP6_NF_MATCH_EUI64
83350 -       tristate "EUI64 address check (EXPERIMENTAL)"
83351 +       tristate "EUI64 address check"
83352         depends on IP6_NF_IPTABLES
83353         help
83354           This module performs checking on the IPv6 source address
83355 diff -Nru a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
83356 --- a/net/ipv6/netfilter/ip6_tables.c   Sat Aug  2 18:29:29 2003
83357 +++ b/net/ipv6/netfilter/ip6_tables.c   Sun Aug 24 05:00:28 2003
83358 @@ -26,6 +26,10 @@
83359  
83360  #include <linux/netfilter_ipv6/ip6_tables.h>
83361  
83362 +MODULE_LICENSE("GPL");
83363 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
83364 +MODULE_DESCRIPTION("IPv6 packet filter");
83365 +
83366  #define IPV6_HDR_LEN   (sizeof(struct ipv6hdr))
83367  #define IPV6_OPTHDR_LEN        (sizeof(struct ipv6_opt_hdr))
83368  
83369 @@ -1923,4 +1927,3 @@
83370  
83371  module_init(init);
83372  module_exit(fini);
83373 -MODULE_LICENSE("GPL");
83374 diff -Nru a/net/ipv6/netfilter/ip6t_MARK.c b/net/ipv6/netfilter/ip6t_MARK.c
83375 --- a/net/ipv6/netfilter/ip6t_MARK.c    Tue Feb  5 07:24:40 2002
83376 +++ b/net/ipv6/netfilter/ip6t_MARK.c    Sun Aug 24 05:00:28 2003
83377 @@ -7,6 +7,9 @@
83378  #include <linux/netfilter_ipv6/ip6_tables.h>
83379  #include <linux/netfilter_ipv6/ip6t_MARK.h>
83380  
83381 +MODULE_LICENSE("GPL");
83382 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
83383 +
83384  static unsigned int
83385  target(struct sk_buff **pskb,
83386         unsigned int hooknum,
83387 @@ -65,4 +68,3 @@
83388  
83389  module_init(init);
83390  module_exit(fini);
83391 -MODULE_LICENSE("GPL");
83392 diff -Nru a/net/ipv6/netfilter/ip6t_eui64.c b/net/ipv6/netfilter/ip6t_eui64.c
83393 --- a/net/ipv6/netfilter/ip6t_eui64.c   Thu Mar 20 00:43:40 2003
83394 +++ b/net/ipv6/netfilter/ip6t_eui64.c   Sun Aug 24 05:00:28 2003
83395 @@ -6,6 +6,10 @@
83396  
83397  #include <linux/netfilter_ipv6/ip6_tables.h>
83398  
83399 +MODULE_DESCRIPTION("IPv6 EUI64 address checking match");
83400 +MODULE_LICENSE("GPL");
83401 +MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
83402 +
83403  static int
83404  match(const struct sk_buff *skb,
83405        const struct net_device *in,
83406 @@ -88,6 +92,3 @@
83407  
83408  module_init(init);
83409  module_exit(fini);
83410 -MODULE_DESCRIPTION("IPv6 EUI64 address checking match");
83411 -MODULE_LICENSE("GPL");
83412 -MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
83413 diff -Nru a/net/ipv6/netfilter/ip6t_length.c b/net/ipv6/netfilter/ip6t_length.c
83414 --- a/net/ipv6/netfilter/ip6t_length.c  Thu Mar 20 00:43:40 2003
83415 +++ b/net/ipv6/netfilter/ip6t_length.c  Sun Aug 24 05:00:28 2003
83416 @@ -5,6 +5,10 @@
83417  #include <linux/netfilter_ipv6/ip6t_length.h>
83418  #include <linux/netfilter_ipv6/ip6_tables.h>
83419  
83420 +MODULE_LICENSE("GPL");
83421 +MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
83422 +MODULE_DESCRIPTION("IPv6 packet length match");
83423 +
83424  static int
83425  match(const struct sk_buff *skb,
83426        const struct net_device *in,
83427 diff -Nru a/net/ipv6/netfilter/ip6t_limit.c b/net/ipv6/netfilter/ip6t_limit.c
83428 --- a/net/ipv6/netfilter/ip6t_limit.c   Thu Mar 20 00:43:40 2003
83429 +++ b/net/ipv6/netfilter/ip6t_limit.c   Sun Aug 24 05:00:28 2003
83430 @@ -15,6 +15,10 @@
83431  #include <linux/netfilter_ipv6/ip6_tables.h>
83432  #include <linux/netfilter_ipv6/ip6t_limit.h>
83433  
83434 +MODULE_LICENSE("GPL");
83435 +MODULE_AUTHOR("Herve Eychenne <rv@wallfire.org>");
83436 +MODULE_DESCRIPTION("rate limiting within ip6tables");
83437 +
83438  /* The algorithm used is the Simple Token Bucket Filter (TBF)
83439   * see net/sched/sch_tbf.c in the linux source tree
83440   */
83441 @@ -136,4 +140,3 @@
83442  
83443  module_init(init);
83444  module_exit(fini);
83445 -MODULE_LICENSE("GPL");
83446 diff -Nru a/net/ipv6/netfilter/ip6t_mac.c b/net/ipv6/netfilter/ip6t_mac.c
83447 --- a/net/ipv6/netfilter/ip6t_mac.c     Thu Mar 20 00:43:40 2003
83448 +++ b/net/ipv6/netfilter/ip6t_mac.c     Sun Aug 24 05:00:28 2003
83449 @@ -6,6 +6,10 @@
83450  #include <linux/netfilter_ipv6/ip6t_mac.h>
83451  #include <linux/netfilter_ipv6/ip6_tables.h>
83452  
83453 +MODULE_LICENSE("GPL");
83454 +MODULE_DESCRIPTION("MAC address matching module for IPv6");
83455 +MODULE_AUTHOR("Netfilter Core Teaam <coreteam@netfilter.org>");
83456 +
83457  static int
83458  match(const struct sk_buff *skb,
83459        const struct net_device *in,
83460 @@ -66,5 +70,3 @@
83461  
83462  module_init(init);
83463  module_exit(fini);
83464 -MODULE_LICENSE("GPL");
83465 -MODULE_DESCRIPTION("MAC address matching module for IPv6");
83466 diff -Nru a/net/ipv6/netfilter/ip6t_mark.c b/net/ipv6/netfilter/ip6t_mark.c
83467 --- a/net/ipv6/netfilter/ip6t_mark.c    Thu Mar 20 00:43:40 2003
83468 +++ b/net/ipv6/netfilter/ip6t_mark.c    Sun Aug 24 05:00:28 2003
83469 @@ -5,6 +5,10 @@
83470  #include <linux/netfilter_ipv6/ip6t_mark.h>
83471  #include <linux/netfilter_ipv6/ip6_tables.h>
83472  
83473 +MODULE_LICENSE("GPL");
83474 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
83475 +MODULE_DESCRIPTION("ip6tables mark match");
83476 +
83477  static int
83478  match(const struct sk_buff *skb,
83479        const struct net_device *in,
83480 @@ -52,4 +56,3 @@
83481  
83482  module_init(init);
83483  module_exit(fini);
83484 -MODULE_LICENSE("GPL");
83485 diff -Nru a/net/ipv6/netfilter/ip6t_multiport.c b/net/ipv6/netfilter/ip6t_multiport.c
83486 --- a/net/ipv6/netfilter/ip6t_multiport.c       Thu Mar 20 00:43:40 2003
83487 +++ b/net/ipv6/netfilter/ip6t_multiport.c       Sun Aug 24 05:00:28 2003
83488 @@ -9,6 +9,10 @@
83489  #include <linux/netfilter_ipv6/ip6t_multiport.h>
83490  #include <linux/netfilter_ipv6/ip6_tables.h>
83491  
83492 +MODULE_LICENSE("GPL");
83493 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
83494 +MODULE_DESCRIPTION("ip6tables match for multiple ports");
83495 +
83496  #if 0
83497  #define duprintf(format, args...) printk(format , ## args)
83498  #else
83499 diff -Nru a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
83500 --- a/net/ipv6/netfilter/ip6table_filter.c      Mon Apr 28 02:27:56 2003
83501 +++ b/net/ipv6/netfilter/ip6table_filter.c      Sun Aug 24 05:00:28 2003
83502 @@ -6,6 +6,10 @@
83503  #include <linux/module.h>
83504  #include <linux/netfilter_ipv6/ip6_tables.h>
83505  
83506 +MODULE_LICENSE("GPL");
83507 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
83508 +MODULE_DESCRIPTION("ip6tables filter table");
83509 +
83510  #define FILTER_VALID_HOOKS ((1 << NF_IP6_LOCAL_IN) | (1 << NF_IP6_FORWARD) | (1 << NF_IP6_LOCAL_OUT))
83511  
83512  /* Standard entry. */
83513 @@ -202,4 +206,3 @@
83514  
83515  module_init(init);
83516  module_exit(fini);
83517 -MODULE_LICENSE("GPL");
83518 diff -Nru a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
83519 --- a/net/ipv6/netfilter/ip6table_mangle.c      Mon Apr 28 02:27:56 2003
83520 +++ b/net/ipv6/netfilter/ip6table_mangle.c      Sun Aug 24 05:00:28 2003
83521 @@ -6,6 +6,10 @@
83522  #include <linux/module.h>
83523  #include <linux/netfilter_ipv6/ip6_tables.h>
83524  
83525 +MODULE_LICENSE("GPL");
83526 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
83527 +MODULE_DESCRIPTION("ip6tables mangle table");
83528 +
83529  #define MANGLE_VALID_HOOKS ((1 << NF_IP6_PRE_ROUTING) | \
83530                             (1 << NF_IP6_LOCAL_IN) | \
83531                             (1 << NF_IP6_FORWARD) | \
83532 @@ -279,4 +283,3 @@
83533  
83534  module_init(init);
83535  module_exit(fini);
83536 -MODULE_LICENSE("GPL");
83537 diff -Nru a/net/ipv6/route.c b/net/ipv6/route.c
83538 --- a/net/ipv6/route.c  Mon Aug 18 03:49:00 2003
83539 +++ b/net/ipv6/route.c  Sat Aug 30 21:26:12 2003
83540 @@ -577,7 +577,7 @@
83541         rt->rt6i_dev      = dev;
83542         rt->rt6i_nexthop  = neigh;
83543         rt->rt6i_expires  = 0;
83544 -       rt->rt6i_flags    = RTF_LOCAL;
83545 +       rt->rt6i_flags    = RTF_LOCAL | RTF_NDISC;
83546         rt->rt6i_metric   = 0;
83547         atomic_set(&rt->u.dst.__refcnt, 1);
83548         rt->u.dst.metrics[RTAX_HOPLIMIT-1] = 255;
83549 @@ -831,7 +831,7 @@
83550                 }
83551         }
83552  
83553 -       rt->rt6i_flags = rtmsg->rtmsg_flags;
83554 +       rt->rt6i_flags = rtmsg->rtmsg_flags & ~RTF_NDISC;
83555  
83556  install_route:
83557         if (rta && rta[RTA_METRICS-1]) {
83558 @@ -1123,6 +1123,8 @@
83559  static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
83560  {
83561         struct rt6_info *rt = ip6_dst_alloc();
83562 +
83563 +       BUG_ON(ort->rt6i_flags & RTF_NDISC);
83564  
83565         if (rt) {
83566                 rt->u.dst.input = ort->u.dst.input;
83567 diff -Nru a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
83568 --- a/net/ipv6/xfrm6_policy.c   Sun Jul 27 19:22:27 2003
83569 +++ b/net/ipv6/xfrm6_policy.c   Sat Aug 30 21:26:12 2003
83570 @@ -55,12 +55,22 @@
83571  __xfrm6_find_bundle(struct flowi *fl, struct rtable *rt, struct xfrm_policy *policy)
83572  {
83573         struct dst_entry *dst;
83574 +       u32 ndisc_bit = 0;
83575 +
83576 +       if (fl->proto == IPPROTO_ICMPV6 &&
83577 +           (fl->fl_icmp_type == NDISC_NEIGHBOUR_ADVERTISEMENT ||
83578 +            fl->fl_icmp_type == NDISC_NEIGHBOUR_SOLICITATION  ||
83579 +            fl->fl_icmp_type == NDISC_ROUTER_SOLICITATION))
83580 +               ndisc_bit = RTF_NDISC;
83581  
83582         /* Still not clear if we should set fl->fl6_{src,dst}... */
83583         read_lock_bh(&policy->lock);
83584         for (dst = policy->bundles; dst; dst = dst->next) {
83585                 struct xfrm_dst *xdst = (struct xfrm_dst*)dst;
83586                 struct in6_addr fl_dst_prefix, fl_src_prefix;
83587 +
83588 +               if ((xdst->u.rt6.rt6i_flags & RTF_NDISC) != ndisc_bit)
83589 +                       continue;
83590  
83591                 ipv6_addr_prefix(&fl_dst_prefix,
83592                                  &fl->fl6_dst,
83593 diff -Nru a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
83594 --- a/net/ipx/af_ipx.c  Wed Jun 18 13:59:01 2003
83595 +++ b/net/ipx/af_ipx.c  Tue Sep  2 04:38:10 2003
83596 @@ -1365,6 +1365,7 @@
83597                         atomic_read(&ipx_sock_nr));
83598  #endif
83599         sock_init_data(sock, sk);
83600 +       sk_set_owner(sk, THIS_MODULE);
83601         sk->sk_no_check = 1;            /* Checksum off by default */
83602         rc = 0;
83603  out:
83604 @@ -2020,3 +2021,4 @@
83605  module_init(ipx_init);
83606  module_exit(ipx_proto_finito);
83607  MODULE_LICENSE("GPL");
83608 +MODULE_ALIAS_NETPROTO(PF_IPX);
83609 diff -Nru a/net/irda/af_irda.c b/net/irda/af_irda.c
83610 --- a/net/irda/af_irda.c        Wed Jun  4 17:57:09 2003
83611 +++ b/net/irda/af_irda.c        Sat Aug 30 19:15:30 2003
83612 @@ -1098,6 +1098,7 @@
83613  
83614         /* Initialise networking socket struct */
83615         sock_init_data(sock, sk);       /* Note : set sk->sk_refcnt to 1 */
83616 +       sk_set_owner(sk, THIS_MODULE);
83617         sk->sk_family = PF_IRDA;
83618         sk->sk_protocol = protocol;
83619         /* Link networking socket and IrDA socket structs together */
83620 diff -Nru a/net/irda/irsyms.c b/net/irda/irsyms.c
83621 --- a/net/irda/irsyms.c Sun May 25 19:36:24 2003
83622 +++ b/net/irda/irsyms.c Tue Sep  2 04:38:10 2003
83623 @@ -351,3 +351,4 @@
83624  #ifdef CONFIG_IRDA_DEBUG
83625  MODULE_PARM(irda_debug, "1l");
83626  #endif
83627 +MODULE_ALIAS_NETPROTO(PF_IRDA);
83628 diff -Nru a/net/key/af_key.c b/net/key/af_key.c
83629 --- a/net/key/af_key.c  Sun Jul 27 16:31:49 2003
83630 +++ b/net/key/af_key.c  Tue Sep  2 04:38:10 2003
83631 @@ -2844,3 +2844,4 @@
83632  module_init(ipsec_pfkey_init);
83633  module_exit(ipsec_pfkey_exit);
83634  MODULE_LICENSE("GPL");
83635 +MODULE_ALIAS_NETPROTO(PF_KEY);
83636 diff -Nru a/net/llc/llc_mac.c b/net/llc/llc_mac.c
83637 --- a/net/llc/llc_mac.c Wed Jun  4 17:57:09 2003
83638 +++ b/net/llc/llc_mac.c Sat Aug 30 19:09:25 2003
83639 @@ -35,7 +35,7 @@
83640  
83641  u8 llc_mac_null_var[IFHWADDRLEN];
83642  
83643 -static void fix_up_incoming_skb(struct sk_buff *skb);
83644 +static int fix_up_incoming_skb(struct sk_buff *skb);
83645  static void llc_station_rcv(struct sk_buff *skb);
83646  static void llc_sap_rcv(struct llc_sap *sap, struct sk_buff *skb);
83647  
83648 @@ -69,7 +69,8 @@
83649         skb = skb_share_check(skb, GFP_ATOMIC);
83650         if (!skb)
83651                 goto out;
83652 -       fix_up_incoming_skb(skb);
83653 +       if (!fix_up_incoming_skb(skb))
83654 +               goto drop;
83655         pdu = llc_pdu_sn_hdr(skb);
83656         if (!pdu->dsap) { /* NULL DSAP, refer to station */
83657                 dprintk("%s: calling llc_station_rcv!\n", __FUNCTION__);
83658 @@ -172,11 +173,15 @@
83659   *     by looking at the two lowest-order bits of the first control field
83660   *     byte; field is either 3 or 4 bytes long.
83661   */
83662 -static void fix_up_incoming_skb(struct sk_buff *skb)
83663 +static int fix_up_incoming_skb(struct sk_buff *skb)
83664  {
83665         u8 llc_len = 2;
83666 -       struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->data;
83667 +       struct llc_pdu_sn *pdu;
83668 +
83669 +       if (!pskb_may_pull(skb, sizeof(*pdu)))
83670 +               return 0;
83671  
83672 +       pdu = (struct llc_pdu_sn *)skb->data;
83673         if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) == LLC_PDU_TYPE_U)
83674                 llc_len = 1;
83675         llc_len += 2;
83676 @@ -188,6 +193,7 @@
83677  
83678                 skb_trim(skb, data_size);
83679         }
83680 +       return 1;
83681  }
83682  
83683  /*
83684 diff -Nru a/net/llc/llc_main.c b/net/llc/llc_main.c
83685 --- a/net/llc/llc_main.c        Mon Jun 16 08:11:36 2003
83686 +++ b/net/llc/llc_main.c        Tue Sep  2 04:38:10 2003
83687 @@ -229,6 +229,7 @@
83688         if (llc_sk_init(sk))
83689                 goto outsk;
83690         sock_init_data(NULL, sk);
83691 +       sk_set_owner(sk, THIS_MODULE);
83692  #ifdef LLC_REFCNT_DEBUG
83693         atomic_inc(&llc_sock_nr);
83694         printk(KERN_DEBUG "LLC socket %p created in %s, now we have %d alive\n", sk,
83695 @@ -603,3 +604,4 @@
83696  MODULE_LICENSE("GPL");
83697  MODULE_AUTHOR("Procom, 1997, Arnaldo C. Melo, Jay Schullist, 2001-2003");
83698  MODULE_DESCRIPTION("LLC 2.0, NET4.0 IEEE 802.2 extended support");
83699 +MODULE_ALIAS_NETPROTO(PF_LLC);
83700 diff -Nru a/net/llc/llc_proc.c b/net/llc/llc_proc.c
83701 --- a/net/llc/llc_proc.c        Mon Jun 16 08:11:36 2003
83702 +++ b/net/llc/llc_proc.c        Sat Aug 30 19:11:23 2003
83703 @@ -245,6 +245,7 @@
83704         llc_proc_dir = proc_mkdir("llc", proc_net);
83705         if (!llc_proc_dir)
83706                 goto out;
83707 +       llc_proc_dir->owner = THIS_MODULE;
83708  
83709         p = create_proc_entry("socket", S_IRUGO, llc_proc_dir);
83710         if (!p)
83711 diff -Nru a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
83712 --- a/net/netlink/af_netlink.c  Sat Jul 12 22:45:18 2003
83713 +++ b/net/netlink/af_netlink.c  Tue Sep  2 12:03:57 2003
83714 @@ -40,6 +40,7 @@
83715  #include <linux/netdevice.h>
83716  #include <linux/rtnetlink.h>
83717  #include <linux/proc_fs.h>
83718 +#include <linux/seq_file.h>
83719  #include <linux/smp_lock.h>
83720  #include <linux/notifier.h>
83721  #include <linux/security.h>
83722 @@ -964,62 +965,108 @@
83723  
83724  #endif
83725  
83726 -
83727  #ifdef CONFIG_PROC_FS
83728 -static int netlink_read_proc(char *buffer, char **start, off_t offset,
83729 -                            int length, int *eof, void *data)
83730 +static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos)
83731  {
83732 -       off_t pos=0;
83733 -       off_t begin=0;
83734 -       int len=0;
83735         int i;
83736         struct sock *s;
83737         struct hlist_node *node;
83738 -       
83739 -       len+= sprintf(buffer,"sk       Eth Pid    Groups   "
83740 -                     "Rmem     Wmem     Dump     Locks\n");
83741 -       
83742 +       loff_t off = 0;
83743 +
83744         for (i=0; i<MAX_LINKS; i++) {
83745 -               read_lock(&nl_table_lock);
83746                 sk_for_each(s, node, &nl_table[i]) {
83747 -                       struct netlink_opt *nlk = nlk_sk(s);
83748 +                       if (off == pos) {
83749 +                               seq->private = (void *) i;
83750 +                               return s;
83751 +                       }
83752 +                       ++off;
83753 +               }
83754 +       }
83755 +       return NULL;
83756 +}
83757  
83758 -                       len+=sprintf(buffer+len,"%p %-3d %-6d %08x %-8d %-8d %p %d",
83759 -                                    s,
83760 -                                    s->sk_protocol,
83761 -                                    nlk->pid,
83762 -                                    nlk->groups,
83763 -                                    atomic_read(&s->sk_rmem_alloc),
83764 -                                    atomic_read(&s->sk_wmem_alloc),
83765 -                                    nlk->cb,
83766 -                                    atomic_read(&s->sk_refcnt)
83767 -                                    );
83768 +static void *netlink_seq_start(struct seq_file *seq, loff_t *pos)
83769 +{
83770 +       read_lock(&nl_table_lock);
83771 +       return *pos ? netlink_seq_socket_idx(seq, *pos - 1) : (void *) 1;
83772 +}
83773 +
83774 +static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
83775 +{
83776 +       struct sock *s;
83777 +
83778 +       ++*pos;
83779  
83780 -                       buffer[len++]='\n';
83781 +       if (v == (void *) 1) 
83782 +               return netlink_seq_socket_idx(seq, 0);
83783                 
83784 -                       pos=begin+len;
83785 -                       if(pos<offset) {
83786 -                               len=0;
83787 -                               begin=pos;
83788 -                       }
83789 -                       if(pos>offset+length) {
83790 -                               read_unlock(&nl_table_lock);
83791 -                               goto done;
83792 +       s = sk_next(v);
83793 +       if (!s) {
83794 +               int i = (int) seq->private; 
83795 +
83796 +               while (++i < MAX_LINKS) {
83797 +                       s = sk_head(&nl_table[i]);
83798 +                       if (s) {
83799 +                               seq->private = (void *) i;
83800 +                               break;
83801                         }
83802                 }
83803 -               read_unlock(&nl_table_lock);
83804         }
83805 -       *eof = 1;
83806 +       return s;
83807 +}
83808  
83809 -done:
83810 -       *start=buffer+(offset-begin);
83811 -       len-=(offset-begin);
83812 -       if(len>length)
83813 -               len=length;
83814 -       if(len<0)
83815 -               len=0;
83816 -       return len;
83817 +static void netlink_seq_stop(struct seq_file *seq, void *v)
83818 +{
83819 +       read_unlock(&nl_table_lock);
83820 +}
83821 +
83822 +
83823 +static int netlink_seq_show(struct seq_file *seq, void *v)
83824 +{
83825 +       if (v == (void *)1) 
83826 +               seq_puts(seq,
83827 +                        "sk       Eth Pid    Groups   "
83828 +                        "Rmem     Wmem     Dump     Locks\n");
83829 +       else {
83830 +               struct sock *s = v;
83831 +               struct netlink_opt *nlk = nlk_sk(s);
83832 +
83833 +               seq_printf(seq, "%p %-3d %-6d %08x %-8d %-8d %p %d\n",
83834 +                          s,
83835 +                          s->sk_protocol,
83836 +                          nlk->pid,
83837 +                          nlk->groups,
83838 +                          atomic_read(&s->sk_rmem_alloc),
83839 +                          atomic_read(&s->sk_wmem_alloc),
83840 +                          nlk->cb,
83841 +                          atomic_read(&s->sk_refcnt)
83842 +                       );
83843 +
83844 +       }
83845 +       return 0;
83846  }
83847 +
83848 +struct seq_operations netlink_seq_ops = {
83849 +       .start  = netlink_seq_start,
83850 +       .next   = netlink_seq_next,
83851 +       .stop   = netlink_seq_stop,
83852 +       .show   = netlink_seq_show,
83853 +};
83854 +
83855 +
83856 +static int netlink_seq_open(struct inode *inode, struct file *file)
83857 +{
83858 +       return seq_open(file, &netlink_seq_ops);
83859 +}
83860 +
83861 +static struct file_operations netlink_seq_fops = {
83862 +       .owner          = THIS_MODULE,
83863 +       .open           = netlink_seq_open,
83864 +       .read           = seq_read,
83865 +       .llseek         = seq_lseek,
83866 +       .release        = seq_release,
83867 +};
83868 +
83869  #endif
83870  
83871  int netlink_register_notifier(struct notifier_block *nb)
83872 @@ -1069,7 +1116,7 @@
83873         }
83874         sock_register(&netlink_family_ops);
83875  #ifdef CONFIG_PROC_FS
83876 -       create_proc_read_entry("net/netlink", 0, 0, netlink_read_proc, NULL);
83877 +       proc_net_fops_create("netlink", 0, &netlink_seq_fops);
83878  #endif
83879         /* The netlink device handler may be needed early. */ 
83880         rtnetlink_init();
83881 @@ -1079,10 +1126,11 @@
83882  static void __exit netlink_proto_exit(void)
83883  {
83884         sock_unregister(PF_NETLINK);
83885 -       remove_proc_entry("net/netlink", NULL);
83886 +       proc_net_remove("netlink");
83887  }
83888  
83889  core_initcall(netlink_proto_init);
83890  module_exit(netlink_proto_exit);
83891  
83892  MODULE_LICENSE("GPL");
83893 +MODULE_ALIAS_NETPROTO(PF_NETLINK);
83894 diff -Nru a/net/netlink/netlink_dev.c b/net/netlink/netlink_dev.c
83895 --- a/net/netlink/netlink_dev.c Sun May 25 19:34:11 2003
83896 +++ b/net/netlink/netlink_dev.c Tue Aug 26 09:25:41 2003
83897 @@ -41,7 +41,7 @@
83898   
83899  static unsigned int netlink_poll(struct file *file, poll_table * wait)
83900  {
83901 -       struct socket *sock = netlink_user[minor(file->f_dentry->d_inode->i_rdev)];
83902 +       struct socket *sock = netlink_user[iminor(file->f_dentry->d_inode)];
83903  
83904         if (sock->ops->poll==NULL)
83905                 return 0;
83906 @@ -56,7 +56,7 @@
83907                              size_t count, loff_t *pos)
83908  {
83909         struct inode *inode = file->f_dentry->d_inode;
83910 -       struct socket *sock = netlink_user[minor(inode->i_rdev)];
83911 +       struct socket *sock = netlink_user[iminor(inode)];
83912         struct msghdr msg;
83913         struct iovec iov;
83914  
83915 @@ -80,7 +80,7 @@
83916                             size_t count, loff_t *pos)
83917  {
83918         struct inode *inode = file->f_dentry->d_inode;
83919 -       struct socket *sock = netlink_user[minor(inode->i_rdev)];
83920 +       struct socket *sock = netlink_user[iminor(inode)];
83921         struct msghdr msg;
83922         struct iovec iov;
83923  
83924 @@ -100,7 +100,7 @@
83925  
83926  static int netlink_open(struct inode * inode, struct file * file)
83927  {
83928 -       unsigned int minor = minor(inode->i_rdev);
83929 +       unsigned int minor = iminor(inode);
83930         struct socket *sock;
83931         struct sockaddr_nl nladdr;
83932         int err;
83933 @@ -132,7 +132,7 @@
83934  
83935  static int netlink_release(struct inode * inode, struct file * file)
83936  {
83937 -       unsigned int minor = minor(inode->i_rdev);
83938 +       unsigned int minor = iminor(inode);
83939         struct socket *sock;
83940  
83941         sock = netlink_user[minor];
83942 @@ -146,7 +146,7 @@
83943  static int netlink_ioctl(struct inode *inode, struct file *file,
83944                     unsigned int cmd, unsigned long arg)
83945  {
83946 -       unsigned int minor = minor(inode->i_rdev);
83947 +       unsigned int minor = iminor(inode);
83948         int retval = 0;
83949  
83950         if (minor >= MAX_LINKS)
83951 diff -Nru a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
83952 --- a/net/netrom/af_netrom.c    Thu Aug 14 21:16:39 2003
83953 +++ b/net/netrom/af_netrom.c    Tue Sep  2 04:38:10 2003
83954 @@ -433,6 +433,7 @@
83955         nr = nr_sk(sk);
83956  
83957         sock_init_data(sock, sk);
83958 +       sk_set_owner(sk, THIS_MODULE);
83959  
83960         sock->ops    = &nr_proto_ops;
83961         sk->sk_protocol = protocol;
83962 @@ -473,6 +474,7 @@
83963         nr = nr_sk(sk);
83964  
83965         sock_init_data(NULL, sk);
83966 +       sk_set_owner(sk, THIS_MODULE);
83967  
83968         sk->sk_type     = osk->sk_type;
83969         sk->sk_socket   = osk->sk_socket;
83970 @@ -1458,6 +1460,7 @@
83971  MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>");
83972  MODULE_DESCRIPTION("The amateur radio NET/ROM network and transport layer protocol");
83973  MODULE_LICENSE("GPL");
83974 +MODULE_ALIAS_NETPROTO(PF_NETROM);
83975  
83976  static void __exit nr_exit(void)
83977  {
83978 diff -Nru a/net/netsyms.c b/net/netsyms.c
83979 --- a/net/netsyms.c     Tue Aug 19 22:13:11 2003
83980 +++ b/net/netsyms.c     Mon Sep  1 17:25:54 2003
83981 @@ -631,7 +631,10 @@
83982  /* ethtool.c */
83983  EXPORT_SYMBOL(ethtool_op_get_link);
83984  EXPORT_SYMBOL(ethtool_op_get_tx_csum);
83985 +EXPORT_SYMBOL(ethtool_op_set_tx_csum);
83986  EXPORT_SYMBOL(ethtool_op_get_sg);
83987  EXPORT_SYMBOL(ethtool_op_set_sg);
83988 +EXPORT_SYMBOL(ethtool_op_get_tso);
83989 +EXPORT_SYMBOL(ethtool_op_set_tso);
83990  
83991  #endif  /* CONFIG_NET */
83992 diff -Nru a/net/packet/af_packet.c b/net/packet/af_packet.c
83993 --- a/net/packet/af_packet.c    Wed Jul  2 08:40:36 2003
83994 +++ b/net/packet/af_packet.c    Tue Sep  2 04:38:10 2003
83995 @@ -1832,3 +1832,4 @@
83996  module_init(packet_init);
83997  module_exit(packet_exit);
83998  MODULE_LICENSE("GPL");
83999 +MODULE_ALIAS_NETPROTO(PF_PACKET);
84000 diff -Nru a/net/rose/af_rose.c b/net/rose/af_rose.c
84001 --- a/net/rose/af_rose.c        Tue Aug 19 20:57:58 2003
84002 +++ b/net/rose/af_rose.c        Tue Sep  2 04:38:10 2003
84003 @@ -518,6 +518,7 @@
84004         rose = rose_sk(sk);
84005  
84006         sock_init_data(sock, sk);
84007 +       sk_set_owner(sk, THIS_MODULE);
84008  
84009         skb_queue_head_init(&rose->ack_queue);
84010  #ifdef M_BIT
84011 @@ -556,6 +557,7 @@
84012         rose = rose_sk(sk);
84013  
84014         sock_init_data(NULL, sk);
84015 +       sk_set_owner(sk, THIS_MODULE);
84016  
84017         skb_queue_head_init(&rose->ack_queue);
84018  #ifdef M_BIT
84019 @@ -1549,6 +1551,7 @@
84020  MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>");
84021  MODULE_DESCRIPTION("The amateur radio ROSE network layer protocol");
84022  MODULE_LICENSE("GPL");
84023 +MODULE_ALIAS_NETPROTO(PF_ROSE);
84024  
84025  static void __exit rose_exit(void)
84026  {
84027 diff -Nru a/net/rxrpc/krxiod.c b/net/rxrpc/krxiod.c
84028 --- a/net/rxrpc/krxiod.c        Tue Feb 11 14:57:54 2003
84029 +++ b/net/rxrpc/krxiod.c        Sat Aug 30 20:36:03 2003
84030 @@ -9,7 +9,6 @@
84031   * 2 of the License, or (at your option) any later version.
84032   */
84033  
84034 -#include <linux/version.h>
84035  #include <linux/sched.h>
84036  #include <linux/completion.h>
84037  #include <linux/spinlock.h>
84038 diff -Nru a/net/rxrpc/krxsecd.c b/net/rxrpc/krxsecd.c
84039 --- a/net/rxrpc/krxsecd.c       Tue Feb 11 14:57:54 2003
84040 +++ b/net/rxrpc/krxsecd.c       Sat Aug 30 20:36:03 2003
84041 @@ -14,7 +14,6 @@
84042   * - responding to security challenges on outbound connections
84043   */
84044  
84045 -#include <linux/version.h>
84046  #include <linux/module.h>
84047  #include <linux/sched.h>
84048  #include <linux/completion.h>
84049 diff -Nru a/net/rxrpc/krxtimod.c b/net/rxrpc/krxtimod.c
84050 --- a/net/rxrpc/krxtimod.c      Sun Apr 20 07:45:44 2003
84051 +++ b/net/rxrpc/krxtimod.c      Sat Aug 30 20:36:03 2003
84052 @@ -9,7 +9,6 @@
84053   * 2 of the License, or (at your option) any later version.
84054   */
84055  
84056 -#include <linux/version.h>
84057  #include <linux/module.h>
84058  #include <linux/init.h>
84059  #include <linux/sched.h>
84060 diff -Nru a/net/sched/sch_generic.c b/net/sched/sch_generic.c
84061 --- a/net/sched/sch_generic.c   Sun Apr 20 00:57:16 2003
84062 +++ b/net/sched/sch_generic.c   Mon Sep  1 01:18:30 2003
84063 @@ -121,7 +121,7 @@
84064                                         printk(KERN_DEBUG "Dead loop on netdevice %s, fix it urgently!\n", dev->name);
84065                                 return -1;
84066                         }
84067 -                       netdev_rx_stat[smp_processor_id()].cpu_collision++;
84068 +                       __get_cpu_var(netdev_rx_stat).cpu_collision++;
84069                 }
84070  
84071                 /* Device kicked us out :(
84072 diff -Nru a/net/sctp/socket.c b/net/sctp/socket.c
84073 --- a/net/sctp/socket.c Mon Aug  4 10:35:40 2003
84074 +++ b/net/sctp/socket.c Thu Aug 28 01:21:04 2003
84075 @@ -852,7 +852,7 @@
84076                 associd = sinfo->sinfo_assoc_id;
84077         }
84078  
84079 -       SCTP_DEBUG_PRINTK("msg_len: %Zd, sinfo_flags: 0x%x\n",
84080 +       SCTP_DEBUG_PRINTK("msg_len: %d, sinfo_flags: 0x%x\n",
84081                           msg_len, sinfo_flags);
84082  
84083         /* MSG_EOF or MSG_ABORT cannot be set on a TCP-style socket. */
84084 diff -Nru a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
84085 --- a/net/sunrpc/rpc_pipe.c     Sat Jun 14 16:58:21 2003
84086 +++ b/net/sunrpc/rpc_pipe.c     Sat Aug 30 20:35:33 2003
84087 @@ -10,7 +10,6 @@
84088   */
84089  #include <linux/config.h>
84090  #include <linux/module.h>
84091 -#include <linux/version.h>
84092  #include <linux/slab.h>
84093  #include <linux/string.h>
84094  #include <linux/pagemap.h>
84095 diff -Nru a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
84096 --- a/net/sunrpc/svcsock.c      Mon Aug 18 15:49:47 2003
84097 +++ b/net/sunrpc/svcsock.c      Sat Aug 30 20:35:33 2003
84098 @@ -27,7 +27,6 @@
84099  #include <linux/inet.h>
84100  #include <linux/udp.h>
84101  #include <linux/tcp.h>
84102 -#include <linux/version.h>
84103  #include <linux/unistd.h>
84104  #include <linux/slab.h>
84105  #include <linux/netdevice.h>
84106 diff -Nru a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
84107 --- a/net/sunrpc/sysctl.c       Mon Aug 11 22:33:48 2003
84108 +++ b/net/sunrpc/sysctl.c       Sat Aug 30 20:35:33 2003
84109 @@ -8,7 +8,6 @@
84110   */
84111  
84112  #include <linux/config.h>
84113 -#include <linux/version.h>
84114  #include <linux/types.h>
84115  #include <linux/linkage.h>
84116  #include <linux/ctype.h>
84117 diff -Nru a/net/sunrpc/timer.c b/net/sunrpc/timer.c
84118 --- a/net/sunrpc/timer.c        Thu Aug 21 18:32:56 2003
84119 +++ b/net/sunrpc/timer.c        Sat Aug 30 20:35:33 2003
84120 @@ -15,7 +15,6 @@
84121  
84122  #include <asm/param.h>
84123  
84124 -#include <linux/version.h>
84125  #include <linux/types.h>
84126  #include <linux/unistd.h>
84127  
84128 diff -Nru a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
84129 --- a/net/sunrpc/xprt.c Thu Aug 21 18:41:58 2003
84130 +++ b/net/sunrpc/xprt.c Sat Aug 30 20:35:33 2003
84131 @@ -45,7 +45,6 @@
84132  
84133  #define __KERNEL_SYSCALLS__
84134  
84135 -#include <linux/version.h>
84136  #include <linux/types.h>
84137  #include <linux/slab.h>
84138  #include <linux/capability.h>
84139 diff -Nru a/net/unix/af_unix.c b/net/unix/af_unix.c
84140 --- a/net/unix/af_unix.c        Sun Jun 29 23:49:26 2003
84141 +++ b/net/unix/af_unix.c        Tue Sep  2 04:38:10 2003
84142 @@ -1965,3 +1965,4 @@
84143  module_exit(af_unix_exit);
84144  
84145  MODULE_LICENSE("GPL");
84146 +MODULE_ALIAS_NETPROTO(PF_UNIX);
84147 diff -Nru a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c
84148 --- a/net/wanrouter/af_wanpipe.c        Wed Jun 18 13:59:01 2003
84149 +++ b/net/wanrouter/af_wanpipe.c        Tue Sep  2 04:38:10 2003
84150 @@ -2600,3 +2600,4 @@
84151  }
84152  #endif
84153  MODULE_LICENSE("GPL");
84154 +MODULE_ALIAS_NETPROTO(PF_WANPIPE);
84155 diff -Nru a/net/x25/af_x25.c b/net/x25/af_x25.c
84156 --- a/net/x25/af_x25.c  Tue Aug  5 17:31:06 2003
84157 +++ b/net/x25/af_x25.c  Tue Sep  2 04:38:10 2003
84158 @@ -449,6 +449,7 @@
84159         x25->sk = sk;
84160  
84161         sock_init_data(NULL, sk);
84162 +       sk_set_owner(sk, THIS_MODULE);
84163  
84164         skb_queue_head_init(&x25->ack_queue);
84165         skb_queue_head_init(&x25->fragment_queue);
84166 @@ -478,6 +479,7 @@
84167         x25 = x25_sk(sk);
84168  
84169         sock_init_data(sock, sk);
84170 +       sk_set_owner(sk, THIS_MODULE);
84171  
84172         init_timer(&x25->timer);
84173  
84174 @@ -1421,3 +1423,4 @@
84175  MODULE_AUTHOR("Jonathan Naylor <g4klx@g4klx.demon.co.uk>");
84176  MODULE_DESCRIPTION("The X.25 Packet Layer network layer protocol");
84177  MODULE_LICENSE("GPL");
84178 +MODULE_ALIAS_NETPROTO(PF_X25);
84179 diff -Nru a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
84180 --- a/net/xfrm/xfrm_user.c      Thu Aug  7 21:04:46 2003
84181 +++ b/net/xfrm/xfrm_user.c      Mon Sep  1 01:12:32 2003
84182 @@ -1195,3 +1195,4 @@
84183  
84184  module_init(xfrm_user_init);
84185  module_exit(xfrm_user_exit);
84186 +MODULE_LICENSE("GPL");
84187 diff -Nru a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
84188 --- a/scripts/kconfig/Makefile  Tue Aug 19 09:27:03 2003
84189 +++ b/scripts/kconfig/Makefile  Sun Aug 31 16:13:49 2003
84190 @@ -2,40 +2,43 @@
84191  # Kernel configuration targets
84192  # These targets are used from top-level makefile
84193  
84194 -.PHONY: oldconfig xconfig gconfig menuconfig config
84195 +.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig
84196  
84197 -xconfig: scripts/kconfig/qconf
84198 -       ./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
84199 +xconfig: $(obj)/qconf
84200 +       $< arch/$(ARCH)/Kconfig
84201  
84202 -gconfig: scripts/kconfig/gconf
84203 -       ./scripts/kconfig/gconf arch/$(ARCH)/Kconfig
84204 +gconfig: $(obj)/gconf
84205 +       ./$<  arch/$(ARCH)/Kconfig
84206  
84207 -menuconfig: scripts/kconfig/mconf
84208 +menuconfig: $(obj)/mconf
84209         $(Q)$(MAKE) $(build)=scripts/lxdialog
84210 -       ./scripts/kconfig/mconf arch/$(ARCH)/Kconfig
84211 +       $< arch/$(ARCH)/Kconfig
84212  
84213 -config: scripts/kconfig/conf
84214 -       ./scripts/kconfig/conf arch/$(ARCH)/Kconfig
84215 +config: $(obj)/conf
84216 +       $< arch/$(ARCH)/Kconfig
84217  
84218 -oldconfig: scripts/kconfig/conf
84219 -       ./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
84220 +oldconfig: $(obj)/conf
84221 +       $< -o arch/$(ARCH)/Kconfig
84222 +
84223 +silentoldconfig: $(obj)/conf
84224 +       $< -s arch/$(ARCH)/Kconfig
84225  
84226  .PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
84227  
84228 -randconfig: scripts/kconfig/conf
84229 -       ./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
84230 +randconfig: $(obj)/conf
84231 +       $< -r arch/$(ARCH)/Kconfig
84232  
84233 -allyesconfig: scripts/kconfig/conf
84234 -       ./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
84235 +allyesconfig: $(obj)/conf
84236 +       $< -y arch/$(ARCH)/Kconfig
84237  
84238 -allnoconfig: scripts/kconfig/conf
84239 -       ./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
84240 +allnoconfig: $(obj)/conf
84241 +       $< -n arch/$(ARCH)/Kconfig
84242  
84243 -allmodconfig: scripts/kconfig/conf
84244 -       ./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
84245 +allmodconfig: $(obj)/conf
84246 +       $< -m arch/$(ARCH)/Kconfig
84247  
84248 -defconfig: scripts/kconfig/conf
84249 -       ./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
84250 +defconfig: $(obj)/conf
84251 +       $< -d arch/$(ARCH)/Kconfig
84252  
84253  # Help text used by make help
84254  help:
84255 diff -Nru a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
84256 --- a/scripts/kconfig/symbol.c  Fri Jun  6 01:28:22 2003
84257 +++ b/scripts/kconfig/symbol.c  Sun Aug 31 16:14:08 2003
84258 @@ -12,21 +12,21 @@
84259  #include "lkc.h"
84260  
84261  struct symbol symbol_yes = {
84262 -       name: "y",
84263 -       curr: { "y", yes },
84264 -       flags: SYMBOL_YES|SYMBOL_VALID,
84265 +       .name = "y",
84266 +       .curr = { "y", yes },
84267 +       .flags = SYMBOL_YES|SYMBOL_VALID,
84268  }, symbol_mod = {
84269 -       name: "m",
84270 -       curr: { "m", mod },
84271 -       flags: SYMBOL_MOD|SYMBOL_VALID,
84272 +       .name = "m",
84273 +       .curr = { "m", mod },
84274 +       .flags = SYMBOL_MOD|SYMBOL_VALID,
84275  }, symbol_no = {
84276 -       name: "n",
84277 -       curr: { "n", no },
84278 -       flags: SYMBOL_NO|SYMBOL_VALID,
84279 +       .name = "n",
84280 +       .curr = { "n", no },
84281 +       .flags = SYMBOL_NO|SYMBOL_VALID,
84282  }, symbol_empty = {
84283 -       name: "",
84284 -       curr: { "", no },
84285 -       flags: SYMBOL_VALID,
84286 +       .name = "",
84287 +       .curr = { "", no },
84288 +       .flags = SYMBOL_VALID,
84289  };
84290  
84291  int sym_change_count;
84292 diff -Nru a/security/capability.c b/security/capability.c
84293 --- a/security/capability.c     Wed Jul  2 21:22:38 2003
84294 +++ b/security/capability.c     Sun Aug 31 16:14:14 2003
84295 @@ -295,12 +295,7 @@
84296  
84297         vm_acct_memory(pages);
84298  
84299 -        /*
84300 -        * Sometimes we want to use more memory than we have
84301 -        */
84302 -       if (sysctl_overcommit_memory == 1)
84303 -               return 0;
84304 -
84305 +       /* We estimate memory ourselves (common case) */
84306         if (sysctl_overcommit_memory == 0) {
84307                 free = get_page_cache_size();
84308                 free += nr_free_pages();
84309 @@ -322,10 +317,16 @@
84310  
84311                 if (free > pages)
84312                         return 0;
84313 +
84314                 vm_unacct_memory(pages);
84315                 return -ENOMEM;
84316         }
84317  
84318 +       /* Kernel assumes allocation */
84319 +       if (sysctl_overcommit_memory == 1)
84320 +               return 0;
84321 +
84322 +       /* sysctl_overcommit_memory must be 2 which means strict_overcommit*/
84323         allowed = totalram_pages * sysctl_overcommit_ratio / 100;
84324         allowed += total_swap_pages;
84325  
84326 diff -Nru a/security/selinux/Kconfig b/security/selinux/Kconfig
84327 --- a/security/selinux/Kconfig  Thu Jul 17 02:38:01 2003
84328 +++ b/security/selinux/Kconfig  Wed Sep  3 23:40:18 2003
84329 @@ -3,11 +3,14 @@
84330         depends on SECURITY
84331         default n
84332         help
84333 -         This enables NSA Security-Enhanced Linux (SELinux).
84334 +         This selects NSA Security-Enhanced Linux (SELinux).
84335           You will also need a policy configuration and a labeled filesystem.
84336           You can obtain the policy compiler (checkpolicy), the utility for
84337           labeling filesystems (setfiles), and an example policy configuration
84338           from http://www.nsa.gov/selinux.
84339 +         SELinux needs to be explicitly enabled on the kernel command line with
84340 +         selinux=1.  If you specify selinux=0 or do not use this parameter,
84341 +         SELinux will not be enabled.
84342           If you are unsure how to answer this question, answer N.
84343  
84344  config SECURITY_SELINUX_DEVELOP
84345 diff -Nru a/security/selinux/hooks.c b/security/selinux/hooks.c
84346 --- a/security/selinux/hooks.c  Mon Aug 18 22:27:19 2003
84347 +++ b/security/selinux/hooks.c  Wed Sep  3 23:40:18 2003
84348 @@ -73,6 +73,15 @@
84349  __setup("enforcing=", enforcing_setup);
84350  #endif
84351  
84352 +int selinux_enabled = 0;
84353 +
84354 +static int __init selinux_enabled_setup(char *str)
84355 +{
84356 +       selinux_enabled = simple_strtol(str, NULL, 0);
84357 +       return 1;
84358 +}
84359 +__setup("selinux=", selinux_enabled_setup);
84360 +
84361  /* Original (dummy) security module. */
84362  static struct security_operations *original_ops = NULL;
84363  
84364 @@ -1332,31 +1341,19 @@
84365  
84366  static int selinux_bprm_alloc_security(struct linux_binprm *bprm)
84367  {
84368 -       int rc;
84369 +       struct bprm_security_struct *bsec;
84370  
84371 -       /* Make sure that the secondary module doesn't use the
84372 -          bprm->security field, since we do not yet support chaining
84373 -          of multiple security structures on the field.  Neither
84374 -          the dummy nor the capability module use the field.  The owlsm
84375 -          module uses the field if CONFIG_OWLSM_FD is enabled. */
84376 -       rc = secondary_ops->bprm_alloc_security(bprm);
84377 -       if (rc)
84378 -               return rc;
84379 -       if (bprm->security) {
84380 -               printk(KERN_WARNING "%s: no support yet for chaining on the "
84381 -                      "security field by secondary modules.\n", __FUNCTION__);
84382 -               /* Release the secondary module's security object. */
84383 -               secondary_ops->bprm_free_security(bprm);
84384 -               /* Unregister the secondary module to prevent problems
84385 -                  with subsequent binprm hooks. This will revert to the
84386 -                  original (dummy) module for the secondary operations. */
84387 -               rc = security_ops->unregister_security("unknown", secondary_ops);
84388 -               if (rc)
84389 -                       return rc;
84390 -               printk(KERN_WARNING "%s: Unregistered the secondary security "
84391 -                      "module.\n", __FUNCTION__);
84392 -       }
84393 -       bprm->security = NULL;
84394 +       bsec = kmalloc(sizeof(struct bprm_security_struct), GFP_KERNEL);
84395 +       if (!bsec)
84396 +               return -ENOMEM;
84397 +
84398 +       memset(bsec, 0, sizeof *bsec);
84399 +       bsec->magic = SELINUX_MAGIC;
84400 +       bsec->bprm = bprm;
84401 +       bsec->sid = SECINITSID_UNLABELED;
84402 +       bsec->set = 0;
84403 +
84404 +       bprm->security = bsec;
84405         return 0;
84406  }
84407  
84408 @@ -1365,6 +1362,7 @@
84409         struct task_security_struct *tsec;
84410         struct inode *inode = bprm->file->f_dentry->d_inode;
84411         struct inode_security_struct *isec;
84412 +       struct bprm_security_struct *bsec;
84413         u32 newsid;
84414         struct avc_audit_data ad;
84415         int rc;
84416 @@ -1373,15 +1371,16 @@
84417         if (rc)
84418                 return rc;
84419  
84420 -       if (bprm->sh_bang || bprm->security)
84421 -               /* The security field should already be set properly. */
84422 +       bsec = bprm->security;
84423 +
84424 +       if (bsec->set)
84425                 return 0;
84426  
84427         tsec = current->security;
84428         isec = inode->i_security;
84429  
84430         /* Default to the current task SID. */
84431 -       bprm->security = (void *)tsec->sid;
84432 +       bsec->sid = tsec->sid;
84433  
84434         /* Reset create SID on execve. */
84435         tsec->create_sid = 0;
84436 @@ -1427,9 +1426,10 @@
84437                         return rc;
84438  
84439                 /* Set the security field to the new SID. */
84440 -               bprm->security = (void*) newsid;
84441 +               bsec->sid = newsid;
84442         }
84443  
84444 +       bsec->set = 1;
84445         return 0;
84446  }
84447  
84448 @@ -1463,8 +1463,9 @@
84449  
84450  static void selinux_bprm_free_security(struct linux_binprm *bprm)
84451  {
84452 -       /* Nothing to do - not dynamically allocated. */
84453 -       return;
84454 +       struct bprm_security_struct *bsec = bprm->security;
84455 +       bprm->security = NULL;
84456 +       kfree(bsec);
84457  }
84458  
84459  /* Derived from fs/exec.c:flush_old_files. */
84460 @@ -1509,6 +1510,7 @@
84461  static void selinux_bprm_compute_creds(struct linux_binprm *bprm)
84462  {
84463         struct task_security_struct *tsec, *psec;
84464 +       struct bprm_security_struct *bsec;
84465         u32 sid;
84466         struct av_decision avd;
84467         int rc;
84468 @@ -1517,9 +1519,8 @@
84469  
84470         tsec = current->security;
84471  
84472 -       sid = (u32)bprm->security;
84473 -       if (!sid)
84474 -               sid = tsec->sid;
84475 +       bsec = bprm->security;
84476 +       sid = bsec->sid;
84477  
84478         tsec->osid = tsec->sid;
84479         if (tsec->sid != sid) {
84480 @@ -2057,9 +2058,11 @@
84481                 case F_GETLK:
84482                 case F_SETLK:
84483                 case F_SETLKW:
84484 +#if BITS_PER_LONG == 32
84485                 case F_GETLK64:
84486                 case F_SETLK64:
84487                 case F_SETLKW64:
84488 +#endif
84489                         if (!file->f_dentry || !file->f_dentry->d_inode) {
84490                                 err = -EINVAL;
84491                                 break;
84492 @@ -3112,9 +3115,8 @@
84493                                char *name, void *value, size_t size)
84494  {
84495         struct task_security_struct *tsec;
84496 -       u32 sid;
84497 +       u32 sid, len;
84498         char *context;
84499 -       size_t len;
84500         int error;
84501  
84502         if (current != p) {
84503 @@ -3353,6 +3355,11 @@
84504  __init int selinux_init(void)
84505  {
84506         struct task_security_struct *tsec;
84507 +
84508 +       if (!selinux_enabled) {
84509 +               printk(KERN_INFO "SELinux:  Not enabled at boot.\n");
84510 +               return 0;
84511 +       }
84512  
84513         printk(KERN_INFO "SELinux:  Initializing.\n");
84514  
84515 diff -Nru a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
84516 --- a/security/selinux/include/objsec.h Thu Aug 14 18:17:44 2003
84517 +++ b/security/selinux/include/objsec.h Sun Aug 31 16:14:20 2003
84518 @@ -21,6 +21,7 @@
84519  #include <linux/list.h>
84520  #include <linux/sched.h>
84521  #include <linux/fs.h>
84522 +#include <linux/binfmts.h>
84523  #include <linux/in.h>
84524  #include "flask.h"
84525  #include "avc.h"
84526 @@ -83,6 +84,13 @@
84527         u16 sclass;     /* security class of this object */
84528         u32 sid;              /* SID of IPC resource */
84529          struct avc_entry_ref avcr;     /* reference to permissions */
84530 +};
84531 +
84532 +struct bprm_security_struct {
84533 +       unsigned long magic;           /* magic number for this module */
84534 +       struct linux_binprm *bprm;     /* back pointer to bprm object */
84535 +       u32 sid;                       /* SID for transformed process */
84536 +       unsigned char set;
84537  };
84538  
84539  extern int inode_security_set_sid(struct inode *inode, u32 sid);
84540 diff -Nru a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
84541 --- a/security/selinux/selinuxfs.c      Thu Jul 17 02:38:01 2003
84542 +++ b/security/selinux/selinuxfs.c      Wed Sep  3 23:40:18 2003
84543 @@ -17,6 +17,8 @@
84544  #include "security.h"
84545  #include "objsec.h"
84546  
84547 +extern int selinux_enabled;
84548 +
84549  /* Check whether a task is allowed to use a security operation. */
84550  int task_has_security(struct task_struct *tsk,
84551                       u32 perms)
84552 @@ -587,7 +589,7 @@
84553  
84554  static int __init init_sel_fs(void)
84555  {
84556 -       return register_filesystem(&sel_fs_type);
84557 +       return selinux_enabled ? register_filesystem(&sel_fs_type) : 0;
84558  }
84559  
84560  __initcall(init_sel_fs);
84561 diff -Nru a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c
84562 --- a/security/selinux/ss/avtab.c       Thu Jul 17 02:38:01 2003
84563 +++ b/security/selinux/ss/avtab.c       Sun Aug 31 16:14:19 2003
84564 @@ -106,7 +106,7 @@
84565                 }
84566                 h->htable[i] = NULL;
84567         }
84568 -       kfree(h->htable);
84569 +       vfree(h->htable);
84570  }
84571  
84572  
84573 @@ -138,7 +138,7 @@
84574  {
84575         int i;
84576  
84577 -       h->htable = kmalloc(sizeof(*(h->htable)) * AVTAB_SIZE, GFP_KERNEL);
84578 +       h->htable = vmalloc(sizeof(*(h->htable)) * AVTAB_SIZE);
84579         if (!h->htable)
84580                 return -ENOMEM;
84581         for (i = 0; i < AVTAB_SIZE; i++)
84582 diff -Nru a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
84583 --- a/security/selinux/ss/ebitmap.c     Thu Jul 17 02:38:01 2003
84584 +++ b/security/selinux/ss/ebitmap.c     Sun Aug 31 16:14:19 2003
84585 @@ -250,8 +250,8 @@
84586         count = le32_to_cpu(buf[2]);
84587  
84588         if (mapsize != MAPSIZE) {
84589 -               printk(KERN_ERR "security: ebitmap: map size %d does not "
84590 -                      "match my size %d (high bit was %d)\n", mapsize,
84591 +               printk(KERN_ERR "security: ebitmap: map size %u does not "
84592 +                      "match my size %Zd (high bit was %d)\n", mapsize,
84593                        MAPSIZE, e->highbit);
84594                 goto out;
84595         }
84596 @@ -261,7 +261,7 @@
84597         }
84598         if (e->highbit & (MAPSIZE - 1)) {
84599                 printk(KERN_ERR "security: ebitmap: high bit (%d) is not a "
84600 -                      "multiple of the map size (%d)\n", e->highbit, MAPSIZE);
84601 +                      "multiple of the map size (%Zd)\n", e->highbit, MAPSIZE);
84602                 goto bad;
84603         }
84604         l = NULL;
84605 @@ -283,13 +283,13 @@
84606  
84607                 if (n->startbit & (MAPSIZE - 1)) {
84608                         printk(KERN_ERR "security: ebitmap start bit (%d) is "
84609 -                              "not a multiple of the map size (%d)\n",
84610 +                              "not a multiple of the map size (%Zd)\n",
84611                                n->startbit, MAPSIZE);
84612                         goto bad_free;
84613                 }
84614                 if (n->startbit > (e->highbit - MAPSIZE)) {
84615                         printk(KERN_ERR "security: ebitmap start bit (%d) is "
84616 -                              "beyond the end of the bitmap (%d)\n",
84617 +                              "beyond the end of the bitmap (%Zd)\n",
84618                                n->startbit, (e->highbit - MAPSIZE));
84619                         goto bad_free;
84620                 }
84621 diff -Nru a/security/selinux/ss/global.h b/security/selinux/ss/global.h
84622 --- a/security/selinux/ss/global.h      Sun Aug 10 04:22:59 2003
84623 +++ b/security/selinux/ss/global.h      Sun Aug 31 16:14:19 2003
84624 @@ -8,6 +8,7 @@
84625  #include <linux/in.h>
84626  #include <linux/spinlock.h>
84627  #include <linux/sched.h>
84628 +#include <linux/vmalloc.h>
84629  
84630  #include "flask.h"
84631  #include "avc.h"
84632 diff -Nru a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
84633 --- a/security/selinux/ss/policydb.c    Mon Aug 18 22:27:19 2003
84634 +++ b/security/selinux/ss/policydb.c    Sun Aug 31 16:14:19 2003
84635 @@ -1074,7 +1074,7 @@
84636         len = buf[1];
84637         if (len != strlen(POLICYDB_STRING)) {
84638                 printk(KERN_ERR "security:  policydb string length %d does not "
84639 -                      "match expected length %d\n",
84640 +                      "match expected length %Zd\n",
84641                        len, strlen(POLICYDB_STRING));
84642                 goto bad;
84643         }
84644 diff -Nru a/sound/core/control.c b/sound/core/control.c
84645 --- a/sound/core/control.c      Mon Jul 21 02:29:40 2003
84646 +++ b/sound/core/control.c      Tue Aug 26 09:25:41 2003
84647 @@ -42,7 +42,7 @@
84648  
84649  static int snd_ctl_open(struct inode *inode, struct file *file)
84650  {
84651 -       int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
84652 +       int cardnum = SNDRV_MINOR_CARD(iminor(inode));
84653         unsigned long flags;
84654         snd_card_t *card;
84655         snd_ctl_file_t *ctl;
84656 diff -Nru a/sound/core/hwdep.c b/sound/core/hwdep.c
84657 --- a/sound/core/hwdep.c        Sun Jun  1 11:47:53 2003
84658 +++ b/sound/core/hwdep.c        Tue Aug 26 09:25:41 2003
84659 @@ -73,7 +73,7 @@
84660  
84661  static int snd_hwdep_open(struct inode *inode, struct file * file)
84662  {
84663 -       int major = major(inode->i_rdev);
84664 +       int major = imajor(inode);
84665         int cardnum;
84666         int device;
84667         snd_hwdep_t *hw;
84668 @@ -82,12 +82,12 @@
84669  
84670         switch (major) {
84671         case CONFIG_SND_MAJOR:
84672 -               cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
84673 -               device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev)) - SNDRV_MINOR_HWDEP;
84674 +               cardnum = SNDRV_MINOR_CARD(iminor(inode));
84675 +               device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_HWDEP;
84676                 break;
84677  #ifdef CONFIG_SND_OSSEMUL
84678         case SOUND_MAJOR:
84679 -               cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
84680 +               cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
84681                 device = 0;
84682                 break;
84683  #endif
84684 diff -Nru a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
84685 --- a/sound/core/oss/mixer_oss.c        Sun Jun  1 11:47:53 2003
84686 +++ b/sound/core/oss/mixer_oss.c        Tue Aug 26 09:25:41 2003
84687 @@ -36,7 +36,7 @@
84688  
84689  static int snd_mixer_oss_open(struct inode *inode, struct file *file)
84690  {
84691 -       int cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
84692 +       int cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
84693         snd_card_t *card;
84694         snd_mixer_oss_file_t *fmixer;
84695         int err;
84696 diff -Nru a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
84697 --- a/sound/core/oss/pcm_oss.c  Fri Aug 15 19:54:09 2003
84698 +++ b/sound/core/oss/pcm_oss.c  Tue Aug 26 09:25:41 2003
84699 @@ -1681,7 +1681,7 @@
84700  
84701  static int snd_pcm_oss_open(struct inode *inode, struct file *file)
84702  {
84703 -       int minor = minor(inode->i_rdev);
84704 +       int minor = iminor(inode);
84705         int cardnum = SNDRV_MINOR_OSS_CARD(minor);
84706         int device;
84707         int err;
84708 diff -Nru a/sound/core/pcm_native.c b/sound/core/pcm_native.c
84709 --- a/sound/core/pcm_native.c   Mon Jul 28 04:35:00 2003
84710 +++ b/sound/core/pcm_native.c   Tue Aug 26 09:25:41 2003
84711 @@ -1431,11 +1431,11 @@
84712                 return 0;
84713         inode = file->f_dentry->d_inode;
84714         if (!S_ISCHR(inode->i_mode) ||
84715 -           major(inode->i_rdev) != snd_major) {
84716 +           imajor(inode) != snd_major) {
84717                 fput(file);
84718                 return 0;
84719         }
84720 -       minor = minor(inode->i_rdev);
84721 +       minor = iminor(inode);
84722         if (minor >= 256 || 
84723             minor % SNDRV_MINOR_DEVICES < SNDRV_MINOR_PCM_PLAYBACK) {
84724                 fput(file);
84725 @@ -1940,8 +1940,8 @@
84726  
84727  int snd_pcm_open(struct inode *inode, struct file *file)
84728  {
84729 -       int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
84730 -       int device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev));
84731 +       int cardnum = SNDRV_MINOR_CARD(iminor(inode));
84732 +       int device = SNDRV_MINOR_DEVICE(iminor(inode));
84733         int err;
84734         snd_pcm_t *pcm;
84735         snd_pcm_file_t *pcm_file;
84736 diff -Nru a/sound/core/rawmidi.c b/sound/core/rawmidi.c
84737 --- a/sound/core/rawmidi.c      Mon Jul 28 04:35:00 2003
84738 +++ b/sound/core/rawmidi.c      Tue Aug 26 09:25:41 2003
84739 @@ -345,7 +345,7 @@
84740  
84741  static int snd_rawmidi_open(struct inode *inode, struct file *file)
84742  {
84743 -       int maj = major(inode->i_rdev);
84744 +       int maj = imajor(inode);
84745         int cardnum;
84746         snd_card_t *card;
84747         int device, subdevice;
84748 @@ -359,16 +359,16 @@
84749  
84750         switch (maj) {
84751         case CONFIG_SND_MAJOR:
84752 -               cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
84753 +               cardnum = SNDRV_MINOR_CARD(iminor(inode));
84754                 cardnum %= SNDRV_CARDS;
84755 -               device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev)) - SNDRV_MINOR_RAWMIDI;
84756 +               device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_RAWMIDI;
84757                 device %= SNDRV_MINOR_RAWMIDIS;
84758                 break;
84759  #ifdef CONFIG_SND_OSSEMUL
84760         case SOUND_MAJOR:
84761 -               cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
84762 +               cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
84763                 cardnum %= SNDRV_CARDS;
84764 -               device = SNDRV_MINOR_OSS_DEVICE(minor(inode->i_rdev)) == SNDRV_MINOR_OSS_MIDI ?
84765 +               device = SNDRV_MINOR_OSS_DEVICE(iminor(inode)) == SNDRV_MINOR_OSS_MIDI ?
84766                         midi_map[cardnum] : amidi_map[cardnum];
84767                 break;
84768  #endif
84769 diff -Nru a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
84770 --- a/sound/core/seq/oss/seq_oss.c      Sun Jun  1 11:47:54 2003
84771 +++ b/sound/core/seq/oss/seq_oss.c      Tue Aug 26 09:25:41 2003
84772 @@ -121,7 +121,7 @@
84773  {
84774         int level, rc;
84775  
84776 -       if (minor(inode->i_rdev) == SNDRV_MINOR_OSS_MUSIC)
84777 +       if (iminor(inode) == SNDRV_MINOR_OSS_MUSIC)
84778                 level = SNDRV_SEQ_OSS_MODE_MUSIC;
84779         else
84780                 level = SNDRV_SEQ_OSS_MODE_SYNTH;
84781 diff -Nru a/sound/core/sound.c b/sound/core/sound.c
84782 --- a/sound/core/sound.c        Mon Jul 28 04:35:00 2003
84783 +++ b/sound/core/sound.c        Tue Aug 26 09:25:41 2003
84784 @@ -117,7 +117,7 @@
84785  
84786  static int snd_open(struct inode *inode, struct file *file)
84787  {
84788 -       int minor = minor(inode->i_rdev);
84789 +       int minor = iminor(inode);
84790         int card = SNDRV_MINOR_CARD(minor);
84791         int dev = SNDRV_MINOR_DEVICE(minor);
84792         snd_minor_t *mptr = NULL;
84793 diff -Nru a/sound/oss/Kconfig b/sound/oss/Kconfig
84794 --- a/sound/oss/Kconfig Fri Jul 18 17:02:51 2003
84795 +++ b/sound/oss/Kconfig Wed Sep  3 23:39:56 2003
84796 @@ -1145,10 +1145,18 @@
84797  config SOUND_FORTE
84798         tristate "ForteMedia FM801 driver"
84799         depends on SOUND_PRIME!=n && PCI
84800 +       help
84801 +         Say Y or M if you want driver support for the ForteMedia FM801 PCI
84802 +         audio controller (Abit AU10, Genius Sound Maker, HP Workstation
84803 +         zx2000, and others).
84804  
84805  config SOUND_RME96XX
84806         tristate "RME Hammerfall (RME96XX) support"
84807         depends on SOUND_PRIME!=n && PCI
84808 +       help
84809 +         Say Y or M if you have a Hammerfall or Hammerfall light
84810 +         multichannel card from RME. If you want to acess advanced
84811 +         features of the card, read Documentation/sound/rme96xx.
84812  
84813  config SOUND_AD1980
84814         tristate "AD1980 front/back switch plugin"
84815 diff -Nru a/sound/oss/ad1889.c b/sound/oss/ad1889.c
84816 --- a/sound/oss/ad1889.c        Sat Aug  2 23:59:09 2003
84817 +++ b/sound/oss/ad1889.c        Tue Aug 26 09:25:41 2003
84818 @@ -755,7 +755,7 @@
84819  static int ad1889_open(struct inode *inode, struct file *file)
84820  {
84821         /* check minor; only support /dev/dsp atm */
84822 -       if (minor(inode->i_rdev) != 3)
84823 +       if (iminor(inode) != 3)
84824                 return -ENXIO;
84825         
84826         file->private_data = ad1889_dev;
84827 @@ -788,7 +788,7 @@
84828  /************************* /dev/mixer interfaces ************************ */
84829  static int ad1889_mixer_open(struct inode *inode, struct file *file)
84830  {
84831 -       if (ad1889_dev->ac97_codec->dev_mixer != minor(inode->i_rdev))
84832 +       if (ad1889_dev->ac97_codec->dev_mixer != iminor(inode))
84833                 return -ENODEV;
84834  
84835         file->private_data = ad1889_dev->ac97_codec;
84836 diff -Nru a/sound/oss/ali5455.c b/sound/oss/ali5455.c
84837 --- a/sound/oss/ali5455.c       Sat Aug  2 23:59:09 2003
84838 +++ b/sound/oss/ali5455.c       Tue Aug 26 09:25:41 2003
84839 @@ -3026,7 +3026,7 @@
84840  static int ali_open_mixdev(struct inode *inode, struct file *file)
84841  {
84842         int i;
84843 -       int minor = minor(inode->i_rdev);
84844 +       int minor = iminor(inode);
84845         struct ali_card *card = devs;
84846         for (card = devs; card != NULL; card = card->next) {
84847                 /*
84848 diff -Nru a/sound/oss/au1000.c b/sound/oss/au1000.c
84849 --- a/sound/oss/au1000.c        Sat Aug  2 23:59:09 2003
84850 +++ b/sound/oss/au1000.c        Tue Aug 26 09:25:41 2003
84851 @@ -1842,7 +1842,7 @@
84852  
84853  static int  au1000_open(struct inode *inode, struct file *file)
84854  {
84855 -       int             minor = MINOR(inode->i_rdev);
84856 +       int             minor = iminor(inode);
84857         DECLARE_WAITQUEUE(wait, current);
84858         struct au1000_state *s = &au1000_state;
84859         int             ret;
84860 diff -Nru a/sound/oss/btaudio.c b/sound/oss/btaudio.c
84861 --- a/sound/oss/btaudio.c       Tue Aug 12 13:28:49 2003
84862 +++ b/sound/oss/btaudio.c       Tue Aug 26 09:25:41 2003
84863 @@ -299,7 +299,7 @@
84864  
84865  static int btaudio_mixer_open(struct inode *inode, struct file *file)
84866  {
84867 -       int minor = minor(inode->i_rdev);
84868 +       int minor = iminor(inode);
84869         struct btaudio *bta;
84870  
84871         for (bta = btaudios; bta != NULL; bta = bta->next)
84872 @@ -458,7 +458,7 @@
84873  
84874  static int btaudio_dsp_open_digital(struct inode *inode, struct file *file)
84875  {
84876 -       int minor = minor(inode->i_rdev);
84877 +       int minor = iminor(inode);
84878         struct btaudio *bta;
84879  
84880         for (bta = btaudios; bta != NULL; bta = bta->next)
84881 @@ -474,7 +474,7 @@
84882  
84883  static int btaudio_dsp_open_analog(struct inode *inode, struct file *file)
84884  {
84885 -       int minor = minor(inode->i_rdev);
84886 +       int minor = iminor(inode);
84887         struct btaudio *bta;
84888  
84889         for (bta = btaudios; bta != NULL; bta = bta->next)
84890 diff -Nru a/sound/oss/cmpci.c b/sound/oss/cmpci.c
84891 --- a/sound/oss/cmpci.c Wed Jul 23 08:32:08 2003
84892 +++ b/sound/oss/cmpci.c Tue Aug 26 09:25:41 2003
84893 @@ -1448,7 +1448,7 @@
84894  
84895  static int cm_open_mixdev(struct inode *inode, struct file *file)
84896  {
84897 -       int minor = minor(inode->i_rdev);
84898 +       int minor = iminor(inode);
84899         struct cm_state *s = devs;
84900  
84901         while (s && s->dev_mixer != minor)
84902 @@ -2207,7 +2207,7 @@
84903  
84904  static int cm_open(struct inode *inode, struct file *file)
84905  {
84906 -       int minor = minor(inode->i_rdev);
84907 +       int minor = iminor(inode);
84908         struct cm_state *s = devs;
84909         unsigned char fmtm = ~0, fmts = 0;
84910  
84911 @@ -2462,7 +2462,7 @@
84912  
84913  static int cm_midi_open(struct inode *inode, struct file *file)
84914  {
84915 -       int minor = minor(inode->i_rdev);
84916 +       int minor = iminor(inode);
84917         struct cm_state *s = devs;
84918         unsigned long flags;
84919  
84920 @@ -2679,7 +2679,7 @@
84921  
84922  static int cm_dmfm_open(struct inode *inode, struct file *file)
84923  {
84924 -       int minor = minor(inode->i_rdev);
84925 +       int minor = iminor(inode);
84926         struct cm_state *s = devs;
84927  
84928         while (s && s->dev_dmfm != minor)
84929 diff -Nru a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
84930 --- a/sound/oss/cs4281/cs4281m.c        Thu Jul 31 08:58:39 2003
84931 +++ b/sound/oss/cs4281/cs4281m.c        Tue Aug 26 09:25:41 2003
84932 @@ -2567,7 +2567,7 @@
84933  
84934  static int cs4281_open_mixdev(struct inode *inode, struct file *file)
84935  {
84936 -       unsigned int minor = minor(inode->i_rdev);
84937 +       unsigned int minor = iminor(inode);
84938         struct cs4281_state *s=NULL;
84939         struct list_head *entry;
84940  
84941 @@ -3624,7 +3624,7 @@
84942  
84943  static int cs4281_open(struct inode *inode, struct file *file)
84944  {
84945 -       unsigned int minor = minor(inode->i_rdev);
84946 +       unsigned int minor = iminor(inode);
84947         struct cs4281_state *s=NULL;
84948         struct list_head *entry;
84949  
84950 @@ -3966,7 +3966,7 @@
84951  static int cs4281_midi_open(struct inode *inode, struct file *file)
84952  {
84953         unsigned long flags, temp1;
84954 -       unsigned int minor = minor(inode->i_rdev);
84955 +       unsigned int minor = iminor(inode);
84956         struct cs4281_state *s=NULL;
84957         struct list_head *entry;
84958         list_for_each(entry, &cs4281_devs)
84959 diff -Nru a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
84960 --- a/sound/oss/cs46xx.c        Tue Aug 12 13:28:49 2003
84961 +++ b/sound/oss/cs46xx.c        Tue Aug 26 09:25:41 2003
84962 @@ -1838,7 +1838,7 @@
84963  
84964  static int cs_midi_open(struct inode *inode, struct file *file)
84965  {
84966 -        unsigned int minor = minor(inode->i_rdev);
84967 +        unsigned int minor = iminor(inode);
84968          struct cs_card *card=NULL;
84969          unsigned long flags;
84970         struct list_head *entry;
84971 @@ -3200,7 +3200,7 @@
84972         struct cs_state *state = NULL;
84973         struct dmabuf *dmabuf = NULL;
84974         struct list_head *entry;
84975 -        unsigned int minor = minor(inode->i_rdev);
84976 +        unsigned int minor = iminor(inode);
84977         int ret=0;
84978         unsigned int tmp;
84979  
84980 @@ -4066,7 +4066,7 @@
84981  static int cs_open_mixdev(struct inode *inode, struct file *file)
84982  {
84983         int i=0;
84984 -       unsigned int minor = minor(inode->i_rdev);
84985 +       unsigned int minor = iminor(inode);
84986         struct cs_card *card=NULL;
84987         struct list_head *entry;
84988         unsigned int tmp;
84989 @@ -4113,7 +4113,7 @@
84990  
84991  static int cs_release_mixdev(struct inode *inode, struct file *file)
84992  {
84993 -       unsigned int minor = minor(inode->i_rdev);
84994 +       unsigned int minor = iminor(inode);
84995         struct cs_card *card=NULL;
84996         struct list_head *entry;
84997         int i;
84998 diff -Nru a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
84999 --- a/sound/oss/dmasound/dmasound_core.c        Tue Aug 12 13:28:49 2003
85000 +++ b/sound/oss/dmasound/dmasound_core.c        Tue Aug 26 09:25:41 2003
85001 @@ -904,7 +904,7 @@
85002           O_RDONLY and dsp1 could be opened O_WRONLY
85003         */
85004  
85005 -       dmasound.minDev = minor(inode->i_rdev) & 0x0f;
85006 +       dmasound.minDev = iminor(inode) & 0x0f;
85007  
85008         /* OK. - we should make some attempt at consistency. At least the H'ware
85009            options should be set with a valid mode.  We will make it that the LL
85010 diff -Nru a/sound/oss/emu10k1/audio.c b/sound/oss/emu10k1/audio.c
85011 --- a/sound/oss/emu10k1/audio.c Tue Jul 15 10:35:45 2003
85012 +++ b/sound/oss/emu10k1/audio.c Tue Aug 26 09:25:41 2003
85013 @@ -1112,7 +1112,7 @@
85014  
85015  static int emu10k1_audio_open(struct inode *inode, struct file *file)
85016  {
85017 -       int minor = minor(inode->i_rdev);
85018 +       int minor = iminor(inode);
85019         struct emu10k1_card *card = NULL;
85020         struct list_head *entry;
85021         struct emu10k1_wavedevice *wave_dev;
85022 diff -Nru a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
85023 --- a/sound/oss/emu10k1/midi.c  Thu Apr  3 14:52:57 2003
85024 +++ b/sound/oss/emu10k1/midi.c  Tue Aug 26 09:25:41 2003
85025 @@ -86,7 +86,7 @@
85026  
85027  static int emu10k1_midi_open(struct inode *inode, struct file *file)
85028  {
85029 -       int minor = minor(inode->i_rdev);
85030 +       int minor = iminor(inode);
85031         struct emu10k1_card *card = NULL;
85032         struct emu10k1_mididevice *midi_dev;
85033         struct list_head *entry;
85034 diff -Nru a/sound/oss/emu10k1/mixer.c b/sound/oss/emu10k1/mixer.c
85035 --- a/sound/oss/emu10k1/mixer.c Tue Jul 15 10:35:45 2003
85036 +++ b/sound/oss/emu10k1/mixer.c Tue Aug 26 09:25:41 2003
85037 @@ -654,7 +654,7 @@
85038  
85039  static int emu10k1_mixer_open(struct inode *inode, struct file *file)
85040  {
85041 -       int minor = minor(inode->i_rdev);
85042 +       int minor = iminor(inode);
85043         struct emu10k1_card *card = NULL;
85044         struct list_head *entry;
85045  
85046 diff -Nru a/sound/oss/es1370.c b/sound/oss/es1370.c
85047 --- a/sound/oss/es1370.c        Tue Aug 12 16:21:59 2003
85048 +++ b/sound/oss/es1370.c        Tue Aug 26 09:25:41 2003
85049 @@ -1023,7 +1023,7 @@
85050  
85051  static int es1370_open_mixdev(struct inode *inode, struct file *file)
85052  {
85053 -       unsigned int minor = minor(inode->i_rdev);
85054 +       unsigned int minor = iminor(inode);
85055         struct list_head *list;
85056         struct es1370_state *s;
85057  
85058 @@ -1727,7 +1727,7 @@
85059  
85060  static int es1370_open(struct inode *inode, struct file *file)
85061  {
85062 -       unsigned int minor = minor(inode->i_rdev);
85063 +       unsigned int minor = iminor(inode);
85064         DECLARE_WAITQUEUE(wait, current);
85065         unsigned long flags;
85066         struct list_head *list;
85067 @@ -2165,7 +2165,7 @@
85068  
85069  static int es1370_open_dac(struct inode *inode, struct file *file)
85070  {
85071 -       unsigned int minor = minor(inode->i_rdev);
85072 +       unsigned int minor = iminor(inode);
85073         DECLARE_WAITQUEUE(wait, current);
85074         unsigned long flags;
85075         struct list_head *list;
85076 @@ -2408,7 +2408,7 @@
85077  
85078  static int es1370_midi_open(struct inode *inode, struct file *file)
85079  {
85080 -       unsigned int minor = minor(inode->i_rdev);
85081 +       unsigned int minor = iminor(inode);
85082         DECLARE_WAITQUEUE(wait, current);
85083         unsigned long flags;
85084         struct list_head *list;
85085 diff -Nru a/sound/oss/es1371.c b/sound/oss/es1371.c
85086 --- a/sound/oss/es1371.c        Tue Aug 12 13:28:49 2003
85087 +++ b/sound/oss/es1371.c        Tue Aug 26 09:25:41 2003
85088 @@ -1210,7 +1210,7 @@
85089  
85090  static int es1371_open_mixdev(struct inode *inode, struct file *file)
85091  {
85092 -       int minor = minor(inode->i_rdev);
85093 +       int minor = iminor(inode);
85094         struct list_head *list;
85095         struct es1371_state *s;
85096  
85097 @@ -1914,7 +1914,7 @@
85098  
85099  static int es1371_open(struct inode *inode, struct file *file)
85100  {
85101 -       int minor = minor(inode->i_rdev);
85102 +       int minor = iminor(inode);
85103         DECLARE_WAITQUEUE(wait, current);
85104         unsigned long flags;
85105         struct list_head *list;
85106 @@ -2345,7 +2345,7 @@
85107  
85108  static int es1371_open_dac(struct inode *inode, struct file *file)
85109  {
85110 -       int minor = minor(inode->i_rdev);
85111 +       int minor = iminor(inode);
85112         DECLARE_WAITQUEUE(wait, current);
85113         unsigned long flags;
85114         struct list_head *list;
85115 @@ -2587,7 +2587,7 @@
85116  
85117  static int es1371_midi_open(struct inode *inode, struct file *file)
85118  {
85119 -       int minor = minor(inode->i_rdev);
85120 +       int minor = iminor(inode);
85121         DECLARE_WAITQUEUE(wait, current);
85122         unsigned long flags;
85123         struct list_head *list;
85124 diff -Nru a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
85125 --- a/sound/oss/esssolo1.c      Thu Jul 31 08:58:39 2003
85126 +++ b/sound/oss/esssolo1.c      Tue Aug 26 09:25:41 2003
85127 @@ -913,7 +913,7 @@
85128  
85129  static int solo1_open_mixdev(struct inode *inode, struct file *file)
85130  {
85131 -       unsigned int minor = minor(inode->i_rdev);
85132 +       unsigned int minor = iminor(inode);
85133         struct solo1_state *s = NULL;
85134         struct pci_dev *pci_dev = NULL;
85135  
85136 @@ -1594,7 +1594,7 @@
85137  
85138  static int solo1_open(struct inode *inode, struct file *file)
85139  {
85140 -       unsigned int minor = minor(inode->i_rdev);
85141 +       unsigned int minor = iminor(inode);
85142         DECLARE_WAITQUEUE(wait, current);
85143         struct solo1_state *s = NULL;
85144         struct pci_dev *pci_dev = NULL;
85145 @@ -1884,7 +1884,7 @@
85146  
85147  static int solo1_midi_open(struct inode *inode, struct file *file)
85148  {
85149 -       unsigned int minor = minor(inode->i_rdev);
85150 +       unsigned int minor = iminor(inode);
85151         DECLARE_WAITQUEUE(wait, current);
85152         unsigned long flags;
85153         struct solo1_state *s = NULL;
85154 @@ -2106,7 +2106,7 @@
85155  
85156  static int solo1_dmfm_open(struct inode *inode, struct file *file)
85157  {
85158 -       unsigned int minor = minor(inode->i_rdev);
85159 +       unsigned int minor = iminor(inode);
85160         DECLARE_WAITQUEUE(wait, current);
85161         struct solo1_state *s = NULL;
85162         struct pci_dev *pci_dev = NULL;
85163 diff -Nru a/sound/oss/hal2.c b/sound/oss/hal2.c
85164 --- a/sound/oss/hal2.c  Sat Aug  2 23:59:09 2003
85165 +++ b/sound/oss/hal2.c  Tue Aug 26 09:25:41 2003
85166 @@ -867,7 +867,7 @@
85167  
85168  static int hal2_open_mixdev(struct inode *inode, struct file *file)
85169  {
85170 -       hal2_card_t *hal2 = hal2_mixer_find_card(MINOR(inode->i_rdev));
85171 +       hal2_card_t *hal2 = hal2_mixer_find_card(iminor(inode));
85172  
85173         if (hal2) {
85174                 file->private_data = hal2;
85175 @@ -1242,7 +1242,7 @@
85176  static int hal2_open(struct inode *inode, struct file *file)
85177  {
85178         int err;
85179 -       hal2_card_t *hal2 = hal2_dsp_find_card(MINOR(inode->i_rdev));
85180 +       hal2_card_t *hal2 = hal2_dsp_find_card(iminor(inode));
85181  
85182         DEBUG("opening audio device.\n");
85183  
85184 diff -Nru a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
85185 --- a/sound/oss/i810_audio.c    Tue Aug 12 16:21:48 2003
85186 +++ b/sound/oss/i810_audio.c    Tue Aug 26 09:25:41 2003
85187 @@ -2648,7 +2648,7 @@
85188  static int i810_open_mixdev(struct inode *inode, struct file *file)
85189  {
85190         int i;
85191 -       int minor = minor(inode->i_rdev);
85192 +       int minor = iminor(inode);
85193         struct i810_card *card = devs;
85194  
85195         for (card = devs; card != NULL; card = card->next) {
85196 diff -Nru a/sound/oss/ite8172.c b/sound/oss/ite8172.c
85197 --- a/sound/oss/ite8172.c       Sun Aug  3 00:02:01 2003
85198 +++ b/sound/oss/ite8172.c       Sun Aug 31 16:14:08 2003
85199 @@ -867,7 +867,7 @@
85200  
85201  static int it8172_open_mixdev(struct inode *inode, struct file *file)
85202  {
85203 -       int minor = MINOR(inode->i_rdev);
85204 +       int minor = iminor(inode);
85205         struct list_head *list;
85206         struct it8172_state *s;
85207  
85208 @@ -1771,7 +1771,7 @@
85209  
85210  static int it8172_open(struct inode *inode, struct file *file)
85211  {
85212 -       int minor = MINOR(inode->i_rdev);
85213 +       int minor = iminor(inode);
85214         DECLARE_WAITQUEUE(wait, current);
85215         unsigned long flags;
85216         struct list_head *list;
85217 @@ -2198,10 +2198,10 @@
85218  MODULE_DEVICE_TABLE(pci, id_table);
85219  
85220  static struct pci_driver it8172_driver = {
85221 -       name: IT8172_MODULE_NAME,
85222 -       id_table: id_table,
85223 -       probe: it8172_probe,
85224 -       remove: it8172_remove
85225 +       .name = IT8172_MODULE_NAME,
85226 +       .id_table = id_table,
85227 +       .probe = it8172_probe,
85228 +       .remove = it8172_remove
85229  };
85230  
85231  static int __init init_it8172(void)
85232 diff -Nru a/sound/oss/maestro.c b/sound/oss/maestro.c
85233 --- a/sound/oss/maestro.c       Tue Aug 12 13:28:49 2003
85234 +++ b/sound/oss/maestro.c       Tue Aug 26 09:25:41 2003
85235 @@ -2138,7 +2138,7 @@
85236  /* --------------------------------------------------------------------- */
85237  static int ess_open_mixdev(struct inode *inode, struct file *file)
85238  {
85239 -       unsigned int minor = minor(inode->i_rdev);
85240 +       unsigned int minor = iminor(inode);
85241         struct ess_card *card = NULL;
85242         struct pci_dev *pdev = NULL;
85243         struct pci_driver *drvr;
85244 @@ -2983,7 +2983,7 @@
85245  static int 
85246  ess_open(struct inode *inode, struct file *file)
85247  {
85248 -       unsigned int minor = minor(inode->i_rdev);
85249 +       unsigned int minor = iminor(inode);
85250         struct ess_state *s = NULL;
85251         unsigned char fmtm = ~0, fmts = 0;
85252         struct pci_dev *pdev = NULL;
85253 diff -Nru a/sound/oss/maestro3.c b/sound/oss/maestro3.c
85254 --- a/sound/oss/maestro3.c      Thu Jul 31 08:58:39 2003
85255 +++ b/sound/oss/maestro3.c      Tue Aug 26 09:25:41 2003
85256 @@ -1980,7 +1980,7 @@
85257  
85258  static int m3_open(struct inode *inode, struct file *file)
85259  {
85260 -    unsigned int minor = minor(inode->i_rdev);
85261 +    unsigned int minor = iminor(inode);
85262      struct m3_card *c;
85263      struct m3_state *s = NULL;
85264      int i;
85265 @@ -2149,7 +2149,7 @@
85266  /* OSS /dev/mixer file operation methods */
85267  static int m3_open_mixdev(struct inode *inode, struct file *file)
85268  {
85269 -    unsigned int minor = minor(inode->i_rdev);
85270 +    unsigned int minor = iminor(inode);
85271      struct m3_card *card = devs;
85272  
85273      for (card = devs; card != NULL; card = card->next) {
85274 diff -Nru a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
85275 --- a/sound/oss/msnd_pinnacle.c Wed Jul 23 08:32:08 2003
85276 +++ b/sound/oss/msnd_pinnacle.c Tue Aug 26 09:25:41 2003
85277 @@ -646,7 +646,7 @@
85278  
85279  static int dev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
85280  {
85281 -       int minor = minor(inode->i_rdev);
85282 +       int minor = iminor(inode);
85283  
85284         if (cmd == OSS_GETVERSION) {
85285                 int sound_version = SOUND_VERSION;
85286 @@ -758,7 +758,7 @@
85287  
85288  static int dev_open(struct inode *inode, struct file *file)
85289  {
85290 -       int minor = minor(inode->i_rdev);
85291 +       int minor = iminor(inode);
85292         int err = 0;
85293  
85294         if (minor == dev.dsp_minor) {
85295 @@ -793,7 +793,7 @@
85296  
85297  static int dev_release(struct inode *inode, struct file *file)
85298  {
85299 -       int minor = minor(inode->i_rdev);
85300 +       int minor = iminor(inode);
85301         int err = 0;
85302  
85303         lock_kernel();
85304 @@ -983,7 +983,7 @@
85305  
85306  static ssize_t dev_read(struct file *file, char *buf, size_t count, loff_t *off)
85307  {
85308 -       int minor = minor(file->f_dentry->d_inode->i_rdev);
85309 +       int minor = iminor(file->f_dentry->d_inode);
85310         if (minor == dev.dsp_minor)
85311                 return dsp_read(buf, count);
85312         else
85313 @@ -992,7 +992,7 @@
85314  
85315  static ssize_t dev_write(struct file *file, const char *buf, size_t count, loff_t *off)
85316  {
85317 -       int minor = minor(file->f_dentry->d_inode->i_rdev);
85318 +       int minor = iminor(file->f_dentry->d_inode);
85319         if (minor == dev.dsp_minor)
85320                 return dsp_write(buf, count);
85321         else
85322 diff -Nru a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
85323 --- a/sound/oss/nec_vrc5477.c   Tue Aug 12 13:28:49 2003
85324 +++ b/sound/oss/nec_vrc5477.c   Tue Aug 26 09:25:41 2003
85325 @@ -857,7 +857,7 @@
85326  
85327  static int vrc5477_ac97_open_mixdev(struct inode *inode, struct file *file)
85328  {
85329 -       int minor = minor(inode->i_rdev);
85330 +       int minor = iminor(inode);
85331         struct list_head *list;
85332         struct vrc5477_ac97_state *s;
85333  
85334 @@ -1569,7 +1569,7 @@
85335  
85336  static int vrc5477_ac97_open(struct inode *inode, struct file *file)
85337  {
85338 -       int minor = minor(inode->i_rdev);
85339 +       int minor = iminor(inode);
85340         DECLARE_WAITQUEUE(wait, current);
85341         unsigned long flags;
85342         struct list_head *list;
85343 diff -Nru a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
85344 --- a/sound/oss/rme96xx.c       Thu Jul 31 08:58:39 2003
85345 +++ b/sound/oss/rme96xx.c       Tue Aug 26 09:25:41 2003
85346 @@ -1445,7 +1445,7 @@
85347  
85348  static int rme96xx_open(struct inode *in, struct file *f)
85349  {
85350 -       int minor = minor(in->i_rdev);
85351 +       int minor = iminor(in);
85352         struct list_head *list;
85353         int devnum;
85354         rme96xx_info *s;
85355 @@ -1769,7 +1769,7 @@
85356  
85357  static int rme96xx_mixer_open(struct inode *inode, struct file *file)
85358  {
85359 -       int minor = minor(inode->i_rdev);
85360 +       int minor = iminor(inode);
85361         struct list_head *list;
85362         rme96xx_info *s;
85363  
85364 diff -Nru a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
85365 --- a/sound/oss/sonicvibes.c    Tue Aug 12 13:28:49 2003
85366 +++ b/sound/oss/sonicvibes.c    Tue Aug 26 09:25:41 2003
85367 @@ -1238,7 +1238,7 @@
85368  
85369  static int sv_open_mixdev(struct inode *inode, struct file *file)
85370  {
85371 -       int minor = minor(inode->i_rdev);
85372 +       int minor = iminor(inode);
85373         struct list_head *list;
85374         struct sv_state *s;
85375  
85376 @@ -1900,7 +1900,7 @@
85377  
85378  static int sv_open(struct inode *inode, struct file *file)
85379  {
85380 -       int minor = minor(inode->i_rdev);
85381 +       int minor = iminor(inode);
85382         DECLARE_WAITQUEUE(wait, current);
85383         unsigned char fmtm = ~0, fmts = 0;
85384         struct list_head *list;
85385 @@ -2149,7 +2149,7 @@
85386  
85387  static int sv_midi_open(struct inode *inode, struct file *file)
85388  {
85389 -       int minor = minor(inode->i_rdev);
85390 +       int minor = iminor(inode);
85391         DECLARE_WAITQUEUE(wait, current);
85392         unsigned long flags;
85393         struct list_head *list;
85394 @@ -2371,7 +2371,7 @@
85395  
85396  static int sv_dmfm_open(struct inode *inode, struct file *file)
85397  {
85398 -       int minor = minor(inode->i_rdev);
85399 +       int minor = iminor(inode);
85400         DECLARE_WAITQUEUE(wait, current);
85401         struct list_head *list;
85402         struct sv_state *s;
85403 diff -Nru a/sound/oss/soundcard.c b/sound/oss/soundcard.c
85404 --- a/sound/oss/soundcard.c     Tue Aug 12 13:28:49 2003
85405 +++ b/sound/oss/soundcard.c     Tue Aug 26 09:25:41 2003
85406 @@ -144,7 +144,7 @@
85407  
85408  static ssize_t sound_read(struct file *file, char *buf, size_t count, loff_t *ppos)
85409  {
85410 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
85411 +       int dev = iminor(file->f_dentry->d_inode);
85412         int ret = -EINVAL;
85413  
85414         /*
85415 @@ -177,7 +177,7 @@
85416  
85417  static ssize_t sound_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
85418  {
85419 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
85420 +       int dev = iminor(file->f_dentry->d_inode);
85421         int ret = -EINVAL;
85422         
85423         lock_kernel();
85424 @@ -204,7 +204,7 @@
85425  
85426  static int sound_open(struct inode *inode, struct file *file)
85427  {
85428 -       int dev = minor(inode->i_rdev);
85429 +       int dev = iminor(inode);
85430         int retval;
85431  
85432         DEB(printk("sound_open(dev=%d)\n", dev));
85433 @@ -253,7 +253,7 @@
85434  
85435  static int sound_release(struct inode *inode, struct file *file)
85436  {
85437 -       int dev = minor(inode->i_rdev);
85438 +       int dev = iminor(inode);
85439  
85440         lock_kernel();
85441         DEB(printk("sound_release(dev=%d)\n", dev));
85442 @@ -333,7 +333,7 @@
85443                        unsigned int cmd, unsigned long arg)
85444  {
85445         int err, len = 0, dtype;
85446 -       int dev = minor(inode->i_rdev);
85447 +       int dev = iminor(inode);
85448  
85449         if (_SIOC_DIR(cmd) != _SIOC_NONE && _SIOC_DIR(cmd) != 0) {
85450                 /*
85451 @@ -396,7 +396,7 @@
85452  static unsigned int sound_poll(struct file *file, poll_table * wait)
85453  {
85454         struct inode *inode = file->f_dentry->d_inode;
85455 -       int dev = minor(inode->i_rdev);
85456 +       int dev = iminor(inode);
85457  
85458         DEB(printk("sound_poll(dev=%d)\n", dev));
85459         switch (dev & 0x0f) {
85460 @@ -420,7 +420,7 @@
85461         int dev_class;
85462         unsigned long size;
85463         struct dma_buffparms *dmap = NULL;
85464 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
85465 +       int dev = iminor(file->f_dentry->d_inode);
85466  
85467         dev_class = dev & 0x0f;
85468         dev >>= 4;
85469 diff -Nru a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
85470 --- a/sound/oss/swarm_cs4297a.c Sun Aug  3 00:04:24 2003
85471 +++ b/sound/oss/swarm_cs4297a.c Tue Aug 26 09:25:41 2003
85472 @@ -1537,7 +1537,7 @@
85473  
85474  static int cs4297a_open_mixdev(struct inode *inode, struct file *file)
85475  {
85476 -       int minor = MINOR(inode->i_rdev);
85477 +       int minor = iminor(inode);
85478         struct cs4297a_state *s=NULL;
85479         struct list_head *entry;
85480  
85481 @@ -2386,7 +2386,7 @@
85482  
85483  static int cs4297a_open(struct inode *inode, struct file *file)
85484  {
85485 -       int minor = MINOR(inode->i_rdev);
85486 +       int minor = iminor(inode);
85487         struct cs4297a_state *s=NULL;
85488         struct list_head *entry;
85489  
85490 diff -Nru a/sound/oss/trident.c b/sound/oss/trident.c
85491 --- a/sound/oss/trident.c       Sat Aug  9 11:53:08 2003
85492 +++ b/sound/oss/trident.c       Tue Aug 26 09:25:41 2003
85493 @@ -2600,7 +2600,7 @@
85494  static int trident_open(struct inode *inode, struct file *file)
85495  {
85496         int i = 0;
85497 -       int minor = minor(inode->i_rdev);
85498 +       int minor = iminor(inode);
85499         struct trident_card *card = devs;
85500         struct trident_state *state = NULL;
85501         struct dmabuf *dmabuf = NULL;
85502 @@ -3883,7 +3883,7 @@
85503  static int trident_open_mixdev(struct inode *inode, struct file *file)
85504  {
85505         int i = 0;
85506 -       int minor = minor(inode->i_rdev);
85507 +       int minor = iminor(inode);
85508         struct trident_card *card = devs;
85509  
85510         for (card = devs; card != NULL; card = card->next)
85511 diff -Nru a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
85512 --- a/sound/oss/via82cxxx_audio.c       Sun Aug  3 00:05:26 2003
85513 +++ b/sound/oss/via82cxxx_audio.c       Tue Aug 26 09:25:41 2003
85514 @@ -1556,7 +1556,7 @@
85515  
85516  static int via_mixer_open (struct inode *inode, struct file *file)
85517  {
85518 -       int minor = minor(inode->i_rdev);
85519 +       int minor = iminor(inode);
85520         struct via_info *card;
85521         struct pci_dev *pdev = NULL;
85522         struct pci_driver *drvr;
85523 @@ -3252,7 +3252,7 @@
85524  
85525  static int via_dsp_open (struct inode *inode, struct file *file)
85526  {
85527 -       int minor = minor(inode->i_rdev);
85528 +       int minor = iminor(inode);
85529         struct via_info *card;
85530         struct pci_dev *pdev = NULL;
85531         struct via_channel *chan;
85532 diff -Nru a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
85533 --- a/sound/oss/vwsnd.c Mon Apr 21 00:32:53 2003
85534 +++ b/sound/oss/vwsnd.c Tue Aug 26 09:25:41 2003
85535 @@ -2916,7 +2916,7 @@
85536  static int vwsnd_audio_open(struct inode *inode, struct file *file)
85537  {
85538         vwsnd_dev_t *devc;
85539 -       dev_t minor = minor(inode->i_rdev);
85540 +       int minor = iminor(inode);
85541         int sw_samplefmt;
85542  
85543         DBGE("(inode=0x%p, file=0x%p)\n", inode, file);
85544 @@ -3063,7 +3063,7 @@
85545  
85546         INC_USE_COUNT;
85547         for (devc = vwsnd_dev_list; devc; devc = devc->next_dev)
85548 -               if (devc->mixer_minor == minor(inode->i_rdev))
85549 +               if (devc->mixer_minor == iminor(inode))
85550                         break;
85551  
85552         if (devc == NULL) {
85553 diff -Nru a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
85554 --- a/sound/oss/ymfpci.c        Mon Aug 18 22:27:20 2003
85555 +++ b/sound/oss/ymfpci.c        Tue Aug 26 09:25:41 2003
85556 @@ -1905,7 +1905,7 @@
85557         struct ymf_state *state;
85558         int err;
85559  
85560 -       minor = minor(inode->i_rdev);
85561 +       minor = iminor(inode);
85562         if ((minor & 0x0F) == 3) {      /* /dev/dspN */
85563                 ;
85564         } else {
85565 @@ -2019,7 +2019,7 @@
85566   */
85567  static int ymf_open_mixdev(struct inode *inode, struct file *file)
85568  {
85569 -       int minor = minor(inode->i_rdev);
85570 +       int minor = iminor(inode);
85571         struct list_head *list;
85572         ymfpci_t *unit;
85573         int i;
85574 diff -Nru a/sound/pcmcia/vx/vx_entry.c b/sound/pcmcia/vx/vx_entry.c
85575 --- a/sound/pcmcia/vx/vx_entry.c        Tue Jun 10 07:32:30 2003
85576 +++ b/sound/pcmcia/vx/vx_entry.c        Fri Aug 22 05:02:18 2003
85577 @@ -34,10 +34,8 @@
85578  static int vxpocket_event(event_t event, int priority, event_callback_args_t *args);
85579  
85580  
85581 -static void vxpocket_release(u_long arg)
85582 +static void vxpocket_release(dev_link_t* link)
85583  {
85584 -       dev_link_t *link = (dev_link_t *)arg;
85585 -       
85586         if (link->state & DEV_CONFIG) {
85587                 /* release cs resources */
85588                 CardServices(ReleaseConfiguration, link->handle);
85589 @@ -56,7 +54,7 @@
85590         struct snd_vxp_entry *hw;
85591         dev_link_t *link = &vxp->link;
85592  
85593 -       vxpocket_release((u_long)link);
85594 +       vxpocket_release(link);
85595  
85596         /* Break the link with Card Services */
85597         if (link->handle)
85598 @@ -148,9 +146,6 @@
85599         link->irq.Handler = &snd_vx_irq_handler;
85600         link->irq.Instance = chip;
85601  
85602 -       link->release.function = &vxpocket_release;
85603 -       link->release.data = (u_long)link;
85604 -
85605         link->conf.Attributes = CONF_ENABLE_IRQ;
85606         link->conf.Vcc = 50;
85607         link->conf.IntType = INT_MEMORY_AND_IO;
85608 @@ -229,8 +224,6 @@
85609  {
85610         vx_core_t *chip = snd_magic_cast(vx_core_t, link->priv, return);
85611  
85612 -       del_timer(&link->release);
85613 -
85614         snd_printdd(KERN_DEBUG "vxpocket_detach called\n");
85615         /* Remove the interface data from the linked list */
85616         if (hw) {
85617 @@ -326,7 +319,6 @@
85618                 snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n");
85619                 link->state &= ~DEV_PRESENT;
85620                 if (link->state & DEV_CONFIG) {
85621 -                       mod_timer(&link->release, jiffies + HZ/20);
85622                         chip->chip_status |= VX_STAT_IS_STALE;
85623                 }
85624                 break;
85625 diff -Nru a/sound/ppc/keywest.c b/sound/ppc/keywest.c
85626 --- a/sound/ppc/keywest.c       Tue May 20 14:13:01 2003
85627 +++ b/sound/ppc/keywest.c       Sun Aug 24 06:11:13 2003
85628 @@ -50,7 +50,7 @@
85629  
85630  
85631  #ifndef i2c_device_name
85632 -#define i2c_device_name(x)     ((x)->dev.name)
85633 +#define i2c_device_name(x)     ((x)->name)
85634  #endif
85635  
85636  static int keywest_attach_adapter(struct i2c_adapter *adapter)
85637 diff -Nru a/sound/sound_core.c b/sound/sound_core.c
85638 --- a/sound/sound_core.c        Sat May 17 12:39:14 2003
85639 +++ b/sound/sound_core.c        Tue Aug 26 09:25:41 2003
85640 @@ -483,7 +483,7 @@
85641  int soundcore_open(struct inode *inode, struct file *file)
85642  {
85643         int chain;
85644 -       int unit = minor(inode->i_rdev);
85645 +       int unit = iminor(inode);
85646         struct sound_unit *s;
85647         struct file_operations *new_fops = NULL;
85648  
This page took 7.287194 seconds and 3 git commands to generate.