]> git.pld-linux.org Git - packages/kernel.git/blob - patch-2.6.0-test4-bk5
- added description of djurban's branch
[packages/kernel.git] / patch-2.6.0-test4-bk5
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/kobject.txt b/Documentation/kobject.txt
420 --- a/Documentation/kobject.txt Tue Jun 17 15:59:07 2003
421 +++ b/Documentation/kobject.txt Sun Aug 31 16:14:13 2003
422 @@ -245,7 +245,9 @@
423    see the sysfs documentation for more information. 
424  
425  - default_attrs: Default attributes to be exported via sysfs when the
426 -  object is registered. 
427 +  object is registered.Note that the last attribute has to be
428 +  initialized to NULL ! You can find a complete implementation
429 +  in drivers/block/genhd.c
430  
431  
432  Instances of struct kobj_type are not registered; only referenced by
433 diff -Nru a/Documentation/sonypi.txt b/Documentation/sonypi.txt
434 --- a/Documentation/sonypi.txt  Tue Mar 11 10:20:18 2003
435 +++ b/Documentation/sonypi.txt  Tue Aug 26 09:02:05 2003
436 @@ -8,7 +8,9 @@
437         Copyright (C) 2000 Andrew Tridgell <tridge@samba.org>
438  
439  This driver enables access to the Sony Programmable I/O Control Device which
440 -can be found in many (all ?) Sony Vaio laptops.
441 +can be found in many Sony Vaio laptops. Some newer Sony laptops (seems to be
442 +limited to new FX series laptops, at least the FX501 and the FX702) lack a
443 +sonypi device and are not supported at all by this driver.
444  
445  It will give access (through a user space utility) to some events those laptops
446  generate, like:
447 @@ -96,6 +98,7 @@
448                                 SONYPI_THUMBPHRASE_MASK         0x0200
449                                 SONYPI_MEYE_MASK                0x0400
450                                 SONYPI_MEMORYSTICK_MASK         0x0800
451 +                               SONYPI_BATTERY_MASK             0x1000
452  
453         useinput:       if set (which is the default) jogdial events are
454                         forwarded to the input subsystem as mouse wheel
455 diff -Nru a/Documentation/sysctl/README b/Documentation/sysctl/README
456 --- a/Documentation/sysctl/README       Tue Feb  5 09:40:37 2002
457 +++ b/Documentation/sysctl/README       Sun Aug 31 16:14:14 2003
458 @@ -55,6 +55,7 @@
459  by piece basis, or just some 'thematic frobbing'.
460  
461  The subdirs are about:
462 +abi/           execution domains & personalities
463  debug/         <empty>
464  dev/           device specific information (eg dev/cdrom/info)
465  fs/            specific filesystems
466 diff -Nru a/Documentation/sysctl/abi.txt b/Documentation/sysctl/abi.txt
467 --- /dev/null   Wed Dec 31 16:00:00 1969
468 +++ b/Documentation/sysctl/abi.txt      Sun Aug 31 16:14:14 2003
469 @@ -0,0 +1,54 @@
470 +Documentation for /proc/sys/abi/* kernel version 2.6.0.test2
471 +       (c) 2003,  Fabian Frederick <ffrederick@users.sourceforge.net>
472 +
473 +For general info : README.
474 +
475 +==============================================================
476 +
477 +This path is binary emulation relevant aka personality types aka abi.
478 +When a process is executed, it's linked to an exec_domain whose
479 +personality is defined using values available from /proc/sys/abi.
480 +You can find further details about abi in include/linux/personality.h.
481 +
482 +Here are the files featuring in 2.6 kernel :
483 +
484 +- defhandler_coff
485 +- defhandler_elf
486 +- defhandler_lcall7
487 +- defhandler_libcso
488 +- fake_utsname
489 +- trace
490 +
491 +===========================================================
492 +defhandler_coff:
493 +defined value :
494 +PER_SCOSVR3
495 +0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE
496 +
497 +===========================================================
498 +defhandler_elf:
499 +defined value :
500 +PER_LINUX
501 +0
502 +
503 +===========================================================
504 +defhandler_lcall7:
505 +defined value :
506 +PER_SVR4
507 +0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
508 +
509 +===========================================================
510 +defhandler_libsco:
511 +defined value:
512 +PER_SVR4
513 +0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
514 +
515 +===========================================================
516 +fake_utsname:
517 +Unused
518 +
519 +===========================================================
520 +trace:
521 +Unused
522 +
523 +===========================================================
524 diff -Nru a/Documentation/usb/hotplug.txt b/Documentation/usb/hotplug.txt
525 --- a/Documentation/usb/hotplug.txt     Fri Dec 27 03:00:19 2002
526 +++ b/Documentation/usb/hotplug.txt     Wed Aug 20 09:40:22 2003
527 @@ -122,17 +122,17 @@
528  something like this:
529  
530      static struct usb_driver mydriver = {
531 -       name:           "mydriver",
532 -       id_table:       mydriver_id_table,
533 -       probe:          my_probe,
534 -       disconnect:     my_disconnect,
535 +       .name           = "mydriver",
536 +       .id_table       = mydriver_id_table,
537 +       .probe          = my_probe,
538 +       .disconnect     = my_disconnect,
539  
540         /*
541         if using the usb chardev framework:
542 -           minor:              MY_USB_MINOR_START,
543 -           fops:               my_file_ops,
544 +           .minor              = MY_USB_MINOR_START,
545 +           .fops               = my_file_ops,
546         if exposing any operations through usbdevfs:
547 -           ioctl:              my_ioctl,
548 +           .ioctl              = my_ioctl,
549         */
550      }
551  
552 diff -Nru a/Documentation/video4linux/meye.txt b/Documentation/video4linux/meye.txt
553 --- a/Documentation/video4linux/meye.txt        Tue Feb 18 03:32:29 2003
554 +++ b/Documentation/video4linux/meye.txt        Fri Aug  1 05:47:51 2003
555 @@ -16,6 +16,23 @@
556  
557  MJPEG hardware grabbing is supported via a private API (see below).
558  
559 +Hardware supported:
560 +-------------------
561 +
562 +This driver supports the 'second' version of the MotionEye camera :)
563 +
564 +The first version was connected directly on the video bus of the Neomagic
565 +video card and is unsupported.
566 +
567 +The second one, made by Kawasaki Steel is fully supported by this 
568 +driver (PCI vendor/device is 0x136b/0xff01)
569 +
570 +The third one, present in recent (more or less last year) Picturebooks
571 +(C1M* models), is not supported. The manufacturer has given the specs
572 +to the developers under a NDA (which allows the develoment of a GPL
573 +driver however), but things are not moving very fast (see
574 +http://r-engine.sourceforge.net/) (PCI vendor/device is 0x10cf/0x2011).
575 +
576  Driver options:
577  ---------------
578  
579 diff -Nru a/MAINTAINERS b/MAINTAINERS
580 --- a/MAINTAINERS       Thu Aug 21 09:09:26 2003
581 +++ b/MAINTAINERS       Sun Aug 31 16:13:57 2003
582 @@ -615,8 +615,6 @@
583  S:     Maintained
584  
585  DRM DRIVERS
586 -P:     Rik Faith
587 -M:     faith@redhat.com
588  L:     dri-devel@lists.sourceforge.net
589  S:     Supported
590  
591 @@ -1087,6 +1085,14 @@
592  L:     kbuild-devel@lists.sourceforge.net
593  W:     http://kbuild.sourceforge.net
594  S:     Maintained 
595 +
596 +KERNEL JANITORS
597 +P:     Several
598 +L:     kernel-janitor-discuss@lists.sf.net
599 +W:     http://www.kerneljanitors.org/
600 +W:     http://sf.net/projects/kernel-janitor/
601 +W:     http://developer.osdl.org/rddunlap/kj-patches/
602 +S:     Maintained
603  
604  KERNEL NFSD
605  P:     Neil Brown
606 diff -Nru a/Makefile b/Makefile
607 --- a/Makefile  Fri Aug 22 16:38:51 2003
608 +++ b/Makefile  Wed Sep  3 04:34:59 2003
609 @@ -1,7 +1,7 @@
610  VERSION = 2
611  PATCHLEVEL = 6
612  SUBLEVEL = 0
613 -EXTRAVERSION = -test4
614 +EXTRAVERSION = -test4-bk5
615  
616  # *DOCUMENTATION*
617  # To see a list of typical targets execute "make help"
618 @@ -268,8 +268,19 @@
619  # Detect when mixed targets is specified, and make a second invocation
620  # of make so .config is not included in this case either (for *config).
621  
622 +no-dot-config-targets := clean mrproper distclean \
623 +                        cscope TAGS tags help %docs check%
624 +
625  config-targets := 0
626  mixed-targets  := 0
627 +dot-config     := 1
628 +
629 +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
630 +       ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
631 +               dot-config := 0
632 +       endif
633 +endif
634 +
635  ifneq ($(filter config %config,$(MAKECMDGOALS)),)
636         config-targets := 1
637         ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
638 @@ -309,7 +320,26 @@
639  core-y         := usr/
640  SUBDIRS                :=
641  
642 --include .config
643 +ifeq ($(dot-config),1)
644 +# In this section, we need .config
645 +
646 +# Read in dependencies to all Kconfig* files, make sure to run
647 +# oldconfig if changes are detected.
648 +-include .config.cmd
649 +
650 +include .config
651 +
652 +# If .config needs to be updated, it will be done via the dependency
653 +# that autoconf has on .config.
654 +# To avoid any implicit rule to kick in, define an empty command
655 +.config: ;
656 +
657 +# If .config is newer than include/linux/autoconf.h, someone tinkered
658 +# with it and forgot to run make oldconfig
659 +include/linux/autoconf.h: scripts/fixdep .config
660 +       $(Q)$(MAKE) $(build)=scripts/kconfig silentoldconfig
661 +
662 +endif
663  
664  include arch/$(ARCH)/Makefile
665  
666 @@ -338,15 +368,7 @@
667  
668  # Here goes the main Makefile
669  # ---------------------------------------------------------------------------
670 -#
671 -# If the user gave a *config target, it'll be handled in another
672 -# section below, since in this case we cannot include .config
673 -# Same goes for other targets like clean/mrproper etc, which
674 -# don't need .config, either
675  
676 -#      In this section, we need .config
677 -
678 --include .config.cmd
679  
680  ifndef CONFIG_FRAME_POINTER
681  CFLAGS         += -fomit-frame-pointer
682 @@ -521,13 +543,6 @@
683         @scripts/split-include include/linux/autoconf.h include/config
684         @touch $@
685  
686 -#      if .config is newer than include/linux/autoconf.h, someone tinkered
687 -#      with it and forgot to run make oldconfig
688 -
689 -include/linux/autoconf.h: .config scripts/fixdep
690 -       $(Q)$(MAKE) $(build)=scripts/kconfig scripts/kconfig/conf
691 -       ./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
692 -
693  # Generate some files
694  # ---------------------------------------------------------------------------
695  
696 @@ -579,6 +594,11 @@
697  
698  .PHONY: _modinst_
699  _modinst_:
700 +       @if [ -z "`$(DEPMOD) -V | grep module-init-tools`" ]; then \
701 +               echo "Warning: you may need to install module-init-tools"; \
702 +               echo "See http://www.codemonkey.org.uk/post-halloween-2.5.txt";\
703 +               sleep 1; \
704 +       fi
705         @rm -rf $(MODLIB)/kernel
706         @rm -f $(MODLIB)/build
707         @mkdir -p $(MODLIB)/kernel
708 diff -Nru a/arch/alpha/Kconfig b/arch/alpha/Kconfig
709 --- a/arch/alpha/Kconfig        Sun Aug 17 01:06:24 2003
710 +++ b/arch/alpha/Kconfig        Sun Aug 31 16:14:22 2003
711 @@ -597,40 +597,6 @@
712  
713  source "drivers/pcmcia/Kconfig"
714  
715 -choice
716 -       prompt "Kernel core (/proc/kcore) format"
717 -       depends on PROC_FS
718 -       default KCORE_ELF
719 -
720 -config KCORE_ELF
721 -       bool "ELF"
722 -       ---help---
723 -         If you enabled support for /proc file system then the file
724 -         /proc/kcore will contain the kernel core image. This can be used
725 -         in gdb:
726 -
727 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
728 -
729 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
730 -         /proc/kcore appear in ELF core format as defined by the Executable
731 -         and Linking Format specification. Selecting A.OUT will choose the
732 -         old "a.out" format which may be necessary for some old versions
733 -         of binutils or on some architectures.
734 -
735 -         This is especially useful if you have compiled the kernel with the
736 -         "-g" option to preserve debugging information. It is mainly used
737 -         for examining kernel data structures on the live kernel so if you
738 -         don't understand what this means or are not a kernel hacker, just
739 -         leave it at its default value ELF.
740 -
741 -config KCORE_AOUT
742 -       bool "A.OUT"
743 -       help
744 -         Not necessary unless you're using a very out-of-date binutils
745 -         version.  You probably want KCORE_ELF.
746 -
747 -endchoice
748 -
749  config SRM_ENV
750         tristate "SRM environment through procfs"
751         depends on PROC_FS
752 diff -Nru a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c
753 --- a/arch/alpha/kernel/core_titan.c    Sun Aug 17 00:57:42 2003
754 +++ b/arch/alpha/kernel/core_titan.c    Sun Aug 31 16:14:08 2003
755 @@ -717,12 +717,12 @@
756  
757  struct alpha_agp_ops titan_agp_ops =
758  {
759 -       setup:          titan_agp_setup,
760 -       cleanup:        titan_agp_cleanup,
761 -       configure:      titan_agp_configure,
762 -       bind:           titan_agp_bind_memory,
763 -       unbind:         titan_agp_unbind_memory,
764 -       translate:      titan_agp_translate
765 +       .setup          = titan_agp_setup,
766 +       .cleanup        = titan_agp_cleanup,
767 +       .configure      = titan_agp_configure,
768 +       .bind           = titan_agp_bind_memory,
769 +       .unbind         = titan_agp_unbind_memory,
770 +       .translate      = titan_agp_translate
771  };
772  
773  alpha_agp_info *
774 diff -Nru a/arch/arm/Kconfig b/arch/arm/Kconfig
775 --- a/arch/arm/Kconfig  Tue Aug 19 11:44:53 2003
776 +++ b/arch/arm/Kconfig  Sun Aug 31 16:14:22 2003
777 @@ -654,39 +654,6 @@
778           If you do not feel you need a faster FP emulation you should better
779           choose NWFPE.
780  
781 -choice
782 -       prompt "Kernel core (/proc/kcore) format"
783 -       default KCORE_ELF
784 -
785 -config KCORE_ELF
786 -       bool "ELF"
787 -       ---help---
788 -         If you enabled support for /proc file system then the file
789 -         /proc/kcore will contain the kernel core image. This can be used
790 -         in gdb:
791 -
792 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
793 -
794 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
795 -         /proc/kcore appear in ELF core format as defined by the Executable
796 -         and Linking Format specification. Selecting A.OUT will choose the
797 -         old "a.out" format which may be necessary for some old versions
798 -         of binutils or on some architectures.
799 -
800 -         This is especially useful if you have compiled the kernel with the
801 -         "-g" option to preserve debugging information. It is mainly used
802 -         for examining kernel data structures on the live kernel so if you
803 -         don't understand what this means or are not a kernel hacker, just
804 -         leave it at its default value ELF.
805 -
806 -config KCORE_AOUT
807 -       bool "A.OUT"
808 -       help
809 -         Not necessary unless you're using a very out-of-date binutils
810 -         version.  You probably want KCORE_ELF.
811 -
812 -endchoice
813 -
814  source "fs/Kconfig.binfmt"
815  
816  source "drivers/base/Kconfig"
817 diff -Nru a/arch/arm/Makefile b/arch/arm/Makefile
818 --- a/arch/arm/Makefile Tue Aug 19 11:44:53 2003
819 +++ b/arch/arm/Makefile Wed Aug 13 16:23:42 2003
820 @@ -24,6 +24,7 @@
821  CFLAGS         += -mbig-endian
822  AS             += -EB
823  LD             += -EB
824 +AFLAGS         += -mbig-endian
825  endif
826  
827  check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
828 diff -Nru a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
829 --- a/arch/arm/boot/Makefile    Tue Apr 15 08:12:47 2003
830 +++ b/arch/arm/boot/Makefile    Wed Aug 13 16:46:20 2003
831 @@ -42,11 +42,12 @@
832  ifeq ($(CONFIG_ARCH_SA1100),y)
833     zreladdr-$(CONFIG_SA1111)           := 0xc0208000
834  endif
835 -  zreladdr-$(CONFIG_ARCH_PXA)          := 0xa0008000
836 -  zreladdr-$(CONFIG_ARCH_ANAKIN)       := 0x20008000
837 -  zreladdr-$(CONFIG_ARCH_IQ80310)      := 0xa0008000
838 -  zreladdr-$(CONFIG_ARCH_IQ80321)      := 0xa0008000
839 -  zreladdr-$(CONFIG_ARCH_ADIFCC)       := 0xc0008000
840 +   zreladdr-$(CONFIG_ARCH_PXA)         := 0xa0008000
841 +   zreladdr-$(CONFIG_ARCH_ANAKIN)      := 0x20008000
842 +   zreladdr-$(CONFIG_ARCH_IOP3XX)      := 0xa0008000
843 +params-phys-$(CONFIG_ARCH_IOP3XX)      := 0xa0000100
844 +   zreladdr-$(CONFIG_ARCH_ADIFCC)      := 0xc0008000
845 +params-phys-$(CONFIG_ARCH_ADIFCC)      := 0xc0000100
846  
847  ZRELADDR    := $(zreladdr-y)
848  ZTEXTADDR   := $(ztextaddr-y)
849 diff -Nru a/arch/arm/common/amba.c b/arch/arm/common/amba.c
850 --- a/arch/arm/common/amba.c    Fri Aug 15 15:22:52 2003
851 +++ b/arch/arm/common/amba.c    Sun Aug 24 07:16:13 2003
852 @@ -41,13 +41,35 @@
853         return amba_lookup(pcdrv->id_table, pcdev) != NULL;
854  }
855  
856 +static int amba_suspend(struct device *dev, u32 state)
857 +{
858 +       struct amba_driver *drv = to_amba_driver(dev->driver);
859 +       int ret = 0;
860 +
861 +       if (dev->driver && drv->suspend)
862 +               ret = drv->suspend(to_amba_device(dev), state);
863 +       return ret;
864 +}
865 +
866 +static int amba_resume(struct device *dev)
867 +{
868 +       struct amba_driver *drv = to_amba_driver(dev->driver);
869 +       int ret = 0;
870 +
871 +       if (dev->driver && drv->resume)
872 +               ret = drv->resume(to_amba_device(dev));
873 +       return ret;
874 +}
875 +
876  /*
877   * Primecells are part of the Advanced Microcontroller Bus Architecture,
878   * so we call the bus "amba".
879   */
880 -struct bus_type amba_bustype = {
881 -       .name   = "amba",
882 -       .match  = amba_match,
883 +static struct bus_type amba_bustype = {
884 +       .name           = "amba",
885 +       .match          = amba_match,
886 +       .suspend        = amba_suspend,
887 +       .resume         = amba_resume,
888  };
889  
890  static int __init amba_init(void)
891 @@ -84,18 +106,6 @@
892         drv->shutdown(to_amba_device(dev));
893  }
894  
895 -static int amba_suspend(struct device *dev, u32 state, u32 level)
896 -{
897 -       struct amba_driver *drv = to_amba_driver(dev->driver);
898 -       return drv->suspend(to_amba_device(dev), state, level);
899 -}
900 -
901 -static int amba_resume(struct device *dev, u32 level)
902 -{
903 -       struct amba_driver *drv = to_amba_driver(dev->driver);
904 -       return drv->resume(to_amba_device(dev), level);
905 -}
906 -
907  /**
908   *     amba_driver_register - register an AMBA device driver
909   *     @drv: amba device driver structure
910 @@ -112,8 +122,6 @@
911         SETFN(probe);
912         SETFN(remove);
913         SETFN(shutdown);
914 -       SETFN(suspend);
915 -       SETFN(resume);
916  
917         return driver_register(&drv->drv);
918  }
919 diff -Nru a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
920 --- a/arch/arm/common/sa1111.c  Fri Aug 15 15:22:52 2003
921 +++ b/arch/arm/common/sa1111.c  Sun Aug 24 07:45:04 2003
922 @@ -790,10 +790,13 @@
923         struct sa1111 *sachip = dev_get_drvdata(dev);
924         struct sa1111_save_data *save;
925         unsigned long flags;
926 +       unsigned int val;
927         char *base;
928  
929 -       if (!dev->saved_state && level == SUSPEND_NOTIFY)
930 -               dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
931 +       if (level != SUSPEND_DISABLE)
932 +               return 0;
933 +
934 +       dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
935         if (!dev->saved_state)
936                 return -ENOMEM;
937  
938 @@ -804,36 +807,31 @@
939         /*
940          * Save state.
941          */
942 -       if (level == SUSPEND_SAVE_STATE) {
943 -               base = sachip->base;
944 -               save->skcr     = sa1111_readl(base + SA1111_SKCR);
945 -               save->skpcr    = sa1111_readl(base + SA1111_SKPCR);
946 -               save->skcdr    = sa1111_readl(base + SA1111_SKCDR);
947 -               save->skaud    = sa1111_readl(base + SA1111_SKAUD);
948 -               save->skpwm0   = sa1111_readl(base + SA1111_SKPWM0);
949 -               save->skpwm1   = sa1111_readl(base + SA1111_SKPWM1);
950 -
951 -               base = sachip->base + SA1111_INTC;
952 -               save->intpol0  = sa1111_readl(base + SA1111_INTPOL0);
953 -               save->intpol1  = sa1111_readl(base + SA1111_INTPOL1);
954 -               save->inten0   = sa1111_readl(base + SA1111_INTEN0);
955 -               save->inten1   = sa1111_readl(base + SA1111_INTEN1);
956 -               save->wakepol0 = sa1111_readl(base + SA1111_WAKEPOL0);
957 -               save->wakepol1 = sa1111_readl(base + SA1111_WAKEPOL1);
958 -               save->wakeen0  = sa1111_readl(base + SA1111_WAKEEN0);
959 -               save->wakeen1  = sa1111_readl(base + SA1111_WAKEEN1);
960 -       }
961 +       base = sachip->base;
962 +       save->skcr     = sa1111_readl(base + SA1111_SKCR);
963 +       save->skpcr    = sa1111_readl(base + SA1111_SKPCR);
964 +       save->skcdr    = sa1111_readl(base + SA1111_SKCDR);
965 +       save->skaud    = sa1111_readl(base + SA1111_SKAUD);
966 +       save->skpwm0   = sa1111_readl(base + SA1111_SKPWM0);
967 +       save->skpwm1   = sa1111_readl(base + SA1111_SKPWM1);
968 +
969 +       base = sachip->base + SA1111_INTC;
970 +       save->intpol0  = sa1111_readl(base + SA1111_INTPOL0);
971 +       save->intpol1  = sa1111_readl(base + SA1111_INTPOL1);
972 +       save->inten0   = sa1111_readl(base + SA1111_INTEN0);
973 +       save->inten1   = sa1111_readl(base + SA1111_INTEN1);
974 +       save->wakepol0 = sa1111_readl(base + SA1111_WAKEPOL0);
975 +       save->wakepol1 = sa1111_readl(base + SA1111_WAKEPOL1);
976 +       save->wakeen0  = sa1111_readl(base + SA1111_WAKEEN0);
977 +       save->wakeen1  = sa1111_readl(base + SA1111_WAKEEN1);
978  
979         /*
980          * Disable.
981          */
982 -       if (level == SUSPEND_POWER_DOWN && state == 4) {
983 -               unsigned int val = sa1111_readl(sachip->base + SA1111_SKCR);
984 -
985 -               sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR);
986 -               sa1111_writel(0, sachip->base + SA1111_SKPWM0);
987 -               sa1111_writel(0, sachip->base + SA1111_SKPWM1);
988 -       }
989 +       val = sa1111_readl(sachip->base + SA1111_SKCR);
990 +       sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR);
991 +       sa1111_writel(0, sachip->base + SA1111_SKPWM0);
992 +       sa1111_writel(0, sachip->base + SA1111_SKPWM1);
993  
994         spin_unlock_irqrestore(&sachip->lock, flags);
995  
996 @@ -857,6 +855,9 @@
997         unsigned long flags, id;
998         char *base;
999  
1000 +       if (level != RESUME_ENABLE)
1001 +               return 0;
1002 +
1003         save = (struct sa1111_save_data *)dev->saved_state;
1004         if (!save)
1005                 return 0;
1006 @@ -878,39 +879,32 @@
1007         /*
1008          * First of all, wake up the chip.
1009          */
1010 -       if (level == RESUME_POWER_ON) {
1011 -               sa1111_wake(sachip);
1012 -
1013 -               sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0);
1014 -               sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1);
1015 -       }
1016 -
1017 -       if (level == RESUME_RESTORE_STATE) {
1018 -               base = sachip->base;
1019 -               sa1111_writel(save->skcr,     base + SA1111_SKCR);
1020 -               sa1111_writel(save->skpcr,    base + SA1111_SKPCR);
1021 -               sa1111_writel(save->skcdr,    base + SA1111_SKCDR);
1022 -               sa1111_writel(save->skaud,    base + SA1111_SKAUD);
1023 -               sa1111_writel(save->skpwm0,   base + SA1111_SKPWM0);
1024 -               sa1111_writel(save->skpwm1,   base + SA1111_SKPWM1);
1025 -
1026 -               base = sachip->base + SA1111_INTC;
1027 -               sa1111_writel(save->intpol0,  base + SA1111_INTPOL0);
1028 -               sa1111_writel(save->intpol1,  base + SA1111_INTPOL1);
1029 -               sa1111_writel(save->inten0,   base + SA1111_INTEN0);
1030 -               sa1111_writel(save->inten1,   base + SA1111_INTEN1);
1031 -               sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0);
1032 -               sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1);
1033 -               sa1111_writel(save->wakeen0,  base + SA1111_WAKEEN0);
1034 -               sa1111_writel(save->wakeen1,  base + SA1111_WAKEEN1);
1035 -       }
1036 +       sa1111_wake(sachip);
1037 +       sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0);
1038 +       sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1);
1039 +
1040 +       base = sachip->base;
1041 +       sa1111_writel(save->skcr,     base + SA1111_SKCR);
1042 +       sa1111_writel(save->skpcr,    base + SA1111_SKPCR);
1043 +       sa1111_writel(save->skcdr,    base + SA1111_SKCDR);
1044 +       sa1111_writel(save->skaud,    base + SA1111_SKAUD);
1045 +       sa1111_writel(save->skpwm0,   base + SA1111_SKPWM0);
1046 +       sa1111_writel(save->skpwm1,   base + SA1111_SKPWM1);
1047 +
1048 +       base = sachip->base + SA1111_INTC;
1049 +       sa1111_writel(save->intpol0,  base + SA1111_INTPOL0);
1050 +       sa1111_writel(save->intpol1,  base + SA1111_INTPOL1);
1051 +       sa1111_writel(save->inten0,   base + SA1111_INTEN0);
1052 +       sa1111_writel(save->inten1,   base + SA1111_INTEN1);
1053 +       sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0);
1054 +       sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1);
1055 +       sa1111_writel(save->wakeen0,  base + SA1111_WAKEEN0);
1056 +       sa1111_writel(save->wakeen1,  base + SA1111_WAKEEN1);
1057  
1058         spin_unlock_irqrestore(&sachip->lock, flags);
1059  
1060 -       if (level == RESUME_ENABLE) {
1061 -               dev->saved_state = NULL;
1062 -               kfree(save);
1063 -       }
1064 +       dev->saved_state = NULL;
1065 +       kfree(save);
1066  
1067         return 0;
1068  }
1069 @@ -1135,9 +1129,55 @@
1070         return dev->devid == drv->devid;
1071  }
1072  
1073 +static int sa1111_bus_suspend(struct device *dev, u32 state)
1074 +{
1075 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
1076 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1077 +       int ret = 0;
1078 +
1079 +       if (drv && drv->suspend)
1080 +               ret = drv->suspend(sadev, state);
1081 +       return ret;
1082 +}
1083 +
1084 +static int sa1111_bus_resume(struct device *dev)
1085 +{
1086 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
1087 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1088 +       int ret = 0;
1089 +
1090 +       if (drv && drv->resume)
1091 +               ret = drv->resume(sadev);
1092 +       return ret;
1093 +}
1094 +
1095 +static int sa1111_bus_probe(struct device *dev)
1096 +{
1097 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
1098 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1099 +       int ret = -ENODEV;
1100 +
1101 +       if (drv->probe)
1102 +               ret = drv->probe(sadev);
1103 +       return ret;
1104 +}
1105 +
1106 +static int sa1111_bus_remove(struct device *dev)
1107 +{
1108 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
1109 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1110 +       int ret = 0;
1111 +
1112 +       if (drv->remove)
1113 +               ret = drv->remove(sadev);
1114 +       return ret;
1115 +}
1116 +
1117  struct bus_type sa1111_bus_type = {
1118 -       .name   = "RAB",
1119 -       .match  = sa1111_match,
1120 +       .name           = "sa1111-rab",
1121 +       .match          = sa1111_match,
1122 +       .suspend        = sa1111_bus_suspend,
1123 +       .resume         = sa1111_bus_resume,
1124  };
1125  
1126  static int sa1111_rab_bus_init(void)
1127 @@ -1147,6 +1187,19 @@
1128  
1129  postcore_initcall(sa1111_rab_bus_init);
1130  
1131 +int sa1111_driver_register(struct sa1111_driver *driver)
1132 +{
1133 +       driver->drv.probe = sa1111_bus_probe;
1134 +       driver->drv.remove = sa1111_bus_remove;
1135 +       driver->drv.bus = &sa1111_bus_type;
1136 +       return driver_register(&driver->drv);
1137 +}
1138 +
1139 +void sa1111_driver_unregister(struct sa1111_driver *driver)
1140 +{
1141 +       driver_unregister(&driver->drv);
1142 +}
1143 +
1144  EXPORT_SYMBOL(sa1111_check_dma_bug);
1145  EXPORT_SYMBOL(sa1111_select_audio_mode);
1146  EXPORT_SYMBOL(sa1111_set_audio_rate);
1147 @@ -1155,3 +1208,5 @@
1148  EXPORT_SYMBOL(sa1111_disable_device);
1149  EXPORT_SYMBOL(sa1111_pll_clock);
1150  EXPORT_SYMBOL(sa1111_bus_type);
1151 +EXPORT_SYMBOL(sa1111_driver_register);
1152 +EXPORT_SYMBOL(sa1111_driver_unregister);
1153 diff -Nru a/arch/arm/def-configs/iq80310 b/arch/arm/def-configs/iq80310
1154 --- a/arch/arm/def-configs/iq80310      Tue Apr 15 07:34:41 2003
1155 +++ b/arch/arm/def-configs/iq80310      Wed Aug 13 16:46:20 2003
1156 @@ -19,6 +19,12 @@
1157  # CONFIG_BSD_PROCESS_ACCT is not set
1158  CONFIG_SYSCTL=y
1159  CONFIG_LOG_BUF_SHIFT=14
1160 +# CONFIG_EMBEDDED is not set
1161 +CONFIG_KALLSYMS=y
1162 +CONFIG_FUTEX=y
1163 +CONFIG_EPOLL=y
1164 +CONFIG_IOSCHED_AS=y
1165 +CONFIG_IOSCHED_DEADLINE=y
1166  
1167  #
1168  # Loadable module support
1169 @@ -34,7 +40,6 @@
1170  #
1171  # CONFIG_ARCH_ADIFCC is not set
1172  # CONFIG_ARCH_ANAKIN is not set
1173 -# CONFIG_ARCH_ARCA5K is not set
1174  # CONFIG_ARCH_CLPS7500 is not set
1175  # CONFIG_ARCH_CLPS711X is not set
1176  # CONFIG_ARCH_CO285 is not set
1177 @@ -50,14 +55,6 @@
1178  # CONFIG_ARCH_SHARK is not set
1179  
1180  #
1181 -# Archimedes/A5000 Implementations
1182 -#
1183 -
1184 -#
1185 -# Archimedes/A5000 Implementations (select only ONE)
1186 -#
1187 -
1188 -#
1189  # CLPS711X/EP721X Implementations
1190  #
1191  
1192 @@ -73,7 +70,9 @@
1193  # IOP3xx Implementation Options
1194  #
1195  CONFIG_ARCH_IQ80310=y
1196 +# CONFIG_ARCH_IQ80321 is not set
1197  CONFIG_ARCH_IOP310=y
1198 +# CONFIG_ARCH_IOP321 is not set
1199  
1200  #
1201  # IOP3xx Chipset Features
1202 @@ -84,6 +83,14 @@
1203  # CONFIG_IOP3XX_PMON is not set
1204  
1205  #
1206 +# ADIFCC Implementation Options
1207 +#
1208 +
1209 +#
1210 +# ADI Board Types
1211 +#
1212 +
1213 +#
1214  # Intel PXA250/210 Implementations
1215  #
1216  
1217 @@ -96,6 +103,7 @@
1218  #
1219  CONFIG_CPU_32=y
1220  CONFIG_CPU_XSCALE=y
1221 +CONFIG_XS80200=y
1222  CONFIG_CPU_32v5=y
1223  
1224  #
1225 @@ -116,9 +124,15 @@
1226  # CONFIG_HOTPLUG is not set
1227  
1228  #
1229 +# MMC/SD Card support
1230 +#
1231 +# CONFIG_MMC is not set
1232 +
1233 +#
1234  # At least one math emulation must be selected
1235  #
1236  CONFIG_FPE_NWFPE=y
1237 +# CONFIG_FPE_NWFPE_XP is not set
1238  # CONFIG_FPE_FASTFPE is not set
1239  CONFIG_KCORE_ELF=y
1240  # CONFIG_KCORE_AOUT is not set
1241 @@ -154,6 +168,7 @@
1242  CONFIG_MTD_BLOCK=y
1243  # CONFIG_FTL is not set
1244  # CONFIG_NFTL is not set
1245 +# CONFIG_INFTL is not set
1246  
1247  #
1248  # RAM/ROM/Flash chip drivers
1249 @@ -164,6 +179,7 @@
1250  # CONFIG_MTD_CFI_ADV_OPTIONS is not set
1251  CONFIG_MTD_CFI_INTELEXT=y
1252  # CONFIG_MTD_CFI_AMDSTD is not set
1253 +# CONFIG_MTD_CFI_STAA is not set
1254  # CONFIG_MTD_RAM is not set
1255  # CONFIG_MTD_ROM is not set
1256  # CONFIG_MTD_ABSENT is not set
1257 @@ -172,13 +188,11 @@
1258  #
1259  # Mapping drivers for chip access
1260  #
1261 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
1262  # CONFIG_MTD_PHYSMAP is not set
1263 -# CONFIG_MTD_NORA is not set
1264  # CONFIG_MTD_ARM_INTEGRATOR is not set
1265  CONFIG_MTD_IQ80310=y
1266  # CONFIG_MTD_EDB7312 is not set
1267 -# CONFIG_MTD_PCI is not set
1268 -# CONFIG_MTD_UCLINUX is not set
1269  
1270  #
1271  # Self-contained MTD device drivers
1272 @@ -191,9 +205,9 @@
1273  #
1274  # Disk-On-Chip Device Drivers
1275  #
1276 -# CONFIG_MTD_DOC1000 is not set
1277  # CONFIG_MTD_DOC2000 is not set
1278  # CONFIG_MTD_DOC2001 is not set
1279 +# CONFIG_MTD_DOC2001PLUS is not set
1280  
1281  #
1282  # NAND Flash Device Drivers
1283 @@ -236,7 +250,6 @@
1284  # CONFIG_NETLINK_DEV is not set
1285  CONFIG_NETFILTER=y
1286  # CONFIG_NETFILTER_DEBUG is not set
1287 -# CONFIG_FILTER is not set
1288  CONFIG_UNIX=y
1289  # CONFIG_NET_KEY is not set
1290  CONFIG_INET=y
1291 @@ -253,7 +266,7 @@
1292  # CONFIG_SYN_COOKIES is not set
1293  # CONFIG_INET_AH is not set
1294  # CONFIG_INET_ESP is not set
1295 -# CONFIG_XFRM_USER is not set
1296 +# CONFIG_INET_IPCOMP is not set
1297  
1298  #
1299  # IP: Netfilter Configuration
1300 @@ -264,7 +277,13 @@
1301  # CONFIG_IP_NF_ARPTABLES is not set
1302  # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
1303  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
1304 +
1305 +#
1306 +# IP: Virtual Server Configuration
1307 +#
1308 +# CONFIG_IP_VS is not set
1309  # CONFIG_IPV6 is not set
1310 +# CONFIG_XFRM_USER is not set
1311  
1312  #
1313  # SCTP Configuration (EXPERIMENTAL)
1314 @@ -310,6 +329,7 @@
1315  #
1316  CONFIG_NET_ETHERNET=y
1317  CONFIG_MII=y
1318 +# CONFIG_SMC91X is not set
1319  # CONFIG_HAPPYMEAL is not set
1320  # CONFIG_SUNGEM is not set
1321  # CONFIG_NET_VENDOR_3COM is not set
1322 @@ -351,6 +371,11 @@
1323  # CONFIG_R8169 is not set
1324  # CONFIG_SK98LIN is not set
1325  # CONFIG_TIGON3 is not set
1326 +
1327 +#
1328 +# Ethernet (10000 Mbit)
1329 +#
1330 +# CONFIG_IXGB is not set
1331  # CONFIG_FDDI is not set
1332  # CONFIG_HIPPI is not set
1333  # CONFIG_PPP is not set
1334 @@ -402,6 +427,7 @@
1335  CONFIG_BLK_DEV_IDECD=y
1336  # CONFIG_BLK_DEV_IDEFLOPPY is not set
1337  # CONFIG_IDE_TASK_IOCTL is not set
1338 +# CONFIG_IDE_TASKFILE_IO is not set
1339  
1340  #
1341  # IDE chipset support/bugfixes
1342 @@ -409,7 +435,7 @@
1343  # CONFIG_BLK_DEV_IDEPCI is not set
1344  
1345  #
1346 -# SCSI support
1347 +# SCSI device support
1348  #
1349  # CONFIG_SCSI is not set
1350  
1351 @@ -481,6 +507,7 @@
1352  #
1353  # I2C Hardware Sensors Chip support
1354  #
1355 +# CONFIG_I2C_SENSOR is not set
1356  
1357  #
1358  # L3 serial bus support
1359 @@ -534,6 +561,8 @@
1360  # CONFIG_VIDEO_PMS is not set
1361  # CONFIG_VIDEO_CPIA is not set
1362  # CONFIG_VIDEO_STRADIS is not set
1363 +# CONFIG_VIDEO_HEXIUM_ORION is not set
1364 +# CONFIG_VIDEO_HEXIUM_GEMINI is not set
1365  
1366  #
1367  # Radio Adapters
1368 @@ -551,18 +580,29 @@
1369  #
1370  # Supported Frontend Modules
1371  #
1372 -CONFIG_DVB_ALPS_BSRU6=y
1373 +# CONFIG_DVB_STV0299 is not set
1374  # CONFIG_DVB_ALPS_BSRV2 is not set
1375  # CONFIG_DVB_ALPS_TDLB7 is not set
1376  # CONFIG_DVB_ALPS_TDMB7 is not set
1377 +# CONFIG_DVB_ATMEL_AT76C651 is not set
1378 +# CONFIG_DVB_CX24110 is not set
1379  # CONFIG_DVB_GRUNDIG_29504_491 is not set
1380  # CONFIG_DVB_GRUNDIG_29504_401 is not set
1381 +# CONFIG_DVB_MT312 is not set
1382  # CONFIG_DVB_VES1820 is not set
1383 +# CONFIG_DVB_TDA1004X is not set
1384  
1385  #
1386 -# Supported DVB Adapters
1387 +# Supported SAA7146 based PCI Adapters
1388  #
1389  # CONFIG_DVB_AV7110 is not set
1390 +# CONFIG_DVB_BUDGET is not set
1391 +
1392 +#
1393 +# Supported FlexCopII (B2C2) Adapters
1394 +#
1395 +# CONFIG_DVB_B2C2_SKYSTAR is not set
1396 +# CONFIG_VIDEO_BTCX is not set
1397  
1398  #
1399  # File systems
1400 @@ -598,6 +638,7 @@
1401  CONFIG_PROC_FS=y
1402  # CONFIG_DEVFS_FS is not set
1403  CONFIG_DEVPTS_FS=y
1404 +# CONFIG_DEVPTS_FS_XATTR is not set
1405  CONFIG_TMPFS=y
1406  CONFIG_RAMFS=y
1407  
1408 @@ -631,13 +672,13 @@
1409  CONFIG_ROOT_NFS=y
1410  CONFIG_LOCKD=y
1411  # CONFIG_EXPORTFS is not set
1412 +CONFIG_SUNRPC=y
1413 +# CONFIG_SUNRPC_GSS is not set
1414  # CONFIG_SMB_FS is not set
1415  # CONFIG_CIFS is not set
1416  # CONFIG_NCP_FS is not set
1417  # CONFIG_CODA_FS is not set
1418  # CONFIG_INTERMEZZO_FS is not set
1419 -CONFIG_SUNRPC=y
1420 -# CONFIG_SUNRPC_GSS is not set
1421  # CONFIG_AFS_FS is not set
1422  
1423  #
1424 @@ -655,6 +696,7 @@
1425  # CONFIG_SOLARIS_X86_PARTITION is not set
1426  # CONFIG_UNIXWARE_DISKLABEL is not set
1427  # CONFIG_LDM_PARTITION is not set
1428 +# CONFIG_NEC98_PARTITION is not set
1429  # CONFIG_SGI_PARTITION is not set
1430  # CONFIG_ULTRIX_PARTITION is not set
1431  # CONFIG_SUN_PARTITION is not set
1432 @@ -666,13 +708,6 @@
1433  # CONFIG_FB is not set
1434  
1435  #
1436 -# Console display driver support
1437 -#
1438 -# CONFIG_VGA_CONSOLE is not set
1439 -# CONFIG_MDA_CONSOLE is not set
1440 -CONFIG_DUMMY_CONSOLE=y
1441 -
1442 -#
1443  # Sound
1444  #
1445  # CONFIG_SOUND is not set
1446 @@ -695,6 +730,7 @@
1447  # USB support
1448  #
1449  # CONFIG_USB is not set
1450 +# CONFIG_USB_GADGET is not set
1451  
1452  #
1453  # Bluetooth support
1454 @@ -714,7 +750,6 @@
1455  # CONFIG_DEBUG_WAITQ is not set
1456  CONFIG_DEBUG_BUGVERBOSE=y
1457  CONFIG_DEBUG_ERRORS=y
1458 -CONFIG_KALLSYMS=y
1459  CONFIG_DEBUG_LL=y
1460  
1461  #
1462 diff -Nru a/arch/arm/def-configs/iq80321 b/arch/arm/def-configs/iq80321
1463 --- a/arch/arm/def-configs/iq80321      Sat Aug  2 12:59:32 2003
1464 +++ b/arch/arm/def-configs/iq80321      Wed Aug 13 16:46:20 2003
1465 @@ -9,7 +9,7 @@
1466  #
1467  # Code maturity level options
1468  #
1469 -# CONFIG_EXPERIMENTAL is not set
1470 +CONFIG_EXPERIMENTAL=y
1471  
1472  #
1473  # General setup
1474 @@ -19,6 +19,12 @@
1475  # CONFIG_BSD_PROCESS_ACCT is not set
1476  CONFIG_SYSCTL=y
1477  CONFIG_LOG_BUF_SHIFT=14
1478 +# CONFIG_EMBEDDED is not set
1479 +CONFIG_KALLSYMS=y
1480 +CONFIG_FUTEX=y
1481 +CONFIG_EPOLL=y
1482 +CONFIG_IOSCHED_AS=y
1483 +CONFIG_IOSCHED_DEADLINE=y
1484  
1485  #
1486  # Loadable module support
1487 @@ -26,6 +32,7 @@
1488  CONFIG_MODULES=y
1489  # CONFIG_MODULE_UNLOAD is not set
1490  CONFIG_OBSOLETE_MODPARM=y
1491 +# CONFIG_MODVERSIONS is not set
1492  CONFIG_KMOD=y
1493  
1494  #
1495 @@ -33,7 +40,6 @@
1496  #
1497  # CONFIG_ARCH_ADIFCC is not set
1498  # CONFIG_ARCH_ANAKIN is not set
1499 -# CONFIG_ARCH_ARCA5K is not set
1500  # CONFIG_ARCH_CLPS7500 is not set
1501  # CONFIG_ARCH_CLPS711X is not set
1502  # CONFIG_ARCH_CO285 is not set
1503 @@ -49,14 +55,6 @@
1504  # CONFIG_ARCH_SHARK is not set
1505  
1506  #
1507 -# Archimedes/A5000 Implementations
1508 -#
1509 -
1510 -#
1511 -# Archimedes/A5000 Implementations (select only ONE)
1512 -#
1513 -
1514 -#
1515  # CLPS711X/EP721X Implementations
1516  #
1517  
1518 @@ -79,6 +77,18 @@
1519  #
1520  # IOP3xx Chipset Features
1521  #
1522 +# CONFIG_IOP3XX_AAU is not set
1523 +# CONFIG_IOP3XX_DMA is not set
1524 +# CONFIG_IOP3XX_MU is not set
1525 +# CONFIG_IOP3XX_PMON is not set
1526 +
1527 +#
1528 +# ADIFCC Implementation Options
1529 +#
1530 +
1531 +#
1532 +# ADI Board Types
1533 +#
1534  
1535  #
1536  # Intel PXA250/210 Implementations
1537 @@ -98,6 +108,7 @@
1538  #
1539  # Processor Features
1540  #
1541 +# CONFIG_ARM_THUMB is not set
1542  CONFIG_XSCALE_PMU=y
1543  
1544  #
1545 @@ -112,17 +123,25 @@
1546  # CONFIG_HOTPLUG is not set
1547  
1548  #
1549 +# MMC/SD Card support
1550 +#
1551 +# CONFIG_MMC is not set
1552 +
1553 +#
1554  # At least one math emulation must be selected
1555  #
1556  CONFIG_FPE_NWFPE=y
1557 +# CONFIG_FPE_NWFPE_XP is not set
1558 +# CONFIG_FPE_FASTFPE is not set
1559  CONFIG_KCORE_ELF=y
1560  # CONFIG_KCORE_AOUT is not set
1561  CONFIG_BINFMT_AOUT=y
1562  CONFIG_BINFMT_ELF=y
1563  # CONFIG_BINFMT_MISC is not set
1564  # CONFIG_PM is not set
1565 +# CONFIG_PREEMPT is not set
1566  # CONFIG_ARTHUR is not set
1567 -CONFIG_CMDLINE="ip=boot root=nfs console=ttyS0,115200"
1568 +CONFIG_CMDLINE="ip=boot root=nfs console=ttyS0,115200 mem=128M@0xa0000000"
1569  CONFIG_ALIGNMENT_TRAP=y
1570  
1571  #
1572 @@ -148,6 +167,7 @@
1573  CONFIG_MTD_BLOCK=y
1574  # CONFIG_FTL is not set
1575  # CONFIG_NFTL is not set
1576 +# CONFIG_INFTL is not set
1577  
1578  #
1579  # RAM/ROM/Flash chip drivers
1580 @@ -158,6 +178,7 @@
1581  # CONFIG_MTD_CFI_ADV_OPTIONS is not set
1582  CONFIG_MTD_CFI_INTELEXT=y
1583  # CONFIG_MTD_CFI_AMDSTD is not set
1584 +# CONFIG_MTD_CFI_STAA is not set
1585  # CONFIG_MTD_RAM is not set
1586  # CONFIG_MTD_ROM is not set
1587  # CONFIG_MTD_ABSENT is not set
1588 @@ -166,13 +187,10 @@
1589  #
1590  # Mapping drivers for chip access
1591  #
1592 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
1593  # CONFIG_MTD_PHYSMAP is not set
1594 -# CONFIG_MTD_NORA is not set
1595  # CONFIG_MTD_ARM_INTEGRATOR is not set
1596 -CONFIG_MTD_IQ80321=y
1597  # CONFIG_MTD_EDB7312 is not set
1598 -# CONFIG_MTD_PCI is not set
1599 -# CONFIG_MTD_UCLINUX is not set
1600  
1601  #
1602  # Self-contained MTD device drivers
1603 @@ -185,9 +203,9 @@
1604  #
1605  # Disk-On-Chip Device Drivers
1606  #
1607 -# CONFIG_MTD_DOC1000 is not set
1608  # CONFIG_MTD_DOC2000 is not set
1609  # CONFIG_MTD_DOC2001 is not set
1610 +# CONFIG_MTD_DOC2001PLUS is not set
1611  
1612  #
1613  # NAND Flash Device Drivers
1614 @@ -206,6 +224,7 @@
1615  # CONFIG_BLK_CPQ_DA is not set
1616  # CONFIG_BLK_CPQ_CISS_DA is not set
1617  # CONFIG_BLK_DEV_DAC960 is not set
1618 +# CONFIG_BLK_DEV_UMEM is not set
1619  # CONFIG_BLK_DEV_LOOP is not set
1620  # CONFIG_BLK_DEV_NBD is not set
1621  CONFIG_BLK_DEV_RAM=y
1622 @@ -229,7 +248,6 @@
1623  # CONFIG_NETLINK_DEV is not set
1624  CONFIG_NETFILTER=y
1625  # CONFIG_NETFILTER_DEBUG is not set
1626 -# CONFIG_FILTER is not set
1627  CONFIG_UNIX=y
1628  # CONFIG_NET_KEY is not set
1629  CONFIG_INET=y
1630 @@ -241,24 +259,47 @@
1631  # CONFIG_IP_PNP_RARP is not set
1632  # CONFIG_NET_IPIP is not set
1633  # CONFIG_NET_IPGRE is not set
1634 +# CONFIG_ARPD is not set
1635  # CONFIG_INET_ECN is not set
1636  # CONFIG_SYN_COOKIES is not set
1637  # CONFIG_INET_AH is not set
1638  # CONFIG_INET_ESP is not set
1639 -# CONFIG_XFRM_USER is not set
1640 +# CONFIG_INET_IPCOMP is not set
1641  
1642  #
1643  # IP: Netfilter Configuration
1644  #
1645  # CONFIG_IP_NF_CONNTRACK is not set
1646 +# CONFIG_IP_NF_QUEUE is not set
1647  # CONFIG_IP_NF_IPTABLES is not set
1648  # CONFIG_IP_NF_ARPTABLES is not set
1649  # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
1650  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
1651 +
1652 +#
1653 +# IP: Virtual Server Configuration
1654 +#
1655 +# CONFIG_IP_VS is not set
1656 +# CONFIG_IPV6 is not set
1657 +# CONFIG_XFRM_USER is not set
1658 +
1659 +#
1660 +# SCTP Configuration (EXPERIMENTAL)
1661 +#
1662 +CONFIG_IPV6_SCTP__=y
1663 +# CONFIG_IP_SCTP is not set
1664 +# CONFIG_ATM is not set
1665  # CONFIG_VLAN_8021Q is not set
1666  # CONFIG_LLC is not set
1667  # CONFIG_DECNET is not set
1668  # CONFIG_BRIDGE is not set
1669 +# CONFIG_X25 is not set
1670 +# CONFIG_LAPB is not set
1671 +# CONFIG_NET_DIVERT is not set
1672 +# CONFIG_ECONET is not set
1673 +# CONFIG_WAN_ROUTER is not set
1674 +# CONFIG_NET_FASTROUTE is not set
1675 +# CONFIG_NET_HW_FLOWCONTROL is not set
1676  
1677  #
1678  # QoS and/or fair queueing
1679 @@ -279,12 +320,14 @@
1680  # CONFIG_BONDING is not set
1681  # CONFIG_EQUALIZER is not set
1682  # CONFIG_TUN is not set
1683 +# CONFIG_ETHERTAP is not set
1684  
1685  #
1686  # Ethernet (10 or 100Mbit)
1687  #
1688  CONFIG_NET_ETHERNET=y
1689  # CONFIG_MII is not set
1690 +# CONFIG_SMC91X is not set
1691  # CONFIG_HAPPYMEAL is not set
1692  # CONFIG_SUNGEM is not set
1693  # CONFIG_NET_VENDOR_3COM is not set
1694 @@ -298,6 +341,7 @@
1695  # CONFIG_PCNET32 is not set
1696  # CONFIG_AMD8111_ETH is not set
1697  # CONFIG_ADAPTEC_STARFIRE is not set
1698 +# CONFIG_B44 is not set
1699  # CONFIG_DGRS is not set
1700  CONFIG_EEPRO100=y
1701  # CONFIG_EEPRO100_PIO is not set
1702 @@ -305,6 +349,7 @@
1703  # CONFIG_FEALNX is not set
1704  # CONFIG_NATSEMI is not set
1705  # CONFIG_NE2K_PCI is not set
1706 +# CONFIG_8139CP is not set
1707  # CONFIG_8139TOO is not set
1708  # CONFIG_SIS900 is not set
1709  # CONFIG_EPIC100 is not set
1710 @@ -317,13 +362,21 @@
1711  #
1712  # CONFIG_ACENIC is not set
1713  # CONFIG_DL2K is not set
1714 -# CONFIG_E1000 is not set
1715 +CONFIG_E1000=y
1716 +CONFIG_E1000_NAPI=y
1717  # CONFIG_NS83820 is not set
1718  # CONFIG_HAMACHI is not set
1719 +# CONFIG_YELLOWFIN is not set
1720  # CONFIG_R8169 is not set
1721  # CONFIG_SK98LIN is not set
1722  # CONFIG_TIGON3 is not set
1723 +
1724 +#
1725 +# Ethernet (10000 Mbit)
1726 +#
1727 +# CONFIG_IXGB is not set
1728  # CONFIG_FDDI is not set
1729 +# CONFIG_HIPPI is not set
1730  # CONFIG_PPP is not set
1731  # CONFIG_SLIP is not set
1732  
1733 @@ -335,6 +388,8 @@
1734  #
1735  # Token Ring devices (depends on LLC=y)
1736  #
1737 +# CONFIG_RCPCI is not set
1738 +# CONFIG_SHAPER is not set
1739  
1740  #
1741  # Wan interfaces
1742 @@ -371,6 +426,7 @@
1743  CONFIG_BLK_DEV_IDECD=y
1744  # CONFIG_BLK_DEV_IDEFLOPPY is not set
1745  # CONFIG_IDE_TASK_IOCTL is not set
1746 +# CONFIG_IDE_TASKFILE_IO is not set
1747  
1748  #
1749  # IDE chipset support/bugfixes
1750 @@ -379,11 +435,13 @@
1751  # CONFIG_BLK_DEV_GENERIC is not set
1752  # CONFIG_IDEPCI_SHARE_IRQ is not set
1753  CONFIG_BLK_DEV_IDEDMA_PCI=y
1754 +# CONFIG_BLK_DEV_IDE_TCQ is not set
1755  # CONFIG_BLK_DEV_OFFBOARD is not set
1756  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
1757  CONFIG_IDEDMA_PCI_AUTO=y
1758  # CONFIG_IDEDMA_ONLYDISK is not set
1759  CONFIG_BLK_DEV_IDEDMA=y
1760 +# CONFIG_IDEDMA_PCI_WIP is not set
1761  CONFIG_BLK_DEV_ADMA=y
1762  # CONFIG_BLK_DEV_AEC62XX is not set
1763  # CONFIG_BLK_DEV_ALI15X3 is not set
1764 @@ -391,11 +449,13 @@
1765  CONFIG_BLK_DEV_CMD64X=y
1766  # CONFIG_BLK_DEV_TRIFLEX is not set
1767  # CONFIG_BLK_DEV_CY82C693 is not set
1768 +# CONFIG_BLK_DEV_CS5520 is not set
1769  # CONFIG_BLK_DEV_HPT34X is not set
1770  # CONFIG_BLK_DEV_HPT366 is not set
1771  # CONFIG_BLK_DEV_SC1200 is not set
1772  # CONFIG_BLK_DEV_PIIX is not set
1773  # CONFIG_BLK_DEV_NS87415 is not set
1774 +# CONFIG_BLK_DEV_OPTI621 is not set
1775  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
1776  # CONFIG_BLK_DEV_PDC202XX_NEW is not set
1777  # CONFIG_BLK_DEV_SVWKS is not set
1778 @@ -408,11 +468,16 @@
1779  # CONFIG_IDEDMA_IVB is not set
1780  
1781  #
1782 -# SCSI support
1783 +# SCSI device support
1784  #
1785  # CONFIG_SCSI is not set
1786  
1787  #
1788 +# IEEE 1394 (FireWire) support (EXPERIMENTAL)
1789 +#
1790 +# CONFIG_IEEE1394 is not set
1791 +
1792 +#
1793  # I2O device support
1794  #
1795  # CONFIG_I2O is not set
1796 @@ -450,11 +515,16 @@
1797  #
1798  # Serial drivers
1799  #
1800 +CONFIG_SERIAL_8250=y
1801 +CONFIG_SERIAL_8250_CONSOLE=y
1802 +# CONFIG_SERIAL_8250_EXTENDED is not set
1803  
1804  #
1805  # Non-8250 serial port support
1806  #
1807  # CONFIG_SERIAL_DZ is not set
1808 +CONFIG_SERIAL_CORE=y
1809 +CONFIG_SERIAL_CORE_CONSOLE=y
1810  CONFIG_UNIX98_PTYS=y
1811  CONFIG_UNIX98_PTY_COUNT=256
1812  
1813 @@ -470,6 +540,7 @@
1814  #
1815  # I2C Hardware Sensors Chip support
1816  #
1817 +# CONFIG_I2C_SENSOR is not set
1818  
1819  #
1820  # L3 serial bus support
1821 @@ -522,6 +593,9 @@
1822  #
1823  # CONFIG_VIDEO_PMS is not set
1824  # CONFIG_VIDEO_CPIA is not set
1825 +# CONFIG_VIDEO_STRADIS is not set
1826 +# CONFIG_VIDEO_HEXIUM_ORION is not set
1827 +# CONFIG_VIDEO_HEXIUM_GEMINI is not set
1828  
1829  #
1830  # Radio Adapters
1831 @@ -534,6 +608,7 @@
1832  # Digital Video Broadcasting Devices
1833  #
1834  # CONFIG_DVB is not set
1835 +# CONFIG_VIDEO_BTCX is not set
1836  
1837  #
1838  # File systems
1839 @@ -567,16 +642,25 @@
1840  # Pseudo filesystems
1841  #
1842  CONFIG_PROC_FS=y
1843 +# CONFIG_DEVFS_FS is not set
1844  CONFIG_DEVPTS_FS=y
1845 +# CONFIG_DEVPTS_FS_XATTR is not set
1846  CONFIG_TMPFS=y
1847  CONFIG_RAMFS=y
1848  
1849  #
1850  # Miscellaneous filesystems
1851  #
1852 +# CONFIG_ADFS_FS is not set
1853 +# CONFIG_AFFS_FS is not set
1854 +# CONFIG_HFS_FS is not set
1855 +# CONFIG_BEFS_FS is not set
1856 +# CONFIG_BFS_FS is not set
1857 +# CONFIG_EFS_FS is not set
1858  # CONFIG_JFFS_FS is not set
1859  CONFIG_JFFS2_FS=y
1860  CONFIG_JFFS2_FS_DEBUG=0
1861 +# CONFIG_JFFS2_FS_NAND is not set
1862  # CONFIG_CRAMFS is not set
1863  # CONFIG_VXFS_FS is not set
1864  # CONFIG_HPFS_FS is not set
1865 @@ -589,15 +673,19 @@
1866  #
1867  CONFIG_NFS_FS=y
1868  # CONFIG_NFS_V3 is not set
1869 +# CONFIG_NFS_V4 is not set
1870  # CONFIG_NFSD is not set
1871  CONFIG_ROOT_NFS=y
1872  CONFIG_LOCKD=y
1873  # CONFIG_EXPORTFS is not set
1874 +CONFIG_SUNRPC=y
1875 +# CONFIG_SUNRPC_GSS is not set
1876  # CONFIG_SMB_FS is not set
1877  # CONFIG_CIFS is not set
1878  # CONFIG_NCP_FS is not set
1879  # CONFIG_CODA_FS is not set
1880 -CONFIG_SUNRPC=y
1881 +# CONFIG_INTERMEZZO_FS is not set
1882 +# CONFIG_AFS_FS is not set
1883  
1884  #
1885  # Partition Types
1886 @@ -614,6 +702,7 @@
1887  # CONFIG_SOLARIS_X86_PARTITION is not set
1888  # CONFIG_UNIXWARE_DISKLABEL is not set
1889  # CONFIG_LDM_PARTITION is not set
1890 +# CONFIG_NEC98_PARTITION is not set
1891  # CONFIG_SGI_PARTITION is not set
1892  # CONFIG_ULTRIX_PARTITION is not set
1893  # CONFIG_SUN_PARTITION is not set
1894 @@ -625,13 +714,6 @@
1895  # CONFIG_FB is not set
1896  
1897  #
1898 -# Console display driver support
1899 -#
1900 -# CONFIG_VGA_CONSOLE is not set
1901 -# CONFIG_MDA_CONSOLE is not set
1902 -CONFIG_DUMMY_CONSOLE=y
1903 -
1904 -#
1905  # Sound
1906  #
1907  # CONFIG_SOUND is not set
1908 @@ -654,6 +736,7 @@
1909  # USB support
1910  #
1911  # CONFIG_USB is not set
1912 +# CONFIG_USB_GADGET is not set
1913  
1914  #
1915  # Bluetooth support
1916 @@ -664,7 +747,7 @@
1917  # Kernel hacking
1918  #
1919  CONFIG_FRAME_POINTER=y
1920 -CONFIG_DEBUG_USER=y
1921 +# CONFIG_DEBUG_USER is not set
1922  # CONFIG_DEBUG_INFO is not set
1923  CONFIG_DEBUG_KERNEL=y
1924  # CONFIG_DEBUG_SLAB is not set
1925 @@ -673,7 +756,6 @@
1926  # CONFIG_DEBUG_WAITQ is not set
1927  CONFIG_DEBUG_BUGVERBOSE=y
1928  CONFIG_DEBUG_ERRORS=y
1929 -# CONFIG_KALLSYMS is not set
1930  CONFIG_DEBUG_LL=y
1931  
1932  #
1933 diff -Nru a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
1934 --- a/arch/arm/kernel/apm.c     Wed Mar 26 05:00:46 2003
1935 +++ b/arch/arm/kernel/apm.c     Sun Aug 31 16:14:08 2003
1936 @@ -26,6 +26,7 @@
1937  #include <linux/init.h>
1938  #include <linux/completion.h>
1939  
1940 +#include <asm/apm.h> /* apm_power_info */
1941  #include <asm/system.h>
1942  
1943  /*
1944 @@ -93,18 +94,7 @@
1945  
1946  static const char driver_version[] = "1.13";   /* no spaces */
1947  
1948 -/*
1949 - * This structure gets filled in by the machine specific 'get_power_status'
1950 - * implementation.  Any fields which are not set default to a safe value.
1951 - */
1952 -struct apm_power_info {
1953 -       unsigned char   ac_line_status;
1954 -       unsigned char   battery_status;
1955 -       unsigned char   battery_flag;
1956 -       unsigned char   battery_life;
1957 -       int             time;
1958 -       int             units;
1959 -};
1960 +
1961  
1962  /*
1963   * Compatibility cruft until the IPAQ people move over to the new
1964 @@ -388,18 +378,18 @@
1965  }
1966  
1967  static struct file_operations apm_bios_fops = {
1968 -       owner:          THIS_MODULE,
1969 -       read:           apm_read,
1970 -       poll:           apm_poll,
1971 -       ioctl:          apm_ioctl,
1972 -       open:           apm_open,
1973 -       release:        apm_release,
1974 +       .owner          = THIS_MODULE,
1975 +       .read           = apm_read,
1976 +       .poll           = apm_poll,
1977 +       .ioctl          = apm_ioctl,
1978 +       .open           = apm_open,
1979 +       .release        = apm_release,
1980  };
1981  
1982  static struct miscdevice apm_device = {
1983 -       minor:          APM_MINOR_DEV,
1984 -       name:           "apm_bios",
1985 -       fops:           &apm_bios_fops
1986 +       .minor          = APM_MINOR_DEV,
1987 +       .name           = "apm_bios",
1988 +       .fops           = &apm_bios_fops
1989  };
1990  
1991  
1992 diff -Nru a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
1993 --- a/arch/arm/kernel/bios32.c  Thu Jul 31 16:47:19 2003
1994 +++ b/arch/arm/kernel/bios32.c  Sun Aug 24 06:12:42 2003
1995 @@ -263,7 +263,7 @@
1996  void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
1997  {
1998         if (debug_pci)
1999 -               printk("PCI: Assigning IRQ %02d to %s\n", irq, dev->dev.name);
2000 +               printk("PCI: Assigning IRQ %02d to %s\n", irq, pci_name(dev));
2001         pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
2002  }
2003  
2004 @@ -362,6 +362,19 @@
2005                         isa_bridge = dev;
2006                         break;
2007  #endif
2008 +               case PCI_CLASS_BRIDGE_PCI:
2009 +                       pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &status);
2010 +                       status |= PCI_BRIDGE_CTL_PARITY|PCI_BRIDGE_CTL_MASTER_ABORT;
2011 +                       status &= ~(PCI_BRIDGE_CTL_BUS_RESET|PCI_BRIDGE_CTL_FAST_BACK);
2012 +                       pci_write_config_word(dev, PCI_BRIDGE_CONTROL, status);
2013 +                       break;
2014 +
2015 +               case PCI_CLASS_BRIDGE_CARDBUS:
2016 +                       pci_read_config_word(dev, PCI_CB_BRIDGE_CONTROL, &status);
2017 +                       status |= PCI_CB_BRIDGE_CTL_PARITY|PCI_CB_BRIDGE_CTL_MASTER_ABORT;
2018 +                       pci_write_config_word(dev, PCI_CB_BRIDGE_CONTROL, status);
2019 +                       break;
2020 +               }
2021         }
2022  
2023         /*
2024 diff -Nru a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
2025 --- a/arch/arm/kernel/ecard.c   Fri Aug 15 15:22:53 2003
2026 +++ b/arch/arm/kernel/ecard.c   Sun Aug 24 05:44:40 2003
2027 @@ -896,7 +896,7 @@
2028  static ssize_t ecard_show_vendor(struct device *dev, char *buf)
2029  {
2030         struct expansion_card *ec = ECARD_DEV(dev);
2031 -       return sprintf(buf, "%u\n", ec->manufacturer);
2032 +       return sprintf(buf, "%u\n", ec->cid.manufacturer);
2033  }
2034  
2035  static DEVICE_ATTR(vendor, S_IRUGO, ecard_show_vendor, NULL);
2036 @@ -904,7 +904,7 @@
2037  static ssize_t ecard_show_device(struct device *dev, char *buf)
2038  {
2039         struct expansion_card *ec = ECARD_DEV(dev);
2040 -       return sprintf(buf, "%u\n", ec->product);
2041 +       return sprintf(buf, "%u\n", ec->cid.product);
2042  }
2043  
2044  static DEVICE_ATTR(device, S_IRUGO, ecard_show_device, NULL);
2045 diff -Nru a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2046 --- a/arch/arm/kernel/entry-header.S    Tue Mar  4 16:47:50 2003
2047 +++ b/arch/arm/kernel/entry-header.S    Sun Aug 24 06:17:52 2003
2048 @@ -63,13 +63,7 @@
2049  #define S_OFF          8
2050  
2051         .macro  set_cpsr_c, reg, mode
2052 -#if 1
2053 -       /* broken binutils */
2054 -       mov     \reg, \mode
2055 -       msr     cpsr_c, \reg
2056 -#else
2057         msr     cpsr_c, \mode
2058 -#endif
2059         .endm
2060  
2061         .macro  disable_irq, temp
2062 diff -Nru a/arch/arm/kernel/pm.c b/arch/arm/kernel/pm.c
2063 --- a/arch/arm/kernel/pm.c      Sat Jun 21 03:42:03 2003
2064 +++ b/arch/arm/kernel/pm.c      Sun Aug 24 05:40:01 2003
2065 @@ -36,23 +36,7 @@
2066         if (ret != 0)
2067                 goto out;
2068  
2069 -       /*
2070 -        * Tell LDM devices we're going to suspend.
2071 -        */
2072 -       ret = device_suspend(4, SUSPEND_NOTIFY);
2073 -       if (ret != 0)
2074 -               goto resume_legacy;
2075 -
2076 -       /*
2077 -        * Disable, devices, and save state.
2078 -        */
2079 -       device_suspend(4, SUSPEND_DISABLE);
2080 -       device_suspend(4, SUSPEND_SAVE_STATE);
2081 -
2082 -       /*
2083 -        * Tell devices that they're going to be powered off.
2084 -        */
2085 -       device_suspend(4, SUSPEND_POWER_DOWN);
2086 +       device_suspend(3);
2087  
2088         local_irq_disable();
2089         leds_event(led_stop);
2090 @@ -62,21 +46,8 @@
2091         leds_event(led_start);
2092         local_irq_enable();
2093  
2094 -       /*
2095 -        * Tell devices that they now have power.
2096 -        */
2097 -       device_resume(RESUME_POWER_ON);
2098 -
2099 -       /*
2100 -        * Resume LDM devices.
2101 -        */
2102 -       device_resume(RESUME_RESTORE_STATE);
2103 -       device_resume(RESUME_ENABLE);
2104 +       device_resume();
2105  
2106 - resume_legacy:
2107 -       /*
2108 -        * Resume "legacy" devices.
2109 -        */
2110         pm_send_all(PM_RESUME, (void *)0);
2111  
2112   out:
2113 diff -Nru a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
2114 --- a/arch/arm/kernel/vmlinux.lds.S     Mon Aug  4 20:39:42 2003
2115 +++ b/arch/arm/kernel/vmlinux.lds.S     Sun Aug 24 04:26:29 2003
2116 @@ -1,21 +1,134 @@
2117 -#include <linux/config.h>
2118 -
2119 -#ifdef CONFIG_CPU_26
2120 -
2121 -#ifdef CONFIG_ROM_KERNEL
2122 -
2123 -#include "vmlinux-armo-rom.lds.in"
2124 -
2125 +/* ld script to make ARM Linux kernel
2126 + * taken from the i386 version by Russell King
2127 + * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
2128 + */
2129 +
2130 +#include <asm-generic/vmlinux.lds.h>
2131 +       
2132 +OUTPUT_ARCH(arm)
2133 +ENTRY(stext)
2134 +#ifndef __ARMEB__
2135 +jiffies = jiffies_64;
2136  #else
2137 -
2138 -#include "vmlinux-armo.lds.in"
2139 -
2140 -#endif
2141 -
2142 -#endif
2143 -
2144 -#ifdef CONFIG_CPU_32
2145 -
2146 -#include "vmlinux-armv.lds.in"
2147 -
2148 +jiffies = jiffies_64 + 4;
2149  #endif
2150 +SECTIONS
2151 +{
2152 +       . = TEXTADDR;
2153 +       .init : {                       /* Init code and data           */
2154 +               _stext = .;
2155 +               __init_begin = .;
2156 +                       _sinittext = .;
2157 +                       *(.init.text)
2158 +                       _einittext = .;
2159 +               __proc_info_begin = .;
2160 +                       *(.proc.info)
2161 +               __proc_info_end = .;
2162 +               __arch_info_begin = .;
2163 +                       *(.arch.info)
2164 +               __arch_info_end = .;
2165 +               __tagtable_begin = .;
2166 +                       *(.taglist)
2167 +               __tagtable_end = .;
2168 +                       *(.init.data)
2169 +               . = ALIGN(16);
2170 +               __setup_start = .;
2171 +                       *(.init.setup)
2172 +               __setup_end = .;
2173 +               __early_begin = .;
2174 +                       *(__early_param)
2175 +               __early_end = .;
2176 +               __start___param = .;
2177 +                       *(__param)
2178 +               __stop___param = .;
2179 +               __initcall_start = .;
2180 +                       *(.initcall1.init)
2181 +                       *(.initcall2.init)
2182 +                       *(.initcall3.init)
2183 +                       *(.initcall4.init)
2184 +                       *(.initcall5.init)
2185 +                       *(.initcall6.init)
2186 +                       *(.initcall7.init)
2187 +               __initcall_end = .;
2188 +               __con_initcall_start = .;
2189 +                       *(.con_initcall.init)
2190 +               __con_initcall_end = .;
2191 +               __security_initcall_start = .;
2192 +                       *(.security_initcall.init)
2193 +               __security_initcall_end = .;
2194 +               . = ALIGN(32);
2195 +               __initramfs_start = .;
2196 +                       usr/built-in.o(.init.ramfs)
2197 +               __initramfs_end = .;
2198 +               . = ALIGN(4096);
2199 +               __init_end = .;
2200 +       }
2201 +
2202 +       /DISCARD/ : {                   /* Exit code and data           */
2203 +               *(.exit.text)
2204 +               *(.exit.data)
2205 +               *(.exitcall.exit)
2206 +       }
2207 +
2208 +       .text : {                       /* Real text segment            */
2209 +               _text = .;              /* Text and read-only data      */
2210 +                       *(.text)
2211 +                       *(.fixup)
2212 +                       *(.gnu.warning)
2213 +                       *(.rodata)
2214 +                       *(.rodata.*)
2215 +                       *(.glue_7)
2216 +                       *(.glue_7t)
2217 +               *(.got)                 /* Global offset table          */
2218 +
2219 +               _etext = .;             /* End of text section          */
2220 +       }
2221 +
2222 +       . = ALIGN(16);
2223 +       __ex_table : {                  /* Exception table              */
2224 +               __start___ex_table = .;
2225 +                       *(__ex_table)
2226 +               __stop___ex_table = .;
2227 +       }
2228 +
2229 +       RODATA
2230 +
2231 +       . = ALIGN(8192);
2232 +
2233 +       .data : {
2234 +               /*
2235 +                * first, the init task union, aligned
2236 +                * to an 8192 byte boundary.
2237 +                */
2238 +               *(.init.task)
2239 +
2240 +               /*
2241 +                * then the cacheline aligned data
2242 +                */
2243 +               . = ALIGN(32);
2244 +               *(.data.cacheline_aligned)
2245 +
2246 +               /*
2247 +                * and the usual data section
2248 +                */
2249 +               *(.data)
2250 +               CONSTRUCTORS
2251 +
2252 +               _edata = .;
2253 +       }
2254 +
2255 +       .bss : {
2256 +               __bss_start = .;        /* BSS                          */
2257 +               *(.bss)
2258 +               *(COMMON)
2259 +               _end = . ;
2260 +       }
2261 +                                       /* Stabs debugging sections.    */
2262 +       .stab 0 : { *(.stab) }
2263 +       .stabstr 0 : { *(.stabstr) }
2264 +       .stab.excl 0 : { *(.stab.excl) }
2265 +       .stab.exclstr 0 : { *(.stab.exclstr) }
2266 +       .stab.index 0 : { *(.stab.index) }
2267 +       .stab.indexstr 0 : { *(.stab.indexstr) }
2268 +       .comment 0 : { *(.comment) }
2269 +}
2270 diff -Nru a/arch/arm/mach-footbridge/netwinder-pci.c b/arch/arm/mach-footbridge/netwinder-pci.c
2271 --- a/arch/arm/mach-footbridge/netwinder-pci.c  Thu Jul 31 16:47:19 2003
2272 +++ b/arch/arm/mach-footbridge/netwinder-pci.c  Sun Aug 24 04:37:15 2003
2273 @@ -36,8 +36,8 @@
2274                 return IRQ_NETWINDER_ETHER10;
2275  
2276         default:
2277 -               printk(KERN_ERR "PCI: unknown device in slot %s: %s\n",
2278 -                       pci_name(dev), dev->dev.name);
2279 +               printk(KERN_ERR "PCI: unknown device in slot %s\n",
2280 +                       pci_name(dev));
2281                 return 0;
2282         }
2283  }
2284 diff -Nru a/arch/arm/mach-iop3xx/iop321-time.c b/arch/arm/mach-iop3xx/iop321-time.c
2285 --- a/arch/arm/mach-iop3xx/iop321-time.c        Tue Apr 15 08:12:47 2003
2286 +++ b/arch/arm/mach-iop3xx/iop321-time.c        Wed Aug 13 16:46:20 2003
2287 @@ -51,7 +51,8 @@
2288         return usec;
2289  }
2290  
2291 -static void iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2292 +static irqreturn_t
2293 +iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2294  {
2295         u32 tisr;
2296  
2297 @@ -62,6 +63,8 @@
2298         asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr));
2299  
2300         do_timer(regs);
2301 +
2302 +       return IRQ_HANDLED;
2303  }
2304  
2305  extern unsigned long (*gettimeoffset)(void);
2306 diff -Nru a/arch/arm/mach-iop3xx/iq80310-time.c b/arch/arm/mach-iop3xx/iq80310-time.c
2307 --- a/arch/arm/mach-iop3xx/iq80310-time.c       Mon Apr 21 15:43:40 2003
2308 +++ b/arch/arm/mach-iop3xx/iq80310-time.c       Wed Aug 13 16:46:20 2003
2309 @@ -88,7 +88,8 @@
2310  }
2311  
2312  
2313 -static void iq80310_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2314 +static irqreturn_t
2315 +iq80310_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2316  {
2317         volatile u_char *timer_en = (volatile u_char *)IQ80310_TIMER_EN;
2318  
2319 @@ -96,21 +97,9 @@
2320         *timer_en &= ~2;
2321         *timer_en |= 2;
2322  
2323 -       /*
2324 -        * AHEM..HACK
2325 -        *
2326 -        * Since the timer interrupt is cascaded through the CPLD and
2327 -        * the 80312 and the demux code calls do_IRQ, the irq count is
2328 -        * going to be at least 2 when we get here and this will cause the
2329 -        * kernel to increment the system tick counter even if we're
2330 -        * idle. This causes it to look like there's always 100% system
2331 -        * time, which is not the case.  To get around it, we just decrement
2332 -        * the IRQ count before calling do_timer. We increment it again
2333 -        * b/c otherwise it will go negative and than bad things happen.
2334 -        *
2335 -        * -DS
2336 -        */
2337         do_timer(regs);
2338 +
2339 +       return IRQ_HANDLED;
2340  }
2341  
2342  extern unsigned long (*gettimeoffset)(void);
2343 @@ -126,7 +115,9 @@
2344         volatile u_char *timer_en = (volatile u_char *)IQ80310_TIMER_EN;
2345  
2346         gettimeoffset = iq80310_gettimeoffset;
2347 +
2348         setup_irq(IRQ_IQ80310_TIMER, &timer_irq);
2349 +
2350         *timer_en = 0;
2351         iq80310_write_timer(LATCH);
2352         *timer_en |= 2;
2353 diff -Nru a/arch/arm/mach-sa1100/leds-simpad.c b/arch/arm/mach-sa1100/leds-simpad.c
2354 --- a/arch/arm/mach-sa1100/leds-simpad.c        Mon Feb  4 23:53:46 2002
2355 +++ b/arch/arm/mach-sa1100/leds-simpad.c        Thu Aug  7 11:40:46 2003
2356 @@ -9,6 +9,7 @@
2357  #include <asm/hardware.h>
2358  #include <asm/leds.h>
2359  #include <asm/system.h>
2360 +#include <asm/arch/simpad.h>
2361  
2362  #include "leds.h"
2363  
2364 diff -Nru a/arch/arm/mach-sa1100/leds.c b/arch/arm/mach-sa1100/leds.c
2365 --- a/arch/arm/mach-sa1100/leds.c       Wed Dec 11 06:27:36 2002
2366 +++ b/arch/arm/mach-sa1100/leds.c       Thu Aug  7 11:40:46 2003
2367 @@ -41,6 +41,8 @@
2368                 leds_event = adsbitsy_leds_event;
2369         if (machine_is_pt_system3())
2370                 leds_event = system3_leds_event;
2371 +       if (machine_is_simpad())
2372 +               leds_event = simpad_leds_event; /* what about machine registry? including led, apm... -zecke */
2373  
2374         leds_event(led_start);
2375         return 0;
2376 diff -Nru a/arch/arm/mach-sa1100/leds.h b/arch/arm/mach-sa1100/leds.h
2377 --- a/arch/arm/mach-sa1100/leds.h       Wed Dec 11 06:27:36 2002
2378 +++ b/arch/arm/mach-sa1100/leds.h       Thu Aug  7 11:40:46 2003
2379 @@ -11,3 +11,4 @@
2380  extern void graphicsmaster_leds_event(led_event_t evt);
2381  extern void adsbitsy_leds_event(led_event_t evt);
2382  extern void system3_leds_event(led_event_t evt);
2383 +extern void simpad_leds_event(led_event_t evt);
2384 diff -Nru a/arch/arm/vmlinux-armo.lds.in b/arch/arm/vmlinux-armo.lds.in
2385 --- a/arch/arm/vmlinux-armo.lds.in      Wed Jun 11 17:40:04 2003
2386 +++ /dev/null   Wed Dec 31 16:00:00 1969
2387 @@ -1,114 +0,0 @@
2388 -/* ld script to make ARM Linux kernel
2389 - * taken from the i386 version by Russell King
2390 - * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
2391 - */
2392 -
2393 -#include <asm-generic/vmlinux.lds.h>
2394 -       
2395 -OUTPUT_ARCH(arm)
2396 -ENTRY(stext)
2397 -jiffies = jiffies_64;
2398 -SECTIONS
2399 -{
2400 -       . = TEXTADDR;
2401 -       .init : {                       /* Init code and data           */
2402 -               _stext = .;
2403 -               __init_begin = .;
2404 -                       _sinittext = .;
2405 -                       *(.init.text)
2406 -                       _einittext = .;
2407 -               __proc_info_begin = .;
2408 -                       *(.proc.info)
2409 -               __proc_info_end = .;
2410 -               __arch_info_begin = .;
2411 -                       *(.arch.info)
2412 -               __arch_info_end = .;
2413 -               __tagtable_begin = .;
2414 -                       *(.taglist)
2415 -               __tagtable_end = .;
2416 -                       *(.init.data)
2417 -               . = ALIGN(16);
2418 -               __setup_start = .;
2419 -                       *(.init.setup)
2420 -               __setup_end = .;
2421 -               __initcall_start = .;
2422 -                       *(.initcall1.init)
2423 -                       *(.initcall2.init)
2424 -                       *(.initcall3.init)
2425 -                       *(.initcall4.init)
2426 -                       *(.initcall5.init)
2427 -                       *(.initcall6.init)
2428 -                       *(.initcall7.init)
2429 -               __initcall_end = .;
2430 -               __con_initcall_start = .;
2431 -                       *(.con_initcall.init)
2432 -               __con_initcall_end = .;
2433 -               SECURITY_INIT
2434 -               . = ALIGN(32768);
2435 -               __init_end = .;
2436 -       }
2437 -
2438 -       .init.task : {
2439 -               *(.init.task)
2440 -       }
2441 -
2442 -       /DISCARD/ : {                   /* Exit code and data           */
2443 -               *(.exit.text)
2444 -               *(.exit.data)
2445 -               *(.exitcall.exit)
2446 -       }
2447 -
2448 -       .text : {                       /* Real text segment            */
2449 -               _text = .;              /* Text and read-only data      */
2450 -                       *(.text)
2451 -                       *(.fixup)
2452 -                       *(.gnu.warning)
2453 -                       *(.rodata)
2454 -                       *(.rodata.*)
2455 -                       *(.glue_7)
2456 -                       *(.glue_7t)
2457 -               *(.got)                 /* Global offset table          */
2458 -
2459 -               _etext = .;             /* End of text section          */
2460 -       }
2461 -
2462 -       . = ALIGN(16);
2463 -       __ex_table : {                  /* Exception table              */
2464 -               __start___ex_table = .;
2465 -                       *(__ex_table)
2466 -               __stop___ex_table = .;
2467 -       }
2468 -
2469 -       RODATA
2470 -
2471 -       .data : {
2472 -               /*
2473 -                * The cacheline aligned data
2474 -                */
2475 -               . = ALIGN(32);
2476 -               *(.data.cacheline_aligned)
2477 -
2478 -               /*
2479 -                * and the usual data section
2480 -                */
2481 -               *(.data)
2482 -               CONSTRUCTORS
2483 -
2484 -               _edata = .;
2485 -       }
2486 -
2487 -       .bss : {
2488 -               __bss_start = .;        /* BSS                          */
2489 -               *(.bss)
2490 -               *(COMMON)
2491 -               _end = . ;
2492 -       }
2493 -                                       /* Stabs debugging sections.    */
2494 -       .stab 0 : { *(.stab) }
2495 -       .stabstr 0 : { *(.stabstr) }
2496 -       .stab.excl 0 : { *(.stab.excl) }
2497 -       .stab.exclstr 0 : { *(.stab.exclstr) }
2498 -       .stab.index 0 : { *(.stab.index) }
2499 -       .stab.indexstr 0 : { *(.stab.indexstr) }
2500 -       .comment 0 : { *(.comment) }
2501 -}
2502 diff -Nru a/arch/arm/vmlinux-armv.lds.in b/arch/arm/vmlinux-armv.lds.in
2503 --- a/arch/arm/vmlinux-armv.lds.in      Wed Jun 18 16:33:31 2003
2504 +++ /dev/null   Wed Dec 31 16:00:00 1969
2505 @@ -1,134 +0,0 @@
2506 -/* ld script to make ARM Linux kernel
2507 - * taken from the i386 version by Russell King
2508 - * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
2509 - */
2510 -
2511 -#include <asm-generic/vmlinux.lds.h>
2512 -       
2513 -OUTPUT_ARCH(arm)
2514 -ENTRY(stext)
2515 -#ifndef __ARMEB__
2516 -jiffies = jiffies_64;
2517 -#else
2518 -jiffies = jiffies_64 + 4;
2519 -#endif
2520 -SECTIONS
2521 -{
2522 -       . = TEXTADDR;
2523 -       .init : {                       /* Init code and data           */
2524 -               _stext = .;
2525 -               __init_begin = .;
2526 -                       _sinittext = .;
2527 -                       *(.init.text)
2528 -                       _einittext = .;
2529 -               __proc_info_begin = .;
2530 -                       *(.proc.info)
2531 -               __proc_info_end = .;
2532 -               __arch_info_begin = .;
2533 -                       *(.arch.info)
2534 -               __arch_info_end = .;
2535 -               __tagtable_begin = .;
2536 -                       *(.taglist)
2537 -               __tagtable_end = .;
2538 -                       *(.init.data)
2539 -               . = ALIGN(16);
2540 -               __setup_start = .;
2541 -                       *(.init.setup)
2542 -               __setup_end = .;
2543 -               __early_begin = .;
2544 -                       *(__early_param)
2545 -               __early_end = .;
2546 -               __start___param = .;
2547 -                       *(__param)
2548 -               __stop___param = .;
2549 -               __initcall_start = .;
2550 -                       *(.initcall1.init)
2551 -                       *(.initcall2.init)
2552 -                       *(.initcall3.init)
2553 -                       *(.initcall4.init)
2554 -                       *(.initcall5.init)
2555 -                       *(.initcall6.init)
2556 -                       *(.initcall7.init)
2557 -               __initcall_end = .;
2558 -               __con_initcall_start = .;
2559 -                       *(.con_initcall.init)
2560 -               __con_initcall_end = .;
2561 -               __security_initcall_start = .;
2562 -                       *(.security_initcall.init)
2563 -               __security_initcall_end = .;
2564 -               . = ALIGN(32);
2565 -               __initramfs_start = .;
2566 -                       usr/built-in.o(.init.ramfs)
2567 -               __initramfs_end = .;
2568 -               . = ALIGN(4096);
2569 -               __init_end = .;
2570 -       }
2571 -
2572 -       /DISCARD/ : {                   /* Exit code and data           */
2573 -               *(.exit.text)
2574 -               *(.exit.data)
2575 -               *(.exitcall.exit)
2576 -       }
2577 -
2578 -       .text : {                       /* Real text segment            */
2579 -               _text = .;              /* Text and read-only data      */
2580 -                       *(.text)
2581 -                       *(.fixup)
2582 -                       *(.gnu.warning)
2583 -                       *(.rodata)
2584 -                       *(.rodata.*)
2585 -                       *(.glue_7)
2586 -                       *(.glue_7t)
2587 -               *(.got)                 /* Global offset table          */
2588 -
2589 -               _etext = .;             /* End of text section          */
2590 -       }
2591 -
2592 -       . = ALIGN(16);
2593 -       __ex_table : {                  /* Exception table              */
2594 -               __start___ex_table = .;
2595 -                       *(__ex_table)
2596 -               __stop___ex_table = .;
2597 -       }
2598 -
2599 -       RODATA
2600 -
2601 -       . = ALIGN(8192);
2602 -
2603 -       .data : {
2604 -               /*
2605 -                * first, the init task union, aligned
2606 -                * to an 8192 byte boundary.
2607 -                */
2608 -               *(.init.task)
2609 -
2610 -               /*
2611 -                * then the cacheline aligned data
2612 -                */
2613 -               . = ALIGN(32);
2614 -               *(.data.cacheline_aligned)
2615 -
2616 -               /*
2617 -                * and the usual data section
2618 -                */
2619 -               *(.data)
2620 -               CONSTRUCTORS
2621 -
2622 -               _edata = .;
2623 -       }
2624 -
2625 -       .bss : {
2626 -               __bss_start = .;        /* BSS                          */
2627 -               *(.bss)
2628 -               *(COMMON)
2629 -               _end = . ;
2630 -       }
2631 -                                       /* Stabs debugging sections.    */
2632 -       .stab 0 : { *(.stab) }
2633 -       .stabstr 0 : { *(.stabstr) }
2634 -       .stab.excl 0 : { *(.stab.excl) }
2635 -       .stab.exclstr 0 : { *(.stab.exclstr) }
2636 -       .stab.index 0 : { *(.stab.index) }
2637 -       .stab.indexstr 0 : { *(.stab.indexstr) }
2638 -       .comment 0 : { *(.comment) }
2639 -}
2640 diff -Nru a/arch/arm26/Kconfig b/arch/arm26/Kconfig
2641 --- a/arch/arm26/Kconfig        Sat Aug  2 14:26:16 2003
2642 +++ b/arch/arm26/Kconfig        Sun Aug 31 16:14:22 2003
2643 @@ -146,39 +146,6 @@
2644           You may say N here if you are going to load the Acorn FPEmulator
2645           early in the bootup.
2646  
2647 -choice
2648 -       prompt "Kernel core (/proc/kcore) format"
2649 -       default KCORE_ELF
2650 -
2651 -config KCORE_ELF
2652 -       bool "ELF"
2653 -       ---help---
2654 -         If you enabled support for /proc file system then the file
2655 -         /proc/kcore will contain the kernel core image. This can be used
2656 -         in gdb:
2657 -
2658 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
2659 -
2660 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
2661 -         /proc/kcore appear in ELF core format as defined by the Executable
2662 -         and Linking Format specification. Selecting A.OUT will choose the
2663 -         old "a.out" format which may be necessary for some old versions
2664 -         of binutils or on some architectures.
2665 -
2666 -         This is especially useful if you have compiled the kernel with the
2667 -         "-g" option to preserve debugging information. It is mainly used
2668 -         for examining kernel data structures on the live kernel so if you
2669 -         don't understand what this means or are not a kernel hacker, just
2670 -         leave it at its default value ELF.
2671 -
2672 -config KCORE_AOUT
2673 -       bool "A.OUT"
2674 -       help
2675 -         Not necessary unless you're using a very out-of-date binutils
2676 -         version.  You probably want KCORE_ELF.
2677 -
2678 -endchoice
2679 -
2680  source "fs/Kconfig.binfmt"
2681  
2682  config PREEMPT
2683 diff -Nru a/arch/arm26/kernel/setup.c b/arch/arm26/kernel/setup.c
2684 --- a/arch/arm26/kernel/setup.c Thu Jul  3 15:03:57 2003
2685 +++ b/arch/arm26/kernel/setup.c Sun Aug 31 16:14:08 2003
2686 @@ -304,12 +304,12 @@
2687  
2688  #if defined(CONFIG_DUMMY_CONSOLE)
2689  struct screen_info screen_info = {
2690 - orig_video_lines:     30,
2691 - orig_video_cols:      80,
2692 - orig_video_mode:      0,
2693 - orig_video_ega_bx:    0,
2694 - orig_video_isVGA:     1,
2695 - orig_video_points:    8
2696 + .orig_video_lines     = 30,
2697 + .orig_video_cols      = 80,
2698 + .orig_video_mode      = 0,
2699 + .orig_video_ega_bx    = 0,
2700 + .orig_video_isVGA     = 1,
2701 + .orig_video_points    = 8
2702  };
2703  
2704  static int __init parse_tag_videotext(const struct tag *tag)
2705 diff -Nru a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c
2706 --- a/arch/cris/arch-v10/drivers/eeprom.c       Fri Jul  4 03:27:37 2003
2707 +++ b/arch/cris/arch-v10/drivers/eeprom.c       Tue Aug 26 09:25:41 2003
2708 @@ -441,9 +441,9 @@
2709  static int eeprom_open(struct inode * inode, struct file * file)
2710  {
2711  
2712 -  if(minor(inode->i_rdev) != EEPROM_MINOR_NR)
2713 +  if(iminor(inode) != EEPROM_MINOR_NR)
2714       return -ENXIO;
2715 -  if(major(inode->i_rdev) != EEPROM_MAJOR_NR)
2716 +  if(imajor(inode) != EEPROM_MAJOR_NR)
2717       return -ENXIO;
2718  
2719    if( eeprom.size > 0 )
2720 diff -Nru a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
2721 --- a/arch/cris/arch-v10/drivers/gpio.c Fri Jul  4 03:27:37 2003
2722 +++ b/arch/cris/arch-v10/drivers/gpio.c Tue Aug 26 09:25:40 2003
2723 @@ -386,7 +386,7 @@
2724  gpio_open(struct inode *inode, struct file *filp)
2725  {
2726         struct gpio_private *priv;
2727 -       int p = minor(inode->i_rdev);
2728 +       int p = iminor(inode);
2729  
2730         if (p > GPIO_MINOR_LAST)
2731                 return -EINVAL;
2732 diff -Nru a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
2733 --- a/arch/cris/arch-v10/drivers/pcf8563.c      Wed Jul 23 07:38:45 2003
2734 +++ b/arch/cris/arch-v10/drivers/pcf8563.c      Sun Aug 31 16:14:08 2003
2735 @@ -57,10 +57,10 @@
2736  int pcf8563_release(struct inode *, struct file *);
2737  
2738  static struct file_operations pcf8563_fops = {
2739 -       owner: THIS_MODULE,
2740 -       ioctl: pcf8563_ioctl,
2741 -       open: pcf8563_open,
2742 -       release: pcf8563_release,
2743 +       .owner = THIS_MODULE,
2744 +       .ioctl = pcf8563_ioctl,
2745 +       .open = pcf8563_open,
2746 +       .release = pcf8563_release,
2747  };
2748  
2749  unsigned char
2750 diff -Nru a/arch/h8300/Kconfig b/arch/h8300/Kconfig
2751 --- a/arch/h8300/Kconfig        Thu Aug 21 08:42:22 2003
2752 +++ b/arch/h8300/Kconfig        Sun Aug 31 16:14:22 2003
2753 @@ -177,13 +177,6 @@
2754  
2755  menu "Executable file formats"
2756  
2757 -config KCORE_AOUT
2758 -       bool
2759 -       default y
2760 -
2761 -config KCORE_ELF
2762 -       default y
2763 -
2764  source "fs/Kconfig.binfmt"
2765  
2766  endmenu
2767 diff -Nru a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
2768 --- a/arch/h8300/kernel/setup.c Sun Jul 27 20:40:08 2003
2769 +++ b/arch/h8300/kernel/setup.c Sun Aug 31 16:14:08 2003
2770 @@ -91,12 +91,12 @@
2771  }
2772  
2773  static const struct console gdb_console = {
2774 -       name:           "gdb_con",
2775 -       write:          gdb_console_output,
2776 -       device:         NULL,
2777 -       setup:          gdb_console_setup,
2778 -       flags:          CON_PRINTBUFFER,
2779 -       index:          -1,
2780 +       .name           = "gdb_con",
2781 +       .write          = gdb_console_output,
2782 +       .device         = NULL,
2783 +       .setup          = gdb_console_setup,
2784 +       .flags          = CON_PRINTBUFFER,
2785 +       .index          = -1,
2786  };
2787  #endif
2788  
2789 @@ -260,8 +260,8 @@
2790  }
2791  
2792  struct seq_operations cpuinfo_op = {
2793 -       start:  c_start,
2794 -       next:   c_next,
2795 -       stop:   c_stop,
2796 -       show:   show_cpuinfo,
2797 +       .start  = c_start,
2798 +       .next   = c_next,
2799 +       .stop   = c_stop,
2800 +       .show   = show_cpuinfo,
2801  };
2802 diff -Nru a/arch/h8300/platform/h8300h/ints.c b/arch/h8300/platform/h8300h/ints.c
2803 --- a/arch/h8300/platform/h8300h/ints.c Thu Aug 21 08:42:22 2003
2804 +++ b/arch/h8300/platform/h8300h/ints.c Wed Aug 27 08:10:22 2003
2805 @@ -32,15 +32,6 @@
2806  #include <asm/regs306x.h>
2807  #include <asm/errno.h>
2808  
2809 -#define EXT_IRQ0 12
2810 -#define EXT_IRQ1 13
2811 -#define EXT_IRQ2 14
2812 -#define EXT_IRQ3 15
2813 -#define EXT_IRQ4 16
2814 -#define EXT_IRQ5 17
2815 -#define EXT_IRQ6 18
2816 -#define EXT_IRQ7 19
2817 -
2818  /*
2819   * This structure has only 4 elements for speed reasons
2820   */
2821 @@ -57,17 +48,20 @@
2822  
2823  extern unsigned long *interrupt_redirect_table;
2824  
2825 +#define CPU_VECTOR ((unsigned long *)0x000000)
2826 +#define ADDR_MASK (0xffffff)
2827 +
2828  static inline unsigned long *get_vector_address(void)
2829  {
2830 -       unsigned long *rom_vector = (unsigned long *)0x000000;
2831 +       unsigned long *rom_vector = CPU_VECTOR;
2832         unsigned long base,tmp;
2833         int vec_no;
2834  
2835 -       base = rom_vector[EXT_IRQ0];
2836 +       base = rom_vector[EXT_IRQ0] & ADDR_MASK;
2837         
2838         /* check romvector format */
2839         for (vec_no = EXT_IRQ1; vec_no <= EXT_IRQ5; vec_no++) {
2840 -               if ((base+(vec_no - EXT_IRQ0)*4) != rom_vector[vec_no])
2841 +               if ((base+(vec_no - EXT_IRQ0)*4) != (rom_vector[vec_no] & ADDR_MASK))
2842                         return NULL;
2843         }
2844  
2845 @@ -171,7 +165,7 @@
2846                        irq, irq_list[irq]->devname);
2847         if (irq >= EXT_IRQ0 && irq <= EXT_IRQ5)
2848                 *(volatile unsigned char *)IER &= ~(1 << (irq - EXT_IRQ0));
2849 -       if ((irq_list[irq] & 0x80000000) == 0) {
2850 +       if (((unsigned long)irq_list[irq] & 0x80000000) == 0) {
2851                 kfree(irq_list[irq]);
2852                 irq_list[irq] = NULL;
2853         }
2854 @@ -241,8 +235,9 @@
2855  {
2856  }
2857  
2858 -static void __init enable_kmalloc(void)
2859 +static int __init enable_kmalloc(void)
2860  {
2861         use_kmalloc = 1;
2862 +       return 0;
2863  }
2864 -__initcall(enable_kmalloc);
2865 +core_initcall(enable_kmalloc);
2866 diff -Nru a/arch/h8300/platform/h8s/ints.c b/arch/h8300/platform/h8s/ints.c
2867 --- a/arch/h8300/platform/h8s/ints.c    Thu Aug 21 08:42:22 2003
2868 +++ b/arch/h8300/platform/h8s/ints.c    Wed Aug 27 08:10:22 2003
2869 @@ -33,23 +33,6 @@
2870  #include <asm/regs267x.h>
2871  #include <asm/errno.h>
2872  
2873 -#define EXT_IRQ0 16
2874 -#define EXT_IRQ1 17
2875 -#define EXT_IRQ2 18
2876 -#define EXT_IRQ3 19
2877 -#define EXT_IRQ4 20
2878 -#define EXT_IRQ5 21
2879 -#define EXT_IRQ6 22
2880 -#define EXT_IRQ7 23
2881 -#define EXT_IRQ8 24
2882 -#define EXT_IRQ9 25
2883 -#define EXT_IRQ10 26
2884 -#define EXT_IRQ11 27
2885 -#define EXT_IRQ12 28
2886 -#define EXT_IRQ13 29
2887 -#define EXT_IRQ14 30
2888 -#define EXT_IRQ15 31
2889 -
2890  /*
2891   * This structure has only 4 elements for speed reasons
2892   */
2893 @@ -95,17 +78,20 @@
2894  
2895  extern unsigned long *interrupt_redirect_table;
2896  
2897 +#define CPU_VECTOR ((unsigned long *)0x000000)
2898 +#define ADDR_MASK (0xffffff)
2899 +
2900  static inline unsigned long *get_vector_address(void)
2901  {
2902 -       volatile unsigned long *rom_vector = (unsigned long *)0x000000;
2903 +       volatile unsigned long *rom_vector = CPU_VECTOR;
2904         unsigned long base,tmp;
2905         int vec_no;
2906  
2907 -       base = rom_vector[EXT_IRQ0];
2908 +       base = rom_vector[EXT_IRQ0] & ADDR_MASK;
2909         
2910         /* check romvector format */
2911         for (vec_no = EXT_IRQ1; vec_no <= EXT_IRQ15; vec_no++) {
2912 -               if ((base+(vec_no - EXT_IRQ0)*4) != rom_vector[vec_no])
2913 +               if ((base+(vec_no - EXT_IRQ0)*4) != (rom_vector[vec_no] & ADDR_MASK))
2914                         return NULL;
2915         }
2916  
2917 @@ -307,4 +293,4 @@
2918         use_kmalloc = 1;
2919         return 0;
2920  }
2921 -__initcall(enable_kmalloc);
2922 +core_initcall(enable_kmalloc);
2923 diff -Nru a/arch/i386/Kconfig b/arch/i386/Kconfig
2924 --- a/arch/i386/Kconfig Wed Aug 20 12:16:36 2003
2925 +++ b/arch/i386/Kconfig Sun Aug 31 16:15:07 2003
2926 @@ -408,6 +408,17 @@
2927  
2928           Otherwise, say N.
2929  
2930 +config HPET_TIMER
2931 +       bool "HPET Timer Support"
2932 +       help
2933 +         This enables the use of the HPET for the kernel's internal timer.
2934 +         HPET is the next generation timer replacing legacy 8254s.
2935 +         You can safely choose Y here.  However, HPET will only be
2936 +         activated if the platform and the BIOS support this feature.
2937 +         Otherwise the 8254 will be used for timing services.
2938 +
2939 +         Choose N to continue using the legacy 8254 timer.
2940 +
2941  config SMP
2942         bool "Symmetric multi-processing support"
2943         ---help---
2944 @@ -1155,40 +1166,6 @@
2945  
2946  
2947  menu "Executable file formats"
2948 -
2949 -choice
2950 -       prompt "Kernel core (/proc/kcore) format"
2951 -       depends on PROC_FS
2952 -       default KCORE_ELF
2953 -
2954 -config KCORE_ELF
2955 -       bool "ELF"
2956 -       ---help---
2957 -         If you enabled support for /proc file system then the file
2958 -         /proc/kcore will contain the kernel core image. This can be used
2959 -         in gdb:
2960 -
2961 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
2962 -
2963 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
2964 -         /proc/kcore appear in ELF core format as defined by the Executable
2965 -         and Linking Format specification. Selecting A.OUT will choose the
2966 -         old "a.out" format which may be necessary for some old versions
2967 -         of binutils or on some architectures.
2968 -
2969 -         This is especially useful if you have compiled the kernel with the
2970 -         "-g" option to preserve debugging information. It is mainly used
2971 -         for examining kernel data structures on the live kernel so if you
2972 -         don't understand what this means or are not a kernel hacker, just
2973 -         leave it at its default value ELF.
2974 -
2975 -config KCORE_AOUT
2976 -       bool "A.OUT"
2977 -       help
2978 -         Not necessary unless you're using a very out-of-date binutils
2979 -         version.  You probably want KCORE_ELF.
2980 -
2981 -endchoice
2982  
2983  source "fs/Kconfig.binfmt"
2984  
2985 diff -Nru a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
2986 --- a/arch/i386/kernel/Makefile Mon Aug 18 11:16:59 2003
2987 +++ b/arch/i386/kernel/Makefile Sun Aug 31 16:14:50 2003
2988 @@ -31,6 +31,7 @@
2989  obj-$(CONFIG_MODULES)          += module.o
2990  obj-y                          += sysenter.o vsyscall.o
2991  obj-$(CONFIG_ACPI_SRAT)        += srat.o
2992 +obj-$(CONFIG_HPET_TIMER)       += time_hpet.o
2993  
2994  EXTRA_AFLAGS   := -traditional
2995  
2996 diff -Nru a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
2997 --- a/arch/i386/kernel/acpi/boot.c      Thu Aug 21 11:08:59 2003
2998 +++ b/arch/i386/kernel/acpi/boot.c      Sun Aug 31 16:14:49 2003
2999 @@ -41,6 +41,7 @@
3000  #define PREFIX                 "ACPI: "
3001  
3002  extern int acpi_disabled;
3003 +extern int acpi_irq;
3004  extern int acpi_ht;
3005  
3006  int acpi_lapic = 0;
3007 @@ -269,6 +270,27 @@
3008         return 0;
3009  }
3010  
3011 +#ifdef CONFIG_HPET_TIMER
3012 +extern unsigned long hpet_address;
3013 +
3014 +static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
3015 +{
3016 +       struct acpi_table_hpet *hpet_tbl;
3017 +
3018 +       hpet_tbl = __va(phys);
3019 +
3020 +       if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
3021 +               printk(KERN_WARNING PREFIX "HPET timers must be located in "
3022 +                      "memory.\n");
3023 +               return -1;
3024 +       }
3025 +
3026 +       hpet_address = hpet_tbl->addr.addrl;
3027 +       printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", hpet_tbl->id,
3028 +              hpet_address);
3029 +       return 0;
3030 +}
3031 +#endif
3032  
3033  unsigned long __init
3034  acpi_find_rsdp (void)
3035 @@ -407,7 +429,7 @@
3036          * If MPS is present, it will handle them,
3037          * otherwise the system will stay in PIC mode
3038          */
3039 -       if (acpi_disabled) {
3040 +       if (acpi_disabled || !acpi_irq) {
3041                 return 1;
3042          }
3043  
3044 @@ -457,6 +479,9 @@
3045                 smp_found_config = 1;
3046                 clustered_apic_check();
3047         }
3048 +#endif
3049 +#ifdef CONFIG_HPET_TIMER
3050 +       acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
3051  #endif
3052  
3053         return 0;
3054 diff -Nru a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
3055 --- a/arch/i386/kernel/apic.c   Mon Aug 18 22:27:07 2003
3056 +++ b/arch/i386/kernel/apic.c   Fri Aug 29 03:51:17 2003
3057 @@ -34,6 +34,7 @@
3058  #include <asm/pgalloc.h>
3059  #include <asm/desc.h>
3060  #include <asm/arch_hooks.h>
3061 +#include <asm/hpet.h>
3062  
3063  #include <mach_apic.h>
3064  
3065 @@ -779,7 +780,8 @@
3066         return count;
3067  }
3068  
3069 -void __init wait_8254_wraparound(void)
3070 +/* next tick in 8254 can be caught by catching timer wraparound */
3071 +static void __init wait_8254_wraparound(void)
3072  {
3073         unsigned int curr_count, prev_count=~0;
3074         int delta;
3075 @@ -801,6 +803,12 @@
3076  }
3077  
3078  /*
3079 + * Default initialization for 8254 timers. If we use other timers like HPET,
3080 + * we override this later
3081 + */
3082 +void (*wait_timer_tick)(void) = wait_8254_wraparound;
3083 +
3084 +/*
3085   * This function sets up the local APIC timer, with a timeout of
3086   * 'clocks' APIC bus clock. During calibration we actually call
3087   * this function twice on the boot CPU, once with a bogus timeout
3088 @@ -841,7 +849,7 @@
3089         /*
3090          * Wait for IRQ0's slice:
3091          */
3092 -       wait_8254_wraparound();
3093 +       wait_timer_tick();
3094  
3095         __setup_APIC_LVTT(clocks);
3096  
3097 @@ -884,7 +892,7 @@
3098          * (the current tick might have been already half done)
3099          */
3100  
3101 -       wait_8254_wraparound();
3102 +       wait_timer_tick();
3103  
3104         /*
3105          * We wrapped around just now. Let's start:
3106 @@ -897,7 +905,7 @@
3107          * Let's wait LOOPS wraprounds:
3108          */
3109         for (i = 0; i < LOOPS; i++)
3110 -               wait_8254_wraparound();
3111 +               wait_timer_tick();
3112  
3113         tt2 = apic_read(APIC_TMCCT);
3114         if (cpu_has_tsc)
3115 diff -Nru a/arch/i386/kernel/cpu/mtrr/if.c b/arch/i386/kernel/cpu/mtrr/if.c
3116 --- a/arch/i386/kernel/cpu/mtrr/if.c    Wed May 14 23:43:54 2003
3117 +++ b/arch/i386/kernel/cpu/mtrr/if.c    Sun Aug 31 16:14:43 2003
3118 @@ -17,6 +17,22 @@
3119  
3120  #define FILE_FCOUNT(f) (((struct seq_file *)((f)->private_data))->private)
3121  
3122 +static char *mtrr_strings[MTRR_NUM_TYPES] =
3123 +{
3124 +    "uncachable",               /* 0 */
3125 +    "write-combining",          /* 1 */
3126 +    "?",                        /* 2 */
3127 +    "?",                        /* 3 */
3128 +    "write-through",            /* 4 */
3129 +    "write-protect",            /* 5 */
3130 +    "write-back",               /* 6 */
3131 +};
3132 +
3133 +char *mtrr_attrib_to_str(int x)
3134 +{
3135 +       return (x <= 6) ? mtrr_strings[x] : "?";
3136 +}
3137 +
3138  static int
3139  mtrr_file_add(unsigned long base, unsigned long size,
3140               unsigned int type, char increment, struct file *file, int page)
3141 @@ -300,11 +316,6 @@
3142  
3143  #  endif                       /*  CONFIG_PROC_FS  */
3144  
3145 -char * attrib_to_str(int x)
3146 -{
3147 -       return (x <= 6) ? mtrr_strings[x] : "?";
3148 -}
3149 -
3150  static int mtrr_seq_show(struct seq_file *seq, void *offset)
3151  {
3152         char factor;
3153 @@ -332,7 +343,7 @@
3154                         len += seq_printf(seq, 
3155                                    "reg%02i: base=0x%05lx000 (%4liMB), size=%4i%cB: %s, count=%d\n",
3156                              i, base, base >> (20 - PAGE_SHIFT), size, factor,
3157 -                            attrib_to_str(type), usage_table[i]);
3158 +                            mtrr_attrib_to_str(type), usage_table[i]);
3159                 }
3160         }
3161         return 0;
3162 diff -Nru a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
3163 --- a/arch/i386/kernel/cpu/mtrr/main.c  Thu Aug 21 11:48:14 2003
3164 +++ b/arch/i386/kernel/cpu/mtrr/main.c  Sun Aug 31 16:14:43 2003
3165 @@ -111,11 +111,6 @@
3166         num_var_ranges = config & 0xff;
3167  }
3168  
3169 -static char * attrib_to_str(int x)
3170 -{
3171 -       return (x <= 6) ? mtrr_strings[x] : "?";
3172 -}
3173 -
3174  static void init_table(void)
3175  {
3176         int i, max;
3177 @@ -362,8 +357,8 @@
3178                         if (type == MTRR_TYPE_UNCACHABLE)
3179                                 continue;
3180                         printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
3181 -                            base, size, attrib_to_str(ltype),
3182 -                            attrib_to_str(type));
3183 +                            base, size, mtrr_attrib_to_str(ltype),
3184 +                            mtrr_attrib_to_str(type));
3185                         goto out;
3186                 }
3187                 if (increment)
3188 @@ -703,16 +698,4 @@
3189         return -ENXIO;
3190  }
3191  
3192 -char *mtrr_strings[MTRR_NUM_TYPES] =
3193 -{
3194 -    "uncachable",               /* 0 */
3195 -    "write-combining",          /* 1 */
3196 -    "?",                        /* 2 */
3197 -    "?",                        /* 3 */
3198 -    "write-through",            /* 4 */
3199 -    "write-protect",            /* 5 */
3200 -    "write-back",               /* 6 */
3201 -};
3202 -
3203  subsys_initcall(mtrr_init);
3204 -
3205 diff -Nru a/arch/i386/kernel/cpu/mtrr/mtrr.h b/arch/i386/kernel/cpu/mtrr/mtrr.h
3206 --- a/arch/i386/kernel/cpu/mtrr/mtrr.h  Wed Nov 27 22:37:22 2002
3207 +++ b/arch/i386/kernel/cpu/mtrr/mtrr.h  Sun Aug 31 16:14:43 2003
3208 @@ -95,5 +95,6 @@
3209  
3210  void finalize_mtrr_state(void);
3211  void mtrr_state_warn(void);
3212 +char *mtrr_attrib_to_str(int x);
3213  
3214  extern char * mtrr_if_name[];
3215 diff -Nru a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
3216 --- a/arch/i386/kernel/cpuid.c  Mon Aug 18 19:46:23 2003
3217 +++ b/arch/i386/kernel/cpuid.c  Tue Aug 26 09:25:40 2003
3218 @@ -115,7 +115,7 @@
3219    u32 data[4];
3220    size_t rv;
3221    u32 reg = *ppos;
3222 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
3223 +  int cpu = iminor(file->f_dentry->d_inode);
3224    
3225    if ( count % 16 )
3226      return -EINVAL; /* Invalid chunk size */
3227 @@ -133,7 +133,7 @@
3228  
3229  static int cpuid_open(struct inode *inode, struct file *file)
3230  {
3231 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
3232 +  int cpu = iminor(file->f_dentry->d_inode);
3233    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
3234  
3235    if (!cpu_online(cpu))
3236 diff -Nru a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
3237 --- a/arch/i386/kernel/mpparse.c        Tue Aug 19 21:21:36 2003
3238 +++ b/arch/i386/kernel/mpparse.c        Sun Aug 31 16:14:25 2003
3239 @@ -850,7 +850,7 @@
3240                         return i;
3241         }
3242  
3243 -       printk(KERN_ERR "ERROR: Unable to locate IOAPIC for IRQ %d/n", irq);
3244 +       printk(KERN_ERR "ERROR: Unable to locate IOAPIC for IRQ %d\n", irq);
3245  
3246         return -1;
3247  }
3248 diff -Nru a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
3249 --- a/arch/i386/kernel/msr.c    Mon Aug 18 19:46:23 2003
3250 +++ b/arch/i386/kernel/msr.c    Tue Aug 26 09:25:40 2003
3251 @@ -194,7 +194,7 @@
3252    u32 data[2];
3253    size_t rv;
3254    u32 reg = *ppos;
3255 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
3256 +  int cpu = iminor(file->f_dentry->d_inode);
3257    int err;
3258  
3259    if ( count % 8 )
3260 @@ -219,7 +219,7 @@
3261    u32 data[2];
3262    size_t rv;
3263    u32 reg = *ppos;
3264 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
3265 +  int cpu = iminor(file->f_dentry->d_inode);
3266    int err;
3267  
3268    if ( count % 8 )
3269 @@ -239,7 +239,7 @@
3270  
3271  static int msr_open(struct inode *inode, struct file *file)
3272  {
3273 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
3274 +  int cpu = iminor(file->f_dentry->d_inode);
3275    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
3276    
3277    if (!cpu_online(cpu))
3278 diff -Nru a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
3279 --- a/arch/i386/kernel/process.c        Wed Aug 20 10:43:52 2003
3280 +++ b/arch/i386/kernel/process.c        Tue Sep  2 00:37:21 2003
3281 @@ -452,7 +452,7 @@
3282  
3283         /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
3284  
3285 -       unlazy_fpu(prev_p);
3286 +       __unlazy_fpu(prev_p);
3287  
3288         /*
3289          * Reload esp0, LDT and the page table pointer:
3290 diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
3291 --- a/arch/i386/kernel/setup.c  Thu Aug 21 11:08:59 2003
3292 +++ b/arch/i386/kernel/setup.c  Sun Aug 31 16:14:11 2003
3293 @@ -71,6 +71,7 @@
3294  EXPORT_SYMBOL(acpi_disabled);
3295  
3296  #ifdef CONFIG_ACPI_BOOT
3297 +       int acpi_irq __initdata = 1;    /* enable IRQ */
3298         int acpi_ht __initdata = 1;     /* enable HT */
3299  #endif
3300  
3301 @@ -542,6 +543,11 @@
3302                 else if (!memcmp(from, "acpi=ht", 7)) {
3303                         acpi_ht = 1;
3304                         if (!acpi_force) acpi_disabled = 1;
3305 +               }
3306 +
3307 +               /* "pci=noacpi" disables ACPI interrupt routing */
3308 +               else if (!memcmp(from, "pci=noacpi", 10)) {
3309 +                       acpi_irq = 0;
3310                 }
3311  
3312  #ifdef CONFIG_X86_LOCAL_APIC
3313 diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
3314 --- a/arch/i386/kernel/time.c   Thu Jul 10 22:22:57 2003
3315 +++ b/arch/i386/kernel/time.c   Fri Aug 29 03:51:17 2003
3316 @@ -60,6 +60,8 @@
3317  #include <linux/timex.h>
3318  #include <linux/config.h>
3319  
3320 +#include <asm/hpet.h>
3321 +
3322  #include <asm/arch_hooks.h>
3323  
3324  #include "io_ports.h"
3325 @@ -291,8 +293,38 @@
3326  
3327  device_initcall(time_init_device);
3328  
3329 +#ifdef CONFIG_HPET_TIMER
3330 +extern void (*late_time_init)(void);
3331 +/* Duplicate of time_init() below, with hpet_enable part added */
3332 +void __init hpet_time_init(void)
3333 +{
3334 +       xtime.tv_sec = get_cmos_time();
3335 +       wall_to_monotonic.tv_sec = -xtime.tv_sec;
3336 +       xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
3337 +       wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
3338 +
3339 +       if (hpet_enable() >= 0) {
3340 +               printk("Using HPET for base-timer\n");
3341 +       }
3342 +
3343 +       cur_timer = select_timer();
3344 +       time_init_hook();
3345 +}
3346 +#endif
3347 +
3348  void __init time_init(void)
3349  {
3350 +#ifdef CONFIG_HPET_TIMER
3351 +       if (is_hpet_capable()) {
3352 +               /*
3353 +                * HPET initialization needs to do memory-mapped io. So, let
3354 +                * us do a late initialization after mem_init().
3355 +                */
3356 +               late_time_init = hpet_time_init;
3357 +               return;
3358 +       }
3359 +#endif
3360 +
3361         xtime.tv_sec = get_cmos_time();
3362         wall_to_monotonic.tv_sec = -xtime.tv_sec;
3363         xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
3364 diff -Nru a/arch/i386/kernel/time_hpet.c b/arch/i386/kernel/time_hpet.c
3365 --- /dev/null   Wed Dec 31 16:00:00 1969
3366 +++ b/arch/i386/kernel/time_hpet.c      Sun Aug 31 16:15:40 2003
3367 @@ -0,0 +1,392 @@
3368 +/*
3369 + *  linux/arch/i386/kernel/time_hpet.c
3370 + *  This code largely copied from arch/x86_64/kernel/time.c
3371 + *  See that file for credits.
3372 + *
3373 + *  2003-06-30    Venkatesh Pallipadi - Additional changes for HPET support
3374 + */
3375 +
3376 +#include <linux/errno.h>
3377 +#include <linux/kernel.h>
3378 +#include <linux/param.h>
3379 +#include <linux/string.h>
3380 +#include <linux/init.h>
3381 +#include <linux/smp.h>
3382 +
3383 +#include <asm/timer.h>
3384 +#include <asm/fixmap.h>
3385 +#include <asm/apic.h>
3386 +
3387 +#include <linux/timex.h>
3388 +#include <linux/config.h>
3389 +
3390 +#include <asm/hpet.h>
3391 +
3392 +unsigned long hpet_period;     /* fsecs / HPET clock */
3393 +unsigned long hpet_tick;       /* hpet clks count per tick */
3394 +unsigned long hpet_address;    /* hpet memory map physical address */
3395 +
3396 +static int use_hpet;           /* can be used for runtime check of hpet */
3397 +static int boot_hpet_disable;  /* boottime override for HPET timer */
3398 +static unsigned long hpet_virt_address;        /* hpet kernel virtual address */
3399 +
3400 +#define FSEC_TO_USEC (1000000000UL)
3401 +
3402 +int hpet_readl(unsigned long a)
3403 +{
3404 +       return readl(hpet_virt_address + a);
3405 +}
3406 +
3407 +void hpet_writel(unsigned long d, unsigned long a)
3408 +{
3409 +       writel(d, hpet_virt_address + a);
3410 +}
3411 +
3412 +#ifdef CONFIG_X86_LOCAL_APIC
3413 +/*
3414 + * HPET counters dont wrap around on every tick. They just change the
3415 + * comparator value and continue. Next tick can be caught by checking
3416 + * for a change in the comparator value. Used in apic.c.
3417 + */
3418 +void __init wait_hpet_tick(void)
3419 +{
3420 +       unsigned int start_cmp_val, end_cmp_val;
3421 +
3422 +       start_cmp_val = hpet_readl(HPET_T0_CMP);
3423 +       do {
3424 +               end_cmp_val = hpet_readl(HPET_T0_CMP);
3425 +       } while (start_cmp_val == end_cmp_val);
3426 +}
3427 +#endif
3428 +
3429 +/*
3430 + * Check whether HPET was found by ACPI boot parse. If yes setup HPET
3431 + * counter 0 for kernel base timer.
3432 + */
3433 +int __init hpet_enable(void)
3434 +{
3435 +       unsigned int cfg, id;
3436 +       unsigned long tick_fsec_low, tick_fsec_high; /* tick in femto sec */
3437 +       unsigned long hpet_tick_rem;
3438 +
3439 +       if (boot_hpet_disable)
3440 +               return -1;
3441 +
3442 +       if (!hpet_address) {
3443 +               return -1;
3444 +       }
3445 +       hpet_virt_address = (unsigned long) ioremap_nocache(hpet_address,
3446 +                                                           HPET_MMAP_SIZE);
3447 +       /*
3448 +        * Read the period, compute tick and quotient.
3449 +        */
3450 +       id = hpet_readl(HPET_ID);
3451 +
3452 +       /*
3453 +        * We are checking for value '1' or more in number field.
3454 +        * So, we are OK with HPET_EMULATE_RTC part too, where we need
3455 +        * to have atleast 2 timers.
3456 +        */
3457 +       if (!(id & HPET_ID_NUMBER) ||
3458 +           !(id & HPET_ID_LEGSUP))
3459 +               return -1;
3460 +
3461 +       if (((id & HPET_ID_VENDOR) >> HPET_ID_VENDOR_SHIFT) !=
3462 +                               HPET_ID_VENDOR_8086)
3463 +               return -1;
3464 +
3465 +       hpet_period = hpet_readl(HPET_PERIOD);
3466 +       if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD))
3467 +               return -1;
3468 +
3469 +       /*
3470 +        * 64 bit math
3471 +        * First changing tick into fsec
3472 +        * Then 64 bit div to find number of hpet clk per tick
3473 +        */
3474 +       ASM_MUL64_REG(tick_fsec_low, tick_fsec_high,
3475 +                       KERNEL_TICK_USEC, FSEC_TO_USEC);
3476 +       ASM_DIV64_REG(hpet_tick, hpet_tick_rem,
3477 +                       hpet_period, tick_fsec_low, tick_fsec_high);
3478 +
3479 +       if (hpet_tick_rem > (hpet_period >> 1))
3480 +               hpet_tick++; /* rounding the result */
3481 +
3482 +       /*
3483 +        * Stop the timers and reset the main counter.
3484 +        */
3485 +       cfg = hpet_readl(HPET_CFG);
3486 +       cfg &= ~HPET_CFG_ENABLE;
3487 +       hpet_writel(cfg, HPET_CFG);
3488 +       hpet_writel(0, HPET_COUNTER);
3489 +       hpet_writel(0, HPET_COUNTER + 4);
3490 +
3491 +       /*
3492 +        * Set up timer 0, as periodic with first interrupt to happen at
3493 +        * hpet_tick, and period also hpet_tick.
3494 +        */
3495 +       cfg = hpet_readl(HPET_T0_CFG);
3496 +       cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
3497 +              HPET_TN_SETVAL | HPET_TN_32BIT;
3498 +       hpet_writel(cfg, HPET_T0_CFG);
3499 +       hpet_writel(hpet_tick, HPET_T0_CMP);
3500 +
3501 +       /*
3502 +        * Go!
3503 +        */
3504 +       cfg = hpet_readl(HPET_CFG);
3505 +       cfg |= HPET_CFG_ENABLE | HPET_CFG_LEGACY;
3506 +       hpet_writel(cfg, HPET_CFG);
3507 +
3508 +       use_hpet = 1;
3509 +#ifdef CONFIG_X86_LOCAL_APIC
3510 +       wait_timer_tick = wait_hpet_tick;
3511 +#endif
3512 +       return 0;
3513 +}
3514 +
3515 +int is_hpet_enabled(void)
3516 +{
3517 +       return use_hpet;
3518 +}
3519 +
3520 +int is_hpet_capable(void)
3521 +{
3522 +       if (!boot_hpet_disable && hpet_address)
3523 +               return 1;
3524 +       return 0;
3525 +}
3526 +
3527 +static int __init hpet_setup(char* str)
3528 +{
3529 +       if (str) {
3530 +               if (!strncmp("disable", str, 7))
3531 +                       boot_hpet_disable = 1;
3532 +       }
3533 +       return 1;
3534 +}
3535 +
3536 +__setup("hpet=", hpet_setup);
3537 +
3538 +#ifdef CONFIG_HPET_EMULATE_RTC
3539 +/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
3540 + * is enabled, we support RTC interrupt functionality in software.
3541 + * RTC has 3 kinds of interrupts:
3542 + * 1) Update Interrupt - generate an interrupt, every sec, when RTC clock
3543 + *    is updated
3544 + * 2) Alarm Interrupt - generate an interrupt at a specific time of day
3545 + * 3) Periodic Interrupt - generate periodic interrupt, with frequencies
3546 + *    2Hz-8192Hz (2Hz-64Hz for non-root user) (all freqs in powers of 2)
3547 + * (1) and (2) above are implemented using polling at a frequency of
3548 + * 64 Hz. The exact frequency is a tradeoff between accuracy and interrupt
3549 + * overhead. (DEFAULT_RTC_INT_FREQ)
3550 + * For (3), we use interrupts at 64Hz or user specified periodic
3551 + * frequency, whichever is higher.
3552 + */
3553 +#include <linux/mc146818rtc.h>
3554 +#include <linux/rtc.h>
3555 +
3556 +extern irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
3557 +extern void get_rtc_time(struct rtc_time *rtc_tm);
3558 +
3559 +#define DEFAULT_RTC_INT_FREQ   64
3560 +#define RTC_NUM_INTS           1
3561 +
3562 +static unsigned long UIE_on;
3563 +static unsigned long prev_update_sec;
3564 +
3565 +static unsigned long AIE_on;
3566 +static struct rtc_time alarm_time;
3567 +
3568 +static unsigned long PIE_on;
3569 +static unsigned long PIE_freq = DEFAULT_RTC_INT_FREQ;
3570 +static unsigned long PIE_count;
3571 +
3572 +static unsigned long hpet_rtc_int_freq; /* RTC interrupt frequency */
3573 +
3574 +/*
3575 + * Timer 1 for RTC, we do not use periodic interrupt feature,
3576 + * even if HPET supports periodic interrupts on Timer 1.
3577 + * The reason being, to set up a periodic interrupt in HPET, we need to
3578 + * stop the main counter. And if we do that everytime someone diables/enables
3579 + * RTC, we will have adverse effect on main kernel timer running on Timer 0.
3580 + * So, for the time being, simulate the periodic interrupt in software.
3581 + *
3582 + * hpet_rtc_timer_init() is called for the first time and during subsequent
3583 + * interuppts reinit happens through hpet_rtc_timer_reinit().
3584 + */
3585 +int hpet_rtc_timer_init(void)
3586 +{
3587 +       unsigned int cfg, cnt;
3588 +       unsigned long flags;
3589 +
3590 +       if (!is_hpet_enabled())
3591 +               return 0;
3592 +       /*
3593 +        * Set the counter 1 and enable the interrupts.
3594 +        */
3595 +       if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
3596 +               hpet_rtc_int_freq = PIE_freq;
3597 +       else
3598 +               hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
3599 +
3600 +       local_irq_save(flags);
3601 +       cnt = hpet_readl(HPET_COUNTER);
3602 +       cnt += ((hpet_tick*HZ)/hpet_rtc_int_freq);
3603 +       hpet_writel(cnt, HPET_T1_CMP);
3604 +       local_irq_restore(flags);
3605 +
3606 +       cfg = hpet_readl(HPET_T1_CFG);
3607 +       cfg |= HPET_TN_ENABLE | HPET_TN_SETVAL | HPET_TN_32BIT;
3608 +       hpet_writel(cfg, HPET_T1_CFG);
3609 +
3610 +       return 1;
3611 +}
3612 +
3613 +static void hpet_rtc_timer_reinit(void)
3614 +{
3615 +       unsigned int cfg, cnt;
3616 +
3617 +       if (!(PIE_on | AIE_on | UIE_on))
3618 +               return;
3619 +
3620 +       if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
3621 +               hpet_rtc_int_freq = PIE_freq;
3622 +       else
3623 +               hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
3624 +
3625 +       /* It is more accurate to use the comparator value than current count.*/
3626 +       cnt = hpet_readl(HPET_T1_CMP);
3627 +       cnt += hpet_tick*HZ/hpet_rtc_int_freq;
3628 +       hpet_writel(cnt, HPET_T1_CMP);
3629 +
3630 +       cfg = hpet_readl(HPET_T1_CFG);
3631 +       cfg |= HPET_TN_ENABLE | HPET_TN_SETVAL | HPET_TN_32BIT;
3632 +       hpet_writel(cfg, HPET_T1_CFG);
3633 +
3634 +       return;
3635 +}
3636 +
3637 +/*
3638 + * The functions below are called from rtc driver.
3639 + * Return 0 if HPET is not being used.
3640 + * Otherwise do the necessary changes and return 1.
3641 + */
3642 +int hpet_mask_rtc_irq_bit(unsigned long bit_mask)
3643 +{
3644 +       if (!is_hpet_enabled())
3645 +               return 0;
3646 +
3647 +       if (bit_mask & RTC_UIE)
3648 +               UIE_on = 0;
3649 +       if (bit_mask & RTC_PIE)
3650 +               PIE_on = 0;
3651 +       if (bit_mask & RTC_AIE)
3652 +               AIE_on = 0;
3653 +
3654 +       return 1;
3655 +}
3656 +
3657 +int hpet_set_rtc_irq_bit(unsigned long bit_mask)
3658 +{
3659 +       int timer_init_reqd = 0;
3660 +
3661 +       if (!is_hpet_enabled())
3662 +               return 0;
3663 +
3664 +       if (!(PIE_on | AIE_on | UIE_on))
3665 +               timer_init_reqd = 1;
3666 +
3667 +       if (bit_mask & RTC_UIE) {
3668 +               UIE_on = 1;
3669 +       }
3670 +       if (bit_mask & RTC_PIE) {
3671 +               PIE_on = 1;
3672 +               PIE_count = 0;
3673 +       }
3674 +       if (bit_mask & RTC_AIE) {
3675 +               AIE_on = 1;
3676 +       }
3677 +
3678 +       if (timer_init_reqd)
3679 +               hpet_rtc_timer_init();
3680 +
3681 +       return 1;
3682 +}
3683 +
3684 +int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec)
3685 +{
3686 +       if (!is_hpet_enabled())
3687 +               return 0;
3688 +
3689 +       alarm_time.tm_hour = hrs;
3690 +       alarm_time.tm_min = min;
3691 +       alarm_time.tm_sec = sec;
3692 +
3693 +       return 1;
3694 +}
3695 +
3696 +int hpet_set_periodic_freq(unsigned long freq)
3697 +{
3698 +       if (!is_hpet_enabled())
3699 +               return 0;
3700 +
3701 +       PIE_freq = freq;
3702 +       PIE_count = 0;
3703 +
3704 +       return 1;
3705 +}
3706 +
3707 +int hpet_rtc_dropped_irq(void)
3708 +{
3709 +       if (!is_hpet_enabled())
3710 +               return 0;
3711 +
3712 +       return 1;
3713 +}
3714 +
3715 +irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3716 +{
3717 +       struct rtc_time curr_time;
3718 +       unsigned long rtc_int_flag = 0;
3719 +       int call_rtc_interrupt = 0;
3720 +
3721 +       hpet_rtc_timer_reinit();
3722 +
3723 +       if (UIE_on | AIE_on) {
3724 +               get_rtc_time(&curr_time);
3725 +       }
3726 +       if (UIE_on) {
3727 +               if (curr_time.tm_sec != prev_update_sec) {
3728 +                       /* Set update int info, call real rtc int routine */
3729 +                       call_rtc_interrupt = 1;
3730 +                       rtc_int_flag = RTC_UF;
3731 +                       prev_update_sec = curr_time.tm_sec;
3732 +               }
3733 +       }
3734 +       if (PIE_on) {
3735 +               PIE_count++;
3736 +               if (PIE_count >= hpet_rtc_int_freq/PIE_freq) {
3737 +                       /* Set periodic int info, call real rtc int routine */
3738 +                       call_rtc_interrupt = 1;
3739 +                       rtc_int_flag |= RTC_PF;
3740 +                       PIE_count = 0;
3741 +               }
3742 +       }
3743 +       if (AIE_on) {
3744 +               if ((curr_time.tm_sec == alarm_time.tm_sec) &&
3745 +                   (curr_time.tm_min == alarm_time.tm_min) &&
3746 +                   (curr_time.tm_hour == alarm_time.tm_hour)) {
3747 +                       /* Set alarm int info, call real rtc int routine */
3748 +                       call_rtc_interrupt = 1;
3749 +                       rtc_int_flag |= RTC_AF;
3750 +               }
3751 +       }
3752 +       if (call_rtc_interrupt) {
3753 +               rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8));
3754 +               rtc_interrupt(rtc_int_flag, dev_id, regs);
3755 +       }
3756 +       return IRQ_HANDLED;
3757 +}
3758 +#endif
3759 +
3760 diff -Nru a/arch/i386/kernel/timers/Makefile b/arch/i386/kernel/timers/Makefile
3761 --- a/arch/i386/kernel/timers/Makefile  Sun May  4 23:38:34 2003
3762 +++ b/arch/i386/kernel/timers/Makefile  Sun Aug 31 16:14:50 2003
3763 @@ -5,3 +5,4 @@
3764  obj-y := timer.o timer_none.o timer_tsc.o timer_pit.o
3765  
3766  obj-$(CONFIG_X86_CYCLONE_TIMER)        += timer_cyclone.o
3767 +obj-$(CONFIG_HPET_TIMER)       += timer_hpet.o
3768 diff -Nru a/arch/i386/kernel/timers/timer.c b/arch/i386/kernel/timers/timer.c
3769 --- a/arch/i386/kernel/timers/timer.c   Wed Jul  2 21:21:34 2003
3770 +++ b/arch/i386/kernel/timers/timer.c   Sun Aug 31 16:15:21 2003
3771 @@ -3,10 +3,21 @@
3772  #include <linux/string.h>
3773  #include <asm/timer.h>
3774  
3775 +#ifdef CONFIG_HPET_TIMER
3776 +/*
3777 + * HPET memory read is slower than tsc reads, but is more dependable as it
3778 + * always runs at constant frequency and reduces complexity due to
3779 + * cpufreq. So, we prefer HPET timer to tsc based one. Also, we cannot use
3780 + * timer_pit when HPET is active. So, we default to timer_tsc.
3781 + */
3782 +#endif
3783  /* list of timers, ordered by preference, NULL terminated */
3784  static struct timer_opts* timers[] = {
3785  #ifdef CONFIG_X86_CYCLONE_TIMER
3786         &timer_cyclone,
3787 +#endif
3788 +#ifdef CONFIG_HPET_TIMER
3789 +       &timer_hpet,
3790  #endif
3791         &timer_tsc,
3792         &timer_pit,
3793 diff -Nru a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c
3794 --- /dev/null   Wed Dec 31 16:00:00 1969
3795 +++ b/arch/i386/kernel/timers/timer_hpet.c      Sun Aug 31 16:15:29 2003
3796 @@ -0,0 +1,241 @@
3797 +/*
3798 + * This code largely moved from arch/i386/kernel/time.c.
3799 + * See comments there for proper credits.
3800 + */
3801 +
3802 +#include <linux/spinlock.h>
3803 +#include <linux/init.h>
3804 +#include <linux/timex.h>
3805 +#include <linux/errno.h>
3806 +#include <linux/string.h>
3807 +#include <linux/jiffies.h>
3808 +
3809 +#include <asm/timer.h>
3810 +#include <asm/io.h>
3811 +#include <asm/processor.h>
3812 +
3813 +#include "io_ports.h"
3814 +#include "mach_timer.h"
3815 +#include <asm/hpet.h>
3816 +
3817 +static unsigned long hpet_usec_quotient;       /* convert hpet clks to usec */
3818 +static unsigned long tsc_hpet_quotient;                /* convert tsc to hpet clks */
3819 +static unsigned long hpet_last;        /* hpet counter value at last tick*/
3820 +static unsigned long last_tsc_low;     /* lsb 32 bits of Time Stamp Counter */
3821 +static unsigned long last_tsc_high;    /* msb 32 bits of Time Stamp Counter */
3822 +static unsigned long long monotonic_base;
3823 +static rwlock_t monotonic_lock = RW_LOCK_UNLOCKED;
3824 +
3825 +/* convert from cycles(64bits) => nanoseconds (64bits)
3826 + *  basic equation:
3827 + *             ns = cycles / (freq / ns_per_sec)
3828 + *             ns = cycles * (ns_per_sec / freq)
3829 + *             ns = cycles * (10^9 / (cpu_mhz * 10^6))
3830 + *             ns = cycles * (10^3 / cpu_mhz)
3831 + *
3832 + *     Then we use scaling math (suggested by george@mvista.com) to get:
3833 + *             ns = cycles * (10^3 * SC / cpu_mhz) / SC
3834 + *             ns = cycles * cyc2ns_scale / SC
3835 + *
3836 + *     And since SC is a constant power of two, we can convert the div
3837 + *  into a shift.
3838 + *                     -johnstul@us.ibm.com "math is hard, lets go shopping!"
3839 + */
3840 +static unsigned long cyc2ns_scale;
3841 +#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
3842 +
3843 +static inline void set_cyc2ns_scale(unsigned long cpu_mhz)
3844 +{
3845 +       cyc2ns_scale = (1000 << CYC2NS_SCALE_FACTOR)/cpu_mhz;
3846 +}
3847 +
3848 +static inline unsigned long long cycles_2_ns(unsigned long long cyc)
3849 +{
3850 +       return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
3851 +}
3852 +
3853 +static unsigned long long monotonic_clock_hpet(void)
3854 +{
3855 +       unsigned long long last_offset, this_offset, base;
3856 +
3857 +       /* atomically read monotonic base & last_offset */
3858 +       read_lock_irq(&monotonic_lock);
3859 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
3860 +       base = monotonic_base;
3861 +       read_unlock_irq(&monotonic_lock);
3862 +
3863 +       /* Read the Time Stamp Counter */
3864 +       rdtscll(this_offset);
3865 +
3866 +       /* return the value in ns */
3867 +       return base + cycles_2_ns(this_offset - last_offset);
3868 +}
3869 +
3870 +static unsigned long get_offset_hpet(void)
3871 +{
3872 +       register unsigned long eax, edx;
3873 +
3874 +       eax = hpet_readl(HPET_COUNTER);
3875 +       eax -= hpet_last;       /* hpet delta */
3876 +
3877 +       /*
3878 +         * Time offset = (hpet delta) * ( usecs per HPET clock )
3879 +        *             = (hpet delta) * ( usecs per tick / HPET clocks per tick)
3880 +        *             = (hpet delta) * ( hpet_usec_quotient ) / (2^32)
3881 +        *
3882 +        * Where,
3883 +        * hpet_usec_quotient = (2^32 * usecs per tick)/HPET clocks per tick
3884 +        *
3885 +        * Using a mull instead of a divl saves some cycles in critical path.
3886 +         */
3887 +       ASM_MUL64_REG(eax, edx, hpet_usec_quotient, eax);
3888 +
3889 +       /* our adjusted time offset in microseconds */
3890 +       return edx;
3891 +}
3892 +
3893 +static void mark_offset_hpet(void)
3894 +{
3895 +       unsigned long long this_offset, last_offset;
3896 +       unsigned long offset;
3897 +
3898 +       write_lock(&monotonic_lock);
3899 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
3900 +       rdtsc(last_tsc_low, last_tsc_high);
3901 +
3902 +       offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
3903 +       if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
3904 +               int lost_ticks = (offset - hpet_last) / hpet_tick;
3905 +               jiffies += lost_ticks;
3906 +       }
3907 +       hpet_last = offset;
3908 +
3909 +       /* update the monotonic base value */
3910 +       this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
3911 +       monotonic_base += cycles_2_ns(this_offset - last_offset);
3912 +       write_unlock(&monotonic_lock);
3913 +}
3914 +
3915 +void delay_hpet(unsigned long loops)
3916 +{
3917 +       unsigned long hpet_start, hpet_end;
3918 +       unsigned long eax;
3919 +
3920 +       /* loops is the number of cpu cycles. Convert it to hpet clocks */
3921 +       ASM_MUL64_REG(eax, loops, tsc_hpet_quotient, loops);
3922 +
3923 +       hpet_start = hpet_readl(HPET_COUNTER);
3924 +       do {
3925 +               rep_nop();
3926 +               hpet_end = hpet_readl(HPET_COUNTER);
3927 +       } while ((hpet_end - hpet_start) < (loops));
3928 +}
3929 +
3930 +/* ------ Calibrate the TSC -------
3931 + * Return 2^32 * (1 / (TSC clocks per usec)) for getting the CPU freq.
3932 + * Set 2^32 * (1 / (tsc per HPET clk)) for delay_hpet().
3933 + * calibrate_tsc() calibrates the processor TSC by comparing
3934 + * it to the HPET timer of known frequency.
3935 + * Too much 64-bit arithmetic here to do this cleanly in C
3936 + */
3937 +#define CALIBRATE_CNT_HPET     (5 * hpet_tick)
3938 +#define CALIBRATE_TIME_HPET    (5 * KERNEL_TICK_USEC)
3939 +
3940 +static unsigned long __init calibrate_tsc(void)
3941 +{
3942 +       unsigned long tsc_startlow, tsc_starthigh;
3943 +       unsigned long tsc_endlow, tsc_endhigh;
3944 +       unsigned long hpet_start, hpet_end;
3945 +       unsigned long result, remain;
3946 +
3947 +       hpet_start = hpet_readl(HPET_COUNTER);
3948 +       rdtsc(tsc_startlow, tsc_starthigh);
3949 +       do {
3950 +               hpet_end = hpet_readl(HPET_COUNTER);
3951 +       } while ((hpet_end - hpet_start) < CALIBRATE_CNT_HPET);
3952 +       rdtsc(tsc_endlow, tsc_endhigh);
3953 +
3954 +       /* 64-bit subtract - gcc just messes up with long longs */
3955 +       __asm__("subl %2,%0\n\t"
3956 +               "sbbl %3,%1"
3957 +               :"=a" (tsc_endlow), "=d" (tsc_endhigh)
3958 +               :"g" (tsc_startlow), "g" (tsc_starthigh),
3959 +                "0" (tsc_endlow), "1" (tsc_endhigh));
3960 +
3961 +       /* Error: ECPUTOOFAST */
3962 +       if (tsc_endhigh)
3963 +               goto bad_calibration;
3964 +
3965 +       /* Error: ECPUTOOSLOW */
3966 +       if (tsc_endlow <= CALIBRATE_TIME_HPET)
3967 +               goto bad_calibration;
3968 +
3969 +       ASM_DIV64_REG(result, remain, tsc_endlow, 0, CALIBRATE_TIME_HPET);
3970 +       if (remain > (tsc_endlow >> 1))
3971 +               result++; /* rounding the result */
3972 +
3973 +       ASM_DIV64_REG(tsc_hpet_quotient, remain, tsc_endlow, 0,
3974 +                       CALIBRATE_CNT_HPET);
3975 +       if (remain > (tsc_endlow >> 1))
3976 +               tsc_hpet_quotient++; /* rounding the result */
3977 +
3978 +       return result;
3979 +bad_calibration:
3980 +       /*
3981 +        * the CPU was so fast/slow that the quotient wouldn't fit in
3982 +        * 32 bits..
3983 +        */
3984 +       return 0;
3985 +}
3986 +
3987 +static int __init init_hpet(char* override)
3988 +{
3989 +       unsigned long result, remain;
3990 +
3991 +       /* check clock override */
3992 +       if (override[0] && strncmp(override,"hpet",4))
3993 +               return -ENODEV;
3994 +
3995 +       if (!is_hpet_enabled())
3996 +               return -ENODEV;
3997 +
3998 +       printk("Using HPET for gettimeofday\n");
3999 +       if (cpu_has_tsc) {
4000 +               unsigned long tsc_quotient = calibrate_tsc();
4001 +               if (tsc_quotient) {
4002 +                       /* report CPU clock rate in Hz.
4003 +                        * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
4004 +                        * clock/second. Our precision is about 100 ppm.
4005 +                        */
4006 +                       {       unsigned long eax=0, edx=1000;
4007 +                               ASM_DIV64_REG(cpu_khz, edx, tsc_quotient,
4008 +                                               eax, edx);
4009 +                               printk("Detected %lu.%03lu MHz processor.\n",
4010 +                                       cpu_khz / 1000, cpu_khz % 1000);
4011 +                       }
4012 +                       set_cyc2ns_scale(cpu_khz/1000);
4013 +               }
4014 +       }
4015 +
4016 +       /*
4017 +        * Math to calculate hpet to usec multiplier
4018 +        * Look for the comments at get_offset_hpet()
4019 +        */
4020 +       ASM_DIV64_REG(result, remain, hpet_tick, 0, KERNEL_TICK_USEC);
4021 +       if (remain > (hpet_tick >> 1))
4022 +               result++; /* rounding the result */
4023 +       hpet_usec_quotient = result;
4024 +
4025 +       return 0;
4026 +}
4027 +
4028 +/************************************************************/
4029 +
4030 +/* tsc timer_opts struct */
4031 +struct timer_opts timer_hpet = {
4032 +       .init =                 init_hpet,
4033 +       .mark_offset =          mark_offset_hpet,
4034 +       .get_offset =           get_offset_hpet,
4035 +       .monotonic_clock =      monotonic_clock_hpet,
4036 +       .delay =                delay_hpet,
4037 +};
4038 diff -Nru a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
4039 --- a/arch/i386/kernel/timers/timer_tsc.c       Mon Aug 18 06:40:02 2003
4040 +++ b/arch/i386/kernel/timers/timer_tsc.c       Sun Aug 31 16:15:21 2003
4041 @@ -19,9 +19,18 @@
4042  #include "io_ports.h"
4043  #include "mach_timer.h"
4044  
4045 +#include <asm/hpet.h>
4046 +
4047 +#ifdef CONFIG_HPET_TIMER
4048 +static unsigned long hpet_usec_quotient;
4049 +static unsigned long hpet_last;
4050 +struct timer_opts timer_tsc;
4051 +#endif
4052 +
4053  int tsc_disable __initdata = 0;
4054  
4055  extern spinlock_t i8253_lock;
4056 +extern volatile unsigned long jiffies;
4057  
4058  static int use_tsc;
4059  /* Number of usecs that the last interrupt was delayed */
4060 @@ -232,7 +241,7 @@
4061  
4062  #define CALIBRATE_TIME (5 * 1000020/HZ)
4063  
4064 -unsigned long __init calibrate_tsc(void)
4065 +static unsigned long __init calibrate_tsc(void)
4066  {
4067         mach_prepare_counter();
4068  
4069 @@ -282,6 +291,107 @@
4070         return 0;
4071  }
4072  
4073 +#ifdef CONFIG_HPET_TIMER
4074 +static void mark_offset_tsc_hpet(void)
4075 +{
4076 +       unsigned long long this_offset, last_offset;
4077 +       unsigned long offset, temp, hpet_current;
4078 +
4079 +       write_lock(&monotonic_lock);
4080 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
4081 +       /*
4082 +        * It is important that these two operations happen almost at
4083 +        * the same time. We do the RDTSC stuff first, since it's
4084 +        * faster. To avoid any inconsistencies, we need interrupts
4085 +        * disabled locally.
4086 +        */
4087 +       /*
4088 +        * Interrupts are just disabled locally since the timer irq
4089 +        * has the SA_INTERRUPT flag set. -arca
4090 +        */
4091 +       /* read Pentium cycle counter */
4092 +
4093 +       hpet_current = hpet_readl(HPET_COUNTER);
4094 +       rdtsc(last_tsc_low, last_tsc_high);
4095 +
4096 +       /* lost tick compensation */
4097 +       offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
4098 +       if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
4099 +               int lost_ticks = (offset - hpet_last) / hpet_tick;
4100 +               jiffies += lost_ticks;
4101 +       }
4102 +       hpet_last = hpet_current;
4103 +
4104 +       /* update the monotonic base value */
4105 +       this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
4106 +       monotonic_base += cycles_2_ns(this_offset - last_offset);
4107 +       write_unlock(&monotonic_lock);
4108 +
4109 +       /* calculate delay_at_last_interrupt */
4110 +       /*
4111 +        * Time offset = (hpet delta) * ( usecs per HPET clock )
4112 +        *             = (hpet delta) * ( usecs per tick / HPET clocks per tick)
4113 +        *             = (hpet delta) * ( hpet_usec_quotient ) / (2^32)
4114 +        * Where,
4115 +        * hpet_usec_quotient = (2^32 * usecs per tick)/HPET clocks per tick
4116 +        */
4117 +       delay_at_last_interrupt = hpet_current - offset;
4118 +       ASM_MUL64_REG(temp, delay_at_last_interrupt,
4119 +                       hpet_usec_quotient, delay_at_last_interrupt);
4120 +}
4121 +
4122 +/* ------ Calibrate the TSC based on HPET timer -------
4123 + * Return 2^32 * (1 / (TSC clocks per usec)) for do_fast_gettimeoffset().
4124 + * calibrate_tsc() calibrates the processor TSC by comparing
4125 + * it to the HPET timer of known frequency.
4126 + * Too much 64-bit arithmetic here to do this cleanly in C
4127 + */
4128 +
4129 +#define CALIBRATE_CNT_HPET     (5 * hpet_tick)
4130 +#define CALIBRATE_TIME_HPET    (5 * KERNEL_TICK_USEC)
4131 +
4132 +unsigned long __init calibrate_tsc_hpet(void)
4133 +{
4134 +       unsigned long tsc_startlow, tsc_starthigh;
4135 +       unsigned long tsc_endlow, tsc_endhigh;
4136 +       unsigned long hpet_start, hpet_end;
4137 +       unsigned long result, remain;
4138 +
4139 +       hpet_start = hpet_readl(HPET_COUNTER);
4140 +       rdtsc(tsc_startlow, tsc_starthigh);
4141 +       do {
4142 +               hpet_end = hpet_readl(HPET_COUNTER);
4143 +       } while ((hpet_end - hpet_start) < CALIBRATE_CNT_HPET);
4144 +       rdtsc(tsc_endlow, tsc_endhigh);
4145 +
4146 +       /* 64-bit subtract - gcc just messes up with long longs */
4147 +       __asm__("subl %2,%0\n\t"
4148 +               "sbbl %3,%1"
4149 +               :"=a" (tsc_endlow), "=d" (tsc_endhigh)
4150 +               :"g" (tsc_startlow), "g" (tsc_starthigh),
4151 +                "0" (tsc_endlow), "1" (tsc_endhigh));
4152 +
4153 +       /* Error: ECPUTOOFAST */
4154 +       if (tsc_endhigh)
4155 +               goto bad_calibration;
4156 +
4157 +       /* Error: ECPUTOOSLOW */
4158 +       if (tsc_endlow <= CALIBRATE_TIME_HPET)
4159 +               goto bad_calibration;
4160 +
4161 +       ASM_DIV64_REG(result, remain, tsc_endlow, 0, CALIBRATE_TIME_HPET);
4162 +       if (remain > (tsc_endlow >> 1))
4163 +               result++; /* rounding the result */
4164 +
4165 +       return result;
4166 +bad_calibration:
4167 +       /*
4168 +        * the CPU was so fast/slow that the quotient wouldn't fit in
4169 +        * 32 bits..
4170 +        */
4171 +       return 0;
4172 +}
4173 +#endif
4174  
4175  #ifdef CONFIG_CPU_FREQ
4176  static unsigned int  ref_freq = 0;
4177 @@ -333,8 +443,16 @@
4178  {
4179  
4180         /* check clock override */
4181 -       if (override[0] && strncmp(override,"tsc",3))
4182 +       if (override[0] && strncmp(override,"tsc",3)) {
4183 +#ifdef CONFIG_HPET_TIMER
4184 +               if (is_hpet_enabled()) {
4185 +                       printk(KERN_ERR "Warning: clock= override failed. Defaulting to tsc\n");
4186 +               } else
4187 +#endif
4188 +               {
4189                         return -ENODEV;
4190 +               }
4191 +       }
4192  
4193         /*
4194          * If we have APM enabled or the CPU clock speed is variable
4195 @@ -368,7 +486,29 @@
4196         count2 = LATCH; /* initialize counter for mark_offset_tsc() */
4197  
4198         if (cpu_has_tsc) {
4199 -               unsigned long tsc_quotient = calibrate_tsc();
4200 +               unsigned long tsc_quotient;
4201 +#ifdef CONFIG_HPET_TIMER
4202 +               if (is_hpet_enabled()){
4203 +                       unsigned long result, remain;
4204 +                       printk("Using TSC for gettimeofday\n");
4205 +                       tsc_quotient = calibrate_tsc_hpet();
4206 +                       timer_tsc.mark_offset = &mark_offset_tsc_hpet;
4207 +                       /*
4208 +                        * Math to calculate hpet to usec multiplier
4209 +                        * Look for the comments at get_offset_tsc_hpet()
4210 +                        */
4211 +                       ASM_DIV64_REG(result, remain, hpet_tick,
4212 +                                       0, KERNEL_TICK_USEC);
4213 +                       if (remain > (hpet_tick >> 1))
4214 +                               result++; /* rounding the result */
4215 +
4216 +                       hpet_usec_quotient = result;
4217 +               } else
4218 +#endif
4219 +               {
4220 +                       tsc_quotient = calibrate_tsc();
4221 +               }
4222 +
4223                 if (tsc_quotient) {
4224                         fast_gettimeoffset_quotient = tsc_quotient;
4225                         use_tsc = 1;
4226 diff -Nru a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
4227 --- a/arch/i386/kernel/traps.c  Thu Jun 26 12:11:29 2003
4228 +++ b/arch/i386/kernel/traps.c  Tue Sep  2 00:37:21 2003
4229 @@ -745,7 +745,8 @@
4230   * Careful.. There are problems with IBM-designed IRQ13 behaviour.
4231   * Don't touch unless you *really* know how it works.
4232   *
4233 - * Must be called with kernel preemption disabled.
4234 + * Must be called with kernel preemption disabled (in this case,
4235 + * local interrupts are disabled at the call-site in entry.S).
4236   */
4237  asmlinkage void math_state_restore(struct pt_regs regs)
4238  {
4239 diff -Nru a/arch/i386/mach-visws/mpparse.c b/arch/i386/mach-visws/mpparse.c
4240 --- a/arch/i386/mach-visws/mpparse.c    Mon Aug 18 19:46:23 2003
4241 +++ b/arch/i386/mach-visws/mpparse.c    Sun Aug 31 16:14:17 2003
4242 @@ -38,7 +38,7 @@
4243  void __init MP_processor_info (struct mpc_config_processor *m)
4244  {
4245         int ver, logical_apicid;
4246 -       cpumask_t apic_cpus;
4247 +       physid_mask_t apic_cpus;
4248         
4249         if (!(m->mpc_cpuflag & CPU_ENABLED))
4250                 return;
4251 diff -Nru a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
4252 --- a/arch/i386/mach-voyager/voyager_smp.c      Mon Aug 18 19:46:23 2003
4253 +++ b/arch/i386/mach-voyager/voyager_smp.c      Sun Aug 31 16:14:42 2003
4254 @@ -130,7 +130,7 @@
4255  {
4256         int cpu;
4257  
4258 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
4259 +       for_each_cpu(cpu, cpu_online_map) {
4260                 if(cpuset & (1<<cpu)) {
4261  #ifdef VOYAGER_DEBUG
4262                         if(!cpu_isset(cpu, cpu_online_map))
4263 @@ -874,10 +874,10 @@
4264  asmlinkage void 
4265  smp_invalidate_interrupt(void)
4266  {
4267 -       __u8 cpu = get_cpu();
4268 +       __u8 cpu = smp_processor_id();
4269  
4270 -       if (!(smp_invalidate_needed & (1UL << cpu)))
4271 -               goto out;
4272 +       if (!test_bit(cpu, &smp_invalidate_needed))
4273 +               return;
4274         /* This will flood messages.  Don't uncomment unless you see
4275          * Problems with cross cpu invalidation
4276         VDEBUG(("VOYAGER SMP: CPU%d received INVALIDATE_CPI\n",
4277 @@ -893,9 +893,9 @@
4278                 } else
4279                         leave_mm(cpu);
4280         }
4281 -       smp_invalidate_needed |= 1UL << cpu;
4282 - out:
4283 -       put_cpu_no_resched();
4284 +       smp_mb__before_clear_bit();
4285 +       clear_bit(cpu, &smp_invalidate_needed);
4286 +       smp_mb__after_clear_bit();
4287  }
4288  
4289  /* All the new flush operations for 2.4 */
4290 @@ -929,6 +929,7 @@
4291         send_CPI(cpumask, VIC_INVALIDATE_CPI);
4292  
4293         while (smp_invalidate_needed) {
4294 +               mb();
4295                 if(--stuck == 0) {
4296                         printk("***WARNING*** Stuck doing invalidate CPI (CPU%d)\n", smp_processor_id());
4297                         break;
4298 @@ -1464,7 +1465,7 @@
4299         cpuset &= 0xff;         /* only first 8 CPUs vaild for VIC CPI */
4300         if(cpuset == 0)
4301                 return;
4302 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
4303 +       for_each_cpu(cpu, cpu_online_map) {
4304                 if(cpuset & (1<<cpu))
4305                         set_bit(cpi, &vic_cpi_mailbox[cpu]);
4306         }
4307 @@ -1578,7 +1579,7 @@
4308         VDEBUG(("VOYAGER: enable_vic_irq(%d) CPU%d affinity 0x%lx\n",
4309                 irq, cpu, cpu_irq_affinity[cpu]));
4310         spin_lock_irqsave(&vic_irq_lock, flags);
4311 -       for_each_cpu(real_cpu, mk_cpumask_const(cpu_online_map)) {
4312 +       for_each_cpu(real_cpu, cpu_online_map) {
4313                 if(!(voyager_extended_vic_processors & (1<<real_cpu)))
4314                         continue;
4315                 if(!(cpu_irq_affinity[real_cpu] & mask)) {
4316 @@ -1723,7 +1724,7 @@
4317  
4318                         printk("VOYAGER SMP: CPU%d lost interrupt %d\n",
4319                                cpu, irq);
4320 -                       for_each_cpu(real_cpu, mk_cpumask_const(mask)) {
4321 +                       for_each_cpu(real_cpu, mask) {
4322  
4323                                 outb(VIC_CPU_MASQUERADE_ENABLE | real_cpu,
4324                                      VIC_PROCESSOR_ID);
4325 @@ -1808,7 +1809,7 @@
4326                  * bus) */
4327                 return;
4328  
4329 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
4330 +       for_each_cpu(cpu, cpu_online_map) {
4331                 unsigned long cpu_mask = 1 << cpu;
4332                 
4333                 if(cpu_mask & real_mask) {
4334 @@ -1874,7 +1875,7 @@
4335         int old_cpu = smp_processor_id(), cpu;
4336  
4337         /* dump the interrupt masks of each processor */
4338 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
4339 +       for_each_cpu(cpu, cpu_online_map) {
4340                 __u16 imr, isr, irr;
4341                 unsigned long flags;
4342  
4343 diff -Nru a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
4344 --- a/arch/i386/oprofile/nmi_int.c      Thu Jul 17 17:21:06 2003
4345 +++ b/arch/i386/oprofile/nmi_int.c      Fri Aug 29 09:02:20 2003
4346 @@ -364,10 +364,21 @@
4347         switch (vendor) {
4348                 case X86_VENDOR_AMD:
4349                         /* Needs to be at least an Athlon (or hammer in 32bit mode) */
4350 -                       if (family < 6)
4351 +
4352 +                       switch (family) {
4353 +                       default:
4354                                 return -ENODEV;
4355 -                       model = &op_athlon_spec;
4356 -                       nmi_ops.cpu_type = "i386/athlon";
4357 +                       case 6:
4358 +                               model = &op_athlon_spec;
4359 +                               nmi_ops.cpu_type = "i386/athlon";
4360 +                               break;
4361 +#if defined(CONFIG_X86_64)
4362 +                       case 0xf:
4363 +                               model = &op_athlon_spec;
4364 +                               nmi_ops.cpu_type = "x86-64/hammer";
4365 +                               break;
4366 +#endif /* CONFIG_X86_64 */
4367 +                       }
4368                         break;
4369   
4370  #if !defined(CONFIG_X86_64)
4371 diff -Nru a/arch/i386/pci/common.c b/arch/i386/pci/common.c
4372 --- a/arch/i386/pci/common.c    Mon Jun 23 12:31:05 2003
4373 +++ b/arch/i386/pci/common.c    Mon Sep  1 17:58:12 2003
4374 @@ -152,7 +152,7 @@
4375         pci_cache_line_size = 32 >> 2;
4376         if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD)
4377                 pci_cache_line_size = 64 >> 2;  /* K7 & K8 */
4378 -       else if (c->x86 > 6)
4379 +       else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL)
4380                 pci_cache_line_size = 128 >> 2; /* P4 */
4381  
4382         pcibios_resource_survey();
4383 diff -Nru a/arch/ia64/Kconfig b/arch/ia64/Kconfig
4384 --- a/arch/ia64/Kconfig Fri Aug  8 10:02:34 2003
4385 +++ b/arch/ia64/Kconfig Sun Aug 31 16:14:22 2003
4386 @@ -234,8 +234,8 @@
4387  endchoice
4388  
4389  config DISCONTIGMEM
4390 -       bool "Discontiguous memory support" if (IA64_DIG && NUMA)
4391 -       default y if IA64_SGI_SN2 || IA64_GENERIC
4392 +       bool "Discontiguous memory support" if (IA64_DIG || IA64_SGI_SN2 || IA64_GENERIC) && NUMA
4393 +       default y if (IA64_SGI_SN2 || IA64_GENERIC) && NUMA
4394         help
4395           Say Y to support efficient handling of discontiguous physical memory,
4396           for architectures which are either NUMA (Non-Uniform Memory Access)
4397 @@ -296,29 +296,6 @@
4398         help
4399           If you are compiling a kernel that will run under SGI's IA-64
4400           simulator (Medusa) then say Y, otherwise say N.
4401 -
4402 -# On IA-64, we always want an ELF /proc/kcore.
4403 -config KCORE_ELF
4404 -       bool
4405 -       default y
4406 -       ---help---
4407 -         If you enabled support for /proc file system then the file
4408 -         /proc/kcore will contain the kernel core image. This can be used
4409 -         in gdb:
4410 -
4411 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
4412 -
4413 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
4414 -         /proc/kcore appear in ELF core format as defined by the Executable
4415 -         and Linking Format specification. Selecting A.OUT will choose the
4416 -         old "a.out" format which may be necessary for some old versions
4417 -         of binutils or on some architectures.
4418 -
4419 -         This is especially useful if you have compiled the kernel with the
4420 -         "-g" option to preserve debugging information. It is mainly used
4421 -         for examining kernel data structures on the live kernel so if you
4422 -         don't understand what this means or are not a kernel hacker, just
4423 -         leave it at its default value ELF.
4424  
4425  config FORCE_MAX_ZONEORDER
4426         int
4427 diff -Nru a/arch/ia64/Makefile b/arch/ia64/Makefile
4428 --- a/arch/ia64/Makefile        Tue Aug 19 23:13:39 2003
4429 +++ b/arch/ia64/Makefile        Sat Aug 23 10:28:23 2003
4430 @@ -70,6 +70,8 @@
4431  
4432  .PHONY: boot compressed check
4433  
4434 +all: compressed
4435 +
4436  compressed: vmlinux.gz
4437  
4438  vmlinux.gz: vmlinux
4439 @@ -100,6 +102,6 @@
4440  
4441  
4442  define archhelp
4443 -  echo '  compressed   - Build compressed kernel image'
4444 +  echo '* compressed   - Build compressed kernel image'
4445    echo '  boot         - Build vmlinux and bootloader for Ski simulator'
4446  endef
4447 diff -Nru a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
4448 --- a/arch/ia64/hp/common/sba_iommu.c   Sun Jul 27 12:01:33 2003
4449 +++ b/arch/ia64/hp/common/sba_iommu.c   Sun Aug 31 16:14:08 2003
4450 @@ -1935,10 +1935,10 @@
4451  }
4452  
4453  static struct acpi_driver acpi_sba_ioc_driver = {
4454 -       name:           "IOC IOMMU Driver",
4455 -       ids:            "HWP0001,HWP0004",
4456 -       ops: {
4457 -               add:    acpi_sba_ioc_add,
4458 +       .name           = "IOC IOMMU Driver",
4459 +       .ids            = "HWP0001,HWP0004",
4460 +       .ops            = {
4461 +               .add    = acpi_sba_ioc_add,
4462         },
4463  };
4464  
4465 diff -Nru a/arch/ia64/ia32/ia32_ioctl.c b/arch/ia64/ia32/ia32_ioctl.c
4466 --- a/arch/ia64/ia32/ia32_ioctl.c       Thu Aug  7 17:00:00 2003
4467 +++ b/arch/ia64/ia32/ia32_ioctl.c       Sun Aug 31 16:14:44 2003
4468 @@ -70,7 +70,7 @@
4469  #define IOCTL_TABLE_START \
4470         struct ioctl_trans ioctl_start[] = {
4471  #define IOCTL_TABLE_END \
4472 -       }; struct ioctl_trans ioctl_end[0];
4473 +       };
4474  
4475  IOCTL_TABLE_START
4476  HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
4477 @@ -79,3 +79,5 @@
4478  #include "compat_ioctl.c"
4479  #include <linux/compat_ioctl.h>
4480  IOCTL_TABLE_END
4481 +
4482 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
4483 diff -Nru a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
4484 --- a/arch/ia64/ia32/sys_ia32.c Tue Aug 19 23:13:39 2003
4485 +++ b/arch/ia64/ia32/sys_ia32.c Mon Aug 25 14:45:43 2003
4486 @@ -76,7 +76,6 @@
4487  
4488  #define OFFSET4K(a)            ((a) & 0xfff)
4489  #define PAGE_START(addr)       ((addr) & PAGE_MASK)
4490 -#define PAGE_OFF(addr)         ((addr) & ~PAGE_MASK)
4491  
4492  #define high2lowuid(uid) ((uid) > 65535 ? 65534 : (uid))
4493  #define high2lowgid(gid) ((gid) > 65535 ? 65534 : (gid))
4494 @@ -170,9 +169,9 @@
4495                 current->thread.map_base  = old_map_base;
4496                 current->thread.task_size = old_task_size;
4497                 set_fs(USER_DS);        /* establish new task-size as the address-limit */
4498 -         out:
4499 -               kfree(av);
4500         }
4501 +  out:
4502 +       kfree(av);
4503         return r;
4504  }
4505  
4506 @@ -271,11 +270,11 @@
4507  
4508         if (old_prot) {
4509                 /* copy back the old page contents.  */
4510 -               if (PAGE_OFF(start))
4511 -                       copy_to_user((void *) PAGE_START(start), page, PAGE_OFF(start));
4512 -               if (PAGE_OFF(end))
4513 -                       copy_to_user((void *) end, page + PAGE_OFF(end),
4514 -                                    PAGE_SIZE - PAGE_OFF(end));
4515 +               if (offset_in_page(start))
4516 +                       copy_to_user((void *) PAGE_START(start), page, offset_in_page(start));
4517 +               if (offset_in_page(end))
4518 +                       copy_to_user((void *) end, page + offset_in_page(end),
4519 +                                    PAGE_SIZE - offset_in_page(end));
4520         }
4521  
4522         if (!(flags & MAP_ANONYMOUS)) {
4523 @@ -330,7 +329,7 @@
4524                                        "%s(%d): emulate_mmap() can't share tail (end=0x%lx)\n",
4525                                        current->comm, current->pid, end);
4526                         ret = mmap_subpage(file, max(start, PAGE_START(end)), end, prot, flags,
4527 -                                          (off + len) - PAGE_OFF(end));
4528 +                                          (off + len) - offset_in_page(end));
4529                         if (IS_ERR((void *) ret))
4530                                 return ret;
4531                         pend -= PAGE_SIZE;
4532 @@ -347,14 +346,14 @@
4533                 tmp = arch_get_unmapped_area(file, pstart - fudge, pend - pstart, 0, flags);
4534                 if (tmp != pstart) {
4535                         pstart = tmp;
4536 -                       start = pstart + PAGE_OFF(off); /* make start congruent with off */
4537 +                       start = pstart + offset_in_page(off);   /* make start congruent with off */
4538                         end = start + len;
4539                         pend = PAGE_ALIGN(end);
4540                 }
4541         }
4542  
4543         poff = off + (pstart - start);  /* note: (pstart - start) may be negative */
4544 -       is_congruent = (flags & MAP_ANONYMOUS) || (PAGE_OFF(poff) == 0);
4545 +       is_congruent = (flags & MAP_ANONYMOUS) || (offset_in_page(poff) == 0);
4546  
4547         if ((flags & MAP_SHARED) && !is_congruent)
4548                 printk(KERN_INFO "%s(%d): emulate_mmap() can't share contents of incongruent mmap "
4549 @@ -588,7 +587,7 @@
4550  
4551         down(&ia32_mmap_sem);
4552         {
4553 -               if (PAGE_OFF(start)) {
4554 +               if (offset_in_page(start)) {
4555                         /* start address is 4KB aligned but not page aligned. */
4556                         retval = mprotect_subpage(PAGE_START(start), prot);
4557                         if (retval < 0)
4558 @@ -599,7 +598,7 @@
4559                                 goto out;       /* retval is already zero... */
4560                 }
4561  
4562 -               if (PAGE_OFF(end)) {
4563 +               if (offset_in_page(end)) {
4564                         /* end address is 4KB aligned but not page aligned. */
4565                         retval = mprotect_subpage(PAGE_START(end), prot);
4566                         if (retval < 0)
4567 diff -Nru a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
4568 --- a/arch/ia64/kernel/acpi.c   Wed Aug  6 12:37:03 2003
4569 +++ b/arch/ia64/kernel/acpi.c   Tue Aug 26 15:09:18 2003
4570 @@ -130,7 +130,7 @@
4571         int vector = -1;
4572  
4573         if (int_type < ACPI_MAX_PLATFORM_INTERRUPTS) {
4574 -               /* correctable platform error interrupt */
4575 +               /* corrected platform error interrupt */
4576                 vector = platform_intr_list[int_type];
4577         } else
4578                 printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n");
4579 diff -Nru a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
4580 --- a/arch/ia64/kernel/entry.S  Sat Aug 16 17:16:48 2003
4581 +++ b/arch/ia64/kernel/entry.S  Mon Aug 25 14:47:33 2003
4582 @@ -1473,7 +1473,7 @@
4583         data8 sys_clock_nanosleep
4584         data8 sys_fstatfs64
4585         data8 sys_statfs64
4586 -       data8 ia64_ni_syscall
4587 +       data8 sys_fadvise64_64
4588         data8 ia64_ni_syscall                   // 1260
4589         data8 ia64_ni_syscall
4590         data8 ia64_ni_syscall
4591 diff -Nru a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S
4592 --- a/arch/ia64/kernel/fsys.S   Thu Jul 10 18:16:32 2003
4593 +++ b/arch/ia64/kernel/fsys.S   Mon Aug 25 14:47:33 2003
4594 @@ -678,9 +678,9 @@
4595         data8 0                         // clock_gettime
4596         data8 0                         // clock_getres         // 1255
4597         data8 0                         // clock_nanosleep
4598 -       data8 0
4599 -       data8 0
4600 -       data8 0
4601 +       data8 0                         // fstatfs64
4602 +       data8 0                         // statfs64
4603 +       data8 0                         // fadvise64_64
4604         data8 0                                                 // 1260
4605         data8 0
4606         data8 0
4607 diff -Nru a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4608 --- a/arch/ia64/kernel/mca.c    Tue Aug 19 23:13:39 2003
4609 +++ b/arch/ia64/kernel/mca.c    Tue Aug 26 13:42:37 2003
4610 @@ -1145,7 +1145,7 @@
4611  
4612         ia64_mca_cmc_int_handler(cpe_irq, arg, ptregs);
4613  
4614 -       for (++cpuid ; !cpu_online(cpuid) && cpuid < NR_CPUS ; cpuid++);
4615 +       for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++);
4616  
4617         if (cpuid < NR_CPUS) {
4618                 platform_send_ipi(cpuid, IA64_CMCP_VECTOR, IA64_IPI_DM_INT, 0);
4619 @@ -1225,7 +1225,7 @@
4620  
4621         ia64_mca_cpe_int_handler(cpe_irq, arg, ptregs);
4622  
4623 -       for (++cpuid ; !cpu_online(cpuid) && cpuid < NR_CPUS ; cpuid++);
4624 +       for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++);
4625  
4626         if (cpuid < NR_CPUS) {
4627                 platform_send_ipi(cpuid, IA64_CPEP_VECTOR, IA64_IPI_DM_INT, 0);
4628 diff -Nru a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
4629 --- a/arch/ia64/kernel/perfmon.c        Thu Aug 21 15:45:04 2003
4630 +++ b/arch/ia64/kernel/perfmon.c        Sun Aug 31 16:14:08 2003
4631 @@ -2109,7 +2109,7 @@
4632         return 1;
4633  }
4634  static struct dentry_operations pfmfs_dentry_operations = {
4635 -       d_delete:       pfmfs_delete_dentry,
4636 +       .d_delete       = pfmfs_delete_dentry,
4637  };
4638  
4639  
4640 diff -Nru a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
4641 --- a/arch/ia64/kernel/smpboot.c        Mon Aug 18 19:46:23 2003
4642 +++ b/arch/ia64/kernel/smpboot.c        Fri Aug 22 15:20:52 2003
4643 @@ -560,7 +560,7 @@
4644                 if (cpu_online(cpu))
4645                         bogosum += cpu_data(cpu)->loops_per_jiffy;
4646  
4647 -       printk(KERN_INFO "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
4648 +       printk(KERN_INFO "Total of %lu processors activated (%lu.%02lu BogoMIPS).\n",
4649                num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100);
4650  }
4651  
4652 diff -Nru a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4653 --- a/arch/ia64/kernel/sys_ia64.c       Wed Jul  9 09:56:58 2003
4654 +++ b/arch/ia64/kernel/sys_ia64.c       Mon Aug 25 14:45:43 2003
4655 @@ -242,7 +242,7 @@
4656  asmlinkage unsigned long
4657  sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, long off)
4658  {
4659 -       if ((off & ~PAGE_MASK) != 0)
4660 +       if (offset_in_page(off) != 0)
4661                 return -EINVAL;
4662  
4663         addr = do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
4664 diff -Nru a/arch/ia64/lib/Makefile b/arch/ia64/lib/Makefile
4665 --- a/arch/ia64/lib/Makefile    Fri Jun 20 12:48:24 2003
4666 +++ b/arch/ia64/lib/Makefile    Mon Aug 25 09:56:27 2003
4667 @@ -14,9 +14,6 @@
4668  lib-$(CONFIG_PERFMON)  += carta_random.o
4669  lib-$(CONFIG_MD_RAID5) += xor.o
4670  
4671 -IGNORE_FLAGS_OBJS =    __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \
4672 -                       __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o
4673 -
4674  AFLAGS___divdi3.o      =
4675  AFLAGS___udivdi3.o     = -DUNSIGNED
4676  AFLAGS___moddi3.o      =            -DMODULO
4677 @@ -27,26 +24,26 @@
4678  AFLAGS___modsi3.o      =            -DMODULO
4679  AFLAGS___umodsi3.o     = -DUNSIGNED -DMODULO
4680  
4681 -$(obj)/__divdi3.o: $(src)/idiv64.S
4682 -       $(cmd_as_o_S)
4683 +$(obj)/__divdi3.o: $(src)/idiv64.S FORCE
4684 +       $(call if_changed_dep,as_o_S)
4685  
4686 -$(obj)/__udivdi3.o: $(src)/idiv64.S
4687 -       $(cmd_as_o_S)
4688 +$(obj)/__udivdi3.o: $(src)/idiv64.S FORCE
4689 +       $(call if_changed_dep,as_o_S)
4690  
4691 -$(obj)/__moddi3.o: $(src)/idiv64.S
4692 -       $(cmd_as_o_S)
4693 +$(obj)/__moddi3.o: $(src)/idiv64.S FORCE
4694 +       $(call if_changed_dep,as_o_S)
4695  
4696 -$(obj)/__umoddi3.o: $(src)/idiv64.S
4697 -       $(cmd_as_o_S)
4698 +$(obj)/__umoddi3.o: $(src)/idiv64.S FORCE
4699 +       $(call if_changed_dep,as_o_S)
4700  
4701 -$(obj)/__divsi3.o: $(src)/idiv32.S
4702 -       $(cmd_as_o_S)
4703 +$(obj)/__divsi3.o: $(src)/idiv32.S FORCE
4704 +       $(call if_changed_dep,as_o_S)
4705  
4706 -$(obj)/__udivsi3.o: $(src)/idiv32.S
4707 -       $(cmd_as_o_S)
4708 +$(obj)/__udivsi3.o: $(src)/idiv32.S FORCE
4709 +       $(call if_changed_dep,as_o_S)
4710  
4711 -$(obj)/__modsi3.o: $(src)/idiv32.S
4712 -       $(cmd_as_o_S)
4713 +$(obj)/__modsi3.o: $(src)/idiv32.S FORCE
4714 +       $(call if_changed_dep,as_o_S)
4715  
4716 -$(obj)/__umodsi3.o: $(src)/idiv32.S
4717 -       $(cmd_as_o_S)
4718 +$(obj)/__umodsi3.o: $(src)/idiv32.S FORCE
4719 +       $(call if_changed_dep,as_o_S)
4720 diff -Nru a/arch/ia64/mm/numa.c b/arch/ia64/mm/numa.c
4721 --- a/arch/ia64/mm/numa.c       Mon Sep 30 06:38:28 2002
4722 +++ b/arch/ia64/mm/numa.c       Thu Aug 21 05:02:28 2003
4723 @@ -42,5 +42,5 @@
4724                     paddr < node_memblk[i].start_paddr + node_memblk[i].size)
4725                         break;
4726  
4727 -       return (i < num_memblks) ? node_memblk[i].nid : -1;
4728 +       return (i < num_memblks) ? node_memblk[i].nid : (num_memblks ? -1 : 0);
4729  }
4730 diff -Nru a/arch/ia64/sn/io/drivers/ioconfig_bus.c b/arch/ia64/sn/io/drivers/ioconfig_bus.c
4731 --- a/arch/ia64/sn/io/drivers/ioconfig_bus.c    Mon May 19 05:42:35 2003
4732 +++ b/arch/ia64/sn/io/drivers/ioconfig_bus.c    Sun Aug 31 16:14:08 2003
4733 @@ -346,9 +346,9 @@
4734  }
4735  
4736  struct file_operations ioconfig_bus_fops = {
4737 -       ioctl:ioconfig_bus_ioctl,
4738 -       open:ioconfig_bus_open,         /* open */
4739 -       release:ioconfig_bus_close      /* release */
4740 +       .ioctl = ioconfig_bus_ioctl,
4741 +       .open = ioconfig_bus_open,              /* open */
4742 +       .release = ioconfig_bus_close   /* release */
4743  };
4744  
4745  
4746 diff -Nru a/arch/ia64/sn/io/sn2/shub.c b/arch/ia64/sn/io/sn2/shub.c
4747 --- a/arch/ia64/sn/io/sn2/shub.c        Mon Aug  4 10:02:37 2003
4748 +++ b/arch/ia64/sn/io/sn2/shub.c        Sun Aug 31 16:14:08 2003
4749 @@ -243,7 +243,7 @@
4750  }
4751  
4752  struct file_operations shub_mon_fops = {
4753 -               ioctl:          shubstats_ioctl,
4754 +               .ioctl          = shubstats_ioctl,
4755  };
4756  
4757  /*
4758 diff -Nru a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
4759 --- a/arch/ia64/sn/kernel/setup.c       Sat Aug 16 16:26:35 2003
4760 +++ b/arch/ia64/sn/kernel/setup.c       Sun Aug 31 16:14:08 2003
4761 @@ -117,14 +117,14 @@
4762   * VGA color display.
4763   */
4764  struct screen_info sn_screen_info = {
4765 -       orig_x:                  0,
4766 -       orig_y:                  0,
4767 -       orig_video_mode:         3,
4768 -       orig_video_cols:        80,
4769 -       orig_video_ega_bx:       3,
4770 -       orig_video_lines:       25,
4771 -       orig_video_isVGA:        1,
4772 -       orig_video_points:      16
4773 +       .orig_x                 = 0,
4774 +       .orig_y                 = 0,
4775 +       .orig_video_mode        = 3,
4776 +       .orig_video_cols        = 80,
4777 +       .orig_video_ega_bx      = 3,
4778 +       .orig_video_lines       = 25,
4779 +       .orig_video_isVGA       = 1,
4780 +       .orig_video_points      = 16
4781  };
4782  
4783  /*
4784 diff -Nru a/arch/m68k/Kconfig b/arch/m68k/Kconfig
4785 --- a/arch/m68k/Kconfig Sat Aug  2 14:26:16 2003
4786 +++ b/arch/m68k/Kconfig Sun Aug 31 16:14:22 2003
4787 @@ -342,40 +342,6 @@
4788  
4789  menu "General setup"
4790  
4791 -choice
4792 -       prompt "Kernel core (/proc/kcore) format"
4793 -       depends on PROC_FS
4794 -       default KCORE_ELF
4795 -
4796 -config KCORE_ELF
4797 -       bool "ELF"
4798 -       ---help---
4799 -         If you enabled support for /proc file system then the file
4800 -         /proc/kcore will contain the kernel core image. This can be used
4801 -         in gdb:
4802 -
4803 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
4804 -
4805 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
4806 -         /proc/kcore appear in ELF core format as defined by the Executable
4807 -         and Linking Format specification. Selecting A.OUT will choose the
4808 -         old "a.out" format which may be necessary for some old versions
4809 -         of binutils or on some architectures.
4810 -
4811 -         This is especially useful if you have compiled the kernel with the
4812 -         "-g" option to preserve debugging information. It is mainly used
4813 -         for examining kernel data structures on the live kernel so if you
4814 -         don't understand what this means or are not a kernel hacker, just
4815 -         leave it at its default value ELF.
4816 -
4817 -config KCORE_AOUT
4818 -       bool "A.OUT"
4819 -       help
4820 -         Not necessary unless you're using a very out-of-date binutils
4821 -         version.  You probably want KCORE_ELF.
4822 -
4823 -endchoice
4824 -
4825  source "fs/Kconfig.binfmt"
4826  
4827  config ZORRO
4828 diff -Nru a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
4829 --- /dev/null   Wed Dec 31 16:00:00 1969
4830 +++ b/arch/m68k/kernel/vmlinux-std.lds  Sun Jun 15 03:46:43 2003
4831 @@ -0,0 +1,97 @@
4832 +/* ld script to make m68k Linux kernel */
4833 +
4834 +#include <asm-generic/vmlinux.lds.h>
4835 +
4836 +OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
4837 +OUTPUT_ARCH(m68k)
4838 +ENTRY(_start)
4839 +jiffies = jiffies_64 + 4;
4840 +SECTIONS
4841 +{
4842 +  . = 0x1000;
4843 +  _text = .;                   /* Text and read-only data */
4844 +  .text : {
4845 +       *(.text)
4846 +       *(.fixup)
4847 +       *(.gnu.warning)
4848 +       } = 0x4e75
4849 +
4850 +  . = ALIGN(16);               /* Exception table */
4851 +  __start___ex_table = .;
4852 +  __ex_table : { *(__ex_table) }
4853 +  __stop___ex_table = .;
4854 +
4855 +  RODATA
4856 +
4857 +  _etext = .;                  /* End of text section */
4858 +
4859 +  .data : {                    /* Data */
4860 +       *(.data)
4861 +       CONSTRUCTORS
4862 +       }
4863 +
4864 +  .bss : { *(.bss) }           /* BSS */
4865 +
4866 +  . = ALIGN(16);
4867 +  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
4868 +
4869 +  _edata = .;                  /* End of data section */
4870 +
4871 +  /* will be freed after init */
4872 +  . = ALIGN(4096);             /* Init code and data */
4873 +  __init_begin = .;
4874 +  .init.text : { 
4875 +       _sinittext = .;
4876 +       *(.init.text)
4877 +       _einittext = .;
4878 +  }
4879 +  .init.data : { *(.init.data) }
4880 +  . = ALIGN(16);
4881 +  __setup_start = .;
4882 +  .init.setup : { *(.init.setup) }
4883 +  __setup_end = .;
4884 +  __start___param = .;
4885 +  __param : { *(__param) }
4886 +  __stop___param = .;
4887 +  __initcall_start = .;
4888 +  .initcall.init : {
4889 +       *(.initcall1.init) 
4890 +       *(.initcall2.init) 
4891 +       *(.initcall3.init) 
4892 +       *(.initcall4.init) 
4893 +       *(.initcall5.init) 
4894 +       *(.initcall6.init) 
4895 +       *(.initcall7.init)
4896 +  }
4897 +  __initcall_end = .;
4898 +  __con_initcall_start = .;
4899 +  .con_initcall.init : { *(.con_initcall.init) }
4900 +  __con_initcall_end = .;
4901 +  SECURITY_INIT
4902 +  . = ALIGN(8192);
4903 +  __initramfs_start = .;
4904 +  .init.ramfs : { *(.init.ramfs) }
4905 +  __initramfs_end = .;
4906 +  . = ALIGN(8192);
4907 +  __init_end = .;
4908 +
4909 +  .data.init_task : { *(.data.init_task) }     /* The initial task and kernel stack */
4910 +
4911 +  _end = . ;
4912 +
4913 +  /* Sections to be discarded */
4914 +  /DISCARD/ : {
4915 +       *(.exit.text)
4916 +       *(.exit.data)
4917 +       *(.exitcall.exit)
4918 +       }
4919 +
4920 +  /* Stabs debugging sections.  */
4921 +  .stab 0 : { *(.stab) }
4922 +  .stabstr 0 : { *(.stabstr) }
4923 +  .stab.excl 0 : { *(.stab.excl) }
4924 +  .stab.exclstr 0 : { *(.stab.exclstr) }
4925 +  .stab.index 0 : { *(.stab.index) }
4926 +  .stab.indexstr 0 : { *(.stab.indexstr) }
4927 +  .comment 0 : { *(.comment) }
4928 +}
4929 diff -Nru a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
4930 --- /dev/null   Wed Dec 31 16:00:00 1969
4931 +++ b/arch/m68k/kernel/vmlinux-sun3.lds Sun Jun 15 03:46:43 2003
4932 @@ -0,0 +1,97 @@
4933 +/* ld script to make m68k Linux kernel */
4934 +
4935 +#include <asm-generic/vmlinux.lds.h>
4936 +
4937 +OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
4938 +OUTPUT_ARCH(m68k)
4939 +ENTRY(_start)
4940 +jiffies = jiffies_64 + 4;
4941 +SECTIONS
4942 +{
4943 +  . = 0xE004000;
4944 +  _text = .;                   /* Text and read-only data */
4945 +  .text : {
4946 +       *(.head)
4947 +       *(.text)
4948 +       *(.fixup)
4949 +       *(.gnu.warning)
4950 +       } = 0x4e75
4951 +       RODATA
4952 +
4953 +  _etext = .;                  /* End of text section */
4954 +
4955 +  .data : {                    /* Data */
4956 +       *(.data)
4957 +       CONSTRUCTORS
4958 +       . = ALIGN(16);          /* Exception table */
4959 +       __start___ex_table = .;
4960 +       *(__ex_table) 
4961 +       __stop___ex_table = .;
4962 +       }
4963 +  /* End of data goes *here* so that freeing init code works properly. */
4964 +  _edata = .;
4965 +
4966 +  /* will be freed after init */
4967 +  . = ALIGN(8192);     /* Init code and data */
4968 +__init_begin = .;
4969 +       .init.text : { 
4970 +               _sinittext = .;
4971 +               *(.init.text)
4972 +               _einittext = .;
4973 +       }
4974 +       .init.data : { *(.init.data) }
4975 +       . = ALIGN(16);
4976 +       __setup_start = .;
4977 +       .init.setup : { *(.init.setup) }
4978 +       __setup_end = .;
4979 +       __start___param = .;
4980 +       __param : { *(__param) }
4981 +       __stop___param = .;
4982 +       __initcall_start = .;
4983 +       .initcall.init : {
4984 +               *(.initcall1.init) 
4985 +               *(.initcall2.init) 
4986 +               *(.initcall3.init) 
4987 +               *(.initcall4.init) 
4988 +               *(.initcall5.init) 
4989 +               *(.initcall6.init) 
4990 +               *(.initcall7.init)
4991 +       }
4992 +       __initcall_end = .;
4993 +       __con_initcall_start = .;
4994 +       .con_initcall.init : { *(.con_initcall.init) }
4995 +       __con_initcall_end = .;
4996 +       SECURITY_INIT
4997 +       . = ALIGN(8192);
4998 +       __initramfs_start = .;
4999 +       .init.ramfs : { *(.init.ramfs) }
5000 +       __initramfs_end = .;
5001 +       . = ALIGN(8192);
5002 +       __init_end = .;
5003 +       .init.task : { *(init_task) }
5004 +       
5005 +
5006 +  .bss : { *(.bss) }           /* BSS */
5007 +
5008 +  _end = . ;
5009 +
5010 +  /* Sections to be discarded */
5011 +  /DISCARD/ : {
5012 +       *(.exit.text)
5013 +       *(.exit.data)
5014 +       *(.exitcall.exit)
5015 +       }
5016 +
5017 +  .crap : {
5018 +       /* Stabs debugging sections.  */
5019 +       *(.stab)
5020 +       *(.stabstr)
5021 +       *(.stab.excl)
5022 +       *(.stab.exclstr)
5023 +       *(.stab.index)
5024 +       *(.stab.indexstr)
5025 +       *(.comment)
5026 +       *(.note)
5027 +  }
5028 +
5029 +}
5030 diff -Nru a/arch/m68k/vmlinux-std.lds b/arch/m68k/vmlinux-std.lds
5031 --- a/arch/m68k/vmlinux-std.lds Wed Jun 11 17:40:05 2003
5032 +++ /dev/null   Wed Dec 31 16:00:00 1969
5033 @@ -1,97 +0,0 @@
5034 -/* ld script to make m68k Linux kernel */
5035 -
5036 -#include <asm-generic/vmlinux.lds.h>
5037 -
5038 -OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
5039 -OUTPUT_ARCH(m68k)
5040 -ENTRY(_start)
5041 -jiffies = jiffies_64 + 4;
5042 -SECTIONS
5043 -{
5044 -  . = 0x1000;
5045 -  _text = .;                   /* Text and read-only data */
5046 -  .text : {
5047 -       *(.text)
5048 -       *(.fixup)
5049 -       *(.gnu.warning)
5050 -       } = 0x4e75
5051 -
5052 -  . = ALIGN(16);               /* Exception table */
5053 -  __start___ex_table = .;
5054 -  __ex_table : { *(__ex_table) }
5055 -  __stop___ex_table = .;
5056 -
5057 -  RODATA
5058 -
5059 -  _etext = .;                  /* End of text section */
5060 -
5061 -  .data : {                    /* Data */
5062 -       *(.data)
5063 -       CONSTRUCTORS
5064 -       }
5065 -
5066 -  .bss : { *(.bss) }           /* BSS */
5067 -
5068 -  . = ALIGN(16);
5069 -  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
5070 -
5071 -  _edata = .;                  /* End of data section */
5072 -
5073 -  /* will be freed after init */
5074 -  . = ALIGN(4096);             /* Init code and data */
5075 -  __init_begin = .;
5076 -  .init.text : { 
5077 -       _sinittext = .;
5078 -       *(.init.text)
5079 -       _einittext = .;
5080 -  }
5081 -  .init.data : { *(.init.data) }
5082 -  . = ALIGN(16);
5083 -  __setup_start = .;
5084 -  .init.setup : { *(.init.setup) }
5085 -  __setup_end = .;
5086 -  __start___param = .;
5087 -  __param : { *(__param) }
5088 -  __stop___param = .;
5089 -  __initcall_start = .;
5090 -  .initcall.init : {
5091 -       *(.initcall1.init) 
5092 -       *(.initcall2.init) 
5093 -       *(.initcall3.init) 
5094 -       *(.initcall4.init) 
5095 -       *(.initcall5.init) 
5096 -       *(.initcall6.init) 
5097 -       *(.initcall7.init)
5098 -  }
5099 -  __initcall_end = .;
5100 -  __con_initcall_start = .;
5101 -  .con_initcall.init : { *(.con_initcall.init) }
5102 -  __con_initcall_end = .;
5103 -  SECURITY_INIT
5104 -  . = ALIGN(8192);
5105 -  __initramfs_start = .;
5106 -  .init.ramfs : { *(.init.ramfs) }
5107 -  __initramfs_end = .;
5108 -  . = ALIGN(8192);
5109 -  __init_end = .;
5110 -
5111 -  .data.init_task : { *(.data.init_task) }     /* The initial task and kernel stack */
5112 -
5113 -  _end = . ;
5114 -
5115 -  /* Sections to be discarded */
5116 -  /DISCARD/ : {
5117 -       *(.exit.text)
5118 -       *(.exit.data)
5119 -       *(.exitcall.exit)
5120 -       }
5121 -
5122 -  /* Stabs debugging sections.  */
5123 -  .stab 0 : { *(.stab) }
5124 -  .stabstr 0 : { *(.stabstr) }
5125 -  .stab.excl 0 : { *(.stab.excl) }
5126 -  .stab.exclstr 0 : { *(.stab.exclstr) }
5127 -  .stab.index 0 : { *(.stab.index) }
5128 -  .stab.indexstr 0 : { *(.stab.indexstr) }
5129 -  .comment 0 : { *(.comment) }
5130 -}
5131 diff -Nru a/arch/m68k/vmlinux-sun3.lds b/arch/m68k/vmlinux-sun3.lds
5132 --- a/arch/m68k/vmlinux-sun3.lds        Wed Jun 11 17:40:05 2003
5133 +++ /dev/null   Wed Dec 31 16:00:00 1969
5134 @@ -1,97 +0,0 @@
5135 -/* ld script to make m68k Linux kernel */
5136 -
5137 -#include <asm-generic/vmlinux.lds.h>
5138 -
5139 -OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
5140 -OUTPUT_ARCH(m68k)
5141 -ENTRY(_start)
5142 -jiffies = jiffies_64 + 4;
5143 -SECTIONS
5144 -{
5145 -  . = 0xE004000;
5146 -  _text = .;                   /* Text and read-only data */
5147 -  .text : {
5148 -       *(.head)
5149 -       *(.text)
5150 -       *(.fixup)
5151 -       *(.gnu.warning)
5152 -       } = 0x4e75
5153 -       RODATA
5154 -
5155 -  _etext = .;                  /* End of text section */
5156 -
5157 -  .data : {                    /* Data */
5158 -       *(.data)
5159 -       CONSTRUCTORS
5160 -       . = ALIGN(16);          /* Exception table */
5161 -       __start___ex_table = .;
5162 -       *(__ex_table) 
5163 -       __stop___ex_table = .;
5164 -       }
5165 -  /* End of data goes *here* so that freeing init code works properly. */
5166 -  _edata = .;
5167 -
5168 -  /* will be freed after init */
5169 -  . = ALIGN(8192);     /* Init code and data */
5170 -__init_begin = .;
5171 -       .init.text : { 
5172 -               _sinittext = .;
5173 -               *(.init.text)
5174 -               _einittext = .;
5175 -       }
5176 -       .init.data : { *(.init.data) }
5177 -       . = ALIGN(16);
5178 -       __setup_start = .;
5179 -       .init.setup : { *(.init.setup) }
5180 -       __setup_end = .;
5181 -       __start___param = .;
5182 -       __param : { *(__param) }
5183 -       __stop___param = .;
5184 -       __initcall_start = .;
5185 -       .initcall.init : {
5186 -               *(.initcall1.init) 
5187 -               *(.initcall2.init) 
5188 -               *(.initcall3.init) 
5189 -               *(.initcall4.init) 
5190 -               *(.initcall5.init) 
5191 -               *(.initcall6.init) 
5192 -               *(.initcall7.init)
5193 -       }
5194 -       __initcall_end = .;
5195 -       __con_initcall_start = .;
5196 -       .con_initcall.init : { *(.con_initcall.init) }
5197 -       __con_initcall_end = .;
5198 -       SECURITY_INIT
5199 -       . = ALIGN(8192);
5200 -       __initramfs_start = .;
5201 -       .init.ramfs : { *(.init.ramfs) }
5202 -       __initramfs_end = .;
5203 -       . = ALIGN(8192);
5204 -       __init_end = .;
5205 -       .init.task : { *(init_task) }
5206 -       
5207 -
5208 -  .bss : { *(.bss) }           /* BSS */
5209 -
5210 -  _end = . ;
5211 -
5212 -  /* Sections to be discarded */
5213 -  /DISCARD/ : {
5214 -       *(.exit.text)
5215 -       *(.exit.data)
5216 -       *(.exitcall.exit)
5217 -       }
5218 -
5219 -  .crap : {
5220 -       /* Stabs debugging sections.  */
5221 -       *(.stab)
5222 -       *(.stabstr)
5223 -       *(.stab.excl)
5224 -       *(.stab.exclstr)
5225 -       *(.stab.index)
5226 -       *(.stab.indexstr)
5227 -       *(.comment)
5228 -       *(.note)
5229 -  }
5230 -
5231 -}
5232 diff -Nru a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
5233 --- a/arch/m68knommu/Kconfig    Sat Aug  2 14:26:16 2003
5234 +++ b/arch/m68knommu/Kconfig    Sun Aug 31 16:14:22 2003
5235 @@ -490,14 +490,6 @@
5236  
5237  menu "Executable file formats"
5238  
5239 -config KCORE_AOUT
5240 -       bool
5241 -       default y
5242 -
5243 -config KCORE_ELF
5244 -       bool
5245 -       default y
5246 -
5247  source "fs/Kconfig.binfmt"
5248  
5249  endmenu
5250 diff -Nru a/arch/m68knommu/platform/5206/config.c b/arch/m68knommu/platform/5206/config.c
5251 --- a/arch/m68knommu/platform/5206/config.c     Tue May 27 20:13:12 2003
5252 +++ b/arch/m68knommu/platform/5206/config.c     Sat Aug 23 06:07:40 2003
5253 @@ -14,6 +14,7 @@
5254  #include <linux/sched.h>
5255  #include <linux/param.h>
5256  #include <linux/init.h>
5257 +#include <linux/interrupt.h>
5258  #include <asm/irq.h>
5259  #include <asm/dma.h>
5260  #include <asm/traps.h>
5261 @@ -26,7 +27,7 @@
5262  /***************************************************************************/
5263  
5264  void coldfire_tick(void);
5265 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
5266 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
5267  unsigned long coldfire_timer_offset(void);
5268  void coldfire_trap_init(void);
5269  void coldfire_reset(void);
5270 diff -Nru a/arch/m68knommu/platform/5206e/config.c b/arch/m68knommu/platform/5206e/config.c
5271 --- a/arch/m68knommu/platform/5206e/config.c    Tue May 27 20:13:12 2003
5272 +++ b/arch/m68knommu/platform/5206e/config.c    Sat Aug 23 06:07:40 2003
5273 @@ -12,6 +12,7 @@
5274  #include <linux/kernel.h>
5275  #include <linux/sched.h>
5276  #include <linux/param.h>
5277 +#include <linux/interrupt.h>
5278  #include <asm/irq.h>
5279  #include <asm/dma.h>
5280  #include <asm/traps.h>
5281 @@ -26,7 +27,7 @@
5282  /***************************************************************************/
5283  
5284  void coldfire_tick(void);
5285 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
5286 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
5287  unsigned long coldfire_timer_offset(void);
5288  void coldfire_trap_init(void);
5289  void coldfire_reset(void);
5290 diff -Nru a/arch/m68knommu/platform/5249/config.c b/arch/m68knommu/platform/5249/config.c
5291 --- a/arch/m68knommu/platform/5249/config.c     Tue Jun 17 06:35:38 2003
5292 +++ b/arch/m68knommu/platform/5249/config.c     Sat Aug 23 06:07:40 2003
5293 @@ -26,7 +26,7 @@
5294  /***************************************************************************/
5295  
5296  void coldfire_tick(void);
5297 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
5298 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
5299  unsigned long coldfire_timer_offset(void);
5300  void coldfire_trap_init(void);
5301  void coldfire_reset(void);
5302 diff -Nru a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c
5303 --- a/arch/m68knommu/platform/5272/config.c     Tue Jun 17 06:35:38 2003
5304 +++ b/arch/m68knommu/platform/5272/config.c     Sat Aug 23 06:07:40 2003
5305 @@ -14,6 +14,7 @@
5306  #include <linux/sched.h>
5307  #include <linux/param.h>
5308  #include <linux/init.h>
5309 +#include <linux/interrupt.h>
5310  #include <asm/irq.h>
5311  #include <asm/dma.h>
5312  #include <asm/traps.h>
5313 @@ -27,7 +28,7 @@
5314  /***************************************************************************/
5315  
5316  void coldfire_tick(void);
5317 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
5318 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
5319  unsigned long coldfire_timer_offset(void);
5320  void coldfire_trap_init(void);
5321  void coldfire_reset(void);
5322 diff -Nru a/arch/mips/Kconfig b/arch/mips/Kconfig
5323 --- a/arch/mips/Kconfig Mon Jul 28 04:57:50 2003
5324 +++ b/arch/mips/Kconfig Sun Aug 31 16:14:22 2003
5325 @@ -1126,31 +1126,6 @@
5326  
5327  menu "Executable file formats"
5328  
5329 -config KCORE_ELF
5330 -       bool
5331 -       default y
5332 -       ---help---
5333 -         If you enabled support for /proc file system then the file
5334 -         /proc/kcore will contain the kernel core image. This can be used
5335 -         in gdb:
5336 -
5337 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
5338 -
5339 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
5340 -         /proc/kcore appear in ELF core format as defined by the Executable
5341 -         and Linking Format specification. Selecting A.OUT will choose the
5342 -         old "a.out" format which may be necessary for some old versions
5343 -         of binutils or on some architectures.
5344 -
5345 -         This is especially useful if you have compiled the kernel with the
5346 -         "-g" option to preserve debugging information. It is mainly used
5347 -         for examining kernel data structures on the live kernel so if you
5348 -         don't understand what this means or are not a kernel hacker, just
5349 -         leave it at its default value ELF.
5350 -
5351 -config KCORE_AOUT
5352 -       bool
5353 -
5354  source "fs/Kconfig.binfmt"
5355  
5356  config TRAD_SIGNALS
5357 diff -Nru a/arch/mips/au1000/common/dma.c b/arch/mips/au1000/common/dma.c
5358 --- a/arch/mips/au1000/common/dma.c     Mon Jun 23 12:12:26 2003
5359 +++ b/arch/mips/au1000/common/dma.c     Sun Aug 31 16:14:08 2003
5360 @@ -62,14 +62,14 @@
5361  spinlock_t au1000_dma_spin_lock = SPIN_LOCK_UNLOCKED;
5362  
5363  struct dma_chan au1000_dma_table[NUM_AU1000_DMA_CHANNELS] = {
5364 -      {dev_id:-1,},
5365 -      {dev_id:-1,},
5366 -      {dev_id:-1,},
5367 -      {dev_id:-1,},
5368 -      {dev_id:-1,},
5369 -      {dev_id:-1,},
5370 -      {dev_id:-1,},
5371 -      {dev_id:-1,}
5372 +      {.dev_id = -1,},
5373 +      {.dev_id = -1,},
5374 +      {.dev_id = -1,},
5375 +      {.dev_id = -1,},
5376 +      {.dev_id = -1,},
5377 +      {.dev_id = -1,},
5378 +      {.dev_id = -1,},
5379 +      {.dev_id = -1,}
5380  };
5381  
5382  // Device FIFO addresses and default DMA modes
5383 diff -Nru a/arch/mips/kernel/ioctl32.c b/arch/mips/kernel/ioctl32.c
5384 --- a/arch/mips/kernel/ioctl32.c        Mon Jul 28 04:57:50 2003
5385 +++ b/arch/mips/kernel/ioctl32.c        Sun Aug 31 16:14:44 2003
5386 @@ -810,8 +810,7 @@
5387  #define IOCTL_TABLE_START \
5388         struct ioctl_trans ioctl_start[] = {
5389  #define IOCTL_TABLE_END \
5390 -       }; struct ioctl_trans ioctl_end[0];
5391 -
5392 +       };
5393  
5394  IOCTL_TABLE_START
5395  #include <linux/compat_ioctl.h>
5396 @@ -1205,6 +1204,8 @@
5397  COMPATIBLE_IOCTL(RTC_WKALM_SET)
5398  COMPATIBLE_IOCTL(RTC_WKALM_RD)
5399  IOCTL_TABLE_END
5400 +
5401 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
5402  
5403  #define NR_IOCTL_TRANS         (sizeof(ioctl_translations) /   \
5404                                  sizeof(ioctl_translations[0]))
5405 diff -Nru a/arch/mips/sibyte/cfe/console.c b/arch/mips/sibyte/cfe/console.c
5406 --- a/arch/mips/sibyte/cfe/console.c    Mon Jul 28 04:57:50 2003
5407 +++ b/arch/mips/sibyte/cfe/console.c    Sun Aug 31 16:14:08 2003
5408 @@ -9,7 +9,6 @@
5409  #include "cfe_error.h"
5410  
5411  extern int cfe_cons_handle;
5412 -static kdev_t cfe_consdev;
5413  
5414  static void cfe_console_write(struct console *cons, const char *str,
5415                        unsigned int count)
5416 @@ -57,15 +56,12 @@
5417  #ifdef CONFIG_SIBYTE_SB1250_DUART
5418                 if (!strcmp(consdev, "uart0")) {
5419                         setleds("u0cn");
5420 -//                     cfe_consdev = MKDEV(TTY_MAJOR, SB1250_DUART_MINOR_BASE + 0);
5421                 } else if (!strcmp(consdev, "uart1")) {
5422                         setleds("u1cn");
5423 -//                     cfe_consdev = MKDEV(TTY_MAJOR, SB1250_DUART_MINOR_BASE + 1);
5424  #endif
5425  #ifdef CONFIG_VGA_CONSOLE
5426                 } else if (!strcmp(consdev, "pcconsole0")) {
5427                         setleds("pccn");
5428 -//                     cfe_consdev = MKDEV(TTY_MAJOR, 0);
5429  #endif
5430                 } else
5431                         return -ENODEV;
5432 @@ -74,12 +70,12 @@
5433  }
5434  
5435  static struct console sb1250_cfe_cons = {
5436 -       name:           "cfe",
5437 -       write:          cfe_console_write,
5438 -       device:         cfe_console_device,
5439 -       setup:          cfe_console_setup,
5440 -       flags:          CON_PRINTBUFFER,
5441 -       index:          -1,
5442 +       .name           = "cfe",
5443 +       .write          = cfe_console_write,
5444 +       .device         = cfe_console_device,
5445 +       .setup          = cfe_console_setup,
5446 +       .flags          = CON_PRINTBUFFER,
5447 +       .index          = -1,
5448  };
5449  
5450  static int __init sb1250_cfe_console_init(void)
5451 diff -Nru a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c
5452 --- a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c  Mon Jul 28 04:57:50 2003
5453 +++ b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c  Tue Aug 26 09:25:40 2003
5454 @@ -253,7 +253,7 @@
5455  {
5456         int minor;
5457  
5458 -       minor = minor(inode->i_rdev);
5459 +       minor = iminor(inode);
5460         if (minor != 0) {
5461                 return -ENODEV;
5462         }
5463 @@ -278,7 +278,7 @@
5464  {
5465         int minor;
5466  
5467 -       minor = minor(inode->i_rdev);
5468 +       minor = iminor(inode);
5469         if (minor != 0 || !sbp.open) {
5470                 return -ENODEV;
5471         }
5472 diff -Nru a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
5473 --- a/arch/mips/tx4927/common/tx4927_irq.c      Mon Apr 14 20:10:10 2003
5474 +++ b/arch/mips/tx4927/common/tx4927_irq.c      Sun Aug 31 16:14:08 2003
5475 @@ -149,26 +149,26 @@
5476  
5477  #define TX4927_CP0_NAME "TX4927-CP0"
5478  static struct hw_interrupt_type tx4927_irq_cp0_type = {
5479 -       typename:       TX4927_CP0_NAME,
5480 -       startup:        tx4927_irq_cp0_startup,
5481 -       shutdown:       tx4927_irq_cp0_shutdown,
5482 -       enable:         tx4927_irq_cp0_enable,
5483 -       disable:        tx4927_irq_cp0_disable,
5484 -       ack:            tx4927_irq_cp0_mask_and_ack,
5485 -       end:            tx4927_irq_cp0_end,
5486 -       set_affinity:   NULL
5487 +       .typename       = TX4927_CP0_NAME,
5488 +       .startup        = tx4927_irq_cp0_startup,
5489 +       .shutdown       = tx4927_irq_cp0_shutdown,
5490 +       .enable         = tx4927_irq_cp0_enable,
5491 +       .disable        = tx4927_irq_cp0_disable,
5492 +       .ack            = tx4927_irq_cp0_mask_and_ack,
5493 +       .end            = tx4927_irq_cp0_end,
5494 +       .set_affinity   = NULL
5495  };
5496  
5497  #define TX4927_PIC_NAME "TX4927-PIC"
5498  static struct hw_interrupt_type tx4927_irq_pic_type = {
5499 -       typename:       TX4927_PIC_NAME,
5500 -       startup:        tx4927_irq_pic_startup,
5501 -       shutdown:       tx4927_irq_pic_shutdown,
5502 -       enable:         tx4927_irq_pic_enable,
5503 -       disable:        tx4927_irq_pic_disable,
5504 -       ack:            tx4927_irq_pic_mask_and_ack,
5505 -       end:            tx4927_irq_pic_end,
5506 -       set_affinity:   NULL
5507 +       .typename       = TX4927_PIC_NAME,
5508 +       .startup        = tx4927_irq_pic_startup,
5509 +       .shutdown       = tx4927_irq_pic_shutdown,
5510 +       .enable         = tx4927_irq_pic_enable,
5511 +       .disable        = tx4927_irq_pic_disable,
5512 +       .ack            = tx4927_irq_pic_mask_and_ack,
5513 +       .end            = tx4927_irq_pic_end,
5514 +       .set_affinity   = NULL
5515  };
5516  
5517  #define TX4927_PIC_ACTION(s) { no_action, 0, 0, s, NULL, NULL }
5518 diff -Nru a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
5519 --- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c  Thu Jul  3 15:17:43 2003
5520 +++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c  Sun Aug 31 16:14:08 2003
5521 @@ -255,14 +255,14 @@
5522  
5523  #define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC"
5524  static struct hw_interrupt_type toshiba_rbtx4927_irq_ioc_type = {
5525 -       typename:TOSHIBA_RBTX4927_IOC_NAME,
5526 -       startup:toshiba_rbtx4927_irq_ioc_startup,
5527 -       shutdown:toshiba_rbtx4927_irq_ioc_shutdown,
5528 -       enable:toshiba_rbtx4927_irq_ioc_enable,
5529 -       disable:toshiba_rbtx4927_irq_ioc_disable,
5530 -       ack:toshiba_rbtx4927_irq_ioc_mask_and_ack,
5531 -       end:toshiba_rbtx4927_irq_ioc_end,
5532 -       set_affinity:NULL
5533 +       .typename = TOSHIBA_RBTX4927_IOC_NAME,
5534 +       .startup = toshiba_rbtx4927_irq_ioc_startup,
5535 +       .shutdown = toshiba_rbtx4927_irq_ioc_shutdown,
5536 +       .enable = toshiba_rbtx4927_irq_ioc_enable,
5537 +       .disable = toshiba_rbtx4927_irq_ioc_disable,
5538 +       .ack = toshiba_rbtx4927_irq_ioc_mask_and_ack,
5539 +       .end = toshiba_rbtx4927_irq_ioc_end,
5540 +       .set_affinity = NULL
5541  };
5542  #define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000
5543  #define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006
5544 @@ -271,14 +271,14 @@
5545  #ifdef CONFIG_TOSHIBA_FPCIB0
5546  #define TOSHIBA_RBTX4927_ISA_NAME "RBTX4927-ISA"
5547  static struct hw_interrupt_type toshiba_rbtx4927_irq_isa_type = {
5548 -       typename:TOSHIBA_RBTX4927_ISA_NAME,
5549 -       startup:toshiba_rbtx4927_irq_isa_startup,
5550 -       shutdown:toshiba_rbtx4927_irq_isa_shutdown,
5551 -       enable:toshiba_rbtx4927_irq_isa_enable,
5552 -       disable:toshiba_rbtx4927_irq_isa_disable,
5553 -       ack:toshiba_rbtx4927_irq_isa_mask_and_ack,
5554 -       end:toshiba_rbtx4927_irq_isa_end,
5555 -       set_affinity:NULL
5556 +       .typename = TOSHIBA_RBTX4927_ISA_NAME,
5557 +       .startup = toshiba_rbtx4927_irq_isa_startup,
5558 +       .shutdown = toshiba_rbtx4927_irq_isa_shutdown,
5559 +       .enable = toshiba_rbtx4927_irq_isa_enable,
5560 +       .disable = toshiba_rbtx4927_irq_isa_disable,
5561 +       .ack = toshiba_rbtx4927_irq_isa_mask_and_ack,
5562 +       .end = toshiba_rbtx4927_irq_isa_end,
5563 +       .set_affinity = NULL
5564  };
5565  #endif
5566  
5567 diff -Nru a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c
5568 --- a/arch/mips/vr41xx/common/vrc4173.c Thu Jul 31 08:59:17 2003
5569 +++ b/arch/mips/vr41xx/common/vrc4173.c Sun Aug 31 16:14:08 2003
5570 @@ -250,10 +250,10 @@
5571  }
5572  
5573  static struct pci_driver vrc4173_driver = {
5574 -       name:           "NEC VRC4173",
5575 -       probe:          vrc4173_probe,
5576 -       remove:         NULL,
5577 -       id_table:       vrc4173_table,
5578 +       .name           = "NEC VRC4173",
5579 +       .probe          = vrc4173_probe,
5580 +       .remove         = NULL,
5581 +       .id_table       = vrc4173_table,
5582  };
5583  
5584  static int __devinit vrc4173_init(void)
5585 diff -Nru a/arch/parisc/Kconfig b/arch/parisc/Kconfig
5586 --- a/arch/parisc/Kconfig       Sat Aug  2 14:26:16 2003
5587 +++ b/arch/parisc/Kconfig       Sun Aug 31 16:14:22 2003
5588 @@ -161,11 +161,6 @@
5589  
5590  menu "Executable file formats"
5591  
5592 -config KCORE_ELF
5593 -       bool
5594 -       depends on PROC_FS
5595 -       default y
5596 -
5597  source "fs/Kconfig.binfmt"
5598  
5599  endmenu
5600 diff -Nru a/arch/parisc/kernel/ioctl32.c b/arch/parisc/kernel/ioctl32.c
5601 --- a/arch/parisc/kernel/ioctl32.c      Fri May  2 10:22:56 2003
5602 +++ b/arch/parisc/kernel/ioctl32.c      Sun Aug 31 16:14:44 2003
5603 @@ -1426,7 +1426,7 @@
5604                 return -EINVAL;
5605                         
5606         tty = (struct tty_struct *)file->private_data;
5607 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
5608 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
5609                 return -EINVAL;
5610                                                         
5611         if (tty->driver->ioctl != vt_ioctl)
5612 @@ -2458,7 +2458,7 @@
5613  #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd, sys_ioctl) 
5614  
5615  #define IOCTL_TABLE_START  struct ioctl_trans ioctl_start[] = {
5616 -#define IOCTL_TABLE_END    }; struct ioctl_trans ioctl_end[0];
5617 +#define IOCTL_TABLE_END    };
5618  
5619  IOCTL_TABLE_START
5620  #include <linux/compat_ioctl.h>
5621 @@ -2631,3 +2631,4 @@
5622  #endif /* DRM */
5623  IOCTL_TABLE_END
5624  
5625 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
5626 diff -Nru a/arch/ppc/8260_io/uart.c b/arch/ppc/8260_io/uart.c
5627 --- a/arch/ppc/8260_io/uart.c   Wed Jun 11 12:32:53 2003
5628 +++ b/arch/ppc/8260_io/uart.c   Tue Aug 26 09:25:39 2003
5629 @@ -50,6 +50,10 @@
5630  #include <asm/cpm_8260.h>
5631  #include <asm/irq.h>
5632  
5633 +#ifdef CONFIG_MAGIC_SYSRQ
5634 +#include <linux/sysrq.h>
5635 +#endif
5636 +
5637  #ifdef CONFIG_SERIAL_CONSOLE
5638  #include <linux/console.h>
5639  
5640 @@ -77,6 +81,14 @@
5641  static struct tty_driver *serial_driver;
5642  static int serial_console_setup(struct console *co, char *options);
5643  
5644 +static void serial_console_write(struct console *c, const char *s,
5645 +                                               unsigned count);
5646 +static kdev_t serial_console_device(struct console *c);
5647 +
5648 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
5649 +static unsigned long break_pressed; /* break, really ... */
5650 +#endif
5651 +
5652  /*
5653   * Serial driver configuration section.  Here are the various options:
5654   */
5655 @@ -208,6 +220,15 @@
5656         cbd_t                   *tx_cur;
5657  } ser_info_t;
5658  
5659 +static struct console sercons = {
5660 +       .name =         "ttyS",
5661 +       .write =        serial_console_write,
5662 +       .device =       serial_console_device,
5663 +       .setup =        serial_console_setup,
5664 +       .flags =        CON_PRINTBUFFER,
5665 +       .index =        CONFIG_SERIAL_CONSOLE_PORT,
5666 +};
5667 +
5668  static void change_speed(ser_info_t *info);
5669  static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout);
5670  
5671 @@ -328,7 +349,7 @@
5672         schedule_work(&info->tqueue);
5673  }
5674  
5675 -static _INLINE_ void receive_chars(ser_info_t *info)
5676 +static _INLINE_ void receive_chars(ser_info_t *info, struct pt_regs *regs)
5677  {
5678         struct tty_struct *tty = info->tty;
5679         unsigned char ch, *cp;
5680 @@ -450,6 +471,19 @@
5681                                         }
5682                                 }
5683                         }
5684 +
5685 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
5686 +                       if (break_pressed && info->line == sercons.index) {
5687 +                               if (ch != 0 && time_before(jiffies,
5688 +                                                       break_pressed + HZ*5)) {
5689 +                                       handle_sysrq(ch, regs, NULL, NULL);
5690 +                                       break_pressed = 0;
5691 +                                       goto ignore_char;
5692 +                               } else
5693 +                                       break_pressed = 0;
5694 +                       }
5695 +#endif
5696 +                       
5697                         if (tty->flip.count >= TTY_FLIPBUF_SIZE)
5698                                 break;
5699  
5700 @@ -458,6 +492,10 @@
5701                         tty->flip.count++;
5702                 }
5703  
5704 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
5705 +       ignore_char:
5706 +#endif
5707 +
5708                 /* This BD is ready to be used again.  Clear status.
5709                  * Get next BD.
5710                  */
5711 @@ -475,7 +513,36 @@
5712         schedule_delayed_work(&tty->flip.work, 1);
5713  }
5714  
5715 -static _INLINE_ void transmit_chars(ser_info_t *info)
5716 +static _INLINE_ void receive_break(ser_info_t *info, struct pt_regs *regs)
5717 +{
5718 +       struct tty_struct *tty = info->tty;
5719 +
5720 +       info->state->icount.brk++;
5721 +
5722 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
5723 +       if (info->line == sercons.index) {
5724 +               if (!break_pressed) {
5725 +                       break_pressed = jiffies;
5726 +                       return;
5727 +               } else
5728 +                       break_pressed = 0;
5729 +       }
5730 +#endif
5731 +
5732 +       /* Check to see if there is room in the tty buffer for
5733 +        * the break.  If not, we exit now, losing the break.  FIXME
5734 +        */
5735 +       if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE)
5736 +               return;
5737 +       *(tty->flip.flag_buf_ptr++) = TTY_BREAK;
5738 +       *(tty->flip.char_buf_ptr++) = 0;
5739 +       tty->flip.count++;
5740 +
5741 +       queue_task(&tty->flip.tqueue, &tq_timer);
5742 +}
5743 +
5744 +
5745 +static _INLINE_ void transmit_chars(ser_info_t *info, struct pt_regs *regs)
5746  {
5747         
5748         if (info->flags & TX_WAKEUP) {
5749 @@ -575,19 +642,23 @@
5750         if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
5751                 smcp = &immr->im_smc[idx];
5752                 events = smcp->smc_smce;
5753 +               if (events & SMCM_BRKE)
5754 +                       receive_break(info, regs);
5755                 if (events & SMCM_RX)
5756 -                       receive_chars(info);
5757 +                       receive_chars(info, regs);
5758                 if (events & SMCM_TX)
5759 -                       transmit_chars(info);
5760 +                       transmit_chars(info, regs);
5761                 smcp->smc_smce = events;
5762         }
5763         else {
5764                 sccp = &immr->im_scc[idx - SCC_IDX_BASE];
5765                 events = sccp->scc_scce;
5766 +               if (events & SMCM_BRKE)
5767 +                       receive_break(info, regs);
5768                 if (events & SCCM_RX)
5769 -                       receive_chars(info);
5770 +                       receive_chars(info, regs);
5771                 if (events & SCCM_TX)
5772 -                       transmit_chars(info);
5773 +                       transmit_chars(info, regs);
5774                 sccp->scc_scce = events;
5775         }
5776         
5777 @@ -2207,7 +2278,7 @@
5778  static void serial_console_write(struct console *c, const char *s,
5779                                 unsigned count)
5780  {
5781 -#if defined(CONFIG_KGDB) && !defined(CONFIG_USE_SERIAL2_KGDB)
5782 +#if defined(CONFIG_KGDB_CONSOLE) && !defined(CONFIG_USE_SERIAL2_KGDB)
5783         /* Try to let stub handle output. Returns true if it did. */ 
5784         if (kgdb_output_string(s, count))
5785                 return;
5786 @@ -2391,21 +2462,11 @@
5787  }
5788  #endif
5789  
5790 -static kdev_t serial_console_device(struct console *c)
5791 +static struct tty_driver *serial_console_device(struct console *c, int *index)
5792  {
5793         *index = c->index;
5794         return serial_driver;
5795  }
5796 -
5797 -
5798 -static struct console sercons = {
5799 -       .name =         "ttyS",
5800 -       .write =        serial_console_write,
5801 -       .device =       serial_console_device,
5802 -       .setup =        serial_console_setup,
5803 -       .flags =        CON_PRINTBUFFER,
5804 -       .index =        CONFIG_SERIAL_CONSOLE_PORT,
5805 -};
5806  
5807  /*
5808   *     Register console.
5809 diff -Nru a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
5810 --- a/arch/ppc/8xx_io/cs4218_tdm.c      Tue Jul 15 10:01:29 2003
5811 +++ b/arch/ppc/8xx_io/cs4218_tdm.c      Tue Aug 26 09:25:40 2003
5812 @@ -2106,11 +2106,11 @@
5813          */
5814         cs4218_ctl_write(cs4218_control);
5815  
5816 -       sound.minDev = MINOR(inode->i_rdev) & 0x0f;
5817 +       sound.minDev = iminor(inode) & 0x0f;
5818         sound.soft = sound.dsp;
5819         sound.hard = sound.dsp;
5820         sound_init();
5821 -       if ((MINOR(inode->i_rdev) & 0x0f) == SND_DEV_AUDIO) {
5822 +       if ((iminor(inode) & 0x0f) == SND_DEV_AUDIO) {
5823                 sound_set_speed(8000);
5824                 sound_set_stereo(0);
5825                 sound_set_format(AFMT_MU_LAW);
5826 diff -Nru a/arch/ppc/8xx_io/uart.c b/arch/ppc/8xx_io/uart.c
5827 --- a/arch/ppc/8xx_io/uart.c    Wed Jun 11 12:32:54 2003
5828 +++ b/arch/ppc/8xx_io/uart.c    Thu Aug 21 15:10:37 2003
5829 @@ -1068,7 +1068,7 @@
5830         volatile cbd_t *bdp;
5831         unsigned char   *cp;
5832  
5833 -#ifdef CONFIG_KGDB
5834 +#ifdef CONFIG_KGDB_CONSOLE
5835          /* Try to let stub handle output. Returns true if it did. */ 
5836          if (kgdb_output_string(buf, count))
5837              return ret;
5838 @@ -2271,7 +2271,7 @@
5839  static void serial_console_write(struct console *c, const char *s,
5840                                 unsigned count)
5841  {
5842 -#ifdef CONFIG_KGDB
5843 +#ifdef CONFIG_KGDB_CONSOLE
5844         /* Try to let stub handle output. Returns true if it did. */ 
5845         if (kgdb_output_string(s, count))
5846                 return;
5847 diff -Nru a/arch/ppc/Kconfig b/arch/ppc/Kconfig
5848 --- a/arch/ppc/Kconfig  Mon Aug  4 16:10:57 2003
5849 +++ b/arch/ppc/Kconfig  Sun Aug 31 16:14:22 2003
5850 @@ -795,22 +795,6 @@
5851         bool "PCI for Permedia2"
5852         depends on !4xx && !8xx && APUS
5853  
5854 -# only elf supported, a.out is not -- Cort
5855 -config KCORE_ELF
5856 -       bool
5857 -       depends on PROC_FS
5858 -       default y
5859 -       help
5860 -         If you enabled support for /proc file system then the file
5861 -         /proc/kcore will contain the kernel core image in ELF format. This
5862 -         can be used in gdb:
5863 -
5864 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
5865 -
5866 -         This is especially useful if you have compiled the kernel with the
5867 -         "-g" option to preserve debugging information. It is mainly used
5868 -         for examining kernel data structures on the live kernel.
5869 -
5870  config KERNEL_ELF
5871         bool
5872         default y
5873 @@ -1277,16 +1261,11 @@
5874           floppy controller, say Y here. Most commonly found in PowerMacs.
5875  
5876  config MAC_SERIAL
5877 -       tristate "Support for PowerMac serial ports"
5878 +       tristate "Support for PowerMac serial ports (OBSOLETE DRIVER)"
5879         depends on PPC_PMAC
5880         help
5881 -         If you have Macintosh style serial ports (8 pin mini-DIN), say Y
5882 -         here. If you also have regular serial ports and enable the driver
5883 -         for them, you can't currently use the serial console feature.
5884 -
5885 -config SERIAL_CONSOLE
5886 -       bool "Support for console on serial port"
5887 -       depends on PPC_PMAC && MAC_SERIAL=y
5888 +         This driver is obsolete. Use CONFIG_SERIAL_PMACZILOG in
5889 +         "Character devices --> Serial drivers --> PowerMac z85c30" option.
5890  
5891  config ADB
5892         bool "Apple Desktop Bus (ADB) support"
5893 @@ -1426,20 +1405,12 @@
5894  config KGDB
5895         bool "Include kgdb kernel debugger"
5896         depends on DEBUG_KERNEL
5897 +       select DEBUG_INFO
5898         help
5899           Include in-kernel hooks for kgdb, the Linux kernel source level
5900           debugger.  See <http://kgdb.sourceforge.net/> for more information.
5901           Unless you are intending to debug the kernel, say N here.
5902  
5903 -config DEBUG_INFO
5904 -       bool "Compile the kernel with debug info"
5905 -       depends on DEBUG_KERNEL
5906 -       help
5907 -          If you say Y here the resulting kernel image will include
5908 -         debugging info resulting in a larger kernel image.
5909 -         Say Y here only if you plan to use gdb to debug the kernel.
5910 -         If you don't debug the kernel, you can say N.
5911 -         
5912  choice
5913         prompt "Serial Port"
5914         depends on KGDB
5915 @@ -1459,6 +1430,14 @@
5916  
5917  endchoice
5918  
5919 +config KGDB_CONSOLE
5920 +       bool "Enable serial console thru kgdb port"
5921 +       depends on KGDB && 8xx || 8260
5922 +       help
5923 +         If you enable this, all serial console messages will be sent
5924 +         over the gdb stub.
5925 +         If unsure, say N.
5926 +
5927  config XMON
5928         bool "Include xmon kernel debugger"
5929         depends on DEBUG_KERNEL
5930 @@ -1474,18 +1453,16 @@
5931           Unless you are intending to debug the kernel with one of these
5932           machines, say N here.
5933  
5934 -config MORE_COMPILE_OPTIONS
5935 -       bool "Add any additional compile options"
5936 -       depends on DEBUG_KERNEL && (KGDB || XMON || BDI_SWITCH)
5937 -       help
5938 -         If you want to add additional CFLAGS to the kernel build, such as -g
5939 -         for KGDB or the BDI2000, enable this option and then enter what you
5940 -         would like to add in the next question.
5941 -
5942 -config COMPILE_OPTIONS
5943 -       string "Additional compile arguments"
5944 -       depends on MORE_COMPILE_OPTIONS
5945 -       default "-g -ggdb"
5946 +config DEBUG_INFO
5947 +       bool "Compile the kernel with debug info"
5948 +       depends on DEBUG_KERNEL
5949 +       default y if BDI_SWITCH || XMON
5950 +       help
5951 +          If you say Y here the resulting kernel image will include
5952 +         debugging info resulting in a larger kernel image.
5953 +         Say Y here only if you plan to use some sort of debugger to
5954 +         debug the kernel.
5955 +         If you don't debug the kernel, you can say N.
5956  
5957  config BOOTX_TEXT
5958         bool "Support for early boot text console (BootX or OpenFirmware only)"
5959 diff -Nru a/arch/ppc/Makefile b/arch/ppc/Makefile
5960 --- a/arch/ppc/Makefile Sun Jul 27 15:52:30 2003
5961 +++ b/arch/ppc/Makefile Thu Aug 21 15:10:37 2003
5962 @@ -22,9 +22,6 @@
5963  
5964  cflags-$(CONFIG_4xx)           += -Wa,-m405
5965  cflags-$(CONFIG_PPC64BRIDGE)   += -Wa,-mppc64bridge
5966 -# Use sed to remove the quotes.
5967 -cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \
5968 -       $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
5969  
5970  CFLAGS += $(cflags-y)
5971  
5972 diff -Nru a/arch/ppc/boot/common/ns16550.c b/arch/ppc/boot/common/ns16550.c
5973 --- a/arch/ppc/boot/common/ns16550.c    Sat Jun 28 11:06:53 2003
5974 +++ b/arch/ppc/boot/common/ns16550.c    Wed Aug 20 10:24:16 2003
5975 @@ -60,7 +60,7 @@
5976         else {
5977                 /* Input clock. */
5978                 outb(com_port + (UART_DLL << shift),
5979 -                    (BASE_BAUD / SERIAL_BAUD));
5980 +                    (BASE_BAUD / SERIAL_BAUD) & 0xFF);
5981                 outb(com_port + (UART_DLM << shift),
5982                      (BASE_BAUD / SERIAL_BAUD) >> 8);
5983                 /* 8 data, 1 stop, no parity */
5984 diff -Nru a/arch/ppc/boot/common/util.S b/arch/ppc/boot/common/util.S
5985 --- a/arch/ppc/boot/common/util.S       Tue Feb 25 11:37:43 2003
5986 +++ b/arch/ppc/boot/common/util.S       Thu Aug 21 10:17:00 2003
5987 @@ -160,9 +160,22 @@
5988         blr
5989  
5990  
5991 +/* udelay (on non-601 processors) needs to know the period of the
5992 + * timebase in nanoseconds.  This used to be hardcoded to be 60ns
5993 + * (period of 66MHz/4).  Now a variable is used that is initialized to
5994 + * 60 for backward compatibility, but it can be overridden as necessary
5995 + * with code something like this:
5996 + *    extern unsigned long timebase_period_ns;
5997 + *    timebase_period_ns = 1000000000 / bd->bi_tbfreq;
5998 + */
5999 +       .data
6000 +       .globl timebase_period_ns
6001 +timebase_period_ns:
6002 +       .long   60
6003 +
6004 +       .text
6005  /*
6006   * Delay for a number of microseconds
6007 - * -- Use the BUS timer (assumes 66MHz)
6008   */
6009         .globl  udelay
6010  udelay:
6011 @@ -180,8 +193,13 @@
6012  
6013  .udelay_not_601:
6014         mulli   r4,r3,1000      /* nanoseconds */
6015 -       addi    r4,r4,59
6016 -       li      r5,60
6017 +       /*  Change r4 to be the number of ticks using:  
6018 +        *      (nanoseconds + (timebase_period_ns - 1 )) / timebase_period_ns
6019 +        *  timebase_period_ns defaults to 60 (16.6MHz) */
6020 +       lis     r5,timebase_period_ns@h
6021 +       lwz     r5,timebase_period_ns@l(r5)
6022 +       addi    r4,r4,r5
6023 +       addi    r4,r4,-1
6024         divw    r4,r4,r5        /* BUS ticks */
6025  1:     mftbu   r5
6026         mftb    r6
6027 diff -Nru a/arch/ppc/boot/include/of1275.h b/arch/ppc/boot/include/of1275.h
6028 --- a/arch/ppc/boot/include/of1275.h    Mon Sep 16 21:58:06 2002
6029 +++ b/arch/ppc/boot/include/of1275.h    Mon Aug 25 05:13:38 2003
6030 @@ -20,6 +20,7 @@
6031  /* function declarations */
6032  
6033  void * claim(unsigned int virt, unsigned int size, unsigned int align);
6034 +int    map(unsigned int phys, unsigned int virt, unsigned int size);
6035  void   enter(void);
6036  void   exit(void);
6037  phandle        finddevice(const char *name);
6038 diff -Nru a/arch/ppc/boot/ld.script b/arch/ppc/boot/ld.script
6039 --- a/arch/ppc/boot/ld.script   Thu May 29 04:06:53 2003
6040 +++ b/arch/ppc/boot/ld.script   Mon Aug 25 05:13:38 2003
6041 @@ -66,7 +66,7 @@
6042    _edata  =  .;
6043    PROVIDE (edata = .);
6044  
6045 -  . = ALIGN(8);
6046 +  . = ALIGN(4096);
6047    __bss_start = .;
6048    .bss       :
6049    {
6050 diff -Nru a/arch/ppc/boot/of1275/Makefile b/arch/ppc/boot/of1275/Makefile
6051 --- a/arch/ppc/boot/of1275/Makefile     Sun Jun  8 01:12:49 2003
6052 +++ b/arch/ppc/boot/of1275/Makefile     Mon Aug 25 09:36:40 2003
6053 @@ -3,4 +3,4 @@
6054  #
6055  
6056  lib-y := claim.o enter.o exit.o finddevice.o getprop.o ofinit.o        \
6057 -        ofstdio.o read.o release.o write.o
6058 +        ofstdio.o read.o release.o write.o map.o
6059 diff -Nru a/arch/ppc/boot/of1275/map.c b/arch/ppc/boot/of1275/map.c
6060 --- /dev/null   Wed Dec 31 16:00:00 1969
6061 +++ b/arch/ppc/boot/of1275/map.c        Mon Aug 25 09:36:40 2003
6062 @@ -0,0 +1,50 @@
6063
6064 +/*
6065 + * Copyright (C) Paul Mackerras 1997.
6066 + * Copyright (C) Leigh Brown 2002.
6067 + *
6068 + * This program is free software; you can redistribute it and/or
6069 + * modify it under the terms of the GNU General Public License
6070 + * as published by the Free Software Foundation; either version
6071 + * 2 of the License, or (at your option) any later version.
6072 + */
6073 +
6074 +#include "of1275.h"
6075 +#include "nonstdio.h"
6076 +
6077 +extern ihandle of_prom_mmu;
6078 +
6079 +int
6080 +map(unsigned int phys, unsigned int virt, unsigned int size)
6081 +{
6082 +    struct prom_args {
6083 +       char *service;
6084 +       int nargs;
6085 +       int nret;
6086 +       char *method;
6087 +       ihandle mmu_ihandle;    
6088 +       int misc;
6089 +       unsigned int phys;
6090 +       unsigned int virt;
6091 +       unsigned int size;
6092 +       int ret0;
6093 +       int ret1;
6094 +    } args;
6095 +
6096 +    if (of_prom_mmu == 0) {
6097 +       printf("map() called, no MMU found\n");
6098 +       return -1;
6099 +    }
6100 +    args.service = "call-method";
6101 +    args.nargs = 6;
6102 +    args.nret = 2;
6103 +    args.method = "map";
6104 +    args.mmu_ihandle = of_prom_mmu;
6105 +    args.misc = -1;
6106 +    args.phys = phys;
6107 +    args.virt = virt;
6108 +    args.size = size;
6109 +    (*of_prom_entry)(&args);
6110 +
6111 +    return (int)args.ret0;
6112 +}
6113 diff -Nru a/arch/ppc/boot/of1275/ofinit.c b/arch/ppc/boot/of1275/ofinit.c
6114 --- a/arch/ppc/boot/of1275/ofinit.c     Mon Sep 16 22:18:13 2002
6115 +++ b/arch/ppc/boot/of1275/ofinit.c     Mon Aug 25 05:13:38 2003
6116 @@ -11,9 +11,17 @@
6117  #include "of1275.h"
6118  
6119  prom_entry of_prom_entry;
6120 +ihandle of_prom_mmu;
6121  
6122  void
6123  ofinit(prom_entry prom_ptr)
6124  {
6125 +    phandle chosen;
6126 +
6127      of_prom_entry = prom_ptr;
6128 +   
6129 +    if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE)
6130 +       return;
6131 +    if (getprop(chosen, "mmu", &of_prom_mmu, sizeof(ihandle)) != 4)
6132 +       return;
6133  }
6134 diff -Nru a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile
6135 --- a/arch/ppc/boot/openfirmware/Makefile       Wed Jul 23 08:39:58 2003
6136 +++ b/arch/ppc/boot/openfirmware/Makefile       Mon Aug 25 05:13:38 2003
6137 @@ -22,7 +22,7 @@
6138  images := $(boot)/images
6139  
6140  OBJCOPY_ARGS   := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
6141 -COFF_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00700000 -Bstatic
6142 +COFF_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00500000 -Bstatic
6143  CHRP_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00800000
6144  NEWWORLD_LD_ARGS:= -T $(boot)/ld.script -e _start -Ttext 0x01000000
6145  
6146 diff -Nru a/arch/ppc/boot/openfirmware/coffmain.c b/arch/ppc/boot/openfirmware/coffmain.c
6147 --- a/arch/ppc/boot/openfirmware/coffmain.c     Thu Nov  7 03:31:11 2002
6148 +++ b/arch/ppc/boot/openfirmware/coffmain.c     Mon Aug 25 05:13:38 2003
6149 @@ -32,16 +32,16 @@
6150  char *begin_avail, *end_avail;
6151  char *avail_high;
6152  
6153 -#define RAM_START      0
6154 -#define RAM_END                (RAM_START + 0x800000)  /* only 8M mapped with BATs */
6155 -
6156 -#define PROG_START     RAM_START
6157 -#define PROG_SIZE      0x00700000
6158 -
6159  #define SCRATCH_SIZE   (128 << 10)
6160  
6161  static char heap[SCRATCH_SIZE];
6162  
6163 +static unsigned long ram_start = 0;
6164 +static unsigned long ram_end = 0x1000000;
6165 +static unsigned long prog_start = 0x800000;
6166 +static unsigned long prog_size = 0x800000;
6167 +
6168 +
6169  typedef void (*kernel_start_t)(int, int, void *);
6170  
6171  void boot(int a1, int a2, void *prom)
6172 @@ -52,32 +52,34 @@
6173      unsigned initrd_start, initrd_size;
6174      
6175      printf("coffboot starting: loaded at 0x%p\n", &_start);
6176 -    setup_bats(RAM_START);
6177 +    setup_bats(ram_start);
6178  
6179      initrd_size = (char *)(&__ramdisk_end) - (char *)(&__ramdisk_begin);
6180      if (initrd_size) {
6181 -       initrd_start = (RAM_END - initrd_size) & ~0xFFF;
6182 +       initrd_start = (ram_end - initrd_size) & ~0xFFF;
6183         a1 = initrd_start;
6184         a2 = initrd_size;
6185 -       claim(initrd_start, RAM_END - initrd_start, 0);
6186 +       claim(initrd_start, ram_end - initrd_start, 0);
6187         printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r",
6188                initrd_start, (char *)(&__ramdisk_begin), initrd_size);
6189         memcpy((char *)initrd_start, (char *)(&__ramdisk_begin), initrd_size);
6190 +       prog_size = initrd_start - prog_start;
6191      } else
6192         a2 = 0xdeadbeef;
6193  
6194      im = (char *)(&__image_begin);
6195      len = (char *)(&__image_end) - (char *)(&__image_begin);
6196 -    /* claim 4MB starting at 0 */
6197 -    claim(0, PROG_SIZE, 0);
6198 -    dst = (void *) RAM_START;
6199 +    /* claim 4MB starting at PROG_START */
6200 +    claim(prog_start, prog_size, 0);
6201 +    map(prog_start, prog_start, prog_size);
6202 +    dst = (void *) prog_start;
6203      if (im[0] == 0x1f && im[1] == 0x8b) {
6204         /* set up scratch space */
6205         begin_avail = avail_high = avail_ram = heap;
6206         end_avail = heap + sizeof(heap);
6207         printf("heap at 0x%p\n", avail_ram);
6208         printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
6209 -       gunzip(dst, PROG_SIZE, im, &len);
6210 +       gunzip(dst, prog_size, im, &len);
6211         printf("done %u bytes\n", len);
6212         printf("%u bytes of heap consumed, max in use %u\n",
6213                avail_high - begin_avail, heap_max);
6214 @@ -87,9 +89,9 @@
6215  
6216      flush_cache(dst, len);
6217      make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac,
6218 -                   (PROG_START + PROG_SIZE));
6219 +                   (prog_start + prog_size));
6220  
6221 -    sa = (unsigned long)PROG_START;
6222 +    sa = (unsigned long)prog_start;
6223      printf("start address = 0x%x\n", sa);
6224  
6225      (*(kernel_start_t)sa)(a1, a2, prom);
6226 diff -Nru a/arch/ppc/boot/openfirmware/misc.S b/arch/ppc/boot/openfirmware/misc.S
6227 --- a/arch/ppc/boot/openfirmware/misc.S Mon Sep 16 21:54:12 2002
6228 +++ b/arch/ppc/boot/openfirmware/misc.S Mon Aug 25 05:13:38 2003
6229 @@ -9,7 +9,7 @@
6230         .text
6231  
6232  /*
6233 - * Use the BAT3 registers to map the 1st 8MB of RAM to
6234 + * Use the BAT2 & 3 registers to map the 1st 16MB of RAM to
6235   * the address given as the 1st argument.
6236   */
6237         .globl  setup_bats
6238 @@ -22,6 +22,10 @@
6239         mtibatl 3,0                     /* invalidate BAT first */
6240         ori     3,3,4                   /* set up BAT registers for 601 */
6241         li      4,0x7f
6242 +       mtibatu 2,3
6243 +       mtibatl 2,4
6244 +       oris    3,3,0x80
6245 +       oris    4,4,0x80
6246         mtibatu 3,3
6247         mtibatl 3,4
6248         b       5f
6249 @@ -29,6 +33,12 @@
6250         mtibatu 3,0
6251         ori     3,3,0xff                /* set up BAT registers for 604 */
6252         li      4,2
6253 +       mtdbatl 2,4
6254 +       mtdbatu 2,3
6255 +       mtibatl 2,4
6256 +       mtibatu 2,3
6257 +       oris    3,3,0x80
6258 +       oris    4,4,0x80
6259         mtdbatl 3,4
6260         mtdbatu 3,3
6261         mtibatl 3,4
6262 diff -Nru a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
6263 --- a/arch/ppc/boot/simple/Makefile     Tue Jul  1 17:01:18 2003
6264 +++ b/arch/ppc/boot/simple/Makefile     Mon Aug 18 09:44:01 2003
6265 @@ -22,7 +22,6 @@
6266  # get_mem_size(), which is memory controller dependent.  Add in the correct
6267  # XXX_memory.o file for this to work, as well as editing the $(MISC) file.
6268  
6269 -boot: zImage
6270  
6271  boot                           := arch/ppc/boot
6272  common                         := $(boot)/common
6273 @@ -32,86 +31,90 @@
6274  
6275  # Normally, we use the 'misc.c' file for decompress_kernel and
6276  # whatnot.  Sometimes we need to override this however.
6277 -MISC                           := misc.o
6278 -ifeq ($(CONFIG_IBM_OPENBIOS),y)
6279 -ZIMAGE                         := zImage-TREE
6280 -ZIMAGEINITRD                   := zImage.initrd-TREE
6281 -END                            := treeboot
6282 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6283 -MISC                           := misc-embedded.o
6284 -endif
6285 -ifeq ($(CONFIG_EMBEDDEDBOOT),y)
6286 -TFTPIMAGE                      := /tftpboot/zImage.embedded
6287 -MISC                           := misc-embedded.o
6288 -endif
6289 -ifeq ($(CONFIG_EBONY),y)
6290 -ZIMAGE                         := zImage-TREE
6291 -ZIMAGEINITRD                   := zImage.initrd-TREE
6292 -END                            := ebony
6293 -ENTRYPOINT                     := 0x01000000
6294 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6295 -endif
6296 -ifeq ($(CONFIG_EV64260),y)
6297 -EXTRA                          := misc-ev64260.o
6298 -TFTPIMAGE                      := /tftpboot/zImage.ev64260
6299 -endif
6300 -ifeq ($(CONFIG_GEMINI),y)
6301 -ZIMAGE                         := zImage-STRIPELF
6302 -ZIMAGEINITRD                   := zImage.initrd-STRIPELF
6303 -END                            := gemini
6304 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6305 -endif
6306 -ifeq ($(CONFIG_K2),y)
6307 -EXTRA                          := legacy.o
6308 -TFTPIMAGE                      := /tftpboot/zImage.k2
6309 -endif
6310 -# kbuild-2.4 'feature', only one of these will ever by 'y' at a time.
6311 +misc-y := misc.o
6312 +
6313 +#
6314 +# See arch/ppc/kconfig and arch/ppc/platforms/Kconfig
6315 +# for definition of what platform each config option refer to.
6316 +#----------------------------------------------------------------------------
6317 +      zimage-$(CONFIG_IBM_OPENBIOS)    := zImage-TREE
6318 +zimageinitrd-$(CONFIG_IBM_OPENBIOS)    := zImage.initrd-TREE
6319 +         end-$(CONFIG_IBM_OPENBIOS)    := treeboot
6320 +   tftpimage-$(CONFIG_IBM_OPENBIOS)    := /tftpboot/zImage.$(end-y)
6321 +        misc-$(CONFIG_IBM_OPENBIOS)    := misc-embedded.o
6322 +
6323 +   tftpimage-$(CONFIG_EMBEDDEDBOOT)    :=  /tftpboot/zImage.embedded
6324 +        misc-$(CONFIG_EMBEDDEDBOOT)    := misc-embedded.o
6325 +
6326 +      zimage-$(CONFIG_EBONY)           := zImage-TREE
6327 +zimageinitrd-$(CONFIG_EBONY)           := zImage.initrd-TREE
6328 +     extra.o-$(CONFIG_EBONY)           := direct.o
6329 +         end-$(CONFIG_EBONY)           := ebony
6330 +  entrypoint-$(CONFIG_EBONY)           := 0x01000000
6331 +   tftpimage-$(CONFIG_EBONY)           := /tftpboot/zImage.$(end-y)
6332 +
6333 +     extra.o-$(CONFIG_EV64260)         := direct.o misc-ev64260.o
6334 +   tftpimage-$(CONFIG_EV64260)         := /tftpboot/zImage.ev64260
6335 +
6336 +      zimage-$(CONFIG_GEMINI)          := zImage-STRIPELF
6337 +zimageinitrd-$(CONFIG_GEMINI)          := zImage.initrd-STRIPELF
6338 +         end-$(CONFIG_GEMINI)          := gemini
6339 +   tftpimage-$(CONFIG_GEMINI)          := /tftpboot/zImage.$(end-y)
6340 +
6341 +     extra.o-$(CONFIG_K2)              := legacy.o
6342 +   tftpimage-$(CONFIG_K2)              := /tftpboot/zImage.k2
6343 +
6344 +# kconfig 'feature', only one of these will ever by 'y' at a time.
6345  # The rest will be unset.
6346 -ifeq ($(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750)$(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS),y)
6347 -ZIMAGE                         := zImage-PPLUS
6348 -ZIMAGEINITRD                   := zImage.initrd-PPLUS
6349 -TFTPIMAGE                      := /tftpboot/zImage.pplus
6350 -ZNETBOOT                       := zImage.pplus
6351 -ZNETBOOTRD                     := zImage.initrd.pplus
6352 -endif
6353 -ifeq ($(CONFIG_PPLUS),y)
6354 -EXTRA                          := legacy.o
6355 -endif
6356 -ifeq ($(CONFIG_PCORE)$(CONFIG_POWERPMC250),y)
6357 -ZIMAGE                         := zImage-STRIPELF
6358 -ZIMAGEINITRD                   := zImage.initrd-STRIPELF
6359 -EXTRA                          := chrpmap.o
6360 -END                            := pcore
6361 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6362 -endif
6363 -ifeq ($(CONFIG_SANDPOINT),y)
6364 -TFTPIMAGE                      := /tftpboot/zImage.sandpoint
6365 -endif
6366 -ifeq ($(CONFIG_SPRUCE),y)
6367 -ZIMAGE                         := zImage-TREE
6368 -ZIMAGEINITRD                   := zImage.initrd-TREE
6369 -END                            := spruce
6370 -ENTRYPOINT                     := 0x00800000
6371 -MISC                           := misc-spruce.o
6372 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6373 -endif
6374 -ifeq ($(CONFIG_SMP),y)
6375 -TFTPIMAGE                      += .smp
6376 -endif
6377 -ifeq ($(CONFIG_REDWOOD_4),y)
6378 +multi := $(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750) \
6379 +$(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS)
6380 +      zimage-$(multi)                  := zImage-PPLUS
6381 +zimageinitrd-$(multi)                  := zImage.initrd-PPLUS
6382 +   tftpimage-$(multi)                  := /tftpboot/zImage.pplus
6383 +    znetboot-$(multi)                  := zImage.pplus
6384 +  znetbootrd-$(multi)                  := zImage.initrd.pplus
6385 +
6386 +# Overrides previous assingment
6387 +     extra.o-$(CONFIG_PPLUS)           := legacy.o
6388 +
6389 +      zimage-$(CONFIG_PCORE)           := zImage-STRIPELF
6390 +zimageinitrd-$(CONFIG_PCORE)           := zImage.initrd-STRIPELF
6391 +     extra.o-$(CONFIG_PCORE)           := chrpmap.o
6392 +         end-$(CONFIG_PCORE)           := pcore
6393 +   tftpimage-$(CONFIG_PCORE)           := /tftpboot/zImage.$(end-y)
6394 +
6395 +      zimage-$(CONFIG_POWERPMC250)     := zImage-STRIPELF
6396 +zimageinitrd-$(CONFIG_POWERPMC250)     := zImage.initrd-STRIPELF
6397 +     extra.o-$(CONFIG_POWERPMC250)     := chrpmap.o
6398 +         end-$(CONFIG_POWERPMC250)     := pcore
6399 +   tftpimage-$(CONFIG_POWERPMC250)     := /tftpboot/zImage.$(end-y)
6400 +
6401 +   tftpimage-$(CONFIG_SANDPOINT)       := /tftpboot/zImage.sandpoint
6402 +
6403 +      zimage-$(CONFIG_SPRUCE)          := zImage-TREE
6404 +zimageinitrd-$(CONFIG_SPRUCE)          := zImage.initrd-TREE
6405 +         end-$(CONFIG_SPRUCE)          := spruce
6406 +  entrypoint-$(CONFIG_SPRUCE)          := 0x00800000
6407 +        misc-$(CONFIG_SPRUCE)          := misc-spruce.o
6408 +   tftpimage-$(CONFIG_SPRUCE)          := /tftpboot/zImage.$(end-y)
6409 +
6410 +
6411 +# tftp image is prefixed with .smp if compiled for SMP
6412 +tftpimage-$(CONFIG_SMP)        += .smp
6413 +
6414  # This is a treeboot that needs init functions until the
6415  # boot rom is sorted out (i.e. this is short lived)
6416 -EXTRA_AFLAGS                   := -Wa,-m405
6417 -EXTRA                          := rw4/rw4_init.o rw4/rw4_init_brd.o
6418 -endif
6419 +extra-aflags-$(CONFIG_REDWOOD_4)       := -Wa,-m405
6420 +extra.o-$(CONFIG_REDWOOD_4)            := rw4/rw4_init.o rw4/rw4_init_brd.o
6421 +EXTRA_AFLAGS := $(extra-aflags-y)
6422  
6423  # Linker args.  This specifies where the image will be run at.
6424 -LD_ARGS                                = -T $(boot)/ld.script \
6425 -                                       -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
6426 +LD_ARGS                                := -T $(boot)/ld.script \
6427 +                                  -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
6428  OBJCOPY_ARGS                   := -O elf32-powerpc
6429  
6430  # head.o and relocate.o must be at the start.
6431 -boot-y                         := head.o relocate.o $(EXTRA) $(MISC) 
6432 +boot-y                         := head.o relocate.o $(extra.o-y) $(misc-y) 
6433  boot-$(CONFIG_40x)             += embed_config.o
6434  boot-$(CONFIG_8xx)             += embed_config.o
6435  boot-$(CONFIG_8260)            += embed_config.o
6436 @@ -160,40 +163,40 @@
6437                 -R .stabstr -R .sysmap
6438  
6439  # Sort-of dummy rules, that let us format the image we want.
6440 -zImage: $(images)/$(ZIMAGE) $(obj)/zvmlinux
6441 +zImage: $(images)/$(zimage-y) $(obj)/zvmlinux
6442         cp -f $(obj)/zvmlinux $(images)/zImage.elf
6443         rm -f $(obj)/zvmlinux
6444  
6445 -zImage.initrd: $(images)/$(ZIMAGEINITRD) $(obj)/zvmlinux.initrd
6446 +zImage.initrd: $(images)/$(zimageinitrd-y) $(obj)/zvmlinux.initrd
6447         cp -f $(obj)/zvmlinux.initrd $(images)/zImage.initrd.elf
6448         rm -f $(obj)/zvmlinux.initrd
6449  
6450  znetboot: zImage
6451  ifneq ($(ZNETBOOT),)
6452 -       cp $(images)/$(ZNETBOOT) $(TFTPIMAGE)
6453 +       cp $(images)/$(ZNETBOOT) $(tftpimage-y)
6454  else
6455 -       cp $(images)/zImage.* $(TFTPIMAGE)
6456 +       cp $(images)/zImage.* $(tftpimage-y)
6457  endif
6458  
6459  znetboot.initrd: zImage.initrd
6460 -ifneq ($(ZNETBOOTRD),)
6461 -       cp $(images)/$(ZNETBOOTRD) $(TFTPIMAGE)
6462 +ifneq ($(znetbootrd-y),)
6463 +       cp $(images)/$(znetbootrd-y) $(tftpimage-y)
6464  else
6465 -       cp $(images)/zImage.* $(TFTPIMAGE)
6466 +       cp $(images)/zImage.* $(tftpimage-y)
6467  endif
6468  
6469  $(images)/zImage-STRIPELF: $(obj)/zvmlinux
6470 -       dd if=$(obj)/zvmlinux of=$(images)/zImage.$(END) skip=64 bs=1k
6471 +       dd if=$(obj)/zvmlinux of=$(images)/zImage.$(end-y) skip=64 bs=1k
6472  
6473  $(images)/zImage.initrd-STRIPELF: $(obj)/zvmlinux.initrd
6474 -       dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(END) \
6475 +       dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(end-y) \
6476                 skip=64 bs=1k
6477  
6478  $(images)/zImage-TREE: $(obj)/zvmlinux $(MKTREE)
6479 -       $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(END) $(ENTRYPOINT)
6480 +       $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(end-y) $(ENTRYPOINT)
6481  
6482  $(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE)
6483 -       $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(END) \
6484 +       $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \
6485                 $(ENTRYPOINT)
6486  
6487  $(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT)
6488 diff -Nru a/arch/ppc/boot/simple/embed_config.c b/arch/ppc/boot/simple/embed_config.c
6489 --- a/arch/ppc/boot/simple/embed_config.c       Sat Mar 22 17:18:48 2003
6490 +++ b/arch/ppc/boot/simple/embed_config.c       Thu Aug 21 10:17:00 2003
6491 @@ -20,6 +20,7 @@
6492  #ifdef CONFIG_40x
6493  #include <asm/io.h>
6494  #endif
6495 +extern unsigned long timebase_period_ns;
6496  
6497  /* For those boards that don't provide one.
6498  */
6499 @@ -768,6 +769,7 @@
6500  #if defined(CONFIG_REDWOOD_5) || defined (CONFIG_REDWOOD_6)
6501         bd->bi_tbfreq = 27 * 1000 * 1000;
6502  #endif
6503 +       timebase_period_ns = 1000000000 / bd->bi_tbfreq;
6504  }
6505  #endif /* CONFIG_BEECH */
6506  #endif /* CONFIG_IBM_OPENBIOS */
6507 diff -Nru a/arch/ppc/boot/simple/misc-embedded.c b/arch/ppc/boot/simple/misc-embedded.c
6508 --- a/arch/ppc/boot/simple/misc-embedded.c      Thu Jun  5 18:06:12 2003
6509 +++ b/arch/ppc/boot/simple/misc-embedded.c      Wed Aug 20 15:44:31 2003
6510 @@ -75,7 +75,7 @@
6511  extern void embed_config(bd_t **bp);
6512  
6513  unsigned long
6514 -decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *bp)
6515 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *bp)
6516  {
6517         char *cp, ch;
6518         int timer = 0, zimage_size;
6519 diff -Nru a/arch/ppc/boot/simple/misc-spruce.c b/arch/ppc/boot/simple/misc-spruce.c
6520 --- a/arch/ppc/boot/simple/misc-spruce.c        Tue Feb 11 15:48:52 2003
6521 +++ b/arch/ppc/boot/simple/misc-spruce.c        Wed Aug 20 15:44:31 2003
6522 @@ -147,7 +147,7 @@
6523  #define MEM_B2EA       0x60
6524  
6525  unsigned long
6526 -decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
6527 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
6528  {
6529         int timer = 0;
6530         char *cp, ch;
6531 diff -Nru a/arch/ppc/boot/simple/misc.c b/arch/ppc/boot/simple/misc.c
6532 --- a/arch/ppc/boot/simple/misc.c       Tue Feb 11 15:48:52 2003
6533 +++ b/arch/ppc/boot/simple/misc.c       Wed Aug 20 15:44:31 2003
6534 @@ -252,3 +252,10 @@
6535  
6536         return (struct bi_record *)rec_loc;
6537  }
6538 +
6539 +/* Allow decompress_kernel to be hooked into.  This is the default. */
6540 +void * __attribute__ ((weak))
6541 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
6542 +{
6543 +               return decompress_kernel(load_addr, num_words, cksum);
6544 +}
6545 diff -Nru a/arch/ppc/boot/simple/relocate.S b/arch/ppc/boot/simple/relocate.S
6546 --- a/arch/ppc/boot/simple/relocate.S   Tue Feb 11 15:48:52 2003
6547 +++ b/arch/ppc/boot/simple/relocate.S   Wed Aug 20 15:44:31 2003
6548 @@ -183,7 +183,7 @@
6549         mr      r4,r7           /* Program length */
6550         mr      r5,r6           /* Checksum */
6551         mr      r6,r11          /* Residual data */
6552 -       bl      decompress_kernel
6553 +       bl      load_kernel
6554  
6555         /*
6556          * Make sure the kernel knows we don't have things set in
6557 diff -Nru a/arch/ppc/boot/utils/mktree.c b/arch/ppc/boot/utils/mktree.c
6558 --- a/arch/ppc/boot/utils/mktree.c      Sun Sep 15 21:51:58 2002
6559 +++ b/arch/ppc/boot/utils/mktree.c      Thu Aug 21 15:00:42 2003
6560 @@ -86,7 +86,7 @@
6561         }
6562  
6563         cksum = 0;
6564 -       cp = (uint *)&bt;
6565 +       cp = (void *)&bt;
6566         for (i=0; i<sizeof(bt)/sizeof(uint); i++)
6567                 cksum += *cp++;
6568         
6569 diff -Nru a/arch/ppc/configs/common_defconfig b/arch/ppc/configs/common_defconfig
6570 --- a/arch/ppc/configs/common_defconfig Sat Aug  2 13:06:57 2003
6571 +++ b/arch/ppc/configs/common_defconfig Sat Aug 23 02:33:38 2003
6572 @@ -9,6 +9,7 @@
6573  # Code maturity level options
6574  #
6575  CONFIG_EXPERIMENTAL=y
6576 +# CONFIG_BROKEN is not set
6577  
6578  #
6579  # General setup
6580 @@ -18,9 +19,15 @@
6581  # CONFIG_BSD_PROCESS_ACCT is not set
6582  CONFIG_SYSCTL=y
6583  CONFIG_LOG_BUF_SHIFT=14
6584 +CONFIG_IKCONFIG=y
6585 +CONFIG_IKCONFIG_PROC=y
6586  # CONFIG_EMBEDDED is not set
6587 +CONFIG_KALLSYMS=y
6588  CONFIG_FUTEX=y
6589  CONFIG_EPOLL=y
6590 +CONFIG_IOSCHED_NOOP=y
6591 +CONFIG_IOSCHED_AS=y
6592 +CONFIG_IOSCHED_DEADLINE=y
6593  
6594  #
6595  # Loadable module support
6596 @@ -86,8 +93,8 @@
6597  CONFIG_PCI=y
6598  CONFIG_PCI_DOMAINS=y
6599  CONFIG_KCORE_ELF=y
6600 -CONFIG_BINFMT_ELF=y
6601  CONFIG_KERNEL_ELF=y
6602 +CONFIG_BINFMT_ELF=y
6603  CONFIG_BINFMT_MISC=m
6604  CONFIG_PCI_LEGACY_PROC=y
6605  CONFIG_PCI_NAMES=y
6606 @@ -126,6 +133,11 @@
6607  CONFIG_BOOT_LOAD=0x00800000
6608  
6609  #
6610 +# Generic Driver Options
6611 +#
6612 +# CONFIG_FW_LOADER is not set
6613 +
6614 +#
6615  # Memory Technology Devices (MTD)
6616  #
6617  # CONFIG_MTD is not set
6618 @@ -144,10 +156,12 @@
6619  # CONFIG_BLK_DEV_DAC960 is not set
6620  # CONFIG_BLK_DEV_UMEM is not set
6621  CONFIG_BLK_DEV_LOOP=y
6622 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
6623  # CONFIG_BLK_DEV_NBD is not set
6624  CONFIG_BLK_DEV_RAM=y
6625  CONFIG_BLK_DEV_RAM_SIZE=4096
6626  CONFIG_BLK_DEV_INITRD=y
6627 +CONFIG_LBD=y
6628  
6629  #
6630  # Multi-device support (RAID and LVM)
6631 @@ -155,40 +169,38 @@
6632  # CONFIG_MD is not set
6633  
6634  #
6635 -# ATA/IDE/MFM/RLL support
6636 +# ATA/ATAPI/MFM/RLL support
6637  #
6638  CONFIG_IDE=y
6639 -
6640 -#
6641 -# IDE, ATA and ATAPI Block devices
6642 -#
6643  CONFIG_BLK_DEV_IDE=y
6644  
6645  #
6646  # Please see Documentation/ide.txt for help/info on IDE drives
6647  #
6648 -# CONFIG_BLK_DEV_HD is not set
6649  CONFIG_BLK_DEV_IDEDISK=y
6650  # CONFIG_IDEDISK_MULTI_MODE is not set
6651  # CONFIG_IDEDISK_STROKE is not set
6652  CONFIG_BLK_DEV_IDECD=y
6653 +# CONFIG_BLK_DEV_IDETAPE is not set
6654  CONFIG_BLK_DEV_IDEFLOPPY=y
6655  CONFIG_BLK_DEV_IDESCSI=y
6656  # CONFIG_IDE_TASK_IOCTL is not set
6657 +# CONFIG_IDE_TASKFILE_IO is not set
6658  
6659  #
6660  # IDE chipset support/bugfixes
6661  #
6662  CONFIG_BLK_DEV_IDEPCI=y
6663 -CONFIG_BLK_DEV_GENERIC=y
6664  CONFIG_IDEPCI_SHARE_IRQ=y
6665 +# CONFIG_BLK_DEV_OFFBOARD is not set
6666 +CONFIG_BLK_DEV_GENERIC=y
6667 +# CONFIG_BLK_DEV_OPTI621 is not set
6668 +CONFIG_BLK_DEV_SL82C105=y
6669  CONFIG_BLK_DEV_IDEDMA_PCI=y
6670  # CONFIG_BLK_DEV_IDE_TCQ is not set
6671 -# CONFIG_BLK_DEV_OFFBOARD is not set
6672  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
6673  CONFIG_IDEDMA_PCI_AUTO=y
6674  # CONFIG_IDEDMA_ONLYDISK is not set
6675 -CONFIG_BLK_DEV_IDEDMA=y
6676  # CONFIG_IDEDMA_PCI_WIP is not set
6677  CONFIG_BLK_DEV_ADMA=y
6678  # CONFIG_BLK_DEV_AEC62XX is not set
6679 @@ -198,12 +210,12 @@
6680  # CONFIG_BLK_DEV_TRIFLEX is not set
6681  # CONFIG_BLK_DEV_CY82C693 is not set
6682  # CONFIG_BLK_DEV_CS5520 is not set
6683 +# CONFIG_BLK_DEV_CS5530 is not set
6684  # CONFIG_BLK_DEV_HPT34X is not set
6685  # CONFIG_BLK_DEV_HPT366 is not set
6686  # CONFIG_BLK_DEV_SC1200 is not set
6687  # CONFIG_BLK_DEV_PIIX is not set
6688  # CONFIG_BLK_DEV_NS87415 is not set
6689 -# CONFIG_BLK_DEV_OPTI621 is not set
6690  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
6691  CONFIG_BLK_DEV_PDC202XX_NEW=y
6692  # CONFIG_PDC202XX_FORCE is not set
6693 @@ -212,15 +224,17 @@
6694  # CONFIG_BLK_DEV_SLC90E66 is not set
6695  # CONFIG_BLK_DEV_TRM290 is not set
6696  # CONFIG_BLK_DEV_VIA82CXXX is not set
6697 -CONFIG_BLK_DEV_SL82C105=y
6698  CONFIG_BLK_DEV_IDE_PMAC=y
6699  CONFIG_BLK_DEV_IDEDMA_PMAC=y
6700  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
6701 -CONFIG_IDEDMA_AUTO=y
6702 +CONFIG_BLK_DEV_IDEDMA=y
6703  # CONFIG_IDEDMA_IVB is not set
6704 +CONFIG_IDEDMA_AUTO=y
6705 +# CONFIG_DMA_NONPCI is not set
6706 +# CONFIG_BLK_DEV_HD is not set
6707  
6708  #
6709 -# SCSI support
6710 +# SCSI device support
6711  #
6712  CONFIG_SCSI=y
6713  
6714 @@ -260,8 +274,6 @@
6715  # CONFIG_SCSI_AIC79XX is not set
6716  # CONFIG_SCSI_DPT_I2O is not set
6717  CONFIG_SCSI_ADVANSYS=m
6718 -# CONFIG_SCSI_IN2000 is not set
6719 -# CONFIG_SCSI_AM53C974 is not set
6720  # CONFIG_SCSI_MEGARAID is not set
6721  # CONFIG_SCSI_BUSLOGIC is not set
6722  # CONFIG_SCSI_CPQFCTS is not set
6723 @@ -270,11 +282,8 @@
6724  # CONFIG_SCSI_EATA_PIO is not set
6725  # CONFIG_SCSI_FUTURE_DOMAIN is not set
6726  # CONFIG_SCSI_GDTH is not set
6727 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
6728 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
6729  # CONFIG_SCSI_INITIO is not set
6730  # CONFIG_SCSI_INIA100 is not set
6731 -# CONFIG_SCSI_NCR53C7xx is not set
6732  CONFIG_SCSI_SYM53C8XX_2=y
6733  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
6734  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
6735 @@ -287,7 +296,6 @@
6736  # CONFIG_SCSI_QLOGIC_1280 is not set
6737  # CONFIG_SCSI_DC395x is not set
6738  # CONFIG_SCSI_DC390T is not set
6739 -# CONFIG_SCSI_U14_34F is not set
6740  # CONFIG_SCSI_NSP32 is not set
6741  # CONFIG_SCSI_DEBUG is not set
6742  CONFIG_SCSI_MESH=y
6743 @@ -321,8 +329,6 @@
6744  CONFIG_PACKET=y
6745  # CONFIG_PACKET_MMAP is not set
6746  # CONFIG_NETLINK_DEV is not set
6747 -CONFIG_NETFILTER=y
6748 -# CONFIG_NETFILTER_DEBUG is not set
6749  CONFIG_UNIX=y
6750  # CONFIG_NET_KEY is not set
6751  CONFIG_INET=y
6752 @@ -340,6 +346,16 @@
6753  # CONFIG_INET_IPCOMP is not set
6754  
6755  #
6756 +# IP: Virtual Server Configuration
6757 +#
6758 +# CONFIG_IP_VS is not set
6759 +# CONFIG_IPV6 is not set
6760 +# CONFIG_DECNET is not set
6761 +# CONFIG_BRIDGE is not set
6762 +CONFIG_NETFILTER=y
6763 +# CONFIG_NETFILTER_DEBUG is not set
6764 +
6765 +#
6766  # IP: Netfilter Configuration
6767  #
6768  CONFIG_IP_NF_CONNTRACK=m
6769 @@ -355,6 +371,7 @@
6770  CONFIG_IP_NF_MATCH_MARK=m
6771  CONFIG_IP_NF_MATCH_MULTIPORT=m
6772  CONFIG_IP_NF_MATCH_TOS=m
6773 +CONFIG_IP_NF_MATCH_RECENT=m
6774  CONFIG_IP_NF_MATCH_ECN=m
6775  CONFIG_IP_NF_MATCH_DSCP=m
6776  CONFIG_IP_NF_MATCH_AH_ESP=m
6777 @@ -386,8 +403,6 @@
6778  # CONFIG_IP_NF_ARPTABLES is not set
6779  CONFIG_IP_NF_COMPAT_IPCHAINS=m
6780  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
6781 -# CONFIG_IPV6 is not set
6782 -# CONFIG_XFRM_USER is not set
6783  
6784  #
6785  # SCTP Configuration (EXPERIMENTAL)
6786 @@ -397,8 +412,6 @@
6787  # CONFIG_ATM is not set
6788  # CONFIG_VLAN_8021Q is not set
6789  # CONFIG_LLC is not set
6790 -# CONFIG_DECNET is not set
6791 -# CONFIG_BRIDGE is not set
6792  # CONFIG_X25 is not set
6793  # CONFIG_LAPB is not set
6794  # CONFIG_NET_DIVERT is not set
6795 @@ -482,6 +495,7 @@
6796  # CONFIG_HAMACHI is not set
6797  # CONFIG_YELLOWFIN is not set
6798  # CONFIG_R8169 is not set
6799 +# CONFIG_SIS190 is not set
6800  # CONFIG_SK98LIN is not set
6801  # CONFIG_TIGON3 is not set
6802  
6803 @@ -553,7 +567,7 @@
6804  # Graphics support
6805  #
6806  CONFIG_FB=y
6807 -CONFIG_FB_CIRRUS=y
6808 +# CONFIG_FB_CIRRUS is not set
6809  # CONFIG_FB_PM2 is not set
6810  # CONFIG_FB_CYBER2000 is not set
6811  CONFIG_FB_OF=y
6812 @@ -606,11 +620,6 @@
6813  CONFIG_LOGO_LINUX_CLUT224=y
6814  
6815  #
6816 -# Old CD-ROM drivers (not SCSI, not IDE)
6817 -#
6818 -# CONFIG_CD_NO_IDESCSI is not set
6819 -
6820 -#
6821  # Input device support
6822  #
6823  CONFIG_INPUT=y
6824 @@ -636,6 +645,7 @@
6825  CONFIG_SERIO_I8042=y
6826  # CONFIG_SERIO_SERPORT is not set
6827  # CONFIG_SERIO_CT82C710 is not set
6828 +# CONFIG_SERIO_PCIPS2 is not set
6829  
6830  #
6831  # Input Device Drivers
6832 @@ -703,10 +713,12 @@
6833  #
6834  # I2C Hardware Sensors Mainboard support
6835  #
6836 +# CONFIG_I2C_ALI1535 is not set
6837  # CONFIG_I2C_ALI15X3 is not set
6838  # CONFIG_I2C_AMD756 is not set
6839  # CONFIG_I2C_AMD8111 is not set
6840  # CONFIG_I2C_I801 is not set
6841 +# CONFIG_I2C_NFORCE2 is not set
6842  # CONFIG_I2C_PIIX4 is not set
6843  # CONFIG_I2C_SIS96X is not set
6844  # CONFIG_I2C_VIAPRO is not set
6845 @@ -718,6 +730,7 @@
6846  # CONFIG_SENSORS_IT87 is not set
6847  # CONFIG_SENSORS_LM75 is not set
6848  # CONFIG_SENSORS_LM85 is not set
6849 +# CONFIG_SENSORS_LM78 is not set
6850  # CONFIG_SENSORS_VIA686A is not set
6851  # CONFIG_SENSORS_W83781D is not set
6852  # CONFIG_I2C_SENSOR is not set
6853 @@ -913,13 +926,70 @@
6854  # Sound
6855  #
6856  CONFIG_SOUND=m
6857 -CONFIG_DMASOUND_AWACS=m
6858 -CONFIG_DMASOUND=m
6859 +# CONFIG_DMASOUND_AWACS is not set
6860  
6861  #
6862  # Advanced Linux Sound Architecture
6863  #
6864 -# CONFIG_SND is not set
6865 +CONFIG_SND=m
6866 +CONFIG_SND_SEQUENCER=m
6867 +# CONFIG_SND_SEQ_DUMMY is not set
6868 +CONFIG_SND_OSSEMUL=y
6869 +CONFIG_SND_MIXER_OSS=m
6870 +CONFIG_SND_PCM_OSS=m
6871 +CONFIG_SND_SEQUENCER_OSS=y
6872 +# CONFIG_SND_VERBOSE_PRINTK is not set
6873 +# CONFIG_SND_DEBUG is not set
6874 +
6875 +#
6876 +# Generic devices
6877 +#
6878 +# CONFIG_SND_DUMMY is not set
6879 +# CONFIG_SND_VIRMIDI is not set
6880 +# CONFIG_SND_MTPAV is not set
6881 +# CONFIG_SND_SERIAL_U16550 is not set
6882 +# CONFIG_SND_MPU401 is not set
6883 +
6884 +#
6885 +# PCI devices
6886 +#
6887 +# CONFIG_SND_ALI5451 is not set
6888 +# CONFIG_SND_AZT3328 is not set
6889 +# CONFIG_SND_CS46XX is not set
6890 +# CONFIG_SND_CS4281 is not set
6891 +# CONFIG_SND_EMU10K1 is not set
6892 +# CONFIG_SND_KORG1212 is not set
6893 +# CONFIG_SND_NM256 is not set
6894 +# CONFIG_SND_RME32 is not set
6895 +# CONFIG_SND_RME96 is not set
6896 +# CONFIG_SND_RME9652 is not set
6897 +# CONFIG_SND_HDSP is not set
6898 +# CONFIG_SND_TRIDENT is not set
6899 +# CONFIG_SND_YMFPCI is not set
6900 +# CONFIG_SND_ALS4000 is not set
6901 +# CONFIG_SND_CMIPCI is not set
6902 +# CONFIG_SND_ENS1370 is not set
6903 +# CONFIG_SND_ENS1371 is not set
6904 +# CONFIG_SND_ES1938 is not set
6905 +# CONFIG_SND_ES1968 is not set
6906 +# CONFIG_SND_MAESTRO3 is not set
6907 +# CONFIG_SND_FM801 is not set
6908 +# CONFIG_SND_ICE1712 is not set
6909 +# CONFIG_SND_ICE1724 is not set
6910 +# CONFIG_SND_INTEL8X0 is not set
6911 +# CONFIG_SND_SONICVIBES is not set
6912 +# CONFIG_SND_VIA82XX is not set
6913 +# CONFIG_SND_VX222 is not set
6914 +
6915 +#
6916 +# ALSA PowerMac devices
6917 +#
6918 +CONFIG_SND_POWERMAC=m
6919 +
6920 +#
6921 +# ALSA USB devices
6922 +#
6923 +CONFIG_SND_USB_AUDIO=m
6924  
6925  #
6926  # Open Sound System
6927 @@ -998,6 +1068,7 @@
6928  #
6929  # USB Network adaptors
6930  #
6931 +# CONFIG_USB_AX8817X is not set
6932  # CONFIG_USB_CATC is not set
6933  # CONFIG_USB_KAWETH is not set
6934  # CONFIG_USB_PEGASUS is not set
6935 @@ -1074,7 +1145,6 @@
6936  # Kernel hacking
6937  #
6938  # CONFIG_DEBUG_KERNEL is not set
6939 -CONFIG_KALLSYMS=y
6940  CONFIG_BOOTX_TEXT=y
6941  
6942  #
6943 diff -Nru a/arch/ppc/configs/ibmchrp_defconfig b/arch/ppc/configs/ibmchrp_defconfig
6944 --- a/arch/ppc/configs/ibmchrp_defconfig        Tue Jul  1 17:01:18 2003
6945 +++ b/arch/ppc/configs/ibmchrp_defconfig        Sat Aug 23 02:33:38 2003
6946 @@ -9,6 +9,7 @@
6947  # Code maturity level options
6948  #
6949  CONFIG_EXPERIMENTAL=y
6950 +# CONFIG_BROKEN is not set
6951  
6952  #
6953  # General setup
6954 @@ -18,9 +19,15 @@
6955  # CONFIG_BSD_PROCESS_ACCT is not set
6956  CONFIG_SYSCTL=y
6957  CONFIG_LOG_BUF_SHIFT=14
6958 +CONFIG_IKCONFIG=y
6959 +CONFIG_IKCONFIG_PROC=y
6960  # CONFIG_EMBEDDED is not set
6961 +CONFIG_KALLSYMS=y
6962  CONFIG_FUTEX=y
6963  CONFIG_EPOLL=y
6964 +CONFIG_IOSCHED_NOOP=y
6965 +CONFIG_IOSCHED_AS=y
6966 +CONFIG_IOSCHED_DEADLINE=y
6967  
6968  #
6969  # Loadable module support
6970 @@ -83,8 +90,8 @@
6971  CONFIG_PCI=y
6972  CONFIG_PCI_DOMAINS=y
6973  CONFIG_KCORE_ELF=y
6974 -CONFIG_BINFMT_ELF=y
6975  CONFIG_KERNEL_ELF=y
6976 +CONFIG_BINFMT_ELF=y
6977  CONFIG_BINFMT_MISC=y
6978  CONFIG_PCI_LEGACY_PROC=y
6979  CONFIG_PCI_NAMES=y
6980 @@ -116,6 +123,10 @@
6981  CONFIG_BOOT_LOAD=0x00800000
6982  
6983  #
6984 +# Generic Driver Options
6985 +#
6986 +
6987 +#
6988  # Memory Technology Devices (MTD)
6989  #
6990  # CONFIG_MTD is not set
6991 @@ -134,10 +145,12 @@
6992  # CONFIG_BLK_DEV_DAC960 is not set
6993  # CONFIG_BLK_DEV_UMEM is not set
6994  CONFIG_BLK_DEV_LOOP=y
6995 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
6996  # CONFIG_BLK_DEV_NBD is not set
6997  CONFIG_BLK_DEV_RAM=y
6998  CONFIG_BLK_DEV_RAM_SIZE=4096
6999  CONFIG_BLK_DEV_INITRD=y
7000 +CONFIG_LBD=y
7001  
7002  #
7003  # Multi-device support (RAID and LVM)
7004 @@ -145,12 +158,12 @@
7005  # CONFIG_MD is not set
7006  
7007  #
7008 -# ATA/IDE/MFM/RLL support
7009 +# ATA/ATAPI/MFM/RLL support
7010  #
7011  # CONFIG_IDE is not set
7012  
7013  #
7014 -# SCSI support
7015 +# SCSI device support
7016  #
7017  CONFIG_SCSI=y
7018  
7019 @@ -183,8 +196,6 @@
7020  # CONFIG_SCSI_AIC79XX is not set
7021  # CONFIG_SCSI_DPT_I2O is not set
7022  # CONFIG_SCSI_ADVANSYS is not set
7023 -# CONFIG_SCSI_IN2000 is not set
7024 -# CONFIG_SCSI_AM53C974 is not set
7025  # CONFIG_SCSI_MEGARAID is not set
7026  # CONFIG_SCSI_BUSLOGIC is not set
7027  # CONFIG_SCSI_CPQFCTS is not set
7028 @@ -193,11 +204,8 @@
7029  # CONFIG_SCSI_EATA_PIO is not set
7030  # CONFIG_SCSI_FUTURE_DOMAIN is not set
7031  # CONFIG_SCSI_GDTH is not set
7032 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
7033 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
7034  # CONFIG_SCSI_INITIO is not set
7035  # CONFIG_SCSI_INIA100 is not set
7036 -# CONFIG_SCSI_NCR53C7xx is not set
7037  CONFIG_SCSI_SYM53C8XX_2=y
7038  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
7039  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
7040 @@ -210,7 +218,6 @@
7041  # CONFIG_SCSI_QLOGIC_1280 is not set
7042  # CONFIG_SCSI_DC395x is not set
7043  # CONFIG_SCSI_DC390T is not set
7044 -# CONFIG_SCSI_U14_34F is not set
7045  # CONFIG_SCSI_NSP32 is not set
7046  # CONFIG_SCSI_DEBUG is not set
7047  # CONFIG_SCSI_MESH is not set
7048 @@ -242,8 +249,6 @@
7049  CONFIG_PACKET=y
7050  # CONFIG_PACKET_MMAP is not set
7051  # CONFIG_NETLINK_DEV is not set
7052 -CONFIG_NETFILTER=y
7053 -# CONFIG_NETFILTER_DEBUG is not set
7054  CONFIG_UNIX=y
7055  # CONFIG_NET_KEY is not set
7056  CONFIG_INET=y
7057 @@ -261,6 +266,16 @@
7058  # CONFIG_INET_IPCOMP is not set
7059  
7060  #
7061 +# IP: Virtual Server Configuration
7062 +#
7063 +# CONFIG_IP_VS is not set
7064 +# CONFIG_IPV6 is not set
7065 +# CONFIG_DECNET is not set
7066 +# CONFIG_BRIDGE is not set
7067 +CONFIG_NETFILTER=y
7068 +# CONFIG_NETFILTER_DEBUG is not set
7069 +
7070 +#
7071  # IP: Netfilter Configuration
7072  #
7073  CONFIG_IP_NF_CONNTRACK=m
7074 @@ -276,6 +291,7 @@
7075  CONFIG_IP_NF_MATCH_MARK=m
7076  CONFIG_IP_NF_MATCH_MULTIPORT=m
7077  CONFIG_IP_NF_MATCH_TOS=m
7078 +CONFIG_IP_NF_MATCH_RECENT=m
7079  CONFIG_IP_NF_MATCH_ECN=m
7080  CONFIG_IP_NF_MATCH_DSCP=m
7081  CONFIG_IP_NF_MATCH_AH_ESP=m
7082 @@ -306,10 +322,9 @@
7083  CONFIG_IP_NF_TARGET_TCPMSS=m
7084  CONFIG_IP_NF_ARPTABLES=m
7085  CONFIG_IP_NF_ARPFILTER=m
7086 +CONFIG_IP_NF_ARP_MANGLE=m
7087  CONFIG_IP_NF_COMPAT_IPCHAINS=m
7088  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
7089 -# CONFIG_IPV6 is not set
7090 -# CONFIG_XFRM_USER is not set
7091  
7092  #
7093  # SCTP Configuration (EXPERIMENTAL)
7094 @@ -319,8 +334,6 @@
7095  # CONFIG_ATM is not set
7096  # CONFIG_VLAN_8021Q is not set
7097  # CONFIG_LLC is not set
7098 -# CONFIG_DECNET is not set
7099 -# CONFIG_BRIDGE is not set
7100  # CONFIG_X25 is not set
7101  # CONFIG_LAPB is not set
7102  # CONFIG_NET_DIVERT is not set
7103 @@ -396,6 +409,7 @@
7104  # CONFIG_HAMACHI is not set
7105  # CONFIG_YELLOWFIN is not set
7106  # CONFIG_R8169 is not set
7107 +# CONFIG_SIS190 is not set
7108  # CONFIG_SK98LIN is not set
7109  # CONFIG_TIGON3 is not set
7110  
7111 @@ -495,11 +509,6 @@
7112  CONFIG_LOGO_LINUX_CLUT224=y
7113  
7114  #
7115 -# Old CD-ROM drivers (not SCSI, not IDE)
7116 -#
7117 -# CONFIG_CD_NO_IDESCSI is not set
7118 -
7119 -#
7120  # Input device support
7121  #
7122  CONFIG_INPUT=y
7123 @@ -525,6 +534,7 @@
7124  CONFIG_SERIO_I8042=y
7125  CONFIG_SERIO_SERPORT=y
7126  # CONFIG_SERIO_CT82C710 is not set
7127 +# CONFIG_SERIO_PCIPS2 is not set
7128  
7129  #
7130  # Input Device Drivers
7131 @@ -791,7 +801,6 @@
7132  # Kernel hacking
7133  #
7134  # CONFIG_DEBUG_KERNEL is not set
7135 -CONFIG_KALLSYMS=y
7136  # CONFIG_BOOTX_TEXT is not set
7137  
7138  #
7139 diff -Nru a/arch/ppc/configs/mcpn765_defconfig b/arch/ppc/configs/mcpn765_defconfig
7140 --- a/arch/ppc/configs/mcpn765_defconfig        Tue Jul  1 17:01:18 2003
7141 +++ b/arch/ppc/configs/mcpn765_defconfig        Mon Jul 21 09:05:22 2003
7142 @@ -19,6 +19,7 @@
7143  CONFIG_SYSCTL=y
7144  CONFIG_LOG_BUF_SHIFT=14
7145  # CONFIG_EMBEDDED is not set
7146 +CONFIG_KALLSYMS=y
7147  CONFIG_FUTEX=y
7148  CONFIG_EPOLL=y
7149  
7150 @@ -74,8 +75,8 @@
7151  CONFIG_PCI=y
7152  CONFIG_PCI_DOMAINS=y
7153  CONFIG_KCORE_ELF=y
7154 -CONFIG_BINFMT_ELF=y
7155  CONFIG_KERNEL_ELF=y
7156 +CONFIG_BINFMT_ELF=y
7157  # CONFIG_BINFMT_MISC is not set
7158  # CONFIG_PCI_LEGACY_PROC is not set
7159  # CONFIG_PCI_NAMES is not set
7160 @@ -104,6 +105,11 @@
7161  CONFIG_BOOT_LOAD=0x00800000
7162  
7163  #
7164 +# Generic Driver Options
7165 +#
7166 +# CONFIG_FW_LOADER is not set
7167 +
7168 +#
7169  # Memory Technology Devices (MTD)
7170  #
7171  # CONFIG_MTD is not set
7172 @@ -122,10 +128,12 @@
7173  # CONFIG_BLK_DEV_DAC960 is not set
7174  # CONFIG_BLK_DEV_UMEM is not set
7175  CONFIG_BLK_DEV_LOOP=y
7176 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
7177  # CONFIG_BLK_DEV_NBD is not set
7178  CONFIG_BLK_DEV_RAM=y
7179  CONFIG_BLK_DEV_RAM_SIZE=4096
7180  CONFIG_BLK_DEV_INITRD=y
7181 +# CONFIG_LBD is not set
7182  
7183  #
7184  # Multi-device support (RAID and LVM)
7185 @@ -133,12 +141,12 @@
7186  # CONFIG_MD is not set
7187  
7188  #
7189 -# ATA/IDE/MFM/RLL support
7190 +# ATA/ATAPI/MFM/RLL support
7191  #
7192  # CONFIG_IDE is not set
7193  
7194  #
7195 -# SCSI support
7196 +# SCSI device support
7197  #
7198  # CONFIG_SCSI is not set
7199  
7200 @@ -320,11 +328,6 @@
7201  # CONFIG_FB is not set
7202  
7203  #
7204 -# Old CD-ROM drivers (not SCSI, not IDE)
7205 -#
7206 -# CONFIG_CD_NO_IDESCSI is not set
7207 -
7208 -#
7209  # Input device support
7210  #
7211  # CONFIG_INPUT is not set
7212 @@ -526,7 +529,6 @@
7213  # Kernel hacking
7214  #
7215  # CONFIG_DEBUG_KERNEL is not set
7216 -# CONFIG_KALLSYMS is not set
7217  # CONFIG_SERIAL_TEXT_DEBUG is not set
7218  
7219  #
7220 diff -Nru a/arch/ppc/configs/pmac_defconfig b/arch/ppc/configs/pmac_defconfig
7221 --- a/arch/ppc/configs/pmac_defconfig   Sat Aug  2 13:06:57 2003
7222 +++ b/arch/ppc/configs/pmac_defconfig   Sat Aug 23 02:33:38 2003
7223 @@ -9,6 +9,7 @@
7224  # Code maturity level options
7225  #
7226  CONFIG_EXPERIMENTAL=y
7227 +# CONFIG_BROKEN is not set
7228  
7229  #
7230  # General setup
7231 @@ -18,9 +19,15 @@
7232  # CONFIG_BSD_PROCESS_ACCT is not set
7233  CONFIG_SYSCTL=y
7234  CONFIG_LOG_BUF_SHIFT=14
7235 +CONFIG_IKCONFIG=y
7236 +CONFIG_IKCONFIG_PROC=y
7237  # CONFIG_EMBEDDED is not set
7238 +CONFIG_KALLSYMS=y
7239  CONFIG_FUTEX=y
7240  CONFIG_EPOLL=y
7241 +CONFIG_IOSCHED_NOOP=y
7242 +CONFIG_IOSCHED_AS=y
7243 +CONFIG_IOSCHED_DEADLINE=y
7244  
7245  #
7246  # Loadable module support
7247 @@ -79,6 +86,7 @@
7248  # CONFIG_TAU_INT is not set
7249  # CONFIG_TAU_AVERAGE is not set
7250  CONFIG_CPU_FREQ=y
7251 +CONFIG_CPU_FREQ_TABLE=y
7252  CONFIG_CPU_FREQ_PROC_INTF=y
7253  CONFIG_CPU_FREQ_24_API=y
7254  CONFIG_CPU_FREQ_PMAC=y
7255 @@ -90,8 +98,8 @@
7256  CONFIG_PCI=y
7257  CONFIG_PCI_DOMAINS=y
7258  CONFIG_KCORE_ELF=y
7259 -CONFIG_BINFMT_ELF=y
7260  CONFIG_KERNEL_ELF=y
7261 +CONFIG_BINFMT_ELF=y
7262  CONFIG_BINFMT_MISC=m
7263  CONFIG_PCI_LEGACY_PROC=y
7264  CONFIG_PCI_NAMES=y
7265 @@ -101,9 +109,9 @@
7266  # PCMCIA/CardBus support
7267  #
7268  CONFIG_PCMCIA=m
7269 +CONFIG_YENTA=m
7270  CONFIG_CARDBUS=y
7271  CONFIG_I82092=m
7272 -CONFIG_I82365=m
7273  CONFIG_TCIC=m
7274  
7275  #
7276 @@ -131,6 +139,11 @@
7277  CONFIG_BOOT_LOAD=0x00800000
7278  
7279  #
7280 +# Generic Driver Options
7281 +#
7282 +# CONFIG_FW_LOADER is not set
7283 +
7284 +#
7285  # Memory Technology Devices (MTD)
7286  #
7287  # CONFIG_MTD is not set
7288 @@ -149,10 +162,12 @@
7289  # CONFIG_BLK_DEV_DAC960 is not set
7290  # CONFIG_BLK_DEV_UMEM is not set
7291  CONFIG_BLK_DEV_LOOP=y
7292 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
7293  # CONFIG_BLK_DEV_NBD is not set
7294  CONFIG_BLK_DEV_RAM=y
7295  CONFIG_BLK_DEV_RAM_SIZE=4096
7296  CONFIG_BLK_DEV_INITRD=y
7297 +CONFIG_LBD=y
7298  
7299  #
7300  # Multi-device support (RAID and LVM)
7301 @@ -160,41 +175,39 @@
7302  # CONFIG_MD is not set
7303  
7304  #
7305 -# ATA/IDE/MFM/RLL support
7306 +# ATA/ATAPI/MFM/RLL support
7307  #
7308  CONFIG_IDE=y
7309 -
7310 -#
7311 -# IDE, ATA and ATAPI Block devices
7312 -#
7313  CONFIG_BLK_DEV_IDE=y
7314  
7315  #
7316  # Please see Documentation/ide.txt for help/info on IDE drives
7317  #
7318 -# CONFIG_BLK_DEV_HD is not set
7319  CONFIG_BLK_DEV_IDEDISK=y
7320  # CONFIG_IDEDISK_MULTI_MODE is not set
7321  # CONFIG_IDEDISK_STROKE is not set
7322  CONFIG_BLK_DEV_IDECS=m
7323  CONFIG_BLK_DEV_IDECD=y
7324 +# CONFIG_BLK_DEV_IDETAPE is not set
7325  CONFIG_BLK_DEV_IDEFLOPPY=y
7326  CONFIG_BLK_DEV_IDESCSI=y
7327  # CONFIG_IDE_TASK_IOCTL is not set
7328 +# CONFIG_IDE_TASKFILE_IO is not set
7329  
7330  #
7331  # IDE chipset support/bugfixes
7332  #
7333  CONFIG_BLK_DEV_IDEPCI=y
7334 -CONFIG_BLK_DEV_GENERIC=y
7335  CONFIG_IDEPCI_SHARE_IRQ=y
7336 +# CONFIG_BLK_DEV_OFFBOARD is not set
7337 +CONFIG_BLK_DEV_GENERIC=y
7338 +# CONFIG_BLK_DEV_OPTI621 is not set
7339 +CONFIG_BLK_DEV_SL82C105=y
7340  CONFIG_BLK_DEV_IDEDMA_PCI=y
7341  # CONFIG_BLK_DEV_IDE_TCQ is not set
7342 -# CONFIG_BLK_DEV_OFFBOARD is not set
7343  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
7344  CONFIG_IDEDMA_PCI_AUTO=y
7345  # CONFIG_IDEDMA_ONLYDISK is not set
7346 -CONFIG_BLK_DEV_IDEDMA=y
7347  # CONFIG_IDEDMA_PCI_WIP is not set
7348  CONFIG_BLK_DEV_ADMA=y
7349  # CONFIG_BLK_DEV_AEC62XX is not set
7350 @@ -204,12 +217,12 @@
7351  # CONFIG_BLK_DEV_TRIFLEX is not set
7352  # CONFIG_BLK_DEV_CY82C693 is not set
7353  # CONFIG_BLK_DEV_CS5520 is not set
7354 +# CONFIG_BLK_DEV_CS5530 is not set
7355  # CONFIG_BLK_DEV_HPT34X is not set
7356  # CONFIG_BLK_DEV_HPT366 is not set
7357  # CONFIG_BLK_DEV_SC1200 is not set
7358  # CONFIG_BLK_DEV_PIIX is not set
7359  # CONFIG_BLK_DEV_NS87415 is not set
7360 -# CONFIG_BLK_DEV_OPTI621 is not set
7361  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
7362  CONFIG_BLK_DEV_PDC202XX_NEW=y
7363  # CONFIG_PDC202XX_FORCE is not set
7364 @@ -218,15 +231,17 @@
7365  # CONFIG_BLK_DEV_SLC90E66 is not set
7366  # CONFIG_BLK_DEV_TRM290 is not set
7367  # CONFIG_BLK_DEV_VIA82CXXX is not set
7368 -CONFIG_BLK_DEV_SL82C105=y
7369  CONFIG_BLK_DEV_IDE_PMAC=y
7370  CONFIG_BLK_DEV_IDEDMA_PMAC=y
7371  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
7372 -CONFIG_IDEDMA_AUTO=y
7373 +CONFIG_BLK_DEV_IDEDMA=y
7374  # CONFIG_IDEDMA_IVB is not set
7375 +CONFIG_IDEDMA_AUTO=y
7376 +# CONFIG_DMA_NONPCI is not set
7377 +# CONFIG_BLK_DEV_HD is not set
7378  
7379  #
7380 -# SCSI support
7381 +# SCSI device support
7382  #
7383  CONFIG_SCSI=y
7384  
7385 @@ -266,8 +281,6 @@
7386  # CONFIG_SCSI_AIC79XX is not set
7387  # CONFIG_SCSI_DPT_I2O is not set
7388  CONFIG_SCSI_ADVANSYS=m
7389 -# CONFIG_SCSI_IN2000 is not set
7390 -# CONFIG_SCSI_AM53C974 is not set
7391  # CONFIG_SCSI_MEGARAID is not set
7392  # CONFIG_SCSI_BUSLOGIC is not set
7393  # CONFIG_SCSI_CPQFCTS is not set
7394 @@ -276,11 +289,8 @@
7395  # CONFIG_SCSI_EATA_PIO is not set
7396  # CONFIG_SCSI_FUTURE_DOMAIN is not set
7397  # CONFIG_SCSI_GDTH is not set
7398 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
7399 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
7400  # CONFIG_SCSI_INITIO is not set
7401  # CONFIG_SCSI_INIA100 is not set
7402 -# CONFIG_SCSI_NCR53C7xx is not set
7403  CONFIG_SCSI_SYM53C8XX_2=y
7404  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
7405  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
7406 @@ -293,7 +303,6 @@
7407  # CONFIG_SCSI_QLOGIC_1280 is not set
7408  # CONFIG_SCSI_DC395x is not set
7409  # CONFIG_SCSI_DC390T is not set
7410 -# CONFIG_SCSI_U14_34F is not set
7411  # CONFIG_SCSI_NSP32 is not set
7412  # CONFIG_SCSI_DEBUG is not set
7413  CONFIG_SCSI_MESH=y
7414 @@ -361,8 +370,6 @@
7415  CONFIG_PACKET=y
7416  # CONFIG_PACKET_MMAP is not set
7417  # CONFIG_NETLINK_DEV is not set
7418 -CONFIG_NETFILTER=y
7419 -# CONFIG_NETFILTER_DEBUG is not set
7420  CONFIG_UNIX=y
7421  # CONFIG_NET_KEY is not set
7422  CONFIG_INET=y
7423 @@ -380,6 +387,16 @@
7424  # CONFIG_INET_IPCOMP is not set
7425  
7426  #
7427 +# IP: Virtual Server Configuration
7428 +#
7429 +# CONFIG_IP_VS is not set
7430 +# CONFIG_IPV6 is not set
7431 +# CONFIG_DECNET is not set
7432 +# CONFIG_BRIDGE is not set
7433 +CONFIG_NETFILTER=y
7434 +# CONFIG_NETFILTER_DEBUG is not set
7435 +
7436 +#
7437  # IP: Netfilter Configuration
7438  #
7439  CONFIG_IP_NF_CONNTRACK=m
7440 @@ -395,6 +412,7 @@
7441  CONFIG_IP_NF_MATCH_MARK=m
7442  CONFIG_IP_NF_MATCH_MULTIPORT=m
7443  CONFIG_IP_NF_MATCH_TOS=m
7444 +CONFIG_IP_NF_MATCH_RECENT=m
7445  CONFIG_IP_NF_MATCH_ECN=m
7446  CONFIG_IP_NF_MATCH_DSCP=m
7447  CONFIG_IP_NF_MATCH_AH_ESP=m
7448 @@ -425,10 +443,9 @@
7449  CONFIG_IP_NF_TARGET_TCPMSS=m
7450  CONFIG_IP_NF_ARPTABLES=m
7451  CONFIG_IP_NF_ARPFILTER=m
7452 +CONFIG_IP_NF_ARP_MANGLE=m
7453  CONFIG_IP_NF_COMPAT_IPCHAINS=m
7454  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
7455 -# CONFIG_IPV6 is not set
7456 -# CONFIG_XFRM_USER is not set
7457  
7458  #
7459  # SCTP Configuration (EXPERIMENTAL)
7460 @@ -438,8 +455,6 @@
7461  # CONFIG_ATM is not set
7462  # CONFIG_VLAN_8021Q is not set
7463  # CONFIG_LLC is not set
7464 -# CONFIG_DECNET is not set
7465 -# CONFIG_BRIDGE is not set
7466  # CONFIG_X25 is not set
7467  # CONFIG_LAPB is not set
7468  # CONFIG_NET_DIVERT is not set
7469 @@ -516,6 +531,7 @@
7470  # CONFIG_HAMACHI is not set
7471  # CONFIG_YELLOWFIN is not set
7472  # CONFIG_R8169 is not set
7473 +# CONFIG_SIS190 is not set
7474  # CONFIG_SK98LIN is not set
7475  # CONFIG_TIGON3 is not set
7476  
7477 @@ -568,6 +584,7 @@
7478  CONFIG_PCMCIA_HERMES=m
7479  # CONFIG_AIRO_CS is not set
7480  # CONFIG_PCMCIA_ATMEL is not set
7481 +# CONFIG_PCMCIA_WL3501 is not set
7482  CONFIG_NET_WIRELESS=y
7483  
7484  #
7485 @@ -637,25 +654,18 @@
7486  #
7487  # Old SIR device drivers
7488  #
7489 -# CONFIG_IRTTY_OLD is not set
7490  # CONFIG_IRPORT_SIR is not set
7491  
7492  #
7493  # Old Serial dongle support
7494  #
7495 -# CONFIG_DONGLE_OLD is not set
7496  
7497  #
7498  # FIR device drivers
7499  #
7500  # CONFIG_USB_IRDA is not set
7501 -# CONFIG_NSC_FIR is not set
7502 -# CONFIG_WINBOND_FIR is not set
7503  # CONFIG_TOSHIBA_OLD is not set
7504  # CONFIG_TOSHIBA_FIR is not set
7505 -# CONFIG_SMC_IRCC_OLD is not set
7506 -# CONFIG_SMC_IRCC_FIR is not set
7507 -# CONFIG_ALI_FIR is not set
7508  # CONFIG_VLSI_FIR is not set
7509  
7510  #
7511 @@ -721,11 +731,6 @@
7512  CONFIG_LOGO_LINUX_CLUT224=y
7513  
7514  #
7515 -# Old CD-ROM drivers (not SCSI, not IDE)
7516 -#
7517 -# CONFIG_CD_NO_IDESCSI is not set
7518 -
7519 -#
7520  # Input device support
7521  #
7522  CONFIG_INPUT=y
7523 @@ -766,7 +771,7 @@
7524  CONFIG_PMAC_PBOOK=y
7525  CONFIG_PMAC_APM_EMU=y
7526  CONFIG_PMAC_BACKLIGHT=y
7527 -CONFIG_MAC_FLOPPY=y
7528 +# CONFIG_MAC_FLOPPY is not set
7529  CONFIG_MAC_SERIAL=y
7530  CONFIG_ADB=y
7531  CONFIG_ADB_MACIO=y
7532 @@ -808,10 +813,12 @@
7533  #
7534  # I2C Hardware Sensors Mainboard support
7535  #
7536 +# CONFIG_I2C_ALI1535 is not set
7537  # CONFIG_I2C_ALI15X3 is not set
7538  # CONFIG_I2C_AMD756 is not set
7539  # CONFIG_I2C_AMD8111 is not set
7540  # CONFIG_I2C_I801 is not set
7541 +# CONFIG_I2C_NFORCE2 is not set
7542  # CONFIG_I2C_PIIX4 is not set
7543  # CONFIG_I2C_SIS96X is not set
7544  # CONFIG_I2C_VIAPRO is not set
7545 @@ -823,6 +830,7 @@
7546  # CONFIG_SENSORS_IT87 is not set
7547  # CONFIG_SENSORS_LM75 is not set
7548  # CONFIG_SENSORS_LM85 is not set
7549 +# CONFIG_SENSORS_LM78 is not set
7550  # CONFIG_SENSORS_VIA686A is not set
7551  # CONFIG_SENSORS_W83781D is not set
7552  # CONFIG_I2C_SENSOR is not set
7553 @@ -1028,8 +1036,7 @@
7554  # Sound
7555  #
7556  CONFIG_SOUND=m
7557 -CONFIG_DMASOUND_AWACS=m
7558 -CONFIG_DMASOUND=m
7559 +# CONFIG_DMASOUND_AWACS is not set
7560  
7561  #
7562  # Advanced Linux Sound Architecture
7563 @@ -1168,6 +1175,7 @@
7564  #
7565  # USB Network adaptors
7566  #
7567 +# CONFIG_USB_AX8817X is not set
7568  # CONFIG_USB_CATC is not set
7569  # CONFIG_USB_KAWETH is not set
7570  # CONFIG_USB_PEGASUS is not set
7571 @@ -1231,7 +1239,6 @@
7572  # Kernel hacking
7573  #
7574  # CONFIG_DEBUG_KERNEL is not set
7575 -CONFIG_KALLSYMS=y
7576  CONFIG_BOOTX_TEXT=y
7577  
7578  #
7579 diff -Nru a/arch/ppc/configs/power3_defconfig b/arch/ppc/configs/power3_defconfig
7580 --- a/arch/ppc/configs/power3_defconfig Tue Jul  1 17:01:18 2003
7581 +++ b/arch/ppc/configs/power3_defconfig Sat Aug 23 02:33:38 2003
7582 @@ -9,6 +9,7 @@
7583  # Code maturity level options
7584  #
7585  CONFIG_EXPERIMENTAL=y
7586 +# CONFIG_BROKEN is not set
7587  
7588  #
7589  # General setup
7590 @@ -18,9 +19,15 @@
7591  # CONFIG_BSD_PROCESS_ACCT is not set
7592  CONFIG_SYSCTL=y
7593  CONFIG_LOG_BUF_SHIFT=15
7594 +CONFIG_IKCONFIG=y
7595 +CONFIG_IKCONFIG_PROC=y
7596  # CONFIG_EMBEDDED is not set
7597 +CONFIG_KALLSYMS=y
7598  CONFIG_FUTEX=y
7599  CONFIG_EPOLL=y
7600 +CONFIG_IOSCHED_NOOP=y
7601 +CONFIG_IOSCHED_AS=y
7602 +CONFIG_IOSCHED_DEADLINE=y
7603  
7604  #
7605  # Loadable module support
7606 @@ -82,8 +89,8 @@
7607  CONFIG_PCI=y
7608  CONFIG_PCI_DOMAINS=y
7609  CONFIG_KCORE_ELF=y
7610 -CONFIG_BINFMT_ELF=y
7611  CONFIG_KERNEL_ELF=y
7612 +CONFIG_BINFMT_ELF=y
7613  CONFIG_BINFMT_MISC=y
7614  CONFIG_PCI_LEGACY_PROC=y
7615  CONFIG_PCI_NAMES=y
7616 @@ -121,6 +128,10 @@
7617  CONFIG_BOOT_LOAD=0x00800000
7618  
7619  #
7620 +# Generic Driver Options
7621 +#
7622 +
7623 +#
7624  # Memory Technology Devices (MTD)
7625  #
7626  # CONFIG_MTD is not set
7627 @@ -140,10 +151,12 @@
7628  # CONFIG_BLK_DEV_DAC960 is not set
7629  # CONFIG_BLK_DEV_UMEM is not set
7630  CONFIG_BLK_DEV_LOOP=y
7631 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
7632  # CONFIG_BLK_DEV_NBD is not set
7633  CONFIG_BLK_DEV_RAM=y
7634  CONFIG_BLK_DEV_RAM_SIZE=4096
7635  CONFIG_BLK_DEV_INITRD=y
7636 +CONFIG_LBD=y
7637  
7638  #
7639  # Multi-device support (RAID and LVM)
7640 @@ -156,14 +169,15 @@
7641  CONFIG_MD_RAID5=y
7642  # CONFIG_MD_MULTIPATH is not set
7643  CONFIG_BLK_DEV_DM=y
7644 +CONFIG_DM_IOCTL_V4=y
7645  
7646  #
7647 -# ATA/IDE/MFM/RLL support
7648 +# ATA/ATAPI/MFM/RLL support
7649  #
7650  # CONFIG_IDE is not set
7651  
7652  #
7653 -# SCSI support
7654 +# SCSI device support
7655  #
7656  CONFIG_SCSI=y
7657  
7658 @@ -196,8 +210,6 @@
7659  # CONFIG_SCSI_AIC79XX is not set
7660  # CONFIG_SCSI_DPT_I2O is not set
7661  # CONFIG_SCSI_ADVANSYS is not set
7662 -# CONFIG_SCSI_IN2000 is not set
7663 -# CONFIG_SCSI_AM53C974 is not set
7664  # CONFIG_SCSI_MEGARAID is not set
7665  # CONFIG_SCSI_BUSLOGIC is not set
7666  # CONFIG_SCSI_CPQFCTS is not set
7667 @@ -206,13 +218,10 @@
7668  # CONFIG_SCSI_EATA_PIO is not set
7669  # CONFIG_SCSI_FUTURE_DOMAIN is not set
7670  # CONFIG_SCSI_GDTH is not set
7671 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
7672 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
7673  # CONFIG_SCSI_INITIO is not set
7674  # CONFIG_SCSI_INIA100 is not set
7675  # CONFIG_SCSI_PPA is not set
7676  # CONFIG_SCSI_IMM is not set
7677 -# CONFIG_SCSI_NCR53C7xx is not set
7678  CONFIG_SCSI_SYM53C8XX_2=y
7679  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
7680  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
7681 @@ -225,7 +234,6 @@
7682  # CONFIG_SCSI_QLOGIC_1280 is not set
7683  # CONFIG_SCSI_DC395x is not set
7684  # CONFIG_SCSI_DC390T is not set
7685 -# CONFIG_SCSI_U14_34F is not set
7686  # CONFIG_SCSI_NSP32 is not set
7687  # CONFIG_SCSI_DEBUG is not set
7688  # CONFIG_SCSI_MESH is not set
7689 @@ -257,7 +265,6 @@
7690  CONFIG_PACKET=y
7691  # CONFIG_PACKET_MMAP is not set
7692  # CONFIG_NETLINK_DEV is not set
7693 -# CONFIG_NETFILTER is not set
7694  CONFIG_UNIX=y
7695  # CONFIG_NET_KEY is not set
7696  CONFIG_INET=y
7697 @@ -274,7 +281,9 @@
7698  # CONFIG_INET_ESP is not set
7699  # CONFIG_INET_IPCOMP is not set
7700  # CONFIG_IPV6 is not set
7701 -# CONFIG_XFRM_USER is not set
7702 +# CONFIG_DECNET is not set
7703 +# CONFIG_BRIDGE is not set
7704 +# CONFIG_NETFILTER is not set
7705  
7706  #
7707  # SCTP Configuration (EXPERIMENTAL)
7708 @@ -284,8 +293,6 @@
7709  # CONFIG_ATM is not set
7710  # CONFIG_VLAN_8021Q is not set
7711  # CONFIG_LLC is not set
7712 -# CONFIG_DECNET is not set
7713 -# CONFIG_BRIDGE is not set
7714  # CONFIG_X25 is not set
7715  # CONFIG_LAPB is not set
7716  # CONFIG_NET_DIVERT is not set
7717 @@ -362,6 +369,7 @@
7718  # CONFIG_HAMACHI is not set
7719  # CONFIG_YELLOWFIN is not set
7720  # CONFIG_R8169 is not set
7721 +# CONFIG_SIS190 is not set
7722  # CONFIG_SK98LIN is not set
7723  # CONFIG_TIGON3 is not set
7724  
7725 @@ -464,11 +472,6 @@
7726  CONFIG_LOGO_LINUX_CLUT224=y
7727  
7728  #
7729 -# Old CD-ROM drivers (not SCSI, not IDE)
7730 -#
7731 -# CONFIG_CD_NO_IDESCSI is not set
7732 -
7733 -#
7734  # Input device support
7735  #
7736  CONFIG_INPUT=y
7737 @@ -495,6 +498,7 @@
7738  CONFIG_SERIO_SERPORT=y
7739  # CONFIG_SERIO_CT82C710 is not set
7740  # CONFIG_SERIO_PARKBD is not set
7741 +# CONFIG_SERIO_PCIPS2 is not set
7742  
7743  #
7744  # Input Device Drivers
7745 @@ -554,9 +558,8 @@
7746  #
7747  CONFIG_I2C=y
7748  CONFIG_I2C_ALGOBIT=y
7749 +# CONFIG_I2C_PROSAVAGE is not set
7750  # CONFIG_I2C_PHILIPSPAR is not set
7751 -# CONFIG_I2C_ELV is not set
7752 -# CONFIG_I2C_VELLEMAN is not set
7753  # CONFIG_SCx200_ACB is not set
7754  CONFIG_I2C_ALGOPCF=y
7755  # CONFIG_I2C_ELEKTOR is not set
7756 @@ -566,10 +569,12 @@
7757  #
7758  # I2C Hardware Sensors Mainboard support
7759  #
7760 +# CONFIG_I2C_ALI1535 is not set
7761  # CONFIG_I2C_ALI15X3 is not set
7762  # CONFIG_I2C_AMD756 is not set
7763  # CONFIG_I2C_AMD8111 is not set
7764  # CONFIG_I2C_I801 is not set
7765 +# CONFIG_I2C_NFORCE2 is not set
7766  # CONFIG_I2C_PIIX4 is not set
7767  # CONFIG_I2C_SIS96X is not set
7768  # CONFIG_I2C_VIAPRO is not set
7769 @@ -581,6 +586,7 @@
7770  # CONFIG_SENSORS_IT87 is not set
7771  # CONFIG_SENSORS_LM75 is not set
7772  # CONFIG_SENSORS_LM85 is not set
7773 +# CONFIG_SENSORS_LM78 is not set
7774  # CONFIG_SENSORS_VIA686A is not set
7775  # CONFIG_SENSORS_W83781D is not set
7776  # CONFIG_I2C_SENSOR is not set
7777 @@ -843,7 +849,6 @@
7778  # Kernel hacking
7779  #
7780  # CONFIG_DEBUG_KERNEL is not set
7781 -CONFIG_KALLSYMS=y
7782  CONFIG_BOOTX_TEXT=y
7783  
7784  #
7785 diff -Nru a/arch/ppc/defconfig b/arch/ppc/defconfig
7786 --- a/arch/ppc/defconfig        Sat Aug  2 12:59:32 2003
7787 +++ b/arch/ppc/defconfig        Sat Aug 23 02:33:38 2003
7788 @@ -9,6 +9,7 @@
7789  # Code maturity level options
7790  #
7791  CONFIG_EXPERIMENTAL=y
7792 +# CONFIG_BROKEN is not set
7793  
7794  #
7795  # General setup
7796 @@ -18,9 +19,15 @@
7797  # CONFIG_BSD_PROCESS_ACCT is not set
7798  CONFIG_SYSCTL=y
7799  CONFIG_LOG_BUF_SHIFT=14
7800 +CONFIG_IKCONFIG=y
7801 +CONFIG_IKCONFIG_PROC=y
7802  # CONFIG_EMBEDDED is not set
7803 +CONFIG_KALLSYMS=y
7804  CONFIG_FUTEX=y
7805  CONFIG_EPOLL=y
7806 +CONFIG_IOSCHED_NOOP=y
7807 +CONFIG_IOSCHED_AS=y
7808 +CONFIG_IOSCHED_DEADLINE=y
7809  
7810  #
7811  # Loadable module support
7812 @@ -78,6 +85,7 @@
7813  # CONFIG_TAU_INT is not set
7814  # CONFIG_TAU_AVERAGE is not set
7815  CONFIG_CPU_FREQ=y
7816 +CONFIG_CPU_FREQ_TABLE=y
7817  CONFIG_CPU_FREQ_PROC_INTF=y
7818  CONFIG_CPU_FREQ_24_API=y
7819  CONFIG_CPU_FREQ_PMAC=y
7820 @@ -89,8 +97,8 @@
7821  CONFIG_PCI=y
7822  CONFIG_PCI_DOMAINS=y
7823  CONFIG_KCORE_ELF=y
7824 -CONFIG_BINFMT_ELF=y
7825  CONFIG_KERNEL_ELF=y
7826 +CONFIG_BINFMT_ELF=y
7827  CONFIG_BINFMT_MISC=m
7828  CONFIG_PCI_LEGACY_PROC=y
7829  CONFIG_PCI_NAMES=y
7830 @@ -128,6 +136,11 @@
7831  CONFIG_BOOT_LOAD=0x00800000
7832  
7833  #
7834 +# Generic Driver Options
7835 +#
7836 +# CONFIG_FW_LOADER is not set
7837 +
7838 +#
7839  # Memory Technology Devices (MTD)
7840  #
7841  # CONFIG_MTD is not set
7842 @@ -146,10 +159,12 @@
7843  # CONFIG_BLK_DEV_DAC960 is not set
7844  # CONFIG_BLK_DEV_UMEM is not set
7845  CONFIG_BLK_DEV_LOOP=y
7846 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
7847  # CONFIG_BLK_DEV_NBD is not set
7848  CONFIG_BLK_DEV_RAM=y
7849  CONFIG_BLK_DEV_RAM_SIZE=4096
7850  CONFIG_BLK_DEV_INITRD=y
7851 +CONFIG_LBD=y
7852  
7853  #
7854  # Multi-device support (RAID and LVM)
7855 @@ -157,40 +172,38 @@
7856  # CONFIG_MD is not set
7857  
7858  #
7859 -# ATA/IDE/MFM/RLL support
7860 +# ATA/ATAPI/MFM/RLL support
7861  #
7862  CONFIG_IDE=y
7863 -
7864 -#
7865 -# IDE, ATA and ATAPI Block devices
7866 -#
7867  CONFIG_BLK_DEV_IDE=y
7868  
7869  #
7870  # Please see Documentation/ide.txt for help/info on IDE drives
7871  #
7872 -# CONFIG_BLK_DEV_HD is not set
7873  CONFIG_BLK_DEV_IDEDISK=y
7874  # CONFIG_IDEDISK_MULTI_MODE is not set
7875  # CONFIG_IDEDISK_STROKE is not set
7876  CONFIG_BLK_DEV_IDECD=y
7877 +# CONFIG_BLK_DEV_IDETAPE is not set
7878  CONFIG_BLK_DEV_IDEFLOPPY=y
7879  CONFIG_BLK_DEV_IDESCSI=y
7880  # CONFIG_IDE_TASK_IOCTL is not set
7881 +# CONFIG_IDE_TASKFILE_IO is not set
7882  
7883  #
7884  # IDE chipset support/bugfixes
7885  #
7886  CONFIG_BLK_DEV_IDEPCI=y
7887 -CONFIG_BLK_DEV_GENERIC=y
7888  CONFIG_IDEPCI_SHARE_IRQ=y
7889 +# CONFIG_BLK_DEV_OFFBOARD is not set
7890 +CONFIG_BLK_DEV_GENERIC=y
7891 +# CONFIG_BLK_DEV_OPTI621 is not set
7892 +CONFIG_BLK_DEV_SL82C105=y
7893  CONFIG_BLK_DEV_IDEDMA_PCI=y
7894  # CONFIG_BLK_DEV_IDE_TCQ is not set
7895 -# CONFIG_BLK_DEV_OFFBOARD is not set
7896  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
7897  CONFIG_IDEDMA_PCI_AUTO=y
7898  # CONFIG_IDEDMA_ONLYDISK is not set
7899 -CONFIG_BLK_DEV_IDEDMA=y
7900  # CONFIG_IDEDMA_PCI_WIP is not set
7901  CONFIG_BLK_DEV_ADMA=y
7902  # CONFIG_BLK_DEV_AEC62XX is not set
7903 @@ -200,12 +213,12 @@
7904  # CONFIG_BLK_DEV_TRIFLEX is not set
7905  # CONFIG_BLK_DEV_CY82C693 is not set
7906  # CONFIG_BLK_DEV_CS5520 is not set
7907 +# CONFIG_BLK_DEV_CS5530 is not set
7908  # CONFIG_BLK_DEV_HPT34X is not set
7909  # CONFIG_BLK_DEV_HPT366 is not set
7910  # CONFIG_BLK_DEV_SC1200 is not set
7911  # CONFIG_BLK_DEV_PIIX is not set
7912  # CONFIG_BLK_DEV_NS87415 is not set
7913 -# CONFIG_BLK_DEV_OPTI621 is not set
7914  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
7915  # CONFIG_BLK_DEV_PDC202XX_NEW is not set
7916  # CONFIG_BLK_DEV_SVWKS is not set
7917 @@ -213,15 +226,17 @@
7918  # CONFIG_BLK_DEV_SLC90E66 is not set
7919  # CONFIG_BLK_DEV_TRM290 is not set
7920  # CONFIG_BLK_DEV_VIA82CXXX is not set
7921 -CONFIG_BLK_DEV_SL82C105=y
7922  CONFIG_BLK_DEV_IDE_PMAC=y
7923  CONFIG_BLK_DEV_IDEDMA_PMAC=y
7924  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
7925 -CONFIG_IDEDMA_AUTO=y
7926 +CONFIG_BLK_DEV_IDEDMA=y
7927  # CONFIG_IDEDMA_IVB is not set
7928 +CONFIG_IDEDMA_AUTO=y
7929 +# CONFIG_DMA_NONPCI is not set
7930 +# CONFIG_BLK_DEV_HD is not set
7931  
7932  #
7933 -# SCSI support
7934 +# SCSI device support
7935  #
7936  CONFIG_SCSI=y
7937  
7938 @@ -261,8 +276,6 @@
7939  # CONFIG_SCSI_AIC79XX is not set
7940  # CONFIG_SCSI_DPT_I2O is not set
7941  CONFIG_SCSI_ADVANSYS=m
7942 -# CONFIG_SCSI_IN2000 is not set
7943 -# CONFIG_SCSI_AM53C974 is not set
7944  # CONFIG_SCSI_MEGARAID is not set
7945  # CONFIG_SCSI_BUSLOGIC is not set
7946  # CONFIG_SCSI_CPQFCTS is not set
7947 @@ -271,11 +284,8 @@
7948  # CONFIG_SCSI_EATA_PIO is not set
7949  # CONFIG_SCSI_FUTURE_DOMAIN is not set
7950  # CONFIG_SCSI_GDTH is not set
7951 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
7952 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
7953  # CONFIG_SCSI_INITIO is not set
7954  # CONFIG_SCSI_INIA100 is not set
7955 -# CONFIG_SCSI_NCR53C7xx is not set
7956  CONFIG_SCSI_SYM53C8XX_2=y
7957  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
7958  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
7959 @@ -288,7 +298,6 @@
7960  # CONFIG_SCSI_QLOGIC_1280 is not set
7961  # CONFIG_SCSI_DC395x is not set
7962  # CONFIG_SCSI_DC390T is not set
7963 -# CONFIG_SCSI_U14_34F is not set
7964  # CONFIG_SCSI_NSP32 is not set
7965  # CONFIG_SCSI_DEBUG is not set
7966  CONFIG_SCSI_MESH=y
7967 @@ -322,8 +331,6 @@
7968  CONFIG_PACKET=y
7969  # CONFIG_PACKET_MMAP is not set
7970  # CONFIG_NETLINK_DEV is not set
7971 -CONFIG_NETFILTER=y
7972 -# CONFIG_NETFILTER_DEBUG is not set
7973  CONFIG_UNIX=y
7974  # CONFIG_NET_KEY is not set
7975  CONFIG_INET=y
7976 @@ -341,6 +348,16 @@
7977  # CONFIG_INET_IPCOMP is not set
7978  
7979  #
7980 +# IP: Virtual Server Configuration
7981 +#
7982 +# CONFIG_IP_VS is not set
7983 +# CONFIG_IPV6 is not set
7984 +# CONFIG_DECNET is not set
7985 +# CONFIG_BRIDGE is not set
7986 +CONFIG_NETFILTER=y
7987 +# CONFIG_NETFILTER_DEBUG is not set
7988 +
7989 +#
7990  # IP: Netfilter Configuration
7991  #
7992  CONFIG_IP_NF_CONNTRACK=m
7993 @@ -356,6 +373,7 @@
7994  CONFIG_IP_NF_MATCH_MARK=m
7995  CONFIG_IP_NF_MATCH_MULTIPORT=m
7996  CONFIG_IP_NF_MATCH_TOS=m
7997 +CONFIG_IP_NF_MATCH_RECENT=m
7998  CONFIG_IP_NF_MATCH_ECN=m
7999  CONFIG_IP_NF_MATCH_DSCP=m
8000  CONFIG_IP_NF_MATCH_AH_ESP=m
8001 @@ -386,10 +404,9 @@
8002  CONFIG_IP_NF_TARGET_TCPMSS=m
8003  CONFIG_IP_NF_ARPTABLES=m
8004  CONFIG_IP_NF_ARPFILTER=m
8005 +CONFIG_IP_NF_ARP_MANGLE=m
8006  CONFIG_IP_NF_COMPAT_IPCHAINS=m
8007  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
8008 -# CONFIG_IPV6 is not set
8009 -# CONFIG_XFRM_USER is not set
8010  
8011  #
8012  # SCTP Configuration (EXPERIMENTAL)
8013 @@ -399,8 +416,6 @@
8014  # CONFIG_ATM is not set
8015  # CONFIG_VLAN_8021Q is not set
8016  # CONFIG_LLC is not set
8017 -# CONFIG_DECNET is not set
8018 -# CONFIG_BRIDGE is not set
8019  # CONFIG_X25 is not set
8020  # CONFIG_LAPB is not set
8021  # CONFIG_NET_DIVERT is not set
8022 @@ -477,6 +492,7 @@
8023  # CONFIG_HAMACHI is not set
8024  # CONFIG_YELLOWFIN is not set
8025  # CONFIG_R8169 is not set
8026 +# CONFIG_SIS190 is not set
8027  # CONFIG_SK98LIN is not set
8028  # CONFIG_TIGON3 is not set
8029  
8030 @@ -548,7 +564,7 @@
8031  # Graphics support
8032  #
8033  CONFIG_FB=y
8034 -CONFIG_FB_CIRRUS=y
8035 +# CONFIG_FB_CIRRUS is not set
8036  # CONFIG_FB_PM2 is not set
8037  # CONFIG_FB_CYBER2000 is not set
8038  CONFIG_FB_OF=y
8039 @@ -602,11 +618,6 @@
8040  CONFIG_LOGO_LINUX_CLUT224=y
8041  
8042  #
8043 -# Old CD-ROM drivers (not SCSI, not IDE)
8044 -#
8045 -# CONFIG_CD_NO_IDESCSI is not set
8046 -
8047 -#
8048  # Input device support
8049  #
8050  CONFIG_INPUT=y
8051 @@ -632,6 +643,7 @@
8052  CONFIG_SERIO_I8042=y
8053  CONFIG_SERIO_SERPORT=y
8054  # CONFIG_SERIO_CT82C710 is not set
8055 +# CONFIG_SERIO_PCIPS2 is not set
8056  
8057  #
8058  # Input Device Drivers
8059 @@ -698,10 +710,12 @@
8060  #
8061  # I2C Hardware Sensors Mainboard support
8062  #
8063 +# CONFIG_I2C_ALI1535 is not set
8064  # CONFIG_I2C_ALI15X3 is not set
8065  # CONFIG_I2C_AMD756 is not set
8066  # CONFIG_I2C_AMD8111 is not set
8067  # CONFIG_I2C_I801 is not set
8068 +# CONFIG_I2C_NFORCE2 is not set
8069  # CONFIG_I2C_PIIX4 is not set
8070  # CONFIG_I2C_SIS96X is not set
8071  # CONFIG_I2C_VIAPRO is not set
8072 @@ -713,6 +727,7 @@
8073  # CONFIG_SENSORS_IT87 is not set
8074  # CONFIG_SENSORS_LM75 is not set
8075  # CONFIG_SENSORS_LM85 is not set
8076 +# CONFIG_SENSORS_LM78 is not set
8077  # CONFIG_SENSORS_VIA686A is not set
8078  # CONFIG_SENSORS_W83781D is not set
8079  # CONFIG_I2C_SENSOR is not set
8080 @@ -1047,6 +1062,7 @@
8081  #
8082  # USB Network adaptors
8083  #
8084 +# CONFIG_USB_AX8817X is not set
8085  # CONFIG_USB_CATC is not set
8086  # CONFIG_USB_KAWETH is not set
8087  # CONFIG_USB_PEGASUS is not set
8088 @@ -1123,7 +1139,6 @@
8089  # Kernel hacking
8090  #
8091  # CONFIG_DEBUG_KERNEL is not set
8092 -CONFIG_KALLSYMS=y
8093  CONFIG_BOOTX_TEXT=y
8094  
8095  #
8096 diff -Nru a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c
8097 --- a/arch/ppc/kernel/cputable.c        Sun Apr 27 05:41:48 2003
8098 +++ b/arch/ppc/kernel/cputable.c        Sun Aug 24 03:04:21 2003
8099 @@ -154,6 +154,15 @@
8100         32, 32,
8101         __setup_cpu_750cx
8102      },
8103 +    {  /* 750FX rev 1.x */
8104 +       0xffffff00, 0x70000100, "750FX",
8105 +       CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
8106 +       CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_CAN_NAP |
8107 +       CPU_FTR_DUAL_PLL_750FX | CPU_FTR_NO_DPM,
8108 +       COMMON_PPC,
8109 +       32, 32,
8110 +       __setup_cpu_750
8111 +    },
8112      {  /* 750FX rev 2.0 must disable HID0[DPM] */
8113         0xffffffff, 0x70000200, "750FX",
8114         CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
8115 diff -Nru a/arch/ppc/kernel/head.S b/arch/ppc/kernel/head.S
8116 --- a/arch/ppc/kernel/head.S    Wed Jun  4 20:07:15 2003
8117 +++ b/arch/ppc/kernel/head.S    Tue Aug 26 06:38:51 2003
8118 @@ -355,11 +355,6 @@
8119   *     -- paulus.
8120   */
8121         . = 0x200
8122 -MachineCheck:
8123 -BEGIN_FTR_SECTION
8124 -       dssall
8125 -       sync
8126 -END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
8127         mtspr   SPRG0,r10
8128         mtspr   SPRG1,r11
8129         mfcr    r10
8130 diff -Nru a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S
8131 --- a/arch/ppc/kernel/misc.S    Tue Jul 15 04:47:19 2003
8132 +++ b/arch/ppc/kernel/misc.S    Fri Aug 22 19:15:18 2003
8133 @@ -1380,3 +1380,4 @@
8134         .long sys_utimes
8135         .long sys_statfs64
8136         .long sys_fstatfs64
8137 +       .long ppc_fadvise64_64
8138 diff -Nru a/arch/ppc/kernel/ppc-stub.c b/arch/ppc/kernel/ppc-stub.c
8139 --- a/arch/ppc/kernel/ppc-stub.c        Mon Jun 30 10:10:33 2003
8140 +++ b/arch/ppc/kernel/ppc-stub.c        Mon Aug 25 11:39:55 2003
8141 @@ -106,6 +106,7 @@
8142  #include <linux/smp.h>
8143  #include <linux/smp_lock.h>
8144  
8145 +#include <asm/cacheflush.h>
8146  #include <asm/system.h>
8147  #include <asm/signal.h>
8148  #include <asm/kgdb.h>
8149 @@ -136,7 +137,7 @@
8150  /* typedef void (*trapfunc_t)(void); */
8151  
8152  static void kgdb_fault_handler(struct pt_regs *regs);
8153 -static void handle_exception (struct pt_regs *regs);
8154 +static int handle_exception (struct pt_regs *regs);
8155  
8156  #if 0
8157  /* Install an exception handler for kgdb */
8158 @@ -186,7 +187,7 @@
8159   * return 0.
8160   */
8161  static unsigned char *
8162 -mem2hex(char *mem, char *buf, int count)
8163 +mem2hex(const char *mem, char *buf, int count)
8164  {
8165         unsigned char ch;
8166         unsigned short tmp_s;
8167 @@ -460,14 +461,12 @@
8168  
8169  int kgdb_bpt(struct pt_regs *regs)
8170  {
8171 -       handle_exception(regs);
8172 -       return 1;
8173 +       return handle_exception(regs);
8174  }
8175  
8176  int kgdb_sstep(struct pt_regs *regs)
8177  {
8178 -       handle_exception(regs);
8179 -       return 1;
8180 +       return handle_exception(regs);
8181  }
8182  
8183  void kgdb(struct pt_regs *regs)
8184 @@ -477,16 +476,14 @@
8185  
8186  int kgdb_iabr_match(struct pt_regs *regs)
8187  {
8188 -       printk("kgdb doesn't support iabr, what?!?\n");
8189 -       handle_exception(regs);
8190 -       return 1;
8191 +       printk(KERN_ERR "kgdb doesn't support iabr, what?!?\n");
8192 +       return handle_exception(regs);
8193  }
8194  
8195  int kgdb_dabr_match(struct pt_regs *regs)
8196  {
8197 -       printk("kgdb doesn't support dabr, what?!?\n");
8198 -       handle_exception(regs);
8199 -       return 1;
8200 +       printk(KERN_ERR "kgdb doesn't support dabr, what?!?\n");
8201 +       return handle_exception(regs);
8202  }
8203  
8204  /* Convert the hardware trap type code to a unix signal number. */
8205 @@ -559,7 +556,7 @@
8206  /*
8207   * This function does all command processing for interfacing to gdb.
8208   */
8209 -static void
8210 +static int
8211  handle_exception (struct pt_regs *regs)
8212  {
8213         int sigval;
8214 @@ -568,14 +565,19 @@
8215         char *ptr;
8216         unsigned int msr;
8217  
8218 +       /* We don't handle user-mode breakpoints. */
8219 +       if (user_mode(regs))
8220 +               return 0;
8221 +
8222         if (debugger_fault_handler) {
8223                 debugger_fault_handler(regs);
8224                 panic("kgdb longjump failed!\n");
8225         }
8226         if (kgdb_active) {
8227 -               printk("interrupt while in kgdb, returning\n");
8228 -               return;
8229 +               printk(KERN_ERR "interrupt while in kgdb, returning\n");
8230 +               return 0;
8231         }
8232 +
8233         kgdb_active = 1;
8234         kgdb_started = 1;
8235  
8236 @@ -783,7 +785,7 @@
8237                                 printk("remcomInBuffer: %s\n", remcomInBuffer);
8238                                 printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8239                         }
8240 -                       return;
8241 +                       return 1;
8242  
8243                 case 's':
8244                         kgdb_flush_cache_all();
8245 @@ -800,7 +802,7 @@
8246                                 printk("remcomInBuffer: %s\n", remcomInBuffer);
8247                                 printk("remcomOutBuffer: %s\n", remcomOutBuffer);
8248                         }
8249 -                       return;
8250 +                       return 1;
8251  
8252                 case 'r':               /* Reset (if user process..exit ???)*/
8253                         panic("kgdb reset.");
8254 @@ -828,11 +830,11 @@
8255                 return;
8256         }
8257  
8258 -       asm("   .globl breakinst
8259 -            breakinst: .long 0x7d821008
8260 -           ");
8261 +       asm("   .globl breakinst        \n\
8262 +            breakinst: .long 0x7d821008");
8263  }
8264  
8265 +#ifdef CONFIG_KGDB_CONSOLE
8266  /* Output string in GDB O-packet format if GDB has connected. If nothing
8267     output, returns 0 (caller must then handle output). */
8268  int
8269 @@ -852,3 +854,4 @@
8270  
8271         return 1;
8272  }
8273 +#endif
8274 diff -Nru a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
8275 --- a/arch/ppc/kernel/ppc_ksyms.c       Tue Jul  1 10:57:22 2003
8276 +++ b/arch/ppc/kernel/ppc_ksyms.c       Sun Aug 24 03:57:52 2003
8277 @@ -200,6 +200,7 @@
8278  EXPORT_SYMBOL(flush_icache_user_range);
8279  EXPORT_SYMBOL(flush_dcache_page);
8280  EXPORT_SYMBOL(flush_tlb_kernel_range);
8281 +EXPORT_SYMBOL(flush_tlb_page);
8282  #ifdef CONFIG_ALTIVEC
8283  EXPORT_SYMBOL(last_task_used_altivec);
8284  EXPORT_SYMBOL(giveup_altivec);
8285 @@ -259,6 +260,15 @@
8286  EXPORT_SYMBOL(pci_busdev_to_OF_node);
8287  EXPORT_SYMBOL(pci_device_to_OF_node);
8288  EXPORT_SYMBOL(pci_device_from_OF_node);
8289 +EXPORT_SYMBOL(of_find_node_by_name);
8290 +EXPORT_SYMBOL(of_find_node_by_type);
8291 +EXPORT_SYMBOL(of_find_compatible_node);
8292 +EXPORT_SYMBOL(of_find_node_by_path);
8293 +EXPORT_SYMBOL(of_find_all_nodes);
8294 +EXPORT_SYMBOL(of_get_parent);
8295 +EXPORT_SYMBOL(of_get_next_child);
8296 +EXPORT_SYMBOL(of_node_get);
8297 +EXPORT_SYMBOL(of_node_put);
8298  #endif /* CONFIG_PPC_OF */
8299  #if defined(CONFIG_BOOTX_TEXT)
8300  EXPORT_SYMBOL(btext_update_display);
8301 diff -Nru a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
8302 --- a/arch/ppc/kernel/setup.c   Mon Aug 18 19:46:23 2003
8303 +++ b/arch/ppc/kernel/setup.c   Mon Aug 25 11:11:43 2003
8304 @@ -624,12 +624,10 @@
8305  #if defined(CONFIG_KGDB)
8306         kgdb_map_scc();
8307         set_debug_traps();
8308 -       if (strstr(cmd_line, "nokgdb"))
8309 -               printk("kgdb default breakpoint deactivated on command line\n");
8310 -       else {
8311 +       if (strstr(cmd_line, "gdb")) {
8312                 if (ppc_md.progress)
8313                         ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
8314 -               printk("kgdb default breakpoint activated\n");
8315 +               printk("kgdb breakpoint activated\n");
8316                 breakpoint();
8317         }
8318  #endif
8319 diff -Nru a/arch/ppc/kernel/smp.c b/arch/ppc/kernel/smp.c
8320 --- a/arch/ppc/kernel/smp.c     Mon Aug 18 19:46:23 2003
8321 +++ b/arch/ppc/kernel/smp.c     Fri Aug 22 19:58:08 2003
8322 @@ -47,8 +47,8 @@
8323  DEFINE_PER_CPU(unsigned int, prof_multiplier);
8324  DEFINE_PER_CPU(unsigned int, prof_counter);
8325  unsigned long cache_decay_ticks = HZ/100;
8326 -unsigned long cpu_online_map = cpumask_of_cpu(0);
8327 -unsigned long cpu_possible_map = 1UL;
8328 +cpumask_t cpu_online_map;
8329 +cpumask_t cpu_possible_map;
8330  int smp_hw_index[NR_CPUS];
8331  struct thread_info *secondary_ti;
8332  
8333 @@ -336,7 +336,7 @@
8334  
8335  void __init smp_prepare_cpus(unsigned int max_cpus)
8336  {
8337 -       int num_cpus;
8338 +       int num_cpus, i;
8339  
8340         /* Fixup boot cpu */
8341          smp_store_cpu_info(smp_processor_id());
8342 @@ -350,7 +350,8 @@
8343  
8344         /* Probe platform for CPUs: always linear. */
8345         num_cpus = smp_ops->probe();
8346 -       cpu_possible_map = (1 << num_cpus)-1;
8347 +       for (i = 0; i < num_cpus; ++i)
8348 +               cpu_set(i, cpu_possible_map);
8349  
8350         /* Backup CPU 0 state */
8351         __save_cpu_setup();
8352 diff -Nru a/arch/ppc/kernel/syscalls.c b/arch/ppc/kernel/syscalls.c
8353 --- a/arch/ppc/kernel/syscalls.c        Tue Jul 15 04:49:49 2003
8354 +++ b/arch/ppc/kernel/syscalls.c        Fri Aug 22 19:15:18 2003
8355 @@ -262,4 +262,14 @@
8356         return error;
8357  }
8358  
8359 +/*
8360 + * We put the arguments in a different order so we only use 6
8361 + * registers for arguments, rather than 7 as sys_fadvise64_64 needs
8362 + * (because `offset' goes in r5/r6).
8363 + */
8364 +long ppc_fadvise64_64(int fd, int advice, loff_t offset, loff_t len)
8365 +{
8366 +       return sys_fadvise64_64(fd, offset, len, advice);
8367 +}
8368 +
8369  cond_syscall(sys_pciconfig_iobase);
8370 diff -Nru a/arch/ppc/platforms/mcpn765_serial.h b/arch/ppc/platforms/mcpn765_serial.h
8371 --- a/arch/ppc/platforms/mcpn765_serial.h       Tue Feb 11 15:48:53 2003
8372 +++ b/arch/ppc/platforms/mcpn765_serial.h       Mon Jul 21 09:05:22 2003
8373 @@ -30,7 +30,8 @@
8374  #endif
8375  
8376  /* Rate for the 1.8432 Mhz clock for the onboard serial chip */
8377 -#define BASE_BAUD ( 1843200 / 16 )
8378 +#define BASE_BAUD      ( 1843200 / 16 )
8379 +#define UART_CLK       1843200
8380  
8381  #ifdef CONFIG_SERIAL_DETECT_IRQ
8382  #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
8383 diff -Nru a/arch/ppc/platforms/mcpn765_setup.c b/arch/ppc/platforms/mcpn765_setup.c
8384 --- a/arch/ppc/platforms/mcpn765_setup.c        Wed Apr 23 00:49:34 2003
8385 +++ b/arch/ppc/platforms/mcpn765_setup.c        Mon Jul 21 09:05:22 2003
8386 @@ -31,6 +31,9 @@
8387  #include <linux/ide.h>
8388  #include <linux/seq_file.h>
8389  #include <linux/root_dev.h>
8390 +#include <linux/serial.h>
8391 +#include <linux/tty.h> /* for linux/serial_core.h */
8392 +#include <linux/serial_core.h>
8393  
8394  #include <asm/system.h>
8395  #include <asm/pgtable.h>
8396 @@ -49,36 +52,94 @@
8397  #include <asm/pplus.h>
8398  
8399  #include "mcpn765.h"
8400 +#include "mcpn765_serial.h"
8401 +
8402  
8403  static u_char mcpn765_openpic_initsenses[] __initdata = {
8404 -       0,      /* 16: i8259 cascade (active high) */
8405 -       1,      /* 17: COM1,2,3,4 */
8406 -       1,      /* 18: Enet 1 (front panel) */
8407 -       1,      /* 19: HAWK WDT XXXX */
8408 -       1,      /* 20: 21554 PCI-PCI bridge */
8409 -       1,      /* 21: cPCI INTA# */
8410 -       1,      /* 22: cPCI INTB# */
8411 -       1,      /* 23: cPCI INTC# */
8412 -       1,      /* 24: cPCI INTD# */
8413 -       1,      /* 25: PMC1 INTA#, PMC2 INTB# */
8414 -       1,      /* 26: PMC1 INTB#, PMC2 INTC# */
8415 -       1,      /* 27: PMC1 INTC#, PMC2 INTD# */
8416 -       1,      /* 28: PMC1 INTD#, PMC2 INTA# */
8417 -       1,      /* 29: Enet 2 (connected to J3) */
8418 -       1,      /* 30: Abort Switch */
8419 -       1,      /* 31: RTC Alarm */
8420 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),/* 16: i8259 cascade */
8421 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 17: COM1,2,3,4 */
8422 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 18: Enet 1 (front) */
8423 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 19: HAWK WDT XXXX */
8424 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 20: 21554 bridge */
8425 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 21: cPCI INTA# */
8426 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 22: cPCI INTB# */
8427 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 23: cPCI INTC# */
8428 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 24: cPCI INTD# */
8429 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 25: PMC1 INTA#,PMC2 INTB#*/
8430 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 26: PMC1 INTB#,PMC2 INTC#*/
8431 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 27: PMC1 INTC#,PMC2 INTD#*/
8432 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 28: PMC1 INTD#,PMC2 INTA#*/
8433 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 29: Enet 2 (J3) */
8434 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 30: Abort Switch */
8435 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 31: RTC Alarm */
8436  };
8437  
8438  
8439  extern u_int openpic_irq(void);
8440  extern char cmd_line[];
8441  
8442 +extern void gen550_progress(char *, unsigned short);
8443 +extern void gen550_init(int, struct uart_port *);
8444 +
8445  int use_of_interrupt_tree = 0;
8446  
8447  static void mcpn765_halt(void);
8448  
8449  TODC_ALLOC();
8450  
8451 +#if defined(CONFIG_SERIAL_8250) && \
8452 +       (defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG))
8453 +static void __init
8454 +mcpn765_early_serial_map(void)
8455 +{
8456 +       struct uart_port serial_req;
8457 +
8458 +       /* Setup serial port access */
8459 +       memset(&serial_req, 0, sizeof(serial_req));
8460 +       serial_req.uartclk = UART_CLK;
8461 +       serial_req.irq = 17;
8462 +       serial_req.flags = STD_COM_FLAGS;
8463 +       serial_req.iotype = SERIAL_IO_MEM;
8464 +       serial_req.membase = (u_char *)MCPN765_SERIAL_1;
8465 +       serial_req.regshift = 4;
8466 +
8467 +       gen550_init(0, &serial_req);
8468 +
8469 +       if (early_serial_setup(&serial_req) != 0)
8470 +               printk(KERN_ERR "Early serial init of port 0 failed\n");
8471 +
8472 +       /* Assume early_serial_setup() doesn't modify serial_req */
8473 +       serial_req.line = 1;
8474 +       serial_req.irq = 17;
8475 +       serial_req.membase = (u_char *)MCPN765_SERIAL_2;
8476 +
8477 +       gen550_init(1, &serial_req);
8478 +
8479 +       if (early_serial_setup(&serial_req) != 0)
8480 +               printk(KERN_ERR "Early serial init of port 1 failed\n");
8481 +
8482 +       /* Assume early_serial_setup() doesn't modify serial_req */
8483 +       serial_req.line = 2;
8484 +       serial_req.irq = 17;
8485 +       serial_req.membase = (u_char *)MCPN765_SERIAL_3;
8486 +
8487 +       gen550_init(2, &serial_req);
8488 +
8489 +       if (early_serial_setup(&serial_req) != 0)
8490 +               printk(KERN_ERR "Early serial init of port 2 failed\n");
8491 +
8492 +       /* Assume early_serial_setup() doesn't modify serial_req */
8493 +       serial_req.line = 3;
8494 +       serial_req.irq = 17;
8495 +       serial_req.membase = (u_char *)MCPN765_SERIAL_4;
8496 +
8497 +       gen550_init(3, &serial_req);
8498 +
8499 +       if (early_serial_setup(&serial_req) != 0)
8500 +               printk(KERN_ERR "Early serial init of port 3 failed\n");
8501 +}
8502 +#endif
8503 +
8504  static void __init
8505  mcpn765_setup_arch(void)
8506  {
8507 @@ -187,12 +248,12 @@
8508         if ( ppc_md.progress )
8509                 ppc_md.progress("init_irq: enter", 0);
8510  
8511 -       openpic_init(1, NUM_8259_INTERRUPTS, NULL, -1);
8512 +       openpic_init(NUM_8259_INTERRUPTS);
8513  
8514         for(i=0; i < NUM_8259_INTERRUPTS; i++)
8515                 irq_desc[i].handler = &i8259_pic;
8516  
8517 -       i8259_init(NULL);
8518 +       i8259_init(0);
8519  
8520         if ( ppc_md.progress )
8521                 ppc_md.progress("init_irq: exit", 0);
8522 @@ -361,65 +422,15 @@
8523  static __inline__ void
8524  mcpn765_set_bat(void)
8525  {
8526 -       unsigned long   bat3u, bat3l;
8527 -       static int      mapping_set = 0;
8528 -
8529 -       if (!mapping_set) {
8530 -
8531 -               __asm__ __volatile__(
8532 -               " lis %0,0xf000\n \
8533 -                 ori %1,%0,0x002a\n \
8534 -                 ori %0,%0,0x1ffe\n \
8535 -                 mtspr 0x21e,%0\n \
8536 -                 mtspr 0x21f,%1\n \
8537 -                 isync\n \
8538 -                 sync "
8539 -               : "=r" (bat3u), "=r" (bat3l));
8540 -
8541 -               mapping_set = 1;
8542 -       }
8543 -
8544 -       return;
8545 -}
8546 -
8547 -#ifdef CONFIG_SERIAL_TEXT_DEBUG
8548 -#include <linux/serialP.h>
8549 -#include <linux/serial_reg.h>
8550 -#include <asm/serial.h>
8551 -
8552 -static struct serial_state rs_table[RS_TABLE_SIZE] = {
8553 -       SERIAL_PORT_DFNS        /* Defined in <asm/serial.h> */
8554 -};
8555 -
8556 -static void
8557 -mcpn765_progress(char *s, unsigned short hex)
8558 -{
8559 -       volatile char c;
8560 -       volatile unsigned long com_port;
8561 -       u16 shift;
8562 -
8563 -       com_port = rs_table[0].port;
8564 -       shift = rs_table[0].iomem_reg_shift;
8565 -
8566 -       while ((c = *s++) != 0) {
8567 -               while ((*((volatile unsigned char *)com_port +
8568 -                               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
8569 -                               ;
8570 -               *(volatile unsigned char *)com_port = c;
8571 -
8572 -               if (c == '\n') {
8573 -                       while ((*((volatile unsigned char *)com_port +
8574 -                               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
8575 -                                       ;
8576 -                       *(volatile unsigned char *)com_port = '\r';
8577 -               }
8578 -       }
8579 +       mb();
8580 +       mtspr(DBAT1U, 0xfe8000fe);
8581 +       mtspr(DBAT1L, 0xfe80002a);
8582 +       mb();
8583  }
8584 -#endif /* CONFIG_SERIAL_TEXT_DEBUG */
8585  
8586  void __init
8587  platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
8588 -             unsigned long r6, unsigned long r7)
8589 +               unsigned long r6, unsigned long r7)
8590  {
8591         parse_bootinfo(find_bootinfo());
8592  
8593 @@ -458,11 +469,13 @@
8594         ppc_md.heartbeat_reset = 0;
8595         ppc_md.heartbeat_count = 0;
8596  
8597 -#ifdef CONFIG_SERIAL_TEXT_DEBUG
8598 -       ppc_md.progress = mcpn765_progress;
8599 -#else  /* !CONFIG_SERIAL_TEXT_DEBUG */
8600 -       ppc_md.progress = NULL;
8601 -#endif /* CONFIG_SERIAL_TEXT_DEBUG */
8602 +#if defined(CONFIG_SERIAL_8250) && \
8603 +       (defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG))
8604 +       mcpn765_early_serial_map();
8605 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8606 +       ppc_md.progress = gen550_progress;
8607 +#endif
8608 +#endif
8609  
8610  #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
8611          ppc_ide_md.default_irq = mcpn765_ide_default_irq;
8612 diff -Nru a/arch/ppc/platforms/pmac_cpufreq.c b/arch/ppc/platforms/pmac_cpufreq.c
8613 --- a/arch/ppc/platforms/pmac_cpufreq.c Wed Jul 23 17:04:23 2003
8614 +++ b/arch/ppc/platforms/pmac_cpufreq.c Mon Aug 25 09:51:43 2003
8615 @@ -21,6 +21,7 @@
8616  #include <linux/slab.h>
8617  #include <linux/cpufreq.h>
8618  #include <linux/init.h>
8619 +#include <linux/sysdev.h>
8620  #include <asm/prom.h>
8621  #include <asm/machdep.h>
8622  #include <asm/irq.h>
8623 @@ -31,12 +32,16 @@
8624  #include <asm/cputable.h>
8625  #include <asm/time.h>
8626  
8627 +/* WARNING !!! This will cause calibrate_delay() to be called,
8628 + * but this is an __init function ! So you MUST go edit
8629 + * init/main.c to make it non-init before enabling DEBUG_FREQ
8630 + */
8631  #undef DEBUG_FREQ
8632  
8633  extern void low_choose_750fx_pll(int pll);
8634  extern void low_sleep_handler(void);
8635 -extern void openpic_sleep_save_intrs(void);
8636 -extern void openpic_sleep_restore_intrs(void);
8637 +extern void openpic_suspend(struct sys_device *sysdev, u32 state);
8638 +extern void openpic_resume(struct sys_device *sysdev);
8639  extern void enable_kernel_altivec(void);
8640  extern void enable_kernel_fp(void);
8641  
8642 @@ -116,10 +121,7 @@
8643         printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));      
8644  #endif
8645         /* Disable all interrupt sources on openpic */
8646 -       openpic_sleep_save_intrs();
8647 -
8648 -       /* Make sure the PMU is idle */
8649 -       pmu_suspend();
8650 +       openpic_suspend(NULL, 1);
8651  
8652         /* Make sure the decrementer won't interrupt us */
8653         asm volatile("mtdec %0" : : "r" (0x7fffffff));
8654 @@ -153,11 +155,16 @@
8655         pmu_request(&req, NULL, 6, PMU_CPU_SPEED, 'W', 'O', 'O', 'F', low_speed);
8656         while (!req.complete)
8657                 pmu_poll();
8658 -       
8659 -       pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,1);
8660  
8661 +       /* Prepare the northbridge for the speed transition */
8662 +       pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,1);
8663 +       
8664 +       /* Call low level code to backup CPU state and recover from
8665 +        * hardware reset
8666 +        */
8667         low_sleep_handler();
8668         
8669 +       /* Restore the northbridge */
8670         pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,0);
8671  
8672         /* Restore L2 cache */
8673 @@ -174,13 +181,14 @@
8674         printk(KERN_DEBUG "HID1, after: %x\n", mfspr(SPRN_HID1));       
8675  #endif
8676  
8677 +       /* Restore low level PMU operations */
8678 +       pmu_unlock();
8679 +
8680         /* Restore decrementer */
8681         wakeup_decrementer();
8682  
8683         /* Restore interrupts */
8684 -       openpic_sleep_restore_intrs();
8685 -
8686 -       pmu_resume();
8687 +       openpic_resume(NULL);
8688  
8689         /* Let interrupts flow again ... */
8690         local_irq_enable();
8691 @@ -195,13 +203,16 @@
8692  static int __pmac
8693  do_set_cpu_speed(int speed_mode)
8694  {
8695 -       struct cpufreq_freqs    freqs;
8696 +       struct cpufreq_freqs freqs;
8697         int rc;
8698         
8699         freqs.old = cur_freq;
8700         freqs.new = (speed_mode == PMAC_CPU_HIGH_SPEED) ? hi_freq : low_freq;
8701         freqs.cpu = smp_processor_id();
8702  
8703 +       if (freqs.old == freqs.new)
8704 +               return 0;
8705 +
8706         cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
8707         if (cpufreq_uses_pmu)
8708                 rc = pmu_set_cpu_speed(speed_mode);
8709 @@ -275,7 +286,10 @@
8710         struct device_node      *cpunode;
8711         u32                     *value;
8712         int                     has_freq_ctl = 0;
8713 -       
8714 +       
8715 +       if (strstr(cmd_line, "nocpufreq"))
8716 +               return 0;
8717 +
8718         /* Assume only one CPU */
8719         cpunode = find_type_devices("cpu");
8720         if (!cpunode)
8721 diff -Nru a/arch/ppc/platforms/pmac_pic.c b/arch/ppc/platforms/pmac_pic.c
8722 --- a/arch/ppc/platforms/pmac_pic.c     Wed Apr 30 05:41:43 2003
8723 +++ b/arch/ppc/platforms/pmac_pic.c     Sun Aug 24 04:12:57 2003
8724 @@ -22,6 +22,9 @@
8725  #include <linux/signal.h>
8726  #include <linux/pci.h>
8727  #include <linux/interrupt.h>
8728 +#include <linux/sysdev.h>
8729 +#include <linux/adb.h>
8730 +#include <linux/pmu.h>
8731  
8732  #include <asm/sections.h>
8733  #include <asm/io.h>
8734 @@ -506,7 +509,7 @@
8735  #endif /* CONFIG_XMON */
8736  }
8737  
8738 -#ifdef CONFIG_PMAC_PBOOK
8739 +#ifdef CONFIG_PM
8740  /*
8741   * These procedures are used in implementing sleep on the powerbooks.
8742   * sleep_save_intrs() saves the states of all interrupt enables
8743 @@ -515,9 +518,32 @@
8744   */
8745  unsigned long sleep_save_mask[2];
8746  
8747 -void __pmac
8748 -pmac_sleep_save_intrs(int viaint)
8749 +/* This used to be passed by the PMU driver but that link got
8750 + * broken with the new driver model. We use this tweak for now...
8751 + */
8752 +static int pmacpic_find_viaint(void)
8753  {
8754 +       int viaint = -1;
8755 +       
8756 +#ifdef CONFIG_ADB_PMU
8757 +       struct device_node *np;
8758 +
8759 +       if (pmu_get_model() != PMU_OHARE_BASED)
8760 +               goto not_found;
8761 +       np = of_find_node_by_name(NULL, "via-pmu");
8762 +       if (np == NULL)
8763 +               goto not_found;
8764 +       viaint = np->intrs[0].line;
8765 +#endif /* CONFIG_ADB_PMU */
8766 +
8767 +not_found:
8768 +       return viaint;
8769 +}
8770 +
8771 +static int pmacpic_suspend(struct sys_device *sysdev, u32 state)
8772 +{
8773 +       int viaint = pmacpic_find_viaint();
8774 +       
8775         sleep_save_mask[0] = ppc_cached_irq_mask[0];
8776         sleep_save_mask[1] = ppc_cached_irq_mask[1];
8777         ppc_cached_irq_mask[0] = 0;
8778 @@ -531,10 +557,11 @@
8779         /* make sure mask gets to controller before we return to caller */
8780         mb();
8781          (void)in_le32(&pmac_irq_hw[0]->enable);
8782 +
8783 +        return 0;
8784  }
8785  
8786 -void __pmac
8787 -pmac_sleep_restore_intrs(void)
8788 +static int pmacpic_resume(struct sys_device *sysdev)
8789  {
8790         int i;
8791  
8792 @@ -545,5 +572,39 @@
8793         for (i = 0; i < max_real_irqs; ++i)
8794                 if (test_bit(i, sleep_save_mask))
8795                         pmac_unmask_irq(i);
8796 +
8797 +       return 0;
8798  }
8799 -#endif /* CONFIG_PMAC_PBOOK */
8800 +
8801 +#endif /* CONFIG_PM */
8802 +
8803 +static struct sysdev_class pmacpic_sysclass = {
8804 +       set_kset_name("pmac_pic"),
8805 +};
8806 +
8807 +static struct sys_device device_pmacpic = {
8808 +       .id             = 0,
8809 +       .cls            = &pmacpic_sysclass,
8810 +};
8811 +
8812 +static struct sysdev_driver driver_pmacpic = {
8813 +#ifdef CONFIG_PM
8814 +       .suspend        = &pmacpic_suspend,
8815 +       .resume         = &pmacpic_resume,
8816 +#endif /* CONFIG_PM */ 
8817 +};
8818 +
8819 +static int __init init_pmacpic_sysfs(void)
8820 +{
8821 +       if (max_irqs == 0)
8822 +               return -ENODEV;
8823 +
8824 +       printk(KERN_DEBUG "Registering pmac pic with sysfs...\n");
8825 +       sysdev_class_register(&pmacpic_sysclass);
8826 +       sys_device_register(&device_pmacpic);
8827 +       sysdev_driver_register(&pmacpic_sysclass, &driver_pmacpic);
8828 +       return 0;
8829 +}
8830 +
8831 +subsys_initcall(init_pmacpic_sysfs);
8832 +
8833 diff -Nru a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
8834 --- a/arch/ppc/platforms/sandpoint.c    Tue Jul  1 10:56:46 2003
8835 +++ b/arch/ppc/platforms/sandpoint.c    Thu Aug 21 10:19:10 2003
8836 @@ -357,6 +357,21 @@
8837  }
8838  
8839  /*
8840 + * Fix IDE interrupts.
8841 + */
8842 +static int __init
8843 +sandpoint_fix_winbond_83553(void)
8844 +{
8845 +       /* Make all 8259 interrupt level sensitive */
8846 +       outb(0xf8, 0x4d0);
8847 +       outb(0xde, 0x4d1);
8848 +
8849 +       return 0;
8850 +}
8851 +
8852 +arch_initcall(sandpoint_fix_winbond_83553);
8853 +
8854 +/*
8855   * Initialize the ISA devices on the Nat'l PC87308VUL SuperIO chip.
8856   */
8857  static int __init
8858 @@ -390,21 +405,6 @@
8859  }
8860  
8861  arch_initcall(sandpoint_setup_natl_87308);
8862 -
8863 -/*
8864 - * Fix IDE interrupts.
8865 - */
8866 -static int __init
8867 -sandpoint_fix_winbond_83553(void)
8868 -{
8869 -       /* Make all 8259 interrupt level sensitive */
8870 -       outb(0xf8, 0x4d0);
8871 -       outb(0xde, 0x4d1);
8872 -
8873 -       return 0;
8874 -}
8875 -
8876 -arch_initcall(sandpoint_fix_winbond_83553);
8877  
8878  static int __init
8879  sandpoint_request_io(void)
8880 diff -Nru a/arch/ppc/platforms/sandpoint.h b/arch/ppc/platforms/sandpoint.h
8881 --- a/arch/ppc/platforms/sandpoint.h    Tue Jul  1 10:56:46 2003
8882 +++ b/arch/ppc/platforms/sandpoint.h    Thu Aug 21 10:19:10 2003
8883 @@ -61,9 +61,9 @@
8884  #define UART_CLK                       1843200
8885  
8886  #ifdef CONFIG_SERIAL_DETECT_IRQ
8887 -#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
8888 +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_AUTO_IRQ)
8889  #else
8890 -#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
8891 +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF)
8892  #endif
8893  
8894  #define STD_SERIAL_PORT_DFNS \
8895 diff -Nru a/arch/ppc/syslib/of_device.c b/arch/ppc/syslib/of_device.c
8896 --- a/arch/ppc/syslib/of_device.c       Sat Aug 16 11:48:20 2003
8897 +++ b/arch/ppc/syslib/of_device.c       Tue Aug 26 06:35:38 2003
8898 @@ -15,8 +15,8 @@
8899   * Used by a driver to check whether an of_device present in the
8900   * system is in its list of supported devices. 
8901   */
8902 -const struct of_match *
8903 -of_match_device(const struct of_match *matches, const struct of_device *dev)
8904 +const struct of_match * of_match_device(const struct of_match *matches,
8905 +                                       const struct of_device *dev)
8906  {
8907         if (!dev->node)
8908                 return NULL;
8909 @@ -38,8 +38,7 @@
8910         return NULL;
8911  }
8912  
8913 -static int
8914 -of_platform_bus_match(struct device *dev, struct device_driver *drv) 
8915 +static int of_platform_bus_match(struct device *dev, struct device_driver *drv) 
8916  {
8917         struct of_device * of_dev = to_of_device(dev);
8918         struct of_platform_driver * of_drv = to_of_platform_driver(drv);
8919 @@ -51,21 +50,27 @@
8920         return of_match_device(matches, of_dev) != NULL;
8921  }
8922  
8923 -struct bus_type of_platform_bus_type = {
8924 -       name:   "of_platform",
8925 -       match:  of_platform_bus_match,
8926 -};
8927 +struct of_device *of_dev_get(struct of_device *dev)
8928 +{
8929 +       struct device *tmp;
8930 +
8931 +       if (!dev)
8932 +               return NULL;
8933 +       tmp = get_device(&dev->dev);
8934 +       if (tmp)
8935 +               return to_of_device(tmp);
8936 +       else
8937 +               return NULL;
8938 +}
8939  
8940 -static int __init
8941 -of_bus_driver_init(void)
8942 +void of_dev_put(struct of_device *dev)
8943  {
8944 -       return bus_register(&of_platform_bus_type);
8945 +       if (dev)
8946 +               put_device(&dev->dev);
8947  }
8948  
8949 -postcore_initcall(of_bus_driver_init);
8950  
8951 -static int
8952 -of_device_probe(struct device *dev)
8953 +static int of_device_probe(struct device *dev)
8954  {
8955         int error = -ENODEV;
8956         struct of_platform_driver *drv;
8957 @@ -78,22 +83,18 @@
8958         if (!drv->probe)
8959                 return error;
8960  
8961 -/*     if (!try_module_get(driver->owner)) {
8962 -               printk(KERN_ERR "Can't get a module reference for %s\n", driver->name);
8963 -               return error;
8964 -       }
8965 -*/
8966 +       of_dev_get(of_dev);
8967 +
8968         match = of_match_device(drv->match_table, of_dev);
8969         if (match)
8970                 error = drv->probe(of_dev, match);
8971 -/*
8972 -       module_put(driver->owner);
8973 -*/     
8974 +       if (error)
8975 +               of_dev_put(of_dev);
8976 +
8977         return error;
8978  }
8979  
8980 -static int
8981 -of_device_remove(struct device *dev)
8982 +static int of_device_remove(struct device *dev)
8983  {
8984         struct of_device * of_dev = to_of_device(dev);
8985         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
8986 @@ -103,32 +104,43 @@
8987         return 0;
8988  }
8989  
8990 -static int
8991 -of_device_suspend(struct device *dev, u32 state, u32 level)
8992 +static int of_device_suspend(struct device *dev, u32 state)
8993  {
8994         struct of_device * of_dev = to_of_device(dev);
8995         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
8996         int error = 0;
8997  
8998         if (drv && drv->suspend)
8999 -               error = drv->suspend(of_dev, state, level);
9000 +               error = drv->suspend(of_dev, state);
9001         return error;
9002  }
9003  
9004 -static int
9005 -of_device_resume(struct device * dev, u32 level)
9006 +static int of_device_resume(struct device * dev)
9007  {
9008         struct of_device * of_dev = to_of_device(dev);
9009         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
9010         int error = 0;
9011  
9012         if (drv && drv->resume)
9013 -               error = drv->resume(of_dev, level);
9014 +               error = drv->resume(of_dev);
9015         return error;
9016  }
9017  
9018 -int
9019 -of_register_driver(struct of_platform_driver *drv)
9020 +struct bus_type of_platform_bus_type = {
9021 +       .name   = "of_platform",
9022 +       .match  = of_platform_bus_match,
9023 +       .suspend        = of_device_suspend,
9024 +       .resume = of_device_resume,
9025 +};
9026 +
9027 +static int __init of_bus_driver_init(void)
9028 +{
9029 +       return bus_register(&of_platform_bus_type);
9030 +}
9031 +
9032 +postcore_initcall(of_bus_driver_init);
9033 +
9034 +int of_register_driver(struct of_platform_driver *drv)
9035  {
9036         int count = 0;
9037  
9038 @@ -136,8 +148,6 @@
9039         drv->driver.name = drv->name;
9040         drv->driver.bus = &of_platform_bus_type;
9041         drv->driver.probe = of_device_probe;
9042 -       drv->driver.resume = of_device_resume;
9043 -       drv->driver.suspend = of_device_suspend;
9044         drv->driver.remove = of_device_remove;
9045  
9046         /* register with core */
9047 @@ -145,15 +155,13 @@
9048         return count ? count : 1;
9049  }
9050  
9051 -void
9052 -of_unregister_driver(struct of_platform_driver *drv)
9053 +void of_unregister_driver(struct of_platform_driver *drv)
9054  {
9055         driver_unregister(&drv->driver);
9056  }
9057  
9058  
9059 -static ssize_t
9060 -dev_show_devspec(struct device *dev, char *buf)
9061 +static ssize_t dev_show_devspec(struct device *dev, char *buf)
9062  {
9063         struct of_device *ofdev;
9064  
9065 @@ -163,8 +171,22 @@
9066  
9067  static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL);
9068  
9069 -int
9070 -of_device_register(struct of_device *ofdev)
9071 +/**
9072 + * of_release_dev - free an of device structure when all users of it are finished.
9073 + * @dev: device that's been disconnected
9074 + *
9075 + * Will be called only by the device core when all users of this of device are
9076 + * done.
9077 + */
9078 +void of_release_dev(struct device *dev)
9079 +{
9080 +       struct of_device *ofdev;
9081 +
9082 +        ofdev = to_of_device(dev);
9083 +       kfree(ofdev);
9084 +}
9085 +
9086 +int of_device_register(struct of_device *ofdev)
9087  {
9088         int rc;
9089         struct of_device **odprop;
9090 @@ -197,21 +219,20 @@
9091         return 0;
9092  }
9093  
9094 -void
9095 -of_device_unregister(struct of_device *ofdev)
9096 +void of_device_unregister(struct of_device *ofdev)
9097  {
9098         struct of_device **odprop;
9099  
9100         device_remove_file(&ofdev->dev, &dev_attr_devspec);
9101 -       device_unregister(&ofdev->dev);
9102  
9103         odprop = (struct of_device **)get_property(ofdev->node, "linux,device", NULL);
9104         if (odprop)
9105                 *odprop = NULL;
9106 +
9107 +       device_unregister(&ofdev->dev);
9108  }
9109  
9110 -struct of_device*
9111 -of_platform_device_create(struct device_node *np, const char *bus_id)
9112 +struct of_device* of_platform_device_create(struct device_node *np, const char *bus_id)
9113  {
9114         struct of_device *dev;
9115         u32 *reg;
9116 @@ -226,6 +247,7 @@
9117         dev->dev.dma_mask = &dev->dma_mask;
9118         dev->dev.parent = NULL;
9119         dev->dev.bus = &of_platform_bus_type;
9120 +       dev->dev.release = of_release_dev;
9121  
9122         reg = (u32 *)get_property(np, "reg", NULL);
9123         strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
9124 @@ -244,4 +266,7 @@
9125  EXPORT_SYMBOL(of_unregister_driver);
9126  EXPORT_SYMBOL(of_device_register);
9127  EXPORT_SYMBOL(of_device_unregister);
9128 +EXPORT_SYMBOL(of_dev_get);
9129 +EXPORT_SYMBOL(of_dev_put);
9130  EXPORT_SYMBOL(of_platform_device_create);
9131 +EXPORT_SYMBOL(of_release_dev);
9132 diff -Nru a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
9133 --- a/arch/ppc/syslib/open_pic.c        Tue Jul 15 10:01:29 2003
9134 +++ b/arch/ppc/syslib/open_pic.c        Sun Aug 24 04:11:21 2003
9135 @@ -15,6 +15,7 @@
9136  #include <linux/init.h>
9137  #include <linux/irq.h>
9138  #include <linux/interrupt.h>
9139 +#include <linux/sysdev.h>
9140  #include <asm/ptrace.h>
9141  #include <asm/signal.h>
9142  #include <asm/io.h>
9143 @@ -276,7 +277,7 @@
9144  }
9145  #endif
9146  
9147 -#if defined(CONFIG_EPIC_SERIAL_MODE) || defined(CONFIG_PMAC_PBOOK)
9148 +#if defined(CONFIG_EPIC_SERIAL_MODE) || defined(CONFIG_PM)
9149  static void openpic_reset(void)
9150  {
9151         openpic_setfield(&OpenPIC->Global.Global_Configuration0,
9152 @@ -532,7 +533,7 @@
9153         openpic_write(&OpenPIC->Global.Processor_Initialization, mask);
9154  }
9155  
9156 -#if defined(CONFIG_SMP) || defined(CONFIG_PMAC_PBOOK)
9157 +#if defined(CONFIG_SMP) || defined(CONFIG_PM)
9158  static spinlock_t openpic_setup_lock = SPIN_LOCK_UNLOCKED;
9159  #endif
9160  
9161 @@ -864,20 +865,55 @@
9162  }
9163  #endif /* CONFIG_SMP */
9164  
9165 -#ifdef CONFIG_PMAC_PBOOK
9166 +#ifdef CONFIG_PM
9167 +
9168 +/*
9169 + * We implement the IRQ controller as a sysdev and put it
9170 + * to sleep at powerdown stage (the callback is named suspend,
9171 + * but it's old semantics, for the Device Model, it's really
9172 + * powerdown). The possible problem is that another sysdev that
9173 + * happens to be suspend after this one will have interrupts off,
9174 + * that may be an issue... For now, this isn't an issue on pmac
9175 + * though...
9176 + */
9177 +
9178  static u32 save_ipi_vp[OPENPIC_NUM_IPI];
9179  static u32 save_irq_src_vp[OPENPIC_MAX_SOURCES];
9180  static u32 save_irq_src_dest[OPENPIC_MAX_SOURCES];
9181  static u32 save_cpu_task_pri[OPENPIC_MAX_PROCESSORS];
9182 +static int openpic_suspend_count;
9183 +
9184 +static void openpic_cached_enable_irq(u_int irq)
9185 +{
9186 +       check_arg_irq(irq);
9187 +       save_irq_src_vp[irq - open_pic_irq_offset] &= ~OPENPIC_MASK; 
9188 +}
9189  
9190 -void __pmac
9191 -openpic_sleep_save_intrs(void)
9192 +static void openpic_cached_disable_irq(u_int irq)
9193 +{
9194 +       check_arg_irq(irq);
9195 +       save_irq_src_vp[irq - open_pic_irq_offset] |= OPENPIC_MASK; 
9196 +}
9197 +
9198 +/* WARNING: Can be called directly by the cpufreq code with NULL parameter,
9199 + * we need something better to deal with that... Maybe switch to S1 for
9200 + * cpufreq changes
9201 + */
9202 +int openpic_suspend(struct sys_device *sysdev, u32 state)
9203  {
9204         int     i;
9205         unsigned long flags;
9206         
9207         spin_lock_irqsave(&openpic_setup_lock, flags);
9208  
9209 +       if (openpic_suspend_count++ > 0) {
9210 +               spin_unlock_irqrestore(&openpic_setup_lock, flags);
9211 +               return 0;
9212 +       }
9213 +
9214 +       open_pic.enable = openpic_cached_enable_irq;
9215 +       open_pic.disable = openpic_cached_disable_irq;
9216 +
9217         for (i=0; i<NumProcessors; i++) {
9218                 save_cpu_task_pri[i] = openpic_read(&OpenPIC->Processor[i].Current_Task_Priority);
9219                 openpic_writefield(&OpenPIC->Processor[i].Current_Task_Priority,
9220 @@ -889,38 +925,112 @@
9221         for (i=0; i<NumSources; i++) {
9222                 if (ISR[i] == 0)
9223                         continue;
9224 -               save_irq_src_vp[i] = openpic_read(&ISR[i]->Vector_Priority)
9225 -                       & ~OPENPIC_ACTIVITY;
9226 +               save_irq_src_vp[i] = openpic_read(&ISR[i]->Vector_Priority) & ~OPENPIC_ACTIVITY;
9227                 save_irq_src_dest[i] = openpic_read(&ISR[i]->Destination);
9228         }
9229 +
9230         spin_unlock_irqrestore(&openpic_setup_lock, flags);
9231 +
9232 +       return 0;
9233  }
9234  
9235 -void __pmac
9236 -openpic_sleep_restore_intrs(void)
9237 +/* WARNING: Can be called directly by the cpufreq code with NULL parameter,
9238 + * we need something better to deal with that... Maybe switch to S1 for
9239 + * cpufreq changes
9240 + */
9241 +int openpic_resume(struct sys_device *sysdev)
9242  {
9243         int             i;
9244         unsigned long   flags;
9245 +       u32             vppmask =       OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |
9246 +                                       OPENPIC_SENSE_MASK | OPENPIC_POLARITY_MASK |
9247 +                                       OPENPIC_MASK;
9248  
9249         spin_lock_irqsave(&openpic_setup_lock, flags);
9250         
9251 +       if ((--openpic_suspend_count) > 0) {
9252 +               spin_unlock_irqrestore(&openpic_setup_lock, flags);
9253 +               return 0;
9254 +       }
9255 +
9256         openpic_reset();
9257  
9258 +       /* OpenPIC sometimes seem to need some time to be fully back up... */
9259 +       do {
9260 +               openpic_set_spurious(OPENPIC_VEC_SPURIOUS+open_pic_irq_offset);
9261 +       } while(openpic_readfield(&OpenPIC->Global.Spurious_Vector, OPENPIC_VECTOR_MASK)
9262 +                       != (OPENPIC_VEC_SPURIOUS + open_pic_irq_offset));
9263 +                       
9264 +       openpic_disable_8259_pass_through();
9265 +
9266         for (i=0; i<OPENPIC_NUM_IPI; i++)
9267                 openpic_write(&OpenPIC->Global.IPI_Vector_Priority(i),
9268                               save_ipi_vp[i]);
9269         for (i=0; i<NumSources; i++) {
9270                 if (ISR[i] == 0)
9271                         continue;
9272 -               openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
9273                 openpic_write(&ISR[i]->Destination, save_irq_src_dest[i]);
9274 +               openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
9275 +               /* make sure mask gets to controller before we return to user */
9276 +               do {
9277 +                       openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
9278 +               } while (openpic_readfield(&ISR[i]->Vector_Priority, vppmask)
9279 +                        != (save_irq_src_vp[i] & vppmask));
9280         }
9281 -       openpic_set_spurious(OPENPIC_VEC_SPURIOUS+open_pic_irq_offset);
9282 -       openpic_disable_8259_pass_through();
9283         for (i=0; i<NumProcessors; i++)
9284                 openpic_write(&OpenPIC->Processor[i].Current_Task_Priority,
9285                               save_cpu_task_pri[i]);
9286  
9287 +       open_pic.enable = openpic_enable_irq;
9288 +       open_pic.disable = openpic_disable_irq;
9289 +
9290         spin_unlock_irqrestore(&openpic_setup_lock, flags);
9291 +
9292 +       return 0;
9293 +}
9294 +
9295 +#endif /* CONFIG_PM */
9296 +
9297 +static struct sysdev_class openpic_sysclass = {
9298 +       set_kset_name("openpic"),
9299 +};
9300 +
9301 +static struct sys_device device_openpic = {
9302 +       .id             = 0,
9303 +       .cls            = &openpic_sysclass,
9304 +};
9305 +
9306 +static struct sysdev_driver driver_openpic = {
9307 +#ifdef CONFIG_PM
9308 +       .suspend        = &openpic_suspend,
9309 +       .resume         = &openpic_resume,
9310 +#endif /* CONFIG_PM */ 
9311 +};
9312 +
9313 +static int __init init_openpic_sysfs(void)
9314 +{
9315 +       int rc;
9316 +
9317 +       if (!OpenPIC_Addr)
9318 +               return -ENODEV;
9319 +       printk(KERN_DEBUG "Registering openpic with sysfs...\n");
9320 +       rc = sysdev_class_register(&openpic_sysclass);
9321 +       if (rc) {
9322 +               printk(KERN_ERR "Failed registering openpic sys class\n");
9323 +               return -ENODEV;
9324 +       }
9325 +       rc = sys_device_register(&device_openpic);
9326 +       if (rc) {
9327 +               printk(KERN_ERR "Failed registering openpic sys device\n");
9328 +               return -ENODEV;
9329 +       }
9330 +       rc = sysdev_driver_register(&openpic_sysclass, &driver_openpic);
9331 +       if (rc) {
9332 +               printk(KERN_ERR "Failed registering openpic sys driver\n");
9333 +               return -ENODEV;
9334 +       }
9335 +       return 0;
9336  }
9337 -#endif /* CONFIG_PMAC_PBOOK */
9338 +
9339 +subsys_initcall(init_openpic_sysfs);
9340 +
9341 diff -Nru a/arch/ppc/syslib/prom.c b/arch/ppc/syslib/prom.c
9342 --- a/arch/ppc/syslib/prom.c    Sat Jun  7 02:18:01 2003
9343 +++ b/arch/ppc/syslib/prom.c    Sun Aug 24 03:57:52 2003
9344 @@ -941,6 +941,184 @@
9345         return NULL;
9346  }
9347  
9348 +/*******
9349 + *
9350 + * New implementation of the OF "find" APIs, return a refcounted
9351 + * object, call of_node_put() when done. Currently, still lacks
9352 + * locking as old implementation, this is beeing done for ppc64.
9353 + *
9354 + * Note that property management will need some locking as well,
9355 + * this isn't dealt with yet
9356 + *
9357 + *******/
9358 +
9359 +/**
9360 + *     of_find_node_by_name - Find a node by it's "name" property
9361 + *     @from:  The node to start searching from or NULL, the node
9362 + *             you pass will not be searched, only the next one
9363 + *             will; typically, you pass what the previous call
9364 + *             returned. of_node_put() will be called on it
9365 + *     @name:  The name string to match against
9366 + *
9367 + *     Returns a node pointer with refcount incremented, use
9368 + *     of_node_put() on it when done.
9369 + */ 
9370 +struct device_node *of_find_node_by_name(struct device_node *from,
9371 +       const char *name)
9372 +{
9373 +       struct device_node *np = from ? from->allnext : allnodes;
9374 +
9375 +       for (; np != 0; np = np->allnext)
9376 +               if (np->name != 0 && strcasecmp(np->name, name) == 0)
9377 +                       break;
9378 +       if (from)
9379 +               of_node_put(from);
9380 +       return of_node_get(np);
9381 +}
9382 +
9383 +/**
9384 + *     of_find_node_by_type - Find a node by it's "device_type" property
9385 + *     @from:  The node to start searching from or NULL, the node
9386 + *             you pass will not be searched, only the next one
9387 + *             will; typically, you pass what the previous call
9388 + *             returned. of_node_put() will be called on it
9389 + *     @name:  The type string to match against
9390 + *
9391 + *     Returns a node pointer with refcount incremented, use
9392 + *     of_node_put() on it when done.
9393 + */
9394 +struct device_node *of_find_node_by_type(struct device_node *from,
9395 +       const char *type)
9396 +{
9397 +       struct device_node *np = from ? from->allnext : allnodes;
9398 +
9399 +       for (; np != 0; np = np->allnext)
9400 +               if (np->type != 0 && strcasecmp(np->type, type) == 0)
9401 +                       break;
9402 +       if (from)
9403 +               of_node_put(from);
9404 +       return of_node_get(np);
9405 +}
9406 +
9407 +/**
9408 + *     of_find_compatible_node - Find a node based on type and one of the
9409 + *                                tokens in it's "compatible" property
9410 + *     @from:          The node to start searching from or NULL, the node
9411 + *                     you pass will not be searched, only the next one
9412 + *                     will; typically, you pass what the previous call
9413 + *                     returned. of_node_put() will be called on it
9414 + *     @type:          The type string to match "device_type" or NULL to ignore
9415 + *     @compatible:    The string to match to one of the tokens in the device
9416 + *                     "compatible" list.
9417 + *
9418 + *     Returns a node pointer with refcount incremented, use
9419 + *     of_node_put() on it when done.
9420 + */
9421 +struct device_node *of_find_compatible_node(struct device_node *from,
9422 +       const char *type, const char *compatible)
9423 +{
9424 +       struct device_node *np = from ? from->allnext : allnodes;
9425 +
9426 +       for (; np != 0; np = np->allnext) {
9427 +               if (type != NULL
9428 +                   && !(np->type != 0 && strcasecmp(np->type, type) == 0))
9429 +                       continue;
9430 +               if (device_is_compatible(np, compatible))
9431 +                       break;
9432 +       }
9433 +       if (from)
9434 +               of_node_put(from);
9435 +       return of_node_get(np);
9436 +}
9437 +
9438 +/**
9439 + *     of_find_node_by_path - Find a node matching a full OF path
9440 + *     @path:  The full path to match
9441 + *
9442 + *     Returns a node pointer with refcount incremented, use
9443 + *     of_node_put() on it when done.
9444 + */
9445 +struct device_node *of_find_node_by_path(const char *path)
9446 +{
9447 +       struct device_node *np = allnodes;
9448 +
9449 +       for (; np != 0; np = np->allnext)
9450 +               if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0)
9451 +                       break;
9452 +       return of_node_get(np);
9453 +}
9454 +
9455 +/**
9456 + *     of_find_all_nodes - Get next node in global list
9457 + *     @prev:  Previous node or NULL to start iteration
9458 + *             of_node_put() will be called on it
9459 + *
9460 + *     Returns a node pointer with refcount incremented, use
9461 + *     of_node_put() on it when done.
9462 + */
9463 +struct device_node *of_find_all_nodes(struct device_node *prev)
9464 +{
9465 +       return of_node_get(prev ? prev->allnext : allnodes);
9466 +}
9467 +
9468 +/**
9469 + *     of_get_parent - Get a node's parent if any
9470 + *     @node:  Node to get parent
9471 + *
9472 + *     Returns a node pointer with refcount incremented, use
9473 + *     of_node_put() on it when done.
9474 + */
9475 +struct device_node *of_get_parent(const struct device_node *node)
9476 +{
9477 +       return node ? of_node_get(node->parent) : NULL;
9478 +}
9479 +
9480 +/**
9481 + *     of_get_next_child - Iterate a node childs
9482 + *     @node:  parent node
9483 + *     @prev:  previous child of the parent node, or NULL to get first
9484 + *
9485 + *     Returns a node pointer with refcount incremented, use
9486 + *     of_node_put() on it when done.
9487 + */
9488 +struct device_node *of_get_next_child(const struct device_node *node,
9489 +                                     struct device_node *prev)
9490 +{
9491 +       struct device_node *next = prev ? prev->sibling : node->child;
9492 +
9493 +       for (; next != 0; next = next->sibling)
9494 +               if (of_node_get(next))
9495 +                       break;
9496 +       if (prev)
9497 +               of_node_put(prev);
9498 +       return next;
9499 +}
9500 +
9501 +/**
9502 + *     of_node_get - Increment refcount of a node
9503 + *     @node:  Node to inc refcount, NULL is supported to
9504 + *             simplify writing of callers
9505 + *
9506 + *     Returns the node itself or NULL if gone. Current implementation
9507 + *     does nothing as we don't yet do dynamic node allocation on ppc32
9508 + */
9509 +struct device_node *of_node_get(struct device_node *node)
9510 +{
9511 +       return node;
9512 +}
9513 +
9514 +/**
9515 + *     of_node_put - Decrement refcount of a node
9516 + *     @node:  Node to dec refcount, NULL is supported to
9517 + *             simplify writing of callers
9518 + *
9519 + *     Current implementation does nothing as we don't yet do dynamic node
9520 + *     allocation on ppc32
9521 + */
9522 +void  of_node_put(struct device_node *node)
9523 +{    
9524 +}
9525 +
9526  /*
9527   * Find the device_node with a given phandle.
9528   */
9529 diff -Nru a/arch/ppc/xmon/start.c b/arch/ppc/xmon/start.c
9530 --- a/arch/ppc/xmon/start.c     Sat Jun  7 02:18:02 2003
9531 +++ b/arch/ppc/xmon/start.c     Sun Aug 24 07:39:33 2003
9532 @@ -225,14 +225,13 @@
9533  static int scc_initialized = 0;
9534  
9535  void xmon_init_scc(void);
9536 -extern void pmu_poll(void);
9537  extern void cuda_poll(void);
9538  
9539  static inline void do_poll_adb(void)
9540  {
9541  #ifdef CONFIG_ADB_PMU
9542         if (sys_ctrler == SYS_CTRLER_PMU)
9543 -               pmu_poll();
9544 +               pmu_poll_adb();
9545  #endif /* CONFIG_ADB_PMU */
9546  #ifdef CONFIG_ADB_CUDA
9547         if (sys_ctrler == SYS_CTRLER_CUDA)
9548 diff -Nru a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
9549 --- a/arch/ppc64/Kconfig        Mon Aug 18 19:46:23 2003
9550 +++ b/arch/ppc64/Kconfig        Sun Aug 31 16:14:22 2003
9551 @@ -175,22 +175,6 @@
9552         bool
9553         default PCI
9554  
9555 -# only elf supported, a.out is not -- Cort
9556 -config KCORE_ELF
9557 -       bool
9558 -       depends on PROC_FS
9559 -       default y
9560 -       help
9561 -         If you enabled support for /proc file system then the file
9562 -         /proc/kcore will contain the kernel core image in ELF format. This
9563 -         can be used in gdb:
9564 -
9565 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
9566 -
9567 -         This is especially useful if you have compiled the kernel with the
9568 -         "-g" option to preserve debugging information. It is mainly used
9569 -         for examining kernel data structures on the live kernel.
9570 -
9571  source "fs/Kconfig.binfmt"
9572  
9573  source "drivers/pci/Kconfig"
9574 diff -Nru a/arch/ppc64/kernel/ioctl32.c b/arch/ppc64/kernel/ioctl32.c
9575 --- a/arch/ppc64/kernel/ioctl32.c       Fri Aug  8 14:53:47 2003
9576 +++ b/arch/ppc64/kernel/ioctl32.c       Sun Aug 31 16:14:44 2003
9577 @@ -725,7 +725,7 @@
9578  #define IOCTL_TABLE_START \
9579         struct ioctl_trans ioctl_start[] = {
9580  #define IOCTL_TABLE_END \
9581 -       }; struct ioctl_trans ioctl_end[0];
9582 +       };
9583  
9584  IOCTL_TABLE_START
9585  #include <linux/compat_ioctl.h>
9586 @@ -763,3 +763,5 @@
9587  HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
9588  HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
9589  IOCTL_TABLE_END
9590 +
9591 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
9592 diff -Nru a/arch/ppc64/kernel/proc_ppc64.c b/arch/ppc64/kernel/proc_ppc64.c
9593 --- a/arch/ppc64/kernel/proc_ppc64.c    Tue Mar 25 20:30:59 2003
9594 +++ b/arch/ppc64/kernel/proc_ppc64.c    Sun Aug 31 16:14:08 2003
9595 @@ -47,9 +47,9 @@
9596  static int     page_map_mmap( struct file *file, struct vm_area_struct *vma );
9597  
9598  static struct file_operations page_map_fops = {
9599 -       llseek: page_map_seek,
9600 -       read:   page_map_read,
9601 -       mmap:   page_map_mmap
9602 +       .llseek = page_map_seek,
9603 +       .read   = page_map_read,
9604 +       .mmap   = page_map_mmap
9605  };
9606  
9607  
9608 diff -Nru a/arch/ppc64/kernel/scanlog.c b/arch/ppc64/kernel/scanlog.c
9609 --- a/arch/ppc64/kernel/scanlog.c       Thu Feb 13 00:47:26 2003
9610 +++ b/arch/ppc64/kernel/scanlog.c       Sun Aug 31 16:14:08 2003
9611 @@ -190,11 +190,11 @@
9612  }
9613  
9614  struct file_operations scanlog_fops = {
9615 -       owner:          THIS_MODULE,
9616 -       read:           scanlog_read,
9617 -       write:          scanlog_write,
9618 -       open:           scanlog_open,
9619 -       release:        scanlog_release,
9620 +       .owner          = THIS_MODULE,
9621 +       .read           = scanlog_read,
9622 +       .write          = scanlog_write,
9623 +       .open           = scanlog_open,
9624 +       .release        = scanlog_release,
9625  };
9626  
9627  int __init scanlog_init(void)
9628 diff -Nru a/arch/s390/Kconfig b/arch/s390/Kconfig
9629 --- a/arch/s390/Kconfig Mon Jul 21 13:25:16 2003
9630 +++ b/arch/s390/Kconfig Sun Aug 31 16:14:22 2003
9631 @@ -217,10 +217,6 @@
9632  
9633  endchoice
9634  
9635 -config KCORE_ELF
9636 -       bool
9637 -       default y
9638 -
9639  source "fs/Kconfig.binfmt"
9640  
9641  config PROCESS_DEBUG
9642 diff -Nru a/arch/s390/kernel/compat_ioctl.c b/arch/s390/kernel/compat_ioctl.c
9643 --- a/arch/s390/kernel/compat_ioctl.c   Tue May 27 12:34:41 2003
9644 +++ b/arch/s390/kernel/compat_ioctl.c   Sun Aug 31 16:14:44 2003
9645 @@ -808,7 +808,7 @@
9646  #define IOCTL_TABLE_START \
9647         struct ioctl_trans ioctl_start[] = {
9648  #define IOCTL_TABLE_END \
9649 -       }; struct ioctl_trans ioctl_end[0];
9650 +       };
9651  
9652  IOCTL_TABLE_START
9653  #include <linux/compat_ioctl.h>
9654 @@ -899,3 +899,5 @@
9655  HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
9656  
9657  IOCTL_TABLE_END
9658 +
9659 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
9660 diff -Nru a/arch/sh/Kconfig b/arch/sh/Kconfig
9661 --- a/arch/sh/Kconfig   Sat Aug  2 14:26:16 2003
9662 +++ b/arch/sh/Kconfig   Sun Aug 31 16:14:22 2003
9663 @@ -729,40 +729,6 @@
9664  
9665  menu "Executable file formats"
9666  
9667 -choice
9668 -       prompt "Kernel core (/proc/kcore) format"
9669 -       depends on PROC_FS
9670 -       default KCORE_ELF
9671 -
9672 -config KCORE_ELF
9673 -       bool "ELF"
9674 -       ---help---
9675 -         If you enabled support for /proc file system then the file
9676 -         /proc/kcore will contain the kernel core image. This can be used
9677 -         in gdb:
9678 -
9679 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
9680 -
9681 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
9682 -         /proc/kcore appear in ELF core format as defined by the Executable
9683 -         and Linking Format specification. Selecting A.OUT will choose the
9684 -         old "a.out" format which may be necessary for some old versions
9685 -         of binutils or on some architectures.
9686 -
9687 -         This is especially useful if you have compiled the kernel with the
9688 -         "-g" option to preserve debugging information. It is mainly used
9689 -         for examining kernel data structures on the live kernel so if you
9690 -         don't understand what this means or are not a kernel hacker, just
9691 -         leave it at its default value ELF.
9692 -
9693 -config KCORE_AOUT
9694 -       bool "A.OUT"
9695 -       help
9696 -         Not necessary unless you're using a very out-of-date binutils
9697 -         version.  You probably want KCORE_ELF.
9698 -
9699 -endchoice
9700 -
9701  source "fs/Kconfig.binfmt"
9702  
9703  endmenu
9704 diff -Nru a/arch/sh/boards/adx/mach.c b/arch/sh/boards/adx/mach.c
9705 --- a/arch/sh/boards/adx/mach.c Mon May 19 16:04:36 2003
9706 +++ b/arch/sh/boards/adx/mach.c Sun Aug 31 16:14:08 2003
9707 @@ -24,41 +24,41 @@
9708   */
9709  
9710  struct sh_machine_vector mv_adx __initmv = {
9711 -       mv_nr_irqs:             48,
9712 +       .mv_nr_irqs             = 48,
9713  
9714 -       mv_inb:                 adx_inb,
9715 -       mv_inw:                 adx_inw,
9716 -       mv_inl:                 adx_inl,
9717 -       mv_outb:                adx_outb,
9718 -       mv_outw:                adx_outw,
9719 -       mv_outl:                adx_outl,
9720 -
9721 -       mv_inb_p:               adx_inb_p,
9722 -       mv_inw_p:               adx_inw,
9723 -       mv_inl_p:               adx_inl,
9724 -       mv_outb_p:              adx_outb_p,
9725 -       mv_outw_p:              adx_outw,
9726 -       mv_outl_p:              adx_outl,
9727 -
9728 -       mv_insb:                adx_insb,
9729 -       mv_insw:                adx_insw,
9730 -       mv_insl:                adx_insl,
9731 -       mv_outsb:               adx_outsb,
9732 -       mv_outsw:               adx_outsw,
9733 -       mv_outsl:               adx_outsl,
9734 -
9735 -       mv_readb:               adx_readb,
9736 -       mv_readw:               adx_readw,
9737 -       mv_readl:               adx_readl,
9738 -       mv_writeb:              adx_writeb,
9739 -       mv_writew:              adx_writew,
9740 -       mv_writel:              adx_writel,
9741 +       .mv_inb                 = adx_inb,
9742 +       .mv_inw                 = adx_inw,
9743 +       .mv_inl                 = adx_inl,
9744 +       .mv_outb                = adx_outb,
9745 +       .mv_outw                = adx_outw,
9746 +       .mv_outl                = adx_outl,
9747 +
9748 +       .mv_inb_p               = adx_inb_p,
9749 +       .mv_inw_p               = adx_inw,
9750 +       .mv_inl_p               = adx_inl,
9751 +       .mv_outb_p              = adx_outb_p,
9752 +       .mv_outw_p              = adx_outw,
9753 +       .mv_outl_p              = adx_outl,
9754 +
9755 +       .mv_insb                = adx_insb,
9756 +       .mv_insw                = adx_insw,
9757 +       .mv_insl                = adx_insl,
9758 +       .mv_outsb               = adx_outsb,
9759 +       .mv_outsw               = adx_outsw,
9760 +       .mv_outsl               = adx_outsl,
9761 +
9762 +       .mv_readb               = adx_readb,
9763 +       .mv_readw               = adx_readw,
9764 +       .mv_readl               = adx_readl,
9765 +       .mv_writeb              = adx_writeb,
9766 +       .mv_writew              = adx_writew,
9767 +       .mv_writel              = adx_writel,
9768  
9769 -       mv_ioremap:             adx_ioremap,
9770 -       mv_iounmap:             adx_iounmap,
9771 +       .mv_ioremap             = adx_ioremap,
9772 +       .mv_iounmap             = adx_iounmap,
9773  
9774 -       mv_isa_port2addr:       adx_isa_port2addr,
9775 +       .mv_isa_port2addr       = adx_isa_port2addr,
9776  
9777 -       mv_init_irq:            init_adx_IRQ,
9778 +       .mv_init_irq            = init_adx_IRQ,
9779  };
9780  ALIAS_MV(adx)
9781 diff -Nru a/arch/sh/boards/bigsur/mach.c b/arch/sh/boards/bigsur/mach.c
9782 --- a/arch/sh/boards/bigsur/mach.c      Sat Mar  2 08:57:07 2002
9783 +++ b/arch/sh/boards/bigsur/mach.c      Sun Aug 31 16:14:08 2003
9784 @@ -28,44 +28,44 @@
9785  extern void init_bigsur_IRQ(void);
9786  
9787  struct sh_machine_vector mv_bigsur __initmv = {
9788 -       mv_nr_irqs:             NR_IRQS,     // Defined in <asm/irq.h>
9789 -       mv_inb:                 bigsur_inb,
9790 -       mv_inw:                 bigsur_inw,
9791 -       mv_inl:                 bigsur_inl,
9792 -       mv_outb:                bigsur_outb,
9793 -       mv_outw:                bigsur_outw,
9794 -       mv_outl:                bigsur_outl,
9795 -
9796 -       mv_inb_p:               bigsur_inb_p,
9797 -       mv_inw_p:               bigsur_inw,
9798 -       mv_inl_p:               bigsur_inl,
9799 -       mv_outb_p:              bigsur_outb_p,
9800 -       mv_outw_p:              bigsur_outw,
9801 -       mv_outl_p:              bigsur_outl,
9802 -
9803 -       mv_insb:                bigsur_insb,
9804 -       mv_insw:                bigsur_insw,
9805 -       mv_insl:                bigsur_insl,
9806 -       mv_outsb:               bigsur_outsb,
9807 -       mv_outsw:               bigsur_outsw,
9808 -       mv_outsl:               bigsur_outsl,
9809 -
9810 -       mv_readb:               generic_readb,
9811 -       mv_readw:               generic_readw,
9812 -       mv_readl:               generic_readl,
9813 -       mv_writeb:              generic_writeb,
9814 -       mv_writew:              generic_writew,
9815 -       mv_writel:              generic_writel,
9816 +       .mv_nr_irqs             = NR_IRQS,     // Defined in <asm/irq.h>
9817 +       .mv_inb                 = bigsur_inb,
9818 +       .mv_inw                 = bigsur_inw,
9819 +       .mv_inl                 = bigsur_inl,
9820 +       .mv_outb                = bigsur_outb,
9821 +       .mv_outw                = bigsur_outw,
9822 +       .mv_outl                = bigsur_outl,
9823 +
9824 +       .mv_inb_p               = bigsur_inb_p,
9825 +       .mv_inw_p               = bigsur_inw,
9826 +       .mv_inl_p               = bigsur_inl,
9827 +       .mv_outb_p              = bigsur_outb_p,
9828 +       .mv_outw_p              = bigsur_outw,
9829 +       .mv_outl_p              = bigsur_outl,
9830 +
9831 +       .mv_insb                = bigsur_insb,
9832 +       .mv_insw                = bigsur_insw,
9833 +       .mv_insl                = bigsur_insl,
9834 +       .mv_outsb               = bigsur_outsb,
9835 +       .mv_outsw               = bigsur_outsw,
9836 +       .mv_outsl               = bigsur_outsl,
9837 +
9838 +       .mv_readb               = generic_readb,
9839 +       .mv_readw               = generic_readw,
9840 +       .mv_readl               = generic_readl,
9841 +       .mv_writeb              = generic_writeb,
9842 +       .mv_writew              = generic_writew,
9843 +       .mv_writel              = generic_writel,
9844  
9845 -       mv_ioremap:             generic_ioremap,
9846 -       mv_iounmap:             generic_iounmap,
9847 +       .mv_ioremap             = generic_ioremap,
9848 +       .mv_iounmap             = generic_iounmap,
9849  
9850 -       mv_isa_port2addr:       bigsur_isa_port2addr,
9851 -       mv_irq_demux:       bigsur_irq_demux,
9852 +       .mv_isa_port2addr       = bigsur_isa_port2addr,
9853 +       .mv_irq_demux       = bigsur_irq_demux,
9854  
9855 -       mv_init_irq:            init_bigsur_IRQ,
9856 +       .mv_init_irq            = init_bigsur_IRQ,
9857  #ifdef CONFIG_HEARTBEAT
9858 -       mv_heartbeat:           heartbeat_bigsur,
9859 +       .mv_heartbeat           = heartbeat_bigsur,
9860  #endif
9861  
9862  };
9863 diff -Nru a/arch/sh/boards/cat68701/mach.c b/arch/sh/boards/cat68701/mach.c
9864 --- a/arch/sh/boards/cat68701/mach.c    Sat Mar  2 08:57:07 2002
9865 +++ b/arch/sh/boards/cat68701/mach.c    Sun Aug 31 16:14:08 2003
9866 @@ -23,44 +23,44 @@
9867   */
9868  
9869  struct sh_machine_vector mv_cat68701 __initmv = {
9870 -       mv_nr_irqs:             32,
9871 -       mv_inb:                 cat68701_inb,
9872 -       mv_inw:                 cat68701_inw,
9873 -       mv_inl:                 cat68701_inl,
9874 -       mv_outb:                cat68701_outb,
9875 -       mv_outw:                cat68701_outw,
9876 -       mv_outl:                cat68701_outl,
9877 -
9878 -       mv_inb_p:               cat68701_inb_p,
9879 -       mv_inw_p:               cat68701_inw,
9880 -       mv_inl_p:               cat68701_inl,
9881 -       mv_outb_p:              cat68701_outb_p,
9882 -       mv_outw_p:              cat68701_outw,
9883 -       mv_outl_p:              cat68701_outl,
9884 -
9885 -       mv_insb:                cat68701_insb,
9886 -       mv_insw:                cat68701_insw,
9887 -       mv_insl:                cat68701_insl,
9888 -       mv_outsb:               cat68701_outsb,
9889 -       mv_outsw:               cat68701_outsw,
9890 -       mv_outsl:               cat68701_outsl,
9891 -
9892 -       mv_readb:               cat68701_readb,
9893 -       mv_readw:               cat68701_readw,
9894 -       mv_readl:               cat68701_readl,
9895 -       mv_writeb:              cat68701_writeb,
9896 -       mv_writew:              cat68701_writew,
9897 -       mv_writel:              cat68701_writel,
9898 +       .mv_nr_irqs             = 32,
9899 +       .mv_inb                 = cat68701_inb,
9900 +       .mv_inw                 = cat68701_inw,
9901 +       .mv_inl                 = cat68701_inl,
9902 +       .mv_outb                = cat68701_outb,
9903 +       .mv_outw                = cat68701_outw,
9904 +       .mv_outl                = cat68701_outl,
9905 +
9906 +       .mv_inb_p               = cat68701_inb_p,
9907 +       .mv_inw_p               = cat68701_inw,
9908 +       .mv_inl_p               = cat68701_inl,
9909 +       .mv_outb_p              = cat68701_outb_p,
9910 +       .mv_outw_p              = cat68701_outw,
9911 +       .mv_outl_p              = cat68701_outl,
9912 +
9913 +       .mv_insb                = cat68701_insb,
9914 +       .mv_insw                = cat68701_insw,
9915 +       .mv_insl                = cat68701_insl,
9916 +       .mv_outsb               = cat68701_outsb,
9917 +       .mv_outsw               = cat68701_outsw,
9918 +       .mv_outsl               = cat68701_outsl,
9919 +
9920 +       .mv_readb               = cat68701_readb,
9921 +       .mv_readw               = cat68701_readw,
9922 +       .mv_readl               = cat68701_readl,
9923 +       .mv_writeb              = cat68701_writeb,
9924 +       .mv_writew              = cat68701_writew,
9925 +       .mv_writel              = cat68701_writel,
9926  
9927 -       mv_ioremap:             cat68701_ioremap,
9928 -       mv_iounmap:             cat68701_iounmap,
9929 +       .mv_ioremap             = cat68701_ioremap,
9930 +       .mv_iounmap             = cat68701_iounmap,
9931  
9932 -       mv_isa_port2addr:       cat68701_isa_port2addr,
9933 -       mv_irq_demux:           cat68701_irq_demux,
9934 +       .mv_isa_port2addr       = cat68701_isa_port2addr,
9935 +       .mv_irq_demux           = cat68701_irq_demux,
9936  
9937 -       mv_init_irq:            init_cat68701_IRQ,
9938 +       .mv_init_irq            = init_cat68701_IRQ,
9939  #ifdef CONFIG_HEARTBEAT
9940 -       mv_heartbeat:           heartbeat_cat68701,
9941 +       .mv_heartbeat           = heartbeat_cat68701,
9942  #endif
9943  };
9944  ALIAS_MV(cat68701)
9945 diff -Nru a/arch/sh/boards/cqreek/mach.c b/arch/sh/boards/cqreek/mach.c
9946 --- a/arch/sh/boards/cqreek/mach.c      Sat Jun 14 11:02:09 2003
9947 +++ b/arch/sh/boards/cqreek/mach.c      Sun Aug 31 16:14:08 2003
9948 @@ -21,46 +21,46 @@
9949  
9950  struct sh_machine_vector mv_cqreek __initmv = {
9951  #if defined(CONFIG_CPU_SH4)
9952 -       mv_nr_irqs:             48,
9953 +       .mv_nr_irqs             = 48,
9954  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
9955 -       mv_nr_irqs:             32,
9956 +       .mv_nr_irqs             = 32,
9957  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
9958 -       mv_nr_irqs:             61,
9959 +       .mv_nr_irqs             = 61,
9960  #endif
9961  
9962 -       mv_inb:                 generic_inb,
9963 -       mv_inw:                 generic_inw,
9964 -       mv_inl:                 generic_inl,
9965 -       mv_outb:                generic_outb,
9966 -       mv_outw:                generic_outw,
9967 -       mv_outl:                generic_outl,
9968 -
9969 -       mv_inb_p:               generic_inb_p,
9970 -       mv_inw_p:               generic_inw_p,
9971 -       mv_inl_p:               generic_inl_p,
9972 -       mv_outb_p:              generic_outb_p,
9973 -       mv_outw_p:              generic_outw_p,
9974 -       mv_outl_p:              generic_outl_p,
9975 -
9976 -       mv_insb:                generic_insb,
9977 -       mv_insw:                generic_insw,
9978 -       mv_insl:                generic_insl,
9979 -       mv_outsb:               generic_outsb,
9980 -       mv_outsw:               generic_outsw,
9981 -       mv_outsl:               generic_outsl,
9982 -
9983 -       mv_readb:               generic_readb,
9984 -       mv_readw:               generic_readw,
9985 -       mv_readl:               generic_readl,
9986 -       mv_writeb:              generic_writeb,
9987 -       mv_writew:              generic_writew,
9988 -       mv_writel:              generic_writel,
9989 +       .mv_inb                 = generic_inb,
9990 +       .mv_inw                 = generic_inw,
9991 +       .mv_inl                 = generic_inl,
9992 +       .mv_outb                = generic_outb,
9993 +       .mv_outw                = generic_outw,
9994 +       .mv_outl                = generic_outl,
9995 +
9996 +       .mv_inb_p               = generic_inb_p,
9997 +       .mv_inw_p               = generic_inw_p,
9998 +       .mv_inl_p               = generic_inl_p,
9999 +       .mv_outb_p              = generic_outb_p,
10000 +       .mv_outw_p              = generic_outw_p,
10001 +       .mv_outl_p              = generic_outl_p,
10002 +
10003 +       .mv_insb                = generic_insb,
10004 +       .mv_insw                = generic_insw,
10005 +       .mv_insl                = generic_insl,
10006 +       .mv_outsb               = generic_outsb,
10007 +       .mv_outsw               = generic_outsw,
10008 +       .mv_outsl               = generic_outsl,
10009 +
10010 +       .mv_readb               = generic_readb,
10011 +       .mv_readw               = generic_readw,
10012 +       .mv_readl               = generic_readl,
10013 +       .mv_writeb              = generic_writeb,
10014 +       .mv_writew              = generic_writew,
10015 +       .mv_writel              = generic_writel,
10016  
10017 -       mv_init_irq:            init_cqreek_IRQ,
10018 +       .mv_init_irq            = init_cqreek_IRQ,
10019  
10020 -       mv_isa_port2addr:       cqreek_port2addr,
10021 +       .mv_isa_port2addr       = cqreek_port2addr,
10022  
10023 -       mv_ioremap:             generic_ioremap,
10024 -       mv_iounmap:             generic_iounmap,
10025 +       .mv_ioremap             = generic_ioremap,
10026 +       .mv_iounmap             = generic_iounmap,
10027  };
10028  ALIAS_MV(cqreek)
10029 diff -Nru a/arch/sh/boards/dmida/mach.c b/arch/sh/boards/dmida/mach.c
10030 --- a/arch/sh/boards/dmida/mach.c       Mon May 19 16:04:36 2003
10031 +++ b/arch/sh/boards/dmida/mach.c       Sun Aug 31 16:14:08 2003
10032 @@ -30,42 +30,42 @@
10033   */
10034  
10035  struct sh_machine_vector mv_dmida __initmv = {
10036 -       mv_name:                "DMIDA",
10037 +       .mv_name                = "DMIDA",
10038  
10039 -       mv_nr_irqs:             HD64465_IRQ_BASE+HD64465_IRQ_NUM,
10040 +       .mv_nr_irqs             = HD64465_IRQ_BASE+HD64465_IRQ_NUM,
10041  
10042 -       mv_inb:                 hd64465_inb,
10043 -       mv_inw:                 hd64465_inw,
10044 -       mv_inl:                 hd64465_inl,
10045 -       mv_outb:                hd64465_outb,
10046 -       mv_outw:                hd64465_outw,
10047 -       mv_outl:                hd64465_outl,
10048 -
10049 -       mv_inb_p:               hd64465_inb_p,
10050 -       mv_inw_p:               hd64465_inw,
10051 -       mv_inl_p:               hd64465_inl,
10052 -       mv_outb_p:              hd64465_outb_p,
10053 -       mv_outw_p:              hd64465_outw,
10054 -       mv_outl_p:              hd64465_outl,
10055 -
10056 -       mv_insb:                hd64465_insb,
10057 -       mv_insw:                hd64465_insw,
10058 -       mv_insl:                hd64465_insl,
10059 -       mv_outsb:               hd64465_outsb,
10060 -       mv_outsw:               hd64465_outsw,
10061 -       mv_outsl:               hd64465_outsl,
10062 -
10063 -       mv_readb:               generic_readb,
10064 -       mv_readw:               generic_readw,
10065 -       mv_readl:               generic_readl,
10066 -       mv_writeb:              generic_writeb,
10067 -       mv_writew:              generic_writew,
10068 -       mv_writel:              generic_writel,
10069 +       .mv_inb                 = hd64465_inb,
10070 +       .mv_inw                 = hd64465_inw,
10071 +       .mv_inl                 = hd64465_inl,
10072 +       .mv_outb                = hd64465_outb,
10073 +       .mv_outw                = hd64465_outw,
10074 +       .mv_outl                = hd64465_outl,
10075 +
10076 +       .mv_inb_p               = hd64465_inb_p,
10077 +       .mv_inw_p               = hd64465_inw,
10078 +       .mv_inl_p               = hd64465_inl,
10079 +       .mv_outb_p              = hd64465_outb_p,
10080 +       .mv_outw_p              = hd64465_outw,
10081 +       .mv_outl_p              = hd64465_outl,
10082 +
10083 +       .mv_insb                = hd64465_insb,
10084 +       .mv_insw                = hd64465_insw,
10085 +       .mv_insl                = hd64465_insl,
10086 +       .mv_outsb               = hd64465_outsb,
10087 +       .mv_outsw               = hd64465_outsw,
10088 +       .mv_outsl               = hd64465_outsl,
10089 +
10090 +       .mv_readb               = generic_readb,
10091 +       .mv_readw               = generic_readw,
10092 +       .mv_readl               = generic_readl,
10093 +       .mv_writeb              = generic_writeb,
10094 +       .mv_writew              = generic_writew,
10095 +       .mv_writel              = generic_writel,
10096  
10097 -       mv_irq_demux:           hd64465_irq_demux,
10098 +       .mv_irq_demux           = hd64465_irq_demux,
10099  
10100 -       mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10101 -       mv_rtc_settimeofday:    sh_rtc_settimeofday,
10102 +       .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10103 +       .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10104  };
10105  ALIAS_MV(dmida)
10106  
10107 diff -Nru a/arch/sh/boards/dreamcast/irq.c b/arch/sh/boards/dreamcast/irq.c
10108 --- a/arch/sh/boards/dreamcast/irq.c    Sat Jun 14 11:02:09 2003
10109 +++ b/arch/sh/boards/dreamcast/irq.c    Sun Aug 31 16:14:08 2003
10110 @@ -110,13 +110,13 @@
10111  }
10112  
10113  struct hw_interrupt_type systemasic_int = {
10114 -        typename:       "System ASIC",
10115 -        startup:        startup_systemasic_irq,
10116 -        shutdown:       shutdown_systemasic_irq,
10117 -        enable:         enable_systemasic_irq,
10118 -        disable:        disable_systemasic_irq,
10119 -        ack:            ack_systemasic_irq,
10120 -        end:            end_systemasic_irq,
10121 +        .typename       = "System ASIC",
10122 +        .startup        = startup_systemasic_irq,
10123 +        .shutdown       = shutdown_systemasic_irq,
10124 +        .enable         = enable_systemasic_irq,
10125 +        .disable        = disable_systemasic_irq,
10126 +        .ack            = ack_systemasic_irq,
10127 +        .end            = end_systemasic_irq,
10128  };
10129  
10130  /*
10131 diff -Nru a/arch/sh/boards/dreamcast/mach.c b/arch/sh/boards/dreamcast/mach.c
10132 --- a/arch/sh/boards/dreamcast/mach.c   Mon May 19 16:04:36 2003
10133 +++ b/arch/sh/boards/dreamcast/mach.c   Sun Aug 31 16:14:08 2003
10134 @@ -21,40 +21,40 @@
10135   */
10136  
10137  struct sh_machine_vector mv_dreamcast __initmv = {
10138 -       mv_nr_irqs:             NR_IRQS,
10139 +       .mv_nr_irqs             = NR_IRQS,
10140  
10141 -       mv_inb:                 generic_inb,
10142 -       mv_inw:                 generic_inw,
10143 -       mv_inl:                 generic_inl,
10144 -       mv_outb:                generic_outb,
10145 -       mv_outw:                generic_outw,
10146 -       mv_outl:                generic_outl,
10147 -
10148 -       mv_inb_p:               generic_inb_p,
10149 -       mv_inw_p:               generic_inw,
10150 -       mv_inl_p:               generic_inl,
10151 -       mv_outb_p:              generic_outb_p,
10152 -       mv_outw_p:              generic_outw,
10153 -       mv_outl_p:              generic_outl,
10154 -
10155 -       mv_insb:                generic_insb,
10156 -       mv_insw:                generic_insw,
10157 -       mv_insl:                generic_insl,
10158 -       mv_outsb:               generic_outsb,
10159 -       mv_outsw:               generic_outsw,
10160 -       mv_outsl:               generic_outsl,
10161 -
10162 -       mv_readb:               generic_readb,
10163 -       mv_readw:               generic_readw,
10164 -       mv_readl:               generic_readl,
10165 -       mv_writeb:              generic_writeb,
10166 -       mv_writew:              generic_writew,
10167 -       mv_writel:              generic_writel,
10168 +       .mv_inb                 = generic_inb,
10169 +       .mv_inw                 = generic_inw,
10170 +       .mv_inl                 = generic_inl,
10171 +       .mv_outb                = generic_outb,
10172 +       .mv_outw                = generic_outw,
10173 +       .mv_outl                = generic_outl,
10174 +
10175 +       .mv_inb_p               = generic_inb_p,
10176 +       .mv_inw_p               = generic_inw,
10177 +       .mv_inl_p               = generic_inl,
10178 +       .mv_outb_p              = generic_outb_p,
10179 +       .mv_outw_p              = generic_outw,
10180 +       .mv_outl_p              = generic_outl,
10181 +
10182 +       .mv_insb                = generic_insb,
10183 +       .mv_insw                = generic_insw,
10184 +       .mv_insl                = generic_insl,
10185 +       .mv_outsb               = generic_outsb,
10186 +       .mv_outsw               = generic_outsw,
10187 +       .mv_outsl               = generic_outsl,
10188 +
10189 +       .mv_readb               = generic_readb,
10190 +       .mv_readw               = generic_readw,
10191 +       .mv_readl               = generic_readl,
10192 +       .mv_writeb              = generic_writeb,
10193 +       .mv_writew              = generic_writew,
10194 +       .mv_writel              = generic_writel,
10195  
10196 -       mv_ioremap:             generic_ioremap,
10197 -       mv_iounmap:             generic_iounmap,
10198 +       .mv_ioremap             = generic_ioremap,
10199 +       .mv_iounmap             = generic_iounmap,
10200  
10201 -       mv_isa_port2addr:       dreamcast_isa_port2addr,
10202 -       mv_irq_demux:           systemasic_irq_demux,
10203 +       .mv_isa_port2addr       = dreamcast_isa_port2addr,
10204 +       .mv_irq_demux           = systemasic_irq_demux,
10205  };
10206  ALIAS_MV(dreamcast)
10207 diff -Nru a/arch/sh/boards/ec3104/irq.c b/arch/sh/boards/ec3104/irq.c
10208 --- a/arch/sh/boards/ec3104/irq.c       Sat Jun 14 11:02:09 2003
10209 +++ b/arch/sh/boards/ec3104/irq.c       Sun Aug 31 16:14:08 2003
10210 @@ -169,13 +169,13 @@
10211  }
10212  
10213  static struct hw_interrupt_type ec3104_int = {
10214 -        typename:       "EC3104",
10215 -        enable:         enable_ec3104_irq,
10216 -        disable:        disable_ec3104_irq,
10217 -        ack:            mask_and_ack_ec3104_irq,
10218 -        end:            end_ec3104_irq,
10219 -        startup:        startup_ec3104_irq,
10220 -        shutdown:       shutdown_ec3104_irq,
10221 +        .typename       = "EC3104",
10222 +        .enable         = enable_ec3104_irq,
10223 +        .disable        = disable_ec3104_irq,
10224 +        .ack            = mask_and_ack_ec3104_irq,
10225 +        .end            = end_ec3104_irq,
10226 +        .startup        = startup_ec3104_irq,
10227 +        .shutdown       = shutdown_ec3104_irq,
10228  };
10229  
10230  /* Yuck.  the _demux API is ugly */
10231 diff -Nru a/arch/sh/boards/ec3104/mach.c b/arch/sh/boards/ec3104/mach.c
10232 --- a/arch/sh/boards/ec3104/mach.c      Sat Jan 19 10:54:19 2002
10233 +++ b/arch/sh/boards/ec3104/mach.c      Sun Aug 31 16:14:08 2003
10234 @@ -28,42 +28,42 @@
10235   */
10236  
10237  struct sh_machine_vector mv_ec3104 __initmv = {
10238 -       mv_name:                "EC3104",
10239 +       .mv_name                = "EC3104",
10240  
10241 -       mv_nr_irqs:             96,
10242 +       .mv_nr_irqs             = 96,
10243  
10244 -       mv_inb:                 ec3104_inb,
10245 -       mv_inw:                 ec3104_inw,
10246 -       mv_inl:                 ec3104_inl,
10247 -       mv_outb:                ec3104_outb,
10248 -       mv_outw:                ec3104_outw,
10249 -       mv_outl:                ec3104_outl,
10250 -
10251 -       mv_inb_p:               generic_inb_p,
10252 -       mv_inw_p:               generic_inw,
10253 -       mv_inl_p:               generic_inl,
10254 -       mv_outb_p:              generic_outb_p,
10255 -       mv_outw_p:              generic_outw,
10256 -       mv_outl_p:              generic_outl,
10257 -
10258 -       mv_insb:                generic_insb,
10259 -       mv_insw:                generic_insw,
10260 -       mv_insl:                generic_insl,
10261 -       mv_outsb:               generic_outsb,
10262 -       mv_outsw:               generic_outsw,
10263 -       mv_outsl:               generic_outsl,
10264 -
10265 -       mv_readb:               generic_readb,
10266 -       mv_readw:               generic_readw,
10267 -       mv_readl:               generic_readl,
10268 -       mv_writeb:              generic_writeb,
10269 -       mv_writew:              generic_writew,
10270 -       mv_writel:              generic_writel,
10271 +       .mv_inb                 = ec3104_inb,
10272 +       .mv_inw                 = ec3104_inw,
10273 +       .mv_inl                 = ec3104_inl,
10274 +       .mv_outb                = ec3104_outb,
10275 +       .mv_outw                = ec3104_outw,
10276 +       .mv_outl                = ec3104_outl,
10277 +
10278 +       .mv_inb_p               = generic_inb_p,
10279 +       .mv_inw_p               = generic_inw,
10280 +       .mv_inl_p               = generic_inl,
10281 +       .mv_outb_p              = generic_outb_p,
10282 +       .mv_outw_p              = generic_outw,
10283 +       .mv_outl_p              = generic_outl,
10284 +
10285 +       .mv_insb                = generic_insb,
10286 +       .mv_insw                = generic_insw,
10287 +       .mv_insl                = generic_insl,
10288 +       .mv_outsb               = generic_outsb,
10289 +       .mv_outsw               = generic_outsw,
10290 +       .mv_outsl               = generic_outsl,
10291 +
10292 +       .mv_readb               = generic_readb,
10293 +       .mv_readw               = generic_readw,
10294 +       .mv_readl               = generic_readl,
10295 +       .mv_writeb              = generic_writeb,
10296 +       .mv_writew              = generic_writew,
10297 +       .mv_writel              = generic_writel,
10298  
10299 -       mv_irq_demux:           ec3104_irq_demux,
10300 +       .mv_irq_demux           = ec3104_irq_demux,
10301  
10302 -       mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10303 -       mv_rtc_settimeofday:    sh_rtc_settimeofday,
10304 +       .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10305 +       .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10306  };
10307  
10308  ALIAS_MV(ec3104)
10309 diff -Nru a/arch/sh/boards/harp/mach.c b/arch/sh/boards/harp/mach.c
10310 --- a/arch/sh/boards/harp/mach.c        Sat Mar  2 08:57:07 2002
10311 +++ b/arch/sh/boards/harp/mach.c        Sun Aug 31 16:14:08 2003
10312 @@ -26,46 +26,46 @@
10313   */
10314  
10315  struct sh_machine_vector mv_harp __initmv = {
10316 -       mv_nr_irqs:             89 + HD64465_IRQ_NUM,
10317 +       .mv_nr_irqs             = 89 + HD64465_IRQ_NUM,
10318  
10319 -       mv_inb:                 hd64465_inb,
10320 -       mv_inw:                 hd64465_inw,
10321 -       mv_inl:                 hd64465_inl,
10322 -       mv_outb:                hd64465_outb,
10323 -       mv_outw:                hd64465_outw,
10324 -       mv_outl:                hd64465_outl,
10325 -
10326 -       mv_inb_p:               hd64465_inb_p,
10327 -       mv_inw_p:               hd64465_inw,
10328 -       mv_inl_p:               hd64465_inl,
10329 -       mv_outb_p:              hd64465_outb_p,
10330 -       mv_outw_p:              hd64465_outw,
10331 -       mv_outl_p:              hd64465_outl,
10332 -
10333 -       mv_insb:                hd64465_insb,
10334 -       mv_insw:                hd64465_insw,
10335 -       mv_insl:                hd64465_insl,
10336 -       mv_outsb:               hd64465_outsb,
10337 -       mv_outsw:               hd64465_outsw,
10338 -       mv_outsl:               hd64465_outsl,
10339 -
10340 -       mv_readb:               generic_readb,
10341 -       mv_readw:               generic_readw,
10342 -       mv_readl:               generic_readl,
10343 -       mv_writeb:              generic_writeb,
10344 -       mv_writew:              generic_writew,
10345 -       mv_writel:              generic_writel,
10346 +       .mv_inb                 = hd64465_inb,
10347 +       .mv_inw                 = hd64465_inw,
10348 +       .mv_inl                 = hd64465_inl,
10349 +       .mv_outb                = hd64465_outb,
10350 +       .mv_outw                = hd64465_outw,
10351 +       .mv_outl                = hd64465_outl,
10352 +
10353 +       .mv_inb_p               = hd64465_inb_p,
10354 +       .mv_inw_p               = hd64465_inw,
10355 +       .mv_inl_p               = hd64465_inl,
10356 +       .mv_outb_p              = hd64465_outb_p,
10357 +       .mv_outw_p              = hd64465_outw,
10358 +       .mv_outl_p              = hd64465_outl,
10359 +
10360 +       .mv_insb                = hd64465_insb,
10361 +       .mv_insw                = hd64465_insw,
10362 +       .mv_insl                = hd64465_insl,
10363 +       .mv_outsb               = hd64465_outsb,
10364 +       .mv_outsw               = hd64465_outsw,
10365 +       .mv_outsl               = hd64465_outsl,
10366 +
10367 +       .mv_readb               = generic_readb,
10368 +       .mv_readw               = generic_readw,
10369 +       .mv_readl               = generic_readl,
10370 +       .mv_writeb              = generic_writeb,
10371 +       .mv_writew              = generic_writew,
10372 +       .mv_writel              = generic_writel,
10373  
10374 -        mv_ioremap:             generic_ioremap,
10375 -        mv_iounmap:             generic_iounmap,
10376 +        .mv_ioremap             = generic_ioremap,
10377 +        .mv_iounmap             = generic_iounmap,
10378   
10379 -        mv_isa_port2addr:       hd64465_isa_port2addr,
10380 +        .mv_isa_port2addr       = hd64465_isa_port2addr,
10381  
10382  #ifdef CONFIG_PCI
10383 -       mv_init_irq:            init_harp_irq,
10384 +       .mv_init_irq            = init_harp_irq,
10385  #endif
10386  #ifdef CONFIG_HEARTBEAT
10387 -       mv_heartbeat:           heartbeat_harp,
10388 +       .mv_heartbeat           = heartbeat_harp,
10389  #endif
10390  };
10391  
10392 diff -Nru a/arch/sh/boards/hp6xx/hp620/mach.c b/arch/sh/boards/hp6xx/hp620/mach.c
10393 --- a/arch/sh/boards/hp6xx/hp620/mach.c Mon May 19 16:04:36 2003
10394 +++ b/arch/sh/boards/hp6xx/hp620/mach.c Sun Aug 31 16:14:08 2003
10395 @@ -24,41 +24,41 @@
10396   */
10397  
10398  struct sh_machine_vector mv_hp620 __initmv = {
10399 -        mv_name:                "hp620",
10400 +        .mv_name                = "hp620",
10401  
10402 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
10403 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
10404  
10405 -        mv_inb:                 hd64461_inb,
10406 -        mv_inw:                 hd64461_inw,
10407 -        mv_inl:                 hd64461_inl,
10408 -        mv_outb:                hd64461_outb,
10409 -        mv_outw:                hd64461_outw,
10410 -        mv_outl:                hd64461_outl,
10411 -
10412 -        mv_inb_p:               hd64461_inb_p,
10413 -        mv_inw_p:               hd64461_inw,
10414 -        mv_inl_p:               hd64461_inl,
10415 -        mv_outb_p:              hd64461_outb_p,
10416 -        mv_outw_p:              hd64461_outw,
10417 -        mv_outl_p:              hd64461_outl,
10418 -
10419 -        mv_insb:                hd64461_insb,
10420 -        mv_insw:                hd64461_insw,
10421 -        mv_insl:                hd64461_insl,
10422 -        mv_outsb:               hd64461_outsb,
10423 -        mv_outsw:               hd64461_outsw,
10424 -        mv_outsl:               hd64461_outsl,
10425 -
10426 -        mv_readb:               generic_readb,
10427 -        mv_readw:               generic_readw,
10428 -        mv_readl:               generic_readl,
10429 -        mv_writeb:              generic_writeb,
10430 -        mv_writew:              generic_writew,
10431 -        mv_writel:              generic_writel,
10432 +        .mv_inb                 = hd64461_inb,
10433 +        .mv_inw                 = hd64461_inw,
10434 +        .mv_inl                 = hd64461_inl,
10435 +        .mv_outb                = hd64461_outb,
10436 +        .mv_outw                = hd64461_outw,
10437 +        .mv_outl                = hd64461_outl,
10438 +
10439 +        .mv_inb_p               = hd64461_inb_p,
10440 +        .mv_inw_p               = hd64461_inw,
10441 +        .mv_inl_p               = hd64461_inl,
10442 +        .mv_outb_p              = hd64461_outb_p,
10443 +        .mv_outw_p              = hd64461_outw,
10444 +        .mv_outl_p              = hd64461_outl,
10445 +
10446 +        .mv_insb                = hd64461_insb,
10447 +        .mv_insw                = hd64461_insw,
10448 +        .mv_insl                = hd64461_insl,
10449 +        .mv_outsb               = hd64461_outsb,
10450 +        .mv_outsw               = hd64461_outsw,
10451 +        .mv_outsl               = hd64461_outsl,
10452 +
10453 +        .mv_readb               = generic_readb,
10454 +        .mv_readw               = generic_readw,
10455 +        .mv_readl               = generic_readl,
10456 +        .mv_writeb              = generic_writeb,
10457 +        .mv_writew              = generic_writew,
10458 +        .mv_writel              = generic_writel,
10459  
10460 -        mv_irq_demux:           hd64461_irq_demux,
10461 +        .mv_irq_demux           = hd64461_irq_demux,
10462  
10463 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10464 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
10465 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10466 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10467  };
10468  ALIAS_MV(hp620)
10469 diff -Nru a/arch/sh/boards/hp6xx/hp680/mach.c b/arch/sh/boards/hp6xx/hp680/mach.c
10470 --- a/arch/sh/boards/hp6xx/hp680/mach.c Mon May 19 16:04:37 2003
10471 +++ b/arch/sh/boards/hp6xx/hp680/mach.c Sun Aug 31 16:14:08 2003
10472 @@ -20,41 +20,41 @@
10473  #include <asm/irq.h>
10474  
10475  struct sh_machine_vector mv_hp680 __initmv = {
10476 -        mv_name:                "hp680",
10477 +        .mv_name                = "hp680",
10478  
10479 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
10480 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
10481  
10482 -        mv_inb:                 hd64461_inb,
10483 -        mv_inw:                 hd64461_inw,
10484 -        mv_inl:                 hd64461_inl,
10485 -        mv_outb:                hd64461_outb,
10486 -        mv_outw:                hd64461_outw,
10487 -        mv_outl:                hd64461_outl,
10488 -
10489 -        mv_inb_p:               hd64461_inb_p,
10490 -        mv_inw_p:               hd64461_inw,
10491 -        mv_inl_p:               hd64461_inl,
10492 -        mv_outb_p:              hd64461_outb_p,
10493 -        mv_outw_p:              hd64461_outw,
10494 -        mv_outl_p:              hd64461_outl,
10495 -
10496 -        mv_insb:                hd64461_insb,
10497 -        mv_insw:                hd64461_insw,
10498 -        mv_insl:                hd64461_insl,
10499 -        mv_outsb:               hd64461_outsb,
10500 -        mv_outsw:               hd64461_outsw,
10501 -        mv_outsl:               hd64461_outsl,
10502 -
10503 -        mv_readb:               generic_readb,
10504 -        mv_readw:               generic_readw,
10505 -        mv_readl:               generic_readl,
10506 -        mv_writeb:              generic_writeb,
10507 -        mv_writew:              generic_writew,
10508 -        mv_writel:              generic_writel,
10509 +        .mv_inb                 = hd64461_inb,
10510 +        .mv_inw                 = hd64461_inw,
10511 +        .mv_inl                 = hd64461_inl,
10512 +        .mv_outb                = hd64461_outb,
10513 +        .mv_outw                = hd64461_outw,
10514 +        .mv_outl                = hd64461_outl,
10515 +
10516 +        .mv_inb_p               = hd64461_inb_p,
10517 +        .mv_inw_p               = hd64461_inw,
10518 +        .mv_inl_p               = hd64461_inl,
10519 +        .mv_outb_p              = hd64461_outb_p,
10520 +        .mv_outw_p              = hd64461_outw,
10521 +        .mv_outl_p              = hd64461_outl,
10522 +
10523 +        .mv_insb                = hd64461_insb,
10524 +        .mv_insw                = hd64461_insw,
10525 +        .mv_insl                = hd64461_insl,
10526 +        .mv_outsb               = hd64461_outsb,
10527 +        .mv_outsw               = hd64461_outsw,
10528 +        .mv_outsl               = hd64461_outsl,
10529 +
10530 +        .mv_readb               = generic_readb,
10531 +        .mv_readw               = generic_readw,
10532 +        .mv_readl               = generic_readl,
10533 +        .mv_writeb              = generic_writeb,
10534 +        .mv_writew              = generic_writew,
10535 +        .mv_writel              = generic_writel,
10536  
10537 -        mv_irq_demux:           hd64461_irq_demux,
10538 +        .mv_irq_demux           = hd64461_irq_demux,
10539  
10540 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10541 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
10542 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10543 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10544  };
10545  ALIAS_MV(hp680)
10546 diff -Nru a/arch/sh/boards/hp6xx/hp690/mach.c b/arch/sh/boards/hp6xx/hp690/mach.c
10547 --- a/arch/sh/boards/hp6xx/hp690/mach.c Mon May 19 16:04:37 2003
10548 +++ b/arch/sh/boards/hp6xx/hp690/mach.c Sun Aug 31 16:14:08 2003
10549 @@ -20,41 +20,41 @@
10550  #include <asm/irq.h>
10551  
10552  struct sh_machine_vector mv_hp690 __initmv = {
10553 -        mv_name:                "hp690",
10554 +        .mv_name                = "hp690",
10555  
10556 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
10557 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
10558  
10559 -        mv_inb:                 hd64461_inb,
10560 -        mv_inw:                 hd64461_inw,
10561 -        mv_inl:                 hd64461_inl,
10562 -        mv_outb:                hd64461_outb,
10563 -        mv_outw:                hd64461_outw,
10564 -        mv_outl:                hd64461_outl,
10565 -
10566 -        mv_inb_p:               hd64461_inb_p,
10567 -        mv_inw_p:               hd64461_inw,
10568 -        mv_inl_p:               hd64461_inl,
10569 -        mv_outb_p:              hd64461_outb_p,
10570 -        mv_outw_p:              hd64461_outw,
10571 -        mv_outl_p:              hd64461_outl,
10572 -
10573 -        mv_insb:                hd64461_insb,
10574 -        mv_insw:                hd64461_insw,
10575 -        mv_insl:                hd64461_insl,
10576 -        mv_outsb:               hd64461_outsb,
10577 -        mv_outsw:               hd64461_outsw,
10578 -        mv_outsl:               hd64461_outsl,
10579 -
10580 -        mv_readb:               generic_readb,
10581 -        mv_readw:               generic_readw,
10582 -        mv_readl:               generic_readl,
10583 -        mv_writeb:              generic_writeb,
10584 -        mv_writew:              generic_writew,
10585 -        mv_writel:              generic_writel,
10586 +        .mv_inb                 = hd64461_inb,
10587 +        .mv_inw                 = hd64461_inw,
10588 +        .mv_inl                 = hd64461_inl,
10589 +        .mv_outb                = hd64461_outb,
10590 +        .mv_outw                = hd64461_outw,
10591 +        .mv_outl                = hd64461_outl,
10592 +
10593 +        .mv_inb_p               = hd64461_inb_p,
10594 +        .mv_inw_p               = hd64461_inw,
10595 +        .mv_inl_p               = hd64461_inl,
10596 +        .mv_outb_p              = hd64461_outb_p,
10597 +        .mv_outw_p              = hd64461_outw,
10598 +        .mv_outl_p              = hd64461_outl,
10599 +
10600 +        .mv_insb                = hd64461_insb,
10601 +        .mv_insw                = hd64461_insw,
10602 +        .mv_insl                = hd64461_insl,
10603 +        .mv_outsb               = hd64461_outsb,
10604 +        .mv_outsw               = hd64461_outsw,
10605 +        .mv_outsl               = hd64461_outsl,
10606 +
10607 +        .mv_readb               = generic_readb,
10608 +        .mv_readw               = generic_readw,
10609 +        .mv_readl               = generic_readl,
10610 +        .mv_writeb              = generic_writeb,
10611 +        .mv_writew              = generic_writew,
10612 +        .mv_writel              = generic_writel,
10613  
10614 -        mv_irq_demux:           hd64461_irq_demux,
10615 +        .mv_irq_demux           = hd64461_irq_demux,
10616  
10617 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10618 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
10619 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10620 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10621  };
10622  ALIAS_MV(hp690)
10623 diff -Nru a/arch/sh/boards/overdrive/mach.c b/arch/sh/boards/overdrive/mach.c
10624 --- a/arch/sh/boards/overdrive/mach.c   Sat Jun 14 11:02:09 2003
10625 +++ b/arch/sh/boards/overdrive/mach.c   Sun Aug 31 16:14:08 2003
10626 @@ -28,46 +28,46 @@
10627   */
10628  
10629  struct sh_machine_vector mv_od __initmv = {
10630 -       mv_nr_irqs:             48,
10631 +       .mv_nr_irqs             = 48,
10632  
10633 -       mv_inb:                 od_inb,
10634 -       mv_inw:                 od_inw,
10635 -       mv_inl:                 od_inl,
10636 -       mv_outb:                od_outb,
10637 -       mv_outw:                od_outw,
10638 -       mv_outl:                od_outl,
10639 -
10640 -       mv_inb_p:               od_inb_p,
10641 -       mv_inw_p:               od_inw_p,
10642 -       mv_inl_p:               od_inl_p,
10643 -       mv_outb_p:              od_outb_p,
10644 -       mv_outw_p:              od_outw_p,
10645 -       mv_outl_p:              od_outl_p,
10646 -
10647 -       mv_insb:                od_insb,
10648 -       mv_insw:                od_insw,
10649 -       mv_insl:                od_insl,
10650 -       mv_outsb:               od_outsb,
10651 -       mv_outsw:               od_outsw,
10652 -       mv_outsl:               od_outsl,
10653 -
10654 -       mv_readb:               generic_readb,
10655 -       mv_readw:               generic_readw,
10656 -       mv_readl:               generic_readl,
10657 -       mv_writeb:              generic_writeb,
10658 -       mv_writew:              generic_writew,
10659 -       mv_writel:              generic_writel,
10660 +       .mv_inb                 = od_inb,
10661 +       .mv_inw                 = od_inw,
10662 +       .mv_inl                 = od_inl,
10663 +       .mv_outb                = od_outb,
10664 +       .mv_outw                = od_outw,
10665 +       .mv_outl                = od_outl,
10666 +
10667 +       .mv_inb_p               = od_inb_p,
10668 +       .mv_inw_p               = od_inw_p,
10669 +       .mv_inl_p               = od_inl_p,
10670 +       .mv_outb_p              = od_outb_p,
10671 +       .mv_outw_p              = od_outw_p,
10672 +       .mv_outl_p              = od_outl_p,
10673 +
10674 +       .mv_insb                = od_insb,
10675 +       .mv_insw                = od_insw,
10676 +       .mv_insl                = od_insl,
10677 +       .mv_outsb               = od_outsb,
10678 +       .mv_outsw               = od_outsw,
10679 +       .mv_outsl               = od_outsl,
10680 +
10681 +       .mv_readb               = generic_readb,
10682 +       .mv_readw               = generic_readw,
10683 +       .mv_readl               = generic_readl,
10684 +       .mv_writeb              = generic_writeb,
10685 +       .mv_writew              = generic_writew,
10686 +       .mv_writel              = generic_writel,
10687  
10688 -       mv_ioremap:             generic_ioremap,
10689 -       mv_iounmap:             generic_iounmap,
10690 +       .mv_ioremap             = generic_ioremap,
10691 +       .mv_iounmap             = generic_iounmap,
10692  
10693 -       mv_isa_port2addr:       generic_isa_port2addr,
10694 +       .mv_isa_port2addr       = generic_isa_port2addr,
10695  
10696  #ifdef CONFIG_PCI
10697 -       mv_init_irq:            init_overdrive_irq,
10698 +       .mv_init_irq            = init_overdrive_irq,
10699  #endif
10700  #ifdef CONFIG_HEARTBEAT
10701 -       mv_heartbeat:           heartbeat_od,
10702 +       .mv_heartbeat           = heartbeat_od,
10703  #endif
10704  };
10705  
10706 diff -Nru a/arch/sh/boards/saturn/irq.c b/arch/sh/boards/saturn/irq.c
10707 --- a/arch/sh/boards/saturn/irq.c       Sat Jun 14 11:02:09 2003
10708 +++ b/arch/sh/boards/saturn/irq.c       Sun Aug 31 16:14:08 2003
10709 @@ -102,13 +102,13 @@
10710  }
10711  
10712  static struct hw_interrupt_type saturn_int = {
10713 -       typename:       "Saturn",
10714 -       enable:         enable_saturn_irq,
10715 -       disable:        disable_saturn_irq,
10716 -       ack:            mask_and_ack_saturn_irq,
10717 -       end:            end_saturn_irq,
10718 -       startup:        startup_saturn_irq,
10719 -       shutdown:       shutdown_saturn_irq,
10720 +       .typename       = "Saturn",
10721 +       .enable         = enable_saturn_irq,
10722 +       .disable        = disable_saturn_irq,
10723 +       .ack            = mask_and_ack_saturn_irq,
10724 +       .end            = end_saturn_irq,
10725 +       .startup        = startup_saturn_irq,
10726 +       .shutdown       = shutdown_saturn_irq,
10727  };
10728  
10729  int saturn_irq_demux(int irq_nr)
10730 diff -Nru a/arch/sh/boards/saturn/mach.c b/arch/sh/boards/saturn/mach.c
10731 --- a/arch/sh/boards/saturn/mach.c      Mon May 19 16:04:39 2003
10732 +++ b/arch/sh/boards/saturn/mach.c      Sun Aug 31 16:14:08 2003
10733 @@ -18,41 +18,41 @@
10734   * The Machine Vector
10735   */
10736  struct sh_machine_vector mv_saturn __initmv = {
10737 -        mv_nr_irqs:             80,    /* Fix this later */
10738 +        .mv_nr_irqs             = 80,  /* Fix this later */
10739  
10740 -        mv_inb:                 generic_inb,
10741 -        mv_inw:                 generic_inw,
10742 -        mv_inl:                 generic_inl,
10743 -        mv_outb:                generic_outb,
10744 -        mv_outw:                generic_outw,
10745 -        mv_outl:                generic_outl,
10746 -
10747 -        mv_inb_p:               generic_inb_p,
10748 -        mv_inw_p:               generic_inw_p,
10749 -        mv_inl_p:               generic_inl_p,
10750 -        mv_outb_p:              generic_outb_p,
10751 -        mv_outw_p:              generic_outw_p,
10752 -        mv_outl_p:              generic_outl_p,
10753 -
10754 -        mv_insb:                generic_insb,
10755 -        mv_insw:                generic_insw,
10756 -        mv_insl:                generic_insl,
10757 -        mv_outsb:               generic_outsb,
10758 -        mv_outsw:               generic_outsw,
10759 -        mv_outsl:               generic_outsl,
10760 -
10761 -        mv_readb:               generic_readb,
10762 -        mv_readw:               generic_readw,
10763 -        mv_readl:               generic_readl,
10764 -        mv_writeb:              generic_writeb,
10765 -        mv_writew:              generic_writew,
10766 -        mv_writel:              generic_writel,
10767 +        .mv_inb                 = generic_inb,
10768 +        .mv_inw                 = generic_inw,
10769 +        .mv_inl                 = generic_inl,
10770 +        .mv_outb                = generic_outb,
10771 +        .mv_outw                = generic_outw,
10772 +        .mv_outl                = generic_outl,
10773 +
10774 +        .mv_inb_p               = generic_inb_p,
10775 +        .mv_inw_p               = generic_inw_p,
10776 +        .mv_inl_p               = generic_inl_p,
10777 +        .mv_outb_p              = generic_outb_p,
10778 +        .mv_outw_p              = generic_outw_p,
10779 +        .mv_outl_p              = generic_outl_p,
10780 +
10781 +        .mv_insb                = generic_insb,
10782 +        .mv_insw                = generic_insw,
10783 +        .mv_insl                = generic_insl,
10784 +        .mv_outsb               = generic_outsb,
10785 +        .mv_outsw               = generic_outsw,
10786 +        .mv_outsl               = generic_outsl,
10787 +
10788 +        .mv_readb               = generic_readb,
10789 +        .mv_readw               = generic_readw,
10790 +        .mv_readl               = generic_readl,
10791 +        .mv_writeb              = generic_writeb,
10792 +        .mv_writew              = generic_writew,
10793 +        .mv_writel              = generic_writel,
10794  
10795 -        mv_isa_port2addr:       saturn_isa_port2addr,
10796 -       mv_irq_demux:           saturn_irq_demux,
10797 +        .mv_isa_port2addr       = saturn_isa_port2addr,
10798 +       .mv_irq_demux           = saturn_irq_demux,
10799  
10800 -        mv_ioremap:             saturn_ioremap,
10801 -        mv_iounmap:             saturn_iounmap,
10802 +        .mv_ioremap             = saturn_ioremap,
10803 +        .mv_iounmap             = saturn_iounmap,
10804  };
10805  
10806  ALIAS_MV(saturn)
10807 diff -Nru a/arch/sh/boards/se/770x/mach.c b/arch/sh/boards/se/770x/mach.c
10808 --- a/arch/sh/boards/se/770x/mach.c     Mon May 19 16:04:39 2003
10809 +++ b/arch/sh/boards/se/770x/mach.c     Sun Aug 31 16:14:08 2003
10810 @@ -28,49 +28,49 @@
10811  
10812  struct sh_machine_vector mv_se __initmv = {
10813  #if defined(CONFIG_CPU_SH4)
10814 -       mv_nr_irqs:             48,
10815 +       .mv_nr_irqs             = 48,
10816  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
10817 -       mv_nr_irqs:             32,
10818 +       .mv_nr_irqs             = 32,
10819  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
10820 -       mv_nr_irqs:             61,
10821 +       .mv_nr_irqs             = 61,
10822  #endif
10823  
10824 -       mv_inb:                 se_inb,
10825 -       mv_inw:                 se_inw,
10826 -       mv_inl:                 se_inl,
10827 -       mv_outb:                se_outb,
10828 -       mv_outw:                se_outw,
10829 -       mv_outl:                se_outl,
10830 -
10831 -       mv_inb_p:               se_inb_p,
10832 -       mv_inw_p:               se_inw,
10833 -       mv_inl_p:               se_inl,
10834 -       mv_outb_p:              se_outb_p,
10835 -       mv_outw_p:              se_outw,
10836 -       mv_outl_p:              se_outl,
10837 -
10838 -       mv_insb:                se_insb,
10839 -       mv_insw:                se_insw,
10840 -       mv_insl:                se_insl,
10841 -       mv_outsb:               se_outsb,
10842 -       mv_outsw:               se_outsw,
10843 -       mv_outsl:               se_outsl,
10844 -
10845 -       mv_readb:               se_readb,
10846 -       mv_readw:               se_readw,
10847 -       mv_readl:               se_readl,
10848 -       mv_writeb:              se_writeb,
10849 -       mv_writew:              se_writew,
10850 -       mv_writel:              se_writel,
10851 +       .mv_inb                 = se_inb,
10852 +       .mv_inw                 = se_inw,
10853 +       .mv_inl                 = se_inl,
10854 +       .mv_outb                = se_outb,
10855 +       .mv_outw                = se_outw,
10856 +       .mv_outl                = se_outl,
10857 +
10858 +       .mv_inb_p               = se_inb_p,
10859 +       .mv_inw_p               = se_inw,
10860 +       .mv_inl_p               = se_inl,
10861 +       .mv_outb_p              = se_outb_p,
10862 +       .mv_outw_p              = se_outw,
10863 +       .mv_outl_p              = se_outl,
10864 +
10865 +       .mv_insb                = se_insb,
10866 +       .mv_insw                = se_insw,
10867 +       .mv_insl                = se_insl,
10868 +       .mv_outsb               = se_outsb,
10869 +       .mv_outsw               = se_outsw,
10870 +       .mv_outsl               = se_outsl,
10871 +
10872 +       .mv_readb               = se_readb,
10873 +       .mv_readw               = se_readw,
10874 +       .mv_readl               = se_readl,
10875 +       .mv_writeb              = se_writeb,
10876 +       .mv_writew              = se_writew,
10877 +       .mv_writel              = se_writel,
10878  
10879 -       mv_ioremap:             generic_ioremap,
10880 -       mv_iounmap:             generic_iounmap,
10881 +       .mv_ioremap             = generic_ioremap,
10882 +       .mv_iounmap             = generic_iounmap,
10883  
10884 -       mv_isa_port2addr:       se_isa_port2addr,
10885 +       .mv_isa_port2addr       = se_isa_port2addr,
10886  
10887 -       mv_init_irq:            init_se_IRQ,
10888 +       .mv_init_irq            = init_se_IRQ,
10889  #ifdef CONFIG_HEARTBEAT
10890 -       mv_heartbeat:           heartbeat_se,
10891 +       .mv_heartbeat           = heartbeat_se,
10892  #endif
10893  };
10894  ALIAS_MV(se)
10895 diff -Nru a/arch/sh/boards/se/7751/mach.c b/arch/sh/boards/se/7751/mach.c
10896 --- a/arch/sh/boards/se/7751/mach.c     Mon May 19 16:04:39 2003
10897 +++ b/arch/sh/boards/se/7751/mach.c     Sun Aug 31 16:14:08 2003
10898 @@ -26,44 +26,44 @@
10899   */
10900  
10901  struct sh_machine_vector mv_7751se __initmv = {
10902 -       mv_nr_irqs:             72,
10903 +       .mv_nr_irqs             = 72,
10904  
10905 -       mv_inb:                 sh7751se_inb,
10906 -       mv_inw:                 sh7751se_inw,
10907 -       mv_inl:                 sh7751se_inl,
10908 -       mv_outb:                sh7751se_outb,
10909 -       mv_outw:                sh7751se_outw,
10910 -       mv_outl:                sh7751se_outl,
10911 -
10912 -       mv_inb_p:               sh7751se_inb_p,
10913 -       mv_inw_p:               sh7751se_inw,
10914 -       mv_inl_p:               sh7751se_inl,
10915 -       mv_outb_p:              sh7751se_outb_p,
10916 -       mv_outw_p:              sh7751se_outw,
10917 -       mv_outl_p:              sh7751se_outl,
10918 -
10919 -       mv_insb:                sh7751se_insb,
10920 -       mv_insw:                sh7751se_insw,
10921 -       mv_insl:                sh7751se_insl,
10922 -       mv_outsb:               sh7751se_outsb,
10923 -       mv_outsw:               sh7751se_outsw,
10924 -       mv_outsl:               sh7751se_outsl,
10925 -
10926 -       mv_readb:               sh7751se_readb,
10927 -       mv_readw:               sh7751se_readw,
10928 -       mv_readl:               sh7751se_readl,
10929 -       mv_writeb:              sh7751se_writeb,
10930 -       mv_writew:              sh7751se_writew,
10931 -       mv_writel:              sh7751se_writel,
10932 +       .mv_inb                 = sh7751se_inb,
10933 +       .mv_inw                 = sh7751se_inw,
10934 +       .mv_inl                 = sh7751se_inl,
10935 +       .mv_outb                = sh7751se_outb,
10936 +       .mv_outw                = sh7751se_outw,
10937 +       .mv_outl                = sh7751se_outl,
10938 +
10939 +       .mv_inb_p               = sh7751se_inb_p,
10940 +       .mv_inw_p               = sh7751se_inw,
10941 +       .mv_inl_p               = sh7751se_inl,
10942 +       .mv_outb_p              = sh7751se_outb_p,
10943 +       .mv_outw_p              = sh7751se_outw,
10944 +       .mv_outl_p              = sh7751se_outl,
10945 +
10946 +       .mv_insb                = sh7751se_insb,
10947 +       .mv_insw                = sh7751se_insw,
10948 +       .mv_insl                = sh7751se_insl,
10949 +       .mv_outsb               = sh7751se_outsb,
10950 +       .mv_outsw               = sh7751se_outsw,
10951 +       .mv_outsl               = sh7751se_outsl,
10952 +
10953 +       .mv_readb               = sh7751se_readb,
10954 +       .mv_readw               = sh7751se_readw,
10955 +       .mv_readl               = sh7751se_readl,
10956 +       .mv_writeb              = sh7751se_writeb,
10957 +       .mv_writew              = sh7751se_writew,
10958 +       .mv_writel              = sh7751se_writel,
10959  
10960 -       mv_ioremap:             generic_ioremap,
10961 -       mv_iounmap:             generic_iounmap,
10962 +       .mv_ioremap             = generic_ioremap,
10963 +       .mv_iounmap             = generic_iounmap,
10964  
10965 -       mv_isa_port2addr:       sh7751se_isa_port2addr,
10966 +       .mv_isa_port2addr       = sh7751se_isa_port2addr,
10967  
10968 -       mv_init_irq:            init_7751se_IRQ,
10969 +       .mv_init_irq            = init_7751se_IRQ,
10970  #ifdef CONFIG_HEARTBEAT
10971 -       mv_heartbeat:           heartbeat_7751se,
10972 +       .mv_heartbeat           = heartbeat_7751se,
10973  #endif
10974  };
10975  ALIAS_MV(7751se)
10976 diff -Nru a/arch/sh/boards/sh2000/mach.c b/arch/sh/boards/sh2000/mach.c
10977 --- a/arch/sh/boards/sh2000/mach.c      Mon May 19 16:04:40 2003
10978 +++ b/arch/sh/boards/sh2000/mach.c      Sun Aug 31 16:14:08 2003
10979 @@ -19,39 +19,39 @@
10980   */
10981  
10982  struct sh_machine_vector mv_sh2000 __initmv = {
10983 -        mv_nr_irqs:             80,
10984 +        .mv_nr_irqs             = 80,
10985  
10986 -        mv_inb:                 generic_inb,
10987 -        mv_inw:                 generic_inw,
10988 -        mv_inl:                 generic_inl,
10989 -        mv_outb:                generic_outb,
10990 -        mv_outw:                generic_outw,
10991 -        mv_outl:                generic_outl,
10992 -
10993 -        mv_inb_p:               generic_inb_p,
10994 -        mv_inw_p:               generic_inw_p,
10995 -        mv_inl_p:               generic_inl_p,
10996 -        mv_outb_p:              generic_outb_p,
10997 -        mv_outw_p:              generic_outw_p,
10998 -        mv_outl_p:              generic_outl_p,
10999 -
11000 -        mv_insb:                generic_insb,
11001 -        mv_insw:                generic_insw,
11002 -        mv_insl:                generic_insl,
11003 -        mv_outsb:               generic_outsb,
11004 -        mv_outsw:               generic_outsw,
11005 -        mv_outsl:               generic_outsl,
11006 -
11007 -        mv_readb:               generic_readb,
11008 -        mv_readw:               generic_readw,
11009 -        mv_readl:               generic_readl,
11010 -        mv_writeb:              generic_writeb,
11011 -        mv_writew:              generic_writew,
11012 -        mv_writel:              generic_writel,
11013 +        .mv_inb                 = generic_inb,
11014 +        .mv_inw                 = generic_inw,
11015 +        .mv_inl                 = generic_inl,
11016 +        .mv_outb                = generic_outb,
11017 +        .mv_outw                = generic_outw,
11018 +        .mv_outl                = generic_outl,
11019 +
11020 +        .mv_inb_p               = generic_inb_p,
11021 +        .mv_inw_p               = generic_inw_p,
11022 +        .mv_inl_p               = generic_inl_p,
11023 +        .mv_outb_p              = generic_outb_p,
11024 +        .mv_outw_p              = generic_outw_p,
11025 +        .mv_outl_p              = generic_outl_p,
11026 +
11027 +        .mv_insb                = generic_insb,
11028 +        .mv_insw                = generic_insw,
11029 +        .mv_insl                = generic_insl,
11030 +        .mv_outsb               = generic_outsb,
11031 +        .mv_outsw               = generic_outsw,
11032 +        .mv_outsl               = generic_outsl,
11033 +
11034 +        .mv_readb               = generic_readb,
11035 +        .mv_readw               = generic_readw,
11036 +        .mv_readl               = generic_readl,
11037 +        .mv_writeb              = generic_writeb,
11038 +        .mv_writew              = generic_writew,
11039 +        .mv_writel              = generic_writel,
11040  
11041 -        mv_isa_port2addr:       sh2000_isa_port2addr,
11042 +        .mv_isa_port2addr       = sh2000_isa_port2addr,
11043  
11044 -        mv_ioremap:             generic_ioremap,
11045 -        mv_iounmap:             generic_iounmap,
11046 +        .mv_ioremap             = generic_ioremap,
11047 +        .mv_iounmap             = generic_iounmap,
11048  };
11049  ALIAS_MV(sh2000)
11050 diff -Nru a/arch/sh/boards/unknown/mach.c b/arch/sh/boards/unknown/mach.c
11051 --- a/arch/sh/boards/unknown/mach.c     Fri Jan 10 04:26:40 2003
11052 +++ b/arch/sh/boards/unknown/mach.c     Sun Aug 31 16:14:08 2003
11053 @@ -24,44 +24,44 @@
11054  
11055  struct sh_machine_vector mv_unknown __initmv = {
11056  #if defined(CONFIG_CPU_SH4)
11057 -       mv_nr_irqs:             48,
11058 +       .mv_nr_irqs             = 48,
11059  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
11060 -       mv_nr_irqs:             32,
11061 +       .mv_nr_irqs             = 32,
11062  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
11063 -       mv_nr_irqs:             61,
11064 +       .mv_nr_irqs             = 61,
11065  #endif
11066  
11067 -       mv_inb:                 unknown_inb,
11068 -       mv_inw:                 unknown_inw,
11069 -       mv_inl:                 unknown_inl,
11070 -       mv_outb:                unknown_outb,
11071 -       mv_outw:                unknown_outw,
11072 -       mv_outl:                unknown_outl,
11073 -
11074 -       mv_inb_p:               unknown_inb_p,
11075 -       mv_inw_p:               unknown_inw_p,
11076 -       mv_inl_p:               unknown_inl_p,
11077 -       mv_outb_p:              unknown_outb_p,
11078 -       mv_outw_p:              unknown_outw_p,
11079 -       mv_outl_p:              unknown_outl_p,
11080 -
11081 -       mv_insb:                unknown_insb,
11082 -       mv_insw:                unknown_insw,
11083 -       mv_insl:                unknown_insl,
11084 -       mv_outsb:               unknown_outsb,
11085 -       mv_outsw:               unknown_outsw,
11086 -       mv_outsl:               unknown_outsl,
11087 -
11088 -       mv_readb:               unknown_readb,
11089 -       mv_readw:               unknown_readw,
11090 -       mv_readl:               unknown_readl,
11091 -       mv_writeb:              unknown_writeb,
11092 -       mv_writew:              unknown_writew,
11093 -       mv_writel:              unknown_writel,
11094 +       .mv_inb                 = unknown_inb,
11095 +       .mv_inw                 = unknown_inw,
11096 +       .mv_inl                 = unknown_inl,
11097 +       .mv_outb                = unknown_outb,
11098 +       .mv_outw                = unknown_outw,
11099 +       .mv_outl                = unknown_outl,
11100 +
11101 +       .mv_inb_p               = unknown_inb_p,
11102 +       .mv_inw_p               = unknown_inw_p,
11103 +       .mv_inl_p               = unknown_inl_p,
11104 +       .mv_outb_p              = unknown_outb_p,
11105 +       .mv_outw_p              = unknown_outw_p,
11106 +       .mv_outl_p              = unknown_outl_p,
11107 +
11108 +       .mv_insb                = unknown_insb,
11109 +       .mv_insw                = unknown_insw,
11110 +       .mv_insl                = unknown_insl,
11111 +       .mv_outsb               = unknown_outsb,
11112 +       .mv_outsw               = unknown_outsw,
11113 +       .mv_outsl               = unknown_outsl,
11114 +
11115 +       .mv_readb               = unknown_readb,
11116 +       .mv_readw               = unknown_readw,
11117 +       .mv_readl               = unknown_readl,
11118 +       .mv_writeb              = unknown_writeb,
11119 +       .mv_writew              = unknown_writew,
11120 +       .mv_writel              = unknown_writel,
11121  
11122 -       mv_ioremap:             unknown_ioremap,
11123 -       mv_iounmap:             unknown_iounmap,
11124 +       .mv_ioremap             = unknown_ioremap,
11125 +       .mv_iounmap             = unknown_iounmap,
11126  
11127 -       mv_isa_port2addr:       unknown_isa_port2addr,
11128 +       .mv_isa_port2addr       = unknown_isa_port2addr,
11129  };
11130  ALIAS_MV(unknown)
11131 diff -Nru a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c
11132 --- a/arch/sh/cchips/hd6446x/hd64465/setup.c    Mon Nov  4 07:33:57 2002
11133 +++ b/arch/sh/cchips/hd6446x/hd64465/setup.c    Sun Aug 31 16:14:08 2003
11134 @@ -89,13 +89,13 @@
11135  
11136  
11137  static struct hw_interrupt_type hd64465_irq_type = {
11138 -       typename:       "HD64465-IRQ",
11139 -       startup:        startup_hd64465_irq,
11140 -       shutdown:       shutdown_hd64465_irq,
11141 -       enable:         enable_hd64465_irq,
11142 -       disable:        disable_hd64465_irq,
11143 -       ack:            mask_and_ack_hd64465,
11144 -       end:            end_hd64465_irq
11145 +       .typename       = "HD64465-IRQ",
11146 +       .startup        = startup_hd64465_irq,
11147 +       .shutdown       = shutdown_hd64465_irq,
11148 +       .enable         = enable_hd64465_irq,
11149 +       .disable        = disable_hd64465_irq,
11150 +       .ack            = mask_and_ack_hd64465,
11151 +       .end            = end_hd64465_irq
11152  };
11153  
11154  
11155 diff -Nru a/arch/sparc/Kconfig b/arch/sparc/Kconfig
11156 --- a/arch/sparc/Kconfig        Sat Aug  2 14:26:16 2003
11157 +++ b/arch/sparc/Kconfig        Sun Aug 31 16:14:22 2003
11158 @@ -254,29 +254,6 @@
11159           <file:Documentation/modules.txt>.
11160           The module will be called openpromfs.  If unsure, say M.
11161  
11162 -config KCORE_ELF
11163 -       bool
11164 -       depends on PROC_FS
11165 -       default y
11166 -       ---help---
11167 -         If you enabled support for /proc file system then the file
11168 -         /proc/kcore will contain the kernel core image. This can be used
11169 -         in gdb:
11170 -
11171 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
11172 -
11173 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
11174 -         /proc/kcore appear in ELF core format as defined by the Executable
11175 -         and Linking Format specification. Selecting A.OUT will choose the
11176 -         old "a.out" format which may be necessary for some old versions
11177 -         of binutils or on some architectures.
11178 -
11179 -         This is especially useful if you have compiled the kernel with the
11180 -         "-g" option to preserve debugging information. It is mainly used
11181 -         for examining kernel data structures on the live kernel so if you
11182 -         don't understand what this means or are not a kernel hacker, just
11183 -         leave it at its default value ELF.
11184 -
11185  source "fs/Kconfig.binfmt"
11186  
11187  config SUNOS_EMUL
11188 diff -Nru a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile
11189 --- a/arch/sparc/boot/Makefile  Sat Jul 12 22:05:29 2003
11190 +++ b/arch/sparc/boot/Makefile  Thu Aug 28 00:18:36 2003
11191 @@ -19,7 +19,7 @@
11192  
11193  BTOBJS := $(HEAD_Y) $(INIT_Y)
11194  BTLIBS := $(CORE_Y) $(LIBS_Y) $(DRIVERS_Y) $(NET_Y)
11195 -LDFLAGS_image := -T arch/sparc/vmlinux.lds.s $(BTOBJS) --start-group $(BTLIBS) --end-group
11196 +LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds.s $(BTOBJS) --start-group $(BTLIBS) --end-group
11197  
11198  # Actual linking
11199  $(obj)/image: $(obj)/btfix.o FORCE
11200 diff -Nru a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
11201 --- a/arch/sparc/kernel/entry.S Sat Aug 16 14:13:18 2003
11202 +++ b/arch/sparc/kernel/entry.S Wed Aug 27 23:52:25 2003
11203 @@ -38,7 +38,7 @@
11204  
11205  #define curptr      g6
11206  
11207 -#define NR_SYSCALLS 266      /* Each OS is different... */
11208 +#define NR_SYSCALLS 267      /* Each OS is different... */
11209  
11210  /* These are just handy. */
11211  #define _SV    save    %sp, -STACKFRAME_SZ, %sp
11212 diff -Nru a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
11213 --- a/arch/sparc/kernel/ioport.c        Sun May 25 17:00:00 2003
11214 +++ b/arch/sparc/kernel/ioport.c        Thu Aug 28 01:15:54 2003
11215 @@ -511,6 +511,26 @@
11216         }
11217  }
11218  
11219 +/*
11220 + * Same as pci_map_single, but with pages.
11221 + */
11222 +dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
11223 +                       unsigned long offset, size_t size, int direction)
11224 +{
11225 +       if (direction == PCI_DMA_NONE)
11226 +               BUG();
11227 +       /* IIep is write-through, not flushing. */
11228 +       return page_to_phys(page) + offset;
11229 +}
11230 +
11231 +void pci_unmap_page(struct pci_dev *hwdev,
11232 +                       dma_addr_t dma_address, size_t size, int direction)
11233 +{
11234 +       if (direction == PCI_DMA_NONE)
11235 +               BUG();
11236 +       /* mmu_inval_dma_area XXX */
11237 +}
11238 +
11239  /* Map a set of buffers described by scatterlist in streaming
11240   * mode for DMA.  This is the scather-gather version of the
11241   * above pci_map_single interface.  Here the scatter gather list
11242 diff -Nru a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c
11243 --- a/arch/sparc/kernel/sys_sunos.c     Sun May 25 17:00:00 2003
11244 +++ b/arch/sparc/kernel/sys_sunos.c     Tue Aug 26 09:25:41 2003
11245 @@ -92,8 +92,8 @@
11246          * SunOS is so stupid some times... hmph!
11247          */
11248         if (file) {
11249 -               if(major(file->f_dentry->d_inode->i_rdev) == MEM_MAJOR &&
11250 -                  minor(file->f_dentry->d_inode->i_rdev) == 5) {
11251 +               if(imajor(file->f_dentry->d_inode) == MEM_MAJOR &&
11252 +                  iminor(file->f_dentry->d_inode) == 5) {
11253                         flags |= MAP_ANONYMOUS;
11254                         fput(file);
11255                         file = 0;
11256 diff -Nru a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
11257 --- a/arch/sparc/kernel/systbls.S       Sat Aug 16 14:13:18 2003
11258 +++ b/arch/sparc/kernel/systbls.S       Thu Aug 28 01:35:18 2003
11259 @@ -72,7 +72,7 @@
11260  /*250*/        .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
11261  /*255*/        .long sys_nis_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
11262  /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
11263 -/*261*/        .long sys_timer_delete, sys_nis_syscall
11264 +/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall
11265  
11266  #ifdef CONFIG_SUNOS_EMUL
11267         /* Now the SunOS syscall table. */
11268 @@ -171,6 +171,6 @@
11269         .long sunos_nosys
11270  /*260*/        .long sunos_nosys, sunos_nosys, sunos_nosys
11271         .long sunos_nosys, sunos_nosys, sunos_nosys
11272 -       .long sunos_nosys
11273 +       .long sunos_nosys, sunos_nosys
11274  
11275  #endif
11276 diff -Nru a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
11277 --- a/arch/sparc64/Kconfig      Sat Aug  2 14:26:53 2003
11278 +++ b/arch/sparc64/Kconfig      Sun Aug 31 16:14:22 2003
11279 @@ -363,29 +363,6 @@
11280           <file:Documentation/modules.txt>.
11281           The module will be called openpromfs.  If unsure, say M.
11282  
11283 -config KCORE_ELF
11284 -       bool
11285 -       depends on PROC_FS
11286 -       default y
11287 -       ---help---
11288 -         If you enabled support for /proc file system then the file
11289 -         /proc/kcore will contain the kernel core image. This can be used
11290 -         in gdb:
11291 -
11292 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
11293 -
11294 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
11295 -         /proc/kcore appear in ELF core format as defined by the Executable
11296 -         and Linking Format specification. Selecting A.OUT will choose the
11297 -         old "a.out" format which may be necessary for some old versions
11298 -         of binutils or on some architectures.
11299 -
11300 -         This is especially useful if you have compiled the kernel with the
11301 -         "-g" option to preserve debugging information. It is mainly used
11302 -         for examining kernel data structures on the live kernel so if you
11303 -         don't understand what this means or are not a kernel hacker, just
11304 -         leave it at its default value ELF.
11305 -
11306  config SPARC32_COMPAT
11307         bool "Kernel support for Linux/Sparc 32bit binary compatibility"
11308         help
11309 diff -Nru a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
11310 --- a/arch/sparc64/kernel/entry.S       Sat Aug 16 14:13:18 2003
11311 +++ b/arch/sparc64/kernel/entry.S       Wed Aug 27 23:52:25 2003
11312 @@ -26,7 +26,7 @@
11313  
11314  #define curptr      g6
11315  
11316 -#define NR_SYSCALLS 266      /* Each OS is different... */
11317 +#define NR_SYSCALLS 267      /* Each OS is different... */
11318  
11319         .text
11320         .align          32
11321 diff -Nru a/arch/sparc64/kernel/ioctl32.c b/arch/sparc64/kernel/ioctl32.c
11322 --- a/arch/sparc64/kernel/ioctl32.c     Fri Aug  8 14:53:47 2003
11323 +++ b/arch/sparc64/kernel/ioctl32.c     Sun Aug 31 16:14:44 2003
11324 @@ -1388,7 +1388,7 @@
11325  #define IOCTL_TABLE_START \
11326         struct ioctl_trans ioctl_start[] = {
11327  #define IOCTL_TABLE_END \
11328 -       }; struct ioctl_trans ioctl_end[0];
11329 +       };
11330  
11331  IOCTL_TABLE_START
11332  #include <linux/compat_ioctl.h>
11333 @@ -1583,3 +1583,5 @@
11334  HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
11335  /* take care of sizeof(sizeof()) breakage */
11336  IOCTL_TABLE_END
11337 +
11338 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
11339 diff -Nru a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
11340 --- a/arch/sparc64/kernel/irq.c Tue Aug 19 19:00:31 2003
11341 +++ b/arch/sparc64/kernel/irq.c Thu Aug 28 17:10:27 2003
11342 @@ -1097,6 +1097,18 @@
11343  
11344         memset(__irq_work + smp_processor_id(), 0, sizeof(*workp));
11345  
11346 +       /* Make sure we are called with PSTATE_IE disabled.  */
11347 +       __asm__ __volatile__("rdpr      %%pstate, %0\n\t"
11348 +                            : "=r" (tmp));
11349 +       if (tmp & PSTATE_IE) {
11350 +               prom_printf("BUG: init_irqwork_curcpu() called with "
11351 +                           "PSTATE_IE enabled, bailing.\n");
11352 +               __asm__ __volatile__("mov       %%i7, %0\n\t"
11353 +                                    : "=r" (tmp));
11354 +               prom_printf("BUG: Called from %lx\n", tmp);
11355 +               prom_halt();
11356 +       }
11357 +
11358         /* Set interrupt globals.  */
11359         workp = &__irq_work[smp_processor_id()];
11360         __asm__ __volatile__(
11361 @@ -1105,7 +1117,7 @@
11362         "mov    %2, %%g6\n\t"
11363         "wrpr   %0, 0x0, %%pstate\n\t"
11364         : "=&r" (tmp)
11365 -       : "i" (PSTATE_IG | PSTATE_IE), "r" (workp));
11366 +       : "i" (PSTATE_IG), "r" (workp));
11367  }
11368  
11369  /* Only invoked on boot processor. */
11370 diff -Nru a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
11371 --- a/arch/sparc64/kernel/pci_psycho.c  Fri Jul 25 08:40:56 2003
11372 +++ b/arch/sparc64/kernel/pci_psycho.c  Sun Aug 24 03:18:58 2003
11373 @@ -874,6 +874,46 @@
11374  #define PSYCHO_PCI_AFAR_A      0x2018UL
11375  #define PSYCHO_PCI_AFAR_B      0x4018UL
11376  
11377 +static irqreturn_t psycho_pcierr_intr_other(struct pci_pbm_info *pbm, int is_pbm_a)
11378 +{
11379 +       unsigned long csr_reg, csr, csr_error_bits;
11380 +       irqreturn_t ret = IRQ_NONE;
11381 +       u16 stat;
11382 +
11383 +       if (is_pbm_a) {
11384 +               csr_reg = pbm->controller_regs + PSYCHO_PCIA_CTRL;
11385 +       } else {
11386 +               csr_reg = pbm->controller_regs + PSYCHO_PCIB_CTRL;
11387 +       }
11388 +       csr = psycho_read(csr_reg);
11389 +       csr_error_bits =
11390 +               csr & (PSYCHO_PCICTRL_SBH_ERR | PSYCHO_PCICTRL_SERR);
11391 +       if (csr_error_bits) {
11392 +               /* Clear the errors.  */
11393 +               psycho_write(csr_reg, csr);
11394 +
11395 +               /* Log 'em.  */
11396 +               if (csr_error_bits & PSYCHO_PCICTRL_SBH_ERR)
11397 +                       printk("%s: PCI streaming byte hole error asserted.\n",
11398 +                              pbm->name);
11399 +               if (csr_error_bits & PSYCHO_PCICTRL_SERR)
11400 +                       printk("%s: PCI SERR signal asserted.\n", pbm->name);
11401 +               ret = IRQ_HANDLED;
11402 +       }
11403 +       pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);
11404 +       if (stat & (PCI_STATUS_PARITY |
11405 +                   PCI_STATUS_SIG_TARGET_ABORT |
11406 +                   PCI_STATUS_REC_TARGET_ABORT |
11407 +                   PCI_STATUS_REC_MASTER_ABORT |
11408 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
11409 +               printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
11410 +                      pbm->name, stat);
11411 +               pci_write_config_word(pbm->pci_bus->self, PCI_STATUS, 0xffff);
11412 +               ret = IRQ_HANDLED;
11413 +       }
11414 +       return ret;
11415 +}
11416 +
11417  static irqreturn_t psycho_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
11418  {
11419         struct pci_pbm_info *pbm = dev_id;
11420 @@ -902,7 +942,7 @@
11421                  PSYCHO_PCIAFSR_SMA | PSYCHO_PCIAFSR_STA |
11422                  PSYCHO_PCIAFSR_SRTRY | PSYCHO_PCIAFSR_SPERR);
11423         if (!error_bits)
11424 -               return IRQ_NONE;
11425 +               return psycho_pcierr_intr_other(pbm, is_pbm_a);
11426         psycho_write(afsr_reg, error_bits);
11427  
11428         /* Log the error. */
11429 @@ -1008,6 +1048,7 @@
11430                 prom_halt();
11431         }
11432  
11433 +       pbm = &p->pbm_A;
11434         irq = psycho_irq_build(pbm, NULL, (portid << 6) | PSYCHO_PCIERR_A_INO);
11435         if (request_irq(irq, psycho_pcierr_intr,
11436                         SA_SHIRQ, "PSYCHO PCIERR", &p->pbm_A) < 0) {
11437 @@ -1016,6 +1057,7 @@
11438                 prom_halt();
11439         }
11440  
11441 +       pbm = &p->pbm_B;
11442         irq = psycho_irq_build(pbm, NULL, (portid << 6) | PSYCHO_PCIERR_B_INO);
11443         if (request_irq(irq, psycho_pcierr_intr,
11444                         SA_SHIRQ, "PSYCHO PCIERR", &p->pbm_B) < 0) {
11445 diff -Nru a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
11446 --- a/arch/sparc64/kernel/pci_sabre.c   Tue Aug 19 16:00:48 2003
11447 +++ b/arch/sparc64/kernel/pci_sabre.c   Sun Aug 24 03:18:58 2003
11448 @@ -221,6 +221,7 @@
11449          ((unsigned long)(REG)))
11450  
11451  static int hummingbird_p;
11452 +static struct pci_bus *sabre_root_bus;
11453  
11454  static void *sabre_pci_config_mkaddr(struct pci_pbm_info *pbm,
11455                                      unsigned char bus,
11456 @@ -860,6 +861,42 @@
11457         return IRQ_HANDLED;
11458  }
11459  
11460 +static irqreturn_t sabre_pcierr_intr_other(struct pci_controller_info *p)
11461 +{
11462 +       unsigned long csr_reg, csr, csr_error_bits;
11463 +       irqreturn_t ret = IRQ_NONE;
11464 +       u16 stat;
11465 +
11466 +       csr_reg = p->pbm_A.controller_regs + SABRE_PCICTRL;
11467 +       csr = sabre_read(csr_reg);
11468 +       csr_error_bits =
11469 +               csr & SABRE_PCICTRL_SERR;
11470 +       if (csr_error_bits) {
11471 +               /* Clear the errors.  */
11472 +               sabre_write(csr_reg, csr);
11473 +
11474 +               /* Log 'em.  */
11475 +               if (csr_error_bits & SABRE_PCICTRL_SERR)
11476 +                       printk("SABRE%d: PCI SERR signal asserted.\n",
11477 +                              p->index);
11478 +               ret = IRQ_HANDLED;
11479 +       }
11480 +       pci_read_config_word(sabre_root_bus->self,
11481 +                            PCI_STATUS, &stat);
11482 +       if (stat & (PCI_STATUS_PARITY |
11483 +                   PCI_STATUS_SIG_TARGET_ABORT |
11484 +                   PCI_STATUS_REC_TARGET_ABORT |
11485 +                   PCI_STATUS_REC_MASTER_ABORT |
11486 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
11487 +               printk("SABRE%d: PCI bus error, PCI_STATUS[%04x]\n",
11488 +                      p->index, stat);
11489 +               pci_write_config_word(sabre_root_bus->self,
11490 +                                     PCI_STATUS, 0xffff);
11491 +               ret = IRQ_HANDLED;
11492 +       }
11493 +       return ret;
11494 +}
11495 +
11496  static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
11497  {
11498         struct pci_controller_info *p = dev_id;
11499 @@ -881,7 +918,7 @@
11500                  SABRE_PIOAFSR_SMA | SABRE_PIOAFSR_STA |
11501                  SABRE_PIOAFSR_SRTRY | SABRE_PIOAFSR_SPERR);
11502         if (!error_bits)
11503 -               return IRQ_NONE;
11504 +               return sabre_pcierr_intr_other(p);
11505         sabre_write(afsr_reg, error_bits);
11506  
11507         /* Log the error. */
11508 @@ -1167,6 +1204,8 @@
11509                                  &p->pbm_A);
11510         pci_fixup_host_bridge_self(sabre_bus);
11511         sabre_bus->self->sysdata = cookie;
11512 +
11513 +       sabre_root_bus = sabre_bus;
11514  
11515         apb_init(p, sabre_bus);
11516  
11517 diff -Nru a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
11518 --- a/arch/sparc64/kernel/pci_schizo.c  Sat Aug  2 18:21:52 2003
11519 +++ b/arch/sparc64/kernel/pci_schizo.c  Sun Aug 24 03:18:58 2003
11520 @@ -845,6 +845,88 @@
11521  #define SCHIZO_PCIAFSR_MEM     0x0000000020000000UL /* Schizo/Tomatillo */
11522  #define SCHIZO_PCIAFSR_IO      0x0000000010000000UL /* Schizo/Tomatillo */
11523  
11524 +#define SCHIZO_PCI_CTRL                (0x2000UL)
11525 +#define SCHIZO_PCICTRL_BUS_UNUS        (1UL << 63UL) /* Safari */
11526 +#define SCHIZO_PCICTRL_ARB_PRIO (0x1ff << 52UL) /* Tomatillo */
11527 +#define SCHIZO_PCICTRL_ESLCK   (1UL << 51UL) /* Safari */
11528 +#define SCHIZO_PCICTRL_ERRSLOT (7UL << 48UL) /* Safari */
11529 +#define SCHIZO_PCICTRL_TTO_ERR (1UL << 38UL) /* Safari/Tomatillo */
11530 +#define SCHIZO_PCICTRL_RTRY_ERR        (1UL << 37UL) /* Safari/Tomatillo */
11531 +#define SCHIZO_PCICTRL_DTO_ERR (1UL << 36UL) /* Safari/Tomatillo */
11532 +#define SCHIZO_PCICTRL_SBH_ERR (1UL << 35UL) /* Safari */
11533 +#define SCHIZO_PCICTRL_SERR    (1UL << 34UL) /* Safari/Tomatillo */
11534 +#define SCHIZO_PCICTRL_PCISPD  (1UL << 33UL) /* Safari */
11535 +#define SCHIZO_PCICTRL_MRM_PREF        (1UL << 28UL) /* Tomatillo */
11536 +#define SCHIZO_PCICTRL_RDO_PREF        (1UL << 27UL) /* Tomatillo */
11537 +#define SCHIZO_PCICTRL_RDL_PREF        (1UL << 26UL) /* Tomatillo */
11538 +#define SCHIZO_PCICTRL_PTO     (3UL << 24UL) /* Safari/Tomatillo */
11539 +#define SCHIZO_PCICTRL_PTO_SHIFT 24UL
11540 +#define SCHIZO_PCICTRL_TRWSW   (7UL << 21UL) /* Tomatillo */
11541 +#define SCHIZO_PCICTRL_F_TGT_A (1UL << 20UL) /* Tomatillo */
11542 +#define SCHIZO_PCICTRL_S_DTO_INT (1UL << 19UL) /* Safari */
11543 +#define SCHIZO_PCICTRL_F_TGT_RT        (1UL << 19UL) /* Tomatillo */
11544 +#define SCHIZO_PCICTRL_SBH_INT (1UL << 18UL) /* Safari */
11545 +#define SCHIZO_PCICTRL_T_DTO_INT (1UL << 18UL) /* Tomatillo */
11546 +#define SCHIZO_PCICTRL_EEN     (1UL << 17UL) /* Safari/Tomatillo */
11547 +#define SCHIZO_PCICTRL_PARK    (1UL << 16UL) /* Safari/Tomatillo */
11548 +#define SCHIZO_PCICTRL_PCIRST  (1UL <<  8UL) /* Safari */
11549 +#define SCHIZO_PCICTRL_ARB_S   (0x3fUL << 0UL) /* Safari */
11550 +#define SCHIZO_PCICTRL_ARB_T   (0xffUL << 0UL) /* Tomatillo */
11551 +
11552 +static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
11553 +{
11554 +       unsigned long csr_reg, csr, csr_error_bits;
11555 +       irqreturn_t ret = IRQ_NONE;
11556 +       u16 stat;
11557 +
11558 +       csr_reg = pbm->pbm_regs + SCHIZO_PCI_CTRL;
11559 +       csr = schizo_read(csr_reg);
11560 +       csr_error_bits =
11561 +               csr & (SCHIZO_PCICTRL_BUS_UNUS |
11562 +                      SCHIZO_PCICTRL_TTO_ERR |
11563 +                      SCHIZO_PCICTRL_RTRY_ERR |
11564 +                      SCHIZO_PCICTRL_DTO_ERR |
11565 +                      SCHIZO_PCICTRL_SBH_ERR |
11566 +                      SCHIZO_PCICTRL_SERR);
11567 +       if (csr_error_bits) {
11568 +               /* Clear the errors.  */
11569 +               schizo_write(csr_reg, csr);
11570 +
11571 +               /* Log 'em.  */
11572 +               if (csr_error_bits & SCHIZO_PCICTRL_BUS_UNUS)
11573 +                       printk("%s: Bus unusable error asserted.\n",
11574 +                              pbm->name);
11575 +               if (csr_error_bits & SCHIZO_PCICTRL_TTO_ERR)
11576 +                       printk("%s: PCI TRDY# timeout error asserted.\n",
11577 +                              pbm->name);
11578 +               if (csr_error_bits & SCHIZO_PCICTRL_RTRY_ERR)
11579 +                       printk("%s: PCI excessive retry error asserted.\n",
11580 +                              pbm->name);
11581 +               if (csr_error_bits & SCHIZO_PCICTRL_DTO_ERR)
11582 +                       printk("%s: PCI discard timeout error asserted.\n",
11583 +                              pbm->name);
11584 +               if (csr_error_bits & SCHIZO_PCICTRL_SBH_ERR)
11585 +                       printk("%s: PCI streaming byte hole error asserted.\n",
11586 +                              pbm->name);
11587 +               if (csr_error_bits & SCHIZO_PCICTRL_SERR)
11588 +                       printk("%s: PCI SERR signal asserted.\n",
11589 +                              pbm->name);
11590 +               ret = IRQ_HANDLED;
11591 +       }
11592 +       pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);
11593 +       if (stat & (PCI_STATUS_PARITY |
11594 +                   PCI_STATUS_SIG_TARGET_ABORT |
11595 +                   PCI_STATUS_REC_TARGET_ABORT |
11596 +                   PCI_STATUS_REC_MASTER_ABORT |
11597 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
11598 +               printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
11599 +                      pbm->name, stat);
11600 +               pci_write_config_word(pbm->pci_bus->self, PCI_STATUS, 0xffff);
11601 +               ret = IRQ_HANDLED;
11602 +       }
11603 +       return ret;
11604 +}
11605 +
11606  static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
11607  {
11608         struct pci_pbm_info *pbm = dev_id;
11609 @@ -871,7 +953,7 @@
11610                  SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
11611                  SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS);
11612         if (!error_bits)
11613 -               return IRQ_NONE;
11614 +               return schizo_pcierr_intr_other(pbm);
11615         schizo_write(afsr_reg, error_bits);
11616  
11617         /* Log the error. */
11618 @@ -1043,34 +1125,6 @@
11619  #define SCHIZO_PCIERR_A_INO    0x32 /* PBM A PCI bus error */
11620  #define SCHIZO_PCIERR_B_INO    0x33 /* PBM B PCI bus error */
11621  #define SCHIZO_SERR_INO                0x34 /* Safari interface error */
11622 -
11623 -#define SCHIZO_PCI_CTRL                (0x2000UL)
11624 -#define SCHIZO_PCICTRL_BUS_UNUS        (1UL << 63UL) /* Safari */
11625 -#define SCHIZO_PCICTRL_ARB_PRIO (0x1ff << 52UL) /* Tomatillo */
11626 -#define SCHIZO_PCICTRL_ESLCK   (1UL << 51UL) /* Safari */
11627 -#define SCHIZO_PCICTRL_ERRSLOT (7UL << 48UL) /* Safari */
11628 -#define SCHIZO_PCICTRL_TTO_ERR (1UL << 38UL) /* Safari/Tomatillo */
11629 -#define SCHIZO_PCICTRL_RTRY_ERR        (1UL << 37UL) /* Safari/Tomatillo */
11630 -#define SCHIZO_PCICTRL_DTO_ERR (1UL << 36UL) /* Safari/Tomatillo */
11631 -#define SCHIZO_PCICTRL_SBH_ERR (1UL << 35UL) /* Safari */
11632 -#define SCHIZO_PCICTRL_SERR    (1UL << 34UL) /* Safari/Tomatillo */
11633 -#define SCHIZO_PCICTRL_PCISPD  (1UL << 33UL) /* Safari */
11634 -#define SCHIZO_PCICTRL_MRM_PREF        (1UL << 28UL) /* Tomatillo */
11635 -#define SCHIZO_PCICTRL_RDO_PREF        (1UL << 27UL) /* Tomatillo */
11636 -#define SCHIZO_PCICTRL_RDL_PREF        (1UL << 26UL) /* Tomatillo */
11637 -#define SCHIZO_PCICTRL_PTO     (3UL << 24UL) /* Safari/Tomatillo */
11638 -#define SCHIZO_PCICTRL_PTO_SHIFT 24UL
11639 -#define SCHIZO_PCICTRL_TRWSW   (7UL << 21UL) /* Tomatillo */
11640 -#define SCHIZO_PCICTRL_F_TGT_A (1UL << 20UL) /* Tomatillo */
11641 -#define SCHIZO_PCICTRL_S_DTO_INT (1UL << 19UL) /* Safari */
11642 -#define SCHIZO_PCICTRL_F_TGT_RT        (1UL << 19UL) /* Tomatillo */
11643 -#define SCHIZO_PCICTRL_SBH_INT (1UL << 18UL) /* Safari */
11644 -#define SCHIZO_PCICTRL_T_DTO_INT (1UL << 18UL) /* Tomatillo */
11645 -#define SCHIZO_PCICTRL_EEN     (1UL << 17UL) /* Safari/Tomatillo */
11646 -#define SCHIZO_PCICTRL_PARK    (1UL << 16UL) /* Safari/Tomatillo */
11647 -#define SCHIZO_PCICTRL_PCIRST  (1UL <<  8UL) /* Safari */
11648 -#define SCHIZO_PCICTRL_ARB_S   (0x3fUL << 0UL) /* Safari */
11649 -#define SCHIZO_PCICTRL_ARB_T   (0xffUL << 0UL) /* Tomatillo */
11650  
11651  struct pci_pbm_info *pbm_for_ino(struct pci_controller_info *p, u32 ino)
11652  {
11653 diff -Nru a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
11654 --- a/arch/sparc64/kernel/sys_sparc32.c Sat Aug 16 07:09:56 2003
11655 +++ b/arch/sparc64/kernel/sys_sparc32.c Sat Aug 30 22:29:28 2003
11656 @@ -388,7 +388,7 @@
11657   *
11658   * This is really horribly ugly.
11659   */
11660 -#define IPCOP_MASK(__x)        (1UL << (__x))
11661 +#define IPCOP_MASK(__x)        (1UL << ((__x)&~IPC_64))
11662  static int do_sys32_semctl(int first, int second, int third, void *uptr)
11663  {
11664         union semun fourth;
11665 @@ -400,7 +400,7 @@
11666         err = -EFAULT;
11667         if (get_user (pad, (u32 *)uptr))
11668                 goto out;
11669 -       if(third == SETVAL)
11670 +       if ((third & ~IPC_64) == SETVAL)
11671                 fourth.val = (int)pad;
11672         else
11673                 fourth.__pad = (void *)A(pad);
11674 @@ -2779,3 +2779,41 @@
11675         return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
11676                                   buf, len);
11677  }
11678 +
11679 +extern asmlinkage long
11680 +sys_timer_create(clockid_t which_clock, struct sigevent *timer_event_spec,
11681 +                timer_t * created_timer_id);
11682 +
11683 +long
11684 +sys32_timer_create(u32 clock, struct sigevent32 *se32, timer_t *timer_id)
11685 +{
11686 +       struct sigevent se;
11687 +       mm_segment_t oldfs;
11688 +       timer_t t;
11689 +       long err;
11690 +
11691 +       if (se32 == NULL)
11692 +               return sys_timer_create(clock, NULL, timer_id);
11693 +
11694 +       memset(&se, 0, sizeof(struct sigevent));
11695 +       if (get_user(se.sigev_value.sival_int,  &se32->sigev_value.sival_int) ||
11696 +           __get_user(se.sigev_signo, &se32->sigev_signo) ||
11697 +           __get_user(se.sigev_notify, &se32->sigev_notify) ||
11698 +           __copy_from_user(&se._sigev_un._pad, &se32->_sigev_un._pad,
11699 +           sizeof(se._sigev_un._pad)))
11700 +               return -EFAULT;
11701 +
11702 +       if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
11703 +               return -EFAULT;
11704 +
11705 +       oldfs = get_fs();
11706 +       set_fs(KERNEL_DS);
11707 +       err = sys_timer_create(clock, &se, &t);
11708 +       set_fs(oldfs);
11709 +
11710 +       if (!err)
11711 +               err = __put_user (t, timer_id);
11712 +
11713 +       return err;
11714 +}
11715 +
11716 diff -Nru a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c
11717 --- a/arch/sparc64/kernel/sys_sunos32.c Sun May 25 17:00:00 2003
11718 +++ b/arch/sparc64/kernel/sys_sunos32.c Tue Aug 26 09:25:41 2003
11719 @@ -90,7 +90,7 @@
11720                 if (!file)
11721                         goto out;
11722                 inode = file->f_dentry->d_inode;
11723 -               if (minor(inode->i_rdev) == MEM_MAJOR && minor(inode->i_rdev) == 5) {
11724 +               if (imajor(inode) == MEM_MAJOR && iminor(inode) == 5) {
11725                         flags |= MAP_ANONYMOUS;
11726                         fput(file);
11727                         file = NULL;
11728 diff -Nru a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
11729 --- a/arch/sparc64/kernel/systbls.S     Sat Aug 16 14:55:44 2003
11730 +++ b/arch/sparc64/kernel/systbls.S     Thu Aug 28 01:35:18 2003
11731 @@ -72,7 +72,7 @@
11732  /*250*/        .word sys32_mremap, sys32_sysctl, sys_getsid, sys_fdatasync, sys32_nfsservctl
11733         .word sys_ni_syscall, compat_clock_settime, compat_clock_gettime, compat_clock_getres, compat_clock_nanosleep
11734  /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, compat_timer_settime, compat_timer_gettime, sys_timer_getoverrun
11735 -       .word sys_timer_delete, sys_ni_syscall
11736 +       .word sys_timer_delete, sys32_timer_create, sys_ni_syscall
11737  
11738         /* Now the 64-bit native Linux syscall table. */
11739  
11740 @@ -133,7 +133,7 @@
11741  /*250*/        .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
11742         .word sys_ni_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
11743  /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
11744 -       .word sys_timer_delete, sys_ni_syscall
11745 +       .word sys_timer_delete, sys_timer_create, sys_ni_syscall
11746  
11747  #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
11748      defined(CONFIG_SOLARIS_EMUL_MODULE)
11749 @@ -228,10 +228,10 @@
11750         .word sunos_nosys, sunos_nosys, sunos_nosys
11751         .word sunos_nosys, sunos_nosys
11752  /*250*/        .word sunos_nosys, sunos_nosys, sunos_nosys
11753 -       .word sunos_nosys, sunos_nosys, sys_ni_syscall
11754 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
11755 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
11756 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
11757 -       .word sys_ni_syscall, sys_ni_syscall
11758 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11759 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11760 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11761 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11762 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11763  
11764  #endif
11765 diff -Nru a/arch/sparc64/mm/hugetlbpage.c b/arch/sparc64/mm/hugetlbpage.c
11766 --- a/arch/sparc64/mm/hugetlbpage.c     Mon Feb 24 23:13:11 2003
11767 +++ b/arch/sparc64/mm/hugetlbpage.c     Tue Aug 26 09:41:27 2003
11768 @@ -380,207 +380,6 @@
11769         return 1;
11770  }
11771  
11772 -static struct inode *set_new_inode(unsigned long len, int prot, int flag, int key)
11773 -{
11774 -       struct inode *inode;
11775 -       int i;
11776 -
11777 -       for (i = 0; i < MAX_ID; i++) {
11778 -               if (htlbpagek[i].key == 0)
11779 -                       break;
11780 -       }
11781 -       if (i == MAX_ID)
11782 -               return NULL;
11783 -       inode = kmalloc(sizeof (struct inode), GFP_KERNEL);
11784 -       if (inode == NULL)
11785 -               return NULL;
11786 -
11787 -       inode_init_once(inode);
11788 -       atomic_inc(&inode->i_writecount);
11789 -       inode->i_mapping = &inode->i_data;
11790 -       inode->i_mapping->host = inode;
11791 -       inode->i_ino = (unsigned long)key;
11792 -
11793 -       htlbpagek[i].key = key;
11794 -       htlbpagek[i].in = inode;
11795 -       inode->i_uid = current->fsuid;
11796 -       inode->i_gid = current->fsgid;
11797 -       inode->i_mode = prot;
11798 -       inode->i_size = len;
11799 -       return inode;
11800 -}
11801 -
11802 -static int check_size_prot(struct inode *inode, unsigned long len, int prot, int flag)
11803 -{
11804 -       if (inode->i_uid != current->fsuid)
11805 -               return -1;
11806 -       if (inode->i_gid != current->fsgid)
11807 -               return -1;
11808 -       if (inode->i_size != len)
11809 -               return -1;
11810 -       return 0;
11811 -}
11812 -
11813 -static int alloc_shared_hugetlb_pages(int key, unsigned long addr, unsigned long len,
11814 -                                     int prot, int flag)
11815 -{
11816 -       struct mm_struct *mm = current->mm;
11817 -       struct vm_area_struct *vma;
11818 -       struct inode *inode;
11819 -       struct address_space *mapping;
11820 -       struct page *page;
11821 -       int idx;
11822 -       int retval = -ENOMEM;
11823 -       int newalloc = 0;
11824 -
11825 -try_again:
11826 -       spin_lock(&htlbpage_lock);
11827 -
11828 -       inode = find_key_inode(key);
11829 -       if (inode == NULL) {
11830 -               if (!capable(CAP_SYS_ADMIN)) {
11831 -                       if (!in_group_p(0)) {
11832 -                               retval = -EPERM;
11833 -                               goto out_err;
11834 -                       }
11835 -               }
11836 -               if (!(flag & IPC_CREAT)) {
11837 -                       retval = -ENOENT;
11838 -                       goto out_err;
11839 -               }
11840 -               inode = set_new_inode(len, prot, flag, key);
11841 -               if (inode == NULL)
11842 -                       goto out_err;
11843 -               newalloc = 1;
11844 -       } else {
11845 -               if (check_size_prot(inode, len, prot, flag) < 0) {
11846 -                       retval = -EINVAL;
11847 -                       goto out_err;
11848 -               } else if (atomic_read(&inode->i_writecount)) {
11849 -                       spin_unlock(&htlbpage_lock);
11850 -                       goto try_again;
11851 -               }
11852 -       }
11853 -       spin_unlock(&htlbpage_lock);
11854 -       mapping = inode->i_mapping;
11855 -
11856 -       addr = do_mmap_pgoff(NULL, addr, len, (unsigned long) prot,
11857 -                            MAP_NORESERVE|MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, 0);
11858 -       if (IS_ERR((void *) addr))
11859 -               goto freeinode;
11860 -
11861 -       vma = find_vma(mm, addr);
11862 -       if (!vma) {
11863 -               retval = -EINVAL;
11864 -               goto freeinode;
11865 -       }
11866 -
11867 -       spin_lock(&mm->page_table_lock);
11868 -       do {
11869 -               pte_t *pte = huge_pte_alloc_map(mm, addr);
11870 -
11871 -               if (!pte || !pte_none(pte)) {
11872 -                       if (pte)
11873 -                               pte_unmap(pte);
11874 -                       goto out;
11875 -               }
11876 -
11877 -               idx = (addr - vma->vm_start) >> HPAGE_SHIFT;
11878 -               page = find_get_page(mapping, idx);
11879 -               if (page == NULL) {
11880 -                       page = alloc_hugetlb_page();
11881 -                       if (page == NULL) {
11882 -                               pte_unmap(pte);
11883 -                               retval = -ENOMEM;
11884 -                               goto out;
11885 -                       }
11886 -                       retval = add_to_page_cache(page, mapping,
11887 -                                               idx, GFP_ATOMIC);
11888 -                       if (retval) {
11889 -                               pte_unmap(pte);
11890 -                               free_hugetlb_page(page);
11891 -                               goto out;
11892 -                       }
11893 -               }
11894 -               set_huge_pte(mm, vma, page, pte,
11895 -                            (vma->vm_flags & VM_WRITE));
11896 -               pte_unmap(pte);
11897 -
11898 -               addr += HPAGE_SIZE;
11899 -       } while (addr < vma->vm_end);
11900 -
11901 -       retval = 0;
11902 -       vma->vm_flags |= (VM_HUGETLB | VM_RESERVED);
11903 -       vma->vm_ops = &hugetlb_vm_ops;
11904 -       spin_unlock(&mm->page_table_lock);
11905 -       spin_lock(&htlbpage_lock);
11906 -       atomic_set(&inode->i_writecount, 0);
11907 -       spin_unlock(&htlbpage_lock);
11908 -
11909 -       return retval;
11910 -
11911 -out:
11912 -       if (addr > vma->vm_start) {
11913 -               unsigned long raddr;
11914 -               raddr = vma->vm_end;
11915 -               vma->vm_end = addr;
11916 -
11917 -               flush_cache_range(vma, vma->vm_start, vma->vm_end);
11918 -               zap_hugetlb_resources(vma);
11919 -               flush_tlb_range(vma, vma->vm_start, vma->vm_end);
11920 -
11921 -               vma->vm_end = raddr;
11922 -       }
11923 -       spin_unlock(&mm->page_table_lock);
11924 -       do_munmap(mm, vma->vm_start, len);
11925 -       if (newalloc)
11926 -               goto freeinode;
11927 -
11928 -       return retval;
11929 -
11930 -out_err:
11931 -       spin_unlock(&htlbpage_lock);
11932 -
11933 -freeinode:
11934 -       if (newalloc) {
11935 -               for (idx = 0; idx < MAX_ID; idx++) {
11936 -                       if (htlbpagek[idx].key == inode->i_ino) {
11937 -                               htlbpagek[idx].key = 0;
11938 -                               htlbpagek[idx].in = NULL;
11939 -                               break;
11940 -                       }
11941 -               }
11942 -               kfree(inode);
11943 -       }
11944 -       return retval;
11945 -}
11946 -
11947 -static int alloc_private_hugetlb_pages(int key, unsigned long addr, unsigned long len,
11948 -                                      int prot, int flag)
11949 -{
11950 -       if (!capable(CAP_SYS_ADMIN)) {
11951 -               if (!in_group_p(0))
11952 -                       return -EPERM;
11953 -       }
11954 -       addr = do_mmap_pgoff(NULL, addr, len, prot,
11955 -                            MAP_NORESERVE|MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0);
11956 -       if (IS_ERR((void *) addr))
11957 -               return -ENOMEM;
11958 -       if (make_hugetlb_pages_present(addr, (addr + len), flag) < 0) {
11959 -               do_munmap(current->mm, addr, len);
11960 -               return -ENOMEM;
11961 -       }
11962 -       return 0;
11963 -}
11964 -
11965 -int alloc_hugetlb_pages(int key, unsigned long addr, unsigned long len, int prot,
11966 -                   int flag)
11967 -{
11968 -       if (key > 0)
11969 -               return alloc_shared_hugetlb_pages(key, addr, len, prot, flag);
11970 -       return alloc_private_hugetlb_pages(key, addr, len, prot, flag);
11971 -}
11972 -
11973  extern long htlbzone_pages;
11974  extern struct list_head htlbpage_freelist;
11975  
11976 diff -Nru a/arch/sparc64/solaris/misc.c b/arch/sparc64/solaris/misc.c
11977 --- a/arch/sparc64/solaris/misc.c       Tue Aug 19 12:12:41 2003
11978 +++ b/arch/sparc64/solaris/misc.c       Tue Aug 26 09:25:41 2003
11979 @@ -77,8 +77,8 @@
11980                         goto out;
11981                 else {
11982                         struct inode * inode = file->f_dentry->d_inode;
11983 -                       if(major(inode->i_rdev) == MEM_MAJOR &&
11984 -                          minor(inode->i_rdev) == 5) {
11985 +                       if(imajor(inode) == MEM_MAJOR &&
11986 +                          iminor(inode) == 5) {
11987                                 flags |= MAP_ANONYMOUS;
11988                                 fput(file);
11989                                 file = NULL;
11990 diff -Nru a/arch/sparc64/solaris/socksys.c b/arch/sparc64/solaris/socksys.c
11991 --- a/arch/sparc64/solaris/socksys.c    Wed May  7 08:47:29 2003
11992 +++ b/arch/sparc64/solaris/socksys.c    Tue Aug 26 09:25:40 2003
11993 @@ -70,14 +70,14 @@
11994                 (int (*)(int,int,int))SUNOS(97);
11995          struct sol_socket_struct * sock;
11996         
11997 -       family = ((minor(inode->i_rdev) >> 4) & 0xf);
11998 +       family = ((iminor(inode) >> 4) & 0xf);
11999         switch (family) {
12000         case AF_UNIX:
12001                 type = SOCK_STREAM;
12002                 protocol = 0;
12003                 break;
12004         case AF_INET:
12005 -               protocol = af_inet_protocols[minor(inode->i_rdev) & 0xf];
12006 +               protocol = af_inet_protocols[iminor(inode) & 0xf];
12007                 switch (protocol) {
12008                 case IPPROTO_TCP: type = SOCK_STREAM; break;
12009                 case IPPROTO_UDP: type = SOCK_DGRAM; break;
12010 diff -Nru a/arch/sparc64/solaris/systbl.S b/arch/sparc64/solaris/systbl.S
12011 --- a/arch/sparc64/solaris/systbl.S     Mon Aug 18 01:08:52 2003
12012 +++ b/arch/sparc64/solaris/systbl.S     Wed Aug 27 23:52:25 2003
12013 @@ -294,4 +294,5 @@
12014         .word solaris_unimplemented     /*                      264     */
12015         .word solaris_unimplemented     /*                      265     */
12016         .word solaris_unimplemented     /*                      266     */
12017 +       .word solaris_unimplemented     /*                      267     */
12018  
12019 diff -Nru a/arch/sparc64/solaris/timod.c b/arch/sparc64/solaris/timod.c
12020 --- a/arch/sparc64/solaris/timod.c      Fri Jun  6 04:40:53 2003
12021 +++ b/arch/sparc64/solaris/timod.c      Tue Aug 26 09:25:41 2003
12022 @@ -924,7 +924,7 @@
12023         if (!ino) goto out;
12024  
12025         if (!ino->i_sock &&
12026 -               (major(ino->i_rdev) != 30 || minor(ino->i_rdev) != 1))
12027 +               (imajor(ino) != 30 || iminor(ino) != 1))
12028                 goto out;
12029  
12030         ctlptr = (struct strbuf *)A(arg1);
12031 diff -Nru a/arch/v850/Kconfig b/arch/v850/Kconfig
12032 --- a/arch/v850/Kconfig Sat Aug  2 14:26:16 2003
12033 +++ b/arch/v850/Kconfig Sun Aug 31 16:14:22 2003
12034 @@ -262,14 +262,6 @@
12035  
12036  menu "Executable file formats"
12037  
12038 -config KCORE_AOUT
12039 -       bool
12040 -       default y
12041 -
12042 -config KCORE_ELF
12043 -       bool
12044 -       default y
12045 -
12046  source "fs/Kconfig.binfmt"
12047  
12048  endmenu
12049 diff -Nru a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S
12050 --- a/arch/v850/kernel/vmlinux.lds.S    Mon Aug  4 20:42:12 2003
12051 +++ b/arch/v850/kernel/vmlinux.lds.S    Tue Aug 26 00:21:26 2003
12052 @@ -33,6 +33,30 @@
12053                         *(.intv.mach)   /* Machine-specific int. vectors.  */ \
12054                 __intv_end = . ;
12055  
12056 +#define RODATA_CONTENTS                                                              \
12057 +               . = ALIGN (16) ;                                              \
12058 +                       *(.rodata) *(.rodata.*)                               \
12059 +                       *(__vermagic)           /* Kernel version magic */    \
12060 +                       *(.rodata1)                                           \
12061 +               /* Kernel symbol table: Normal symbols */                     \
12062 +               ___start___ksymtab = .;                                       \
12063 +                       *(__ksymtab)                                          \
12064 +               ___stop___ksymtab = .;                                        \
12065 +               /* Kernel symbol table: GPL-only symbols */                   \
12066 +               ___start___ksymtab_gpl = .;                                   \
12067 +                       *(__ksymtab_gpl)                                      \
12068 +               ___stop___ksymtab_gpl = .;                                    \
12069 +               /* Kernel symbol table: strings */                            \
12070 +                       *(__ksymtab_strings)                                  \
12071 +               /* Kernel symbol table: Normal symbols */                     \
12072 +               ___start___kcrctab = .;                                       \
12073 +                       *(__kcrctab)                                          \
12074 +               ___stop___kcrctab = .;                                        \
12075 +               /* Kernel symbol table: GPL-only symbols */                   \
12076 +               ___start___kcrctab_gpl = .;                                   \
12077 +                       *(__kcrctab_gpl)                                      \
12078 +               ___stop___kcrctab_gpl = .;                                    \
12079 +
12080  /* Kernel text segment, and some constant data areas.  */
12081  #define TEXT_CONTENTS                                                        \
12082                 __stext = . ;                                                 \
12083 @@ -42,7 +66,7 @@
12084                         *(.text.lock)                                         \
12085                         *(.exitcall.exit)                                     \
12086                 __real_etext = . ;      /* There may be data after here.  */  \
12087 -               RODATA                                                        \
12088 +               RODATA_CONTENTS                                               \
12089                 . = ALIGN (4) ;                                               \
12090                         *(.call_table_data)                                   \
12091                         *(.call_table_text)                                   \
12092 diff -Nru a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
12093 --- a/arch/x86_64/Kconfig       Sat Aug  2 14:26:16 2003
12094 +++ b/arch/x86_64/Kconfig       Sun Aug 31 16:14:22 2003
12095 @@ -370,11 +370,6 @@
12096  
12097  menu "Executable file formats / Emulations"
12098  
12099 -config KCORE_ELF
12100 -       bool
12101 -       depends on PROC_FS
12102 -       default y
12103 -
12104  source "fs/Kconfig.binfmt"
12105  
12106  config IA32_EMULATION
12107 diff -Nru a/arch/x86_64/defconfig b/arch/x86_64/defconfig
12108 --- a/arch/x86_64/defconfig     Sat Aug  9 07:53:46 2003
12109 +++ b/arch/x86_64/defconfig     Sat Aug 23 04:57:05 2003
12110 @@ -14,6 +14,7 @@
12111  # Code maturity level options
12112  #
12113  CONFIG_EXPERIMENTAL=y
12114 +# CONFIG_BROKEN is not set
12115  
12116  #
12117  # General setup
12118 @@ -23,10 +24,12 @@
12119  # CONFIG_BSD_PROCESS_ACCT is not set
12120  CONFIG_SYSCTL=y
12121  CONFIG_LOG_BUF_SHIFT=18
12122 +# CONFIG_IKCONFIG is not set
12123  # CONFIG_EMBEDDED is not set
12124  CONFIG_KALLSYMS=y
12125  CONFIG_FUTEX=y
12126  CONFIG_EPOLL=y
12127 +CONFIG_IOSCHED_NOOP=y
12128  CONFIG_IOSCHED_AS=y
12129  CONFIG_IOSCHED_DEADLINE=y
12130  
12131 @@ -72,10 +75,10 @@
12132  CONFIG_SOFTWARE_SUSPEND=y
12133  
12134  #
12135 -# ACPI Support
12136 +# ACPI (Advanced Configuration and Power Interface) Support
12137  #
12138 +# CONFIG_ACPI_HT is not set
12139  CONFIG_ACPI=y
12140 -# CONFIG_ACPI_HT_ONLY is not set
12141  CONFIG_ACPI_BOOT=y
12142  CONFIG_ACPI_SLEEP=y
12143  CONFIG_ACPI_SLEEP_PROC_FS=y
12144 @@ -117,7 +120,6 @@
12145  #
12146  # Generic Driver Options
12147  #
12148 -# CONFIG_FW_LOADER is not set
12149  
12150  #
12151  # Memory Technology Devices (MTD)
12152 @@ -159,6 +161,7 @@
12153  CONFIG_IDEDISK_MULTI_MODE=y
12154  # CONFIG_IDEDISK_STROKE is not set
12155  CONFIG_BLK_DEV_IDECD=y
12156 +# CONFIG_BLK_DEV_IDETAPE is not set
12157  # CONFIG_BLK_DEV_IDEFLOPPY is not set
12158  # CONFIG_BLK_DEV_IDESCSI is not set
12159  # CONFIG_IDE_TASK_IOCTL is not set
12160 @@ -318,7 +321,6 @@
12161  # CONFIG_DECNET is not set
12162  # CONFIG_BRIDGE is not set
12163  # CONFIG_NETFILTER is not set
12164 -# CONFIG_XFRM_USER is not set
12165  
12166  #
12167  # SCTP Configuration (EXPERIMENTAL)
12168 @@ -405,6 +407,7 @@
12169  # CONFIG_HAMACHI is not set
12170  # CONFIG_YELLOWFIN is not set
12171  # CONFIG_R8169 is not set
12172 +# CONFIG_SIS190 is not set
12173  # CONFIG_SK98LIN is not set
12174  CONFIG_TIGON3=y
12175  
12176 @@ -595,10 +598,7 @@
12177  CONFIG_REISERFS_FS=y
12178  # CONFIG_REISERFS_CHECK is not set
12179  # CONFIG_REISERFS_PROC_INFO is not set
12180 -CONFIG_JFS_FS=y
12181 -CONFIG_JFS_POSIX_ACL=y
12182 -# CONFIG_JFS_DEBUG is not set
12183 -# CONFIG_JFS_STATISTICS is not set
12184 +# CONFIG_JFS_FS is not set
12185  CONFIG_FS_POSIX_ACL=y
12186  # CONFIG_XFS_FS is not set
12187  # CONFIG_MINIX_FS is not set
12188 @@ -674,49 +674,6 @@
12189  #
12190  # CONFIG_PARTITION_ADVANCED is not set
12191  CONFIG_MSDOS_PARTITION=y
12192 -CONFIG_NLS=y
12193 -
12194 -#
12195 -# Native Language Support
12196 -#
12197 -CONFIG_NLS_DEFAULT="iso8859-1"
12198 -# CONFIG_NLS_CODEPAGE_437 is not set
12199 -# CONFIG_NLS_CODEPAGE_737 is not set
12200 -# CONFIG_NLS_CODEPAGE_775 is not set
12201 -# CONFIG_NLS_CODEPAGE_850 is not set
12202 -# CONFIG_NLS_CODEPAGE_852 is not set
12203 -# CONFIG_NLS_CODEPAGE_855 is not set
12204 -# CONFIG_NLS_CODEPAGE_857 is not set
12205 -# CONFIG_NLS_CODEPAGE_860 is not set
12206 -# CONFIG_NLS_CODEPAGE_861 is not set
12207 -# CONFIG_NLS_CODEPAGE_862 is not set
12208 -# CONFIG_NLS_CODEPAGE_863 is not set
12209 -# CONFIG_NLS_CODEPAGE_864 is not set
12210 -# CONFIG_NLS_CODEPAGE_865 is not set
12211 -# CONFIG_NLS_CODEPAGE_866 is not set
12212 -# CONFIG_NLS_CODEPAGE_869 is not set
12213 -# CONFIG_NLS_CODEPAGE_936 is not set
12214 -# CONFIG_NLS_CODEPAGE_950 is not set
12215 -# CONFIG_NLS_CODEPAGE_932 is not set
12216 -# CONFIG_NLS_CODEPAGE_949 is not set
12217 -# CONFIG_NLS_CODEPAGE_874 is not set
12218 -# CONFIG_NLS_ISO8859_8 is not set
12219 -# CONFIG_NLS_CODEPAGE_1250 is not set
12220 -# CONFIG_NLS_CODEPAGE_1251 is not set
12221 -# CONFIG_NLS_ISO8859_1 is not set
12222 -# CONFIG_NLS_ISO8859_2 is not set
12223 -# CONFIG_NLS_ISO8859_3 is not set
12224 -# CONFIG_NLS_ISO8859_4 is not set
12225 -# CONFIG_NLS_ISO8859_5 is not set
12226 -# CONFIG_NLS_ISO8859_6 is not set
12227 -# CONFIG_NLS_ISO8859_7 is not set
12228 -# CONFIG_NLS_ISO8859_9 is not set
12229 -# CONFIG_NLS_ISO8859_13 is not set
12230 -# CONFIG_NLS_ISO8859_14 is not set
12231 -# CONFIG_NLS_ISO8859_15 is not set
12232 -# CONFIG_NLS_KOI8_R is not set
12233 -# CONFIG_NLS_KOI8_U is not set
12234 -# CONFIG_NLS_UTF8 is not set
12235  
12236  #
12237  # Graphics support
12238 diff -Nru a/arch/x86_64/ia32/ia32_ioctl.c b/arch/x86_64/ia32/ia32_ioctl.c
12239 --- a/arch/x86_64/ia32/ia32_ioctl.c     Fri Jul 11 05:14:13 2003
12240 +++ b/arch/x86_64/ia32/ia32_ioctl.c     Sun Aug 31 16:14:44 2003
12241 @@ -673,12 +673,10 @@
12242         return err;
12243  } 
12244  
12245 -#define REF_SYMBOL(handler) if (0) (void)handler;
12246 -#define HANDLE_IOCTL2(cmd,handler) REF_SYMBOL(handler);  asm volatile(".quad %P0, " #handler ",0"::"i" (cmd)); 
12247 -#define HANDLE_IOCTL(cmd,handler) HANDLE_IOCTL2(cmd,handler)
12248 +#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL },
12249  #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl)
12250 -#define IOCTL_TABLE_START void ioctl_dummy(void) { asm volatile("\n.global ioctl_start\nioctl_start:\n\t" );
12251 -#define IOCTL_TABLE_END  asm volatile("\n.global ioctl_end;\nioctl_end:\n"); }
12252 +#define IOCTL_TABLE_START struct ioctl_trans ioctl_start[] = {
12253 +#define IOCTL_TABLE_END  };
12254  
12255  IOCTL_TABLE_START
12256  #include <linux/compat_ioctl.h>
12257 @@ -765,3 +763,4 @@
12258  HANDLE_IOCTL(MTRRIOC32_KILL_PAGE_ENTRY, mtrr_ioctl32)
12259  IOCTL_TABLE_END
12260  
12261 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
12262 diff -Nru a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
12263 --- a/arch/x86_64/ia32/sys_ia32.c       Mon Jul 14 04:19:39 2003
12264 +++ b/arch/x86_64/ia32/sys_ia32.c       Sun Aug 31 05:33:07 2003
12265 @@ -1170,8 +1170,6 @@
12266         return ret;
12267  }
12268  
12269 -extern void check_pending(int signum);
12270 -
12271  asmlinkage long sys_utimes(char *, struct timeval *);
12272  
12273  asmlinkage long
12274 diff -Nru a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
12275 --- a/arch/x86_64/kernel/apic.c Mon Aug 18 19:46:23 2003
12276 +++ b/arch/x86_64/kernel/apic.c Sat Aug 23 05:13:33 2003
12277 @@ -299,7 +299,7 @@
12278          * This is meaningless in clustered apic mode, so we skip it.
12279          */
12280         if (!clustered_apic_mode &&
12281 -               !cpu_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
12282 +               !physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
12283                 BUG();
12284  
12285         /*
12286 @@ -993,7 +993,7 @@
12287  
12288         connect_bsp_APIC();
12289  
12290 -       phys_cpu_present_map = cpumask_of_cpu(0);
12291 +       phys_cpu_present_map = physid_mask_of_physid(0);
12292         apic_write_around(APIC_ID, boot_cpu_id);
12293  
12294         setup_local_APIC();
12295 diff -Nru a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
12296 --- a/arch/x86_64/kernel/io_apic.c      Tue Aug 19 07:45:10 2003
12297 +++ b/arch/x86_64/kernel/io_apic.c      Sat Aug 23 05:13:33 2003
12298 @@ -1014,7 +1014,7 @@
12299  static void __init setup_ioapic_ids_from_mpc (void)
12300  {
12301         union IO_APIC_reg_00 reg_00;
12302 -       cpumask_t phys_id_present_map = phys_cpu_present_map;
12303 +       physid_mask_t phys_id_present_map = phys_cpu_present_map;
12304         int apic;
12305         int i;
12306         unsigned char old_id;
12307 @@ -1047,22 +1047,22 @@
12308                  * system must have a unique ID or we get lots of nice
12309                  * 'stuck on smp_invalidate_needed IPI wait' messages.
12310                  */
12311 -               if (cpu_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
12312 +               if (physid_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
12313                         printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
12314                                 apic, mp_ioapics[apic].mpc_apicid);
12315                         for (i = 0; i < 0xf; i++)
12316 -                               if (!cpu_isset(i, phys_id_present_map))
12317 +                               if (!physid_isset(i, phys_id_present_map))
12318                                         break;
12319                         if (i >= 0xf)
12320                                 panic("Max APIC ID exceeded!\n");
12321                         printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
12322                                 i);
12323 -                       cpu_set(i, phys_id_present_map);
12324 +                       physid_set(i, phys_id_present_map);
12325                         mp_ioapics[apic].mpc_apicid = i;
12326                 } else {
12327                         printk(KERN_INFO 
12328                                "Using IO-APIC %d\n", mp_ioapics[apic].mpc_apicid);
12329 -                       cpu_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
12330 +                       physid_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
12331                 }
12332  
12333  
12334 @@ -1642,7 +1642,7 @@
12335  int __init io_apic_get_unique_id (int ioapic, int apic_id)
12336  {
12337         union IO_APIC_reg_00 reg_00;
12338 -       static cpumask_t apic_id_map;
12339 +       static physid_mask_t apic_id_map;
12340         unsigned long flags;
12341         int i = 0;
12342  
12343 @@ -1655,7 +1655,7 @@
12344          *      advantage of new APIC bus architecture.
12345          */
12346  
12347 -       if (!cpus_empty(apic_id_map))
12348 +       if (!physids_empty(apic_id_map))
12349                 apic_id_map = phys_cpu_present_map;
12350  
12351         spin_lock_irqsave(&ioapic_lock, flags);
12352 @@ -1672,10 +1672,10 @@
12353          * Every APIC in a system must have a unique ID or we get lots of nice 
12354          * 'stuck on smp_invalidate_needed IPI wait' messages.
12355          */
12356 -       if (cpu_isset(apic_id, apic_id_map)) {
12357 +       if (physid_isset(apic_id, apic_id_map)) {
12358  
12359                 for (i = 0; i < IO_APIC_MAX_ID; i++) {
12360 -                       if (!cpu_isset(i, apic_id_map))
12361 +                       if (!physid_isset(i, apic_id_map))
12362                                 break;
12363                 }
12364  
12365 @@ -1688,7 +1688,7 @@
12366                 apic_id = i;
12367         } 
12368  
12369 -       cpu_set(apic_id, apic_id_map);
12370 +       physid_set(apic_id, apic_id_map);
12371  
12372         if (reg_00.bits.ID != apic_id) {
12373                 reg_00.bits.ID = apic_id;
12374 diff -Nru a/arch/x86_64/kernel/ioport.c b/arch/x86_64/kernel/ioport.c
12375 --- a/arch/x86_64/kernel/ioport.c       Wed Aug 20 10:43:52 2003
12376 +++ b/arch/x86_64/kernel/ioport.c       Sat Aug 23 05:03:34 2003
12377 @@ -10,12 +10,11 @@
12378  #include <linux/errno.h>
12379  #include <linux/types.h>
12380  #include <linux/ioport.h>
12381 -#include <linux/mm.h>
12382  #include <linux/smp.h>
12383  #include <linux/smp_lock.h>
12384  #include <linux/stddef.h>
12385  #include <linux/slab.h>
12386 -#include <asm/io.h>
12387 +#include <linux/thread_info.h>
12388  
12389  /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
12390  static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value)
12391 @@ -118,12 +117,7 @@
12392                         return -EPERM;
12393         }
12394         regs.eflags = (regs.eflags &~ 0x3000UL) | (level << 12);
12395 +       /* Make sure we return the long way (not sysenter) */
12396 +       set_thread_flag(TIF_IRET);
12397         return 0;
12398  }
12399 -
12400 -void eat_key(void)
12401 -{
12402 -       if (inb(0x60) & 1) 
12403 -               inb(0x64);
12404 -}
12405 -
12406 diff -Nru a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
12407 --- a/arch/x86_64/kernel/mpparse.c      Tue Aug 19 07:45:28 2003
12408 +++ b/arch/x86_64/kernel/mpparse.c      Sat Aug 23 05:13:33 2003
12409 @@ -67,7 +67,7 @@
12410  static unsigned int num_processors = 0;
12411  
12412  /* Bitmask of physically existing CPUs */
12413 -cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
12414 +physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
12415  
12416  /* ACPI MADT entry parsing functions */
12417  #ifdef CONFIG_ACPI_BOOT
12418 @@ -126,7 +126,7 @@
12419         }
12420         ver = m->mpc_apicver;
12421  
12422 -       cpu_set(m->mpc_apicid, phys_cpu_present_map);
12423 +       physid_set(m->mpc_apicid, phys_cpu_present_map);
12424         /*
12425          * Validate version
12426          */
12427 diff -Nru a/arch/x86_64/kernel/msr.c b/arch/x86_64/kernel/msr.c
12428 --- a/arch/x86_64/kernel/msr.c  Mon Aug 18 19:46:23 2003
12429 +++ b/arch/x86_64/kernel/msr.c  Tue Aug 26 09:25:40 2003
12430 @@ -194,7 +194,7 @@
12431    u32 data[2];
12432    size_t rv;
12433    u32 reg = *ppos;
12434 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
12435 +  int cpu = iminor(file->f_dentry->d_inode);
12436    int err;
12437  
12438    if ( count % 8 )
12439 @@ -219,7 +219,7 @@
12440    u32 data[2];
12441    size_t rv;
12442    u32 reg = *ppos;
12443 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
12444 +  int cpu = iminor(file->f_dentry->d_inode);
12445    int err;
12446  
12447    if ( count % 8 )
12448 @@ -239,7 +239,7 @@
12449  
12450  static int msr_open(struct inode *inode, struct file *file)
12451  {
12452 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
12453 +  int cpu = iminor(file->f_dentry->d_inode);
12454    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
12455    
12456    if (!cpu_online(cpu))
12457 diff -Nru a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
12458 --- a/arch/x86_64/kernel/setup.c        Mon Aug 18 19:46:23 2003
12459 +++ b/arch/x86_64/kernel/setup.c        Sat Aug 23 04:55:48 2003
12460 @@ -243,6 +243,8 @@
12461  
12462  void __init setup_arch(char **cmdline_p)
12463  {
12464 +       unsigned long low_mem_size;
12465 +
12466         ROOT_DEV = ORIG_ROOT_DEV;
12467         drive_info = DRIVE_INFO;
12468         screen_info = SCREEN_INFO;
12469 @@ -378,7 +380,13 @@
12470                 request_resource(&ioport_resource, standard_io_resources+i);
12471         }
12472  
12473 -       pci_mem_start = IOMAP_START; 
12474 +       /* Will likely break when you have unassigned resources with more
12475 +          than 4GB memory and bridges that don't support more than 4GB. 
12476 +          Doing it properly would require to allocate GFP_DMA memory
12477 +          in this case. */
12478 +       low_mem_size = ((end_pfn << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
12479 +       if (low_mem_size > pci_mem_start)
12480 +               pci_mem_start = low_mem_size;
12481  
12482  #ifdef CONFIG_GART_IOMMU
12483         iommu_hole_init();
12484 diff -Nru a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
12485 --- a/arch/x86_64/kernel/smpboot.c      Mon Aug 18 19:46:23 2003
12486 +++ b/arch/x86_64/kernel/smpboot.c      Sat Aug 23 05:13:33 2003
12487 @@ -734,10 +734,10 @@
12488         current_thread_info()->cpu = 0;
12489         smp_tune_scheduling();
12490  
12491 -       if (!cpu_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
12492 +       if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
12493                 printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
12494                        hard_smp_processor_id());
12495 -               cpu_set(hard_smp_processor_id(), phys_cpu_present_map);
12496 +               physid_set(hard_smp_processor_id(), phys_cpu_present_map);
12497         }
12498  
12499         /*
12500 @@ -748,7 +748,7 @@
12501                 printk(KERN_NOTICE "SMP motherboard not detected.\n");
12502                 io_apic_irqs = 0;
12503                 cpu_online_map = cpumask_of_cpu(0);
12504 -               phys_cpu_present_map = cpumask_of_cpu(0);
12505 +               phys_cpu_present_map = physid_mask_of_physid(0);
12506                 if (APIC_init_uniprocessor())
12507                         printk(KERN_NOTICE "Local APIC not detected."
12508                                            " Using dummy APIC emulation.\n");
12509 @@ -759,10 +759,10 @@
12510          * Should not be necessary because the MP table should list the boot
12511          * CPU too, but we do it for the sake of robustness anyway.
12512          */
12513 -       if (!cpu_isset(boot_cpu_id, phys_cpu_present_map)) {
12514 +       if (!physid_isset(boot_cpu_id, phys_cpu_present_map)) {
12515                 printk(KERN_NOTICE "weird, boot CPU (#%d) not listed by the BIOS.\n",
12516                                                                  boot_cpu_id);
12517 -               cpu_set(hard_smp_processor_id(), phys_cpu_present_map);
12518 +               physid_set(hard_smp_processor_id(), phys_cpu_present_map);
12519         }
12520  
12521         /*
12522 @@ -774,7 +774,7 @@
12523                 printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
12524                 io_apic_irqs = 0;
12525                 cpu_online_map = cpumask_of_cpu(0);
12526 -               phys_cpu_present_map = cpumask_of_cpu(0);
12527 +               phys_cpu_present_map = physid_mask_of_physid(0);
12528                 disable_apic = 1;
12529                 goto smp_done;
12530         }
12531 @@ -789,7 +789,7 @@
12532                 printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n");
12533                 io_apic_irqs = 0;
12534                 cpu_online_map = cpumask_of_cpu(0);
12535 -               phys_cpu_present_map = cpumask_of_cpu(0);
12536 +               phys_cpu_present_map = physid_mask_of_physid(0);
12537                 disable_apic = 1;
12538                 goto smp_done;
12539         }
12540 @@ -803,7 +803,7 @@
12541         /*
12542          * Now scan the CPU present map and fire up the other CPUs.
12543          */
12544 -       Dprintk("CPU present map: %lx\n", phys_cpu_present_map);
12545 +       Dprintk("CPU present map: %lx\n", physids_coerce(phys_cpu_present_map));
12546  
12547         for (apicid = 0; apicid < NR_CPUS; apicid++) {
12548                 /*
12549 diff -Nru a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
12550 --- a/arch/x86_64/kernel/time.c Thu Jul 10 22:22:57 2003
12551 +++ b/arch/x86_64/kernel/time.c Sat Aug 23 04:31:18 2003
12552 @@ -79,6 +79,7 @@
12553         unsigned long t;
12554         unsigned long x;
12555         rdtscll_sync(&t);
12556 +       if (t < vxtime.last_tsc) t = vxtime.last_tsc; /* hack */
12557         x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32;
12558         return x;
12559  }
12560 diff -Nru a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
12561 --- a/arch/x86_64/kernel/vsyscall.c     Fri Jun 13 01:16:29 2003
12562 +++ b/arch/x86_64/kernel/vsyscall.c     Sat Aug 23 04:31:40 2003
12563 @@ -85,6 +85,7 @@
12564                 if (__vxtime.mode == VXTIME_TSC) {
12565                         sync_core();
12566                         rdtscll(t);
12567 +                       if (t < __vxtime.last_tsc) t = __vxtime.last_tsc;
12568                         usec += ((t - __vxtime.last_tsc) *
12569                                  __vxtime.tsc_quot) >> 32;
12570                 } else {
12571 diff -Nru a/drivers/Makefile b/drivers/Makefile
12572 --- a/drivers/Makefile  Tue Aug 12 08:42:21 2003
12573 +++ b/drivers/Makefile  Sun Aug 24 07:59:26 2003
12574 @@ -20,6 +20,7 @@
12575  obj-y                          += base/ block/ misc/ net/ media/
12576  obj-$(CONFIG_NUBUS)            += nubus/
12577  obj-$(CONFIG_ATM)              += atm/
12578 +obj-$(CONFIG_PPC_PMAC)         += macintosh/
12579  obj-$(CONFIG_IDE)              += ide/
12580  obj-$(CONFIG_FC4)              += fc4/
12581  obj-$(CONFIG_SCSI)             += scsi/
12582 @@ -31,7 +32,6 @@
12583  obj-$(CONFIG_DIO)              += dio/
12584  obj-$(CONFIG_SBUS)             += sbus/
12585  obj-$(CONFIG_ZORRO)            += zorro/
12586 -obj-$(CONFIG_PPC_PMAC)         += macintosh/
12587  obj-$(CONFIG_MAC)              += macintosh/
12588  obj-$(CONFIG_PARIDE)           += block/paride/
12589  obj-$(CONFIG_TC)               += tc/
12590 diff -Nru a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c
12591 --- a/drivers/acorn/block/fd1772.c      Thu Aug  7 02:25:23 2003
12592 +++ b/drivers/acorn/block/fd1772.c      Tue Aug 26 09:25:40 2003
12593 @@ -1455,8 +1455,8 @@
12594  
12595  static int floppy_open(struct inode *inode, struct file *filp)
12596  {
12597 -       int drive = minor(inode->i_rdev) & 3;
12598 -       int type =  minor(inode->i_rdev) >> 2;
12599 +       int drive = iminor(inode) & 3;
12600 +       int type =  iminor(inode) >> 2;
12601         int old_dev = fd_device[drive];
12602  
12603         if (fd_ref[drive] && old_dev != type)
12604 @@ -1490,7 +1490,7 @@
12605  
12606  static int floppy_release(struct inode *inode, struct file *filp)
12607  {
12608 -       int drive = minor(inode->i_rdev) & 3;
12609 +       int drive = iminor(inode) & 3;
12610  
12611         if (fd_ref[drive] < 0)
12612                 fd_ref[drive] = 0;
12613 diff -Nru a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
12614 --- a/drivers/acpi/Kconfig      Wed Aug 20 09:06:49 2003
12615 +++ b/drivers/acpi/Kconfig      Sat Aug 23 04:07:34 2003
12616 @@ -69,6 +69,7 @@
12617         bool "Sleep States (EXPERIMENTAL)"
12618         depends on X86 && ACPI
12619         depends on EXPERIMENTAL && PM
12620 +       select SOFTWARE_SUSPEND
12621         default y
12622         ---help---
12623           This option adds support for ACPI suspend states. 
12624 diff -Nru a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
12625 --- a/drivers/acpi/pci_link.c   Tue Jul 29 13:28:29 2003
12626 +++ b/drivers/acpi/pci_link.c   Sun Aug 31 16:14:25 2003
12627 @@ -516,9 +516,8 @@
12628                 return_VALUE(0);
12629         }
12630  
12631 -       if (acpi_pci_link_allocate(link)) {
12632 -               return -ENODEV;
12633 -       }
12634 +       if (acpi_pci_link_allocate(link))
12635 +               return_VALUE(0);
12636            
12637         if (!link->irq.active) {
12638                 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link disabled\n"));
12639 diff -Nru a/drivers/atm/Kconfig b/drivers/atm/Kconfig
12640 --- a/drivers/atm/Kconfig       Tue Jul 29 22:31:46 2003
12641 +++ b/drivers/atm/Kconfig       Mon Aug 25 06:04:02 2003
12642 @@ -241,7 +241,7 @@
12643  
12644  config ATM_AMBASSADOR
12645         tristate "Madge Ambassador (Collage PCI 155 Server)"
12646 -       depends on PCI && ATM
12647 +       depends on PCI && ATM && BROKEN_ON_SMP
12648         help
12649           This is a driver for ATMizer based ATM card produced by Madge
12650           Networks Ltd. Say Y (or M to compile as a module named ambassador)
12651 diff -Nru a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
12652 --- a/drivers/atm/ambassador.c  Tue Aug 19 21:10:45 2003
12653 +++ b/drivers/atm/ambassador.c  Wed Aug 27 23:17:10 2003
12654 @@ -310,10 +310,11 @@
12655    0xdeadbeef
12656  };
12657  
12658 +static void do_housekeeping (unsigned long arg);
12659  /********** globals **********/
12660  
12661  static amb_dev * amb_devs = NULL;
12662 -static struct timer_list housekeeping;
12663 +static struct timer_list housekeeping = TIMER_INITIALIZER(do_housekeeping, 0, 1);
12664  
12665  static unsigned short debug = 0;
12666  static unsigned int cmds = 8;
12667 @@ -937,63 +938,6 @@
12668    return IRQ_HANDLED;
12669  }
12670  
12671 -/********** don't panic... yeah, right **********/
12672 -
12673 -#ifdef DEBUG_AMBASSADOR
12674 -static void dont_panic (amb_dev * dev) {
12675 -  amb_cq * cq = &dev->cq;
12676 -  volatile amb_cq_ptrs * ptrs = &cq->ptrs;
12677 -  amb_txq * txq;
12678 -  amb_rxq * rxq;
12679 -  command * cmd;
12680 -  tx_in * tx;
12681 -  tx_simple * tx_descr;
12682 -  unsigned char pool;
12683 -  rx_in * rx;
12684 -  
12685 -  unsigned long flags;
12686 -  save_flags (flags);
12687 -  cli();
12688 -  
12689 -  PRINTK (KERN_INFO, "don't panic - putting adapter into reset");
12690 -  wr_plain (dev, offsetof(amb_mem, reset_control),
12691 -           rd_plain (dev, offsetof(amb_mem, reset_control)) | AMB_RESET_BITS);
12692 -  
12693 -  PRINTK (KERN_INFO, "marking all commands complete");
12694 -  for (cmd = ptrs->start; cmd < ptrs->limit; ++cmd)
12695 -    cmd->request = cpu_to_be32 (SRB_COMPLETE);
12696 -
12697 -  PRINTK (KERN_INFO, "completing all TXs");
12698 -  txq = &dev->txq;
12699 -  tx = txq->in.ptr;
12700 -  while (txq->pending--) {
12701 -    if (tx == txq->in.start)
12702 -      tx = txq->in.limit;
12703 -    --tx;
12704 -    tx_descr = bus_to_virt (be32_to_cpu (tx->tx_descr_addr));
12705 -    amb_kfree_skb (tx_descr->skb);
12706 -    kfree (tx_descr);
12707 -  }
12708 -  
12709 -  PRINTK (KERN_INFO, "freeing all RX buffers");
12710 -  for (pool = 0; pool < NUM_RX_POOLS; ++pool) {
12711 -    rxq = &dev->rxq[pool];
12712 -    rx = rxq->in.ptr;
12713 -    while (rxq->pending--) {
12714 -      if (rx == rxq->in.start)
12715 -       rx = rxq->in.limit;
12716 -      --rx;
12717 -      dev_kfree_skb_any (bus_to_virt (rx->handle));
12718 -    }
12719 -  }
12720 -  
12721 -  PRINTK (KERN_INFO, "don't panic over - close all VCs and rmmod");
12722 -  set_bit (dead, &dev->flags);
12723 -  restore_flags (flags);
12724 -  return;
12725 -}
12726 -#endif
12727 -
12728  /********** make rate (not quite as much fun as Horizon) **********/
12729  
12730  static unsigned int make_rate (unsigned int rate, rounding r,
12731 @@ -1420,32 +1364,6 @@
12732    return;
12733  }
12734  
12735 -/********** Debug\17Ioctl **********/
12736 -
12737 -#if 0
12738 -static int amb_ioctl (struct atm_dev * dev, unsigned int cmd, void * arg) {
12739 -  unsigned short newdebug;
12740 -  if (cmd == AMB_SETDEBUG) {
12741 -    if (!capable(CAP_NET_ADMIN))
12742 -      return -EPERM;
12743 -    if (copy_from_user (&newdebug, arg, sizeof(newdebug))) {
12744 -      // moan
12745 -      return -EFAULT;
12746 -    } else {
12747 -      debug = newdebug;
12748 -      return 0;
12749 -    }
12750 -  } else if (cmd == AMB_DONTPANIC) {
12751 -    if (!capable(CAP_NET_ADMIN))
12752 -      return -EPERM;
12753 -    dont_panic (dev);
12754 -  } else {
12755 -    // moan
12756 -    return -ENOIOCTLCMD;
12757 -  }
12758 -}
12759 -#endif
12760 -
12761  /********** Set socket options for a VC **********/
12762  
12763  // int amb_getsockopt (struct atm_vcc * atm_vcc, int level, int optname, void * optval, int optlen);
12764 @@ -1524,33 +1442,6 @@
12765    tx.tx_descr_length = cpu_to_be16 (sizeof(tx_frag)+sizeof(tx_frag_end));
12766    tx.tx_descr_addr = cpu_to_be32 (virt_to_bus (&tx_descr->tx_frag));
12767    
12768 -#ifdef DEBUG_AMBASSADOR
12769 -  /* wey-hey! */
12770 -  if (vc == 1023) {
12771 -    unsigned int i;
12772 -    unsigned short d = 0;
12773 -    char * s = skb->data;
12774 -    switch (*s++) {
12775 -      case 'D': {
12776 -       for (i = 0; i < 4; ++i) {
12777 -         d = (d<<4) | ((*s <= '9') ? (*s - '0') : (*s - 'a' + 10));
12778 -         ++s;
12779 -       }
12780 -       PRINTK (KERN_INFO, "debug bitmap is now %hx", debug = d);
12781 -       break;
12782 -      }
12783 -      case 'R': {
12784 -       if (*s++ == 'e' && *s++ == 's' && *s++ == 'e' && *s++ == 't')
12785 -         dont_panic (dev);
12786 -       break;
12787 -      }
12788 -      default: {
12789 -       break;
12790 -      }
12791 -    }
12792 -  }
12793 -#endif
12794 -  
12795    while (tx_give (dev, &tx))
12796      schedule();
12797    return 0;
12798 @@ -1663,21 +1554,14 @@
12799  /********** Operation Structure **********/
12800  
12801  static const struct atmdev_ops amb_ops = {
12802 -  .open        = amb_open,
12803 +  .open         = amb_open,
12804    .close       = amb_close,
12805 -  .send        = amb_send,
12806 +  .send         = amb_send,
12807    .proc_read   = amb_proc_read,
12808    .owner       = THIS_MODULE,
12809  };
12810  
12811  /********** housekeeping **********/
12812 -
12813 -static inline void set_timer (struct timer_list * timer, unsigned long delay) {
12814 -  timer->expires = jiffies + delay;
12815 -  add_timer (timer);
12816 -  return;
12817 -}
12818 -
12819  static void do_housekeeping (unsigned long arg) {
12820    amb_dev * dev = amb_devs;
12821    // data is set to zero at module unload
12822 @@ -1693,7 +1577,7 @@
12823        
12824        dev = dev->prev;
12825      }
12826 -    set_timer (&housekeeping, 10*HZ);
12827 +    mod_timer(&housekeeping, jiffies + 10*HZ);
12828    }
12829    
12830    return;
12831 @@ -2579,11 +2463,7 @@
12832    devs = amb_probe();
12833    
12834    if (devs) {
12835 -    init_timer (&housekeeping);
12836 -    housekeeping.function = do_housekeeping;
12837 -    // paranoia
12838 -    housekeeping.data = 1;
12839 -    set_timer (&housekeeping, 0);
12840 +    mod_timer (&housekeeping, jiffies);
12841    } else {
12842      PRINTK (KERN_INFO, "no (usable) adapters found");
12843    }
12844 @@ -2600,7 +2480,7 @@
12845    
12846    // paranoia
12847    housekeeping.data = 0;
12848 -  del_timer (&housekeeping);
12849 +  del_timer_sync(&housekeeping);
12850    
12851    while (amb_devs) {
12852      dev = amb_devs;
12853 diff -Nru a/drivers/atm/eni.c b/drivers/atm/eni.c
12854 --- a/drivers/atm/eni.c Tue Aug 19 21:10:45 2003
12855 +++ b/drivers/atm/eni.c Mon Sep  1 08:23:55 2003
12856 @@ -1809,10 +1809,6 @@
12857                     "master (0x%02x)\n",dev->number,error);
12858                 return error;
12859         }
12860 -#ifdef __sparc_v9__ /* copied from drivers/net/sunhme.c */
12861 -       /* NOTE: Cache line size is in 32-bit word units. */
12862 -       pci_write_config_byte(eni_dev->pci_dev, PCI_CACHE_LINE_SIZE, 0x10);
12863 -#endif
12864         if ((error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,
12865             END_SWAP_DMA))) {
12866                 printk(KERN_ERR DEV_LABEL "(itf %d): can't set endian swap "
12867 @@ -2345,7 +2341,7 @@
12868         struct sk_buff *skb; /* dummy for sizeof */
12869  
12870         if (sizeof(skb->cb) < sizeof(struct eni_skb_prv)) {
12871 -               printk(KERN_ERR "eni_detect: skb->cb is too small (%d < %d)\n",
12872 +               printk(KERN_ERR "eni_detect: skb->cb is too small (%Zd < %Zd)\n",
12873                     sizeof(skb->cb),sizeof(struct eni_skb_prv));
12874                 return -EIO;
12875         }
12876 diff -Nru a/drivers/atm/firestream.c b/drivers/atm/firestream.c
12877 --- a/drivers/atm/firestream.c  Tue Aug 19 21:10:45 2003
12878 +++ b/drivers/atm/firestream.c  Sun Aug 31 16:14:27 2003
12879 @@ -895,7 +895,7 @@
12880         /* XXX handle qos parameters (rate limiting) ? */
12881  
12882         vcc = kmalloc(sizeof(struct fs_vcc), GFP_KERNEL);
12883 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc VCC: %p(%d)\n", vcc, sizeof(struct fs_vcc));
12884 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc VCC: %p(%Zd)\n", vcc, sizeof(struct fs_vcc));
12885         if (!vcc) {
12886                 clear_bit(ATM_VF_ADDR, &atm_vcc->flags);
12887                 return -ENOMEM;
12888 @@ -946,7 +946,7 @@
12889  
12890         if (DO_DIRECTION (txtp)) {
12891                 tc = kmalloc (sizeof (struct fs_transmit_config), GFP_KERNEL);
12892 -               fs_dprintk (FS_DEBUG_ALLOC, "Alloc tc: %p(%d)\n", 
12893 +               fs_dprintk (FS_DEBUG_ALLOC, "Alloc tc: %p(%Zd)\n",
12894                             tc, sizeof (struct fs_transmit_config));
12895                 if (!tc) {
12896                         fs_dprintk (FS_DEBUG_OPEN, "fs: can't alloc transmit_config.\n");
12897 @@ -1180,7 +1180,7 @@
12898         vcc->last_skb = skb;
12899  
12900         td = kmalloc (sizeof (struct FS_BPENTRY), GFP_ATOMIC);
12901 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc transd: %p(%d)\n", td, sizeof (struct FS_BPENTRY));
12902 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc transd: %p(%Zd)\n", td, sizeof (struct FS_BPENTRY));
12903         if (!td) {
12904                 /* Oops out of mem */
12905                 return -ENOMEM;
12906 @@ -1487,7 +1487,7 @@
12907                 fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-skb: %p(%d)\n", skb, fp->bufsize);
12908                 if (!skb) break;
12909                 ne = kmalloc (sizeof (struct FS_BPENTRY), gfp_flags);
12910 -               fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-d: %p(%d)\n", ne, sizeof (struct FS_BPENTRY));
12911 +               fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-d: %p(%Zd)\n", ne, sizeof (struct FS_BPENTRY));
12912                 if (!ne) {
12913                         fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p\n", skb);
12914                         dev_kfree_skb_any (skb);
12915 @@ -1792,7 +1792,7 @@
12916         }
12917         dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *), 
12918                                  GFP_KERNEL);
12919 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%d)\n", 
12920 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
12921                     dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
12922  
12923         if (!dev->atm_vccs) {
12924 @@ -1900,7 +1900,7 @@
12925                 goto err_out;
12926  
12927         fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
12928 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%d)\n", 
12929 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
12930                     fs_dev, sizeof (struct fs_dev));
12931         if (!fs_dev)
12932                 goto err_out;
12933 diff -Nru a/drivers/block/DAC960.c b/drivers/block/DAC960.c
12934 --- a/drivers/block/DAC960.c    Fri Aug 15 09:39:48 2003
12935 +++ b/drivers/block/DAC960.c    Sun Aug 31 16:13:56 2003
12936 @@ -23,6 +23,7 @@
12937  #include <linux/version.h>
12938  #include <linux/module.h>
12939  #include <linux/types.h>
12940 +#include <linux/miscdevice.h>
12941  #include <linux/blkdev.h>
12942  #include <linux/bio.h>
12943  #include <linux/completion.h>
12944 @@ -44,6 +45,8 @@
12945  #include <asm/uaccess.h>
12946  #include "DAC960.h"
12947  
12948 +#define DAC960_GAM_MINOR       252
12949 +
12950  
12951  static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers];
12952  static int DAC960_ControllerCount;
12953 @@ -71,10 +74,6 @@
12954         DAC960_Controller_T *p = disk->queue->queuedata;
12955         int drive_nr = (int)disk->private_data;
12956  
12957 -       /* bad hack for the "user" ioctls */
12958 -       if (!p->ControllerNumber && !drive_nr && (file->f_flags & O_NONBLOCK))
12959 -               return 0;
12960 -
12961         if (p->FirmwareType == DAC960_V1_Controller) {
12962                 if (p->V1.LogicalDriveInformation[drive_nr].
12963                     LogicalDriveState == DAC960_V1_LogicalDrive_Offline)
12964 @@ -101,9 +100,6 @@
12965         int drive_nr = (int)disk->private_data;
12966         struct hd_geometry g, *loc = (struct hd_geometry *)arg;
12967  
12968 -       if (file && (file->f_flags & O_NONBLOCK))
12969 -               return DAC960_UserIOCTL(inode, file, cmd, arg);
12970 -
12971         if (cmd != HDIO_GETGEO || !loc)
12972                 return -EINVAL;
12973  
12974 @@ -5569,407 +5565,6 @@
12975  }
12976  
12977  /*
12978 -  DAC960_UserIOCTL is the User IOCTL Function for the DAC960 Driver.
12979 -*/
12980 -
12981 -static int DAC960_UserIOCTL(struct inode *inode, struct file *file,
12982 -                           unsigned int Request, unsigned long Argument)
12983 -{
12984 -  int ErrorCode = 0;
12985 -  if (!capable(CAP_SYS_ADMIN)) return -EACCES;
12986 -  switch (Request)
12987 -    {
12988 -    case DAC960_IOCTL_GET_CONTROLLER_COUNT:
12989 -      return DAC960_ControllerCount;
12990 -    case DAC960_IOCTL_GET_CONTROLLER_INFO:
12991 -      {
12992 -       DAC960_ControllerInfo_T *UserSpaceControllerInfo =
12993 -         (DAC960_ControllerInfo_T *) Argument;
12994 -       DAC960_ControllerInfo_T ControllerInfo;
12995 -       DAC960_Controller_T *Controller;
12996 -       int ControllerNumber;
12997 -       if (UserSpaceControllerInfo == NULL) return -EINVAL;
12998 -       ErrorCode = get_user(ControllerNumber,
12999 -                            &UserSpaceControllerInfo->ControllerNumber);
13000 -       if (ErrorCode != 0) return ErrorCode;
13001 -       if (ControllerNumber < 0 ||
13002 -           ControllerNumber > DAC960_ControllerCount - 1)
13003 -         return -ENXIO;
13004 -       Controller = DAC960_Controllers[ControllerNumber];
13005 -       if (Controller == NULL) return -ENXIO;
13006 -       memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
13007 -       ControllerInfo.ControllerNumber = ControllerNumber;
13008 -       ControllerInfo.FirmwareType = Controller->FirmwareType;
13009 -       ControllerInfo.Channels = Controller->Channels;
13010 -       ControllerInfo.Targets = Controller->Targets;
13011 -       ControllerInfo.PCI_Bus = Controller->Bus;
13012 -       ControllerInfo.PCI_Device = Controller->Device;
13013 -       ControllerInfo.PCI_Function = Controller->Function;
13014 -       ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
13015 -       ControllerInfo.PCI_Address = Controller->PCI_Address;
13016 -       strcpy(ControllerInfo.ModelName, Controller->ModelName);
13017 -       strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
13018 -       return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
13019 -                            sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
13020 -      }
13021 -    case DAC960_IOCTL_V1_EXECUTE_COMMAND:
13022 -      {
13023 -       DAC960_V1_UserCommand_T *UserSpaceUserCommand =
13024 -         (DAC960_V1_UserCommand_T *) Argument;
13025 -       DAC960_V1_UserCommand_T UserCommand;
13026 -       DAC960_Controller_T *Controller;
13027 -       DAC960_Command_T *Command = NULL;
13028 -       DAC960_V1_CommandOpcode_T CommandOpcode;
13029 -       DAC960_V1_CommandStatus_T CommandStatus;
13030 -       DAC960_V1_DCDB_T DCDB;
13031 -       DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
13032 -       dma_addr_t      DCDB_IOBUFDMA;
13033 -       unsigned long flags;
13034 -       int ControllerNumber, DataTransferLength;
13035 -       unsigned char *DataTransferBuffer = NULL;
13036 -       dma_addr_t DataTransferBufferDMA;
13037 -       if (UserSpaceUserCommand == NULL) return -EINVAL;
13038 -       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
13039 -                                  sizeof(DAC960_V1_UserCommand_T))) {
13040 -               ErrorCode = -EFAULT;
13041 -               goto Failure1a;
13042 -       }
13043 -       ControllerNumber = UserCommand.ControllerNumber;
13044 -       if (ControllerNumber < 0 ||
13045 -           ControllerNumber > DAC960_ControllerCount - 1)
13046 -         return -ENXIO;
13047 -       Controller = DAC960_Controllers[ControllerNumber];
13048 -       if (Controller == NULL) return -ENXIO;
13049 -       if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
13050 -       CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
13051 -       DataTransferLength = UserCommand.DataTransferLength;
13052 -       if (CommandOpcode & 0x80) return -EINVAL;
13053 -       if (CommandOpcode == DAC960_V1_DCDB)
13054 -         {
13055 -           if (copy_from_user(&DCDB, UserCommand.DCDB,
13056 -                              sizeof(DAC960_V1_DCDB_T))) {
13057 -               ErrorCode = -EFAULT;
13058 -               goto Failure1a;
13059 -           }
13060 -           if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
13061 -           if (!((DataTransferLength == 0 &&
13062 -                  DCDB.Direction
13063 -                  == DAC960_V1_DCDB_NoDataTransfer) ||
13064 -                 (DataTransferLength > 0 &&
13065 -                  DCDB.Direction
13066 -                  == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
13067 -                 (DataTransferLength < 0 &&
13068 -                  DCDB.Direction
13069 -                  == DAC960_V1_DCDB_DataTransferSystemToDevice)))
13070 -             return -EINVAL;
13071 -           if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
13072 -               != abs(DataTransferLength))
13073 -             return -EINVAL;
13074 -           DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
13075 -                       sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
13076 -           if (DCDB_IOBUF == NULL)
13077 -                       return -ENOMEM;
13078 -         }
13079 -       if (DataTransferLength > 0)
13080 -         {
13081 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13082 -                               DataTransferLength, &DataTransferBufferDMA);
13083 -           if (DataTransferBuffer == NULL) {
13084 -               ErrorCode = -ENOMEM;
13085 -               goto Failure1;
13086 -           }
13087 -           memset(DataTransferBuffer, 0, DataTransferLength);
13088 -         }
13089 -       else if (DataTransferLength < 0)
13090 -         {
13091 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13092 -                               -DataTransferLength, &DataTransferBufferDMA);
13093 -           if (DataTransferBuffer == NULL) {
13094 -               ErrorCode = -ENOMEM;
13095 -               goto Failure1;
13096 -           }
13097 -           if (copy_from_user(DataTransferBuffer,
13098 -                              UserCommand.DataTransferBuffer,
13099 -                              -DataTransferLength)) {
13100 -               ErrorCode = -EFAULT;
13101 -               goto Failure1;
13102 -           }
13103 -         }
13104 -       if (CommandOpcode == DAC960_V1_DCDB)
13105 -         {
13106 -           spin_lock_irqsave(&Controller->queue_lock, flags);
13107 -           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13108 -             DAC960_WaitForCommand(Controller);
13109 -           while (Controller->V1.DirectCommandActive[DCDB.Channel]
13110 -                                                    [DCDB.TargetID])
13111 -             {
13112 -               spin_unlock_irq(&Controller->queue_lock);
13113 -               __wait_event(Controller->CommandWaitQueue,
13114 -                            !Controller->V1.DirectCommandActive
13115 -                                            [DCDB.Channel][DCDB.TargetID]);
13116 -               spin_lock_irq(&Controller->queue_lock);
13117 -             }
13118 -           Controller->V1.DirectCommandActive[DCDB.Channel]
13119 -                                             [DCDB.TargetID] = true;
13120 -           spin_unlock_irqrestore(&Controller->queue_lock, flags);
13121 -           DAC960_V1_ClearCommand(Command);
13122 -           Command->CommandType = DAC960_ImmediateCommand;
13123 -           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
13124 -                  sizeof(DAC960_V1_CommandMailbox_T));
13125 -           Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
13126 -           DCDB.BusAddress = DataTransferBufferDMA;
13127 -           memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
13128 -         }
13129 -       else
13130 -         {
13131 -           spin_lock_irqsave(&Controller->queue_lock, flags);
13132 -           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13133 -             DAC960_WaitForCommand(Controller);
13134 -           spin_unlock_irqrestore(&Controller->queue_lock, flags);
13135 -           DAC960_V1_ClearCommand(Command);
13136 -           Command->CommandType = DAC960_ImmediateCommand;
13137 -           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
13138 -                  sizeof(DAC960_V1_CommandMailbox_T));
13139 -           if (DataTransferBuffer != NULL)
13140 -             Command->V1.CommandMailbox.Type3.BusAddress =
13141 -               DataTransferBufferDMA;
13142 -         }
13143 -       DAC960_ExecuteCommand(Command);
13144 -       CommandStatus = Command->V1.CommandStatus;
13145 -       spin_lock_irqsave(&Controller->queue_lock, flags);
13146 -       DAC960_DeallocateCommand(Command);
13147 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13148 -       if (DataTransferLength > 0)
13149 -         {
13150 -           if (copy_to_user(UserCommand.DataTransferBuffer,
13151 -                            DataTransferBuffer, DataTransferLength)) {
13152 -               ErrorCode = -EFAULT;
13153 -               goto Failure1;
13154 -            }
13155 -         }
13156 -       if (CommandOpcode == DAC960_V1_DCDB)
13157 -         {
13158 -           /*
13159 -             I don't believe Target or Channel in the DCDB_IOBUF
13160 -             should be any different from the contents of DCDB.
13161 -            */
13162 -           Controller->V1.DirectCommandActive[DCDB.Channel]
13163 -                                             [DCDB.TargetID] = false;
13164 -           if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
13165 -                            sizeof(DAC960_V1_DCDB_T))) {
13166 -               ErrorCode = -EFAULT;
13167 -               goto Failure1;
13168 -           }
13169 -         }
13170 -       ErrorCode = CommandStatus;
13171 -      Failure1:
13172 -       if (DataTransferBuffer != NULL)
13173 -         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
13174 -                       DataTransferBuffer, DataTransferBufferDMA);
13175 -       if (DCDB_IOBUF != NULL)
13176 -         pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
13177 -                       DCDB_IOBUF, DCDB_IOBUFDMA);
13178 -      Failure1a:
13179 -       return ErrorCode;
13180 -      }
13181 -    case DAC960_IOCTL_V2_EXECUTE_COMMAND:
13182 -      {
13183 -       DAC960_V2_UserCommand_T *UserSpaceUserCommand =
13184 -         (DAC960_V2_UserCommand_T *) Argument;
13185 -       DAC960_V2_UserCommand_T UserCommand;
13186 -       DAC960_Controller_T *Controller;
13187 -       DAC960_Command_T *Command = NULL;
13188 -       DAC960_V2_CommandMailbox_T *CommandMailbox;
13189 -       DAC960_V2_CommandStatus_T CommandStatus;
13190 -       unsigned long flags;
13191 -       int ControllerNumber, DataTransferLength;
13192 -       int DataTransferResidue, RequestSenseLength;
13193 -       unsigned char *DataTransferBuffer = NULL;
13194 -       dma_addr_t DataTransferBufferDMA;
13195 -       unsigned char *RequestSenseBuffer = NULL;
13196 -       dma_addr_t RequestSenseBufferDMA;
13197 -       if (UserSpaceUserCommand == NULL) return -EINVAL;
13198 -       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
13199 -                          sizeof(DAC960_V2_UserCommand_T))) {
13200 -               ErrorCode = -EFAULT;
13201 -               goto Failure2a;
13202 -       }
13203 -       ControllerNumber = UserCommand.ControllerNumber;
13204 -       if (ControllerNumber < 0 ||
13205 -           ControllerNumber > DAC960_ControllerCount - 1)
13206 -         return -ENXIO;
13207 -       Controller = DAC960_Controllers[ControllerNumber];
13208 -       if (Controller == NULL) return -ENXIO;
13209 -       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
13210 -       DataTransferLength = UserCommand.DataTransferLength;
13211 -       if (DataTransferLength > 0)
13212 -         {
13213 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13214 -                               DataTransferLength, &DataTransferBufferDMA);
13215 -           if (DataTransferBuffer == NULL) return -ENOMEM;
13216 -           memset(DataTransferBuffer, 0, DataTransferLength);
13217 -         }
13218 -       else if (DataTransferLength < 0)
13219 -         {
13220 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13221 -                               -DataTransferLength, &DataTransferBufferDMA);
13222 -           if (DataTransferBuffer == NULL) return -ENOMEM;
13223 -           if (copy_from_user(DataTransferBuffer,
13224 -                              UserCommand.DataTransferBuffer,
13225 -                              -DataTransferLength)) {
13226 -               ErrorCode = -EFAULT;
13227 -               goto Failure2;
13228 -           }
13229 -         }
13230 -       RequestSenseLength = UserCommand.RequestSenseLength;
13231 -       if (RequestSenseLength > 0)
13232 -         {
13233 -           RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
13234 -                       RequestSenseLength, &RequestSenseBufferDMA);
13235 -           if (RequestSenseBuffer == NULL)
13236 -             {
13237 -               ErrorCode = -ENOMEM;
13238 -               goto Failure2;
13239 -             }
13240 -           memset(RequestSenseBuffer, 0, RequestSenseLength);
13241 -         }
13242 -       spin_lock_irqsave(&Controller->queue_lock, flags);
13243 -       while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13244 -         DAC960_WaitForCommand(Controller);
13245 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13246 -       DAC960_V2_ClearCommand(Command);
13247 -       Command->CommandType = DAC960_ImmediateCommand;
13248 -       CommandMailbox = &Command->V2.CommandMailbox;
13249 -       memcpy(CommandMailbox, &UserCommand.CommandMailbox,
13250 -              sizeof(DAC960_V2_CommandMailbox_T));
13251 -       CommandMailbox->Common.CommandControlBits
13252 -                             .AdditionalScatterGatherListMemory = false;
13253 -       CommandMailbox->Common.CommandControlBits
13254 -                             .NoAutoRequestSense = true;
13255 -       CommandMailbox->Common.DataTransferSize = 0;
13256 -       CommandMailbox->Common.DataTransferPageNumber = 0;
13257 -       memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
13258 -              sizeof(DAC960_V2_DataTransferMemoryAddress_T));
13259 -       if (DataTransferLength != 0)
13260 -         {
13261 -           if (DataTransferLength > 0)
13262 -             {
13263 -               CommandMailbox->Common.CommandControlBits
13264 -                                     .DataTransferControllerToHost = true;
13265 -               CommandMailbox->Common.DataTransferSize = DataTransferLength;
13266 -             }
13267 -           else
13268 -             {
13269 -               CommandMailbox->Common.CommandControlBits
13270 -                                     .DataTransferControllerToHost = false;
13271 -               CommandMailbox->Common.DataTransferSize = -DataTransferLength;
13272 -             }
13273 -           CommandMailbox->Common.DataTransferMemoryAddress
13274 -                                 .ScatterGatherSegments[0]
13275 -                                 .SegmentDataPointer = DataTransferBufferDMA;
13276 -           CommandMailbox->Common.DataTransferMemoryAddress
13277 -                                 .ScatterGatherSegments[0]
13278 -                                 .SegmentByteCount =
13279 -             CommandMailbox->Common.DataTransferSize;
13280 -         }
13281 -       if (RequestSenseLength > 0)
13282 -         {
13283 -           CommandMailbox->Common.CommandControlBits
13284 -                                 .NoAutoRequestSense = false;
13285 -           CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
13286 -           CommandMailbox->Common.RequestSenseBusAddress =
13287 -                                                       RequestSenseBufferDMA;
13288 -         }
13289 -       DAC960_ExecuteCommand(Command);
13290 -       CommandStatus = Command->V2.CommandStatus;
13291 -       RequestSenseLength = Command->V2.RequestSenseLength;
13292 -       DataTransferResidue = Command->V2.DataTransferResidue;
13293 -       spin_lock_irqsave(&Controller->queue_lock, flags);
13294 -       DAC960_DeallocateCommand(Command);
13295 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13296 -       if (RequestSenseLength > UserCommand.RequestSenseLength)
13297 -         RequestSenseLength = UserCommand.RequestSenseLength;
13298 -       if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
13299 -                                &DataTransferResidue,
13300 -                                sizeof(DataTransferResidue))) {
13301 -               ErrorCode = -EFAULT;
13302 -               goto Failure2;
13303 -       }
13304 -       if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
13305 -                        &RequestSenseLength, sizeof(RequestSenseLength))) {
13306 -               ErrorCode = -EFAULT;
13307 -               goto Failure2;
13308 -       }
13309 -       if (DataTransferLength > 0)
13310 -         {
13311 -           if (copy_to_user(UserCommand.DataTransferBuffer,
13312 -                            DataTransferBuffer, DataTransferLength)) {
13313 -               ErrorCode = -EFAULT;
13314 -               goto Failure2;
13315 -           }
13316 -         }
13317 -       if (RequestSenseLength > 0)
13318 -         {
13319 -           if (copy_to_user(UserCommand.RequestSenseBuffer,
13320 -                            RequestSenseBuffer, RequestSenseLength)) {
13321 -               ErrorCode = -EFAULT;
13322 -               goto Failure2;
13323 -           }
13324 -         }
13325 -       ErrorCode = CommandStatus;
13326 -      Failure2:
13327 -         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
13328 -               DataTransferBuffer, DataTransferBufferDMA);
13329 -       if (RequestSenseBuffer != NULL)
13330 -         pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
13331 -               RequestSenseBuffer, RequestSenseBufferDMA);
13332 -      Failure2a:
13333 -       return ErrorCode;
13334 -      }
13335 -    case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
13336 -      {
13337 -       DAC960_V2_GetHealthStatus_T *UserSpaceGetHealthStatus =
13338 -         (DAC960_V2_GetHealthStatus_T *) Argument;
13339 -       DAC960_V2_GetHealthStatus_T GetHealthStatus;
13340 -       DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
13341 -       DAC960_Controller_T *Controller;
13342 -       int ControllerNumber;
13343 -       if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
13344 -       if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
13345 -                          sizeof(DAC960_V2_GetHealthStatus_T)))
13346 -               return -EFAULT;
13347 -       ControllerNumber = GetHealthStatus.ControllerNumber;
13348 -       if (ControllerNumber < 0 ||
13349 -           ControllerNumber > DAC960_ControllerCount - 1)
13350 -         return -ENXIO;
13351 -       Controller = DAC960_Controllers[ControllerNumber];
13352 -       if (Controller == NULL) return -ENXIO;
13353 -       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
13354 -       if (copy_from_user(&HealthStatusBuffer,
13355 -                          GetHealthStatus.HealthStatusBuffer,
13356 -                          sizeof(DAC960_V2_HealthStatusBuffer_T)))
13357 -               return -EFAULT;
13358 -       while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
13359 -              == HealthStatusBuffer.StatusChangeCounter &&
13360 -              Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
13361 -              == HealthStatusBuffer.NextEventSequenceNumber)
13362 -         {
13363 -           interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
13364 -                                          DAC960_MonitoringTimerInterval);
13365 -           if (signal_pending(current)) return -EINTR;
13366 -         }
13367 -       if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
13368 -                        Controller->V2.HealthStatusBuffer,
13369 -                        sizeof(DAC960_V2_HealthStatusBuffer_T)))
13370 -               return -EFAULT;
13371 -       return 0;
13372 -      }
13373 -    }
13374 -  return -EINVAL;
13375 -}
13376 -
13377 -
13378 -/*
13379    DAC960_CheckStatusBuffer verifies that there is room to hold ByteCount
13380    additional bytes in the Combined Status Buffer and grows the buffer if
13381    necessary.  It returns true if there is enough room and false otherwise.
13382 @@ -6901,6 +6496,436 @@
13383        Controller->ControllerProcEntry = NULL;
13384  }
13385  
13386 +#ifdef DAC960_GAM_MINOR
13387 +
13388 +/*
13389 + * DAC960_gam_ioctl is the ioctl function for performing RAID operations.
13390 +*/
13391 +
13392 +static int DAC960_gam_ioctl(struct inode *inode, struct file *file,
13393 +                           unsigned int Request, unsigned long Argument)
13394 +{
13395 +  int ErrorCode = 0;
13396 +  if (!capable(CAP_SYS_ADMIN)) return -EACCES;
13397 +  switch (Request)
13398 +    {
13399 +    case DAC960_IOCTL_GET_CONTROLLER_COUNT:
13400 +      return DAC960_ControllerCount;
13401 +    case DAC960_IOCTL_GET_CONTROLLER_INFO:
13402 +      {
13403 +       DAC960_ControllerInfo_T *UserSpaceControllerInfo =
13404 +         (DAC960_ControllerInfo_T *) Argument;
13405 +       DAC960_ControllerInfo_T ControllerInfo;
13406 +       DAC960_Controller_T *Controller;
13407 +       int ControllerNumber;
13408 +       if (UserSpaceControllerInfo == NULL) return -EINVAL;
13409 +       ErrorCode = get_user(ControllerNumber,
13410 +                            &UserSpaceControllerInfo->ControllerNumber);
13411 +       if (ErrorCode != 0) return ErrorCode;
13412 +       if (ControllerNumber < 0 ||
13413 +           ControllerNumber > DAC960_ControllerCount - 1)
13414 +         return -ENXIO;
13415 +       Controller = DAC960_Controllers[ControllerNumber];
13416 +       if (Controller == NULL) return -ENXIO;
13417 +       memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
13418 +       ControllerInfo.ControllerNumber = ControllerNumber;
13419 +       ControllerInfo.FirmwareType = Controller->FirmwareType;
13420 +       ControllerInfo.Channels = Controller->Channels;
13421 +       ControllerInfo.Targets = Controller->Targets;
13422 +       ControllerInfo.PCI_Bus = Controller->Bus;
13423 +       ControllerInfo.PCI_Device = Controller->Device;
13424 +       ControllerInfo.PCI_Function = Controller->Function;
13425 +       ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
13426 +       ControllerInfo.PCI_Address = Controller->PCI_Address;
13427 +       strcpy(ControllerInfo.ModelName, Controller->ModelName);
13428 +       strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
13429 +       return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
13430 +                            sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
13431 +      }
13432 +    case DAC960_IOCTL_V1_EXECUTE_COMMAND:
13433 +      {
13434 +       DAC960_V1_UserCommand_T *UserSpaceUserCommand =
13435 +         (DAC960_V1_UserCommand_T *) Argument;
13436 +       DAC960_V1_UserCommand_T UserCommand;
13437 +       DAC960_Controller_T *Controller;
13438 +       DAC960_Command_T *Command = NULL;
13439 +       DAC960_V1_CommandOpcode_T CommandOpcode;
13440 +       DAC960_V1_CommandStatus_T CommandStatus;
13441 +       DAC960_V1_DCDB_T DCDB;
13442 +       DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
13443 +       dma_addr_t      DCDB_IOBUFDMA;
13444 +       unsigned long flags;
13445 +       int ControllerNumber, DataTransferLength;
13446 +       unsigned char *DataTransferBuffer = NULL;
13447 +       dma_addr_t DataTransferBufferDMA;
13448 +       if (UserSpaceUserCommand == NULL) return -EINVAL;
13449 +       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
13450 +                                  sizeof(DAC960_V1_UserCommand_T))) {
13451 +               ErrorCode = -EFAULT;
13452 +               goto Failure1a;
13453 +       }
13454 +       ControllerNumber = UserCommand.ControllerNumber;
13455 +       if (ControllerNumber < 0 ||
13456 +           ControllerNumber > DAC960_ControllerCount - 1)
13457 +         return -ENXIO;
13458 +       Controller = DAC960_Controllers[ControllerNumber];
13459 +       if (Controller == NULL) return -ENXIO;
13460 +       if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
13461 +       CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
13462 +       DataTransferLength = UserCommand.DataTransferLength;
13463 +       if (CommandOpcode & 0x80) return -EINVAL;
13464 +       if (CommandOpcode == DAC960_V1_DCDB)
13465 +         {
13466 +           if (copy_from_user(&DCDB, UserCommand.DCDB,
13467 +                              sizeof(DAC960_V1_DCDB_T))) {
13468 +               ErrorCode = -EFAULT;
13469 +               goto Failure1a;
13470 +           }
13471 +           if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
13472 +           if (!((DataTransferLength == 0 &&
13473 +                  DCDB.Direction
13474 +                  == DAC960_V1_DCDB_NoDataTransfer) ||
13475 +                 (DataTransferLength > 0 &&
13476 +                  DCDB.Direction
13477 +                  == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
13478 +                 (DataTransferLength < 0 &&
13479 +                  DCDB.Direction
13480 +                  == DAC960_V1_DCDB_DataTransferSystemToDevice)))
13481 +             return -EINVAL;
13482 +           if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
13483 +               != abs(DataTransferLength))
13484 +             return -EINVAL;
13485 +           DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
13486 +                       sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
13487 +           if (DCDB_IOBUF == NULL)
13488 +                       return -ENOMEM;
13489 +         }
13490 +       if (DataTransferLength > 0)
13491 +         {
13492 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13493 +                               DataTransferLength, &DataTransferBufferDMA);
13494 +           if (DataTransferBuffer == NULL) {
13495 +               ErrorCode = -ENOMEM;
13496 +               goto Failure1;
13497 +           }
13498 +           memset(DataTransferBuffer, 0, DataTransferLength);
13499 +         }
13500 +       else if (DataTransferLength < 0)
13501 +         {
13502 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13503 +                               -DataTransferLength, &DataTransferBufferDMA);
13504 +           if (DataTransferBuffer == NULL) {
13505 +               ErrorCode = -ENOMEM;
13506 +               goto Failure1;
13507 +           }
13508 +           if (copy_from_user(DataTransferBuffer,
13509 +                              UserCommand.DataTransferBuffer,
13510 +                              -DataTransferLength)) {
13511 +               ErrorCode = -EFAULT;
13512 +               goto Failure1;
13513 +           }
13514 +         }
13515 +       if (CommandOpcode == DAC960_V1_DCDB)
13516 +         {
13517 +           spin_lock_irqsave(&Controller->queue_lock, flags);
13518 +           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13519 +             DAC960_WaitForCommand(Controller);
13520 +           while (Controller->V1.DirectCommandActive[DCDB.Channel]
13521 +                                                    [DCDB.TargetID])
13522 +             {
13523 +               spin_unlock_irq(&Controller->queue_lock);
13524 +               __wait_event(Controller->CommandWaitQueue,
13525 +                            !Controller->V1.DirectCommandActive
13526 +                                            [DCDB.Channel][DCDB.TargetID]);
13527 +               spin_lock_irq(&Controller->queue_lock);
13528 +             }
13529 +           Controller->V1.DirectCommandActive[DCDB.Channel]
13530 +                                             [DCDB.TargetID] = true;
13531 +           spin_unlock_irqrestore(&Controller->queue_lock, flags);
13532 +           DAC960_V1_ClearCommand(Command);
13533 +           Command->CommandType = DAC960_ImmediateCommand;
13534 +           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
13535 +                  sizeof(DAC960_V1_CommandMailbox_T));
13536 +           Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
13537 +           DCDB.BusAddress = DataTransferBufferDMA;
13538 +           memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
13539 +         }
13540 +       else
13541 +         {
13542 +           spin_lock_irqsave(&Controller->queue_lock, flags);
13543 +           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13544 +             DAC960_WaitForCommand(Controller);
13545 +           spin_unlock_irqrestore(&Controller->queue_lock, flags);
13546 +           DAC960_V1_ClearCommand(Command);
13547 +           Command->CommandType = DAC960_ImmediateCommand;
13548 +           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
13549 +                  sizeof(DAC960_V1_CommandMailbox_T));
13550 +           if (DataTransferBuffer != NULL)
13551 +             Command->V1.CommandMailbox.Type3.BusAddress =
13552 +               DataTransferBufferDMA;
13553 +         }
13554 +       DAC960_ExecuteCommand(Command);
13555 +       CommandStatus = Command->V1.CommandStatus;
13556 +       spin_lock_irqsave(&Controller->queue_lock, flags);
13557 +       DAC960_DeallocateCommand(Command);
13558 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13559 +       if (DataTransferLength > 0)
13560 +         {
13561 +           if (copy_to_user(UserCommand.DataTransferBuffer,
13562 +                            DataTransferBuffer, DataTransferLength)) {
13563 +               ErrorCode = -EFAULT;
13564 +               goto Failure1;
13565 +            }
13566 +         }
13567 +       if (CommandOpcode == DAC960_V1_DCDB)
13568 +         {
13569 +           /*
13570 +             I don't believe Target or Channel in the DCDB_IOBUF
13571 +             should be any different from the contents of DCDB.
13572 +            */
13573 +           Controller->V1.DirectCommandActive[DCDB.Channel]
13574 +                                             [DCDB.TargetID] = false;
13575 +           if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
13576 +                            sizeof(DAC960_V1_DCDB_T))) {
13577 +               ErrorCode = -EFAULT;
13578 +               goto Failure1;
13579 +           }
13580 +         }
13581 +       ErrorCode = CommandStatus;
13582 +      Failure1:
13583 +       if (DataTransferBuffer != NULL)
13584 +         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
13585 +                       DataTransferBuffer, DataTransferBufferDMA);
13586 +       if (DCDB_IOBUF != NULL)
13587 +         pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
13588 +                       DCDB_IOBUF, DCDB_IOBUFDMA);
13589 +      Failure1a:
13590 +       return ErrorCode;
13591 +      }
13592 +    case DAC960_IOCTL_V2_EXECUTE_COMMAND:
13593 +      {
13594 +       DAC960_V2_UserCommand_T *UserSpaceUserCommand =
13595 +         (DAC960_V2_UserCommand_T *) Argument;
13596 +       DAC960_V2_UserCommand_T UserCommand;
13597 +       DAC960_Controller_T *Controller;
13598 +       DAC960_Command_T *Command = NULL;
13599 +       DAC960_V2_CommandMailbox_T *CommandMailbox;
13600 +       DAC960_V2_CommandStatus_T CommandStatus;
13601 +       unsigned long flags;
13602 +       int ControllerNumber, DataTransferLength;
13603 +       int DataTransferResidue, RequestSenseLength;
13604 +       unsigned char *DataTransferBuffer = NULL;
13605 +       dma_addr_t DataTransferBufferDMA;
13606 +       unsigned char *RequestSenseBuffer = NULL;
13607 +       dma_addr_t RequestSenseBufferDMA;
13608 +       if (UserSpaceUserCommand == NULL) return -EINVAL;
13609 +       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
13610 +                          sizeof(DAC960_V2_UserCommand_T))) {
13611 +               ErrorCode = -EFAULT;
13612 +               goto Failure2a;
13613 +       }
13614 +       ControllerNumber = UserCommand.ControllerNumber;
13615 +       if (ControllerNumber < 0 ||
13616 +           ControllerNumber > DAC960_ControllerCount - 1)
13617 +         return -ENXIO;
13618 +       Controller = DAC960_Controllers[ControllerNumber];
13619 +       if (Controller == NULL) return -ENXIO;
13620 +       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
13621 +       DataTransferLength = UserCommand.DataTransferLength;
13622 +       if (DataTransferLength > 0)
13623 +         {
13624 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13625 +                               DataTransferLength, &DataTransferBufferDMA);
13626 +           if (DataTransferBuffer == NULL) return -ENOMEM;
13627 +           memset(DataTransferBuffer, 0, DataTransferLength);
13628 +         }
13629 +       else if (DataTransferLength < 0)
13630 +         {
13631 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13632 +                               -DataTransferLength, &DataTransferBufferDMA);
13633 +           if (DataTransferBuffer == NULL) return -ENOMEM;
13634 +           if (copy_from_user(DataTransferBuffer,
13635 +                              UserCommand.DataTransferBuffer,
13636 +                              -DataTransferLength)) {
13637 +               ErrorCode = -EFAULT;
13638 +               goto Failure2;
13639 +           }
13640 +         }
13641 +       RequestSenseLength = UserCommand.RequestSenseLength;
13642 +       if (RequestSenseLength > 0)
13643 +         {
13644 +           RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
13645 +                       RequestSenseLength, &RequestSenseBufferDMA);
13646 +           if (RequestSenseBuffer == NULL)
13647 +             {
13648 +               ErrorCode = -ENOMEM;
13649 +               goto Failure2;
13650 +             }
13651 +           memset(RequestSenseBuffer, 0, RequestSenseLength);
13652 +         }
13653 +       spin_lock_irqsave(&Controller->queue_lock, flags);
13654 +       while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13655 +         DAC960_WaitForCommand(Controller);
13656 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13657 +       DAC960_V2_ClearCommand(Command);
13658 +       Command->CommandType = DAC960_ImmediateCommand;
13659 +       CommandMailbox = &Command->V2.CommandMailbox;
13660 +       memcpy(CommandMailbox, &UserCommand.CommandMailbox,
13661 +              sizeof(DAC960_V2_CommandMailbox_T));
13662 +       CommandMailbox->Common.CommandControlBits
13663 +                             .AdditionalScatterGatherListMemory = false;
13664 +       CommandMailbox->Common.CommandControlBits
13665 +                             .NoAutoRequestSense = true;
13666 +       CommandMailbox->Common.DataTransferSize = 0;
13667 +       CommandMailbox->Common.DataTransferPageNumber = 0;
13668 +       memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
13669 +              sizeof(DAC960_V2_DataTransferMemoryAddress_T));
13670 +       if (DataTransferLength != 0)
13671 +         {
13672 +           if (DataTransferLength > 0)
13673 +             {
13674 +               CommandMailbox->Common.CommandControlBits
13675 +                                     .DataTransferControllerToHost = true;
13676 +               CommandMailbox->Common.DataTransferSize = DataTransferLength;
13677 +             }
13678 +           else
13679 +             {
13680 +               CommandMailbox->Common.CommandControlBits
13681 +                                     .DataTransferControllerToHost = false;
13682 +               CommandMailbox->Common.DataTransferSize = -DataTransferLength;
13683 +             }
13684 +           CommandMailbox->Common.DataTransferMemoryAddress
13685 +                                 .ScatterGatherSegments[0]
13686 +                                 .SegmentDataPointer = DataTransferBufferDMA;
13687 +           CommandMailbox->Common.DataTransferMemoryAddress
13688 +                                 .ScatterGatherSegments[0]
13689 +                                 .SegmentByteCount =
13690 +             CommandMailbox->Common.DataTransferSize;
13691 +         }
13692 +       if (RequestSenseLength > 0)
13693 +         {
13694 +           CommandMailbox->Common.CommandControlBits
13695 +                                 .NoAutoRequestSense = false;
13696 +           CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
13697 +           CommandMailbox->Common.RequestSenseBusAddress =
13698 +                                                       RequestSenseBufferDMA;
13699 +         }
13700 +       DAC960_ExecuteCommand(Command);
13701 +       CommandStatus = Command->V2.CommandStatus;
13702 +       RequestSenseLength = Command->V2.RequestSenseLength;
13703 +       DataTransferResidue = Command->V2.DataTransferResidue;
13704 +       spin_lock_irqsave(&Controller->queue_lock, flags);
13705 +       DAC960_DeallocateCommand(Command);
13706 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13707 +       if (RequestSenseLength > UserCommand.RequestSenseLength)
13708 +         RequestSenseLength = UserCommand.RequestSenseLength;
13709 +       if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
13710 +                                &DataTransferResidue,
13711 +                                sizeof(DataTransferResidue))) {
13712 +               ErrorCode = -EFAULT;
13713 +               goto Failure2;
13714 +       }
13715 +       if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
13716 +                        &RequestSenseLength, sizeof(RequestSenseLength))) {
13717 +               ErrorCode = -EFAULT;
13718 +               goto Failure2;
13719 +       }
13720 +       if (DataTransferLength > 0)
13721 +         {
13722 +           if (copy_to_user(UserCommand.DataTransferBuffer,
13723 +                            DataTransferBuffer, DataTransferLength)) {
13724 +               ErrorCode = -EFAULT;
13725 +               goto Failure2;
13726 +           }
13727 +         }
13728 +       if (RequestSenseLength > 0)
13729 +         {
13730 +           if (copy_to_user(UserCommand.RequestSenseBuffer,
13731 +                            RequestSenseBuffer, RequestSenseLength)) {
13732 +               ErrorCode = -EFAULT;
13733 +               goto Failure2;
13734 +           }
13735 +         }
13736 +       ErrorCode = CommandStatus;
13737 +      Failure2:
13738 +         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
13739 +               DataTransferBuffer, DataTransferBufferDMA);
13740 +       if (RequestSenseBuffer != NULL)
13741 +         pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
13742 +               RequestSenseBuffer, RequestSenseBufferDMA);
13743 +      Failure2a:
13744 +       return ErrorCode;
13745 +      }
13746 +    case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
13747 +      {
13748 +       DAC960_V2_GetHealthStatus_T *UserSpaceGetHealthStatus =
13749 +         (DAC960_V2_GetHealthStatus_T *) Argument;
13750 +       DAC960_V2_GetHealthStatus_T GetHealthStatus;
13751 +       DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
13752 +       DAC960_Controller_T *Controller;
13753 +       int ControllerNumber;
13754 +       if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
13755 +       if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
13756 +                          sizeof(DAC960_V2_GetHealthStatus_T)))
13757 +               return -EFAULT;
13758 +       ControllerNumber = GetHealthStatus.ControllerNumber;
13759 +       if (ControllerNumber < 0 ||
13760 +           ControllerNumber > DAC960_ControllerCount - 1)
13761 +         return -ENXIO;
13762 +       Controller = DAC960_Controllers[ControllerNumber];
13763 +       if (Controller == NULL) return -ENXIO;
13764 +       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
13765 +       if (copy_from_user(&HealthStatusBuffer,
13766 +                          GetHealthStatus.HealthStatusBuffer,
13767 +                          sizeof(DAC960_V2_HealthStatusBuffer_T)))
13768 +               return -EFAULT;
13769 +       while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
13770 +              == HealthStatusBuffer.StatusChangeCounter &&
13771 +              Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
13772 +              == HealthStatusBuffer.NextEventSequenceNumber)
13773 +         {
13774 +           interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
13775 +                                          DAC960_MonitoringTimerInterval);
13776 +           if (signal_pending(current)) return -EINTR;
13777 +         }
13778 +       if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
13779 +                        Controller->V2.HealthStatusBuffer,
13780 +                        sizeof(DAC960_V2_HealthStatusBuffer_T)))
13781 +               return -EFAULT;
13782 +       return 0;
13783 +      }
13784 +    }
13785 +  return -EINVAL;
13786 +}
13787 +
13788 +static struct file_operations DAC960_gam_fops = {
13789 +       .owner          = THIS_MODULE,
13790 +       .ioctl          = DAC960_gam_ioctl
13791 +};
13792 +
13793 +static struct miscdevice DAC960_gam_dev = {
13794 +       DAC960_GAM_MINOR,
13795 +       "dac960_gam",
13796 +       &DAC960_gam_fops
13797 +};
13798 +
13799 +static int DAC960_gam_init(void)
13800 +{
13801 +       int ret;
13802 +
13803 +       ret = misc_register(&DAC960_gam_dev);
13804 +       if (ret)
13805 +               printk(KERN_ERR "DAC960_gam: can't misc_register on minor %d\n", DAC960_GAM_MINOR);
13806 +       return ret;
13807 +}
13808 +
13809 +static void DAC960_gam_cleanup(void)
13810 +{
13811 +       misc_deregister(&DAC960_gam_dev);
13812 +}
13813 +
13814 +#endif /* DAC960_GAM_MINOR */
13815 +
13816  static struct DAC960_privdata DAC960_BA_privdata = {
13817         .HardwareType =         DAC960_BA_Controller,
13818         .FirmwareType   =       DAC960_V2_Controller,
13819 @@ -7000,12 +7025,23 @@
13820  
13821  static int DAC960_init_module(void)
13822  {
13823 -       return pci_module_init(&DAC960_pci_driver);
13824 +       int ret;
13825 +
13826 +       ret =  pci_module_init(&DAC960_pci_driver);
13827 +#ifdef DAC960_GAM_MINOR
13828 +       if (!ret)
13829 +               DAC960_gam_init();
13830 +#endif
13831 +       return ret;
13832  }
13833  
13834  static void DAC960_cleanup_module(void)
13835  {
13836         int i;
13837 +
13838 +#ifdef DAC960_GAM_MINOR
13839 +       DAC960_gam_cleanup();
13840 +#endif
13841  
13842         for (i = 0; i < DAC960_ControllerCount; i++) {
13843                 DAC960_Controller_T *Controller = DAC960_Controllers[i];
13844 diff -Nru a/drivers/block/DAC960.h b/drivers/block/DAC960.h
13845 --- a/drivers/block/DAC960.h    Thu Aug  7 06:13:28 2003
13846 +++ b/drivers/block/DAC960.h    Sun Aug 31 16:13:56 2003
13847 @@ -4138,8 +4138,6 @@
13848  static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *);
13849  static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *);
13850  static void DAC960_MonitoringTimerFunction(unsigned long);
13851 -static int DAC960_UserIOCTL(struct inode *, struct file *,
13852 -                           unsigned int, unsigned long);
13853  static void DAC960_Message(DAC960_MessageLevel_T, unsigned char *,
13854                            DAC960_Controller_T *, ...);
13855  static void DAC960_CreateProcEntries(DAC960_Controller_T *);
13856 diff -Nru a/drivers/block/acsi_slm.c b/drivers/block/acsi_slm.c
13857 --- a/drivers/block/acsi_slm.c  Sun Jun  8 04:05:16 2003
13858 +++ b/drivers/block/acsi_slm.c  Tue Aug 26 09:25:40 2003
13859 @@ -374,7 +374,7 @@
13860         if (!(page = __get_free_page( GFP_KERNEL )))
13861                 return( -ENOMEM );
13862         
13863 -       length = slm_getstats( (char *)page, MINOR(node->i_rdev) );
13864 +       length = slm_getstats( (char *)page, iminor(node) );
13865         if (length < 0) {
13866                 count = length;
13867                 goto out;
13868 @@ -622,7 +622,7 @@
13869  
13870  {
13871         struct inode *node = file->f_dentry->d_inode;
13872 -       int             device = MINOR( node->i_rdev );
13873 +       int             device = iminor(node);
13874         int             n, filled, w, h;
13875  
13876         while( SLMState == PRINTING ||
13877 @@ -694,7 +694,7 @@
13878  static int slm_ioctl( struct inode *inode, struct file *file,
13879                                           unsigned int cmd, unsigned long arg )
13880  
13881 -{      int             device = MINOR( inode->i_rdev ), err;
13882 +{      int             device = iminor(inode), err;
13883         
13884         /* I can think of setting:
13885          *  - manual feed
13886 @@ -768,7 +768,7 @@
13887  {      int device;
13888         struct slm *sip;
13889         
13890 -       device = MINOR(inode->i_rdev);
13891 +       device = iminor(inode);
13892         if (device >= N_SLM_Printers)
13893                 return( -ENXIO );
13894         sip = &slm_info[device];
13895 @@ -797,7 +797,7 @@
13896  {      int device;
13897         struct slm *sip;
13898         
13899 -       device = MINOR(inode->i_rdev);
13900 +       device = iminor(inode);
13901         sip = &slm_info[device];
13902  
13903         if (file->f_mode & 2)
13904 diff -Nru a/drivers/block/amiflop.c b/drivers/block/amiflop.c
13905 --- a/drivers/block/amiflop.c   Thu Aug  7 02:25:23 2003
13906 +++ b/drivers/block/amiflop.c   Wed Sep  3 03:32:10 2003
13907 @@ -55,24 +55,15 @@
13908  
13909  #include <linux/module.h>
13910  
13911 -#include <linux/sched.h>
13912 -#include <linux/fs.h>
13913 -#include <linux/fcntl.h>
13914 -#include <linux/kernel.h>
13915 -#include <linux/timer.h>
13916  #include <linux/fd.h>
13917  #include <linux/hdreg.h>
13918 -#include <linux/errno.h>
13919 -#include <linux/types.h>
13920  #include <linux/delay.h>
13921 -#include <linux/string.h>
13922 -#include <linux/slab.h>
13923  #include <linux/init.h>
13924  #include <linux/amifdreg.h>
13925  #include <linux/amifd.h>
13926 -#include <linux/ioport.h>
13927  #include <linux/buffer_head.h>
13928 -#include <linux/interrupt.h>
13929 +#include <linux/blkdev.h>
13930 +#include <linux/elevator.h>
13931  
13932  #include <asm/setup.h>
13933  #include <asm/uaccess.h>
13934 @@ -1446,7 +1437,7 @@
13935  static int fd_ioctl(struct inode *inode, struct file *filp,
13936                     unsigned int cmd, unsigned long param)
13937  {
13938 -       int drive = minor(inode->i_rdev) & 3;
13939 +       int drive = iminor(inode) & 3;
13940         static struct floppy_struct getprm;
13941  
13942         switch(cmd){
13943 @@ -1570,8 +1561,8 @@
13944   */
13945  static int floppy_open(struct inode *inode, struct file *filp)
13946  {
13947 -       int drive = minor(inode->i_rdev) & 3;
13948 -       int system =  (minor(inode->i_rdev) & 4) >> 2;
13949 +       int drive = iminor(inode) & 3;
13950 +       int system =  (iminor(inode) & 4) >> 2;
13951         int old_dev;
13952         unsigned long flags;
13953  
13954 @@ -1618,7 +1609,7 @@
13955  
13956  static int floppy_release(struct inode * inode, struct file * filp)
13957  {
13958 -       int drive = minor(inode->i_rdev) & 3;
13959 +       int drive = iminor(inode) & 3;
13960  
13961         if (unit[drive].dirty == 1) {
13962                 del_timer (flush_track_timer + drive);
13963 @@ -1740,7 +1731,7 @@
13964  
13965  int __init amiga_floppy_init(void)
13966  {
13967 -       int i;
13968 +       int i, ret;
13969  
13970         if (!AMIGAHW_PRESENT(AMI_FLOPPY))
13971                 return -ENXIO;
13972 @@ -1752,41 +1743,39 @@
13973          *  We request DSKPTR, DSKLEN and DSKDATA only, because the other
13974          *  floppy registers are too spreaded over the custom register space
13975          */
13976 +       ret = -EBUSY;
13977         if (!request_mem_region(CUSTOM_PHYSADDR+0x20, 8, "amiflop [Paula]")) {
13978                 printk("fd: cannot get floppy registers\n");
13979 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
13980 -               return -EBUSY;
13981 +               goto out_blkdev;
13982         }
13983 +
13984 +       ret = -ENOMEM;
13985         if ((raw_buf = (char *)amiga_chip_alloc (RAW_BUF_SIZE, "Floppy")) ==
13986             NULL) {
13987                 printk("fd: cannot get chip mem buffer\n");
13988 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
13989 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
13990 -               return -ENOMEM;
13991 +               goto out_memregion;
13992         }
13993 +
13994 +       ret = -EBUSY;
13995         if (request_irq(IRQ_AMIGA_DSKBLK, fd_block_done, 0, "floppy_dma", NULL)) {
13996                 printk("fd: cannot get irq for dma\n");
13997 -               amiga_chip_free(raw_buf);
13998 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
13999 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
14000 -               return -EBUSY;
14001 +               goto out_irq;
14002         }
14003 +
14004         if (request_irq(IRQ_AMIGA_CIAA_TB, ms_isr, 0, "floppy_timer", NULL)) {
14005                 printk("fd: cannot get irq for timer\n");
14006 -               free_irq(IRQ_AMIGA_DSKBLK, NULL);
14007 -               amiga_chip_free(raw_buf);
14008 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
14009 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
14010 -               return -EBUSY;
14011 -       }
14012 -       if (fd_probe_drives() < 1) { /* No usable drives */
14013 -               free_irq(IRQ_AMIGA_CIAA_TB, NULL);
14014 -               free_irq(IRQ_AMIGA_DSKBLK, NULL);
14015 -               amiga_chip_free(raw_buf);
14016 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
14017 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
14018 -               return -ENXIO;
14019 +               goto out_irq2;
14020         }
14021 +
14022 +       ret = -ENOMEM;
14023 +       floppy_queue = blk_init_queue(do_fd_request, &amiflop_lock);
14024 +       if (!floppy_queue)
14025 +               goto out_queue;
14026 +
14027 +       ret = -ENXIO;
14028 +       if (fd_probe_drives() < 1) /* No usable drives */
14029 +               goto out_probe;
14030 +
14031         blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
14032                                 floppy_find, NULL, NULL);
14033  
14034 @@ -1813,17 +1802,6 @@
14035         post_write_timer.data = 0;
14036         post_write_timer.function = post_write;
14037    
14038 -       floppy_queue = blk_init_queue(do_fd_request, &amiflop_lock);
14039 -       if (!floppy_queue) {
14040 -               free_irq(IRQ_AMIGA_CIAA_TB, NULL);
14041 -               free_irq(IRQ_AMIGA_DSKBLK, NULL);
14042 -               amiga_chip_free(raw_buf);
14043 -               release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
14044 -               unregister_blkdev(FLOPPY_MAJOR,"fd");
14045 -               blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
14046 -               return -ENOMEM;
14047 -       }
14048 -
14049         for (i = 0; i < 128; i++)
14050                 mfmdecode[i]=255;
14051         for (i = 0; i < 16; i++)
14052 @@ -1835,6 +1813,20 @@
14053         /* init ms timer */
14054         ciaa.crb = 8; /* one-shot, stop */
14055         return 0;
14056 +
14057 +out_probe:
14058 +       blk_cleanup_queue(floppy_queue);
14059 +out_queue:
14060 +       free_irq(IRQ_AMIGA_CIAA_TB, NULL);
14061 +out_irq2:
14062 +       free_irq(IRQ_AMIGA_DSKBLK, NULL);
14063 +out_irq:
14064 +       amiga_chip_free(raw_buf);
14065 +out_memregion:
14066 +       release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
14067 +out_blkdev:
14068 +       unregister_blkdev(FLOPPY_MAJOR,"fd");
14069 +       return ret;
14070  }
14071  
14072  #ifdef MODULE
14073 diff -Nru a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c
14074 --- a/drivers/block/as-iosched.c        Fri Aug 15 00:57:28 2003
14075 +++ b/drivers/block/as-iosched.c        Sun Aug 31 16:14:29 2003
14076 @@ -709,6 +709,14 @@
14077                 return 1;
14078         }
14079  
14080 +       if (aic->seek_samples == 0 || aic->ttime_samples == 0) {
14081 +               /*
14082 +                * Process has just started IO so default to not anticipate.
14083 +                * Maybe should be smarter.
14084 +                */
14085 +               return 1;
14086 +       }
14087 +
14088         if (aic->ttime_mean > ad->antic_expire) {
14089                 /* the process thinks too much between requests */
14090                 return 1;
14091 diff -Nru a/drivers/block/ataflop.c b/drivers/block/ataflop.c
14092 --- a/drivers/block/ataflop.c   Thu Aug  7 02:25:23 2003
14093 +++ b/drivers/block/ataflop.c   Wed Jul 30 15:49:57 2003
14094 @@ -63,35 +63,16 @@
14095  
14096  #include <linux/module.h>
14097  
14098 -#include <linux/sched.h>
14099 -#include <linux/string.h>
14100 -#include <linux/fs.h>
14101 -#include <linux/fcntl.h>
14102 -#include <linux/kernel.h>
14103 -#include <linux/timer.h>
14104  #include <linux/fd.h>
14105 -#include <linux/errno.h>
14106 -#include <linux/types.h>
14107  #include <linux/delay.h>
14108 -#include <linux/mm.h>
14109 -#include <linux/slab.h>
14110  #include <linux/init.h>
14111 -#include <linux/buffer_head.h>         /* for invalidate_buffers() */
14112 -
14113 -#include <asm/setup.h>
14114 -#include <asm/system.h>
14115 -#include <asm/bitops.h>
14116 -#include <asm/irq.h>
14117 -#include <asm/pgtable.h>
14118 -#include <asm/uaccess.h>
14119 +#include <linux/blkdev.h>
14120  
14121  #include <asm/atafd.h>
14122  #include <asm/atafdreg.h>
14123 -#include <asm/atarihw.h>
14124  #include <asm/atariints.h>
14125  #include <asm/atari_stdma.h>
14126  #include <asm/atari_stram.h>
14127 -#include <linux/blkpg.h>
14128  
14129  #define        FD_MAX_UNITS 2
14130  
14131 @@ -1838,7 +1819,7 @@
14132  static int floppy_open( struct inode *inode, struct file *filp )
14133  {
14134         struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data;
14135 -       int type  = minor(inode->i_rdev) >> 2;
14136 +       int type  = iminor(inode) >> 2;
14137  
14138         DPRINT(("fd_open: type=%d\n",type));
14139         if (p->ref && p->type != type)
14140 diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c
14141 --- a/drivers/block/cciss.c     Thu Aug  7 06:13:28 2003
14142 +++ b/drivers/block/cciss.c     Tue Aug 26 09:25:41 2003
14143 @@ -356,11 +356,11 @@
14144   */
14145  static int cciss_open(struct inode *inode, struct file *filep)
14146  {
14147 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
14148 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
14149 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
14150 +       int dsk  = iminor(inode) >> NWD_SHIFT;
14151  
14152  #ifdef CCISS_DEBUG
14153 -       printk(KERN_DEBUG "cciss_open %x (%x:%x)\n", inode->i_rdev, ctlr, dsk);
14154 +       printk(KERN_DEBUG "cciss_open %s (%x:%x)\n", inode->i_bdev->bd_disk->disk_name, ctlr, dsk);
14155  #endif /* CCISS_DEBUG */ 
14156  
14157         if (ctlr >= MAX_CTLR || hba[ctlr] == NULL)
14158 @@ -372,7 +372,7 @@
14159          * for "raw controller".
14160          */
14161         if (hba[ctlr]->drv[dsk].nr_blocks == 0) {
14162 -               if (minor(inode->i_rdev) != 0)
14163 +               if (iminor(inode) != 0)
14164                         return -ENXIO;
14165                 if (!capable(CAP_SYS_ADMIN))
14166                         return -EPERM;
14167 @@ -386,11 +386,11 @@
14168   */
14169  static int cciss_release(struct inode *inode, struct file *filep)
14170  {
14171 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
14172 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
14173 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
14174 +       int dsk  = iminor(inode) >> NWD_SHIFT;
14175  
14176  #ifdef CCISS_DEBUG
14177 -       printk(KERN_DEBUG "cciss_release %x (%x:%x)\n", inode->i_rdev, ctlr, dsk);
14178 +       printk(KERN_DEBUG "cciss_release %s (%x:%x)\n", inode->i_bdev->bd_disk->disk_name, ctlr, dsk);
14179  #endif /* CCISS_DEBUG */
14180  
14181         /* fsync_dev(inode->i_rdev); */
14182 @@ -406,8 +406,8 @@
14183  static int cciss_ioctl(struct inode *inode, struct file *filep, 
14184                 unsigned int cmd, unsigned long arg)
14185  {
14186 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
14187 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
14188 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
14189 +       int dsk  = iminor(inode) >> NWD_SHIFT;
14190  
14191  #ifdef CCISS_DEBUG
14192         printk(KERN_DEBUG "cciss_ioctl: Called with cmd=%x %lx\n", cmd, arg);
14193 @@ -2525,6 +2525,9 @@
14194         if (!q)
14195                 goto err_all;
14196  
14197 +       hba[i]->queue = q;
14198 +       q->queuedata = hba[i];
14199 +
14200         /* Initialize the pdev driver private data. 
14201                 have it point to hba[i].  */
14202         pci_set_drvdata(pdev, hba[i]);
14203 @@ -2545,7 +2548,6 @@
14204  
14205         cciss_procinit(i);
14206  
14207 -        q->queuedata = hba[i];
14208         blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
14209  
14210         /* This is a hardware imposed limit. */
14211 diff -Nru a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
14212 --- a/drivers/block/cpqarray.c  Thu Aug  7 02:25:24 2003
14213 +++ b/drivers/block/cpqarray.c  Tue Aug 26 09:25:41 2003
14214 @@ -1078,7 +1078,7 @@
14215                 put_user(host->ctlr_sig, (int*)arg);
14216                 return 0;
14217         case IDAREVALIDATEVOLS:
14218 -               if (minor(inode->i_rdev) != 0)
14219 +               if (iminor(inode) != 0)
14220                         return -ENXIO;
14221                 return revalidate_allvol(host);
14222         case IDADRIVERVERSION:
14223 diff -Nru a/drivers/block/floppy.c b/drivers/block/floppy.c
14224 --- a/drivers/block/floppy.c    Fri Aug 15 10:27:03 2003
14225 +++ b/drivers/block/floppy.c    Sun Aug 31 16:14:41 2003
14226 @@ -695,23 +695,9 @@
14227         spin_unlock_irqrestore(&floppy_lock, flags);
14228  }
14229  
14230 -static int maximum(int a, int b)
14231 -{
14232 -       if (a > b)
14233 -               return a;
14234 -       else
14235 -               return b;
14236 -}
14237 -#define INFBOUND(a,b) (a)=maximum((a),(b));
14238 +#define INFBOUND(a,b) (a)=max_t(int, a, b)
14239  
14240 -static int minimum(int a, int b)
14241 -{
14242 -       if (a < b)
14243 -               return a;
14244 -       else
14245 -               return b;
14246 -}
14247 -#define SUPBOUND(a,b) (a)=minimum((a),(b));
14248 +#define SUPBOUND(a,b) (a)=min_t(int, a, b)
14249  
14250  
14251  /*
14252 @@ -1021,9 +1007,9 @@
14253  
14254  static DECLARE_WORK(floppy_work, NULL, NULL);
14255  
14256 -static void schedule_bh( void (*handler)(void*) )
14257 +static void schedule_bh(void (*handler) (void))
14258  {
14259 -       PREPARE_WORK(&floppy_work, handler, NULL);
14260 +       PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL);
14261         schedule_work(&floppy_work);
14262  }
14263  
14264 @@ -1035,7 +1021,7 @@
14265  
14266         spin_lock_irqsave(&floppy_lock, flags);
14267         do_floppy = NULL;
14268 -       PREPARE_WORK(&floppy_work, (void*)(void*)empty, NULL);
14269 +       PREPARE_WORK(&floppy_work, (void*)empty, NULL);
14270         del_timer(&fd_timer);
14271         spin_unlock_irqrestore(&floppy_lock, flags);
14272  }
14273 @@ -1813,9 +1799,9 @@
14274                         max_sensei--;
14275                 } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2 && max_sensei);
14276         }
14277 -       if (handler) {
14278 -               schedule_bh( (void *)(void *) handler);
14279 -       } else
14280 +       if (handler)
14281 +               schedule_bh(handler);
14282 +       else
14283                 FDCS->reset = 1;
14284         is_alive("normal interrupt end");
14285  
14286 @@ -2058,26 +2044,26 @@
14287         wake_up(&command_done);
14288  }
14289  
14290 -static struct cont_t wakeup_cont={
14291 -       empty,
14292 -       do_wakeup,
14293 -       empty,
14294 -       (done_f)empty
14295 +static struct cont_t wakeup_cont = {
14296 +       .interrupt = empty,
14297 +       .redo = do_wakeup,
14298 +       .error = empty,
14299 +       .done = (done_f) empty
14300  };
14301  
14302  
14303 -static struct cont_t intr_cont={
14304 -       empty,
14305 -       process_fd_request,
14306 -       empty,
14307 -       (done_f) empty
14308 +static struct cont_t intr_cont = {
14309 +       .interrupt = empty,
14310 +       .redo = process_fd_request,
14311 +       .error = empty,
14312 +       .done = (done_f) empty
14313  };
14314  
14315  static int wait_til_done(void (*handler)(void), int interruptible)
14316  {
14317         int ret;
14318  
14319 -       schedule_bh((void *)(void *)handler);
14320 +       schedule_bh(handler);
14321  
14322         if (command_status < 2 && NO_SIGNAL) {
14323                 DECLARE_WAITQUEUE(wait, current);
14324 @@ -2281,11 +2267,12 @@
14325  #endif
14326  }
14327  
14328 -static struct cont_t format_cont={
14329 -       format_interrupt,
14330 -       redo_format,
14331 -       bad_flp_intr,
14332 -       generic_done };
14333 +static struct cont_t format_cont = {
14334 +       .interrupt = format_interrupt,
14335 +       .redo = redo_format,
14336 +       .error = bad_flp_intr,
14337 +       .done = generic_done
14338 +};
14339  
14340  static int do_format(int drive, struct format_descr *tmp_format_req)
14341  {
14342 @@ -2523,12 +2510,12 @@
14343         int size, i;
14344  
14345         max_sector = transfer_size(ssize,
14346 -                                  minimum(max_sector, max_sector_2),
14347 +                                  min(max_sector, max_sector_2),
14348                                    current_req->nr_sectors);
14349  
14350         if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
14351             buffer_max > fsector_t + current_req->nr_sectors)
14352 -               current_count_sectors = minimum(buffer_max - fsector_t,
14353 +               current_count_sectors = min_t(int, buffer_max - fsector_t,
14354                                                 current_req->nr_sectors);
14355  
14356         remaining = current_count_sectors << 9;
14357 @@ -2546,7 +2533,7 @@
14358         }
14359  #endif
14360  
14361 -       buffer_max = maximum(max_sector, buffer_max);
14362 +       buffer_max = max(max_sector, buffer_max);
14363  
14364         dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
14365  
14366 @@ -2697,7 +2684,7 @@
14367         if ((_floppy->rate & FD_2M) && (!TRACK) && (!HEAD)){
14368                 max_sector = 2 * _floppy->sect / 3;
14369                 if (fsector_t >= max_sector){
14370 -                       current_count_sectors = minimum(_floppy->sect - fsector_t,
14371 +                       current_count_sectors = min_t(int, _floppy->sect - fsector_t,
14372                                                         current_req->nr_sectors);
14373                         return 1;
14374                 }
14375 @@ -2987,7 +2974,7 @@
14376  
14377                 if (TESTF(FD_NEED_TWADDLE))
14378                         twaddle();
14379 -               schedule_bh( (void *)(void *) floppy_start);
14380 +               schedule_bh(floppy_start);
14381  #ifdef DEBUGT
14382                 debugt("queue fd request");
14383  #endif
14384 @@ -2996,16 +2983,17 @@
14385  #undef REPEAT
14386  }
14387  
14388 -static struct cont_t rw_cont={
14389 -       rw_interrupt,
14390 -       redo_fd_request,
14391 -       bad_flp_intr,
14392 -       request_done };
14393 +static struct cont_t rw_cont = {
14394 +       .interrupt = rw_interrupt,
14395 +       .redo = redo_fd_request,
14396 +       .error = bad_flp_intr,
14397 +       .done = request_done
14398 +};
14399  
14400  static void process_fd_request(void)
14401  {
14402         cont = &rw_cont;
14403 -       schedule_bh( (void *)(void *) redo_fd_request);
14404 +       schedule_bh(redo_fd_request);
14405  }
14406  
14407  static void do_fd_request(request_queue_t * q)
14408 @@ -3031,11 +3019,12 @@
14409         is_alive("do fd request");
14410  }
14411  
14412 -static struct cont_t poll_cont={
14413 -       success_and_wakeup,
14414 -       floppy_ready,
14415 -       generic_failure,
14416 -       generic_done };
14417 +static struct cont_t poll_cont = {
14418 +       .interrupt = success_and_wakeup,
14419 +       .redo = floppy_ready,
14420 +       .error = generic_failure,
14421 +       .done = generic_done
14422 +};
14423  
14424  static int poll_drive(int interruptible, int flag)
14425  {
14426 @@ -3066,11 +3055,12 @@
14427         printk("weird, reset interrupt called\n");
14428  }
14429  
14430 -static struct cont_t reset_cont={
14431 -       reset_intr,
14432 -       success_and_wakeup,
14433 -       generic_failure,
14434 -       generic_done };
14435 +static struct cont_t reset_cont = {
14436 +       .interrupt = reset_intr,
14437 +       .redo = success_and_wakeup,
14438 +       .error = generic_failure,
14439 +       .done = generic_done
14440 +};
14441  
14442  static int user_reset_fdc(int drive, int arg, int interruptible)
14443  {
14444 @@ -3174,11 +3164,11 @@
14445  }
14446  
14447  
14448 -static struct cont_t raw_cmd_cont={
14449 -       success_and_wakeup,
14450 -       floppy_start,
14451 -       generic_failure,
14452 -       raw_cmd_done
14453 +static struct cont_t raw_cmd_cont = {
14454 +       .interrupt = success_and_wakeup,
14455 +       .redo = floppy_start,
14456 +       .error = generic_failure,
14457 +       .done = raw_cmd_done
14458  };
14459  
14460  static inline int raw_cmd_copyout(int cmd, char *param,
14461 @@ -3781,9 +3771,9 @@
14462                 }
14463         }
14464  
14465 -       UDRS->fd_device = minor(inode->i_rdev);
14466 -       set_capacity(disks[drive], floppy_sizes[minor(inode->i_rdev)]);
14467 -       if (old_dev != -1 && old_dev != minor(inode->i_rdev)) {
14468 +       UDRS->fd_device = iminor(inode);
14469 +       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
14470 +       if (old_dev != -1 && old_dev != iminor(inode)) {
14471                 if (buffer_drive == drive)
14472                         buffer_track = -1;
14473         }
14474 @@ -3910,22 +3900,6 @@
14475         return 0;
14476  }
14477  
14478 -static int floppy_read_block_0(struct gendisk *disk)
14479 -{
14480 -       struct block_device *bdev;
14481 -       int ret;
14482 -
14483 -       bdev = bdget_disk(disk, 0);
14484 -       if (!bdev) {
14485 -               printk("No block device for %s\n", disk->disk_name);
14486 -               BUG();
14487 -       }
14488 -       bdev->bd_disk = disk;   /* ewww */
14489 -       ret = __floppy_read_block_0(bdev);
14490 -       atomic_dec(&bdev->bd_count);
14491 -       return ret;
14492 -}
14493 -
14494  /* revalidate the floppy disk, i.e. trigger format autodetection by reading
14495   * the bootblock (block 0). "Autodetection" is also needed to check whether
14496   * there is a disk in the drive at all... Thus we also do it for fixed
14497 @@ -3961,7 +3935,7 @@
14498                         UDRS->generation++;
14499                 if (NO_GEOM){
14500                         /* auto-sensing */
14501 -                       res = floppy_read_block_0(disk);
14502 +                       res = __floppy_read_block_0(opened_bdev[drive]);
14503                 } else {
14504                         if (cf)
14505                                 poll_drive(0, FD_RAW_NEED_DISK);
14506 diff -Nru a/drivers/block/floppy98.c b/drivers/block/floppy98.c
14507 --- a/drivers/block/floppy98.c  Thu Aug  7 02:25:24 2003
14508 +++ b/drivers/block/floppy98.c  Tue Aug 26 09:44:42 2003
14509 @@ -3844,9 +3844,9 @@
14510                 }
14511         }
14512  
14513 -       UDRS->fd_device = minor(inode->i_rdev);
14514 -       set_capacity(disks[drive], floppy_sizes[minor(inode->i_rdev)]);
14515 -       if (old_dev != -1 && old_dev != minor(inode->i_rdev)) {
14516 +       UDRS->fd_device = iminor(inode);
14517 +       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
14518 +       if (old_dev != -1 && old_dev != iminor(inode)) {
14519                 if (buffer_drive == drive)
14520                         buffer_track = -1;
14521         }
14522 @@ -3989,22 +3989,6 @@
14523         return 0;
14524  }
14525  
14526 -static int floppy_read_block_0(struct gendisk *disk)
14527 -{
14528 -       struct block_device *bdev;
14529 -       int ret;
14530 -
14531 -       bdev = bdget_disk(disk, 0);
14532 -       if (!bdev) {
14533 -               printk("No block device for %s\n", disk->disk_name);
14534 -               BUG();
14535 -       }
14536 -       bdev->bd_disk = disk;   /* ewww */
14537 -       ret = __floppy_read_block_0(bdev);
14538 -       atomic_dec(&bdev->bd_count);
14539 -       return ret;
14540 -}
14541 -
14542  /* revalidate the floppy disk, i.e. trigger format autodetection by reading
14543   * the bootblock (block 0). "Autodetection" is also needed to check whether
14544   * there is a disk in the drive at all... Thus we also do it for fixed
14545 @@ -4040,7 +4024,7 @@
14546                         UDRS->generation++;
14547                 if (NO_GEOM){
14548                         /* auto-sensing */
14549 -                       res = floppy_read_block_0(disk);
14550 +                       res = __floppy_read_block_0(opened_bdev[drive]);
14551                 } else {
14552                         if (cf)
14553                                 poll_drive(0, FD_RAW_NEED_DISK);
14554 diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c
14555 --- a/drivers/block/genhd.c     Fri Aug  1 02:22:20 2003
14556 +++ b/drivers/block/genhd.c     Tue Aug 26 12:06:15 2003
14557 @@ -576,13 +576,10 @@
14558  
14559  void set_device_ro(struct block_device *bdev, int flag)
14560  {
14561 -       struct gendisk *disk = bdev->bd_disk;
14562 -       if (bdev->bd_contains != bdev) {
14563 -               int part = bdev->bd_dev - MKDEV(disk->major, disk->first_minor);
14564 -               struct hd_struct *p = disk->part[part-1];
14565 -               if (p) p->policy = flag;
14566 -       } else
14567 -               disk->policy = flag;
14568 +       if (bdev->bd_contains != bdev)
14569 +               bdev->bd_part->policy = flag;
14570 +       else
14571 +               bdev->bd_disk->policy = flag;
14572  }
14573  
14574  void set_disk_ro(struct gendisk *disk, int flag)
14575 @@ -595,17 +592,12 @@
14576  
14577  int bdev_read_only(struct block_device *bdev)
14578  {
14579 -       struct gendisk *disk;
14580         if (!bdev)
14581                 return 0;
14582 -       disk = bdev->bd_disk;
14583 -       if (bdev->bd_contains != bdev) {
14584 -               int part = bdev->bd_dev - MKDEV(disk->major, disk->first_minor);
14585 -               struct hd_struct *p = disk->part[part-1];
14586 -               if (p) return p->policy;
14587 -               return 0;
14588 -       } else
14589 -               return disk->policy;
14590 +       else if (bdev->bd_contains != bdev)
14591 +               return bdev->bd_part->policy;
14592 +       else
14593 +               return bdev->bd_disk->policy;
14594  }
14595  
14596  int invalidate_partition(struct gendisk *disk, int index)
14597 diff -Nru a/drivers/block/ioctl.c b/drivers/block/ioctl.c
14598 --- a/drivers/block/ioctl.c     Thu Jul 17 22:30:42 2003
14599 +++ b/drivers/block/ioctl.c     Tue Aug 26 12:06:15 2003
14600 @@ -8,7 +8,6 @@
14601  static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg *arg)
14602  {
14603         struct block_device *bdevp;
14604 -       int holder;
14605         struct gendisk *disk;
14606         struct blkpg_ioctl_arg a;
14607         struct blkpg_partition p;
14608 @@ -41,8 +40,11 @@
14609                                         return -EINVAL;
14610                         }
14611                         /* partition number in use? */
14612 -                       if (disk->part[part - 1])
14613 +                       down(&bdev->bd_sem);
14614 +                       if (disk->part[part - 1]) {
14615 +                               up(&bdev->bd_sem);
14616                                 return -EBUSY;
14617 +                       }
14618                         /* overlap? */
14619                         for (i = 0; i < disk->minors - 1; i++) {
14620                                 struct hd_struct *s = disk->part[i];
14621 @@ -50,22 +52,26 @@
14622                                 if (!s)
14623                                         continue;
14624                                 if (!(start+length <= s->start_sect ||
14625 -                                     start >= s->start_sect + s->nr_sects))
14626 +                                     start >= s->start_sect + s->nr_sects)) {
14627 +                                       up(&bdev->bd_sem);
14628                                         return -EBUSY;
14629 +                               }
14630                         }
14631                         /* all seems OK */
14632                         add_partition(disk, part, start, length);
14633 +                       up(&bdev->bd_sem);
14634                         return 0;
14635                 case BLKPG_DEL_PARTITION:
14636                         if (!disk->part[part-1])
14637                                 return -ENXIO;
14638                         if (disk->part[part - 1]->nr_sects == 0)
14639                                 return -ENXIO;
14640 -                       /* partition in use? Incomplete check for now. */
14641                         bdevp = bdget_disk(disk, part);
14642                         if (!bdevp)
14643                                 return -ENOMEM;
14644 -                       if (bd_claim(bdevp, &holder) < 0) {
14645 +                       down(&bdevp->bd_sem);
14646 +                       if (bdevp->bd_openers) {
14647 +                               up(&bdevp->bd_sem);
14648                                 bdput(bdevp);
14649                                 return -EBUSY;
14650                         }
14651 @@ -73,9 +79,12 @@
14652                         fsync_bdev(bdevp);
14653                         invalidate_bdev(bdevp, 0);
14654  
14655 +                       down(&bdev->bd_sem);
14656                         delete_partition(disk, part);
14657 -                       bd_release(bdevp);
14658 +                       up(&bdev->bd_sem);
14659 +                       up(&bdevp->bd_sem);
14660                         bdput(bdevp);
14661 +
14662                         return 0;
14663                 default:
14664                         return -EINVAL;
14665 diff -Nru a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
14666 --- a/drivers/block/ll_rw_blk.c Mon Aug 18 22:28:54 2003
14667 +++ b/drivers/block/ll_rw_blk.c Mon Sep  1 04:55:34 2003
14668 @@ -136,6 +136,12 @@
14669         return ret;
14670  }
14671  
14672 +void blk_queue_activity_fn(request_queue_t *q, activity_fn *fn, void *data)
14673 +{
14674 +       q->activity_fn = fn;
14675 +       q->activity_data = data;
14676 +}
14677 +
14678  /**
14679   * blk_queue_prep_rq - set a prepare_request function for queue
14680   * @q:         queue
14681 @@ -225,6 +231,8 @@
14682         blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
14683  
14684         INIT_LIST_HEAD(&q->plug_list);
14685 +
14686 +       blk_queue_activity_fn(q, NULL, NULL);
14687  }
14688  
14689  /**
14690 @@ -1314,7 +1322,7 @@
14691  
14692         if (!printed) {
14693                 printed = 1;
14694 -               printk("Using %s elevator\n", chosen_elevator->elevator_name);
14695 +               printk("Using %s io scheduler\n", chosen_elevator->elevator_name);
14696         }
14697  
14698         if (elevator_init(q, chosen_elevator))
14699 @@ -1666,6 +1674,9 @@
14700  {
14701         drive_stat_acct(req, req->nr_sectors, 1);
14702  
14703 +       if (q->activity_fn)
14704 +               q->activity_fn(q->activity_data, rq_data_dir(req));
14705 +
14706         /*
14707          * elevator indicated where it wants this request to be
14708          * inserted at elevator_merge time
14709 @@ -2043,24 +2054,23 @@
14710  static inline void blk_partition_remap(struct bio *bio)
14711  {
14712         struct block_device *bdev = bio->bi_bdev;
14713 -       struct gendisk *disk = bdev->bd_disk;
14714 -       struct hd_struct *p;
14715 -       if (bdev == bdev->bd_contains)
14716 -               return;
14717  
14718 -       p = disk->part[bdev->bd_dev-MKDEV(disk->major,disk->first_minor)-1];
14719 -       switch (bio->bi_rw) {
14720 -       case READ:
14721 -               p->read_sectors += bio_sectors(bio);
14722 -               p->reads++;
14723 -               break;
14724 -       case WRITE:
14725 -               p->write_sectors += bio_sectors(bio);
14726 -               p->writes++;
14727 -               break;
14728 +       if (bdev != bdev->bd_contains) {
14729 +               struct hd_struct *p = bdev->bd_part;
14730 +
14731 +               switch (bio->bi_rw) {
14732 +               case READ:
14733 +                       p->read_sectors += bio_sectors(bio);
14734 +                       p->reads++;
14735 +                       break;
14736 +               case WRITE:
14737 +                       p->write_sectors += bio_sectors(bio);
14738 +                       p->writes++;
14739 +                       break;
14740 +               }
14741 +               bio->bi_sector += p->start_sect;
14742 +               bio->bi_bdev = bdev->bd_contains;
14743         }
14744 -       bio->bi_sector += bdev->bd_offset;
14745 -       bio->bi_bdev = bdev->bd_contains;
14746  }
14747  
14748  /**
14749 diff -Nru a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
14750 --- a/drivers/block/paride/pg.c Sun May 25 02:45:05 2003
14751 +++ b/drivers/block/paride/pg.c Tue Aug 26 09:25:41 2003
14752 @@ -527,11 +527,9 @@
14753         return -1;
14754  }
14755  
14756 -#define DEVICE_NR(dev) (minor(dev) & 0x7F)
14757 -
14758  static int pg_open(struct inode *inode, struct file *file)
14759  {
14760 -       int unit = DEVICE_NR(inode->i_rdev);
14761 +       int unit = iminor(inode) & 0x7f;
14762         struct pg *dev = &devices[unit];
14763  
14764         if ((unit >= PG_UNITS) || (!dev->present))
14765 diff -Nru a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
14766 --- a/drivers/block/paride/pt.c Sun May 25 02:45:06 2003
14767 +++ b/drivers/block/paride/pt.c Tue Aug 26 09:25:41 2003
14768 @@ -670,11 +670,11 @@
14769         return -1;
14770  }
14771  
14772 -#define DEVICE_NR(dev) (minor(dev) & 0x7F)
14773 +#define DEVICE_NR(inode)       (iminor(inode) & 0x7F)
14774  
14775  static int pt_open(struct inode *inode, struct file *file)
14776  {
14777 -       int unit = DEVICE_NR(inode->i_rdev);
14778 +       int unit = DEVICE_NR(inode);
14779  
14780         if ((unit >= PT_UNITS) || (!PT.present))
14781                 return -ENODEV;
14782 @@ -696,7 +696,7 @@
14783                 return -EROFS;
14784         }
14785  
14786 -       if (!(minor(inode->i_rdev) & 128))
14787 +       if (!(iminor(inode) & 128))
14788                 PT.flags |= PT_REWIND;
14789  
14790         PT.bufptr = kmalloc(PT_BUFSIZE, GFP_KERNEL);
14791 @@ -715,7 +715,7 @@
14792         int unit;
14793         struct mtop mtop;
14794  
14795 -       unit = DEVICE_NR(inode->i_rdev);
14796 +       unit = DEVICE_NR(inode);
14797         if (unit >= PT_UNITS)
14798                 return -EINVAL;
14799         if (!PT.present)
14800 @@ -753,7 +753,7 @@
14801  static int
14802  pt_release(struct inode *inode, struct file *file)
14803  {
14804 -       int unit = DEVICE_NR(inode->i_rdev);
14805 +       int unit = DEVICE_NR(inode);
14806  
14807         if ((unit >= PT_UNITS) || (atomic_read(&PT.available) > 1))
14808                 return -EINVAL;
14809 @@ -776,7 +776,7 @@
14810  static ssize_t pt_read(struct file *filp, char *buf, size_t count, loff_t * ppos)
14811  {
14812         struct inode *ino = filp->f_dentry->d_inode;
14813 -       int unit = DEVICE_NR(ino->i_rdev);
14814 +       int unit = DEVICE_NR(ino);
14815         char rd_cmd[12] = { ATAPI_READ_6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
14816         int k, n, r, p, s, t, b;
14817  
14818 @@ -873,7 +873,7 @@
14819  static ssize_t pt_write(struct file *filp, const char *buf, size_t count, loff_t * ppos)
14820  {
14821         struct inode *ino = filp->f_dentry->d_inode;
14822 -       int unit = DEVICE_NR(ino->i_rdev);
14823 +       int unit = DEVICE_NR(ino);
14824         char wr_cmd[12] = { ATAPI_WRITE_6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
14825         int k, n, r, p, s, t, b;
14826  
14827 diff -Nru a/drivers/block/rd.c b/drivers/block/rd.c
14828 --- a/drivers/block/rd.c        Thu Aug  7 02:25:24 2003
14829 +++ b/drivers/block/rd.c        Tue Aug 26 10:05:56 2003
14830 @@ -245,6 +245,7 @@
14831  static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
14832  {
14833         int error;
14834 +       struct block_device *bdev = inode->i_bdev;
14835  
14836         if (cmd != BLKFLSBUF)
14837                 return -EINVAL;
14838 @@ -253,12 +254,12 @@
14839            it's not like with the other blockdevices where
14840            this ioctl only flushes away the buffer cache. */
14841         error = -EBUSY;
14842 -       down(&inode->i_bdev->bd_sem);
14843 -       if (inode->i_bdev->bd_openers <= 2) {
14844 -               truncate_inode_pages(inode->i_mapping, 0);
14845 +       down(&bdev->bd_sem);
14846 +       if (bdev->bd_openers <= 2) {
14847 +               truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
14848                 error = 0;
14849         }
14850 -       up(&inode->i_bdev->bd_sem);
14851 +       up(&bdev->bd_sem);
14852         return error;
14853  }
14854  
14855 @@ -269,18 +270,18 @@
14856  
14857  static int rd_open(struct inode * inode, struct file * filp)
14858  {
14859 -       unsigned unit = minor(inode->i_rdev);
14860 +       unsigned unit = iminor(inode);
14861  
14862         /*
14863          * Immunize device against invalidate_buffers() and prune_icache().
14864          */
14865         if (rd_bdev[unit] == NULL) {
14866                 struct block_device *bdev = inode->i_bdev;
14867 -               atomic_inc(&bdev->bd_count);
14868 +               inode = igrab(bdev->bd_inode);
14869                 rd_bdev[unit] = bdev;
14870                 bdev->bd_openers++;
14871                 bdev->bd_block_size = rd_blocksize;
14872 -               bdev->bd_inode->i_size = get_capacity(rd_disks[unit])<<9;
14873 +               inode->i_size = get_capacity(rd_disks[unit])<<9;
14874                 inode->i_mapping->a_ops = &ramdisk_aops;
14875                 inode->i_mapping->backing_dev_info = &rd_backing_dev_info;
14876         }
14877 diff -Nru a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c
14878 --- a/drivers/block/scsi_ioctl.c        Thu Aug  7 11:22:15 2003
14879 +++ b/drivers/block/scsi_ioctl.c        Mon Sep  1 12:24:06 2003
14880 @@ -438,11 +438,7 @@
14881                         err = sg_emulated_host(q, (int *) arg);
14882                         break;
14883                 case SG_IO:
14884 -                       err = bd_claim(bdev, current);
14885 -                       if (err)
14886 -                               break;
14887                         err = sg_io(q, bdev, (struct sg_io_hdr *) arg);
14888 -                       bd_release(bdev);
14889                         break;
14890                 /*
14891                  * old junk scsi send command ioctl
14892 @@ -452,11 +448,7 @@
14893                         if (!arg)
14894                                 break;
14895  
14896 -                       err = bd_claim(bdev, current);
14897 -                       if (err)
14898 -                               break;
14899                         err = sg_scsi_ioctl(q, bdev, (Scsi_Ioctl_Command *)arg);
14900 -                       bd_release(bdev);
14901                         break;
14902                 case CDROMCLOSETRAY:
14903                         close = 1;
14904 diff -Nru a/drivers/block/z2ram.c b/drivers/block/z2ram.c
14905 --- a/drivers/block/z2ram.c     Thu Aug  7 02:25:24 2003
14906 +++ b/drivers/block/z2ram.c     Wed Jul 30 15:20:18 2003
14907 @@ -28,10 +28,10 @@
14908  #define DEVICE_NAME "Z2RAM"
14909  
14910  #include <linux/major.h>
14911 -#include <linux/slab.h>
14912  #include <linux/vmalloc.h>
14913  #include <linux/init.h>
14914  #include <linux/module.h>
14915 +#include <linux/blkdev.h>
14916  
14917  #include <asm/setup.h>
14918  #include <asm/bitops.h>
14919 @@ -150,7 +150,7 @@
14920         sizeof( z2ram_map[0] );
14921      int rc = -ENOMEM;
14922  
14923 -    device = minor( inode->i_rdev );
14924 +    device = iminor(inode);
14925  
14926      if ( current_device != -1 && current_device != device )
14927      {
14928 diff -Nru a/drivers/cdrom/Kconfig b/drivers/cdrom/Kconfig
14929 --- a/drivers/cdrom/Kconfig     Thu Jun 26 23:05:31 2003
14930 +++ b/drivers/cdrom/Kconfig     Mon Aug 25 06:13:29 2003
14931 @@ -74,7 +74,7 @@
14932  
14933  config SBPCD
14934         tristate "Matsushita/Panasonic/Creative, Longshine, TEAC CDROM support"
14935 -       depends on CD_NO_IDESCSI
14936 +       depends on CD_NO_IDESCSI && BROKEN_ON_SMP
14937         ---help---
14938           This driver supports most of the drives which use the Panasonic or
14939           Sound Blaster interface.  Please read the file
14940 @@ -199,7 +199,7 @@
14941  
14942  config CM206
14943         tristate "Philips/LMS CM206 CDROM support"
14944 -       depends on CD_NO_IDESCSI
14945 +       depends on CD_NO_IDESCSI && BROKEN_ON_SMP
14946         ---help---
14947           If you have a Philips/LMS CD-ROM drive cm206 in combination with a
14948           cm260 host adapter card, say Y here. Please also read the file
14949 @@ -245,7 +245,7 @@
14950  
14951  config CDU31A
14952         tristate "Sony CDU31A/CDU33A CDROM support"
14953 -       depends on CD_NO_IDESCSI
14954 +       depends on CD_NO_IDESCSI && BROKEN_ON_SMP
14955         ---help---
14956           These CD-ROM drives have a spring-pop-out caddyless drawer, and a
14957           rectangular green LED centered beneath it.  NOTE: these CD-ROM
14958 @@ -267,7 +267,7 @@
14959  
14960  config CDU535
14961         tristate "Sony CDU535 CDROM support"
14962 -       depends on CD_NO_IDESCSI
14963 +       depends on CD_NO_IDESCSI && BROKEN_ON_SMP
14964         ---help---
14965           This is the driver for the older Sony CDU-535 and CDU-531 CD-ROM
14966           drives. Please read the file <file:Documentation/cdrom/sonycd535>.
14967 diff -Nru a/drivers/char/Kconfig b/drivers/char/Kconfig
14968 --- a/drivers/char/Kconfig      Fri Aug 22 09:52:20 2003
14969 +++ b/drivers/char/Kconfig      Tue Sep  2 11:28:13 2003
14970 @@ -80,7 +80,7 @@
14971  
14972  config COMPUTONE
14973         tristate "Computone IntelliPort Plus serial support"
14974 -       depends on SERIAL_NONSTANDARD
14975 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
14976         ---help---
14977           This driver supports the entire family of Intelliport II/Plus
14978           controllers with the exception of the MicroChannel controllers and
14979 @@ -113,7 +113,7 @@
14980  
14981  config CYCLADES
14982         tristate "Cyclades async mux support"
14983 -       depends on SERIAL_NONSTANDARD
14984 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
14985         ---help---
14986           This is a driver for a card that gives you many serial ports. You
14987           would need something like this to connect more than two modems to
14988 @@ -145,7 +145,7 @@
14989  
14990  config DIGIEPCA
14991         tristate "Digiboard Intelligent Async Support"
14992 -       depends on SERIAL_NONSTANDARD
14993 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
14994         ---help---
14995           This is a driver for Digi International's Xx, Xeve, and Xem series
14996           of cards which provide multiple serial ports. You would need
14997 @@ -164,7 +164,7 @@
14998  
14999  config DIGI
15000         tristate "Digiboard PC/Xx Support"
15001 -       depends on SERIAL_NONSTANDARD && DIGIEPCA=n
15002 +       depends on SERIAL_NONSTANDARD && DIGIEPCA=n && BROKEN_ON_SMP
15003         help
15004           This is a driver for the Digiboard PC/Xe, PC/Xi, and PC/Xeve cards
15005           that give you many serial ports. You would need something like this
15006 @@ -177,7 +177,7 @@
15007  
15008  config ESPSERIAL
15009         tristate "Hayes ESP serial port support"
15010 -       depends on SERIAL_NONSTANDARD && ISA
15011 +       depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP
15012         help
15013           This is a driver which supports Hayes ESP serial ports.  Both single
15014           port cards and multiport cards are supported.  Make sure to read
15015 @@ -190,7 +190,7 @@
15016  
15017  config MOXA_INTELLIO
15018         tristate "Moxa Intellio support"
15019 -       depends on SERIAL_NONSTANDARD
15020 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
15021         help
15022           Say Y here if you have a Moxa Intellio multiport serial card.
15023  
15024 @@ -201,7 +201,7 @@
15025  
15026  config MOXA_SMARTIO
15027         tristate "Moxa SmartIO support"
15028 -       depends on SERIAL_NONSTANDARD
15029 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
15030         help
15031           Say Y here if you have a Moxa SmartIO multiport serial card.
15032  
15033 @@ -212,7 +212,7 @@
15034  
15035  config ISI
15036         tristate "Multi-Tech multiport card support (EXPERIMENTAL)"
15037 -       depends on SERIAL_NONSTANDARD && EXPERIMENTAL && m
15038 +       depends on SERIAL_NONSTANDARD && EXPERIMENTAL && BROKEN_ON_SMP && m
15039         help
15040           This is a driver for the Multi-Tech cards which provide several
15041           serial ports.  The driver is experimental and can currently only be
15042 @@ -262,7 +262,7 @@
15043  
15044  config RISCOM8
15045         tristate "SDL RISCom/8 card support"
15046 -       depends on SERIAL_NONSTANDARD
15047 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
15048         help
15049           This is a driver for the SDL Communications RISCom/8 multiport card,
15050           which gives you many serial ports. You would need something like
15051 @@ -275,7 +275,7 @@
15052  
15053  config SPECIALIX
15054         tristate "Specialix IO8+ card support"
15055 -       depends on SERIAL_NONSTANDARD
15056 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
15057         help
15058           This is a driver for the Specialix IO8+ multiport card (both the
15059           ISA and the PCI version) which gives you many serial ports. You
15060 @@ -299,7 +299,7 @@
15061  
15062  config SX
15063         tristate "Specialix SX (and SI) card support"
15064 -       depends on SERIAL_NONSTANDARD
15065 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
15066         help
15067           This is a driver for the SX and SI multiport serial cards.
15068           Please read the file <file:Documentation/sx.txt> for details.
15069 @@ -310,7 +310,7 @@
15070  
15071  config RIO
15072         tristate "Specialix RIO system support"
15073 -       depends on SERIAL_NONSTANDARD
15074 +       depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP
15075         help
15076           This is a driver for the Specialix RIO, a smart serial card which
15077           drives an outboard box that can support up to 128 ports.  Product
15078 @@ -339,7 +339,7 @@
15079  
15080  config STALLION
15081         tristate "Stallion EasyIO or EC8/32 support"
15082 -       depends on STALDRV
15083 +       depends on STALDRV && BROKEN_ON_SMP
15084         help
15085           If you have an EasyIO or EasyConnection 8/32 multiport Stallion
15086           card, then this is for you; say Y.  Make sure to read
15087 @@ -352,7 +352,7 @@
15088  
15089  config ISTALLION
15090         tristate "Stallion EC8/64, ONboard, Brumby support"
15091 -       depends on STALDRV
15092 +       depends on STALDRV && BROKEN
15093         help
15094           If you have an EasyConnection 8/64, ONboard, Brumby or Stallion
15095           serial multiport card, say Y here. Make sure to read
15096 @@ -365,7 +365,7 @@
15097  
15098  config SERIAL_TX3912
15099         bool "TMPTX3912/PR31700 serial port support"
15100 -       depends on SERIAL_NONSTANDARD && MIPS
15101 +       depends on SERIAL_NONSTANDARD && MIPS && BROKEN_ON_SMP
15102         help
15103           The TX3912 is a Toshiba RISC processor based o the MIPS 3900 core;
15104           see <http://www.toshiba.com/taec/components/Generic/risc/tx3912.htm>.
15105 @@ -425,7 +425,7 @@
15106  
15107  config A2232
15108         tristate "Commodore A2232 serial support (EXPERIMENTAL)"
15109 -       depends on EXPERIMENTAL && ZORRO
15110 +       depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP
15111         ---help---
15112           This option supports the 2232 7-port serial card shipped with the
15113           Amiga 2000 and other Zorro-bus machines, dating from 1989.  At
15114 @@ -909,6 +909,7 @@
15115  
15116  config FTAPE
15117         tristate "Ftape (QIC-80/Travan) support"
15118 +       depends on BROKEN_ON_SMP
15119         ---help---
15120           If you have a tape drive that is connected to your floppy
15121           controller, say Y here.
15122 diff -Nru a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
15123 --- a/drivers/char/agp/Kconfig  Fri Aug 15 07:33:19 2003
15124 +++ b/drivers/char/agp/Kconfig  Thu Aug 28 16:22:00 2003
15125 @@ -63,15 +63,19 @@
15126           You should say Y here if you use XFree86 3.3.6 or 4.x and want to
15127           use GLX or DRI.  If unsure, say N.
15128  
15129 +# RED-PEN this option is misnamed, it's not 8151 specific
15130  config AGP_AMD_8151
15131 -       tristate "AMD Opteron/Athlon64 on-CPU GART support"
15132 +       tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU
15133         depends on AGP && X86
15134 -       default GART_IOMMU
15135 +       default y if GART_IOMMU
15136         help
15137           This option gives you AGP support for the GLX component of
15138 -         XFree86 4.x using the on-CPU AGP bridge of the AMD Athlon64/Opteron CPUs.
15139 +         XFree86 4.x using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.
15140 +         You still need an external AGP bridge like the AMD 8151, VIA
15141 +          K8T400M, SiS755. It may also support other AGP bridges when loaded
15142 +         with agp_try_unsupported=1.
15143           You should say Y here if you use XFree86 3.3.6 or 4.x and want to
15144 -         use GLX or DRI.  If unsure, say N
15145 +         use GLX or DRI.  If unsure, say Y
15146  
15147  config AGP_INTEL
15148         tristate "Intel 440LX/BX/GX, I8xx and E7x05 chipset support"
15149 diff -Nru a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
15150 --- a/drivers/char/agp/agp.h    Fri Aug 15 06:28:58 2003
15151 +++ b/drivers/char/agp/agp.h    Thu Aug 28 18:04:31 2003
15152 @@ -167,8 +167,10 @@
15153  
15154  #define PGE_EMPTY(b, p)        (!(p) || (p) == (unsigned long) (b)->scratch_page)
15155  
15156 -/* intel register */
15157 -#define INTEL_APBASE   0x10
15158 +/* Chipset independant registers (from AGP Spec) */
15159 +#define AGP_APBASE     0x10
15160 +
15161 +/* Intel registers */
15162  #define INTEL_APSIZE   0xb4
15163  #define INTEL_ATTBASE  0xb8
15164  #define INTEL_AGPCTRL  0xb0
15165 @@ -176,7 +178,6 @@
15166  #define INTEL_ERRSTS   0x91
15167  
15168  /* Intel 460GX Registers */
15169 -#define INTEL_I460_APBASE              0x10
15170  #define INTEL_I460_BAPBASE             0x98
15171  #define INTEL_I460_GXBCTL              0xa0
15172  #define INTEL_I460_AGPSIZ              0xa2
15173 @@ -184,7 +185,7 @@
15174  #define INTEL_I460_GATT_VALID          (1UL << 24)
15175  #define INTEL_I460_GATT_COHERENT       (1UL << 25)
15176  
15177 -/* intel i830 registers */
15178 +/* Intel i830 registers */
15179  #define I830_GMCH_CTRL                 0x52
15180  #define I830_GMCH_ENABLED              0x4
15181  #define I830_GMCH_MEM_MASK             0x1
15182 @@ -218,31 +219,31 @@
15183  #define I852_GME                       0x2
15184  #define I852_GM                                0x5
15185  
15186 -/* intel 815 register */
15187 +/* Intel 815 register */
15188  #define INTEL_815_APCONT       0x51
15189  #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
15190  
15191 -/* intel i820 registers */
15192 +/* Intel i820 registers */
15193  #define INTEL_I820_RDCR                0x51
15194  #define INTEL_I820_ERRSTS      0xc8
15195  
15196 -/* intel i840 registers */
15197 +/* Intel i840 registers */
15198  #define INTEL_I840_MCHCFG      0x50
15199  #define INTEL_I840_ERRSTS      0xc8
15200   
15201 -/* intel i845 registers */
15202 +/* Intel i845 registers */
15203  #define INTEL_I845_AGPM                0x51
15204  #define INTEL_I845_ERRSTS      0xc8
15205  
15206 -/* intel i850 registers */
15207 +/* Intel i850 registers */
15208  #define INTEL_I850_MCHCFG      0x50
15209  #define INTEL_I850_ERRSTS      0xc8
15210  
15211 -/* intel i860 registers */
15212 +/* Intel i860 registers */
15213  #define INTEL_I860_MCHCFG      0x50
15214  #define INTEL_I860_ERRSTS      0xc8
15215  
15216 -/* intel i810 registers */
15217 +/* Intel i810 registers */
15218  #define I810_GMADDR            0x10
15219  #define I810_MMADDR            0x14
15220  #define I810_PTE_BASE          0x10000
15221 @@ -261,7 +262,6 @@
15222  #define I810_DRAM_ROW_0_SDRAM  0x00000001
15223  
15224  /* Intel 7505 registers */
15225 -#define INTEL_I7505_NAPBASELO  0x10
15226  #define INTEL_I7505_APSIZE     0x74
15227  #define INTEL_I7505_NCAPID     0x60
15228  #define INTEL_I7505_NISTAT     0x6c
15229 @@ -271,26 +271,23 @@
15230  #define INTEL_I7505_MCHCFG     0x50
15231  
15232  /* VIA register */
15233 -#define VIA_APBASE     0x10
15234  #define VIA_GARTCTRL   0x80
15235  #define VIA_APSIZE     0x84
15236  #define VIA_ATTBASE    0x88
15237  
15238  /* VIA KT400 */
15239  #define VIA_AGP3_GARTCTRL      0x90
15240 -#define VIA_AGP3_APSIZE        0x94
15241 +#define VIA_AGP3_APSIZE                0x94
15242  #define VIA_AGP3_ATTBASE       0x98
15243 -#define VIA_AGPSEL     0xfd
15244 +#define VIA_AGPSEL             0xfd
15245  
15246  /* SiS registers */
15247 -#define SIS_APBASE     0x10
15248  #define SIS_ATTBASE    0x90
15249  #define SIS_APSIZE     0x94
15250  #define SIS_TLBCNTRL   0x97
15251  #define SIS_TLBFLUSH   0x98
15252  
15253  /* AMD registers */
15254 -#define AMD_APBASE     0x10
15255  #define AMD_MMBASE     0x14
15256  #define AMD_APSIZE     0xac
15257  #define AMD_MODECNTL   0xb0
15258 @@ -300,24 +297,14 @@
15259  #define AMD_TLBFLUSH   0x0c    /* In mmio region (32-bit register) */
15260  #define AMD_CACHEENTRY 0x10    /* In mmio region (32-bit register) */
15261  
15262 -#define AMD_8151_APSIZE        0xb4
15263 -#define AMD_8151_GARTBLOCK     0xb8
15264 -
15265 -#define AMD_X86_64_GARTAPERTURECTL     0x90
15266 -#define AMD_X86_64_GARTAPERTUREBASE    0x94
15267 -#define AMD_X86_64_GARTTABLEBASE       0x98
15268 -#define AMD_X86_64_GARTCACHECTL                0x9c
15269 -#define AMD_X86_64_GARTEN      1<<0
15270 -
15271 -#define AMD_8151_VMAPERTURE            0x10
15272 -#define AMD_8151_AGP_CTL               0xb0
15273 -#define AMD_8151_APERTURESIZE  0xb4
15274 -#define AMD_8151_GARTPTR               0xb8
15275 -#define AMD_8151_GTLBEN        1<<7
15276 -#define AMD_8151_APEREN        1<<8
15277 +/* AMD64 registers */
15278 +#define AMD64_GARTAPERTURECTL  0x90
15279 +#define AMD64_GARTAPERTUREBASE 0x94
15280 +#define AMD64_GARTTABLEBASE    0x98
15281 +#define AMD64_GARTCACHECTL             0x9c
15282 +#define AMD64_GARTEN           1<<0
15283  
15284  /* ALi registers */
15285 -#define ALI_APBASE                     0x10
15286  #define ALI_AGPCTRL                    0xb8
15287  #define ALI_ATTBASE                    0xbc
15288  #define ALI_TLBCTRL                    0xc0
15289 @@ -327,19 +314,17 @@
15290  #define ALI_CACHE_FLUSH_EN             0x100
15291  
15292  /* ATI register */
15293 -#define ATI_APBASE                  0x10
15294 -#define ATI_GART_MMBASE_ADDR        0x14
15295 -#define ATI_RS100_APSIZE            0xac
15296 -#define ATI_RS300_APSIZE            0xf8
15297 -#define ATI_RS100_IG_AGPMODE        0xb0
15298 -#define ATI_RS300_IG_AGPMODE        0xfc
15299 -
15300 -#define ATI_GART_FEATURE_ID         0x00
15301 -#define ATI_GART_BASE               0x04
15302 -#define ATI_GART_CACHE_SZBASE       0x08
15303 -#define ATI_GART_CACHE_CNTRL        0x0c
15304 -#define ATI_GART_CACHE_ENTRY_CNTRL  0x10
15305 -
15306 +#define ATI_GART_MMBASE_ADDR   0x14
15307 +#define ATI_RS100_APSIZE       0xac
15308 +#define ATI_RS300_APSIZE       0xf8
15309 +#define ATI_RS100_IG_AGPMODE   0xb0
15310 +#define ATI_RS300_IG_AGPMODE   0xfc
15311 +
15312 +#define ATI_GART_FEATURE_ID            0x00
15313 +#define ATI_GART_BASE                  0x04
15314 +#define ATI_GART_CACHE_SZBASE          0x08
15315 +#define ATI_GART_CACHE_CNTRL           0x0c
15316 +#define ATI_GART_CACHE_ENTRY_CNTRL     0x10
15317  
15318  /* Serverworks Registers */
15319  #define SVWRKS_APSIZE          0x10
15320 @@ -369,6 +354,17 @@
15321  #define HP_ZX1_PDIR_BASE       0x320
15322  #define HP_ZX1_CACHE_FLUSH     0x428
15323  
15324 +/* NVIDIA registers */
15325 +#define NVIDIA_0_APSIZE                0x80
15326 +#define NVIDIA_1_WBC           0xf0
15327 +#define NVIDIA_2_GARTCTRL      0xd0
15328 +#define NVIDIA_2_APBASE                0xd8
15329 +#define NVIDIA_2_APLIMIT       0xdc
15330 +#define NVIDIA_2_ATTBASE(i)    (0xe0 + (i) * 4)
15331 +#define NVIDIA_3_APBASE                0x50
15332 +#define NVIDIA_3_APLIMIT       0x54
15333 +
15334 +
15335  struct agp_device_ids {
15336         unsigned short device_id; /* first, to make table easier to read */
15337         enum chipset_type chipset;
15338 @@ -405,6 +401,9 @@
15339  void global_cache_flush(void);
15340  void get_agp_version(struct agp_bridge_data *bridge);
15341  unsigned long agp_generic_mask_memory(unsigned long addr, int type);
15342 +
15343 +extern int agp_off;
15344 +extern int agp_try_unsupported_boot;
15345  
15346  /* Standard agp registers */
15347  #define AGPSTAT                        0x4
15348 diff -Nru a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
15349 --- a/drivers/char/agp/ali-agp.c        Mon Aug 18 10:39:21 2003
15350 +++ b/drivers/char/agp/ali-agp.c        Thu Aug 28 16:44:18 2003
15351 @@ -76,7 +76,7 @@
15352         pci_write_config_dword(agp_bridge->dev, ALI_TLBCTRL, ((temp & 0xffffff00) | 0x00000010));
15353  
15354         /* address to map to */
15355 -       pci_read_config_dword(agp_bridge->dev, ALI_APBASE, &temp);
15356 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15357         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15358  
15359  #if 0
15360 diff -Nru a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
15361 --- a/drivers/char/agp/amd-k7-agp.c     Mon Aug 18 10:39:21 2003
15362 +++ b/drivers/char/agp/amd-k7-agp.c     Thu Aug 28 16:44:18 2003
15363 @@ -148,7 +148,7 @@
15364          * used to program the agp master not the cpu
15365          */
15366  
15367 -       pci_read_config_dword(agp_bridge->dev, AMD_APBASE, &temp);
15368 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15369         addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15370         agp_bridge->gart_bus_addr = addr;
15371  
15372 diff -Nru a/drivers/char/agp/amd-k8-agp.c b/drivers/char/agp/amd-k8-agp.c
15373 --- a/drivers/char/agp/amd-k8-agp.c     Thu Jul 31 08:58:45 2003
15374 +++ b/drivers/char/agp/amd-k8-agp.c     Thu Aug 28 18:04:31 2003
15375 @@ -8,12 +8,6 @@
15376   * work is done in the northbridge(s).
15377   */
15378  
15379 -/*
15380 - * On x86-64 the AGP driver needs to be initialized early by the IOMMU 
15381 - * code.  When you use this driver as a template for a new K8 AGP bridge
15382 - * driver don't forget to change arch/x86_64/kernel/pci-gart.c too -AK.
15383 - */
15384 -
15385  #include <linux/module.h>
15386  #include <linux/pci.h>
15387  #include <linux/init.h>
15388 @@ -21,7 +15,11 @@
15389  #include "agp.h"
15390  
15391  /* Will need to be increased if hammer ever goes >8-way. */
15392 +#ifdef CONFIG_SMP
15393  #define MAX_HAMMER_GARTS   8
15394 +#else
15395 +#define MAX_HAMMER_GARTS   1
15396 +#endif
15397  
15398  /* PTE bits. */
15399  #define GPTE_VALID     1
15400 @@ -39,6 +37,8 @@
15401  static int nr_garts;
15402  static struct pci_dev * hammers[MAX_HAMMER_GARTS];
15403  
15404 +static int __initdata agp_try_unsupported;
15405 +
15406  static int gart_iterator;
15407  #define for_each_nb() for(gart_iterator=0;gart_iterator<nr_garts;gart_iterator++)
15408  
15409 @@ -46,9 +46,9 @@
15410  {
15411         u32 tmp;
15412  
15413 -       pci_read_config_dword (dev, AMD_X86_64_GARTCACHECTL, &tmp);
15414 +       pci_read_config_dword (dev, AMD64_GARTCACHECTL, &tmp);
15415         tmp |= INVGART;
15416 -       pci_write_config_dword (dev, AMD_X86_64_GARTCACHECTL, tmp);
15417 +       pci_write_config_dword (dev, AMD64_GARTCACHECTL, tmp);
15418  }
15419  
15420  static void amd_x86_64_tlbflush(struct agp_memory *temp)
15421 @@ -135,7 +135,7 @@
15422         if (dev==NULL)
15423                 return 0;
15424  
15425 -       pci_read_config_dword(dev, AMD_X86_64_GARTAPERTURECTL, &temp);
15426 +       pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &temp);
15427         temp = (temp & 0xe);
15428         values = A_SIZE_32(x86_64_aperture_sizes);
15429  
15430 @@ -162,7 +162,7 @@
15431         u64 addr, aper_base;
15432  
15433         /* Address to map to */
15434 -       pci_read_config_dword (hammer, AMD_X86_64_GARTAPERTUREBASE, &tmp);
15435 +       pci_read_config_dword (hammer, AMD64_GARTAPERTUREBASE, &tmp);
15436         aperturebase = tmp << 25;
15437         aper_base = (aperturebase & PCI_BASE_ADDRESS_MEM_MASK);
15438  
15439 @@ -171,13 +171,13 @@
15440         addr >>= 12;
15441         tmp = (u32) addr<<4;
15442         tmp &= ~0xf;
15443 -       pci_write_config_dword (hammer, AMD_X86_64_GARTTABLEBASE, tmp);
15444 +       pci_write_config_dword (hammer, AMD64_GARTTABLEBASE, tmp);
15445  
15446         /* Enable GART translation for this hammer. */
15447 -       pci_read_config_dword(hammer, AMD_X86_64_GARTAPERTURECTL, &tmp);
15448 +       pci_read_config_dword(hammer, AMD64_GARTAPERTURECTL, &tmp);
15449         tmp |= GARTEN;
15450         tmp &= ~(DISGARTCPU | DISGARTIO);
15451 -       pci_write_config_dword(hammer, AMD_X86_64_GARTAPERTURECTL, tmp);
15452 +       pci_write_config_dword(hammer, AMD64_GARTAPERTURECTL, tmp);
15453  
15454         /* keep CPU's coherent. */
15455         flush_x86_64_tlb (hammer);
15456 @@ -216,9 +216,9 @@
15457  
15458         for_each_nb() {
15459                 /* disable gart translation */
15460 -               pci_read_config_dword (hammers[gart_iterator], AMD_X86_64_GARTAPERTURECTL, &tmp);
15461 -               tmp &= ~(AMD_X86_64_GARTEN);
15462 -               pci_write_config_dword (hammers[gart_iterator], AMD_X86_64_GARTAPERTURECTL, tmp);
15463 +               pci_read_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, &tmp);
15464 +               tmp &= ~AMD64_GARTEN;
15465 +               pci_write_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, tmp);
15466         }
15467  }
15468  
15469 @@ -246,24 +246,123 @@
15470         .agp_destroy_page       = agp_generic_destroy_page,
15471  };
15472  
15473 +/* Some basic sanity checks for the aperture. */
15474 +static int __init aperture_valid(u64 aper, u32 size)
15475 +{ 
15476 +       static int not_first_call; 
15477 +       u32 pfn, c;
15478 +       if (aper == 0) { 
15479 +               printk(KERN_ERR "No aperture\n");
15480 +               return 0; 
15481 +       }
15482 +       if (size < 32*1024*1024) {
15483 +               printk(KERN_ERR "Aperture too small (%d MB)\n", size>>20);
15484 +               return 0;
15485 +       }
15486 +       if (aper + size > 0xffffffff) { 
15487 +               printk(KERN_ERR "Aperture out of bounds\n"); 
15488 +               return 0;
15489 +       } 
15490 +       pfn = aper >> PAGE_SHIFT;
15491 +       for (c = 0; c < size/PAGE_SIZE; c++) { 
15492 +               if (!pfn_valid(pfn + c))
15493 +                       break;
15494 +               if (!PageReserved(pfn_to_page(pfn + c))) { 
15495 +                       printk(KERN_ERR "Aperture pointing to RAM\n");
15496 +                       return 0;
15497 +               }
15498 +       }
15499  
15500 -#ifdef CONFIG_SMP
15501 -static int cache_nbs (void)
15502 +       /* Request the Aperture. This catches cases when someone else
15503 +          already put a mapping in there - happens with some very broken BIOS 
15504 +
15505 +          Maybe better to use pci_assign_resource/pci_enable_device instead trusting
15506 +          the bridges? */
15507 +       if (!not_first_call && request_mem_region(aper, size, "aperture") < 0) { 
15508 +               printk(KERN_ERR "Aperture conflicts with PCI mapping.\n"); 
15509 +               return 0;
15510 +       }
15511 +
15512 +       not_first_call = 1;
15513 +       return 1;
15514 +} 
15515 +
15516 +/* 
15517 + * W*s centric BIOS sometimes only set up the aperture in the AGP
15518 + * bridge, not the northbridge. On AMD64 this is handled early 
15519 + * in aperture.c, but when GART_IOMMU is not enabled or we run
15520 + * on a 32bit kernel this needs to be redone. 
15521 + * Unfortunately it is impossible to fix the aperture here because it's too late
15522 + * to allocate that much memory. But at least error out cleanly instead of
15523 + * crashing.
15524 + */ 
15525 +static __init int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, 
15526 +                                                                u16 cap)
15527 +{
15528 +       u32 aper_low, aper_hi;
15529 +       u64 aper, nb_aper;
15530 +       int order = 0;
15531 +       u32 nb_order, nb_base;
15532 +       u16 apsize;
15533 +
15534 +       pci_read_config_dword(nb, 0x90, &nb_order); 
15535 +       nb_order = (nb_order >> 1) & 7;
15536 +       pci_read_config_dword(nb, 0x94, &nb_base); 
15537 +       nb_aper = nb_base << 25;        
15538 +       if (aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) { 
15539 +               return 0;
15540 +       }
15541 +
15542 +       /* Northbridge seems to contain crap. Try the AGP bridge. */
15543 +
15544 +       pci_read_config_word(agp, cap+0x14, &apsize); 
15545 +       if (apsize == 0xffff) 
15546 +               return -1; 
15547 +
15548 +       apsize &= 0xfff;
15549 +       /* Some BIOS use weird encodings not in the AGPv3 table. */
15550 +       if (apsize & 0xff) 
15551 +               apsize |= 0xf00; 
15552 +       order = 7 - hweight16(apsize); 
15553 +
15554 +       pci_read_config_dword(agp, 0x10, &aper_low);
15555 +       pci_read_config_dword(agp, 0x14, &aper_hi);
15556 +       aper = (aper_low & ~((1<<22)-1)) | ((u64)aper_hi << 32); 
15557 +       printk(KERN_INFO "Aperture from AGP @ %Lx size %u MB\n", aper, 32 << order);
15558 +       if (order < 0 || !aperture_valid(aper, (32*1024*1024)<<order))
15559 +               return -1; 
15560 +       
15561 +       pci_write_config_dword(nb, 0x90, order << 1); 
15562 +       pci_write_config_dword(nb, 0x94, aper >> 25); 
15563 +
15564 +       return 0;
15565 +} 
15566 +
15567 +static __init int cache_nbs (struct pci_dev *pdev, u32 cap_ptr)
15568  {
15569         struct pci_dev *loop_dev = NULL;
15570         int i = 0;
15571  
15572         /* cache pci_devs of northbridges. */
15573 -       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) != NULL) {
15574 +       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) 
15575 +                       != NULL) {
15576 +               if (fix_northbridge(loop_dev, pdev, cap_ptr) < 0) { 
15577 +                       printk("No usable aperture found.\n");
15578 +#ifdef __x86_64__ 
15579 +                       /* should port this to i386 */
15580 +                       printk("Consider rebooting with iommu=memaper=2 to get a good aperture.\n");
15581 +#endif 
15582 +                       return -1;  
15583 +               }
15584                 hammers[i++] = loop_dev;
15585                 nr_garts = i;
15586 -               if (i == MAX_HAMMER_GARTS)
15587 +               if (i == MAX_HAMMER_GARTS) { 
15588 +                       printk(KERN_INFO "Too many northbridges for AGP\n");
15589                         return -1;
15590 +               }
15591         }
15592 -       return 0;
15593 +       return i == 0 ? -1 : 0;
15594  }
15595 -#endif
15596 -
15597  
15598  static int __init agp_amdk8_probe(struct pci_dev *pdev,
15599                                   const struct pci_device_id *ent)
15600 @@ -277,7 +376,7 @@
15601         if (!cap_ptr)
15602                 return -ENODEV;
15603  
15604 -       printk(KERN_INFO PFX "Detected Opteron/Athlon64 on-CPU GART\n");
15605 +       /* Could check for AGPv3 here */
15606  
15607         bridge = agp_alloc_bridge();
15608         if (!bridge)
15609 @@ -311,6 +410,9 @@
15610                         bridge->major_version = 3;
15611                         bridge->minor_version = 0;
15612                 }
15613 +       } else {
15614 +               printk(KERN_INFO PFX "Detected AGP bridge %x\n",
15615 +                       pdev->devfn);
15616         }
15617  
15618         bridge->driver = &amd_8151_driver;
15619 @@ -320,22 +422,10 @@
15620         /* Fill in the mode register */
15621         pci_read_config_dword(pdev, bridge->capndx+PCI_AGP_STATUS, &bridge->mode);
15622  
15623 -#ifdef CONFIG_SMP
15624 -       if (cache_nbs() == -1) {
15625 +       if (cache_nbs(pdev, cap_ptr) == -1) {
15626                 agp_put_bridge(bridge);
15627 -               return -ENOMEM;
15628 -       }
15629 -#else
15630 -       {
15631 -       struct pci_dev *loop_dev = NULL;
15632 -       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) != NULL) {
15633 -               /* For UP, we only care about the first GART. */
15634 -               hammers[0] = loop_dev;
15635 -               nr_garts = 1;
15636 -               break;
15637 -       }
15638 +               return -ENODEV;
15639         }
15640 -#endif
15641  
15642         pci_set_drvdata(pdev, bridge);
15643         return agp_add_bridge(bridge);
15644 @@ -345,6 +435,8 @@
15645  {
15646         struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
15647  
15648 +       release_mem_region(virt_to_phys(bridge->gatt_table_real), 
15649 +                          x86_64_aperture_sizes[bridge->aperture_size_idx].size); 
15650         agp_remove_bridge(bridge);
15651         agp_put_bridge(bridge);
15652  }
15653 @@ -358,11 +450,21 @@
15654         .subvendor      = PCI_ANY_ID,
15655         .subdevice      = PCI_ANY_ID,
15656         },
15657 +       /* VIA K8T800 */
15658         {
15659         .class          = (PCI_CLASS_BRIDGE_HOST << 8),
15660         .class_mask     = ~0,
15661         .vendor         = PCI_VENDOR_ID_VIA,
15662 -       .device         = PCI_DEVICE_ID_VIA_K8T400M_0,
15663 +       .device         = PCI_DEVICE_ID_VIA_8385_0,
15664 +       .subvendor      = PCI_ANY_ID,
15665 +       .subdevice      = PCI_ANY_ID,
15666 +       },
15667 +       /* VIA K8M800 / K8N800 */
15668 +       {
15669 +       .class          = (PCI_CLASS_BRIDGE_HOST << 8),
15670 +       .class_mask     = ~0,
15671 +       .vendor         = PCI_VENDOR_ID_VIA,
15672 +       .device         = PCI_DEVICE_ID_VIA_8380_0,
15673         .subvendor      = PCI_ANY_ID,
15674         .subdevice      = PCI_ANY_ID,
15675         },
15676 @@ -386,10 +488,43 @@
15677         .remove         = agp_amdk8_remove,
15678  };
15679  
15680 +
15681  /* Not static due to IOMMU code calling it early. */
15682  int __init agp_amdk8_init(void)
15683  {
15684 -       return pci_module_init(&agp_amdk8_pci_driver);
15685 +       int err = 0;
15686 +       if (agp_off)
15687 +               return -EINVAL;
15688 +       if (pci_module_init(&agp_amdk8_pci_driver) == 0) { 
15689 +               struct pci_dev *dev;
15690 +               if (!agp_try_unsupported && !agp_try_unsupported_boot) { 
15691 +                       printk(KERN_INFO "No supported AGP bridge found.\n");
15692 +#ifdef MODULE                  
15693 +                       printk(KERN_INFO "You can try agp_try_unsupported=1\n");
15694 +#else
15695 +                       printk(KERN_INFO "You can boot with agp=try_unsupported\n");
15696 +#endif                 
15697 +                       return -ENODEV;
15698 +               }
15699 +
15700 +               /* First check that we have at least one K8 NB */
15701 +               if (!pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, NULL))
15702 +                       return -ENODEV;
15703 +
15704 +               /* Look for any AGP bridge */
15705 +               dev = NULL;
15706 +               err = -ENODEV;
15707 +               while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev))) {
15708 +                       if (!pci_find_capability(dev, PCI_CAP_ID_AGP))
15709 +                               continue;
15710 +                       /* Only one bridge supported right now */       
15711 +                       if (agp_amdk8_probe(dev, NULL) == 0) {
15712 +                               err = 0;
15713 +                               break;
15714 +                       }       
15715 +               }               
15716 +       }
15717 +       return err;
15718  }
15719  
15720  static void __exit agp_amdk8_cleanup(void)
15721 @@ -404,6 +539,6 @@
15722  module_exit(agp_amdk8_cleanup);
15723  #endif
15724  
15725 -MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
15726 +MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>, Andi Kleen");
15727 +MODULE_PARM(agp_try_unsupported, "1i");
15728  MODULE_LICENSE("GPL and additional rights");
15729 -
15730 diff -Nru a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
15731 --- a/drivers/char/agp/ati-agp.c        Mon Aug 18 10:39:21 2003
15732 +++ b/drivers/char/agp/ati-agp.c        Thu Aug 28 16:44:18 2003
15733 @@ -1,5 +1,5 @@
15734  /*
15735 - * ALi AGPGART routines.
15736 + * ATi AGPGART routines.
15737   */
15738  
15739  #include <linux/types.h>
15740 @@ -212,7 +212,7 @@
15741  
15742         /* address to map too */
15743          /*
15744 -       pci_read_config_dword(agp_bridge.dev, ATI_APBASE, &temp);
15745 +       pci_read_config_dword(agp_bridge.dev, AGP_APBASE, &temp);
15746         agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15747         printk(KERN_INFO "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr);
15748          */
15749 @@ -355,7 +355,7 @@
15750          * This is a bus address even on the alpha, b/c its
15751          * used to program the agp master not the cpu
15752          */
15753 -       pci_read_config_dword(agp_bridge->dev, ATI_APBASE, &temp);
15754 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15755         addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15756         agp_bridge->gart_bus_addr = addr;
15757  
15758 diff -Nru a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
15759 --- a/drivers/char/agp/backend.c        Wed Aug 13 10:20:16 2003
15760 +++ b/drivers/char/agp/backend.c        Thu Aug 28 16:22:00 2003
15761 @@ -301,9 +301,14 @@
15762  }
15763  EXPORT_SYMBOL_GPL(agp_remove_bridge);
15764  
15765 +int agp_off;
15766 +int agp_try_unsupported_boot;
15767 +EXPORT_SYMBOL(agp_off);
15768 +EXPORT_SYMBOL(agp_try_unsupported_boot);
15769  
15770  static int __init agp_init(void)
15771  {
15772 +       if (!agp_off) 
15773         printk(KERN_INFO "Linux agpgart interface v%d.%d (c) Dave Jones\n",
15774                AGPGART_VERSION_MAJOR, AGPGART_VERSION_MINOR);
15775         return 0;
15776 @@ -313,6 +318,15 @@
15777  {
15778  }
15779  
15780 +static __init int agp_setup(char *s)
15781 +{
15782 +       if (!strcmp(s,"off"))
15783 +               agp_off = 1;
15784 +       if (!strcmp(s,"try_unsupported"))
15785 +               agp_try_unsupported_boot = 1;
15786 +       return 1;       
15787 +}
15788 +__setup("agp=", agp_setup);
15789  
15790  MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
15791  MODULE_DESCRIPTION("AGP GART driver");
15792 diff -Nru a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
15793 --- a/drivers/char/agp/frontend.c       Sun Jul 13 05:36:05 2003
15794 +++ b/drivers/char/agp/frontend.c       Tue Aug 26 09:25:41 2003
15795 @@ -698,7 +698,7 @@
15796  
15797  static int agp_open(struct inode *inode, struct file *file)
15798  {
15799 -       int minor = minor(inode->i_rdev);
15800 +       int minor = iminor(inode);
15801         struct agp_file_private *priv;
15802         struct agp_client *client;
15803         int rc = -ENXIO;
15804 diff -Nru a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
15805 --- a/drivers/char/agp/generic.c        Wed Aug 13 01:35:50 2003
15806 +++ b/drivers/char/agp/generic.c        Wed Aug 27 11:06:10 2003
15807 @@ -577,12 +577,12 @@
15808                         agp_device_command(command, TRUE);
15809                         return;
15810                 } else {
15811 -                   /* Disable calibration cycle in RX91<1> when not in AGP3.0 mode of operation.*/            
15812 +                   /* Disable calibration cycle in RX91<1> when not in AGP3.0 mode of operation.*/
15813                     command &= ~(7<<10) ;
15814                     pci_read_config_dword(agp_bridge->dev, agp_bridge->capndx+AGPCTRL, &temp);
15815                     temp |= (1<<9);
15816                     pci_write_config_dword(agp_bridge->dev, agp_bridge->capndx+AGPCTRL, temp);
15817 -                   
15818 +
15819                     printk (KERN_INFO PFX "Device is in legacy mode,"
15820                                 " falling back to 2.x\n");
15821                 }
15822 diff -Nru a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
15823 --- a/drivers/char/agp/intel-agp.c      Fri Aug 15 07:25:05 2003
15824 +++ b/drivers/char/agp/intel-agp.c      Thu Aug 28 16:44:18 2003
15825 @@ -618,7 +618,7 @@
15826         pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
15827  
15828         /* address to map to */
15829 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15830 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15831         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15832  
15833         /* attbase - aperture base */
15834 @@ -657,7 +657,7 @@
15835                         current_size->size_value); 
15836  
15837         /* address to map to */
15838 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15839 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15840         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15841  
15842         pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr);
15843 @@ -708,7 +708,7 @@
15844         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
15845  
15846         /* address to map to */
15847 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15848 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15849         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15850  
15851         /* attbase - aperture base */
15852 @@ -739,7 +739,7 @@
15853         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
15854  
15855         /* address to map to */
15856 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15857 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15858         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15859  
15860         /* attbase - aperture base */
15861 @@ -768,7 +768,7 @@
15862         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
15863  
15864         /* address to map to */
15865 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15866 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15867         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15868  
15869         /* attbase - aperture base */
15870 @@ -797,7 +797,7 @@
15871         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
15872  
15873         /* address to map to */
15874 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15875 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15876         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15877  
15878         /* attbase - aperture base */
15879 @@ -826,7 +826,7 @@
15880         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
15881  
15882         /* address to map to */
15883 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15884 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15885         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15886  
15887         /* attbase - aperture base */
15888 @@ -855,7 +855,7 @@
15889         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
15890  
15891         /* address to map to */
15892 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15893 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15894         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15895  
15896         /* attbase - aperture base */
15897 @@ -884,7 +884,7 @@
15898         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
15899  
15900         /* address to map to */
15901 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15902 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15903         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15904  
15905         /* attbase - aperture base */
15906 diff -Nru a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
15907 --- a/drivers/char/agp/nvidia-agp.c     Fri Aug 15 07:22:22 2003
15908 +++ b/drivers/char/agp/nvidia-agp.c     Thu Aug 28 16:56:50 2003
15909 @@ -13,18 +13,6 @@
15910  #include <linux/mm.h>
15911  #include "agp.h"
15912  
15913 -
15914 -/* registers */
15915 -#define NVIDIA_0_APBASE                0x10
15916 -#define NVIDIA_0_APSIZE                0x80
15917 -#define NVIDIA_1_WBC           0xf0
15918 -#define NVIDIA_2_GARTCTRL      0xd0
15919 -#define NVIDIA_2_APBASE                0xd8
15920 -#define NVIDIA_2_APLIMIT       0xdc
15921 -#define NVIDIA_2_ATTBASE(i)    (0xe0 + (i) * 4)
15922 -#define NVIDIA_3_APBASE                0x50
15923 -#define NVIDIA_3_APLIMIT       0x54
15924 -
15925  static struct _nvidia_private {
15926         struct pci_dev *dev_1;
15927         struct pci_dev *dev_2;
15928 @@ -73,7 +61,7 @@
15929                 current_size->size_value);
15930  
15931      /* address to map to */
15932 -       pci_read_config_dword(agp_bridge->dev, NVIDIA_0_APBASE, &apbase);
15933 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &apbase);
15934         apbase &= PCI_BASE_ADDRESS_MEM_MASK;
15935         agp_bridge->gart_bus_addr = apbase;
15936         aplimit = apbase + (current_size->size * 1024 * 1024) - 1;
15937 diff -Nru a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
15938 --- a/drivers/char/agp/sis-agp.c        Mon Aug 18 10:39:21 2003
15939 +++ b/drivers/char/agp/sis-agp.c        Thu Aug 28 16:44:18 2003
15940 @@ -43,7 +43,7 @@
15941  
15942         current_size = A_SIZE_8(agp_bridge->current_size);
15943         pci_write_config_byte(agp_bridge->dev, SIS_TLBCNTRL, 0x05);
15944 -       pci_read_config_dword(agp_bridge->dev, SIS_APBASE, &temp);
15945 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15946         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15947         pci_write_config_dword(agp_bridge->dev, SIS_ATTBASE,
15948                                agp_bridge->gatt_bus_addr);
15949 diff -Nru a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
15950 --- a/drivers/char/agp/via-agp.c        Wed Aug 13 01:41:04 2003
15951 +++ b/drivers/char/agp/via-agp.c        Thu Aug 28 17:14:45 2003
15952 @@ -39,7 +39,7 @@
15953         pci_write_config_byte(agp_bridge->dev, VIA_APSIZE,
15954                               current_size->size_value);
15955         /* address to map too */
15956 -       pci_read_config_dword(agp_bridge->dev, VIA_APBASE, &temp);
15957 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15958         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15959  
15960         /* GART control register */
15961 @@ -114,7 +114,7 @@
15962         current_size = A_SIZE_16(agp_bridge->current_size);
15963  
15964         /* address to map too */
15965 -       pci_read_config_dword(agp_bridge->dev, VIA_APBASE, &temp);
15966 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15967         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15968  
15969         /* attbase - aperture GATT base */
15970 @@ -215,52 +215,52 @@
15971  {
15972         {
15973                 .device_id      = PCI_DEVICE_ID_VIA_82C597_0,
15974 -               .chipset_name   = "VP3",
15975 +               .chipset_name   = "Apollo VP3",
15976         },
15977  
15978         {
15979                 .device_id      = PCI_DEVICE_ID_VIA_82C598_0,
15980 -               .chipset_name   = "MVP3",
15981 +               .chipset_name   = "Apollo MVP3",
15982         },
15983  
15984         {
15985                 .device_id      = PCI_DEVICE_ID_VIA_8501_0,
15986 -               .chipset_name   = "MVP4",
15987 +               .chipset_name   = "Apollo MVP4",
15988         },
15989  
15990         /* VT8601 */
15991         {
15992                 .device_id      = PCI_DEVICE_ID_VIA_8601_0,
15993 -               .chipset_name   = "PLE133 ProMedia",
15994 +               .chipset_name   = "Apollo ProMedia/PLE133Ta",
15995         },
15996  
15997         /* VT82C693A / VT28C694T */
15998         {
15999 -               .device_id      = PCI_DEVICE_ID_VIA_82C691,
16000 +               .device_id      = PCI_DEVICE_ID_VIA_82C691_0,
16001                 .chipset_name   = "Apollo Pro 133",
16002         },
16003  
16004         {
16005                 .device_id      = PCI_DEVICE_ID_VIA_8371_0,
16006 -               .chipset_name   = "Apollo Pro KX133",
16007 +               .chipset_name   = "KX133",
16008         },
16009  
16010         /* VT8633 */
16011         {
16012                 .device_id      = PCI_DEVICE_ID_VIA_8633_0,
16013 -               .chipset_name   = "Apollo Pro 266",
16014 +               .chipset_name   = "Pro 266",
16015         },
16016  
16017         /* VT8361 */
16018         {
16019                 .device_id      = PCI_DEVICE_ID_VIA_8361,
16020 -               .chipset_name   = "Apollo KLE133",
16021 +               .chipset_name   = "KLE133",
16022         },
16023  
16024         /* VT8365 / VT8362 */
16025         {
16026                 .device_id      = PCI_DEVICE_ID_VIA_8363_0,
16027 -               .chipset_name   = "Apollo Pro KT133/KM133/TwisterK",
16028 +               .chipset_name   = "Twister-K/KT133x/KM133",
16029         },
16030  
16031         /* VT8753A */
16032 @@ -272,79 +272,79 @@
16033         /* VT8366 */
16034         {
16035                 .device_id      = PCI_DEVICE_ID_VIA_8367_0,
16036 -               .chipset_name   = "Apollo Pro KT266/KT333",
16037 +               .chipset_name   = "KT266/KY266x/KT333",
16038         },
16039  
16040         /* VT8633 (for CuMine/ Celeron) */
16041         {
16042                 .device_id      = PCI_DEVICE_ID_VIA_8653_0,
16043 -               .chipset_name   = "Apollo Pro 266T",
16044 +               .chipset_name   = "Pro266T",
16045         },
16046  
16047         /* KM266 / PM266 */
16048         {
16049 -               .device_id      = PCI_DEVICE_ID_VIA_KM266,
16050 -               .chipset_name   = "KM266/PM266",
16051 +               .device_id      = PCI_DEVICE_ID_VIA_XM266,
16052 +               .chipset_name   = "PM266/KM266",
16053         },
16054  
16055         /* CLE266 */
16056         {
16057 -               .device_id      = PCI_DEVICE_ID_VIA_CLE266,
16058 +               .device_id      = PCI_DEVICE_ID_VIA_862X_0,
16059                 .chipset_name   = "CLE266",
16060         },
16061  
16062         {
16063                 .device_id      = PCI_DEVICE_ID_VIA_8377_0,
16064 -               .chipset_name   = "Apollo Pro KT400",
16065 +               .chipset_name   = "KT400/KT400A/KT600",
16066         },
16067  
16068 -       /* VT8604 / VT8605 / VT8603 / TwisterT
16069 +       /* VT8604 / VT8605 / VT8603
16070          * (Apollo Pro133A chipset with S3 Savage4) */
16071         {
16072 -               .device_id      = PCI_DEVICE_ID_VIA_82C694X_0,
16073 -               .chipset_name   = "Apollo ProSavage PM133/PL133/PN133/Twister"
16074 +               .device_id      = PCI_DEVICE_ID_VIA_8605_0,
16075 +               .chipset_name   = "ProSavage PM133/PL133/PN133"
16076         },
16077  
16078 -       /* VT8752*/
16079 +       /* P4M266x/P4N266 */
16080         {
16081 -               .device_id      = PCI_DEVICE_ID_VIA_8752,
16082 -               .chipset_name   = "ProSavage DDR P4M266",
16083 +               .device_id      = PCI_DEVICE_ID_VIA_8703_51_0,
16084 +               .chipset_name   = "P4M266x/P4N266",
16085         },
16086  
16087 -       /* KN266/PN266 */
16088 +       /* VT8754 */
16089         {
16090 -               .device_id      = PCI_DEVICE_ID_VIA_KN266,
16091 -               .chipset_name   = "KN266/PN266",
16092 +               .device_id      = PCI_DEVICE_ID_VIA_8754C_0,
16093 +               .chipset_name   = "PT800",
16094         },
16095  
16096 -       /* VT8754 */
16097 +       /* P4X600 */
16098         {
16099 -               .device_id      = PCI_DEVICE_ID_VIA_8754,
16100 -               .chipset_name   = "Apollo P4X333/P4X400"
16101 +               .device_id      = PCI_DEVICE_ID_VIA_8763_0,
16102 +               .chipset_name   = "P4X600"
16103         },
16104  
16105 -       /* P4N333 */
16106 +       /* KM400 */
16107         {
16108 -               .device_id      = PCI_DEVICE_ID_VIA_P4N333,
16109 -               .chipset_name   = "P4N333",
16110 +               .device_id      = PCI_DEVICE_ID_VIA_8378_0,
16111 +               .chipset_name   = "KM400/KM400A",
16112         },
16113  
16114 -       /* P4X600 */
16115 +       /* PT880 */
16116         {
16117 -               .device_id      = PCI_DEVICE_ID_VIA_P4X600,
16118 -               .chipset_name   = "P4X600",
16119 +               .device_id      = PCI_DEVICE_ID_VIA_PT880,
16120 +               .chipset_name   = "PT880",
16121         },
16122  
16123 -       /* KM400 */
16124 +       /* PT890 */
16125         {
16126 -               .device_id      = PCI_DEVICE_ID_VIA_KM400,
16127 -               .chipset_name   = "KM400",
16128 +               .device_id      = PCI_DEVICE_ID_VIA_8783_0,
16129 +               .chipset_name   = "PT890",
16130         },
16131  
16132 -       /* P4M400 */
16133 +       /* PM800/PN800/PM880/PN880 */
16134         {
16135 -               .device_id      = PCI_DEVICE_ID_VIA_P4M400,
16136 -               .chipset_name   = "P4M400",
16137 +               .device_id      = PCI_DEVICE_ID_VIA_PX8X0_0,
16138 +               .chipset_name   = "PM800/PN800/PM880/PN880",
16139         },
16140  
16141         { }, /* dummy final entry, always present */
16142 diff -Nru a/drivers/char/busmouse.c b/drivers/char/busmouse.c
16143 --- a/drivers/char/busmouse.c   Fri Jul 11 23:17:17 2003
16144 +++ b/drivers/char/busmouse.c   Tue Aug 26 09:25:41 2003
16145 @@ -51,7 +51,7 @@
16146  
16147  #define NR_MICE                        15
16148  #define FIRST_MOUSE            0
16149 -#define DEV_TO_MOUSE(dev)      MINOR_TO_MOUSE(minor(dev))
16150 +#define DEV_TO_MOUSE(inode)    MINOR_TO_MOUSE(iminor(inode))
16151  #define MINOR_TO_MOUSE(minor)  ((minor) - FIRST_MOUSE)
16152  
16153  /*
16154 @@ -190,7 +190,7 @@
16155         unsigned int mousedev;
16156         int ret;
16157  
16158 -       mousedev = DEV_TO_MOUSE(inode->i_rdev);
16159 +       mousedev = DEV_TO_MOUSE(inode);
16160         if (mousedev >= NR_MICE)
16161                 return -EINVAL;
16162  
16163 diff -Nru a/drivers/char/cyclades.c b/drivers/char/cyclades.c
16164 --- a/drivers/char/cyclades.c   Fri Aug  1 02:20:44 2003
16165 +++ b/drivers/char/cyclades.c   Sun Aug 31 16:14:39 2003
16166 @@ -1050,14 +1050,14 @@
16167      udelay(5000L);
16168  
16169      /* Enable the Tx interrupts on the CD1400 */
16170 -    save_flags(flags); cli();
16171 +    local_irq_save(flags);
16172         cy_writeb((u_long)address + (CyCAR<<index), 0);
16173         cyy_issue_cmd(address, CyCHAN_CTL|CyENB_XMTR, index);
16174  
16175         cy_writeb((u_long)address + (CyCAR<<index), 0);
16176         cy_writeb((u_long)address + (CySRER<<index), 
16177                 cy_readb(address + (CySRER<<index)) | CyTxRdy);
16178 -    restore_flags(flags);
16179 +    local_irq_restore(flags);
16180  
16181      /* Wait ... */
16182      udelay(5000L);
16183 @@ -5665,7 +5665,7 @@
16184  cy_cleanup_module(void)
16185  {
16186      int i;
16187 -    int e1;
16188 +    int e1, e2;
16189      unsigned long flags;
16190  
16191  #ifndef CONFIG_CYZ_INTR
16192 @@ -5675,13 +5675,10 @@
16193      }
16194  #endif /* CONFIG_CYZ_INTR */
16195  
16196 -    save_flags(flags); cli();
16197 -
16198      if ((e1 = tty_unregister_driver(cy_serial_driver)))
16199              printk("cyc: failed to unregister Cyclades serial driver(%d)\n",
16200                 e1);
16201  
16202 -    restore_flags(flags);
16203      put_tty_driver(cy_serial_driver);
16204  
16205      for (i = 0; i < NR_CARDS; i++) {
16206 diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
16207 --- a/drivers/char/drm/drm_drv.h        Thu Aug  7 15:37:26 2003
16208 +++ b/drivers/char/drm/drm_drv.h        Tue Aug 26 09:25:41 2003
16209 @@ -795,7 +795,7 @@
16210         int i;
16211  
16212         for (i = 0; i < DRM(numdevs); i++) {
16213 -               if (minor(inode->i_rdev) == DRM(minor)[i]) {
16214 +               if (iminor(inode) == DRM(minor)[i]) {
16215                         dev = &(DRM(device)[i]);
16216                         break;
16217                 }
16218 diff -Nru a/drivers/char/drm/drm_fops.h b/drivers/char/drm/drm_fops.h
16219 --- a/drivers/char/drm/drm_fops.h       Thu Jul 10 23:18:01 2003
16220 +++ b/drivers/char/drm/drm_fops.h       Tue Aug 26 09:25:41 2003
16221 @@ -51,7 +51,7 @@
16222   */
16223  int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
16224  {
16225 -       int          minor = minor(inode->i_rdev);
16226 +       int          minor = iminor(inode);
16227         drm_file_t   *priv;
16228  
16229         if (filp->f_flags & O_EXCL)   return -EBUSY; /* No exclusive opens */
16230 diff -Nru a/drivers/char/drm/drm_stub.h b/drivers/char/drm/drm_stub.h
16231 --- a/drivers/char/drm/drm_stub.h       Thu Jul 10 23:18:01 2003
16232 +++ b/drivers/char/drm/drm_stub.h       Tue Aug 26 09:25:41 2003
16233 @@ -62,7 +62,7 @@
16234   */
16235  static int DRM(stub_open)(struct inode *inode, struct file *filp)
16236  {
16237 -       int                    minor = minor(inode->i_rdev);
16238 +       int                    minor = iminor(inode);
16239         int                    err   = -ENODEV;
16240         struct file_operations *old_fops;
16241  
16242 diff -Nru a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
16243 --- a/drivers/char/dsp56k.c     Wed May  7 08:47:29 2003
16244 +++ b/drivers/char/dsp56k.c     Tue Aug 26 09:25:41 2003
16245 @@ -207,7 +207,7 @@
16246                            loff_t *ppos)
16247  {
16248         struct inode *inode = file->f_dentry->d_inode;
16249 -       int dev = minor(inode->i_rdev) & 0x0f;
16250 +       int dev = iminor(inode) & 0x0f;
16251  
16252         switch(dev)
16253         {
16254 @@ -270,7 +270,7 @@
16255                             loff_t *ppos)
16256  {
16257         struct inode *inode = file->f_dentry->d_inode;
16258 -       int dev = minor(inode->i_rdev) & 0x0f;
16259 +       int dev = iminor(inode) & 0x0f;
16260  
16261         switch(dev)
16262         {
16263 @@ -331,7 +331,7 @@
16264  static int dsp56k_ioctl(struct inode *inode, struct file *file,
16265                         unsigned int cmd, unsigned long arg)
16266  {
16267 -       int dev = minor(inode->i_rdev) & 0x0f;
16268 +       int dev = iminor(inode) & 0x0f;
16269  
16270         switch(dev)
16271         {
16272 @@ -424,7 +424,7 @@
16273  #if 0
16274  static unsigned int dsp56k_poll(struct file *file, poll_table *wait)
16275  {
16276 -       int dev = minor(file->f_dentry->d_inode->i_rdev) & 0x0f;
16277 +       int dev = iminor(file->f_dentry->d_inode) & 0x0f;
16278  
16279         switch(dev)
16280         {
16281 @@ -441,7 +441,7 @@
16282  
16283  static int dsp56k_open(struct inode *inode, struct file *file)
16284  {
16285 -       int dev = minor(inode->i_rdev) & 0x0f;
16286 +       int dev = iminor(inode) & 0x0f;
16287  
16288         switch(dev)
16289         {
16290 @@ -472,7 +472,7 @@
16291  
16292  static int dsp56k_release(struct inode *inode, struct file *file)
16293  {
16294 -       int dev = minor(inode->i_rdev) & 0x0f;
16295 +       int dev = iminor(inode) & 0x0f;
16296  
16297         switch(dev)
16298         {
16299 diff -Nru a/drivers/char/dtlk.c b/drivers/char/dtlk.c
16300 --- a/drivers/char/dtlk.c       Fri Jul 11 06:34:28 2003
16301 +++ b/drivers/char/dtlk.c       Tue Aug 26 09:25:41 2003
16302 @@ -125,7 +125,7 @@
16303  static ssize_t dtlk_read(struct file *file, char *buf,
16304                          size_t count, loff_t * ppos)
16305  {
16306 -       unsigned int minor = minor(file->f_dentry->d_inode->i_rdev);
16307 +       unsigned int minor = iminor(file->f_dentry->d_inode);
16308         char ch;
16309         int i = 0, retries;
16310  
16311 @@ -185,7 +185,7 @@
16312         if (ppos != &file->f_pos)
16313                 return -ESPIPE;
16314  
16315 -       if (minor(file->f_dentry->d_inode->i_rdev) != DTLK_MINOR)
16316 +       if (iminor(file->f_dentry->d_inode) != DTLK_MINOR)
16317                 return -EINVAL;
16318  
16319         while (1) {
16320 @@ -304,7 +304,7 @@
16321  {
16322         TRACE_TEXT("(dtlk_open");
16323  
16324 -       switch (minor(inode->i_rdev)) {
16325 +       switch (iminor(inode)) {
16326         case DTLK_MINOR:
16327                 if (dtlk_busy)
16328                         return -EBUSY;
16329 @@ -319,7 +319,7 @@
16330  {
16331         TRACE_TEXT("(dtlk_release");
16332  
16333 -       switch (minor(inode->i_rdev)) {
16334 +       switch (iminor(inode)) {
16335         case DTLK_MINOR:
16336                 break;
16337  
16338 diff -Nru a/drivers/char/epca.c b/drivers/char/epca.c
16339 --- a/drivers/char/epca.c       Thu Jul 31 08:58:45 2003
16340 +++ b/drivers/char/epca.c       Sun Aug 31 16:01:49 2003
16341 @@ -40,6 +40,7 @@
16342  #include <linux/tty_flip.h>
16343  #include <linux/slab.h>
16344  #include <linux/ioport.h>
16345 +#include <linux/interrupt.h>
16346  #include <asm/uaccess.h>
16347  #include <asm/io.h>
16348  
16349 diff -Nru a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c
16350 --- a/drivers/char/ftape/lowlevel/fdc-io.c      Tue Jul 15 10:01:29 2003
16351 +++ b/drivers/char/ftape/lowlevel/fdc-io.c      Sun Aug 31 16:13:58 2003
16352 @@ -1305,7 +1305,7 @@
16353         } else {
16354                 TRACE(ft_t_bug, "Unexpected ftape interrupt");
16355         }
16356 -       return IRQ_RETVAL(handled);
16357 +       TRACE_EXIT IRQ_RETVAL(handled);
16358  }
16359  
16360  int fdc_grab_irq_and_dma(void)
16361 diff -Nru a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
16362 --- a/drivers/char/ftape/zftape/zftape-init.c   Tue Jul 15 10:01:29 2003
16363 +++ b/drivers/char/ftape/zftape/zftape-init.c   Tue Aug 26 09:25:41 2003
16364 @@ -110,11 +110,11 @@
16365         int result;
16366         TRACE_FUN(ft_t_flow);
16367  
16368 -       TRACE(ft_t_flow, "called for minor %d", minor(ino->i_rdev));
16369 +       TRACE(ft_t_flow, "called for minor %d", iminor(ino));
16370         if ( test_and_set_bit(0,&busy_flag) ) {
16371                 TRACE_ABORT(-EBUSY, ft_t_warn, "failed: already busy");
16372         }
16373 -       if ((minor(ino->i_rdev) & ~(ZFT_MINOR_OP_MASK | FTAPE_NO_REWIND))
16374 +       if ((iminor(ino) & ~(ZFT_MINOR_OP_MASK | FTAPE_NO_REWIND))
16375              > 
16376             FTAPE_SEL_D) {
16377                 clear_bit(0,&busy_flag);
16378 @@ -122,7 +122,7 @@
16379         }
16380         orig_sigmask = current->blocked;
16381         sigfillset(&current->blocked);
16382 -       result = _zft_open(minor(ino->i_rdev), filep->f_flags & O_ACCMODE);
16383 +       result = _zft_open(iminor(ino), filep->f_flags & O_ACCMODE);
16384         if (result < 0) {
16385                 current->blocked = orig_sigmask; /* restore mask */
16386                 clear_bit(0,&busy_flag);
16387 @@ -144,7 +144,7 @@
16388         int result;
16389         TRACE_FUN(ft_t_flow);
16390  
16391 -       if ( !test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit) {
16392 +       if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit) {
16393                 TRACE(ft_t_err, "failed: not busy or wrong unit");
16394                 TRACE_EXIT 0;
16395         }
16396 @@ -167,7 +167,7 @@
16397         sigset_t old_sigmask;
16398         TRACE_FUN(ft_t_flow);
16399  
16400 -       if ( !test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit || ft_failure) {
16401 +       if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
16402                 TRACE_ABORT(-EIO, ft_t_err,
16403                             "failed: not busy, failure or wrong unit");
16404         }
16405 @@ -188,7 +188,7 @@
16406         TRACE_FUN(ft_t_flow);
16407  
16408         if ( !test_bit(0,&busy_flag) || 
16409 -           minor(filep->f_dentry->d_inode->i_rdev) != zft_unit || 
16410 +           iminor(filep->f_dentry->d_inode) != zft_unit || 
16411             ft_failure)
16412         {
16413                 TRACE_ABORT(-EIO, ft_t_err,
16414 @@ -217,7 +217,7 @@
16415         TRACE_FUN(ft_t_flow);
16416  
16417         TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len);
16418 -       if (!test_bit(0,&busy_flag)  || minor(ino->i_rdev) != zft_unit || ft_failure) {
16419 +       if (!test_bit(0,&busy_flag)  || iminor(ino) != zft_unit || ft_failure) {
16420                 TRACE_ABORT(-EIO, ft_t_err,
16421                             "failed: not busy, failure or wrong unit");
16422         }
16423 @@ -240,7 +240,7 @@
16424         TRACE_FUN(ft_t_flow);
16425  
16426         TRACE(ft_t_flow, "called with count: %ld", (unsigned long)req_len);
16427 -       if (!test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit || ft_failure) {
16428 +       if (!test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
16429                 TRACE_ABORT(-EIO, ft_t_err,
16430                             "failed: not busy, failure or wrong unit");
16431         }
16432 diff -Nru a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
16433 --- a/drivers/char/generic_serial.c     Wed Jun 11 12:32:33 2003
16434 +++ b/drivers/char/generic_serial.c     Sun Aug 31 16:09:23 2003
16435 @@ -25,6 +25,7 @@
16436  #include <linux/serial.h>
16437  #include <linux/mm.h>
16438  #include <linux/generic_serial.h>
16439 +#include <linux/interrupt.h>
16440  #include <asm/semaphore.h>
16441  #include <asm/uaccess.h>
16442  
16443 diff -Nru a/drivers/char/ip2main.c b/drivers/char/ip2main.c
16444 --- a/drivers/char/ip2main.c    Mon Jul 14 06:47:09 2003
16445 +++ b/drivers/char/ip2main.c    Tue Aug 26 09:25:41 2003
16446 @@ -2733,7 +2733,7 @@
16447  ssize_t
16448  ip2_ipl_read(struct file *pFile, char *pData, size_t count, loff_t *off )
16449  {
16450 -       unsigned int minor = minor( pFile->f_dentry->d_inode->i_rdev );
16451 +       unsigned int minor = iminor(pFile->f_dentry->d_inode);
16452         int rc = 0;
16453  
16454  #ifdef IP2DEBUG_IPL
16455 @@ -2863,7 +2863,7 @@
16456  static int
16457  ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
16458  {
16459 -       unsigned int iplminor = minor(pInode->i_rdev);
16460 +       unsigned int iplminor = iminor(pInode);
16461         int rc = 0;
16462         ULONG *pIndex = (ULONG*)arg;
16463         i2eBordStrPtr pB = i2BoardPtrTable[iplminor / 4];
16464 @@ -2998,7 +2998,7 @@
16465  static int
16466  ip2_ipl_open( struct inode *pInode, struct file *pFile )
16467  {
16468 -       unsigned int iplminor = minor(pInode->i_rdev);
16469 +       unsigned int iplminor = iminor(pInode);
16470         i2eBordStrPtr pB;
16471         i2ChanStrPtr  pCh;
16472  
16473 diff -Nru a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
16474 --- a/drivers/char/ipmi/ipmi_devintf.c  Wed May  7 08:47:29 2003
16475 +++ b/drivers/char/ipmi/ipmi_devintf.c  Tue Aug 26 09:25:41 2003
16476 @@ -110,7 +110,7 @@
16477  
16478  static int ipmi_open(struct inode *inode, struct file *file)
16479  {
16480 -       int                      if_num = minor(inode->i_rdev);
16481 +       int                      if_num = iminor(inode);
16482         int                      rv;
16483         struct ipmi_file_private *priv;
16484  
16485 diff -Nru a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
16486 --- a/drivers/char/ipmi/ipmi_watchdog.c Mon Aug 11 04:34:37 2003
16487 +++ b/drivers/char/ipmi/ipmi_watchdog.c Tue Aug 26 09:25:41 2003
16488 @@ -645,7 +645,7 @@
16489  
16490  static int ipmi_open(struct inode *ino, struct file *filep)
16491  {
16492 -        switch (minor(ino->i_rdev))
16493 +        switch (iminor(ino))
16494          {
16495                  case WATCHDOG_MINOR:
16496                      if (ipmi_wdog_open)
16497 @@ -688,7 +688,7 @@
16498  
16499  static int ipmi_close(struct inode *ino, struct file *filep)
16500  {
16501 -       if (minor(ino->i_rdev)==WATCHDOG_MINOR)
16502 +       if (iminor(ino)==WATCHDOG_MINOR)
16503         {
16504  #ifndef CONFIG_WATCHDOG_NOWAYOUT       
16505                 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
16506 diff -Nru a/drivers/char/istallion.c b/drivers/char/istallion.c
16507 --- a/drivers/char/istallion.c  Mon Jun 23 18:43:58 2003
16508 +++ b/drivers/char/istallion.c  Tue Aug 26 09:25:41 2003
16509 @@ -4805,7 +4805,7 @@
16510                         (int) fp, (int) buf, count, (int) offp);
16511  #endif
16512  
16513 -       brdnr = minor(fp->f_dentry->d_inode->i_rdev);
16514 +       brdnr = iminor(fp->f_dentry->d_inode);
16515         if (brdnr >= stli_nrbrds)
16516                 return(-ENODEV);
16517         brdp = stli_brds[brdnr];
16518 @@ -4860,7 +4860,7 @@
16519                         (int) fp, (int) buf, count, (int) offp);
16520  #endif
16521  
16522 -       brdnr = minor(fp->f_dentry->d_inode->i_rdev);
16523 +       brdnr = iminor(fp->f_dentry->d_inode);
16524         if (brdnr >= stli_nrbrds)
16525                 return(-ENODEV);
16526         brdp = stli_brds[brdnr];
16527 @@ -5201,7 +5201,7 @@
16528   *     Now handle the board specific ioctls. These all depend on the
16529   *     minor number of the device they were called from.
16530   */
16531 -       brdnr = minor(ip->i_rdev);
16532 +       brdnr = iminor(ip);
16533         if (brdnr >= STL_MAXBRDS)
16534                 return(-ENODEV);
16535         brdp = stli_brds[brdnr];
16536 diff -Nru a/drivers/char/ite_gpio.c b/drivers/char/ite_gpio.c
16537 --- a/drivers/char/ite_gpio.c   Thu Mar  6 14:03:51 2003
16538 +++ b/drivers/char/ite_gpio.c   Tue Aug 26 09:25:41 2003
16539 @@ -238,7 +238,7 @@
16540  
16541  static int ite_gpio_open(struct inode *inode, struct file *file)
16542  {
16543 -       unsigned int minor = minor(inode->i_rdev); 
16544 +       unsigned int minor = iminor(inode); 
16545         if (minor != GPIO_MINOR)
16546                 return -ENODEV;
16547  
16548 diff -Nru a/drivers/char/lcd.c b/drivers/char/lcd.c
16549 --- a/drivers/char/lcd.c        Wed May 29 12:05:13 2002
16550 +++ b/drivers/char/lcd.c        Sun Aug 31 16:14:08 2003
16551 @@ -551,9 +551,9 @@
16552   */
16553  
16554  static struct file_operations lcd_fops = {
16555 -       read:           lcd_read,
16556 -       ioctl:          lcd_ioctl,
16557 -       open:           lcd_open,
16558 +       .read           = lcd_read,
16559 +       .ioctl          = lcd_ioctl,
16560 +       .open           = lcd_open,
16561  };
16562  
16563  static struct miscdevice lcd_dev=
16564 diff -Nru a/drivers/char/lp.c b/drivers/char/lp.c
16565 --- a/drivers/char/lp.c Wed May  7 08:47:29 2003
16566 +++ b/drivers/char/lp.c Tue Aug 26 09:25:41 2003
16567 @@ -292,7 +292,7 @@
16568  static ssize_t lp_write(struct file * file, const char * buf,
16569                         size_t count, loff_t *ppos)
16570  {
16571 -       unsigned int minor = minor(file->f_dentry->d_inode->i_rdev);
16572 +       unsigned int minor = iminor(file->f_dentry->d_inode);
16573         struct parport *port = lp_table[minor].dev->port;
16574         char *kbuf = lp_table[minor].lp_buffer;
16575         ssize_t retv = 0;
16576 @@ -408,7 +408,7 @@
16577  static ssize_t lp_read(struct file * file, char * buf,
16578                        size_t count, loff_t *ppos)
16579  {
16580 -       unsigned int minor=minor(file->f_dentry->d_inode->i_rdev);
16581 +       unsigned int minor=iminor(file->f_dentry->d_inode);
16582         struct parport *port = lp_table[minor].dev->port;
16583         ssize_t retval = 0;
16584         char *kbuf = lp_table[minor].lp_buffer;
16585 @@ -483,7 +483,7 @@
16586  
16587  static int lp_open(struct inode * inode, struct file * file)
16588  {
16589 -       unsigned int minor = minor(inode->i_rdev);
16590 +       unsigned int minor = iminor(inode);
16591  
16592         if (minor >= LP_NO)
16593                 return -ENXIO;
16594 @@ -540,7 +540,7 @@
16595  
16596  static int lp_release(struct inode * inode, struct file * file)
16597  {
16598 -       unsigned int minor = minor(inode->i_rdev);
16599 +       unsigned int minor = iminor(inode);
16600  
16601         lp_claim_parport_or_block (&lp_table[minor]);
16602         parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT);
16603 @@ -555,7 +555,7 @@
16604  static int lp_ioctl(struct inode *inode, struct file *file,
16605                     unsigned int cmd, unsigned long arg)
16606  {
16607 -       unsigned int minor = minor(inode->i_rdev);
16608 +       unsigned int minor = iminor(inode);
16609         int status;
16610         int retval = 0;
16611  
16612 diff -Nru a/drivers/char/lp_old98.c b/drivers/char/lp_old98.c
16613 --- a/drivers/char/lp_old98.c   Thu Apr 24 03:30:40 2003
16614 +++ b/drivers/char/lp_old98.c   Tue Aug 26 09:25:41 2003
16615 @@ -219,7 +219,7 @@
16616  
16617  static int lp_old98_open(struct inode * inode, struct file * file)
16618  {
16619 -       if (minor(inode->i_rdev) != 0)
16620 +       if (iminor(inode) != 0)
16621                 return -ENXIO;
16622  
16623         if (lp.flags & LP_BUSY)
16624 diff -Nru a/drivers/char/mem.c b/drivers/char/mem.c
16625 --- a/drivers/char/mem.c        Tue Jun 10 23:33:17 2003
16626 +++ b/drivers/char/mem.c        Tue Aug 26 09:25:41 2003
16627 @@ -607,7 +607,7 @@
16628  
16629  static int memory_open(struct inode * inode, struct file * filp)
16630  {
16631 -       switch (minor(inode->i_rdev)) {
16632 +       switch (iminor(inode)) {
16633                 case 1:
16634                         filp->f_op = &mem_fops;
16635                         break;
16636 diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
16637 --- a/drivers/char/misc.c       Sat May 17 12:39:13 2003
16638 +++ b/drivers/char/misc.c       Tue Aug 26 09:25:41 2003
16639 @@ -100,7 +100,7 @@
16640  
16641  static int misc_open(struct inode * inode, struct file * file)
16642  {
16643 -       int minor = minor(inode->i_rdev);
16644 +       int minor = iminor(inode);
16645         struct miscdevice *c;
16646         int err = -ENODEV;
16647         struct file_operations *old_fops, *new_fops = NULL;
16648 diff -Nru a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
16649 --- a/drivers/char/n_hdlc.c     Fri May 30 19:53:01 2003
16650 +++ b/drivers/char/n_hdlc.c     Sun Aug 31 16:14:27 2003
16651 @@ -182,9 +182,9 @@
16652  
16653  /* TTY callbacks */
16654  
16655 -static int n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
16656 +static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
16657                            __u8 *buf, size_t nr);
16658 -static int n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
16659 +static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
16660                             const __u8 *buf, size_t nr);
16661  static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
16662                             unsigned int cmd, unsigned long arg);
16663 @@ -572,7 +572,7 @@
16664   *     
16665   * Returns the number of bytes returned or error code.
16666   */
16667 -static int n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
16668 +static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
16669                            __u8 *buf, size_t nr)
16670  {
16671         struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
16672 @@ -649,7 +649,7 @@
16673   *             
16674   * Returns the number of bytes written (or error code).
16675   */
16676 -static int n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
16677 +static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
16678                             const __u8 *data, size_t count)
16679  {
16680         struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
16681 @@ -658,7 +658,7 @@
16682         struct n_hdlc_buf *tbuf;
16683  
16684         if (debuglevel >= DEBUG_LEVEL_INFO)     
16685 -               printk("%s(%d)n_hdlc_tty_write() called count=%d\n",
16686 +               printk("%s(%d)n_hdlc_tty_write() called count=%Zd\n",
16687                         __FILE__,__LINE__,count);
16688                 
16689         /* Verify pointers */
16690 @@ -673,7 +673,7 @@
16691                 if (debuglevel & DEBUG_LEVEL_INFO)
16692                         printk (KERN_WARNING
16693                                 "n_hdlc_tty_write: truncating user packet "
16694 -                               "from %lu to %d\n", (unsigned long) count,
16695 +                               "from %lu to %Zd\n", (unsigned long) count,
16696                                 maxframe );
16697                 count = maxframe;
16698         }
16699 diff -Nru a/drivers/char/pcxx.c b/drivers/char/pcxx.c
16700 --- a/drivers/char/pcxx.c       Wed Aug 20 14:20:10 2003
16701 +++ b/drivers/char/pcxx.c       Sun Aug 31 16:14:07 2003
16702 @@ -121,7 +121,7 @@
16703  MODULE_PARM(altpin,      "1-4i");
16704  MODULE_PARM(numports,    "1-4i");
16705  
16706 -#endif MODULE
16707 +#endif /* MODULE */
16708  
16709  static int numcards = 1;
16710  static int nbdevs = 0;
16711 diff -Nru a/drivers/char/ppdev.c b/drivers/char/ppdev.c
16712 --- a/drivers/char/ppdev.c      Wed May  7 08:47:29 2003
16713 +++ b/drivers/char/ppdev.c      Tue Aug 26 09:25:41 2003
16714 @@ -104,7 +104,7 @@
16715  static ssize_t pp_read (struct file * file, char * buf, size_t count,
16716                         loff_t * ppos)
16717  {
16718 -       unsigned int minor = minor (file->f_dentry->d_inode->i_rdev);
16719 +       unsigned int minor = iminor(file->f_dentry->d_inode);
16720         struct pp_struct *pp = file->private_data;
16721         char * kbuffer;
16722         ssize_t bytes_read = 0;
16723 @@ -187,7 +187,7 @@
16724  static ssize_t pp_write (struct file * file, const char * buf, size_t count,
16725                          loff_t * ppos)
16726  {
16727 -       unsigned int minor = minor (file->f_dentry->d_inode->i_rdev);
16728 +       unsigned int minor = iminor(file->f_dentry->d_inode);
16729         struct pp_struct *pp = file->private_data;
16730         char * kbuffer;
16731         ssize_t bytes_written = 0;
16732 @@ -330,7 +330,7 @@
16733  static int pp_ioctl(struct inode *inode, struct file *file,
16734                     unsigned int cmd, unsigned long arg)
16735  {
16736 -       unsigned int minor = minor(inode->i_rdev);
16737 +       unsigned int minor = iminor(inode);
16738         struct pp_struct *pp = file->private_data;
16739         struct parport * port;
16740  
16741 @@ -638,7 +638,7 @@
16742  
16743  static int pp_open (struct inode * inode, struct file * file)
16744  {
16745 -       unsigned int minor = minor (inode->i_rdev);
16746 +       unsigned int minor = iminor(inode);
16747         struct pp_struct *pp;
16748  
16749         if (minor >= PARPORT_MAX)
16750 @@ -667,7 +667,7 @@
16751  
16752  static int pp_release (struct inode * inode, struct file * file)
16753  {
16754 -       unsigned int minor = minor (inode->i_rdev);
16755 +       unsigned int minor = iminor(inode);
16756         struct pp_struct *pp = file->private_data;
16757         int compat_negot;
16758  
16759 diff -Nru a/drivers/char/random.c b/drivers/char/random.c
16760 --- a/drivers/char/random.c     Wed Aug  6 10:59:31 2003
16761 +++ b/drivers/char/random.c     Sun Aug 31 16:13:54 2003
16762 @@ -269,9 +269,9 @@
16763  
16764  /*
16765   * The minimum number of bits of entropy before we wake up a read on
16766 - * /dev/random.  Should always be at least 8, or at least 1 byte.
16767 + * /dev/random.  Should be enough to do a significant reseed.
16768   */
16769 -static int random_read_wakeup_thresh = 8;
16770 +static int random_read_wakeup_thresh = 64;
16771  
16772  /*
16773   * If the entropy count falls under this number of bits, then we
16774 @@ -483,9 +483,9 @@
16775         unsigned        add_ptr;
16776         int             entropy_count;
16777         int             input_rotate;
16778 -       int             extract_count;
16779         struct poolinfo poolinfo;
16780         __u32           *pool;
16781 +       spinlock_t lock;
16782  };
16783  
16784  /*
16785 @@ -502,7 +502,7 @@
16786  
16787         poolwords = (size + 3) / 4; /* Convert bytes->words */
16788         /* The pool size must be a multiple of 16 32-bit words */
16789 -       poolwords = ((poolwords + 15) / 16) * 16; 
16790 +       poolwords = ((poolwords + 15) / 16) * 16;
16791  
16792         for (p = poolinfo_table; p->poolwords; p++) {
16793                 if (poolwords == p->poolwords)
16794 @@ -524,6 +524,7 @@
16795                 return -ENOMEM;
16796         }
16797         memset(r->pool, 0, POOLBYTES);
16798 +       r->lock = SPIN_LOCK_UNLOCKED;
16799         *ret_bucket = r;
16800         return 0;
16801  }
16802 @@ -534,7 +535,6 @@
16803         r->add_ptr = 0;
16804         r->entropy_count = 0;
16805         r->input_rotate = 0;
16806 -       r->extract_count = 0;
16807         memset(r->pool, 0, r->poolinfo.POOLBYTES);
16808  }
16809  #ifdef CONFIG_SYSCTL
16810 @@ -565,6 +565,9 @@
16811         int new_rotate;
16812         int wordmask = r->poolinfo.poolwords - 1;
16813         __u32 w;
16814 +       unsigned long flags;
16815 +
16816 +       spin_lock_irqsave(&r->lock, flags);
16817  
16818         while (nwords--) {
16819                 w = rotate_left(r->input_rotate, *in++);
16820 @@ -589,6 +592,8 @@
16821                 w ^= r->pool[i];
16822                 r->pool[i] = (w >> 3) ^ twist_table[w & 7];
16823         }
16824 +
16825 +       spin_unlock_irqrestore(&r->lock, flags);
16826  }
16827  
16828  /*
16829 @@ -596,6 +601,10 @@
16830   */
16831  static void credit_entropy_store(struct entropy_store *r, int nbits)
16832  {
16833 +       unsigned long flags;
16834 +
16835 +       spin_lock_irqsave(&r->lock, flags);
16836 +
16837         if (r->entropy_count + nbits < 0) {
16838                 DEBUG_ENT("negative entropy/overflow (%d+%d)\n",
16839                           r->entropy_count, nbits);
16840 @@ -605,11 +614,15 @@
16841         } else {
16842                 r->entropy_count += nbits;
16843                 if (nbits)
16844 -                       DEBUG_ENT("%s added %d bits, now %d\n",
16845 +                       DEBUG_ENT("%04d %04d : added %d bits to %s\n",
16846 +                                 random_state->entropy_count,
16847 +                                 sec_random_state->entropy_count,
16848 +                                 nbits,
16849                                   r == sec_random_state ? "secondary" :
16850 -                                 r == random_state ? "primary" : "unknown",
16851 -                                 nbits, r->entropy_count);
16852 +                                 r == random_state ? "primary" : "unknown");
16853         }
16854 +
16855 +       spin_unlock_irqrestore(&r->lock, flags);
16856  }
16857  
16858  /**********************************************************************
16859 @@ -620,27 +633,33 @@
16860   *
16861   **********************************************************************/
16862  
16863 -static __u32   *batch_entropy_pool;
16864 -static int     *batch_entropy_credit;
16865 -static int     batch_max;
16866 +struct sample {
16867 +       __u32 data[2];
16868 +       int credit;
16869 +};
16870 +
16871 +static struct sample *batch_entropy_pool, *batch_entropy_copy;
16872  static int     batch_head, batch_tail;
16873 +static spinlock_t batch_lock = SPIN_LOCK_UNLOCKED;
16874 +
16875 +static int     batch_max;
16876  static void batch_entropy_process(void *private_);
16877  static DECLARE_WORK(batch_work, batch_entropy_process, NULL);
16878  
16879  /* note: the size must be a power of 2 */
16880  static int __init batch_entropy_init(int size, struct entropy_store *r)
16881  {
16882 -       batch_entropy_pool = kmalloc(2*size*sizeof(__u32), GFP_KERNEL);
16883 +       batch_entropy_pool = kmalloc(size*sizeof(struct sample), GFP_KERNEL);
16884         if (!batch_entropy_pool)
16885                 return -1;
16886 -       batch_entropy_credit =kmalloc(size*sizeof(int), GFP_KERNEL);
16887 -       if (!batch_entropy_credit) {
16888 +       batch_entropy_copy = kmalloc(size*sizeof(struct sample), GFP_KERNEL);
16889 +       if (!batch_entropy_copy) {
16890                 kfree(batch_entropy_pool);
16891                 return -1;
16892         }
16893         batch_head = batch_tail = 0;
16894 -       batch_max = size;
16895         batch_work.data = r;
16896 +       batch_max = size;
16897         return 0;
16898  }
16899  
16900 @@ -652,27 +671,33 @@
16901   */
16902  void batch_entropy_store(u32 a, u32 b, int num)
16903  {
16904 -       int     new;
16905 +       int new;
16906 +       unsigned long flags;
16907  
16908         if (!batch_max)
16909                 return;
16910 -       
16911 -       batch_entropy_pool[2*batch_head] = a;
16912 -       batch_entropy_pool[(2*batch_head) + 1] = b;
16913 -       batch_entropy_credit[batch_head] = num;
16914  
16915 -       new = (batch_head+1) & (batch_max-1);
16916 -       if ((unsigned)(new - batch_tail) >= (unsigned)(batch_max / 2)) {
16917 +       spin_lock_irqsave(&batch_lock, flags);
16918 +
16919 +       batch_entropy_pool[batch_head].data[0] = a;
16920 +       batch_entropy_pool[batch_head].data[1] = b;
16921 +       batch_entropy_pool[batch_head].credit = num;
16922 +
16923 +       if (((batch_head - batch_tail) & (batch_max-1)) >= (batch_max / 2)) {
16924                 /*
16925                  * Schedule it for the next timer tick:
16926                  */
16927                 schedule_delayed_work(&batch_work, 1);
16928 -               batch_head = new;
16929 -       } else if (new == batch_tail) {
16930 +       }
16931 +
16932 +       new = (batch_head+1) & (batch_max-1);
16933 +       if (new == batch_tail) {
16934                 DEBUG_ENT("batch entropy buffer full\n");
16935         } else {
16936                 batch_head = new;
16937         }
16938 +
16939 +       spin_unlock_irqrestore(&batch_lock, flags);
16940  }
16941  
16942  /*
16943 @@ -684,20 +709,34 @@
16944  {
16945         struct entropy_store *r = (struct entropy_store *) private_, *p;
16946         int max_entropy = r->poolinfo.POOLBITS;
16947 +       unsigned head, tail;
16948  
16949 -       if (!batch_max)
16950 -               return;
16951 +       /* Mixing into the pool is expensive, so copy over the batch
16952 +        * data and release the batch lock. The pool is at least half
16953 +        * full, so don't worry too much about copying only the used
16954 +        * part.
16955 +        */
16956 +       spin_lock_irq(&batch_lock);
16957 +
16958 +       memcpy(batch_entropy_copy, batch_entropy_pool,
16959 +              batch_max*sizeof(struct sample));
16960 +
16961 +       head = batch_head;
16962 +       tail = batch_tail;
16963 +       batch_tail = batch_head;
16964 +
16965 +       spin_unlock_irq(&batch_lock);
16966  
16967         p = r;
16968 -       while (batch_head != batch_tail) {
16969 +       while (head != tail) {
16970                 if (r->entropy_count >= max_entropy) {
16971                         r = (r == sec_random_state) ?   random_state :
16972                                                         sec_random_state;
16973                         max_entropy = r->poolinfo.POOLBITS;
16974                 }
16975 -               add_entropy_words(r, batch_entropy_pool + 2*batch_tail, 2);
16976 -               credit_entropy_store(r, batch_entropy_credit[batch_tail]);
16977 -               batch_tail = (batch_tail+1) & (batch_max-1);
16978 +               add_entropy_words(r, batch_entropy_copy[tail].data, 2);
16979 +               credit_entropy_store(r, batch_entropy_copy[tail].credit);
16980 +               tail = (tail+1) & (batch_max-1);
16981         }
16982         if (p->entropy_count >= random_read_wakeup_thresh)
16983                 wake_up_interruptible(&random_read_wait);
16984 @@ -1216,6 +1255,7 @@
16985  
16986  #define EXTRACT_ENTROPY_USER           1
16987  #define EXTRACT_ENTROPY_SECONDARY      2
16988 +#define EXTRACT_ENTROPY_LIMIT          4
16989  #define TMP_BUF_SIZE                   (HASH_BUFFER_SIZE + HASH_EXTRA_SIZE)
16990  #define SEC_XFER_SIZE                  (TMP_BUF_SIZE*4)
16991  
16992 @@ -1224,36 +1264,28 @@
16993  
16994  /*
16995   * This utility inline function is responsible for transfering entropy
16996 - * from the primary pool to the secondary extraction pool.  We pull
16997 - * randomness under two conditions; one is if there isn't enough entropy
16998 - * in the secondary pool.  The other is after we have extracted 1024 bytes,
16999 - * at which point we do a "catastrophic reseeding".
17000 + * from the primary pool to the secondary extraction pool. We make
17001 + * sure we pull enough for a 'catastrophic reseed'.
17002   */
17003  static inline void xfer_secondary_pool(struct entropy_store *r,
17004                                        size_t nbytes, __u32 *tmp)
17005  {
17006         if (r->entropy_count < nbytes * 8 &&
17007             r->entropy_count < r->poolinfo.POOLBITS) {
17008 -               int nwords = min_t(int,
17009 -                                  r->poolinfo.poolwords - r->entropy_count/32,
17010 -                                  sizeof(tmp) / 4);
17011 +               int bytes = max_t(int, random_read_wakeup_thresh / 8,
17012 +                               min_t(int, nbytes, TMP_BUF_SIZE));
17013  
17014 -               DEBUG_ENT("xfer %d from primary to %s (have %d, need %d)\n",
17015 -                         nwords * 32,
17016 +               DEBUG_ENT("%04d %04d : going to reseed %s with %d bits "
17017 +                         "(%d of %d requested)\n",
17018 +                         random_state->entropy_count,
17019 +                         sec_random_state->entropy_count,
17020                           r == sec_random_state ? "secondary" : "unknown",
17021 -                         r->entropy_count, nbytes * 8);
17022 +                         bytes * 8, nbytes * 8, r->entropy_count);
17023  
17024 -               extract_entropy(random_state, tmp, nwords * 4, 0);
17025 -               add_entropy_words(r, tmp, nwords);
17026 -               credit_entropy_store(r, nwords * 32);
17027 -       }
17028 -       if (r->extract_count > 1024) {
17029 -               DEBUG_ENT("reseeding %s with %d from primary\n",
17030 -                         r == sec_random_state ? "secondary" : "unknown",
17031 -                         sizeof(tmp) * 8);
17032 -               extract_entropy(random_state, tmp, sizeof(tmp), 0);
17033 -               add_entropy_words(r, tmp, sizeof(tmp) / 4);
17034 -               r->extract_count = 0;
17035 +               bytes=extract_entropy(random_state, tmp, bytes,
17036 +                                     EXTRACT_ENTROPY_LIMIT);
17037 +               add_entropy_words(r, tmp, bytes);
17038 +               credit_entropy_store(r, bytes*8);
17039         }
17040  }
17041  
17042 @@ -1276,8 +1308,8 @@
17043         ssize_t ret, i;
17044         __u32 tmp[TMP_BUF_SIZE];
17045         __u32 x;
17046 +       unsigned long cpuflags;
17047  
17048 -       add_timer_randomness(&extract_timer_state, nbytes);
17049  
17050         /* Redundant, but just in case... */
17051         if (r->entropy_count > r->poolinfo.POOLBITS)
17052 @@ -1286,10 +1318,18 @@
17053         if (flags & EXTRACT_ENTROPY_SECONDARY)
17054                 xfer_secondary_pool(r, nbytes, tmp);
17055  
17056 -       DEBUG_ENT("%s has %d bits, want %d bits\n",
17057 +       /* Hold lock while accounting */
17058 +       spin_lock_irqsave(&r->lock, cpuflags);
17059 +
17060 +       DEBUG_ENT("%04d %04d : trying to extract %d bits from %s\n",
17061 +                 random_state->entropy_count,
17062 +                 sec_random_state->entropy_count,
17063 +                 nbytes * 8,
17064                   r == sec_random_state ? "secondary" :
17065 -                 r == random_state ? "primary" : "unknown",
17066 -                 r->entropy_count, nbytes * 8);
17067 +                 r == random_state ? "primary" : "unknown");
17068 +
17069 +       if (flags & EXTRACT_ENTROPY_LIMIT && nbytes >= r->entropy_count / 8)
17070 +               nbytes = r->entropy_count / 8;
17071  
17072         if (r->entropy_count / 8 >= nbytes)
17073                 r->entropy_count -= nbytes*8;
17074 @@ -1299,8 +1339,16 @@
17075         if (r->entropy_count < random_write_wakeup_thresh)
17076                 wake_up_interruptible(&random_write_wait);
17077  
17078 -       r->extract_count += nbytes;
17079 -       
17080 +       DEBUG_ENT("%04d %04d : debiting %d bits from %s%s\n",
17081 +                 random_state->entropy_count,
17082 +                 sec_random_state->entropy_count,
17083 +                 nbytes * 8,
17084 +                 r == sec_random_state ? "secondary" :
17085 +                 r == random_state ? "primary" : "unknown",
17086 +                 flags & EXTRACT_ENTROPY_LIMIT ? "" : " (unlimited)");
17087 +
17088 +       spin_unlock_irqrestore(&r->lock, cpuflags);
17089 +
17090         ret = 0;
17091         while (nbytes) {
17092                 /*
17093 @@ -1312,7 +1360,16 @@
17094                                         ret = -ERESTARTSYS;
17095                                 break;
17096                         }
17097 +
17098 +                       DEBUG_ENT("%04d %04d : extract feeling sleepy (%d bytes left)\n",
17099 +                                 random_state->entropy_count,
17100 +                                 sec_random_state->entropy_count, nbytes);
17101 +
17102                         schedule();
17103 +
17104 +                       DEBUG_ENT("%04d %04d : extract woke up\n",
17105 +                                 random_state->entropy_count,
17106 +                                 sec_random_state->entropy_count);
17107                 }
17108  
17109                 /* Hash the pool to get the output */
17110 @@ -1361,7 +1418,6 @@
17111                 nbytes -= i;
17112                 buf += i;
17113                 ret += i;
17114 -               add_timer_randomness(&extract_timer_state, nbytes);
17115         }
17116  
17117         /* Wipe data just returned from memory */
17118 @@ -1488,15 +1544,27 @@
17119         if (nbytes == 0)
17120                 return 0;
17121  
17122 -       add_wait_queue(&random_read_wait, &wait);
17123         while (nbytes > 0) {
17124 -               set_current_state(TASK_INTERRUPTIBLE);
17125 -               
17126                 n = nbytes;
17127                 if (n > SEC_XFER_SIZE)
17128                         n = SEC_XFER_SIZE;
17129 -               if (n > random_state->entropy_count / 8)
17130 -                       n = random_state->entropy_count / 8;
17131 +
17132 +               DEBUG_ENT("%04d %04d : reading %d bits, p: %d s: %d\n",
17133 +                         random_state->entropy_count,
17134 +                         sec_random_state->entropy_count,
17135 +                         n*8, random_state->entropy_count,
17136 +                         sec_random_state->entropy_count);
17137 +
17138 +               n = extract_entropy(sec_random_state, buf, n,
17139 +                                   EXTRACT_ENTROPY_USER |
17140 +                                   EXTRACT_ENTROPY_LIMIT |
17141 +                                   EXTRACT_ENTROPY_SECONDARY);
17142 +
17143 +               DEBUG_ENT("%04d %04d : read got %d bits (%d still needed)\n",
17144 +                         random_state->entropy_count,
17145 +                         sec_random_state->entropy_count,
17146 +                         n*8, (nbytes-n)*8);
17147 +
17148                 if (n == 0) {
17149                         if (file->f_flags & O_NONBLOCK) {
17150                                 retval = -EAGAIN;
17151 @@ -1506,12 +1574,27 @@
17152                                 retval = -ERESTARTSYS;
17153                                 break;
17154                         }
17155 -                       schedule();
17156 +
17157 +                       DEBUG_ENT("%04d %04d : sleeping?\n",
17158 +                                 random_state->entropy_count,
17159 +                                 sec_random_state->entropy_count);
17160 +
17161 +                       set_current_state(TASK_INTERRUPTIBLE);
17162 +                       add_wait_queue(&random_read_wait, &wait);
17163 +
17164 +                       if (sec_random_state->entropy_count / 8 == 0)
17165 +                               schedule();
17166 +
17167 +                       set_current_state(TASK_RUNNING);
17168 +                       remove_wait_queue(&random_read_wait, &wait);
17169 +
17170 +                       DEBUG_ENT("%04d %04d : waking up\n",
17171 +                                 random_state->entropy_count,
17172 +                                 sec_random_state->entropy_count);
17173 +
17174                         continue;
17175                 }
17176 -               n = extract_entropy(sec_random_state, buf, n,
17177 -                                   EXTRACT_ENTROPY_USER |
17178 -                                   EXTRACT_ENTROPY_SECONDARY);
17179 +
17180                 if (n < 0) {
17181                         retval = n;
17182                         break;
17183 @@ -1522,8 +1605,6 @@
17184                 break;          /* This break makes the device work */
17185                                 /* like a named pipe */
17186         }
17187 -       current->state = TASK_RUNNING;
17188 -       remove_wait_queue(&random_read_wait, &wait);
17189  
17190         /*
17191          * If we gave the user some bytes, update the access time.
17192 @@ -1595,8 +1676,9 @@
17193  random_ioctl(struct inode * inode, struct file * file,
17194              unsigned int cmd, unsigned long arg)
17195  {
17196 -       int *p, size, ent_count;
17197 +       int *p, *tmp, size, ent_count;
17198         int retval;
17199 +       unsigned long flags;
17200         
17201         switch (cmd) {
17202         case RNDGETENTCNT:
17203 @@ -1621,17 +1703,36 @@
17204                 if (!capable(CAP_SYS_ADMIN))
17205                         return -EPERM;
17206                 p = (int *) arg;
17207 -               ent_count = random_state->entropy_count;
17208 -               if (put_user(ent_count, p++) ||
17209 -                   get_user(size, p) ||
17210 +               if (get_user(size, p) ||
17211                     put_user(random_state->poolinfo.poolwords, p++))
17212                         return -EFAULT;
17213                 if (size < 0)
17214 -                       return -EINVAL;
17215 +                       return -EFAULT;
17216                 if (size > random_state->poolinfo.poolwords)
17217                         size = random_state->poolinfo.poolwords;
17218 -               if (copy_to_user(p, random_state->pool, size * sizeof(__u32)))
17219 +
17220 +               /* prepare to atomically snapshot pool */
17221 +
17222 +               tmp = kmalloc(size * sizeof(__u32), GFP_KERNEL);
17223 +
17224 +               if (!tmp)
17225                         return -EFAULT;
17226 +
17227 +               spin_lock_irqsave(&random_state->lock, flags);
17228 +               ent_count = random_state->entropy_count;
17229 +               memcpy(tmp, random_state->pool, size * sizeof(__u32));
17230 +               spin_unlock_irqrestore(&random_state->lock, flags);
17231 +
17232 +               if (!copy_to_user(p, tmp, size * sizeof(__u32))) {
17233 +                       kfree(tmp);
17234 +                       return -EFAULT;
17235 +               }
17236 +
17237 +               kfree(tmp);
17238 +
17239 +               if(put_user(ent_count, p++))
17240 +                       return -EFAULT;
17241 +
17242                 return 0;
17243         case RNDADDENTROPY:
17244                 if (!capable(CAP_SYS_ADMIN))
17245 diff -Nru a/drivers/char/raw.c b/drivers/char/raw.c
17246 --- a/drivers/char/raw.c        Fri Jun 20 13:16:17 2003
17247 +++ b/drivers/char/raw.c        Sun Aug 31 16:14:45 2003
17248 @@ -43,7 +43,7 @@
17249   */
17250  static int raw_open(struct inode *inode, struct file *filp)
17251  {
17252 -       const int minor = minor(inode->i_rdev);
17253 +       const int minor = iminor(inode);
17254         struct block_device *bdev;
17255         int err;
17256  
17257 @@ -60,23 +60,25 @@
17258         bdev = raw_devices[minor].binding;
17259         err = -ENODEV;
17260         if (bdev) {
17261 -               err = bd_claim(bdev, raw_open);
17262 +               err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
17263                 if (err)
17264                         goto out;
17265 -               atomic_inc(&bdev->bd_count);
17266 -               err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
17267 +               igrab(bdev->bd_inode);
17268 +               err = bd_claim(bdev, raw_open);
17269 +               if (err) {
17270 +                       blkdev_put(bdev, BDEV_RAW);
17271 +                       goto out;
17272 +               }
17273 +               err = set_blocksize(bdev, bdev_hardsect_size(bdev));
17274                 if (err) {
17275                         bd_release(bdev);
17276 +                       blkdev_put(bdev, BDEV_RAW);
17277                         goto out;
17278 -               } else {
17279 -                       err = set_blocksize(bdev, bdev_hardsect_size(bdev));
17280 -                       if (err == 0) {
17281 -                               filp->f_flags |= O_DIRECT;
17282 -                               if (++raw_devices[minor].inuse == 1)
17283 -                                       filp->f_dentry->d_inode->i_mapping =
17284 -                                               bdev->bd_inode->i_mapping;
17285 -                       }
17286                 }
17287 +               filp->f_flags |= O_DIRECT;
17288 +               if (++raw_devices[minor].inuse == 1)
17289 +                       filp->f_dentry->d_inode->i_mapping =
17290 +                               bdev->bd_inode->i_mapping;
17291         }
17292         filp->private_data = bdev;
17293  out:
17294 @@ -90,7 +92,7 @@
17295   */
17296  static int raw_release(struct inode *inode, struct file *filp)
17297  {
17298 -       const int minor= minor(inode->i_rdev);
17299 +       const int minor= iminor(inode);
17300         struct block_device *bdev;
17301  
17302         down(&raw_mutex);
17303 diff -Nru a/drivers/char/rtc.c b/drivers/char/rtc.c
17304 --- a/drivers/char/rtc.c        Tue Aug 12 13:25:18 2003
17305 +++ b/drivers/char/rtc.c        Sun Aug 31 16:15:40 2003
17306 @@ -44,10 +44,12 @@
17307   *      1.11    Takashi Iwai: Kernel access functions
17308   *                           rtc_register/rtc_unregister/rtc_control
17309   *      1.11a   Daniele Bellucci: Audit create_proc_read_entry in rtc_init
17310 + *     1.12    Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer
17311 + *             CONFIG_HPET_EMULATE_RTC
17312   *
17313   */
17314  
17315 -#define RTC_VERSION            "1.11a"
17316 +#define RTC_VERSION            "1.12"
17317  
17318  #define RTC_IO_EXTENT  0x8
17319  
17320 @@ -80,6 +82,10 @@
17321  #include <asm/uaccess.h>
17322  #include <asm/system.h>
17323  
17324 +#if defined(__i386__)
17325 +#include <asm/hpet.h>
17326 +#endif
17327 +
17328  #ifdef __sparc__
17329  #include <linux/pci.h>
17330  #include <asm/ebus.h>
17331 @@ -95,6 +101,17 @@
17332  static int rtc_has_irq = 1;
17333  #endif
17334  
17335 +#ifndef CONFIG_HPET_EMULATE_RTC
17336 +#define is_hpet_enabled()                      0
17337 +#define hpet_set_alarm_time(hrs, min, sec)     0
17338 +#define hpet_set_periodic_freq(arg)            0
17339 +#define hpet_mask_rtc_irq_bit(arg)             0
17340 +#define hpet_set_rtc_irq_bit(arg)              0
17341 +#define hpet_rtc_timer_init()                  do { } while (0)
17342 +#define hpet_rtc_dropped_irq()                         0
17343 +static inline irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs) {return 0;}
17344 +#endif
17345 +
17346  /*
17347   *     We sponge a minor off of the misc major. No need slurping
17348   *     up another valuable major dev number for this. If you add
17349 @@ -120,7 +137,7 @@
17350  static unsigned int rtc_poll(struct file *file, poll_table *wait);
17351  #endif
17352  
17353 -static void get_rtc_time (struct rtc_time *rtc_tm);
17354 +void get_rtc_time (struct rtc_time *rtc_tm);
17355  static void get_rtc_alm_time (struct rtc_time *alm_tm);
17356  #if RTC_IRQ
17357  static void rtc_dropped_irq(unsigned long data);
17358 @@ -182,7 +199,7 @@
17359   *     (See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.)
17360   */
17361  
17362 -static irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
17363 +irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
17364  {
17365         /*
17366          *      Can be an alarm interrupt, update complete interrupt,
17367 @@ -194,7 +211,16 @@
17368         spin_lock (&rtc_lock);
17369         rtc_irq_data += 0x100;
17370         rtc_irq_data &= ~0xff;
17371 -       rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);
17372 +       if (is_hpet_enabled()) {
17373 +               /*
17374 +                * In this case it is HPET RTC interrupt handler
17375 +                * calling us, with the interrupt information
17376 +                * passed as arg1, instead of irq.
17377 +                */
17378 +               rtc_irq_data |= (unsigned long)irq & 0xF0;
17379 +       } else {
17380 +               rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);
17381 +       }
17382  
17383         if (rtc_status & RTC_TIMER_ON)
17384                 mod_timer(&rtc_irq_timer, jiffies + HZ/rtc_freq + 2*HZ/100);
17385 @@ -429,6 +455,12 @@
17386                 sec = alm_tm.tm_sec;
17387  
17388                 spin_lock_irq(&rtc_lock);
17389 +               if (hpet_set_alarm_time(hrs, min, sec)) {
17390 +                       /*
17391 +                        * Fallthru and set alarm time in CMOS too,
17392 +                        * so that we will get proper value in RTC_ALM_READ
17393 +                        */
17394 +               }
17395                 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) ||
17396                     RTC_ALWAYS_BCD)
17397                 {
17398 @@ -582,6 +614,10 @@
17399                         return -EINVAL;
17400  
17401                 spin_lock_irq(&rtc_lock);
17402 +               if (hpet_set_periodic_freq(arg)) {
17403 +                       spin_unlock_irq(&rtc_lock);
17404 +                       return 0;
17405 +               }
17406                 rtc_freq = arg;
17407  
17408                 val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0;
17409 @@ -667,13 +703,14 @@
17410          */
17411  
17412         spin_lock_irq(&rtc_lock);
17413 -       tmp = CMOS_READ(RTC_CONTROL);
17414 -       tmp &=  ~RTC_PIE;
17415 -       tmp &=  ~RTC_AIE;
17416 -       tmp &=  ~RTC_UIE;
17417 -       CMOS_WRITE(tmp, RTC_CONTROL);
17418 -       CMOS_READ(RTC_INTR_FLAGS);
17419 -
17420 +       if (!hpet_mask_rtc_irq_bit(RTC_PIE | RTC_AIE | RTC_UIE)) {
17421 +               tmp = CMOS_READ(RTC_CONTROL);
17422 +               tmp &=  ~RTC_PIE;
17423 +               tmp &=  ~RTC_AIE;
17424 +               tmp &=  ~RTC_UIE;
17425 +               CMOS_WRITE(tmp, RTC_CONTROL);
17426 +               CMOS_READ(RTC_INTR_FLAGS);
17427 +       }
17428         if (rtc_status & RTC_TIMER_ON) {
17429                 rtc_status &= ~RTC_TIMER_ON;
17430                 del_timer(&rtc_irq_timer);
17431 @@ -765,12 +802,14 @@
17432         rtc_callback = NULL;
17433         
17434         /* disable controls */
17435 -       tmp = CMOS_READ(RTC_CONTROL);
17436 -       tmp &= ~RTC_PIE;
17437 -       tmp &= ~RTC_AIE;
17438 -       tmp &= ~RTC_UIE;
17439 -       CMOS_WRITE(tmp, RTC_CONTROL);
17440 -       CMOS_READ(RTC_INTR_FLAGS);
17441 +       if (!hpet_mask_rtc_irq_bit(RTC_PIE | RTC_AIE | RTC_UIE)) {
17442 +               tmp = CMOS_READ(RTC_CONTROL);
17443 +               tmp &= ~RTC_PIE;
17444 +               tmp &= ~RTC_AIE;
17445 +               tmp &= ~RTC_UIE;
17446 +               CMOS_WRITE(tmp, RTC_CONTROL);
17447 +               CMOS_READ(RTC_INTR_FLAGS);
17448 +       }
17449         if (rtc_status & RTC_TIMER_ON) {
17450                 rtc_status &= ~RTC_TIMER_ON;
17451                 del_timer(&rtc_irq_timer);
17452 @@ -822,6 +861,10 @@
17453         &rtc_fops
17454  };
17455  
17456 +#if RTC_IRQ
17457 +static irqreturn_t (*rtc_int_handler_ptr)(int irq, void *dev_id, struct pt_regs *regs);
17458 +#endif
17459 +
17460  static int __init rtc_init(void)
17461  {
17462  #if defined(__alpha__) || defined(__mips__)
17463 @@ -889,12 +932,20 @@
17464         }
17465  
17466  #if RTC_IRQ
17467 -       if (request_irq(RTC_IRQ, rtc_interrupt, SA_INTERRUPT, "rtc", NULL)) {
17468 +       if (is_hpet_enabled()) {
17469 +               rtc_int_handler_ptr = hpet_rtc_interrupt;
17470 +       } else {
17471 +               rtc_int_handler_ptr = rtc_interrupt;
17472 +       }
17473 +
17474 +       if(request_irq(RTC_IRQ, rtc_int_handler_ptr, SA_INTERRUPT, "rtc", NULL)) {
17475                 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */
17476                 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
17477                 release_region(RTC_PORT(0), RTC_IO_EXTENT);
17478                 return -EIO;
17479         }
17480 +       hpet_rtc_timer_init();
17481 +
17482  #endif
17483  
17484  #endif /* __sparc__ vs. others */
17485 @@ -965,10 +1016,12 @@
17486         init_timer(&rtc_irq_timer);
17487         rtc_irq_timer.function = rtc_dropped_irq;
17488         spin_lock_irq(&rtc_lock);
17489 -       /* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
17490 -       CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
17491 -       spin_unlock_irq(&rtc_lock);
17492         rtc_freq = 1024;
17493 +       if (!hpet_set_periodic_freq(rtc_freq)) {
17494 +               /* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
17495 +               CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
17496 +       }
17497 +       spin_unlock_irq(&rtc_lock);
17498  no_irq2:
17499  #endif
17500  
17501 @@ -1019,6 +1072,11 @@
17502  
17503         spin_lock_irq (&rtc_lock);
17504  
17505 +       if (hpet_rtc_dropped_irq()) {
17506 +               spin_unlock_irq(&rtc_lock);
17507 +               return;
17508 +       }
17509 +
17510         /* Just in case someone disabled the timer from behind our back... */
17511         if (rtc_status & RTC_TIMER_ON)
17512                 mod_timer(&rtc_irq_timer, jiffies + HZ/rtc_freq + 2*HZ/100);
17513 @@ -1148,7 +1206,7 @@
17514         return uip;
17515  }
17516  
17517 -static void get_rtc_time(struct rtc_time *rtc_tm)
17518 +void get_rtc_time(struct rtc_time *rtc_tm)
17519  {
17520         unsigned long uip_watchdog = jiffies;
17521         unsigned char ctrl;
17522 @@ -1254,6 +1312,10 @@
17523         unsigned char val;
17524  
17525         spin_lock_irq(&rtc_lock);
17526 +       if (hpet_mask_rtc_irq_bit(bit)) {
17527 +               spin_unlock_irq(&rtc_lock);
17528 +               return;
17529 +       }
17530         val = CMOS_READ(RTC_CONTROL);
17531         val &=  ~bit;
17532         CMOS_WRITE(val, RTC_CONTROL);
17533 @@ -1268,6 +1330,10 @@
17534         unsigned char val;
17535  
17536         spin_lock_irq(&rtc_lock);
17537 +       if (hpet_set_rtc_irq_bit(bit)) {
17538 +               spin_unlock_irq(&rtc_lock);
17539 +               return;
17540 +       }
17541         val = CMOS_READ(RTC_CONTROL);
17542         val |= bit;
17543         CMOS_WRITE(val, RTC_CONTROL);
17544 diff -Nru a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
17545 --- a/drivers/char/scx200_gpio.c        Sat Dec  7 08:54:07 2002
17546 +++ b/drivers/char/scx200_gpio.c        Tue Aug 26 09:25:41 2003
17547 @@ -29,7 +29,7 @@
17548  static ssize_t scx200_gpio_write(struct file *file, const char *data, 
17549                                  size_t len, loff_t *ppos)
17550  {
17551 -       unsigned m = minor(file->f_dentry->d_inode->i_rdev);
17552 +       unsigned m = iminor(file->f_dentry->d_inode);
17553         size_t i;
17554  
17555         if (ppos != &file->f_pos)
17556 @@ -80,7 +80,7 @@
17557  static ssize_t scx200_gpio_read(struct file *file, char *buf,
17558                                 size_t len, loff_t *ppos)
17559  {
17560 -       unsigned m = minor(file->f_dentry->d_inode->i_rdev);
17561 +       unsigned m = iminor(file->f_dentry->d_inode);
17562         int value;
17563  
17564         if (ppos != &file->f_pos)
17565 @@ -95,7 +95,7 @@
17566  
17567  static int scx200_gpio_open(struct inode *inode, struct file *file)
17568  {
17569 -       unsigned m = minor(inode->i_rdev);
17570 +       unsigned m = iminor(inode);
17571         if (m > 63)
17572                 return -EINVAL;
17573         return 0;
17574 diff -Nru a/drivers/char/sonypi.c b/drivers/char/sonypi.c
17575 --- a/drivers/char/sonypi.c     Fri Jun 13 07:30:24 2003
17576 +++ b/drivers/char/sonypi.c     Fri Aug  1 05:36:14 2003
17577 @@ -308,7 +308,7 @@
17578         int i, j;
17579  
17580         v1 = inb_p(sonypi_device.ioport1);
17581 -       v2 = inb_p(sonypi_device.ioport2);
17582 +       v2 = inb_p(sonypi_device.ioport1 + sonypi_device.evtype_offset);
17583  
17584         for (i = 0; sonypi_eventtypes[i].model; i++) {
17585                 if (sonypi_device.model != sonypi_eventtypes[i].model)
17586 @@ -670,11 +670,13 @@
17587         if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) {
17588                 ioport_list = sonypi_type2_ioport_list;
17589                 sonypi_device.region_size = SONYPI_TYPE2_REGION_SIZE;
17590 +               sonypi_device.evtype_offset = SONYPI_TYPE2_EVTYPE_OFFSET;
17591                 irq_list = sonypi_type2_irq_list;
17592         }
17593         else {
17594                 ioport_list = sonypi_type1_ioport_list;
17595                 sonypi_device.region_size = SONYPI_TYPE1_REGION_SIZE;
17596 +               sonypi_device.evtype_offset = SONYPI_TYPE1_EVTYPE_OFFSET;
17597                 irq_list = sonypi_type1_irq_list;
17598         }
17599  
17600 diff -Nru a/drivers/char/sonypi.h b/drivers/char/sonypi.h
17601 --- a/drivers/char/sonypi.h     Tue Jun 10 03:03:28 2003
17602 +++ b/drivers/char/sonypi.h     Mon Sep  1 03:37:24 2003
17603 @@ -56,12 +56,14 @@
17604  #define SONYPI_BASE                    0x50
17605  #define SONYPI_G10A                    (SONYPI_BASE+0x14)
17606  #define SONYPI_TYPE1_REGION_SIZE       0x08
17607 +#define SONYPI_TYPE1_EVTYPE_OFFSET     0x04
17608  
17609  /* type2 series specifics */
17610  #define SONYPI_SIRQ                    0x9b
17611  #define SONYPI_SLOB                    0x9c
17612  #define SONYPI_SHIB                    0x9d
17613  #define SONYPI_TYPE2_REGION_SIZE       0x20
17614 +#define SONYPI_TYPE2_EVTYPE_OFFSET     0x12
17615  
17616  /* battery / brightness addresses */
17617  #define SONYPI_BAT_FLAGS       0x81
17618 @@ -167,6 +169,7 @@
17619  #define SONYPI_THUMBPHRASE_MASK                        0x00000200
17620  #define SONYPI_MEYE_MASK                       0x00000400
17621  #define SONYPI_MEMORYSTICK_MASK                        0x00000800
17622 +#define SONYPI_BATTERY_MASK                    0x00001000
17623  
17624  struct sonypi_event {
17625         u8      data;
17626 @@ -293,6 +296,13 @@
17627         { 0, 0 }
17628  };
17629  
17630 +/* The set of possible battery events */
17631 +static struct sonypi_event sonypi_batteryev[] = {
17632 +       { 0x20, SONYPI_EVENT_BATTERY_INSERT },
17633 +       { 0x30, SONYPI_EVENT_BATTERY_REMOVE },
17634 +       { 0, 0 }
17635 +};
17636 +
17637  struct sonypi_eventtypes {
17638         int                     model;
17639         u8                      data;
17640 @@ -307,19 +317,22 @@
17641         { SONYPI_DEVICE_MODEL_TYPE1, 0x20, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
17642         { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
17643         { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_PKEY_MASK, sonypi_pkeyev },
17644 +       { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
17645 +       { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_BATTERY_MASK, sonypi_batteryev },
17646  
17647         { SONYPI_DEVICE_MODEL_TYPE2, 0, 0xffffffff, sonypi_releaseev },
17648         { SONYPI_DEVICE_MODEL_TYPE2, 0x38, SONYPI_LID_MASK, sonypi_lidev },
17649 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_JOGGER_MASK, sonypi_joggerev },
17650 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_CAPTURE_MASK, sonypi_captureev },
17651 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
17652 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
17653 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_JOGGER_MASK, sonypi_joggerev },
17654 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x61, SONYPI_CAPTURE_MASK, sonypi_captureev },
17655 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
17656 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
17657         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev },
17658 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_BACK_MASK, sonypi_backev },
17659 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev },
17660         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_HELP_MASK, sonypi_helpev },
17661         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_ZOOM_MASK, sonypi_zoomev },
17662         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev },
17663 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
17664 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
17665 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev },
17666  
17667         { 0, 0, 0, 0 }
17668  };
17669 @@ -354,6 +367,7 @@
17670         u16 ioport1;
17671         u16 ioport2;
17672         u16 region_size;
17673 +       u16 evtype_offset;
17674         int camera_power;
17675         int bluetooth_power;
17676         struct semaphore lock;
17677 diff -Nru a/drivers/char/stallion.c b/drivers/char/stallion.c
17678 --- a/drivers/char/stallion.c   Wed Jul 30 04:37:51 2003
17679 +++ b/drivers/char/stallion.c   Sun Aug 24 05:39:23 2003
17680 @@ -3078,7 +3078,7 @@
17681                 (int) fp, cmd, (int) arg);
17682  #endif
17683  
17684 -       brdnr = minor(ip->i_rdev);
17685 +       brdnr = iminor(ip);
17686         if (brdnr >= STL_MAXBRDS)
17687                 return(-ENODEV);
17688         rc = 0;
17689 @@ -4234,7 +4234,7 @@
17690         misr = inb(ioaddr + EREG_DATA);
17691         if (misr & MISR_DCD) {
17692                 set_bit(ASYI_DCDCHANGE, &portp->istate);
17693 -               schedule_task(&portp->tqueue);
17694 +               schedule_work(&portp->tqueue);
17695                 portp->stats.modem++;
17696         }
17697  
17698 @@ -5031,7 +5031,7 @@
17699         if ((len == 0) || ((len < STL_TXBUFLOW) &&
17700             (test_bit(ASYI_TXLOW, &portp->istate) == 0))) {
17701                 set_bit(ASYI_TXLOW, &portp->istate);
17702 -               schedule_task(&portp->tqueue); 
17703 +               schedule_work(&portp->tqueue); 
17704         }
17705  
17706         if (len == 0) {
17707 @@ -5248,7 +5248,7 @@
17708                 ipr = stl_sc26198getreg(portp, IPR);
17709                 if (ipr & IPR_DCDCHANGE) {
17710                         set_bit(ASYI_DCDCHANGE, &portp->istate);
17711 -                       schedule_task(&portp->tqueue); 
17712 +                       schedule_work(&portp->tqueue); 
17713                         portp->stats.modem++;
17714                 }
17715                 break;
17716 diff -Nru a/drivers/char/tipar.c b/drivers/char/tipar.c
17717 --- a/drivers/char/tipar.c      Wed May  7 08:47:30 2003
17718 +++ b/drivers/char/tipar.c      Tue Aug 26 09:25:41 2003
17719 @@ -248,7 +248,7 @@
17720  static int
17721  tipar_open(struct inode *inode, struct file *file)
17722  {
17723 -       unsigned int minor = minor(inode->i_rdev) - TIPAR_MINOR;
17724 +       unsigned int minor = iminor(inode) - TIPAR_MINOR;
17725  
17726         if (minor > tp_count - 1)
17727                 return -ENXIO;
17728 @@ -266,7 +266,7 @@
17729  static int
17730  tipar_close(struct inode *inode, struct file *file)
17731  {
17732 -       unsigned int minor = minor(inode->i_rdev) - TIPAR_MINOR;
17733 +       unsigned int minor = iminor(inode) - TIPAR_MINOR;
17734  
17735         if (minor > tp_count - 1)
17736                 return -ENXIO;
17737 @@ -279,8 +279,7 @@
17738  static ssize_t
17739  tipar_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
17740  {
17741 -       unsigned int minor =
17742 -           minor(file->f_dentry->d_inode->i_rdev) - TIPAR_MINOR;
17743 +       unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
17744         ssize_t n;
17745  
17746         parport_claim_or_block(table[minor].dev);
17747 @@ -308,8 +307,7 @@
17748  tipar_read(struct file *file, char *buf, size_t count, loff_t * ppos)
17749  {
17750         int b = 0;
17751 -       unsigned int minor =
17752 -           minor(file->f_dentry->d_inode->i_rdev) - TIPAR_MINOR;
17753 +       unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
17754         ssize_t retval = 0;
17755         ssize_t n = 0;
17756  
17757 diff -Nru a/drivers/char/tpqic02.c b/drivers/char/tpqic02.c
17758 --- a/drivers/char/tpqic02.c    Wed May  7 08:47:30 2003
17759 +++ b/drivers/char/tpqic02.c    Tue Aug 26 09:25:41 2003
17760 @@ -169,7 +169,7 @@
17761  static volatile unsigned dma_mode;     /* !=0 also means DMA in use */
17762  static flag need_rewind = YES;
17763  
17764 -static kdev_t current_tape_dev;
17765 +static int current_type;
17766  static int extra_blocks_left = BLOCKS_BEYOND_EW;
17767  static struct timer_list tp_timer;
17768  
17769 @@ -677,7 +677,7 @@
17770          * exception flag from previous exception which we are trying to clear.
17771          */
17772  
17773 -       if (TP_DIAGS(current_tape_dev))
17774 +       if (TP_DIAGS(current_type))
17775                 printk(TPQIC02_NAME ": reading status bytes: ");
17776  
17777         for (q = stp; q < stp + size; q++) {
17778 @@ -693,7 +693,7 @@
17779  
17780                 *q = inb_p(QIC02_DATA_PORT);    /* read status byte */
17781  
17782 -               if (TP_DIAGS(current_tape_dev))
17783 +               if (TP_DIAGS(current_type))
17784                         printk("[%1d]=0x%x  ", q - stp, (unsigned) (*q) & 0xff);
17785  
17786                 outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);    /* set request */
17787 @@ -714,7 +714,7 @@
17788                 cpu_relax();
17789         /* wait for ready */
17790  
17791 -       if (TP_DIAGS(current_tape_dev))
17792 +       if (TP_DIAGS(current_type))
17793                 printk("\n");
17794  
17795         return TE_OK;
17796 @@ -1614,7 +1614,7 @@
17797  
17798         if (status_expect_int) {
17799  #ifdef WANT_EXTRA_FULL_DEBUGGING
17800 -               if (TP_DIAGS(current_tape_dev))
17801 +               if (TP_DIAGS(current_type))
17802                         printk("@");
17803  #endif
17804                 stat = inb(QIC02_STAT_PORT);    /* Knock, knock */
17805 @@ -1726,7 +1726,7 @@
17806  
17807  static ssize_t qic02_tape_read(struct file *filp, char *buf, size_t count, loff_t * ppos)
17808  {
17809 -       kdev_t dev = filp->f_dentry->d_inode->i_rdev;
17810 +       int type = iminor(filp->f_dentry->d_inode);
17811         unsigned short flags = filp->f_flags;
17812         unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
17813         int stat;
17814 @@ -1736,8 +1736,8 @@
17815                 return -ENXIO;
17816         }
17817  
17818 -       if (TP_DIAGS(current_tape_dev))
17819 -               printk(TPQIC02_NAME ": request READ, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n", minor(dev), buf,
17820 +       if (TP_DIAGS(current_type))
17821 +               printk(TPQIC02_NAME ": request READ, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n", type, buf,
17822                        (long) count, filp->f_pos, flags);
17823  
17824         if (count % TAPE_BLKSIZE) {     /* Only allow mod 512 bytes at a time. */
17825 @@ -1904,7 +1904,7 @@
17826   */
17827  static ssize_t qic02_tape_write(struct file *filp, const char *buf, size_t count, loff_t * ppos)
17828  {
17829 -       kdev_t dev = filp->f_dentry->d_inode->i_rdev;
17830 +       int type = iminor(filp->f_dentry->d_inode);
17831         unsigned short flags = filp->f_flags;
17832         unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
17833  
17834 @@ -1913,9 +1913,9 @@
17835                 return -ENXIO;
17836         }
17837  
17838 -       if (TP_DIAGS(current_tape_dev)) {
17839 +       if (TP_DIAGS(current_type)) {
17840                 printk(TPQIC02_NAME ": request WRITE, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n",
17841 -                      minor(dev), buf, (long) count, filp->f_pos, flags);
17842 +                      type, buf, (long) count, filp->f_pos, flags);
17843         }
17844  
17845         if (count % TAPE_BLKSIZE) {     /* only allow mod 512 bytes at a time */
17846 @@ -2070,17 +2070,18 @@
17847  static int qic02_tape_open_no_use_count(struct inode *inode,
17848                                         struct file *filp)
17849  {
17850 -       kdev_t dev = inode->i_rdev;
17851 +       int type = iminor(inode);
17852         unsigned short flags = filp->f_flags;
17853         unsigned short dens = 0;
17854         int s;
17855  
17856  
17857 -       if (TP_DIAGS(dev)) {
17858 -               printk("qic02_tape_open: dev=%s, flags=%x     ", cdevname(dev), flags);
17859 +       if (TP_DIAGS(type)) {
17860 +               printk("qic02_tape_open: dev=tpqic2(%d), flags=%x     ",
17861 +                       type, flags);
17862         }
17863  
17864 -       if (minor(dev) == 255) {        /* special case for resetting */
17865 +       if (type == 255) {      /* special case for resetting */
17866                 if (capable(CAP_SYS_ADMIN)) {
17867                         return (tape_reset(1) == TE_OK) ? -EAGAIN : -ENXIO;
17868                 } else {
17869 @@ -2162,7 +2163,7 @@
17870          */
17871  
17872         /* not allowed to do QCMD_DENS_* unless tape is rewound */
17873 -       if ((TP_DENS(dev) != 0) && (TP_DENS(current_tape_dev) != TP_DENS(dev))) {
17874 +       if ((TP_DENS(type) != 0) && (TP_DENS(current_type) != TP_DENS(type))) {
17875                 /* force rewind if minor bits have changed,
17876                  * i.e. user wants to use tape in different format.
17877                  * [assuming single drive operation]
17878 @@ -2175,7 +2176,7 @@
17879                 /* density bits still the same, but TP_DIAGS bit 
17880                  * may have changed.
17881                  */
17882 -               current_tape_dev = dev;
17883 +               current_type = type;
17884         }
17885  
17886         if (need_rewind == YES) {
17887 @@ -2212,14 +2213,14 @@
17888          * so we must have done a rewind by now. If not, just skip over.
17889          * Only give set density command when minor bits have changed.
17890          */
17891 -       if (TP_DENS(current_tape_dev) == TP_DENS(dev)) {
17892 +       if (TP_DENS(current_type) == TP_DENS(type)) {
17893                 return 0;
17894         }
17895  
17896 -       current_tape_dev = dev;
17897 +       current_type = type;
17898         need_rewind = NO;
17899         if (TP_HAVE_DENS) {
17900 -               dens = TP_DENS(dev);
17901 +               dens = TP_DENS(type);
17902         }
17903  
17904         if (dens < sizeof(format_names) / sizeof(char *))
17905 @@ -2227,7 +2228,7 @@
17906         else
17907                 tpqputs(TPQD_REWIND, "Wait for retensioning...");
17908  
17909 -       switch (TP_DENS(dev)) {
17910 +       switch (TP_DENS(type)) {
17911         case 0:         /* Minor 0 is for drives without set-density support */
17912                 s = 0;
17913                 break;
17914 @@ -2254,7 +2255,7 @@
17915         }
17916         if (s != 0) {
17917                 status_dead = YES;      /* force reset */
17918 -               current_tape_dev = NODEV;/* earlier 0xff80 */
17919 +               current_type = 0;/* earlier 0xff80 */
17920                 return -EIO;
17921         }
17922  
17923 @@ -2264,10 +2265,10 @@
17924  
17925  static int qic02_tape_release(struct inode *inode, struct file *filp)
17926  {
17927 -       kdev_t dev = inode->i_rdev;
17928 +       int type = iminor(inode);
17929  
17930 -       if (TP_DIAGS(dev)) {
17931 -               printk("qic02_tape_release: dev=%s\n", cdevname(dev));
17932 +       if (TP_DIAGS(type)) {
17933 +               printk("qic02_tape_release: dev=tpqic2(%d)\n", type);
17934         }
17935  
17936         if (status_zombie == NO) {      /* don't rewind in zombie mode */
17937 @@ -2283,7 +2284,7 @@
17938                 /* Rewind only if minor number requires it AND 
17939                  * read/writes have been done. ************* IS THIS CORRECT??????????
17940                  */
17941 -               if ((TP_REWCLOSE(dev)) && (status_bytes_rd | status_bytes_wr)) {
17942 +               if (TP_REWCLOSE(type) && (status_bytes_rd | status_bytes_wr)) {
17943                         tpqputs(TPQD_REWIND, "release: Doing rewind...");
17944                         (void) do_qic_cmd(QCMD_REWIND, TIM_R);
17945                 }
17946 @@ -2398,7 +2399,7 @@
17947         struct mtpos ioctl_tell;
17948  
17949  
17950 -       if (TP_DIAGS(current_tape_dev))
17951 +       if (TP_DIAGS(current_type))
17952                 printk(TPQIC02_NAME ": ioctl(%4x, %4lx)\n", iocmd, ioarg);
17953  
17954         if (!inode)
17955 @@ -2459,7 +2460,7 @@
17956                  * ---      tape at the beginning of the current file.
17957                  */
17958  
17959 -               if (TP_DIAGS(current_tape_dev))
17960 +               if (TP_DIAGS(current_type))
17961                         printk("OP op=%4x, count=%4x\n", operation.mt_op, operation.mt_count);
17962  
17963                 if (operation.mt_count < 0)
17964 @@ -2492,7 +2493,7 @@
17965                 return 0;
17966  
17967         } else if (c == _IOC_NR(MTIOCGET)) {
17968 -               if (TP_DIAGS(current_tape_dev))
17969 +               if (TP_DIAGS(current_type))
17970                         printk("GET ");
17971  
17972                 CHECK_IOC_SIZE(mtget);
17973 @@ -2507,7 +2508,7 @@
17974                         return -EFAULT;
17975                 return 0;
17976         } else if (TP_HAVE_TELL && (c == _IOC_NR(MTIOCPOS))) {
17977 -               if (TP_DIAGS(current_tape_dev))
17978 +               if (TP_DIAGS(current_type))
17979                         printk("POS ");
17980  
17981                 CHECK_IOC_SIZE(mtpos);
17982 @@ -2664,7 +2665,7 @@
17983                 return -ENODEV;
17984         }
17985  
17986 -       current_tape_dev = mk_kdev(QIC02_TAPE_MAJOR, 0);
17987 +       current_type = 0;
17988  
17989  #ifndef CONFIG_QIC02_DYNCONF
17990         printk(TPQIC02_NAME ": IRQ %d, DMA %d, IO 0x%x, IFC %s, %s, %s\n",
17991 diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
17992 --- a/drivers/char/tty_io.c     Fri Aug  1 02:22:20 2003
17993 +++ b/drivers/char/tty_io.c     Sun Aug 31 16:15:47 2003
17994 @@ -177,7 +177,7 @@
17995  
17996  EXPORT_SYMBOL(tty_name);
17997  
17998 -inline int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
17999 +inline int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
18000                               const char *routine)
18001  {
18002  #ifdef TTY_PARANOIA_CHECK
18003 @@ -187,11 +187,11 @@
18004                 "Warning: null TTY for (%s) in %s\n";
18005  
18006         if (!tty) {
18007 -               printk(badtty, cdevname(device), routine);
18008 +               printk(badtty, cdevname(inode->i_rdev), routine);
18009                 return 1;
18010         }
18011         if (tty->magic != TTY_MAGIC) {
18012 -               printk(badmagic, cdevname(device), routine);
18013 +               printk(badmagic, cdevname(inode->i_rdev), routine);
18014                 return 1;
18015         }
18016  #endif
18017 @@ -646,7 +646,7 @@
18018  
18019         tty = (struct tty_struct *)file->private_data;
18020         inode = file->f_dentry->d_inode;
18021 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_read"))
18022 +       if (tty_paranoia_check(tty, inode, "tty_read"))
18023                 return -EIO;
18024         if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags)))
18025                 return -EIO;
18026 @@ -763,7 +763,7 @@
18027         }
18028  
18029         tty = (struct tty_struct *)file->private_data;
18030 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_write"))
18031 +       if (tty_paranoia_check(tty, inode, "tty_write"))
18032                 return -EIO;
18033         if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags)))
18034                 return -EIO;
18035 @@ -1023,7 +1023,7 @@
18036                 o_tty->magic = 0;
18037                 o_tty->driver->refcount--;
18038                 file_list_lock();
18039 -               list_del(&o_tty->tty_files);
18040 +               list_del_init(&o_tty->tty_files);
18041                 file_list_unlock();
18042                 free_tty_struct(o_tty);
18043         }
18044 @@ -1037,7 +1037,7 @@
18045         tty->magic = 0;
18046         tty->driver->refcount--;
18047         file_list_lock();
18048 -       list_del(&tty->tty_files);
18049 +       list_del_init(&tty->tty_files);
18050         file_list_unlock();
18051         module_put(tty->driver->owner);
18052         free_tty_struct(tty);
18053 @@ -1059,7 +1059,7 @@
18054         char    buf[64];
18055         
18056         tty = (struct tty_struct *)filp->private_data;
18057 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "release_dev"))
18058 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "release_dev"))
18059                 return;
18060  
18061         check_tty_count(tty, "release_dev");
18062 @@ -1439,7 +1439,7 @@
18063         struct tty_struct * tty;
18064  
18065         tty = (struct tty_struct *)filp->private_data;
18066 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "tty_poll"))
18067 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "tty_poll"))
18068                 return 0;
18069  
18070         if (tty->ldisc.poll)
18071 @@ -1453,7 +1453,7 @@
18072         int retval;
18073  
18074         tty = (struct tty_struct *)filp->private_data;
18075 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "tty_fasync"))
18076 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "tty_fasync"))
18077                 return 0;
18078         
18079         retval = fasync_helper(fd, filp, on, &tty->fasync);
18080 @@ -1727,7 +1727,7 @@
18081         int retval;
18082         
18083         tty = (struct tty_struct *)file->private_data;
18084 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
18085 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
18086                 return -EINVAL;
18087  
18088         real_tty = tty;
18089 diff -Nru a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
18090 --- a/drivers/char/vc_screen.c  Wed May  7 08:47:30 2003
18091 +++ b/drivers/char/vc_screen.c  Tue Aug 26 09:25:41 2003
18092 @@ -49,7 +49,7 @@
18093  vcs_size(struct inode *inode)
18094  {
18095         int size;
18096 -       int minor = minor(inode->i_rdev);
18097 +       int minor = iminor(inode);
18098         int currcons = minor & 127;
18099         if (currcons == 0)
18100                 currcons = fg_console;
18101 @@ -104,7 +104,7 @@
18102  vcs_read(struct file *file, char *buf, size_t count, loff_t *ppos)
18103  {
18104         struct inode *inode = file->f_dentry->d_inode;
18105 -       unsigned int currcons = minor(inode->i_rdev);
18106 +       unsigned int currcons = iminor(inode);
18107         long pos = *ppos;
18108         long viewed, attr, read;
18109         int col, maxcol;
18110 @@ -273,7 +273,7 @@
18111  vcs_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
18112  {
18113         struct inode *inode = file->f_dentry->d_inode;
18114 -       unsigned int currcons = minor(inode->i_rdev);
18115 +       unsigned int currcons = iminor(inode);
18116         long pos = *ppos;
18117         long viewed, attr, size, written;
18118         char *con_buf0;
18119 @@ -456,7 +456,7 @@
18120  static int
18121  vcs_open(struct inode *inode, struct file *filp)
18122  {
18123 -       unsigned int currcons = minor(inode->i_rdev) & 127;
18124 +       unsigned int currcons = iminor(inode) & 127;
18125         if(currcons && !vc_cons_allocated(currcons-1))
18126                 return -ENXIO;
18127         return 0;
18128 diff -Nru a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
18129 --- a/drivers/char/watchdog/Kconfig     Mon Jul 28 13:28:55 2003
18130 +++ b/drivers/char/watchdog/Kconfig     Sun Aug 31 11:39:56 2003
18131 @@ -346,6 +346,18 @@
18132           module, say M here and read <file:Documentation/modules.txt>.  Most
18133           people will say N.
18134  
18135 +config ALIM1535_WDT
18136 +       tristate "ALi M1535 PMU Watchdog Timer"
18137 +       depends on WATCHDOG
18138 +       ---help---
18139 +         This is the driver for the hardware watchdog on the ALi M1535 PMU.
18140 +
18141 +         This driver is also available as a module ( = code which can be
18142 +         inserted in and removed from the running kernel whenever you want).
18143 +         The module is called alim1535_wdt.  If you want to compile it as a
18144 +         module, say M here and read <file:Documentation/modules.txt>.  Most
18145 +         people will say N.
18146 +
18147  config SC1200_WDT
18148         tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"
18149         depends on WATCHDOG
18150 diff -Nru a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
18151 --- a/drivers/char/watchdog/Makefile    Thu Feb 27 12:38:45 2003
18152 +++ b/drivers/char/watchdog/Makefile    Sun Aug 31 11:39:56 2003
18153 @@ -27,6 +27,7 @@
18154  obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
18155  obj-$(CONFIG_SC520_WDT) += sc520_wdt.o
18156  obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o
18157 +obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o
18158  obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
18159  obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
18160  obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
18161 diff -Nru a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c
18162 --- a/drivers/char/watchdog/acquirewdt.c        Fri Aug  8 03:28:08 2003
18163 +++ b/drivers/char/watchdog/acquirewdt.c        Sun Aug 31 14:15:12 2003
18164 @@ -1,5 +1,5 @@
18165  /*
18166 - *     Acquire Single Board Computer Watchdog Timer driver for Linux 2.1.x
18167 + *     Acquire Single Board Computer Watchdog Timer driver
18168   *
18169   *      Based on wdt.c. Original copyright messages:
18170   *
18171 @@ -10,10 +10,10 @@
18172   *     modify it under the terms of the GNU General Public License
18173   *     as published by the Free Software Foundation; either version
18174   *     2 of the License, or (at your option) any later version.
18175 - *     
18176 - *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
18177 - *     warranty for any of this software. This material is provided 
18178 - *     "AS-IS" and at no charge.       
18179 + *
18180 + *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
18181 + *     warranty for any of this software. This material is provided
18182 + *     "AS-IS" and at no charge.
18183   *
18184   *     (c) Copyright 1995    Alan Cox <alan@redhat.com>
18185   *
18186 @@ -22,33 +22,39 @@
18187   *          Can't add timeout - driver doesn't allow changing value
18188   */
18189  
18190 -#include <linux/config.h>
18191  #include <linux/module.h>
18192  #include <linux/moduleparam.h>
18193  #include <linux/types.h>
18194  #include <linux/miscdevice.h>
18195  #include <linux/watchdog.h>
18196 +#include <linux/fs.h>
18197  #include <linux/ioport.h>
18198  #include <linux/notifier.h>
18199 -#include <linux/fs.h>
18200  #include <linux/reboot.h>
18201  #include <linux/init.h>
18202 -#include <linux/spinlock.h>
18203  
18204  #include <asm/io.h>
18205  #include <asm/uaccess.h>
18206  #include <asm/system.h>
18207  
18208 -static int acq_is_open;
18209 -static spinlock_t acq_lock;
18210 -static int expect_close = 0;
18211 +#define WATCHDOG_NAME "Acquire WDT"
18212 +#define PFX WATCHDOG_NAME ": "
18213 +#define WATCHDOG_TIMEOUT 0     /* ??? Is the timeout hardcoded to 1 minute ??? */
18214 +
18215 +static unsigned long acq_is_open;
18216 +static char expect_close;
18217  
18218  /*
18219   *     You must set these - there is no sane way to probe for this board.
18220   */
18221
18222 -#define WDT_STOP 0x43
18223 -#define WDT_START 0x443
18224 +
18225 +static int wdt_stop = 0x43;
18226 +module_param(wdt_stop, int, 0);
18227 +MODULE_PARM_DESC(wdt_stop, "Acquire WDT 'stop' io port (default 0x43)");
18228 +
18229 +static int wdt_start = 0x443;
18230 +module_param(wdt_start, int, 0);
18231 +MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)");
18232  
18233  #ifdef CONFIG_WATCHDOG_NOWAYOUT
18234  static int nowayout = 1;
18235 @@ -62,38 +68,52 @@
18236  /*
18237   *     Kernel methods.
18238   */
18239
18240  
18241  static void acq_ping(void)
18242  {
18243         /* Write a watchdog value */
18244 -       inb_p(WDT_START);
18245 +       inb_p(wdt_start);
18246  }
18247  
18248 +static void acq_stop(void)
18249 +{
18250 +       /* Turn the card off */
18251 +       inb_p(wdt_stop);
18252 +}
18253 +
18254 +/*
18255 + *     /dev/watchdog handling.
18256 + */
18257 +
18258  static ssize_t acq_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
18259  {
18260         /*  Can't seek (pwrite) on this device  */
18261         if (ppos != &file->f_pos)
18262                 return -ESPIPE;
18263  
18264 +       /* See if we got the magic character 'V' and reload the timer */
18265         if(count) {
18266                 if (!nowayout) {
18267                         size_t i;
18268  
18269 +                       /* note: just in case someone wrote the magic character
18270 +                        * five months ago... */
18271                         expect_close = 0;
18272  
18273 +                       /* scan to see wether or not we got the magic character */
18274                         for (i = 0; i != count; i++) {
18275                                 char c;
18276                                 if (get_user(c, buf + i))
18277                                         return -EFAULT;
18278                                 if (c == 'V')
18279 -                                       expect_close = 1;
18280 +                                       expect_close = 42;
18281                         }
18282                 }
18283 +
18284 +               /* Well, anyhow someone wrote to us, we should return that favour */
18285                 acq_ping();
18286 -               return 1;
18287         }
18288 -       return 0;
18289 +       return count;
18290  }
18291  
18292  static int acq_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
18293 @@ -103,65 +123,75 @@
18294         {
18295                 .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
18296                 .firmware_version = 1,
18297 -               .identity = "Acquire WDT"
18298 +               .identity = "Acquire WDT",
18299         };
18300 -       
18301 +
18302         switch(cmd)
18303         {
18304         case WDIOC_GETSUPPORT:
18305 -         if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
18306 -           return -EFAULT;
18307 -         break;
18308 -         
18309 +         return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)) ? -EFAULT : 0;
18310 +
18311         case WDIOC_GETSTATUS:
18312 -         if (copy_to_user((int *)arg, &acq_is_open,  sizeof(int)))
18313 -           return -EFAULT;
18314 -         break;
18315 +       case WDIOC_GETBOOTSTATUS:
18316 +         return put_user(0, (int *)arg);
18317  
18318         case WDIOC_KEEPALIVE:
18319           acq_ping();
18320 -         break;
18321 +         return 0;
18322 +
18323 +       case WDIOC_GETTIMEOUT:
18324 +         return put_user(WATCHDOG_TIMEOUT, (int *)arg);
18325 +
18326 +       case WDIOC_SETOPTIONS:
18327 +       {
18328 +           int options, retval = -EINVAL;
18329 +
18330 +           if (get_user(options, (int *)arg))
18331 +             return -EFAULT;
18332 +
18333 +           if (options & WDIOS_DISABLECARD)
18334 +           {
18335 +             acq_stop();
18336 +             retval = 0;
18337 +           }
18338 +
18339 +           if (options & WDIOS_ENABLECARD)
18340 +           {
18341 +             acq_ping();
18342 +             retval = 0;
18343 +           }
18344 +
18345 +           return retval;
18346 +       }
18347  
18348         default:
18349 -         return -ENOTTY;
18350 +         return -ENOIOCTLCMD;
18351         }
18352 -       return 0;
18353  }
18354  
18355  static int acq_open(struct inode *inode, struct file *file)
18356  {
18357 -       if ((minor(inode->i_rdev) == WATCHDOG_MINOR)) {
18358 -               spin_lock(&acq_lock);
18359 -               if(acq_is_open) {
18360 -                       spin_unlock(&acq_lock);
18361 -                       return -EBUSY;
18362 -               }
18363 -               if (nowayout)
18364 -                       __module_get(THIS_MODULE);
18365 +       if (test_and_set_bit(0, &acq_is_open))
18366 +               return -EBUSY;
18367  
18368 -               /* Activate */
18369 -               acq_is_open=1;
18370 -               inb_p(WDT_START);      
18371 -               spin_unlock(&acq_lock);
18372 -               return 0;
18373 +       if (nowayout)
18374 +               __module_get(THIS_MODULE);
18375  
18376 -       } else {
18377 -               return -ENODEV;
18378 -       }
18379 +       /* Activate */
18380 +       acq_ping();
18381 +       return 0;
18382  }
18383  
18384  static int acq_close(struct inode *inode, struct file *file)
18385  {
18386 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR) {
18387 -               spin_lock(&acq_lock);
18388 -               if (expect_close)
18389 -                       inb_p(WDT_STOP);
18390 -               else
18391 -                       printk(KERN_CRIT "WDT closed unexpectedly.  WDT will not stop!\n");
18392 -
18393 -               acq_is_open=0;
18394 -               spin_unlock(&acq_lock);
18395 +       if (expect_close == 42) {
18396 +               acq_stop();
18397 +       } else {
18398 +               printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
18399 +               acq_ping();
18400         }
18401 +       clear_bit(0, &acq_is_open);
18402 +       expect_close = 0;
18403         return 0;
18404  }
18405  
18406 @@ -172,20 +202,20 @@
18407  static int acq_notify_sys(struct notifier_block *this, unsigned long code,
18408         void *unused)
18409  {
18410 -       if(code==SYS_DOWN || code==SYS_HALT)
18411 -               /* Turn the card off */
18412 -               inb_p(WDT_STOP);
18413 -
18414 +       if(code==SYS_DOWN || code==SYS_HALT) {
18415 +               /* Turn the WDT off */
18416 +               acq_stop();
18417 +       }
18418         return NOTIFY_DONE;
18419  }
18420
18421 +
18422  /*
18423   *     Kernel Interfaces
18424   */
18425
18426
18427 +
18428  static struct file_operations acq_fops = {
18429         .owner          = THIS_MODULE,
18430 +       .llseek         = no_llseek,
18431         .write          = acq_write,
18432         .ioctl          = acq_ioctl,
18433         .open           = acq_open,
18434 @@ -196,52 +226,84 @@
18435  {
18436         .minor = WATCHDOG_MINOR,
18437         .name = "watchdog",
18438 -       .fops = &acq_fops
18439 +       .fops = &acq_fops,
18440  };
18441  
18442 -
18443  /*
18444   *     The WDT card needs to learn about soft shutdowns in order to
18445 - *     turn the timebomb registers off. 
18446 + *     turn the timebomb registers off.
18447   */
18448
18449 +
18450  static struct notifier_block acq_notifier =
18451  {
18452         .notifier_call = acq_notify_sys,
18453         .next = NULL,
18454 -       .priority = 0
18455 +       .priority = 0,
18456  };
18457  
18458  static int __init acq_init(void)
18459  {
18460 +       int ret;
18461 +
18462         printk(KERN_INFO "WDT driver for Acquire single board computer initialising.\n");
18463  
18464 -       spin_lock_init(&acq_lock);
18465 -       if (misc_register(&acq_miscdev))
18466 -               return -ENODEV;
18467 -       if (!request_region(WDT_STOP, 1, "Acquire WDT")) {
18468 -               misc_deregister(&acq_miscdev);
18469 -               return -EIO;
18470 -       }
18471 -       if (!request_region(WDT_START, 1, "Acquire WDT")) {
18472 -               release_region(WDT_STOP, 1);
18473 -               misc_deregister(&acq_miscdev);
18474 -               return -EIO;
18475 +       if (wdt_stop != wdt_start) {
18476 +               if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
18477 +                       printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
18478 +                               wdt_stop);
18479 +                       ret = -EIO;
18480 +                       goto out;
18481 +               }
18482         }
18483  
18484 -       register_reboot_notifier(&acq_notifier);
18485 -       return 0;
18486 +       if (!request_region(wdt_start, 1, WATCHDOG_NAME)) {
18487 +               printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
18488 +                       wdt_start);
18489 +               ret = -EIO;
18490 +               goto unreg_stop;
18491 +       }
18492 +
18493 +        ret = register_reboot_notifier(&acq_notifier);
18494 +        if (ret != 0) {
18495 +                printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
18496 +                        ret);
18497 +                goto unreg_regions;
18498 +        }
18499 +                                                                                                 
18500 +        ret = misc_register(&acq_miscdev);
18501 +        if (ret != 0) {
18502 +                printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
18503 +                        WATCHDOG_MINOR, ret);
18504 +                goto unreg_reboot;
18505 +        }
18506 +                                                                                                 
18507 +        printk (KERN_INFO PFX "initialized. (nowayout=%d)\n",
18508 +                nowayout);
18509 +                                                                                                 
18510 +out:
18511 +        return ret;
18512 +unreg_reboot:
18513 +        unregister_reboot_notifier(&acq_notifier);
18514 +unreg_regions:
18515 +        release_region(wdt_start, 1);
18516 +unreg_stop:
18517 +        if (wdt_stop != wdt_start)
18518 +                release_region(wdt_stop, 1);
18519 +        goto out;
18520  }
18521 -       
18522 +
18523  static void __exit acq_exit(void)
18524  {
18525         misc_deregister(&acq_miscdev);
18526         unregister_reboot_notifier(&acq_notifier);
18527 -       release_region(WDT_STOP,1);
18528 -       release_region(WDT_START,1);
18529 +       if(wdt_stop != wdt_start)
18530 +               release_region(wdt_stop,1);
18531 +       release_region(wdt_start,1);
18532  }
18533  
18534  module_init(acq_init);
18535  module_exit(acq_exit);
18536  
18537  MODULE_LICENSE("GPL");
18538 +MODULE_AUTHOR("Unkown");
18539 +MODULE_DESCRIPTION("Acquire Single Board Computer Watchdog Timer driver");
18540 diff -Nru a/drivers/char/watchdog/advantechwdt.c b/drivers/char/watchdog/advantechwdt.c
18541 --- a/drivers/char/watchdog/advantechwdt.c      Sat Aug  9 07:00:04 2003
18542 +++ b/drivers/char/watchdog/advantechwdt.c      Sat Aug 30 04:48:19 2003
18543 @@ -133,7 +133,7 @@
18544         static struct watchdog_info ident = {
18545                 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
18546                 .firmware_version = 1,
18547 -               .identity = "Advantech WDT"
18548 +               .identity = "Advantech WDT",
18549         };
18550  
18551         switch (cmd) {
18552 diff -Nru a/drivers/char/watchdog/alim1535_wdt.c b/drivers/char/watchdog/alim1535_wdt.c
18553 --- /dev/null   Wed Dec 31 16:00:00 1969
18554 +++ b/drivers/char/watchdog/alim1535_wdt.c      Sun Aug 31 11:38:01 2003
18555 @@ -0,0 +1,465 @@
18556 +/*
18557 + *     Watchdog for the 7101 PMU version found in the ALi M1535 chipsets
18558 + *
18559 + *     This program is free software; you can redistribute it and/or
18560 + *     modify it under the terms of the GNU General Public License
18561 + *     as published by the Free Software Foundation; either version
18562 + *     2 of the License, or (at your option) any later version.
18563 + */
18564 +
18565 +#include <linux/module.h>
18566 +#include <linux/moduleparam.h>
18567 +#include <linux/types.h>
18568 +#include <linux/miscdevice.h>
18569 +#include <linux/watchdog.h>
18570 +#include <linux/ioport.h>
18571 +#include <linux/notifier.h>
18572 +#include <linux/reboot.h>
18573 +#include <linux/init.h>
18574 +#include <linux/pci.h>
18575 +
18576 +#include <asm/uaccess.h>
18577 +#include <asm/io.h>
18578 +
18579 +#define WATCHDOG_NAME "ALi_M1535"
18580 +#define PFX WATCHDOG_NAME ": "
18581 +#define WATCHDOG_TIMEOUT 60    /* 60 sec default timeout */
18582 +
18583 +/* internal variables */
18584 +static unsigned long ali_is_open;
18585 +static char ali_expect_release;
18586 +static struct pci_dev *ali_pci;
18587 +static u32 ali_timeout_bits;   /* stores the computed timeout */
18588 +static spinlock_t ali_lock;    /* Guards the hardware */
18589 +
18590 +/* module parameters */
18591 +static int timeout = WATCHDOG_TIMEOUT;
18592 +module_param(timeout, int, 0);
18593 +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (0<timeout<18000, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
18594 +
18595 +#ifdef CONFIG_WATCHDOG_NOWAYOUT
18596 +static int nowayout = 1;
18597 +#else
18598 +static int nowayout = 0;
18599 +#endif
18600 +
18601 +module_param(nowayout, int, 0);
18602 +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
18603 +
18604 +/*
18605 + *     ali_start       -       start watchdog countdown
18606 + *
18607 + *     Starts the timer running providing the timer has a counter
18608 + *     configuration set.
18609 + */
18610 +
18611 +static void ali_start(void)
18612 +{
18613 +       u32 val;
18614 +
18615 +       spin_lock(&ali_lock);
18616 +
18617 +       pci_read_config_dword(ali_pci, 0xCC, &val);
18618 +       val &= ~0x3F;   /* Mask count */
18619 +       val |= (1<<25) | ali_timeout_bits;
18620 +       pci_write_config_dword(ali_pci, 0xCC, val);
18621 +
18622 +       spin_unlock(&ali_lock);
18623 +}
18624 +
18625 +/*
18626 + *     ali_stop        -       stop the timer countdown
18627 + *
18628 + *     Stop the ALi watchdog countdown
18629 + */
18630 +
18631 +static void ali_stop(void)
18632 +{
18633 +       u32 val;
18634 +
18635 +       spin_lock(&ali_lock);
18636 +
18637 +       pci_read_config_dword(ali_pci, 0xCC, &val);
18638 +       val &= ~0x3F;   /* Mask count to zero (disabled) */
18639 +       val &= ~(1<<25);/* and for safety mask the reset enable */
18640 +       pci_write_config_dword(ali_pci, 0xCC, val);
18641 +
18642 +       spin_unlock(&ali_lock);
18643 +}
18644 +
18645 +/*
18646 + *     ali_keepalive   -       send a keepalive to the watchdog
18647 + *
18648 + *      Send a keepalive to the timer (actually we restart the timer).
18649 + */
18650 +
18651 +static void ali_keepalive(void)
18652 +{
18653 +       ali_start();
18654 +}
18655 +
18656 +/*
18657 + *     ali_settimer    -       compute the timer reload value
18658 + *     @t: time in seconds
18659 + *
18660 + *     Computes the timeout values needed
18661 + */
18662 +
18663 +static int ali_settimer(int t)
18664 +{
18665 +       if(t < 0)
18666 +               return -EINVAL;
18667 +       else if(t < 60)
18668 +               ali_timeout_bits = t|(1<<6);
18669 +       else if(t < 3600)
18670 +               ali_timeout_bits = (t/60)|(1<<7);
18671 +       else if(t < 18000)
18672 +               ali_timeout_bits = (t/300)|(1<<6)|(1<<7);
18673 +       else return -EINVAL;
18674 +
18675 +       timeout = t;
18676 +       return 0;
18677 +}
18678 +
18679 +/*
18680 + *     /dev/watchdog handling
18681 + */
18682 +
18683 +/*
18684 + *     ali_write       -       writes to ALi watchdog
18685 + *     @file: file from VFS
18686 + *     @data: user address of data
18687 + *     @len: length of data
18688 + *     @ppos: pointer to the file offset
18689 + *
18690 + *     Handle a write to the ALi watchdog. Writing to the file pings
18691 + *     the watchdog and resets it. Writing the magic 'V' sequence allows
18692 + *     the next close to turn off the watchdog.
18693 + */
18694 +
18695 +static ssize_t ali_write(struct file *file, const char *data,
18696 +                             size_t len, loff_t * ppos)
18697 +{
18698 +       /*  Can't seek (pwrite) on this device  */
18699 +       if (ppos != &file->f_pos)
18700 +               return -ESPIPE;
18701 +
18702 +       /* See if we got the magic character 'V' and reload the timer */
18703 +       if (len) {
18704 +               if (!nowayout) {
18705 +                       size_t i;
18706 +
18707 +                       /* note: just in case someone wrote the magic character
18708 +                        * five months ago... */
18709 +                       ali_expect_release = 0;
18710 +
18711 +                       /* scan to see wether or not we got the magic character */
18712 +                       for (i = 0; i != len; i++) {
18713 +                               char c;
18714 +                               if(get_user(c, data+i))
18715 +                                       return -EFAULT;
18716 +                               if (c == 'V')
18717 +                                       ali_expect_release = 42;
18718 +                       }
18719 +               }
18720 +
18721 +               /* someone wrote to us, we should reload the timer */
18722 +               ali_start();
18723 +       }
18724 +       return len;
18725 +}
18726 +
18727 +/*
18728 + *     ali_ioctl       -       handle watchdog ioctls
18729 + *     @inode: VFS inode
18730 + *     @file: VFS file pointer
18731 + *     @cmd: ioctl number
18732 + *     @arg: arguments to the ioctl
18733 + *
18734 + *     Handle the watchdog ioctls supported by the ALi driver. Really
18735 + *     we want an extension to enable irq ack monitoring and the like
18736 + */
18737 +
18738 +static int ali_ioctl(struct inode *inode, struct file *file,
18739 +                         unsigned int cmd, unsigned long arg)
18740 +{
18741 +       static struct watchdog_info ident = {
18742 +               .options =              WDIOF_KEEPALIVEPING |
18743 +                                       WDIOF_SETTIMEOUT |
18744 +                                       WDIOF_MAGICCLOSE,
18745 +               .firmware_version =     0,
18746 +               .identity =             "ALi M1535 WatchDog Timer",
18747 +       };
18748 +
18749 +       switch (cmd) {
18750 +               case WDIOC_GETSUPPORT:
18751 +                       return copy_to_user((struct watchdog_info *) arg, &ident,
18752 +                               sizeof (ident)) ? -EFAULT : 0;
18753 +
18754 +               case WDIOC_GETSTATUS:
18755 +               case WDIOC_GETBOOTSTATUS:
18756 +                       return put_user(0, (int *) arg);
18757 +
18758 +               case WDIOC_KEEPALIVE:
18759 +                       ali_keepalive();
18760 +                       return 0;
18761 +
18762 +               case WDIOC_SETOPTIONS:
18763 +               {
18764 +                       int new_options, retval = -EINVAL;
18765 +
18766 +                       if (get_user (new_options, (int *) arg))
18767 +                               return -EFAULT;
18768 +
18769 +                       if (new_options & WDIOS_DISABLECARD) {
18770 +                               ali_stop();
18771 +                               retval = 0;
18772 +                       }
18773 +
18774 +                       if (new_options & WDIOS_ENABLECARD) {
18775 +                               ali_start();
18776 +                               retval = 0;
18777 +                       }
18778 +
18779 +                       return retval;
18780 +               }
18781 +
18782 +               case WDIOC_SETTIMEOUT:
18783 +               {
18784 +                       int new_timeout;
18785 +
18786 +                       if (get_user(new_timeout, (int *) arg))
18787 +                               return -EFAULT;
18788 +
18789 +                       if (ali_settimer(new_timeout))
18790 +                           return -EINVAL;
18791 +
18792 +                       ali_keepalive();
18793 +                       /* Fall */
18794 +               }
18795 +
18796 +               case WDIOC_GETTIMEOUT:
18797 +                       return put_user(timeout, (int *)arg);
18798 +
18799 +               default:
18800 +                       return -ENOIOCTLCMD;
18801 +       }
18802 +}
18803 +
18804 +/*
18805 + *     ali_open        -       handle open of ali watchdog
18806 + *     @inode: inode from VFS
18807 + *     @file: file from VFS
18808 + *
18809 + *     Open the ALi watchdog device. Ensure only one person opens it
18810 + *     at a time. Also start the watchdog running.
18811 + */
18812 +
18813 +static int ali_open(struct inode *inode, struct file *file)
18814 +{
18815 +       /* /dev/watchdog can only be opened once */
18816 +       if (test_and_set_bit(0, &ali_is_open))
18817 +               return -EBUSY;
18818 +
18819 +       /* Activate */
18820 +       ali_start();
18821 +       return 0;
18822 +}
18823 +
18824 +/*
18825 + *     ali_release     -       close an ALi watchdog
18826 + *     @inode: inode from VFS
18827 + *     @file: file from VFS
18828 + *
18829 + *     Close the ALi watchdog device. Actual shutdown of the timer
18830 + *     only occurs if the magic sequence has been set.
18831 + */
18832 +
18833 +static int ali_release(struct inode *inode, struct file *file)
18834 +{
18835 +       /*
18836 +        *      Shut off the timer.
18837 +        */
18838 +       if (ali_expect_release == 42) {
18839 +               ali_stop();
18840 +       } else {
18841 +               printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
18842 +               ali_keepalive();
18843 +       }
18844 +       clear_bit(0, &ali_is_open);
18845 +       ali_expect_release = 0;
18846 +       return 0;
18847 +}
18848 +
18849 +/*
18850 + *     ali_notify_sys  -       System down notifier
18851 + *
18852 + *     Notifier for system down
18853 + */
18854 +
18855 +
18856 +static int ali_notify_sys(struct notifier_block *this, unsigned long code, void *unused)
18857 +{
18858 +       if (code==SYS_DOWN || code==SYS_HALT) {
18859 +               /* Turn the WDT off */
18860 +               ali_stop();
18861 +       }
18862 +
18863 +       return NOTIFY_DONE;
18864 +}
18865 +
18866 +/*
18867 + *     Data for PCI driver interface
18868 + *
18869 + *     This data only exists for exporting the supported
18870 + *     PCI ids via MODULE_DEVICE_TABLE.  We do not actually
18871 + *     register a pci_driver, because someone else might one day
18872 + *     want to register another driver on the same PCI id.
18873 + */
18874 +
18875 +static struct pci_device_id ali_pci_tbl[] __initdata = {
18876 +       { PCI_VENDOR_ID_AL, 1535, PCI_ANY_ID, PCI_ANY_ID,},
18877 +       { 0, },
18878 +};
18879 +MODULE_DEVICE_TABLE(pci, ali_pci_tbl);
18880 +
18881 +/*
18882 + *     ali_find_watchdog       -       find a 1535 and 7101
18883 + *
18884 + *     Scans the PCI hardware for a 1535 series bridge and matching 7101
18885 + *     watchdog device. This may be overtight but it is better to be safe
18886 + */
18887 +
18888 +static int __init ali_find_watchdog(void)
18889 +{
18890 +       struct pci_dev *pdev;
18891 +       u32 wdog;
18892 +
18893 +       /* Check for a 1535 series bridge */
18894 +       pdev = pci_find_device(PCI_VENDOR_ID_AL, 0x1535, NULL);
18895 +       if(pdev == NULL)
18896 +               return -ENODEV;
18897 +
18898 +       /* Check for the a 7101 PMU */
18899 +       pdev = pci_find_device(PCI_VENDOR_ID_AL, 0x7101, NULL);
18900 +       if(pdev == NULL)
18901 +               return -ENODEV;
18902 +
18903 +       if(pci_enable_device(pdev))
18904 +               return -EIO;
18905 +
18906 +       ali_pci = pdev;
18907 +
18908 +       /*
18909 +        *      Initialize the timer bits
18910 +        */
18911 +       pci_read_config_dword(pdev, 0xCC, &wdog);
18912 +
18913 +       wdog &= ~0x3F;          /* Timer bits */
18914 +       wdog &= ~((1<<27)|(1<<26)|(1<<25)|(1<<24));     /* Issued events */
18915 +       wdog &= ~((1<<16)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9));      /* No monitor bits */
18916 +
18917 +       pci_write_config_dword(pdev, 0xCC, wdog);
18918 +
18919 +       return 0;
18920 +}
18921 +
18922 +/*
18923 + *     Kernel Interfaces
18924 + */
18925 +
18926 +static struct file_operations ali_fops = {
18927 +       .owner =        THIS_MODULE,
18928 +       .llseek =       no_llseek,
18929 +       .write =        ali_write,
18930 +       .ioctl =        ali_ioctl,
18931 +       .open =         ali_open,
18932 +       .release =      ali_release,
18933 +};
18934 +
18935 +static struct miscdevice ali_miscdev = {
18936 +       .minor =        WATCHDOG_MINOR,
18937 +       .name =         "watchdog",
18938 +       .fops =         &ali_fops,
18939 +};
18940 +
18941 +static struct notifier_block ali_notifier = {
18942 +       .notifier_call =        ali_notify_sys,
18943 +       .next =                 NULL,
18944 +       .priority =             0,
18945 +};
18946 +
18947 +/*
18948 + *     watchdog_init   -       module initialiser
18949 + *
18950 + *     Scan for a suitable watchdog and if so initialize it. Return an error
18951 + *     if we cannot, the error causes the module to unload
18952 + */
18953 +
18954 +static int __init watchdog_init(void)
18955 +{
18956 +       int ret;
18957 +
18958 +       spin_lock_init(&ali_lock);
18959 +
18960 +       /* Check wether or not the hardware watchdog is there */
18961 +       if (ali_find_watchdog() != 0) {
18962 +               return -ENODEV;
18963 +       }
18964 +
18965 +       /* Check that the timeout value is within it's range ; if not reset to the default */
18966 +       if (timeout < 1 || timeout >= 18000) {
18967 +               timeout = WATCHDOG_TIMEOUT;
18968 +               printk(KERN_INFO PFX "timeout value must be 0<timeout<18000, using %d\n",
18969 +                       timeout);
18970 +       }
18971 +
18972 +       /* Calculate the watchdog's timeout */
18973 +       ali_settimer(timeout);
18974 +
18975 +       ret = misc_register(&ali_miscdev);
18976 +       if (ret != 0) {
18977 +               printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
18978 +                       WATCHDOG_MINOR, ret);
18979 +               goto out;
18980 +       }
18981 +
18982 +       ret = register_reboot_notifier(&ali_notifier);
18983 +       if (ret != 0) {
18984 +               printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
18985 +                       ret);
18986 +               goto unreg_miscdev;
18987 +       }
18988 +
18989 +       printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
18990 +               timeout, nowayout);
18991 +
18992 +out:
18993 +       return ret;
18994 +unreg_miscdev:
18995 +       misc_deregister(&ali_miscdev);
18996 +       goto out;
18997 +}
18998 +
18999 +/*
19000 + *     watchdog_exit   -       module de-initialiser
19001 + *
19002 + *     Called while unloading a successfully installed watchdog module.
19003 + */
19004 +
19005 +static void __exit watchdog_exit(void)
19006 +{
19007 +       /* Stop the timer before we leave */
19008 +       ali_stop();
19009 +
19010 +       /* Deregister */
19011 +       unregister_reboot_notifier(&ali_notifier);
19012 +       misc_deregister(&ali_miscdev);
19013 +}
19014 +
19015 +module_init(watchdog_init);
19016 +module_exit(watchdog_exit);
19017 +
19018 +MODULE_AUTHOR("Alan Cox");
19019 +MODULE_DESCRIPTION("ALi M1535 PMU Watchdog Timer driver");
19020 +MODULE_LICENSE("GPL");
19021 diff -Nru a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c
19022 --- a/drivers/char/watchdog/cpu5wdt.c   Thu Feb 13 06:54:43 2003
19023 +++ b/drivers/char/watchdog/cpu5wdt.c   Tue Aug 26 09:25:41 2003
19024 @@ -134,7 +134,7 @@
19025  
19026  static int cpu5wdt_open(struct inode *inode, struct file *file)
19027  {
19028 -       switch(minor(inode->i_rdev)) {
19029 +       switch(iminor(inode)) {
19030                 case WATCHDOG_MINOR:
19031                         if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
19032                                 return -EBUSY;
19033 @@ -148,7 +148,7 @@
19034  
19035  static int cpu5wdt_release(struct inode *inode, struct file *file)
19036  {
19037 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR) {
19038 +       if(iminor(inode)==WATCHDOG_MINOR) {
19039                 clear_bit(0, &cpu5wdt_device.inuse);
19040         }
19041         return 0;
19042 diff -Nru a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c
19043 --- a/drivers/char/watchdog/ib700wdt.c  Fri Aug  8 03:28:08 2003
19044 +++ b/drivers/char/watchdog/ib700wdt.c  Tue Aug 26 09:25:41 2003
19045 @@ -218,7 +218,7 @@
19046  static int
19047  ibwdt_open(struct inode *inode, struct file *file)
19048  {
19049 -       if (minor(inode->i_rdev) == WATCHDOG_MINOR) {
19050 +       if (iminor(inode) == WATCHDOG_MINOR) {
19051                 spin_lock(&ibwdt_lock);
19052                 if (ibwdt_is_open) {
19053                         spin_unlock(&ibwdt_lock);
19054 @@ -240,7 +240,7 @@
19055  static int
19056  ibwdt_close(struct inode *inode, struct file *file)
19057  {
19058 -       if (minor(inode->i_rdev) == WATCHDOG_MINOR) {
19059 +       if (iminor(inode) == WATCHDOG_MINOR) {
19060                 spin_lock(&ibwdt_lock);
19061                 if (expect_close)
19062                         outb_p(wd_times[wd_margin], WDT_STOP);
19063 diff -Nru a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c
19064 --- a/drivers/char/watchdog/machzwd.c   Fri Aug  8 03:28:08 2003
19065 +++ b/drivers/char/watchdog/machzwd.c   Tue Aug 26 09:25:41 2003
19066 @@ -377,7 +377,7 @@
19067  
19068  static int zf_open(struct inode *inode, struct file *file)
19069  {
19070 -       switch(minor(inode->i_rdev)){
19071 +       switch(iminor(inode)){
19072                 case WATCHDOG_MINOR:
19073                         spin_lock(&zf_lock);
19074                         if(zf_is_open){
19075 @@ -402,7 +402,7 @@
19076  
19077  static int zf_close(struct inode *inode, struct file *file)
19078  {
19079 -       if(minor(inode->i_rdev) == WATCHDOG_MINOR){
19080 +       if(iminor(inode) == WATCHDOG_MINOR){
19081  
19082                 if(zf_expect_close){
19083                         zf_timer_off();
19084 diff -Nru a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c
19085 --- a/drivers/char/watchdog/pcwd.c      Fri Aug  1 03:02:31 2003
19086 +++ b/drivers/char/watchdog/pcwd.c      Tue Aug 26 09:25:41 2003
19087 @@ -426,7 +426,7 @@
19088  
19089  static int pcwd_open(struct inode *ino, struct file *filep)
19090  {
19091 -       switch (minor(ino->i_rdev)) {
19092 +       switch (iminor(ino)) {
19093         case WATCHDOG_MINOR:
19094                 if (!atomic_dec_and_test(&open_allowed) ) {
19095                         atomic_inc( &open_allowed );
19096 @@ -457,7 +457,7 @@
19097         /*  Can't seek (pread) on this device  */
19098         if (ppos != &file->f_pos)
19099                 return -ESPIPE;
19100 -       switch(minor(file->f_dentry->d_inode->i_rdev)) 
19101 +       switch(iminor(file->f_dentry->d_inode)) 
19102         {
19103                 case TEMP_MINOR:
19104                         /*
19105 @@ -477,7 +477,7 @@
19106  
19107  static int pcwd_close(struct inode *ino, struct file *filep)
19108  {
19109 -       if (minor(ino->i_rdev)==WATCHDOG_MINOR) {
19110 +       if (iminor(ino)==WATCHDOG_MINOR) {
19111                 if (expect_close) {
19112                         /*  Disable the board  */
19113                         if (revision == PCWD_REVISION_C) {
19114 diff -Nru a/drivers/char/watchdog/wafer5823wdt.c b/drivers/char/watchdog/wafer5823wdt.c
19115 --- a/drivers/char/watchdog/wafer5823wdt.c      Fri Aug  1 03:02:31 2003
19116 +++ b/drivers/char/watchdog/wafer5823wdt.c      Sun Aug 31 11:32:43 2003
19117 @@ -1,5 +1,5 @@
19118  /*
19119 - *     ICP Wafer 5823 Single Board Computer WDT driver for Linux 2.4.x
19120 + *     ICP Wafer 5823 Single Board Computer WDT driver
19121   *      http://www.icpamerica.com/wafer_5823.php
19122   *      May also work on other similar models
19123   *
19124 @@ -17,10 +17,10 @@
19125   *     modify it under the terms of the GNU General Public License
19126   *     as published by the Free Software Foundation; either version
19127   *     2 of the License, or (at your option) any later version.
19128 - *     
19129 - *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
19130 - *     warranty for any of this software. This material is provided 
19131 - *     "AS-IS" and at no charge.       
19132 + *
19133 + *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
19134 + *     warranty for any of this software. This material is provided
19135 + *     "AS-IS" and at no charge.
19136   *
19137   *     (c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
19138   *
19139 @@ -39,9 +39,13 @@
19140  #include <asm/io.h>
19141  #include <asm/uaccess.h>
19142  
19143 +#define WATCHDOG_NAME "Wafer 5823 WDT"
19144 +#define PFX WATCHDOG_NAME ": "
19145 +#define WD_TIMO 60                     /* 60 sec default timeout */
19146 +
19147  static unsigned long wafwdt_is_open;
19148 +static char expect_close;
19149  static spinlock_t wafwdt_lock;
19150 -static int expect_close = 0;
19151  
19152  /*
19153   *     You must set these - there is no sane way to probe for this board.
19154 @@ -52,11 +56,17 @@
19155   *      to restart it again.
19156   */
19157  
19158 -#define WDT_START 0x443
19159 -#define WDT_STOP 0x843
19160 -
19161 -#define WD_TIMO 60             /* 1 minute */
19162 -static int wd_margin = WD_TIMO;
19163 +static int wdt_stop = 0x843;
19164 +module_param(wdt_stop, int, 0);
19165 +MODULE_PARM_DESC(wdt_stop, "Wafer 5823 WDT 'stop' io port (default 0x843)");
19166 +
19167 +static int wdt_start = 0x443;
19168 +module_param(wdt_start, int, 0);
19169 +MODULE_PARM_DESC(wdt_start, "Wafer 5823 WDT 'start' io port (default 0x443)");
19170 +
19171 +static int timeout = WD_TIMO;  /* in seconds */
19172 +module_param(timeout, int, 0);
19173 +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WD_TIMO) ".");
19174  
19175  #ifdef CONFIG_WATCHDOG_NOWAYOUT
19176  static int nowayout = 1;
19177 @@ -70,24 +80,24 @@
19178  static void wafwdt_ping(void)
19179  {
19180         /* pat watchdog */
19181 -        spin_lock(&wafwdt_lock);
19182 -       inb_p(WDT_STOP);
19183 -       inb_p(WDT_START);
19184 -        spin_unlock(&wafwdt_lock);
19185 +       spin_lock(&wafwdt_lock);
19186 +       inb_p(wdt_stop);
19187 +       inb_p(wdt_start);
19188 +       spin_unlock(&wafwdt_lock);
19189  }
19190  
19191  static void wafwdt_start(void)
19192  {
19193         /* start up watchdog */
19194 -       outb_p(wd_margin, WDT_START);
19195 -       inb_p(WDT_START);
19196 +       outb_p(timeout, wdt_start);
19197 +       inb_p(wdt_start);
19198  }
19199  
19200  static void
19201  wafwdt_stop(void)
19202  {
19203         /* stop watchdog */
19204 -       inb_p(WDT_STOP);
19205 +       inb_p(wdt_stop);
19206  }
19207  
19208  static ssize_t wafwdt_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
19209 @@ -96,6 +106,7 @@
19210         if (ppos != &file->f_pos)
19211                 return -ESPIPE;
19212  
19213 +       /* See if we got the magic character 'V' and reload the timer */
19214         if (count) {
19215                 if (!nowayout) {
19216                         size_t i;
19217 @@ -103,30 +114,30 @@
19218                         /* In case it was set long ago */
19219                         expect_close = 0;
19220  
19221 +                       /* scan to see wether or not we got the magic character */
19222                         for (i = 0; i != count; i++) {
19223                                 char c;
19224                                 if (get_user(c, buf + i))
19225                                         return -EFAULT;
19226                                 if (c == 'V')
19227 -                                       expect_close = 1;
19228 +                                       expect_close = 42;
19229                         }
19230                 }
19231 +               /* Well, anyhow someone wrote to us, we should return that favour */
19232                 wafwdt_ping();
19233 -               return 1;
19234         }
19235 -       return 0;
19236 +       return count;
19237  }
19238  
19239  static int wafwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
19240              unsigned long arg)
19241  {
19242 -       int new_margin;
19243 +       int new_timeout;
19244         static struct watchdog_info ident = {
19245                 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
19246                 .firmware_version = 1,
19247 -               .identity = "Wafer 5823 WDT"
19248 +               .identity = "Wafer 5823 WDT",
19249         };
19250 -       int one=1;
19251  
19252         switch (cmd) {
19253         case WDIOC_GETSUPPORT:
19254 @@ -136,25 +147,44 @@
19255                 break;
19256  
19257         case WDIOC_GETSTATUS:
19258 -               if (copy_to_user((int *) arg, &one, sizeof (int)))
19259 -                       return -EFAULT;
19260 -               break;
19261 +       case WDIOC_GETBOOTSTATUS:
19262 +               return put_user(0, (int *)arg);
19263  
19264         case WDIOC_KEEPALIVE:
19265                 wafwdt_ping();
19266                 break;
19267  
19268         case WDIOC_SETTIMEOUT:
19269 -               if (get_user(new_margin, (int *)arg))
19270 +               if (get_user(new_timeout, (int *)arg))
19271                         return -EFAULT;
19272 -               if ((new_margin < 1) || (new_margin > 255))
19273 +               if ((new_timeout < 1) || (new_timeout > 255))
19274                         return -EINVAL;
19275 -               wd_margin = new_margin;
19276 +               timeout = new_timeout;
19277                 wafwdt_stop();
19278                 wafwdt_start();
19279                 /* Fall */
19280         case WDIOC_GETTIMEOUT:
19281 -               return put_user(wd_margin, (int *)arg);
19282 +               return put_user(timeout, (int *)arg);
19283 +
19284 +       case WDIOC_SETOPTIONS:
19285 +       {
19286 +               int options, retval = -EINVAL;
19287 +
19288 +               if (get_user(options, (int *)arg))
19289 +                       return -EFAULT;
19290 +
19291 +               if (options & WDIOS_DISABLECARD) {
19292 +                       wafwdt_start();
19293 +                       retval = 0;
19294 +               }
19295 +
19296 +               if (options & WDIOS_ENABLECARD) {
19297 +                       wafwdt_stop();
19298 +                       retval = 0;
19299 +               }
19300 +
19301 +               return retval;
19302 +       }
19303  
19304         default:
19305                 return -ENOTTY;
19306 @@ -166,6 +196,10 @@
19307  {
19308         if (test_and_set_bit(0, &wafwdt_is_open))
19309                 return -EBUSY;
19310 +
19311 +       /*
19312 +        *      Activate
19313 +        */
19314         wafwdt_start();
19315         return 0;
19316  }
19317 @@ -173,12 +207,14 @@
19318  static int
19319  wafwdt_close(struct inode *inode, struct file *file)
19320  {
19321 -       clear_bit(0, &wafwdt_is_open);
19322 -       if (expect_close) {   
19323 +       if (expect_close == 42) {
19324                 wafwdt_stop();
19325         } else {
19326 -               printk(KERN_CRIT "WDT device closed unexpectedly.  WDT will not stop!\n");
19327 +               printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will not stop!\n");
19328 +               wafwdt_ping();
19329         }
19330 +       clear_bit(0, &wafwdt_is_open);
19331 +       expect_close = 0;
19332         return 0;
19333  }
19334  
19335 @@ -201,6 +237,7 @@
19336  
19337  static struct file_operations wafwdt_fops = {
19338         .owner          = THIS_MODULE,
19339 +       .llseek         = no_llseek,
19340         .write          = wafwdt_write,
19341         .ioctl          = wafwdt_ioctl,
19342         .open           = wafwdt_open,
19343 @@ -210,53 +247,93 @@
19344  static struct miscdevice wafwdt_miscdev = {
19345         .minor  = WATCHDOG_MINOR,
19346         .name   = "watchdog",
19347 -       .fops   = &wafwdt_fops
19348 +       .fops   = &wafwdt_fops,
19349  };
19350  
19351  /*
19352   *     The WDT needs to learn about soft shutdowns in order to
19353 - *     turn the timebomb registers off. 
19354 + *     turn the timebomb registers off.
19355   */
19356  
19357  static struct notifier_block wafwdt_notifier = {
19358         .notifier_call = wafwdt_notify_sys,
19359         .next = NULL,
19360 -       .priority = 0
19361 +       .priority = 0,
19362  };
19363  
19364  static int __init wafwdt_init(void)
19365  {
19366 +       int ret;
19367 +
19368         printk(KERN_INFO "WDT driver for Wafer 5823 single board computer initialising.\n");
19369  
19370         spin_lock_init(&wafwdt_lock);
19371 -       if(!request_region(WDT_STOP, 1, "Wafer 5823 WDT"))
19372 -               goto error;
19373 -       if(!request_region(WDT_START, 1, "Wafer 5823 WDT"))
19374 +
19375 +       if (timeout < 1 || timeout > 63) {
19376 +               timeout = WD_TIMO;
19377 +               printk (KERN_INFO PFX "timeout value must be 1<=x<=255, using %d\n",
19378 +                       timeout);
19379 +       }
19380 +
19381 +       if (wdt_stop != wdt_start) {
19382 +               if(!request_region(wdt_stop, 1, "Wafer 5823 WDT")) {
19383 +                       printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
19384 +                       wdt_stop);
19385 +                       ret = -EIO;
19386 +                       goto error;
19387 +               }
19388 +       }
19389 +
19390 +       if(!request_region(wdt_start, 1, "Wafer 5823 WDT")) {
19391 +               printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
19392 +                       wdt_start);
19393 +               ret = -EIO;
19394                 goto error2;
19395 -       if(misc_register(&wafwdt_miscdev)<0)
19396 +       }
19397 +
19398 +       ret = register_reboot_notifier(&wafwdt_notifier);
19399 +       if (ret != 0) {
19400 +               printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
19401 +                       ret);
19402                 goto error3;
19403 -       register_reboot_notifier(&wafwdt_notifier);
19404 -       return 0;
19405 +       }
19406 +
19407 +       ret = misc_register(&wafwdt_miscdev);
19408 +       if (ret != 0) {
19409 +               printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
19410 +                       WATCHDOG_MINOR, ret);
19411 +               goto error4;
19412 +       }
19413 +
19414 +       printk (KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
19415 +               timeout, nowayout);
19416 +
19417 +       return ret;
19418 +error4:
19419 +       unregister_reboot_notifier(&wafwdt_notifier);
19420  error3:
19421 -       release_region(WDT_START, 1);
19422 +       release_region(wdt_start, 1);
19423  error2:
19424 -       release_region(WDT_STOP, 1);
19425 +       if (wdt_stop != wdt_start)
19426 +               release_region(wdt_stop, 1);
19427  error:
19428 -       return -ENODEV;
19429 +       return ret;
19430  }
19431  
19432  static void __exit wafwdt_exit(void)
19433  {
19434         misc_deregister(&wafwdt_miscdev);
19435         unregister_reboot_notifier(&wafwdt_notifier);
19436 -       release_region(WDT_STOP, 1);
19437 -       release_region(WDT_START, 1);
19438 +       if(wdt_stop != wdt_start)
19439 +               release_region(wdt_stop, 1);
19440 +       release_region(wdt_start, 1);
19441  }
19442  
19443  module_init(wafwdt_init);
19444  module_exit(wafwdt_exit);
19445  
19446  MODULE_AUTHOR("Justin Cormack");
19447 +MODULE_DESCRIPTION("ICP Wafer 5823 Single Board Computer WDT driver");
19448  MODULE_LICENSE("GPL");
19449  
19450  /* end of wafer5823wdt.c */
19451 diff -Nru a/drivers/char/watchdog/wdt.c b/drivers/char/watchdog/wdt.c
19452 --- a/drivers/char/watchdog/wdt.c       Thu Apr 24 05:36:57 2003
19453 +++ b/drivers/char/watchdog/wdt.c       Tue Aug 26 09:25:41 2003
19454 @@ -290,7 +290,7 @@
19455         if (ptr != &file->f_pos)
19456                 return -ESPIPE;
19457  
19458 -       switch(minor(file->f_dentry->d_inode->i_rdev))
19459 +       switch(iminor(file->f_dentry->d_inode))
19460         {
19461                 case TEMP_MINOR:
19462                         c*=11;
19463 @@ -373,7 +373,7 @@
19464   
19465  static int wdt_open(struct inode *inode, struct file *file)
19466  {
19467 -       switch(minor(inode->i_rdev))
19468 +       switch(iminor(inode))
19469         {
19470                 case WATCHDOG_MINOR:
19471                         if(test_and_set_bit(0, &wdt_is_open))
19472 @@ -413,7 +413,7 @@
19473   
19474  static int wdt_release(struct inode *inode, struct file *file)
19475  {
19476 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR)
19477 +       if(iminor(inode)==WATCHDOG_MINOR)
19478         {
19479                 if (expect_close) {
19480                         inb_p(WDT_DC);          /* Disable counters */
19481 diff -Nru a/drivers/char/watchdog/wdt_pci.c b/drivers/char/watchdog/wdt_pci.c
19482 --- a/drivers/char/watchdog/wdt_pci.c   Fri Aug  1 11:59:44 2003
19483 +++ b/drivers/char/watchdog/wdt_pci.c   Tue Aug 26 09:25:41 2003
19484 @@ -276,7 +276,7 @@
19485         if (ptr != &file->f_pos)
19486                 return -ESPIPE;
19487  
19488 -       switch(minor(file->f_dentry->d_inode->i_rdev))
19489 +       switch(iminor(file->f_dentry->d_inode))
19490         {
19491                 case TEMP_MINOR:
19492                         c*=11;
19493 @@ -361,7 +361,7 @@
19494  {
19495         unsigned long flags;
19496  
19497 -       switch(minor(inode->i_rdev))
19498 +       switch(iminor(inode))
19499         {
19500                 case WATCHDOG_MINOR:
19501                         if (down_trylock(&open_sem))
19502 @@ -423,7 +423,7 @@
19503  static int wdtpci_release(struct inode *inode, struct file *file)
19504  {
19505  
19506 -       if (minor(inode->i_rdev)==WATCHDOG_MINOR) {
19507 +       if (iminor(inode)==WATCHDOG_MINOR) {
19508                 unsigned long flags;
19509                 if (expect_close) {
19510                         spin_lock_irqsave(&wdtpci_lock, flags);
19511 diff -Nru a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
19512 --- a/drivers/i2c/Kconfig       Fri Aug  1 21:55:21 2003
19513 +++ b/drivers/i2c/Kconfig       Tue Aug 26 11:58:28 2003
19514 @@ -150,7 +150,7 @@
19515  
19516  config I2C_ELEKTOR
19517         tristate "Elektor ISA card"
19518 -       depends on I2C_ALGOPCF
19519 +       depends on I2C_ALGOPCF && BROKEN_ON_SMP
19520         help
19521           This supports the PCF8584 ISA bus I2C adapter.  Say Y if you own
19522           such an adapter.
19523 diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
19524 --- a/drivers/i2c/i2c-dev.c     Wed Aug  6 02:26:55 2003
19525 +++ b/drivers/i2c/i2c-dev.c     Tue Aug 26 09:25:41 2003
19526 @@ -138,7 +138,7 @@
19527                 return -ENOMEM;
19528  
19529         pr_debug("i2c-dev.o: i2c-%d reading %d bytes.\n",
19530 -               minor(file->f_dentry->d_inode->i_rdev), count);
19531 +               iminor(file->f_dentry->d_inode), count);
19532  
19533         ret = i2c_master_recv(client,tmp,count);
19534         if (ret >= 0)
19535 @@ -166,7 +166,7 @@
19536         }
19537  
19538         pr_debug("i2c-dev.o: i2c-%d writing %d bytes.\n",
19539 -               minor(file->f_dentry->d_inode->i_rdev), count);
19540 +               iminor(file->f_dentry->d_inode), count);
19541  
19542         ret = i2c_master_send(client,tmp,count);
19543         kfree(tmp);
19544 @@ -186,7 +186,7 @@
19545         unsigned long funcs;
19546  
19547         dev_dbg(&client->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n",
19548 -               minor(inode->i_rdev),cmd, arg);
19549 +               iminor(inode),cmd, arg);
19550  
19551         switch ( cmd ) {
19552         case I2C_SLAVE:
19553 @@ -373,7 +373,7 @@
19554  
19555  static int i2cdev_open(struct inode *inode, struct file *file)
19556  {
19557 -       unsigned int minor = minor(inode->i_rdev);
19558 +       unsigned int minor = iminor(inode);
19559         struct i2c_client *client;
19560         struct i2c_adapter *adap;
19561         struct i2c_dev *i2c_dev;
19562 diff -Nru a/drivers/i2c/i2c-keywest.c b/drivers/i2c/i2c-keywest.c
19563 --- a/drivers/i2c/i2c-keywest.c Wed Jul  9 04:45:34 2003
19564 +++ b/drivers/i2c/i2c-keywest.c Tue Aug 26 06:35:38 2003
19565 @@ -81,9 +81,6 @@
19566  int probe = 0;
19567  int debug = 0;
19568  
19569 -static struct keywest_iface *ifaces = NULL;
19570 -
19571 -
19572  static void
19573  do_stop(struct keywest_iface* iface, int result)
19574  {
19575 @@ -306,6 +303,7 @@
19576         write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
19577         write_reg(reg_ier, KW_I2C_IRQ_MASK);
19578  
19579 +       /* Wait interrupt operations completion */
19580         wait_for_completion(&iface->complete);  
19581  
19582         rc = iface->result;     
19583 @@ -385,6 +383,7 @@
19584                 write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
19585                 write_reg(reg_ier, KW_I2C_IRQ_MASK);
19586  
19587 +               /* Wait interrupt operations completion */
19588                 wait_for_completion(&iface->complete);  
19589  
19590                 rc = iface->result;
19591 @@ -409,16 +408,16 @@
19592  
19593  /* For now, we only handle combined mode (smbus) */
19594  static struct i2c_algorithm keywest_algorithm = {
19595 -       name:           "Keywest i2c",
19596 -       id:             I2C_ALGO_SMBUS,
19597 -       smbus_xfer:     keywest_smbus_xfer,
19598 -       master_xfer:    keywest_xfer,
19599 -       functionality:  keywest_func,
19600 +       .name           = "Keywest i2c",
19601 +       .id             = I2C_ALGO_SMBUS,
19602 +       .smbus_xfer     = keywest_smbus_xfer,
19603 +       .master_xfer    = keywest_xfer,
19604 +       .functionality  = keywest_func,
19605  };
19606  
19607  
19608  static int
19609 -create_iface(struct device_node* np)
19610 +create_iface(struct device_node *np, struct device *dev)
19611  {
19612         unsigned long steps, *psteps, *prate;
19613         unsigned bsteps, tsize, i, nchan, addroffset;
19614 @@ -487,8 +486,8 @@
19615                         *prate);
19616         }
19617         
19618 -       /* Select standard mode by default */
19619 -       iface->cur_mode |= KW_I2C_MODE_STANDARD;
19620 +       /* Select standard sub mode */
19621 +       iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
19622         
19623         /* Write mode */
19624         write_reg(reg_mode, iface->cur_mode);
19625 @@ -506,11 +505,13 @@
19626                 return -ENODEV;
19627         }
19628  
19629 +       dev_set_drvdata(dev, iface);
19630 +       
19631         for (i=0; i<nchan; i++) {
19632                 struct keywest_chan* chan = &iface->channels[i];
19633                 u8 addr;
19634                 
19635 -               sprintf(chan->adapter.dev.name, "%s %d", np->parent->name, i);
19636 +               sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
19637                 chan->iface = iface;
19638                 chan->chan_no = i;
19639                 chan->adapter.id = I2C_ALGO_SMBUS;
19640 @@ -519,11 +520,12 @@
19641                 chan->adapter.client_register = NULL;
19642                 chan->adapter.client_unregister = NULL;
19643                 i2c_set_adapdata(&chan->adapter, chan);
19644 +               chan->adapter.dev.parent = dev;
19645  
19646                 rc = i2c_add_adapter(&chan->adapter);
19647                 if (rc) {
19648                         printk("i2c-keywest.c: Adapter %s registration failed\n",
19649 -                               chan->adapter.dev.name);
19650 +                               chan->adapter.name);
19651                         i2c_set_adapdata(&chan->adapter, NULL);
19652                 }
19653                 if (probe) {
19654 @@ -540,20 +542,18 @@
19655         printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n",
19656                 np->parent->name, nchan, nchan > 1 ? "s" : "", bsteps);
19657                 
19658 -       iface->next = ifaces;
19659 -       ifaces = iface;
19660         return 0;
19661  }
19662  
19663 -static void
19664 -dispose_iface(struct keywest_iface *iface)
19665 +static int
19666 +dispose_iface(struct device *dev)
19667  {
19668 +       struct keywest_iface *iface = dev_get_drvdata(dev);
19669         int i, rc;
19670         
19671 -       ifaces = iface->next;
19672 -
19673         /* Make sure we stop all activity */
19674         down(&iface->sem);
19675 +
19676         spin_lock_irq(&iface->lock);
19677         while (iface->state != state_idle) {
19678                 spin_unlock_irq(&iface->lock);
19679 @@ -578,31 +578,76 @@
19680                         printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
19681         }
19682         iounmap((void *)iface->base);
19683 +       dev_set_drvdata(dev, NULL);
19684         kfree(iface);
19685 +
19686 +       return 0;
19687 +}
19688 +
19689 +static int
19690 +create_iface_macio(struct macio_dev* dev, const struct of_match *match)
19691 +{
19692 +       return create_iface(dev->ofdev.node, &dev->ofdev.dev);
19693 +}
19694 +
19695 +static int
19696 +dispose_iface_macio(struct macio_dev* dev)
19697 +{
19698 +       return dispose_iface(&dev->ofdev.dev);
19699 +}
19700 +
19701 +static int
19702 +create_iface_of_platform(struct of_device* dev, const struct of_match *match)
19703 +{
19704 +       return create_iface(dev->node, &dev->dev);
19705 +}
19706 +
19707 +static int
19708 +dispose_iface_of_platform(struct of_device* dev)
19709 +{
19710 +       return dispose_iface(&dev->dev);
19711  }
19712  
19713 +static struct of_match i2c_keywest_match[] = 
19714 +{
19715 +       {
19716 +       .name           = OF_ANY_MATCH,
19717 +       .type           = "i2c",
19718 +       .compatible     = "keywest"
19719 +       },
19720 +       {},
19721 +};
19722 +
19723 +static struct macio_driver i2c_keywest_macio_driver = 
19724 +{
19725 +       .name           = "i2c-keywest",
19726 +       .match_table    = i2c_keywest_match,
19727 +       .probe          = create_iface_macio,
19728 +       .remove         = dispose_iface_macio
19729 +};
19730 +
19731 +static struct of_platform_driver i2c_keywest_of_platform_driver = 
19732 +{
19733 +       .name           = "i2c-keywest",
19734 +       .match_table    = i2c_keywest_match,
19735 +       .probe          = create_iface_of_platform,
19736 +       .remove         = dispose_iface_of_platform
19737 +};
19738 +
19739  static int __init
19740  i2c_keywest_init(void)
19741  {
19742 -       struct device_node *np;
19743 -       int rc = -ENODEV;
19744 -       
19745 -       np = find_compatible_devices("i2c", "keywest");
19746 -       while (np != 0) {
19747 -               if (np->n_addrs >= 1 && np->n_intrs >= 1)
19748 -                       rc = create_iface(np);
19749 -               np = np->next;
19750 -       }
19751 -       if (ifaces)
19752 -               rc = 0;
19753 -       return rc;
19754 +       macio_register_driver(&i2c_keywest_macio_driver);
19755 +       of_register_driver(&i2c_keywest_of_platform_driver);
19756 +
19757 +       return 0;
19758  }
19759  
19760  static void __exit
19761  i2c_keywest_cleanup(void)
19762  {
19763 -       while(ifaces)
19764 -               dispose_iface(ifaces);
19765 +       macio_unregister_driver(&i2c_keywest_macio_driver);
19766 +       of_unregister_driver(&i2c_keywest_of_platform_driver);
19767  }
19768  
19769  module_init(i2c_keywest_init);
19770 diff -Nru a/drivers/i2c/i2c-keywest.h b/drivers/i2c/i2c-keywest.h
19771 --- a/drivers/i2c/i2c-keywest.h Fri Feb 15 14:32:09 2002
19772 +++ b/drivers/i2c/i2c-keywest.h Sun Aug 24 06:10:14 2003
19773 @@ -67,7 +67,6 @@
19774         int                     stopretry;
19775         struct timer_list       timeout_timer;
19776         struct completion       complete;
19777 -       struct keywest_iface*   next;
19778  };
19779  
19780  enum {
19781 diff -Nru a/drivers/ide/Kconfig b/drivers/ide/Kconfig
19782 --- a/drivers/ide/Kconfig       Wed Aug 13 14:35:06 2003
19783 +++ b/drivers/ide/Kconfig       Sun Aug 24 06:08:48 2003
19784 @@ -815,6 +815,17 @@
19785           most of the recent Apple Power Macintoshes and PowerBooks.
19786           If unsure, say Y.
19787  
19788 +config BLK_DEV_IDE_PMAC_ATA100FIRST
19789 +       bool "Probe internal ATA/100 (Kauai) first"
19790 +       depends on BLK_DEV_IDE_PMAC
19791 +       help
19792 +         This option will cause the ATA/100 controller found in UniNorth2
19793 +         based machines (Windtunnel PowerMac, Aluminium PowerBooks, ...)
19794 +         to be probed before the ATA/66 and ATA/33 controllers. Without
19795 +         these, those machine used to have the hard disk on hdc and the
19796 +         CD-ROM on hda. This option changes this to more natural hda for
19797 +         hard disk and hdc for CD-ROM.
19798 +
19799  config BLK_DEV_IDEDMA_PMAC
19800         bool "PowerMac IDE DMA support"
19801         depends on BLK_DEV_IDE_PMAC
19802 diff -Nru a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
19803 --- a/drivers/ide/ide-cd.c      Wed Aug 20 09:01:03 2003
19804 +++ b/drivers/ide/ide-cd.c      Fri Aug 22 18:04:49 2003
19805 @@ -794,16 +794,16 @@
19806                            request or data protect error.*/
19807                         ide_dump_status (drive, "command error", stat);
19808                         do_end_request = 1;
19809 -               } else if ((err & ~ABRT_ERR) != 0) {
19810 -                       /* Go to the default handler
19811 -                          for other errors. */
19812 -                       DRIVER(drive)->error(drive, "cdrom_decode_status",stat);
19813 -                       return 1;
19814                 } else if (sense_key == MEDIUM_ERROR) {
19815                         /* No point in re-trying a zillion times on a bad 
19816                          * sector...  If we got here the error is not correctable */
19817                         ide_dump_status (drive, "media error (bad sector)", stat);
19818                         do_end_request = 1;
19819 +               } else if ((err & ~ABRT_ERR) != 0) {
19820 +                       /* Go to the default handler
19821 +                          for other errors. */
19822 +                       DRIVER(drive)->error(drive, "cdrom_decode_status",stat);
19823 +                       return 1;
19824                 } else if ((++rq->errors > ERROR_MAX)) {
19825                         /* We've racked up too many retries.  Abort. */
19826                         do_end_request = 1;
19827 diff -Nru a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
19828 --- a/drivers/ide/ide-io.c      Thu Aug  7 02:25:24 2003
19829 +++ b/drivers/ide/ide-io.c      Sun Aug 24 15:33:30 2003
19830 @@ -54,8 +54,6 @@
19831  #include <asm/io.h>
19832  #include <asm/bitops.h>
19833  
19834 -#include "ide_modes.h"
19835 -
19836  #if (DISK_RECOVERY_TIME > 0)
19837  
19838  #error So the User Has To Fix the Compilation And Stop Hacking Port 0x43. Does anyone ever use this anyway ??
19839 diff -Nru a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
19840 --- a/drivers/ide/ide-lib.c     Thu Aug  7 02:25:25 2003
19841 +++ b/drivers/ide/ide-lib.c     Sun Aug 24 15:33:30 2003
19842 @@ -22,8 +22,6 @@
19843  #include <asm/io.h>
19844  #include <asm/bitops.h>
19845  
19846 -#include "ide_modes.h"
19847 -
19848  /*
19849   *     IDE library routines. These are plug in code that most 
19850   *     drivers can use but occasionally may be weird enough
19851 @@ -170,7 +168,7 @@
19852                 BUG();
19853         return min(speed, speed_max[mode]);
19854  #else /* !CONFIG_BLK_DEV_IDEDMA */
19855 -       return min(speed, XFER_PIO_4);
19856 +       return min(speed, (u8)XFER_PIO_4);
19857  #endif /* CONFIG_BLK_DEV_IDEDMA */
19858  }
19859  
19860 @@ -188,6 +186,12 @@
19861  
19862  EXPORT_SYMBOL(ide_dma_enable);
19863  
19864 +/*
19865 + * Standard (generic) timings for PIO modes, from ATA2 specification.
19866 + * These timings are for access to the IDE data port register *only*.
19867 + * Some drives may specify a mode, while also specifying a different
19868 + * value for cycle_time (from drive identification data).
19869 + */
19870  const ide_pio_timings_t ide_pio_timings[6] = {
19871         { 70,   165,    600 },  /* PIO Mode 0 */
19872         { 50,   125,    383 },  /* PIO Mode 1 */
19873 @@ -198,6 +202,13 @@
19874  };
19875  
19876  EXPORT_SYMBOL_GPL(ide_pio_timings);
19877 +
19878 +/*
19879 + * Shared data/functions for determining best PIO mode for an IDE drive.
19880 + * Most of this stuff originally lived in cmd640.c, and changes to the
19881 + * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
19882 + * breaking the fragile cmd640.c support.
19883 + */
19884  
19885  /*
19886   * Black list. Some drives incorrectly report their maximal PIO mode,
19887 diff -Nru a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
19888 --- a/drivers/ide/ide-probe.c   Thu Aug 14 16:52:06 2003
19889 +++ b/drivers/ide/ide-probe.c   Tue Sep  2 07:18:29 2003
19890 @@ -644,15 +644,26 @@
19891         return drive->present;
19892  }
19893  
19894 +static void hwif_release_dev (struct device *dev)
19895 +{
19896 +       ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev);
19897 +
19898 +       up(&hwif->gendev_rel_sem);
19899 +}
19900 +
19901  static void hwif_register (ide_hwif_t *hwif)
19902  {
19903         /* register with global device tree */
19904         strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE);
19905         hwif->gendev.driver_data = hwif;
19906 -       if (hwif->pci_dev)
19907 -               hwif->gendev.parent = &hwif->pci_dev->dev;
19908 -       else
19909 -               hwif->gendev.parent = NULL; /* Would like to do = &device_legacy */
19910 +       if (hwif->gendev.parent == NULL) {
19911 +               if (hwif->pci_dev)
19912 +                       hwif->gendev.parent = &hwif->pci_dev->dev;
19913 +               else
19914 +                       /* Would like to do = &device_legacy */
19915 +                       hwif->gendev.parent = NULL;
19916 +       }
19917 +       hwif->gendev.release = hwif_release_dev;
19918         device_register(&hwif->gendev);
19919  }
19920  
19921 @@ -770,8 +781,7 @@
19922          */
19923         for (unit = 0; unit < MAX_DRIVES; ++unit) {
19924                 ide_drive_t *drive = &hwif->drives[unit];
19925 -               drive->dn = ((hwif->channel ? 2 : 0) + unit);
19926 -               hwif->drives[unit].dn = ((hwif->channel ? 2 : 0) + unit);
19927 +               drive->dn = (hwif->channel ? 2 : 0) + unit;
19928                 (void) probe_for_drive(drive);
19929                 if (drive->present && !hwif->present) {
19930                         hwif->present = 1;
19931 @@ -945,15 +955,10 @@
19932         if (drive->disk)
19933                 drive->disk->queue = drive->queue;
19934  
19935 -       return 0;
19936 -}
19937 -
19938 -/*
19939 - * Setup the drive for request handling.
19940 - */
19941 -static void ide_init_drive(ide_drive_t *drive)
19942 -{
19943 +       /* needs drive->queue to be set */
19944         ide_toggle_bounce(drive, 1);
19945 +
19946 +       return 0;
19947  }
19948  
19949  /*
19950 @@ -1068,10 +1073,9 @@
19951         }
19952  
19953         /*
19954 -        * Link any new drives into the hwgroup, allocate
19955 -        * the block device queue and initialize the drive.
19956 -        * Note that ide_init_drive sends commands to the new
19957 -        * drive.
19958 +        * For any present drive:
19959 +        * - allocate the block device queue
19960 +        * - link drive into the hwgroup
19961          */
19962         for (index = 0; index < MAX_DRIVES; ++index) {
19963                 ide_drive_t *drive = &hwif->drives[index];
19964 @@ -1092,7 +1096,6 @@
19965                         hwgroup->drive->next = drive;
19966                 }
19967                 spin_unlock_irq(&ide_lock);
19968 -               ide_init_drive(drive);
19969         }
19970  
19971  #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
19972 @@ -1201,6 +1204,13 @@
19973         return -ENOMEM;
19974  }
19975  
19976 +static void drive_release_dev (struct device *dev)
19977 +{
19978 +       ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
19979 +
19980 +       up(&drive->gendev_rel_sem);
19981 +}
19982 +
19983  /*
19984   * init_gendisk() (as opposed to ide_geninit) is called for each major device,
19985   * after probing for drives, to allocate partition tables and other data
19986 @@ -1219,6 +1229,7 @@
19987                 drive->gendev.parent = &hwif->gendev;
19988                 drive->gendev.bus = &ide_bus_type;
19989                 drive->gendev.driver_data = drive;
19990 +               drive->gendev.release = drive_release_dev;
19991                 if (drive->present) {
19992                         device_register(&drive->gendev);
19993                         sprintf(drive->devfs_name, "ide/host%d/bus%d/target%d/lun%d",
19994 @@ -1303,31 +1314,6 @@
19995  
19996  EXPORT_SYMBOL(hwif_init);
19997  
19998 -int export_ide_init_queue (ide_drive_t *drive)
19999 -{
20000 -       if (ide_init_queue(drive))
20001 -               return 1;
20002 -
20003 -       ide_init_drive(drive);
20004 -       return 0;
20005 -}
20006 -
20007 -EXPORT_SYMBOL(export_ide_init_queue);
20008 -
20009 -u8 export_probe_for_drive (ide_drive_t *drive)
20010 -{
20011 -       return probe_for_drive(drive);
20012 -}
20013 -
20014 -EXPORT_SYMBOL(export_probe_for_drive);
20015 -
20016 -int ideprobe_init (void);
20017 -static ide_module_t ideprobe_module = {
20018 -       IDE_PROBE_MODULE,
20019 -       ideprobe_init,
20020 -       NULL
20021 -};
20022 -
20023  int ideprobe_init (void)
20024  {
20025         unsigned int index;
20026 @@ -1359,7 +1345,7 @@
20027                 }
20028         }
20029         if (!ide_probe)
20030 -               ide_probe = &ideprobe_module;
20031 +               ide_probe = &ideprobe_init;
20032         MOD_DEC_USE_COUNT;
20033         return 0;
20034  }
20035 diff -Nru a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
20036 --- a/drivers/ide/ide-tape.c    Wed Aug 20 14:21:56 2003
20037 +++ b/drivers/ide/ide-tape.c    Tue Aug 26 09:25:41 2003
20038 @@ -4922,7 +4922,7 @@
20039         struct inode *inode = file->f_dentry->d_inode;
20040         ide_drive_t *drive = file->private_data;
20041         idetape_tape_t *tape = drive->driver_data;
20042 -       unsigned int minor = minor(inode->i_rdev);
20043 +       unsigned int minor = iminor(inode);
20044         ssize_t retval, actually_written = 0;
20045         int position;
20046  
20047 @@ -5568,7 +5568,7 @@
20048   */
20049  static int idetape_chrdev_open (struct inode *inode, struct file *filp)
20050  {
20051 -       unsigned int minor = minor(inode->i_rdev), i = minor & ~0xc0;
20052 +       unsigned int minor = iminor(inode), i = minor & ~0xc0;
20053         ide_drive_t *drive;
20054         idetape_tape_t *tape;
20055         idetape_pc_t pc;
20056 @@ -5649,7 +5649,7 @@
20057         ide_drive_t *drive = filp->private_data;
20058         idetape_tape_t *tape;
20059         idetape_pc_t pc;
20060 -       unsigned int minor = minor(inode->i_rdev);
20061 +       unsigned int minor = iminor(inode);
20062  
20063         lock_kernel();
20064         tape = drive->driver_data;
20065 diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
20066 --- a/drivers/ide/ide.c Wed Aug 20 09:01:03 2003
20067 +++ b/drivers/ide/ide.c Tue Sep  2 07:18:29 2003
20068 @@ -161,8 +161,6 @@
20069  #include <asm/io.h>
20070  #include <asm/bitops.h>
20071  
20072 -#include "ide_modes.h"
20073 -
20074  
20075  /* default maximum number of failures */
20076  #define IDE_DEFAULT_MAX_FAILURES       1
20077 @@ -180,7 +178,9 @@
20078  DECLARE_MUTEX(ide_cfg_sem);
20079  spinlock_t ide_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
20080  
20081 +#ifdef CONFIG_BLK_DEV_IDEPCI
20082  static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */
20083 +#endif
20084  
20085  #ifdef CONFIG_IDEDMA_AUTO
20086  int noautodma = 0;
20087 @@ -190,11 +190,7 @@
20088  
20089  EXPORT_SYMBOL(noautodma);
20090  
20091 -/*
20092 - * ide_modules keeps track of the available IDE chipset/probe/driver modules.
20093 - */
20094 -ide_module_t *ide_chipsets;
20095 -ide_module_t *ide_probe;
20096 +int (*ide_probe)(void);
20097  
20098  /*
20099   * This is declared extern in ide.h, for access by other IDE modules:
20100 @@ -255,6 +251,8 @@
20101         hwif->mwdma_mask = 0x80;        /* disable all mwdma */
20102         hwif->swdma_mask = 0x80;        /* disable all swdma */
20103  
20104 +       sema_init(&hwif->gendev_rel_sem, 0);
20105 +
20106         default_hwif_iops(hwif);
20107         default_hwif_transport(hwif);
20108         for (unit = 0; unit < MAX_DRIVES; ++unit) {
20109 @@ -277,6 +275,7 @@
20110                 drive->driver                   = &idedefault_driver;
20111                 drive->vdma                     = 0;
20112                 INIT_LIST_HEAD(&drive->list);
20113 +               sema_init(&drive->gendev_rel_sem, 0);
20114         }
20115  }
20116  
20117 @@ -452,7 +451,7 @@
20118                 (void) request_module("ide-probe-mod");
20119  #endif /* (CONFIG_KMOD) && (CONFIG_BLK_DEV_IDE_MODULE) */
20120         } else {
20121 -               (void) ide_probe->init();
20122 +               (void)ide_probe();
20123         }
20124  }
20125  
20126 @@ -749,6 +748,7 @@
20127                 spin_unlock_irq(&ide_lock);
20128                 blk_cleanup_queue(drive->queue);
20129                 device_unregister(&drive->gendev);
20130 +               down(&drive->gendev_rel_sem);
20131                 spin_lock_irq(&ide_lock);
20132                 drive->queue = NULL;
20133         }
20134 @@ -778,6 +778,7 @@
20135         /* More messed up locking ... */
20136         spin_unlock_irq(&ide_lock);
20137         device_unregister(&hwif->gendev);
20138 +       down(&hwif->gendev_rel_sem);
20139  
20140         /*
20141          * Remove us from the kernel's knowledge
20142 @@ -1046,21 +1047,6 @@
20143  EXPORT_SYMBOL(ide_register_hw);
20144  
20145  /*
20146 - * Compatibility function with existing drivers.  If you want
20147 - * something different, use the function above.
20148 - */
20149 -int ide_register (int arg1, int arg2, int irq)
20150 -{
20151 -       hw_regs_t hw;
20152 -       ide_init_hwif_ports(&hw, (unsigned long) arg1, (unsigned long) arg2, NULL);
20153 -       hw.irq = irq;
20154 -       return ide_register_hw(&hw, NULL);
20155 -}
20156 -
20157 -EXPORT_SYMBOL(ide_register);
20158 -
20159 -
20160 -/*
20161   *     Locks for IDE setting functionality
20162   */
20163  
20164 @@ -1658,11 +1644,15 @@
20165  
20166                 case HDIO_SCAN_HWIF:
20167                 {
20168 +                       hw_regs_t hw;
20169                         int args[3];
20170                         if (!capable(CAP_SYS_RAWIO)) return -EACCES;
20171                         if (copy_from_user(args, (void *)arg, 3 * sizeof(int)))
20172                                 return -EFAULT;
20173 -                       if (ide_register(args[0], args[1], args[2]) == -1)
20174 +                       ide_init_hwif_ports(&hw, (unsigned long) args[0],
20175 +                                           (unsigned long) args[1], NULL);
20176 +                       hw.irq = args[2];
20177 +                       if (ide_register_hw(&hw, NULL) == -1)
20178                                 return -EIO;
20179                         return 0;
20180                 }
20181 @@ -1870,7 +1860,7 @@
20182   *                             registered. In most cases, only one device
20183   *                             will be present.
20184   * "hdx=scsi"          : the return of the ide-scsi flag, this is useful for
20185 - *                             allowwing ide-floppy, ide-tape, and ide-cdrom|writers
20186 + *                             allowing ide-floppy, ide-tape, and ide-cdrom|writers
20187   *                             to use ide-scsi emulation on a device specific option.
20188   * "idebus=xx"         : inform IDE driver of VESA/PCI bus speed in MHz,
20189   *                             where "xx" is between 20 and 66 inclusive,
20190 diff -Nru a/drivers/ide/ide_modes.h b/drivers/ide/ide_modes.h
20191 --- a/drivers/ide/ide_modes.h   Mon Sep 16 05:54:57 2002
20192 +++ /dev/null   Wed Dec 31 16:00:00 1969
20193 @@ -1,41 +0,0 @@
20194 -/*
20195 - *  linux/drivers/ide/ide_modes.h
20196 - *
20197 - *  Copyright (C) 1996  Linus Torvalds, Igor Abramov, and Mark Lord
20198 - */
20199 -
20200 -#ifndef _IDE_MODES_H
20201 -#define _IDE_MODES_H
20202 -
20203 -#include <linux/config.h>
20204 -
20205 -/*
20206 - * Shared data/functions for determining best PIO mode for an IDE drive.
20207 - * Most of this stuff originally lived in cmd640.c, and changes to the
20208 - * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
20209 - * breaking the fragile cmd640.c support.
20210 - */
20211 -
20212 -/*
20213 - * Standard (generic) timings for PIO modes, from ATA2 specification.
20214 - * These timings are for access to the IDE data port register *only*.
20215 - * Some drives may specify a mode, while also specifying a different
20216 - * value for cycle_time (from drive identification data).
20217 - */
20218 -typedef struct ide_pio_timings_s {
20219 -       int     setup_time;     /* Address setup (ns) minimum */
20220 -       int     active_time;    /* Active pulse (ns) minimum */
20221 -       int     cycle_time;     /* Cycle time (ns) minimum = (setup + active + recovery) */
20222 -} ide_pio_timings_t;
20223 -
20224 -typedef struct ide_pio_data_s {
20225 -       u8 pio_mode;
20226 -       u8 use_iordy;
20227 -       u8 overridden;
20228 -       u8 blacklisted;
20229 -       unsigned int cycle_time;
20230 -} ide_pio_data_t;
20231 -       
20232 -u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d);
20233 -extern const ide_pio_timings_t ide_pio_timings[6];
20234 -#endif /* _IDE_MODES_H */
20235 diff -Nru a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
20236 --- a/drivers/ide/legacy/ali14xx.c      Tue Aug 12 13:29:09 2003
20237 +++ b/drivers/ide/legacy/ali14xx.c      Sun Aug 24 15:33:30 2003
20238 @@ -54,8 +54,6 @@
20239  
20240  #include <asm/io.h>
20241  
20242 -#include "ide_modes.h"
20243 -
20244  /* port addresses for auto-detection */
20245  #define ALI_NUM_PORTS 4
20246  static int ports[ALI_NUM_PORTS] __initdata = {0x074, 0x0f4, 0x034, 0x0e4};
20247 diff -Nru a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c
20248 --- a/drivers/ide/legacy/dtc2278.c      Tue Aug 12 13:29:09 2003
20249 +++ b/drivers/ide/legacy/dtc2278.c      Sun Aug 24 15:33:30 2003
20250 @@ -21,8 +21,6 @@
20251  
20252  #include <asm/io.h>
20253  
20254 -#include "ide_modes.h"
20255 -
20256  /*
20257   * Changing this #undef to #define may solve start up problems in some systems.
20258   */
20259 diff -Nru a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
20260 --- a/drivers/ide/legacy/ht6560b.c      Tue Aug 12 13:29:09 2003
20261 +++ b/drivers/ide/legacy/ht6560b.c      Sun Aug 24 15:33:30 2003
20262 @@ -53,8 +53,6 @@
20263  
20264  #include <asm/io.h>
20265  
20266 -#include "ide_modes.h"
20267 -
20268  /* #define DEBUG */  /* remove comments for DEBUG messages */
20269  
20270  /*
20271 diff -Nru a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
20272 --- a/drivers/ide/legacy/macide.c       Tue Feb 18 10:06:19 2003
20273 +++ b/drivers/ide/legacy/macide.c       Sun Aug 24 05:37:06 2003
20274 @@ -126,7 +126,7 @@
20275                         /* probing the drive which freezes a 190.       */
20276  
20277                         ide_drive_t *drive = &ide_hwifs[index].drives[0];
20278 -                       drive->capacity = drive->cyl*drive->head*drive->sect;
20279 +                       drive->capacity64 = drive->cyl*drive->head*drive->sect;
20280  
20281  #ifdef CONFIG_BLK_DEV_MAC_MEDIABAY
20282                         request_irq(IRQ_BABOON_2, macide_mediabay_interrupt,
20283 diff -Nru a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
20284 --- a/drivers/ide/legacy/qd65xx.c       Tue Aug 12 13:29:09 2003
20285 +++ b/drivers/ide/legacy/qd65xx.c       Sun Aug 24 15:33:30 2003
20286 @@ -42,7 +42,6 @@
20287  #include <asm/system.h>
20288  #include <asm/io.h>
20289  
20290 -#include "ide_modes.h"
20291  #include "qd65xx.h"
20292  
20293  /*
20294 diff -Nru a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c
20295 --- a/drivers/ide/legacy/umc8672.c      Tue Aug 12 13:29:09 2003
20296 +++ b/drivers/ide/legacy/umc8672.c      Sun Aug 24 15:33:30 2003
20297 @@ -54,8 +54,6 @@
20298  
20299  #include <asm/io.h>
20300  
20301 -#include "ide_modes.h"
20302 -
20303  /*
20304   * Default speeds.  These can be changed with "auto-tune" and/or hdparm.
20305   */
20306 diff -Nru a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
20307 --- a/drivers/ide/pci/aec62xx.c Thu Jul 31 08:58:49 2003
20308 +++ b/drivers/ide/pci/aec62xx.c Sun Aug 24 15:33:30 2003
20309 @@ -16,7 +16,6 @@
20310  
20311  #include <asm/io.h>
20312  
20313 -#include "ide_modes.h"
20314  #include "aec62xx.h"
20315  
20316  #if defined(DISPLAY_AEC62XX_TIMINGS) && defined(CONFIG_PROC_FS)
20317 diff -Nru a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
20318 --- a/drivers/ide/pci/alim15x3.c        Sat Aug 16 06:34:25 2003
20319 +++ b/drivers/ide/pci/alim15x3.c        Sun Aug 24 15:33:30 2003
20320 @@ -37,7 +37,6 @@
20321  
20322  #include <asm/io.h>
20323  
20324 -#include "ide_modes.h"
20325  #include "alim15x3.h"
20326  
20327  /*
20328 diff -Nru a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
20329 --- a/drivers/ide/pci/cmd640.c  Thu Mar 13 16:49:44 2003
20330 +++ b/drivers/ide/pci/cmd640.c  Sun Aug 24 15:33:30 2003
20331 @@ -115,8 +115,6 @@
20332  
20333  #include <asm/io.h>
20334  
20335 -#include "ide_modes.h"
20336 -
20337  /*
20338   * This flag is set in ide.c by the parameter:  ide0=cmd640_vlb
20339   */
20340 diff -Nru a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
20341 --- a/drivers/ide/pci/cmd64x.c  Thu Jul 31 08:58:49 2003
20342 +++ b/drivers/ide/pci/cmd64x.c  Mon Sep  1 08:23:55 2003
20343 @@ -25,7 +25,6 @@
20344  
20345  #include <asm/io.h>
20346  
20347 -#include "ide_modes.h"
20348  #include "cmd64x.h"
20349  
20350  #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS)
20351 @@ -629,10 +628,7 @@
20352  
20353         /* Set a good latency timer and cache line size value. */
20354         (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
20355 -#ifdef __sparc_v9__
20356 -       (void) pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x10);
20357 -#endif
20358 -
20359 +       /* FIXME: pci_set_master() to ensure a good latency timer value */
20360  
20361         /* Setup interrupts. */
20362         (void) pci_read_config_byte(dev, MRDMODE, &mrdmode);
20363 diff -Nru a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
20364 --- a/drivers/ide/pci/cs5520.c  Thu Jul 31 08:58:49 2003
20365 +++ b/drivers/ide/pci/cs5520.c  Sun Aug 24 15:33:30 2003
20366 @@ -51,7 +51,6 @@
20367  #include <asm/io.h>
20368  #include <asm/irq.h>
20369  
20370 -#include "ide_modes.h"
20371  #include "cs5520.h"
20372  
20373  #if defined(DISPLAY_CS5520_TIMINGS) && defined(CONFIG_PROC_FS)
20374 diff -Nru a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
20375 --- a/drivers/ide/pci/cs5530.c  Thu Jul 31 08:58:49 2003
20376 +++ b/drivers/ide/pci/cs5530.c  Sun Aug 24 15:33:30 2003
20377 @@ -31,7 +31,6 @@
20378  #include <asm/io.h>
20379  #include <asm/irq.h>
20380  
20381 -#include "ide_modes.h"
20382  #include "cs5530.h"
20383  
20384  #if defined(DISPLAY_CS5530_TIMINGS) && defined(CONFIG_PROC_FS)
20385 diff -Nru a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
20386 --- a/drivers/ide/pci/cy82c693.c        Thu Jul 31 08:58:49 2003
20387 +++ b/drivers/ide/pci/cy82c693.c        Sun Aug 24 15:33:30 2003
20388 @@ -54,7 +54,6 @@
20389  
20390  #include <asm/io.h>
20391  
20392 -#include "ide_modes.h"
20393  #include "cy82c693.h"
20394  
20395  /*
20396 @@ -113,7 +112,7 @@
20397  
20398         /* note: we use the same values for 16bit IOR and IOW
20399           *     those are all the same, since I don't have other
20400 -        *      timings than those from ide_modes.h
20401 +        *      timings than those from ide-lib.c
20402          */
20403  
20404         p_pclk->time_16r = (u8)clk1;
20405 diff -Nru a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
20406 --- a/drivers/ide/pci/hpt34x.c  Thu Jul 31 08:58:49 2003
20407 +++ b/drivers/ide/pci/hpt34x.c  Sun Aug 24 15:33:30 2003
20408 @@ -42,7 +42,6 @@
20409  #include <asm/io.h>
20410  #include <asm/irq.h>
20411  
20412 -#include "ide_modes.h"
20413  #include "hpt34x.h"
20414  
20415  #if defined(DISPLAY_HPT34X_TIMINGS) && defined(CONFIG_PROC_FS)
20416 diff -Nru a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
20417 --- a/drivers/ide/pci/hpt366.c  Mon Aug 11 09:04:06 2003
20418 +++ b/drivers/ide/pci/hpt366.c  Sun Aug 24 15:33:30 2003
20419 @@ -62,7 +62,6 @@
20420  #include <asm/io.h>
20421  #include <asm/irq.h>
20422  
20423 -#include "ide_modes.h"
20424  #include "hpt366.h"
20425  
20426  #if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
20427 @@ -989,7 +988,40 @@
20428         hwif->intrproc                  = &hpt3xx_intrproc;
20429         hwif->maskproc                  = &hpt3xx_maskproc;
20430  
20431 -       pci_read_config_byte(hwif->pci_dev, 0x5a, &ata66);
20432 +       /*
20433 +        * The HPT37x uses the CBLID pins as outputs for MA15/MA16
20434 +        * address lines to access an external eeprom.  To read valid
20435 +        * cable detect state the pins must be enabled as inputs.
20436 +        */
20437 +       if (hpt_minimum_revision(dev, 8) && PCI_FUNC(dev->devfn) & 1) {
20438 +               /*
20439 +                * HPT374 PCI function 1
20440 +                * - set bit 15 of reg 0x52 to enable TCBLID as input
20441 +                * - set bit 15 of reg 0x56 to enable FCBLID as input
20442 +                */
20443 +               u16 mcr3, mcr6;
20444 +               pci_read_config_word(dev, 0x52, &mcr3);
20445 +               pci_read_config_word(dev, 0x56, &mcr6);
20446 +               pci_write_config_word(dev, 0x52, mcr3 | 0x8000);
20447 +               pci_write_config_word(dev, 0x56, mcr6 | 0x8000);
20448 +               /* now read cable id register */
20449 +               pci_read_config_byte(dev, 0x5a, &ata66);
20450 +               pci_write_config_word(dev, 0x52, mcr3);
20451 +               pci_write_config_word(dev, 0x56, mcr6);
20452 +       } else if (hpt_minimum_revision(dev, 3)) {
20453 +               /*
20454 +                * HPT370/372 and 374 pcifn 0
20455 +                * - clear bit 0 of 0x5b to enable P/SCBLID as inputs
20456 +                */
20457 +               u8 scr2;
20458 +               pci_read_config_byte(dev, 0x5b, &scr2);
20459 +               pci_write_config_byte(dev, 0x5b, scr2 & ~1);
20460 +               /* now read cable id register */
20461 +               pci_read_config_byte(dev, 0x5a, &ata66);
20462 +               pci_write_config_byte(dev, 0x5b, scr2);
20463 +       } else {
20464 +               pci_read_config_byte(dev, 0x5a, &ata66);
20465 +       }
20466  
20467  #ifdef DEBUG
20468         printk("HPT366: reg5ah=0x%02x ATA-%s Cable Port%d\n",
20469 diff -Nru a/drivers/ide/pci/it8172.c b/drivers/ide/pci/it8172.c
20470 --- a/drivers/ide/pci/it8172.c  Thu Jul 31 08:58:49 2003
20471 +++ b/drivers/ide/pci/it8172.c  Sun Aug 24 15:33:30 2003
20472 @@ -42,7 +42,6 @@
20473  #include <asm/io.h>
20474  #include <asm/it8172/it8172_int.h>
20475  
20476 -#include "ide_modes.h"
20477  #include "it8172.h"
20478  
20479  /*
20480 diff -Nru a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
20481 --- a/drivers/ide/pci/ns87415.c Thu Jul 31 08:58:49 2003
20482 +++ b/drivers/ide/pci/ns87415.c Mon Sep  1 08:23:55 2003
20483 @@ -147,9 +147,7 @@
20484  
20485         /* Set a good latency timer and cache line size value. */
20486         (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
20487 -#ifdef __sparc_v9__
20488 -       (void) pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x10);
20489 -#endif
20490 +       /* FIXME: use pci_set_master() to ensure good latency timer value */
20491  
20492         /*
20493          * We cannot probe for IRQ: both ports share common IRQ on INTA.
20494 diff -Nru a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
20495 --- a/drivers/ide/pci/opti621.c Thu Jul 31 08:58:49 2003
20496 +++ b/drivers/ide/pci/opti621.c Sun Aug 24 15:33:30 2003
20497 @@ -104,7 +104,6 @@
20498  
20499  #include <asm/io.h>
20500  
20501 -#include "ide_modes.h"
20502  #include "opti621.h"
20503  
20504  #define OPTI621_MAX_PIO 3
20505 diff -Nru a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
20506 --- a/drivers/ide/pci/pdc202xx_new.c    Thu Jul 31 08:58:49 2003
20507 +++ b/drivers/ide/pci/pdc202xx_new.c    Sun Aug 24 15:33:30 2003
20508 @@ -32,7 +32,6 @@
20509  #include <asm/io.h>
20510  #include <asm/irq.h>
20511  
20512 -#include "ide_modes.h"
20513  #include "pdc202xx_new.h"
20514  
20515  #define PDC202_DEBUG_CABLE     0
20516 diff -Nru a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
20517 --- a/drivers/ide/pci/pdc202xx_old.c    Wed Aug 13 17:45:49 2003
20518 +++ b/drivers/ide/pci/pdc202xx_old.c    Sun Aug 24 15:33:30 2003
20519 @@ -46,7 +46,6 @@
20520  #include <asm/io.h>
20521  #include <asm/irq.h>
20522  
20523 -#include "ide_modes.h"
20524  #include "pdc202xx_old.h"
20525  
20526  #define PDC202_DEBUG_CABLE     0
20527 diff -Nru a/drivers/ide/pci/pdcadma.c b/drivers/ide/pci/pdcadma.c
20528 --- a/drivers/ide/pci/pdcadma.c Thu Jul 31 08:58:49 2003
20529 +++ b/drivers/ide/pci/pdcadma.c Sun Aug 24 15:33:30 2003
20530 @@ -24,7 +24,6 @@
20531  #include <asm/io.h>
20532  #include <asm/irq.h>
20533  
20534 -#include "ide_modes.h"
20535  #include "pdcadma.h"
20536  
20537  #if defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS)
20538 diff -Nru a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
20539 --- a/drivers/ide/pci/piix.c    Thu Jul 31 08:58:49 2003
20540 +++ b/drivers/ide/pci/piix.c    Sun Aug 24 15:33:30 2003
20541 @@ -103,7 +103,6 @@
20542  
20543  #include <asm/io.h>
20544  
20545 -#include "ide_modes.h"
20546  #include "piix.h"
20547  
20548  static int no_piix_dma;
20549 diff -Nru a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
20550 --- a/drivers/ide/pci/sc1200.c  Thu Jul 31 08:58:49 2003
20551 +++ b/drivers/ide/pci/sc1200.c  Sun Aug 24 15:33:30 2003
20552 @@ -29,7 +29,6 @@
20553  #include <asm/io.h>
20554  #include <asm/irq.h>
20555  
20556 -#include "ide_modes.h"
20557  #include "sc1200.h"
20558  
20559  #define SC1200_REV_A   0x00
20560 diff -Nru a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
20561 --- a/drivers/ide/pci/serverworks.c     Thu Jul 31 08:58:49 2003
20562 +++ b/drivers/ide/pci/serverworks.c     Sun Aug 24 15:33:30 2003
20563 @@ -39,7 +39,6 @@
20564  
20565  #include <asm/io.h>
20566  
20567 -#include "ide_modes.h"
20568  #include "serverworks.h"
20569  
20570  static u8 svwks_revision = 0;
20571 diff -Nru a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
20572 --- a/drivers/ide/pci/siimage.c Wed Aug 13 17:45:20 2003
20573 +++ b/drivers/ide/pci/siimage.c Mon Sep  1 15:53:57 2003
20574 @@ -1,7 +1,24 @@
20575  /*
20576 - * linux/drivers/ide/pci/siimage.c             Version 1.02    Jan 30, 2003
20577 + * linux/drivers/ide/pci/siimage.c             Version 1.06    June 11, 2003
20578   *
20579   * Copyright (C) 2001-2002     Andre Hedrick <andre@linux-ide.org>
20580 + * Copyright (C) 2003          Red Hat <alan@redhat.com>
20581 + *
20582 + *  May be copied or modified under the terms of the GNU General Public License
20583 + *
20584 + *  Documentation available under NDA only
20585 + *
20586 + *
20587 + *  FAQ Items:
20588 + *     If you are using Marvell SATA-IDE adapters with Maxtor drives
20589 + *     ensure the system is set up for ATA100/UDMA5 not UDMA6.
20590 + *
20591 + *     If you are using WD drives with SATA bridges you must set the
20592 + *     drive to "Single". "Master" will hang
20593 + *
20594 + *     If you have strange problems with nVidia chipset systems please
20595 + *     see the SI support documentation and update your system BIOS
20596 + *     if neccessary
20597   */
20598  
20599  #include <linux/config.h>
20600 @@ -15,7 +32,6 @@
20601  
20602  #include <asm/io.h>
20603  
20604 -#include "ide_modes.h"
20605  #include "siimage.h"
20606  
20607  #if defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS)
20608 @@ -23,16 +39,107 @@
20609  #include <linux/proc_fs.h>
20610  
20611  static u8 siimage_proc = 0;
20612 -#define SIIMAGE_MAX_DEVS               5
20613 +#define SIIMAGE_MAX_DEVS               16
20614  static struct pci_dev *siimage_devs[SIIMAGE_MAX_DEVS];
20615  static int n_siimage_devs;
20616  
20617 -static char * print_siimage_get_info (char *buf, struct pci_dev *dev, int index)
20618 +/**
20619 + *     pdev_is_sata            -       check if device is SATA
20620 + *     @pdev:  PCI device to check
20621 + *     
20622 + *     Returns true if this is a SATA controller
20623 + */
20624
20625 +static int pdev_is_sata(struct pci_dev *pdev)
20626 +{
20627 +       switch(pdev->device)
20628 +       {
20629 +               case PCI_DEVICE_ID_SII_3112:
20630 +               case PCI_DEVICE_ID_SII_1210SA:
20631 +                       return 1;
20632 +               case PCI_DEVICE_ID_SII_680:
20633 +                       return 0;
20634 +       }
20635 +       BUG();
20636 +       return 0;
20637 +}
20638
20639 +/**
20640 + *     is_sata                 -       check if hwif is SATA
20641 + *     @hwif:  interface to check
20642 + *     
20643 + *     Returns true if this is a SATA controller
20644 + */
20645
20646 +static inline int is_sata(ide_hwif_t *hwif)
20647 +{
20648 +       return pdev_is_sata(hwif->pci_dev);
20649 +}
20650 +
20651 +/**
20652 + *     siimage_selreg          -       return register base
20653 + *     @hwif: interface
20654 + *     @r: config offset
20655 + *
20656 + *     Turn a config register offset into the right address in either
20657 + *     PCI space or MMIO space to access the control register in question
20658 + *     Thankfully this is a configuration operation so isnt performance
20659 + *     criticial. 
20660 + */
20661
20662 +static unsigned long siimage_selreg(ide_hwif_t *hwif, int r)
20663 +{
20664 +       unsigned long base = (unsigned long)hwif->hwif_data;
20665 +       base += 0xA0 + r;
20666 +       if(hwif->mmio)
20667 +               base += (hwif->channel << 6);
20668 +       else
20669 +               base += (hwif->channel << 4);
20670 +       return base;
20671 +}
20672 +       
20673 +/**
20674 + *     siimage_seldev          -       return register base
20675 + *     @hwif: interface
20676 + *     @r: config offset
20677 + *
20678 + *     Turn a config register offset into the right address in either
20679 + *     PCI space or MMIO space to access the control register in question
20680 + *     including accounting for the unit shift.
20681 + */
20682
20683 +static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
20684 +{
20685 +       ide_hwif_t *hwif        = HWIF(drive);
20686 +       unsigned long base = (unsigned long)hwif->hwif_data;
20687 +       base += 0xA0 + r;
20688 +       if(hwif->mmio)
20689 +               base += (hwif->channel << 6);
20690 +       else
20691 +               base += (hwif->channel << 4);
20692 +       base |= drive->select.b.unit << drive->select.b.unit;
20693 +       return base;
20694 +}
20695 +       
20696 +/**
20697 + *     print_siimage_get_info  -       print minimal proc information
20698 + *     @buf: buffer to write into (kernel space)
20699 + *     @dev: PCI device we are describing
20700 + *     @index: Controller number
20701 + *
20702 + *     Print the basic information for the state of the CMD680/SI3112
20703 + *     channel. We don't actually dump a lot of information out for
20704 + *     this controller although we could expand it if we needed.
20705 + */
20706
20707 +static char *print_siimage_get_info (char *buf, struct pci_dev *dev, int index)
20708  {
20709         char *p         = buf;
20710         u8 mmio         = (pci_get_drvdata(dev) != NULL) ? 1 : 0;
20711 -       unsigned long bmdma     = (mmio) ? ((unsigned long) pci_get_drvdata(dev)) :
20712 -                                   (pci_resource_start(dev, 4));
20713 +       unsigned long bmdma = pci_resource_start(dev, 4);
20714 +       
20715 +       if(mmio)
20716 +               bmdma = pci_resource_start(dev, 5);
20717  
20718         p += sprintf(p, "\nController: %d\n", index);
20719         p += sprintf(p, "SiI%x Chipset.\n", dev->device);
20720 @@ -40,18 +147,20 @@
20721                 p += sprintf(p, "MMIO Base 0x%lx\n", bmdma);
20722         p += sprintf(p, "%s-DMA Base 0x%lx\n", (mmio)?"MMIO":"BM", bmdma);
20723         p += sprintf(p, "%s-DMA Base 0x%lx\n", (mmio)?"MMIO":"BM", bmdma+8);
20724 -
20725 -       p += sprintf(p, "--------------- Primary Channel "
20726 -                       "---------------- Secondary Channel "
20727 -                       "-------------\n");
20728 -       p += sprintf(p, "--------------- drive0 --------- drive1 "
20729 -                       "-------- drive0 ---------- drive1 ------\n");
20730 -       p += sprintf(p, "PIO Mode:       %s                %s"
20731 -                       "               %s                 %s\n",
20732 -                       "?", "?", "?", "?");
20733         return (char *)p;
20734  }
20735  
20736 +/**
20737 + *     siimage_get_info        -       proc callback
20738 + *     @buffer: kernel buffer to complete
20739 + *     @addr: written with base of data to return
20740 + *     offset: seek offset
20741 + *     count: bytes to fill in 
20742 + *
20743 + *     Called when the user reads data from the virtual file for this
20744 + *     controller from /proc
20745 + */
20746
20747  static int siimage_get_info (char *buffer, char **addr, off_t offset, int count)
20748  {
20749         char *p = buffer;
20750 @@ -72,46 +181,70 @@
20751  
20752  #endif /* defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS) */
20753  
20754 +/**
20755 + *     siimage_ratemask        -       Compute available modes
20756 + *     @drive: IDE drive
20757 + *
20758 + *     Compute the available speeds for the devices on the interface.
20759 + *     For the CMD680 this depends on the clocking mode (scsc), for the
20760 + *     SI3312 SATA controller life is a bit simpler. Enforce UDMA33
20761 + *     as a limit if there is no 80pin cable present.
20762 + */
20763
20764  static byte siimage_ratemask (ide_drive_t *drive)
20765  {
20766         ide_hwif_t *hwif        = HWIF(drive);
20767         u8 mode = 0, scsc = 0;
20768 +       unsigned long base = (unsigned long) hwif->hwif_data;
20769  
20770         if (hwif->mmio)
20771 -               scsc = hwif->INB(HWIFADDR(0x4A));
20772 +               scsc = hwif->INB(base + 0x4A);
20773         else
20774                 pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc);
20775  
20776 -       switch(hwif->pci_dev->device) {
20777 -               case PCI_DEVICE_ID_SII_3112:
20778 -                       return 4;
20779 -               case PCI_DEVICE_ID_SII_680:
20780 -                       if ((scsc & 0x10) == 0x10)      /* 133 */
20781 -                               mode = 4;
20782 -                       else if ((scsc & 0x30) == 0x00) /* 100 */
20783 -                               mode = 3;
20784 -                       else if ((scsc & 0x20) == 0x20) /* 66 eek */
20785 -                               BUG();  // mode = 2;
20786 -                       break;
20787 -               default:        return 0;
20788 +       if(is_sata(hwif))
20789 +       {
20790 +               if(strstr(drive->id->model, "Maxtor"))
20791 +                       return 3;
20792 +               return 4;
20793         }
20794 +       
20795 +       if ((scsc & 0x30) == 0x10)      /* 133 */
20796 +               mode = 4;
20797 +       else if ((scsc & 0x30) == 0x20) /* 2xPCI */
20798 +               mode = 4;
20799 +       else if ((scsc & 0x30) == 0x00) /* 100 */
20800 +               mode = 3;
20801 +       else    /* Disabled ? */
20802 +               BUG();
20803 +
20804         if (!eighty_ninty_three(drive))
20805                 mode = min(mode, (u8)1);
20806         return mode;
20807  }
20808  
20809 +/**
20810 + *     siimage_taskfile_timing -       turn timing data to a mode
20811 + *     @hwif: interface to query
20812 + *
20813 + *     Read the timing data for the interface and return the 
20814 + *     mode that is being used.
20815 + */
20816
20817  static byte siimage_taskfile_timing (ide_hwif_t *hwif)
20818  {
20819         u16 timing      = 0x328a;
20820 +       unsigned long addr = siimage_selreg(hwif, 2);
20821  
20822         if (hwif->mmio)
20823 -               timing = hwif->INW(SELADDR(2));
20824 +               timing = hwif->INW(addr);
20825         else
20826 -               pci_read_config_word(hwif->pci_dev, SELREG(2), &timing);
20827 +               pci_read_config_word(hwif->pci_dev, addr, &timing);
20828  
20829         switch (timing) {
20830                 case 0x10c1:    return 4;
20831                 case 0x10c3:    return 3;
20832 +               case 0x1104:
20833                 case 0x1281:    return 2;
20834                 case 0x2283:    return 1;
20835                 case 0x328a:
20836 @@ -119,34 +252,88 @@
20837         }
20838  }
20839  
20840 +/**
20841 + *     simmage_tuneproc        -       tune a drive
20842 + *     @drive: drive to tune
20843 + *     @mode_wanted: the target operating mode
20844 + *
20845 + *     Load the timing settings for this device mode into the
20846 + *     controller. If we are in PIO mode 3 or 4 turn on IORDY
20847 + *     monitoring (bit 9). The TF timing is bits 31:16
20848 + */
20849
20850  static void siimage_tuneproc (ide_drive_t *drive, byte mode_wanted)
20851  {
20852         ide_hwif_t *hwif        = HWIF(drive);
20853 -       struct pci_dev *dev     = hwif->pci_dev;
20854 -       u16 speedt              = 0;
20855 -       u8 unit                 = drive->select.b.unit;
20856 -
20857 -       if (hwif->mmio)
20858 -               speedt = hwif->INW(SELADDR(0x04|(unit<<unit)));
20859 -       else
20860 -               pci_read_config_word(dev, SELADDR(0x04|(unit<<unit)), &speedt);
20861 -
20862 +       u32 speedt              = 0;
20863 +       u16 speedp              = 0;
20864 +       unsigned long addr      = siimage_seldev(drive, 0x04);
20865 +       unsigned long tfaddr    = siimage_selreg(hwif, 0x02);
20866 +       
20867         /* cheat for now and use the docs */
20868 -//     switch(siimage_taskfile_timing(hwif)) {
20869         switch(mode_wanted) {
20870 -               case 4:         speedt = 0x10c1; break;
20871 -               case 3:         speedt = 0x10C3; break;
20872 -               case 2:         speedt = 0x1104; break;
20873 -               case 1:         speedt = 0x2283; break;
20874 +               case 4: 
20875 +                       speedp = 0x10c1; 
20876 +                       speedt = 0x10c1;
20877 +                       break;
20878 +               case 3: 
20879 +                       speedp = 0x10C3; 
20880 +                       speedt = 0x10C3;
20881 +                       break;
20882 +               case 2: 
20883 +                       speedp = 0x1104; 
20884 +                       speedt = 0x1281;
20885 +                       break;
20886 +               case 1:         
20887 +                       speedp = 0x2283; 
20888 +                       speedt = 0x1281;
20889 +                       break;
20890                 case 0:
20891 -               default:        speedt = 0x328A; break;
20892 +               default:
20893 +                       speedp = 0x328A; 
20894 +                       speedt = 0x328A;
20895 +                       break;
20896         }
20897         if (hwif->mmio)
20898 -               hwif->OUTW(speedt, SELADDR(0x04|(unit<<unit)));
20899 +       {
20900 +               hwif->OUTW(speedt, addr);
20901 +               hwif->OUTW(speedp, tfaddr);
20902 +               /* Now set up IORDY */
20903 +               if(mode_wanted == 3 || mode_wanted == 4)
20904 +                       hwif->OUTW(hwif->INW(tfaddr-2)|0x200, tfaddr-2);
20905 +               else
20906 +                       hwif->OUTW(hwif->INW(tfaddr-2)&~0x200, tfaddr-2);
20907 +       }
20908         else
20909 -               pci_write_config_word(dev, SELADDR(0x04|(unit<<unit)), speedt);
20910 +       {
20911 +               pci_write_config_word(hwif->pci_dev, addr, speedp);
20912 +               pci_write_config_word(hwif->pci_dev, tfaddr, speedt);
20913 +               pci_read_config_word(hwif->pci_dev, tfaddr-2, &speedp);
20914 +               speedp &= ~0x200;
20915 +               /* Set IORDY for mode 3 or 4 */
20916 +               if(mode_wanted == 3 || mode_wanted == 4)
20917 +                       speedp |= 0x200;
20918 +               pci_write_config_word(hwif->pci_dev, tfaddr-2, speedp);
20919 +       }
20920  }
20921  
20922 +/**
20923 + *     config_siimage_chipset_for_pio  -       set drive timings
20924 + *     @drive: drive to tune
20925 + *     @speed we want
20926 + *
20927 + *     Compute the best pio mode we can for a given device. Also honour
20928 + *     the timings for the driver when dealing with mixed devices. Some
20929 + *     of this is ugly but its all wrapped up here
20930 + *
20931 + *     The SI680 can also do VDMA - we need to start using that
20932 + *
20933 + *     FIXME: we use the BIOS channel timings to avoid driving the task
20934 + *     files too fast at the disk. We need to compute the master/slave
20935 + *     drive PIO mode properly so that we can up the speed on a hotplug
20936 + *     system.
20937 + */
20938
20939  static void config_siimage_chipset_for_pio (ide_drive_t *drive, byte set_speed)
20940  {
20941         u8 channel_timings      = siimage_taskfile_timing(HWIF(drive));
20942 @@ -167,6 +354,16 @@
20943         config_siimage_chipset_for_pio(drive, set_speed);
20944  }
20945  
20946 +/**
20947 + *     siimage_tune_chipset    -       set controller timings
20948 + *     @drive: Drive to set up
20949 + *     @xferspeed: speed we want to achieve
20950 + *
20951 + *     Tune the SII chipset for the desired mode. If we can't achieve
20952 + *     the desired mode then tune for a lower one, but ultimately
20953 + *     make the thing work.
20954 + */
20955
20956  static int siimage_tune_chipset (ide_drive_t *drive, byte xferspeed)
20957  {
20958         u8 ultra6[]             = { 0x0F, 0x0B, 0x07, 0x05, 0x03, 0x02, 0x01 };
20959 @@ -176,30 +373,32 @@
20960         ide_hwif_t *hwif        = HWIF(drive);
20961         u16 ultra = 0, multi    = 0;
20962         u8 mode = 0, unit       = drive->select.b.unit;
20963 -       u8 speed        = ide_rate_filter(siimage_ratemask(drive), xferspeed);
20964 +       u8 speed                = ide_rate_filter(siimage_ratemask(drive), xferspeed);
20965 +       unsigned long base      = (unsigned long)hwif->hwif_data;
20966         u8 scsc = 0, addr_mask  = ((hwif->channel) ?
20967                                     ((hwif->mmio) ? 0xF4 : 0x84) :
20968                                     ((hwif->mmio) ? 0xB4 : 0x80));
20969 +                                   
20970 +       unsigned long ma        = siimage_seldev(drive, 0x08);
20971 +       unsigned long ua        = siimage_seldev(drive, 0x0C);
20972  
20973         if (hwif->mmio) {
20974 -               scsc = hwif->INB(HWIFADDR(0x4A));
20975 -               mode = hwif->INB(HWIFADDR(addr_mask));
20976 -               multi = hwif->INW(SELADDR(0x08|(unit<<unit)));
20977 -               ultra = hwif->INW(SELADDR(0x0C|(unit<<unit)));
20978 +               scsc = hwif->INB(base + 0x4A);
20979 +               mode = hwif->INB(base + addr_mask);
20980 +               multi = hwif->INW(ma);
20981 +               ultra = hwif->INW(ua);
20982         } else {
20983 -               pci_read_config_byte(hwif->pci_dev, HWIFADDR(0x8A), &scsc);
20984 +               pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc);
20985                 pci_read_config_byte(hwif->pci_dev, addr_mask, &mode);
20986 -               pci_read_config_word(hwif->pci_dev,
20987 -                               SELREG(0x08|(unit<<unit)), &multi);
20988 -               pci_read_config_word(hwif->pci_dev,
20989 -                               SELREG(0x0C|(unit<<unit)), &ultra);
20990 +               pci_read_config_word(hwif->pci_dev, ma, &multi);
20991 +               pci_read_config_word(hwif->pci_dev, ua, &ultra);
20992         }
20993  
20994         mode &= ~((unit) ? 0x30 : 0x03);
20995         ultra &= ~0x3F;
20996         scsc = ((scsc & 0x30) == 0x00) ? 0 : 1;
20997  
20998 -       scsc = (hwif->pci_dev->device == PCI_DEVICE_ID_SII_3112) ? 1 : scsc;
20999 +       scsc = is_sata(hwif) ? 1 : scsc;
21000  
21001         switch(speed) {
21002                 case XFER_PIO_4:
21003 @@ -225,8 +424,8 @@
21004                 case XFER_UDMA_1:
21005                 case XFER_UDMA_0:
21006                         multi = dma[2];
21007 -                       ultra |= ((scsc) ? (ultra5[speed - XFER_UDMA_0]) :
21008 -                                          (ultra6[speed - XFER_UDMA_0]));
21009 +                       ultra |= ((scsc) ? (ultra6[speed - XFER_UDMA_0]) :
21010 +                                          (ultra5[speed - XFER_UDMA_0]));
21011                         mode |= ((unit) ? 0x30 : 0x03);
21012                         config_siimage_chipset_for_pio(drive, 0);
21013                         break;
21014 @@ -235,20 +434,26 @@
21015         }
21016  
21017         if (hwif->mmio) {
21018 -               hwif->OUTB(mode, HWIFADDR(addr_mask));
21019 -               hwif->OUTW(multi, SELADDR(0x08|(unit<<unit)));
21020 -               hwif->OUTW(ultra, SELADDR(0x0C|(unit<<unit)));
21021 +               hwif->OUTB(mode, base + addr_mask);
21022 +               hwif->OUTW(multi, ma);
21023 +               hwif->OUTW(ultra, ua);
21024         } else {
21025                 pci_write_config_byte(hwif->pci_dev, addr_mask, mode);
21026 -               pci_write_config_word(hwif->pci_dev,
21027 -                               SELREG(0x08|(unit<<unit)), multi);
21028 -               pci_write_config_word(hwif->pci_dev,
21029 -                               SELREG(0x0C|(unit<<unit)), ultra);
21030 +               pci_write_config_word(hwif->pci_dev, ma, multi);
21031 +               pci_write_config_word(hwif->pci_dev, ua, ultra);
21032         }
21033 -
21034         return (ide_config_drive_speed(drive, speed));
21035  }
21036  
21037 +/**
21038 + *     config_chipset_for_dma  -       configure for DMA
21039 + *     @drive: drive to configure
21040 + *
21041 + *     Called by the IDE layer when it wants the timings set up.
21042 + *     For the CMD680 we also need to set up the PIO timings and
21043 + *     enable DMA.
21044 + */
21045
21046  static int config_chipset_for_dma (ide_drive_t *drive)
21047  {
21048         u8 speed        = ide_dma_speed(drive, siimage_ratemask(drive));
21049 @@ -267,14 +472,22 @@
21050         return ide_dma_enable(drive);
21051  }
21052  
21053 +/**
21054 + *     siimage_configure_drive_for_dma -       set up for DMA transfers
21055 + *     @drive: drive we are going to set up
21056 + *
21057 + *     Set up the drive for DMA, tune the controller and drive as 
21058 + *     required. If the drive isn't suitable for DMA or we hit
21059 + *     other problems then we will drop down to PIO and set up
21060 + *     PIO appropriately
21061 + */
21062
21063  static int siimage_config_drive_for_dma (ide_drive_t *drive)
21064  {
21065         ide_hwif_t *hwif        = HWIF(drive);
21066         struct hd_driveid *id   = drive->id;
21067  
21068 -       if (id != NULL && (id->capability & 1) != 0 && drive->autodma) {
21069 -               if (!(hwif->atapi_dma))
21070 -                       goto fast_ata_pio;
21071 +       if ((id->capability & 1) != 0 && drive->autodma) {
21072                 /* Consult the list of known "bad" drives */
21073                 if (hwif->ide_dma_bad_drive(drive))
21074                         goto fast_ata_pio;
21075 @@ -316,18 +529,28 @@
21076  {
21077         ide_hwif_t *hwif        = HWIF(drive);
21078         u8 dma_altstat          = 0;
21079 +       unsigned long addr      = siimage_selreg(hwif, 1);
21080  
21081         /* return 1 if INTR asserted */
21082         if ((hwif->INB(hwif->dma_status) & 4) == 4)
21083                 return 1;
21084  
21085         /* return 1 if Device INTR asserted */
21086 -       pci_read_config_byte(hwif->pci_dev, SELREG(1), &dma_altstat);
21087 +       pci_read_config_byte(hwif->pci_dev, addr, &dma_altstat);
21088         if (dma_altstat & 8)
21089                 return 0;       //return 1;
21090         return 0;
21091  }
21092  
21093 +/**
21094 + *     siimage_mmio_ide_dma_count      -       DMA bytes done
21095 + *     @drive
21096 + *
21097 + *     If we are doing VDMA the CMD680 requires a little bit
21098 + *     of more careful handling and we have to read the counts
21099 + *     off ourselves. For non VDMA life is normal.
21100 + */
21101
21102  static int siimage_mmio_ide_dma_count (ide_drive_t *drive)
21103  {
21104  #ifdef SIIMAGE_VIRTUAL_DMAPIO
21105 @@ -335,9 +558,10 @@
21106         ide_hwif_t *hwif        = HWIF(drive);
21107         u32 count               = (rq->nr_sectors * SECTOR_SIZE);
21108         u32 rcount              = 0;
21109 +       unsigned long addr      = siimage_selreg(hwif, 0x1C);
21110  
21111 -       hwif->OUTL(count, SELADDR(0x1C));
21112 -       rcount = hwif->INL(SELADDR(0x1C));
21113 +       hwif->OUTL(count, addr);
21114 +       rcount = hwif->INL(addr);
21115  
21116         printk("\n%s: count = %d, rcount = %d, nr_sectors = %lu\n",
21117                 drive->name, count, rcount, rq->nr_sectors);
21118 @@ -346,13 +570,22 @@
21119         return __ide_dma_count(drive);
21120  }
21121  
21122 -/* returns 1 if dma irq issued, 0 otherwise */
21123 +/**
21124 + *     siimage_mmio_ide_dma_test_irq   -       check we caused an IRQ
21125 + *     @drive: drive we are testing
21126 + *
21127 + *     Check if we caused an IDE DMA interrupt. We may also have caused
21128 + *     SATA status interrupts, if so we clean them up and continue.
21129 + */
21130
21131  static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
21132  {
21133         ide_hwif_t *hwif        = HWIF(drive);
21134 +       unsigned long base      = (unsigned long)hwif->hwif_data;
21135 +       unsigned long addr      = siimage_selreg(hwif, 0x1);
21136  
21137         if (SATA_ERROR_REG) {
21138 -               u32 ext_stat = hwif->INL(HWIFADDR(0x10));
21139 +               u32 ext_stat = hwif->INL(base + 0x10);
21140                 u8 watchdog = 0;
21141                 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) {
21142                         u32 sata_error = hwif->INL(SATA_ERROR_REG);
21143 @@ -379,7 +612,7 @@
21144                 return 1;
21145  
21146         /* return 1 if Device INTR asserted */
21147 -       if ((hwif->INB(SELADDR(1)) & 8) == 8)
21148 +       if ((hwif->INB(addr) & 8) == 8)
21149                 return 0;       //return 1;
21150  
21151         return 0;
21152 @@ -388,21 +621,29 @@
21153  static int siimage_mmio_ide_dma_verbose (ide_drive_t *drive)
21154  {
21155         int temp = __ide_dma_verbose(drive);
21156 -#if 0
21157 -       drive->using_dma = 0;
21158 -#endif
21159         return temp;
21160  }
21161  
21162 +/**
21163 + *     siimage_busproc         -       bus isolation ioctl
21164 + *     @drive: drive to isolate/restore
21165 + *     @state: bus state to set
21166 + *
21167 + *     Used by the SII3112 to handle bus isolation. As this is a 
21168 + *     SATA controller the work required is quite limited, we 
21169 + *     just have to clean up the statistics
21170 + */
21171
21172  static int siimage_busproc (ide_drive_t * drive, int state)
21173  {
21174         ide_hwif_t *hwif        = HWIF(drive);
21175         u32 stat_config         = 0;
21176 +       unsigned long addr      = siimage_selreg(hwif, 0);
21177  
21178         if (hwif->mmio) {
21179 -               stat_config = hwif->INL(SELADDR(0));
21180 +               stat_config = hwif->INL(addr);
21181         } else
21182 -               pci_read_config_dword(hwif->pci_dev, SELREG(0), &stat_config);
21183 +               pci_read_config_dword(hwif->pci_dev, addr, &stat_config);
21184  
21185         switch (state) {
21186                 case BUSSTATE_ON:
21187 @@ -418,12 +659,20 @@
21188                         hwif->drives[1].failures = hwif->drives[1].max_failures + 1;
21189                         break;
21190                 default:
21191 -                       return 0;
21192 +                       return -EINVAL;
21193         }
21194         hwif->bus_state = state;
21195         return 0;
21196  }
21197  
21198 +/**
21199 + *     siimage_reset_poll      -       wait for sata reset
21200 + *     @drive: drive we are resetting
21201 + *
21202 + *     Poll the SATA phy and see whether it has come back from the dead
21203 + *     yet.
21204 + */
21205
21206  static int siimage_reset_poll (ide_drive_t *drive)
21207  {
21208         if (SATA_STATUS_REG) {
21209 @@ -433,13 +682,7 @@
21210                         printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n",
21211                                 hwif->name, hwif->INL(SATA_STATUS_REG));
21212                         HWGROUP(drive)->poll_timeout = 0;
21213 -#if 0
21214 -                       drive->failures++;
21215 -                       return ide_stopped;
21216 -#else
21217                         return ide_started;
21218 -#endif
21219 -                       return 1;
21220                 }
21221                 return 0;
21222         } else {
21223 @@ -447,34 +690,53 @@
21224         }
21225  }
21226  
21227 +/**
21228 + *     siimage_pre_reset       -       reset hook
21229 + *     @drive: IDE device being reset
21230 + *
21231 + *     For the SATA devices we need to handle recalibration/geometry
21232 + *     differently
21233 + */
21234
21235  static void siimage_pre_reset (ide_drive_t *drive)
21236  {
21237         if (drive->media != ide_disk)
21238                 return;
21239  
21240 -       if (HWIF(drive)->pci_dev->device == PCI_DEVICE_ID_SII_3112) {
21241 +       if (is_sata(HWIF(drive)))
21242 +       {
21243                 drive->special.b.set_geometry = 0;
21244                 drive->special.b.recalibrate = 0;
21245         }
21246  }
21247  
21248 +/**
21249 + *     siimage_reset   -       reset a device on an siimage controller
21250 + *     @drive: drive to reset
21251 + *
21252 + *     Perform a controller level reset fo the device. For
21253 + *     SATA we must also check the PHY.
21254 + */
21255
21256  static void siimage_reset (ide_drive_t *drive)
21257  {
21258         ide_hwif_t *hwif        = HWIF(drive);
21259         u8 reset                = 0;
21260 +       unsigned long addr      = siimage_selreg(hwif, 0);
21261  
21262         if (hwif->mmio) {
21263 -               reset = hwif->INB(SELADDR(0));
21264 -               hwif->OUTB((reset|0x03), SELADDR(0));
21265 +               reset = hwif->INB(addr);
21266 +               hwif->OUTB((reset|0x03), addr);
21267 +               /* FIXME:posting */
21268                 udelay(25);
21269 -               hwif->OUTB(reset, SELADDR(0));
21270 -               (void) hwif->INB(SELADDR(0));
21271 +               hwif->OUTB(reset, addr);
21272 +               (void) hwif->INB(addr);
21273         } else {
21274 -               pci_read_config_byte(hwif->pci_dev, SELREG(0), &reset);
21275 -               pci_write_config_byte(hwif->pci_dev, SELREG(0), reset|0x03);
21276 +               pci_read_config_byte(hwif->pci_dev, addr, &reset);
21277 +               pci_write_config_byte(hwif->pci_dev, addr, reset|0x03);
21278                 udelay(25);
21279 -               pci_write_config_byte(hwif->pci_dev, SELREG(0), reset);
21280 -               pci_read_config_byte(hwif->pci_dev, SELREG(0), &reset);
21281 +               pci_write_config_byte(hwif->pci_dev, addr, reset);
21282 +               pci_read_config_byte(hwif->pci_dev, addr, &reset);
21283         }
21284  
21285         if (SATA_STATUS_REG) {
21286 @@ -490,20 +752,28 @@
21287  
21288  }
21289  
21290 +/**
21291 + *     proc_reports_siimage            -       add siimage controller to proc
21292 + *     @dev: PCI device
21293 + *     @clocking: SCSC value
21294 + *     @name: controller name
21295 + *
21296 + *     Report the clocking mode of the controller and add it to
21297 + *     the /proc interface layer
21298 + */
21299
21300  static void proc_reports_siimage (struct pci_dev *dev, u8 clocking, const char *name)
21301  {
21302 -       if (dev->device == PCI_DEVICE_ID_SII_3112)
21303 +       if(pdev_is_sata(dev))
21304                 goto sata_skip;
21305  
21306         printk(KERN_INFO "%s: BASE CLOCK ", name);
21307 -       clocking &= ~0x0C;
21308 +       clocking &= 0x03;
21309         switch(clocking) {
21310                 case 0x03: printk("DISABLED !\n"); break;
21311                 case 0x02: printk("== 2X PCI \n"); break;
21312                 case 0x01: printk("== 133 \n"); break;
21313                 case 0x00: printk("== 100 \n"); break;
21314 -               default:
21315 -                       BUG();
21316         }
21317  
21318  sata_skip:
21319 @@ -518,75 +788,108 @@
21320  #endif /* DISPLAY_SIIMAGE_TIMINGS && CONFIG_PROC_FS */
21321  }
21322  
21323 +/**
21324 + *     setup_mmio_siimage      -       switch an SI controller into MMIO
21325 + *     @dev: PCI device we are configuring
21326 + *     @name: device name
21327 + *
21328 + *     Attempt to put the device into mmio mode. There are some slight
21329 + *     complications here with certain systems where the mmio bar isnt
21330 + *     mapped so we have to be sure we can fall back to I/O.
21331 + */
21332
21333  static unsigned int setup_mmio_siimage (struct pci_dev *dev, const char *name)
21334  {
21335         unsigned long bar5      = pci_resource_start(dev, 5);
21336 -       unsigned long end5      = pci_resource_end(dev, 5);
21337 +       unsigned long barsize   = pci_resource_len(dev, 5);
21338         u8 tmpbyte      = 0;
21339         unsigned long addr;
21340         void *ioaddr;
21341  
21342 -       ioaddr = ioremap_nocache(bar5, (end5 - bar5));
21343 +       /*
21344 +        *      Drop back to PIO if we can't map the mmio. Some
21345 +        *      systems seem to get terminally confused in the PCI
21346 +        *      spaces.
21347 +        */
21348 +        
21349 +       if(!request_mem_region(bar5, barsize, name))
21350 +       {
21351 +               printk(KERN_WARNING "siimage: IDE controller MMIO ports not available.\n");
21352 +               return 0;
21353 +       }
21354 +               
21355 +       ioaddr = ioremap(bar5, barsize);
21356  
21357         if (ioaddr == NULL)
21358 +       {
21359 +               release_mem_region(bar5, barsize);
21360                 return 0;
21361 +       }
21362  
21363         pci_set_master(dev);
21364         pci_set_drvdata(dev, ioaddr);
21365         addr = (unsigned long) ioaddr;
21366  
21367 -       if (dev->device == PCI_DEVICE_ID_SII_3112) {
21368 -               writel(0, DEVADDR(0x148));
21369 -               writel(0, DEVADDR(0x1C8));
21370 +       if (pdev_is_sata(dev)) {
21371 +               writel(0, addr + 0x148);
21372 +               writel(0, addr + 0x1C8);
21373         }
21374  
21375 -       writeb(0, DEVADDR(0xB4));
21376 -       writeb(0, DEVADDR(0xF4));
21377 -       tmpbyte = readb(DEVADDR(0x4A));
21378 -
21379 -       switch(tmpbyte) {
21380 -               case 0x01:
21381 -                       writeb(tmpbyte|0x10, DEVADDR(0x4A));
21382 -                       tmpbyte = readb(DEVADDR(0x4A));
21383 -               case 0x31:
21384 -                       /* if clocking is disabled */
21385 -                       /* 133 clock attempt to force it on */
21386 -                       writeb(tmpbyte & ~0x20, DEVADDR(0x4A));
21387 -                       tmpbyte = readb(DEVADDR(0x4A));
21388 -               case 0x11:
21389 -               case 0x21:
21390 +       writeb(0, addr + 0xB4);
21391 +       writeb(0, addr + 0xF4);
21392 +       tmpbyte = readb(addr + 0x4A);
21393 +
21394 +       switch(tmpbyte & 0x30) {
21395 +               case 0x00:
21396 +                       /* In 100 MHz clocking, try and switch to 133 */
21397 +                       writeb(tmpbyte|0x10, addr + 0x4A);
21398                         break;
21399 -               default:
21400 -                       tmpbyte &= ~0x30;
21401 -                       tmpbyte |= 0x20;
21402 -                       writeb(tmpbyte, DEVADDR(0x4A));
21403 +               case 0x10:
21404 +                       /* On 133Mhz clocking */
21405 +                       break;
21406 +               case 0x20:
21407 +                       /* On PCIx2 clocking */
21408 +                       break;
21409 +               case 0x30:
21410 +                       /* Clocking is disabled */
21411 +                       /* 133 clock attempt to force it on */
21412 +                       writeb(tmpbyte & ~0x20, addr + 0x4A);
21413                         break;
21414         }
21415         
21416 -       writeb(0x72, DEVADDR(0xA1));
21417 -       writew(0x328A, DEVADDR(0xA2));
21418 -       writel(0x62DD62DD, DEVADDR(0xA4));
21419 -       writel(0x43924392, DEVADDR(0xA8));
21420 -       writel(0x40094009, DEVADDR(0xAC));
21421 -       writeb(0x72, DEVADDR(0xE1));
21422 -       writew(0x328A, DEVADDR(0xE2));
21423 -       writel(0x62DD62DD, DEVADDR(0xE4));
21424 -       writel(0x43924392, DEVADDR(0xE8));
21425 -       writel(0x40094009, DEVADDR(0xEC));
21426 -
21427 -       if (dev->device == PCI_DEVICE_ID_SII_3112) {
21428 -               writel(0xFFFF0000, DEVADDR(0x108));
21429 -               writel(0xFFFF0000, DEVADDR(0x188));
21430 -               writel(0x00680000, DEVADDR(0x148));
21431 -               writel(0x00680000, DEVADDR(0x1C8));
21432 +       writeb(      0x72, addr + 0xA1);
21433 +       writew(    0x328A, addr + 0xA2);
21434 +       writel(0x62DD62DD, addr + 0xA4);
21435 +       writel(0x43924392, addr + 0xA8);
21436 +       writel(0x40094009, addr + 0xAC);
21437 +       writeb(      0x72, addr + 0xE1);
21438 +       writew(    0x328A, addr + 0xE2);
21439 +       writel(0x62DD62DD, addr + 0xE4);
21440 +       writel(0x43924392, addr + 0xE8);
21441 +       writel(0x40094009, addr + 0xEC);
21442 +
21443 +       if (pdev_is_sata(dev)) {
21444 +               writel(0xFFFF0000, addr + 0x108);
21445 +               writel(0xFFFF0000, addr + 0x188);
21446 +               writel(0x00680000, addr + 0x148);
21447 +               writel(0x00680000, addr + 0x1C8);
21448         }
21449  
21450 -       tmpbyte = readb(DEVADDR(0x4A));
21451 +       tmpbyte = readb(addr + 0x4A);
21452  
21453 -       proc_reports_siimage(dev, (tmpbyte>>=4), name);
21454 +       proc_reports_siimage(dev, (tmpbyte>>4), name);
21455         return 1;
21456  }
21457  
21458 +/**
21459 + *     init_chipset_siimage    -       set up an SI device
21460 + *     @dev: PCI device
21461 + *     @name: device name
21462 + *
21463 + *     Perform the initial PCI set up for this device. Attempt to switch
21464 + *     to 133MHz clocking if the system isn't already set up to do it.
21465 + */
21466 +
21467  static unsigned int __init init_chipset_siimage (struct pci_dev *dev, const char *name)
21468  {
21469         u32 class_rev   = 0;
21470 @@ -607,139 +910,150 @@
21471         pci_write_config_byte(dev, 0x80, 0x00);
21472         pci_write_config_byte(dev, 0x84, 0x00);
21473         pci_read_config_byte(dev, 0x8A, &tmpbyte);
21474 -       switch(tmpbyte) {
21475 +       switch(tmpbyte & 0x30) {
21476                 case 0x00:
21477 -               case 0x01:
21478                         /* 133 clock attempt to force it on */
21479                         pci_write_config_byte(dev, 0x8A, tmpbyte|0x10);
21480 -                       pci_read_config_byte(dev, 0x8A, &tmpbyte);
21481                 case 0x30:
21482 -               case 0x31:
21483                         /* if clocking is disabled */
21484                         /* 133 clock attempt to force it on */
21485                         pci_write_config_byte(dev, 0x8A, tmpbyte & ~0x20);
21486 -                       pci_read_config_byte(dev, 0x8A, &tmpbyte);
21487                 case 0x10:
21488 -               case 0x11:
21489 -               case 0x20:
21490 -               case 0x21:
21491 +                       /* 133 already */
21492                         break;
21493 -               default:
21494 -                       tmpbyte &= ~0x30;
21495 -                       tmpbyte |= 0x20;
21496 -                       pci_write_config_byte(dev, 0x8A, tmpbyte);
21497 +               case 0x20:
21498 +                       /* BIOS set PCI x2 clocking */
21499                         break;
21500         }
21501  
21502 -       pci_read_config_byte(dev, 0x8A, &tmpbyte);
21503 -       pci_write_config_byte(dev, 0xA1, 0x72);
21504 -       pci_write_config_word(dev, 0xA2, 0x328A);
21505 +       pci_read_config_byte(dev,   0x8A, &tmpbyte);
21506 +
21507 +       pci_write_config_byte(dev,  0xA1, 0x72);
21508 +       pci_write_config_word(dev,  0xA2, 0x328A);
21509         pci_write_config_dword(dev, 0xA4, 0x62DD62DD);
21510         pci_write_config_dword(dev, 0xA8, 0x43924392);
21511         pci_write_config_dword(dev, 0xAC, 0x40094009);
21512 -       pci_write_config_byte(dev, 0xB1, 0x72);
21513 -       pci_write_config_word(dev, 0xB2, 0x328A);
21514 +       pci_write_config_byte(dev,  0xB1, 0x72);
21515 +       pci_write_config_word(dev,  0xB2, 0x328A);
21516         pci_write_config_dword(dev, 0xB4, 0x62DD62DD);
21517         pci_write_config_dword(dev, 0xB8, 0x43924392);
21518         pci_write_config_dword(dev, 0xBC, 0x40094009);
21519  
21520 -       pci_read_config_byte(dev, 0x8A, &tmpbyte);
21521 -       proc_reports_siimage(dev, (tmpbyte>>=4), name);
21522 +       proc_reports_siimage(dev, (tmpbyte>>4), name);
21523         return 0;
21524  }
21525  
21526 +/**
21527 + *     init_mmio_iops_siimage  -       set up the iops for MMIO
21528 + *     @hwif: interface to set up
21529 + *
21530 + *     The basic setup here is fairly simple, we can use standard MMIO
21531 + *     operations. However we do have to set the taskfile register offsets
21532 + *     by hand as there isnt a standard defined layout for them this
21533 + *     time.
21534 + *
21535 + *     The hardware supports buffered taskfiles and also some rather nice
21536 + *     extended PRD tables. Unfortunately right now we don't.
21537 + */
21538
21539  static void __init init_mmio_iops_siimage (ide_hwif_t *hwif)
21540  {
21541         struct pci_dev *dev     = hwif->pci_dev;
21542 -       unsigned long addr      = (unsigned long) pci_get_drvdata(hwif->pci_dev);
21543 +       void *addr              = pci_get_drvdata(dev);
21544         u8 ch                   = hwif->channel;
21545 -//     u16 i                   = 0;
21546 -       hw_regs_t hw;
21547 +       hw_regs_t               hw;
21548 +       unsigned long           base;
21549 +
21550 +       /*
21551 +        *      Fill in the basic HWIF bits
21552 +        */
21553  
21554         default_hwif_mmiops(hwif);
21555 +       hwif->hwif_data                 = addr;
21556 +
21557 +       /*
21558 +        *      Now set up the hw. We have to do this ourselves as
21559 +        *      the MMIO layout isnt the same as the the standard port
21560 +        *      based I/O
21561 +        */
21562 +        
21563         memset(&hw, 0, sizeof(hw_regs_t));
21564 +       hw.priv                         = addr;
21565  
21566 -#if 1
21567 -#ifdef SIIMAGE_BUFFERED_TASKFILE
21568 -       hw.io_ports[IDE_DATA_OFFSET]    = DEVADDR((ch) ? 0xD0 : 0x90);
21569 -       hw.io_ports[IDE_ERROR_OFFSET]   = DEVADDR((ch) ? 0xD1 : 0x91);
21570 -       hw.io_ports[IDE_NSECTOR_OFFSET] = DEVADDR((ch) ? 0xD2 : 0x92);
21571 -       hw.io_ports[IDE_SECTOR_OFFSET]  = DEVADDR((ch) ? 0xD3 : 0x93);
21572 -       hw.io_ports[IDE_LCYL_OFFSET]    = DEVADDR((ch) ? 0xD4 : 0x94);
21573 -       hw.io_ports[IDE_HCYL_OFFSET]    = DEVADDR((ch) ? 0xD5 : 0x95);
21574 -       hw.io_ports[IDE_SELECT_OFFSET]  = DEVADDR((ch) ? 0xD6 : 0x96);
21575 -       hw.io_ports[IDE_STATUS_OFFSET]  = DEVADDR((ch) ? 0xD7 : 0x97);
21576 -       hw.io_ports[IDE_CONTROL_OFFSET] = DEVADDR((ch) ? 0xDA : 0x9A);
21577 -#else /* ! SIIMAGE_BUFFERED_TASKFILE */
21578 -       hw.io_ports[IDE_DATA_OFFSET]    = DEVADDR((ch) ? 0xC0 : 0x80);
21579 -       hw.io_ports[IDE_ERROR_OFFSET]   = DEVADDR((ch) ? 0xC1 : 0x81);
21580 -       hw.io_ports[IDE_NSECTOR_OFFSET] = DEVADDR((ch) ? 0xC2 : 0x82);
21581 -       hw.io_ports[IDE_SECTOR_OFFSET]  = DEVADDR((ch) ? 0xC3 : 0x83);
21582 -       hw.io_ports[IDE_LCYL_OFFSET]    = DEVADDR((ch) ? 0xC4 : 0x84);
21583 -       hw.io_ports[IDE_HCYL_OFFSET]    = DEVADDR((ch) ? 0xC5 : 0x85);
21584 -       hw.io_ports[IDE_SELECT_OFFSET]  = DEVADDR((ch) ? 0xC6 : 0x86);
21585 -       hw.io_ports[IDE_STATUS_OFFSET]  = DEVADDR((ch) ? 0xC7 : 0x87);
21586 -       hw.io_ports[IDE_CONTROL_OFFSET] = DEVADDR((ch) ? 0xCA : 0x8A);
21587 -#endif /* SIIMAGE_BUFFERED_TASKFILE */
21588 -#else
21589 -#ifdef SIIMAGE_BUFFERED_TASKFILE
21590 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
21591 -               hw.io_ports[i] = DEVADDR((ch) ? 0xD0 : 0x90)|(i);
21592 -       hw.io_ports[IDE_CONTROL_OFFSET] = DEVADDR((ch) ? 0xDA : 0x9A);
21593 -#else /* ! SIIMAGE_BUFFERED_TASKFILE */
21594 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
21595 -               hw.io_ports[i] = DEVADDR((ch) ? 0xC0 : 0x80)|(i);
21596 -       hw.io_ports[IDE_CONTROL_OFFSET] = DEVADDR((ch) ? 0xCA : 0x8A);
21597 -#endif /* SIIMAGE_BUFFERED_TASKFILE */
21598 -#endif
21599 +       base                            = (unsigned long)addr;
21600 +       if(ch)
21601 +               base += 0xC0;
21602 +       else
21603 +               base += 0x80;
21604  
21605 -#if 0
21606 -       printk(KERN_DEBUG "%s: ", hwif->name);
21607 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
21608 -               printk("0x%08x ", DEVADDR((ch) ? 0xC0 : 0x80)|(i));
21609 -       printk("0x%08x ", DEVADDR((ch) ? 0xCA : 0x8A)|(i));
21610 -#endif
21611 +       /*
21612 +        *      The buffered task file doesn't have status/control
21613 +        *      so we can't currently use it sanely since we want to
21614 +        *      use LBA48 mode.
21615 +        */     
21616 +//     base += 0x10;
21617 +//     hwif->no_lba48 = 1;
21618 +
21619 +       hw.io_ports[IDE_DATA_OFFSET]    = base;
21620 +       hw.io_ports[IDE_ERROR_OFFSET]   = base + 1;
21621 +       hw.io_ports[IDE_NSECTOR_OFFSET] = base + 2;
21622 +       hw.io_ports[IDE_SECTOR_OFFSET]  = base + 3;
21623 +       hw.io_ports[IDE_LCYL_OFFSET]    = base + 4;
21624 +       hw.io_ports[IDE_HCYL_OFFSET]    = base + 5;
21625 +       hw.io_ports[IDE_SELECT_OFFSET]  = base + 6;
21626 +       hw.io_ports[IDE_STATUS_OFFSET]  = base + 7;
21627 +       hw.io_ports[IDE_CONTROL_OFFSET] = base + 10;
21628  
21629         hw.io_ports[IDE_IRQ_OFFSET]     = 0;
21630  
21631 -        if (dev->device == PCI_DEVICE_ID_SII_3112) {
21632 -               hw.sata_scr[SATA_STATUS_OFFSET] = DEVADDR((ch) ? 0x184 : 0x104);
21633 -               hw.sata_scr[SATA_ERROR_OFFSET]  = DEVADDR((ch) ? 0x188 : 0x108);
21634 -               hw.sata_scr[SATA_CONTROL_OFFSET]= DEVADDR((ch) ? 0x180 : 0x100);
21635 -               hw.sata_misc[SATA_MISC_OFFSET]  = DEVADDR((ch) ? 0x1C0 : 0x140);
21636 -               hw.sata_misc[SATA_PHY_OFFSET]   = DEVADDR((ch) ? 0x1C4 : 0x144);
21637 -               hw.sata_misc[SATA_IEN_OFFSET]   = DEVADDR((ch) ? 0x1C8 : 0x148);
21638 +        if (pdev_is_sata(dev)) {
21639 +               base = (unsigned long) addr;
21640 +               if(ch)
21641 +                       base += 0x80;
21642 +               hw.sata_scr[SATA_STATUS_OFFSET] = base + 0x104;
21643 +               hw.sata_scr[SATA_ERROR_OFFSET]  = base + 0x108;
21644 +               hw.sata_scr[SATA_CONTROL_OFFSET]= base + 0x100;
21645 +               hw.sata_misc[SATA_MISC_OFFSET]  = base + 0x140;
21646 +               hw.sata_misc[SATA_PHY_OFFSET]   = base + 0x144;
21647 +               hw.sata_misc[SATA_IEN_OFFSET]   = base + 0x148;
21648         }
21649  
21650 -       hw.priv                         = (void *) addr;
21651 -//     hw.priv                         = pci_get_drvdata(hwif->pci_dev);
21652         hw.irq                          = hwif->pci_dev->irq;
21653  
21654         memcpy(&hwif->hw, &hw, sizeof(hw));
21655         memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
21656  
21657 -       if (hwif->pci_dev->device == PCI_DEVICE_ID_SII_3112) {
21658 +       if (is_sata(hwif)) {
21659                 memcpy(hwif->sata_scr, hwif->hw.sata_scr, sizeof(hwif->hw.sata_scr));
21660                 memcpy(hwif->sata_misc, hwif->hw.sata_misc, sizeof(hwif->hw.sata_misc));
21661         }
21662  
21663 -#ifdef SIIMAGE_BUFFERED_TASKFILE
21664 -       hwif->no_lba48 = 1;
21665 -#endif /* SIIMAGE_BUFFERED_TASKFILE */
21666         hwif->irq                       = hw.irq;
21667 -       hwif->hwif_data                 = pci_get_drvdata(hwif->pci_dev);
21668 +
21669 +               base = (unsigned long) addr;
21670  
21671  #ifdef SIIMAGE_LARGE_DMA
21672 -       hwif->dma_base                  = DEVADDR((ch) ? 0x18 : 0x10);
21673 -       hwif->dma_base2                 = DEVADDR((ch) ? 0x08 : 0x00);
21674 -       hwif->dma_prdtable              = (hwif->dma_base2 + 4);
21675 +/* Watch the brackets - even Ken and Dennis get some language design wrong */
21676 +       hwif->dma_base                  = base + (ch ? 0x18 : 0x10);
21677 +       hwif->dma_base2                 = base + (ch ? 0x08 : 0x00);
21678 +       hwif->dma_prdtable              = hwif->dma_base2 + 4;
21679  #else /* ! SIIMAGE_LARGE_DMA */
21680 -       hwif->dma_base                  = DEVADDR((ch) ? 0x08 : 0x00);
21681 -       hwif->dma_base2                 = DEVADDR((ch) ? 0x18 : 0x10);
21682 +       hwif->dma_base                  = base + (ch ? 0x08 : 0x00);
21683 +       hwif->dma_base2                 = base + (ch ? 0x18 : 0x10);
21684  #endif /* SIIMAGE_LARGE_DMA */
21685 -       hwif->mmio                      = 1;
21686 +       hwif->mmio                      = 2;
21687  }
21688  
21689 +/**
21690 + *     init_iops_siimage       -       set up iops
21691 + *     @hwif: interface to set up
21692 + *
21693 + *     Do the basic setup for the SIIMAGE hardware interface
21694 + *     and then do the MMIO setup if we can. This is the first
21695 + *     look in we get for setting up the hwif so that we
21696 + *     can get the iops right before using them.
21697 + */
21698
21699  static void __init init_iops_siimage (ide_hwif_t *hwif)
21700  {
21701         struct pci_dev *dev     = hwif->pci_dev;
21702 @@ -747,37 +1061,60 @@
21703  
21704         pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
21705         class_rev &= 0xff;
21706 +       
21707 +       hwif->hwif_data = 0;
21708  
21709         hwif->rqsize = 128;
21710 -       if ((dev->device == PCI_DEVICE_ID_SII_3112) && (!(class_rev)))
21711 -               hwif->rqsize = 16;
21712 +       if (is_sata(hwif))
21713 +               hwif->rqsize = 15;
21714  
21715         if (pci_get_drvdata(dev) == NULL)
21716                 return;
21717         init_mmio_iops_siimage(hwif);
21718  }
21719  
21720 +/**
21721 + *     ata66_siimage   -       check for 80 pin cable
21722 + *     @hwif: interface to check
21723 + *
21724 + *     Check for the presence of an ATA66 capable cable on the
21725 + *     interface.
21726 + */
21727
21728  static unsigned int __init ata66_siimage (ide_hwif_t *hwif)
21729  {
21730 +       unsigned long addr = siimage_selreg(hwif, 0);
21731         if (pci_get_drvdata(hwif->pci_dev) == NULL) {
21732                 u8 ata66 = 0;
21733 -               pci_read_config_byte(hwif->pci_dev, SELREG(0), &ata66);
21734 +               pci_read_config_byte(hwif->pci_dev, addr, &ata66);
21735                 return (ata66 & 0x01) ? 1 : 0;
21736         }
21737  
21738 -       return (hwif->INB(SELADDR(0)) & 0x01) ? 1 : 0;
21739 +       return (hwif->INB(addr) & 0x01) ? 1 : 0;
21740  }
21741  
21742 +/**
21743 + *     init_hwif_siimage       -       set up hwif structs
21744 + *     @hwif: interface to set up
21745 + *
21746 + *     We do the basic set up of the interface structure. The SIIMAGE
21747 + *     requires several custom handlers so we override the default
21748 + *     ide DMA handlers appropriately
21749 + */
21750
21751  static void __init init_hwif_siimage (ide_hwif_t *hwif)
21752  {
21753         hwif->autodma = 0;
21754 -       hwif->busproc   = &siimage_busproc;
21755 +       
21756         hwif->resetproc = &siimage_reset;
21757         hwif->speedproc = &siimage_tune_chipset;
21758         hwif->tuneproc  = &siimage_tuneproc;
21759         hwif->reset_poll = &siimage_reset_poll;
21760         hwif->pre_reset = &siimage_pre_reset;
21761  
21762 +       if(is_sata(hwif))
21763 +               hwif->busproc   = &siimage_busproc;
21764 +
21765         if (!hwif->dma_base) {
21766                 hwif->drives[0].autotune = 1;
21767                 hwif->drives[1].autotune = 1;
21768 @@ -788,7 +1125,7 @@
21769         hwif->mwdma_mask = 0x07;
21770         hwif->swdma_mask = 0x07;
21771  
21772 -       if (hwif->pci_dev->device != PCI_DEVICE_ID_SII_3112)
21773 +       if (!is_sata(hwif))
21774                 hwif->atapi_dma = 1;
21775  
21776         hwif->ide_dma_check = &siimage_config_drive_for_dma;
21777 @@ -802,12 +1139,26 @@
21778         } else {
21779                 hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq;
21780         }
21781 -       if (!noautodma)
21782 -               hwif->autodma = 1;
21783 +       
21784 +       /*
21785 +        *      The BIOS often doesn't set up DMA on this controller
21786 +        *      so we always do it.
21787 +        */
21788 +
21789 +       hwif->autodma = 1;
21790         hwif->drives[0].autodma = hwif->autodma;
21791         hwif->drives[1].autodma = hwif->autodma;
21792  }
21793  
21794 +/**
21795 + *     init_dma_siimage        -       set up IDE DMA
21796 + *     @hwif: interface
21797 + *     @dmabase: DMA base address to use
21798 + *     
21799 + *     For the SI chips this requires no special set up so we can just
21800 + *     let the IDE DMA core do the usual work.
21801 + */
21802
21803  static void __init init_dma_siimage (ide_hwif_t *hwif, unsigned long dmabase)
21804  {
21805         ide_setup_dma(hwif, dmabase, 8);
21806 @@ -816,6 +1167,15 @@
21807  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
21808  
21809  
21810 +/**
21811 + *     siimage_init_one        -       pci layer discovery entry
21812 + *     @dev: PCI device
21813 + *     @id: ident table entry
21814 + *
21815 + *     Called by the PCI code when it finds an SI680 or SI3112 controller.
21816 + *     We then use the IDE PCI generic helper to do most of the work.
21817 + */
21818
21819  static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id)
21820  {
21821         ide_pci_device_t *d = &siimage_chipsets[id->driver_data];
21822 @@ -829,6 +1189,7 @@
21823  static struct pci_device_id siimage_pci_tbl[] = {
21824         { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_680,  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
21825         { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
21826 +       { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_1210SA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
21827         { 0, },
21828  };
21829  
21830 @@ -851,6 +1212,6 @@
21831  module_init(siimage_ide_init);
21832  module_exit(siimage_ide_exit);
21833  
21834 -MODULE_AUTHOR("Andre Hedrick");
21835 +MODULE_AUTHOR("Andre Hedrick, Alan Cox");
21836  MODULE_DESCRIPTION("PCI driver module for SiI IDE");
21837  MODULE_LICENSE("GPL");
21838 diff -Nru a/drivers/ide/pci/siimage.h b/drivers/ide/pci/siimage.h
21839 --- a/drivers/ide/pci/siimage.h Mon Feb 17 11:01:34 2003
21840 +++ b/drivers/ide/pci/siimage.h Mon Sep  1 15:53:57 2003
21841 @@ -13,12 +13,6 @@
21842  #undef SIIMAGE_BUFFERED_TASKFILE
21843  #undef SIIMAGE_LARGE_DMA
21844  
21845 -#if 0
21846 -typedef struct ide_io_ops_s siimage_iops {
21847 -
21848 -}
21849 -#endif
21850 -
21851  #define SII_DEBUG 0
21852  
21853  #if SII_DEBUG
21854 @@ -27,12 +21,6 @@
21855  #define siiprintk(x...)
21856  #endif
21857  
21858 -#define ADJREG(B,R)    ((B)|(R)|((hwif->channel)<<(4+(2*(hwif->mmio)))))
21859 -#define SELREG(R)      ADJREG((0xA0),(R))
21860 -#define SELADDR(R)     ((((unsigned long)hwif->hwif_data)*(hwif->mmio))|SELREG((R)))
21861 -#define HWIFADDR(R)    ((((unsigned long)hwif->hwif_data)*(hwif->mmio))|(R))
21862 -#define DEVADDR(R)     (((unsigned long) pci_get_drvdata(dev))|(R))
21863 -
21864  
21865  #if defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS)
21866  #include <linux/stat.h>
21867 @@ -76,6 +64,19 @@
21868                 .vendor         = PCI_VENDOR_ID_CMD,
21869                 .device         = PCI_DEVICE_ID_SII_3112,
21870                 .name           = "SiI3112 Serial ATA",
21871 +               .init_chipset   = init_chipset_siimage,
21872 +               .init_iops      = init_iops_siimage,
21873 +               .init_hwif      = init_hwif_siimage,
21874 +               .init_dma       = init_dma_siimage,
21875 +               .channels       = 2,
21876 +               .autodma        = AUTODMA,
21877 +               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
21878 +               .bootable       = ON_BOARD,
21879 +               .extra          = 0,
21880 +       },{     /* 2 */
21881 +               .vendor         = PCI_VENDOR_ID_CMD,
21882 +               .device         = PCI_DEVICE_ID_SII_1210SA,
21883 +               .name           = "Adaptec AAR-1210SA",
21884                 .init_chipset   = init_chipset_siimage,
21885                 .init_iops      = init_iops_siimage,
21886                 .init_hwif      = init_hwif_siimage,
21887 diff -Nru a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
21888 --- a/drivers/ide/pci/sis5513.c Thu Jul 31 08:58:49 2003
21889 +++ b/drivers/ide/pci/sis5513.c Sun Aug 24 15:33:30 2003
21890 @@ -63,7 +63,6 @@
21891  #include <asm/irq.h>
21892  
21893  #include "ide-timing.h"
21894 -#include "ide_modes.h"
21895  #include "sis5513.h"
21896  
21897  /* registers layout and init values are chipset family dependant */
21898 diff -Nru a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
21899 --- a/drivers/ide/pci/sl82c105.c        Thu Jul 31 08:58:49 2003
21900 +++ b/drivers/ide/pci/sl82c105.c        Sun Aug 24 15:33:30 2003
21901 @@ -29,7 +29,6 @@
21902  #include <asm/io.h>
21903  #include <asm/dma.h>
21904  
21905 -#include "ide_modes.h"
21906  #include "sl82c105.h"
21907  
21908  #undef DEBUG
21909 diff -Nru a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
21910 --- a/drivers/ide/pci/slc90e66.c        Thu Jul 31 08:58:49 2003
21911 +++ b/drivers/ide/pci/slc90e66.c        Sun Aug 24 15:33:30 2003
21912 @@ -21,7 +21,6 @@
21913  
21914  #include <asm/io.h>
21915  
21916 -#include "ide_modes.h"
21917  #include "slc90e66.h"
21918  
21919  #if defined(DISPLAY_SLC90E66_TIMINGS) && defined(CONFIG_PROC_FS)
21920 diff -Nru a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
21921 --- a/drivers/ide/pci/triflex.c Sat Feb 22 15:52:14 2003
21922 +++ b/drivers/ide/pci/triflex.c Sun Aug 24 15:33:30 2003
21923 @@ -41,7 +41,6 @@
21924  #include <linux/ide.h>
21925  #include <linux/init.h>
21926  
21927 -#include "ide_modes.h"
21928  #include "triflex.h"
21929  
21930  static struct pci_dev *triflex_dev;
21931 diff -Nru a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c
21932 --- a/drivers/ide/ppc/mpc8xx.c  Fri May  2 10:53:08 2003
21933 +++ b/drivers/ide/ppc/mpc8xx.c  Sun Aug 24 15:33:30 2003
21934 @@ -42,7 +42,6 @@
21935  #include <asm/machdep.h>
21936  #include <asm/irq.h>
21937  
21938 -#include "ide_modes.h"
21939  static int identify  (volatile u8 *p);
21940  static void print_fixed (volatile u8 *p);
21941  static void print_funcid (int func);
21942 diff -Nru a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
21943 --- a/drivers/ide/ppc/pmac.c    Sat Aug 16 11:46:50 2003
21944 +++ b/drivers/ide/ppc/pmac.c    Sun Aug 31 14:09:16 2003
21945 @@ -5,7 +5,7 @@
21946   * These IDE interfaces are memory-mapped and have a DBDMA channel
21947   * for doing DMA.
21948   *
21949 - *  Copyright (C) 1998-2001 Paul Mackerras & Ben. Herrenschmidt
21950 + *  Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt
21951   *
21952   *  This program is free software; you can redistribute it and/or
21953   *  modify it under the terms of the GNU General Public License
21954 @@ -16,6 +16,11 @@
21955   *
21956   *  Copyright (c) 1995-1998  Mark Lord
21957   *
21958 + * TODO: - Use pre-calculated (kauai) timing tables all the time and
21959 + * get rid of the "rounded" tables used previously, so we have the
21960 + * same table format for all controllers and can then just have one
21961 + * big table
21962 + * 
21963   */
21964  #include <linux/config.h>
21965  #include <linux/types.h>
21966 @@ -27,6 +32,8 @@
21967  #include <linux/notifier.h>
21968  #include <linux/reboot.h>
21969  #include <linux/pci.h>
21970 +#include <linux/adb.h>
21971 +#include <linux/pmu.h>
21972  
21973  #include <asm/prom.h>
21974  #include <asm/io.h>
21975 @@ -38,26 +45,27 @@
21976  #include <asm/pmac_feature.h>
21977  #include <asm/sections.h>
21978  #include <asm/irq.h>
21979 -#ifdef CONFIG_PMAC_PBOOK
21980 -#include <linux/adb.h>
21981 -#include <linux/pmu.h>
21982 -#endif
21983 -#include "ide_modes.h"
21984 +
21985 +#include "ide-timing.h"
21986  
21987  extern void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq);
21988  
21989  #define IDE_PMAC_DEBUG
21990  
21991 -#define DMA_WAIT_TIMEOUT       500
21992 +#define DMA_WAIT_TIMEOUT       100
21993  
21994  typedef struct pmac_ide_hwif {
21995         unsigned long                   regbase;
21996         int                             irq;
21997         int                             kind;
21998         int                             aapl_bus_id;
21999 +       int                             cable_80 : 1;
22000 +       int                             mediabay : 1;
22001 +       int                             broken_dma : 1;
22002 +       int                             broken_dma_warn : 1;
22003         struct device_node*             node;
22004 -       u32                             timings[2];
22005 -       int                             index;
22006 +       struct macio_dev                *mdev;
22007 +       u32                             timings[4];
22008  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
22009         /* Those fields are duplicating what is in hwif. We currently
22010          * can't use the hwif ones because of some assumptions that are
22011 @@ -82,7 +90,15 @@
22012         controller_heathrow,    /* Heathrow/Paddington */
22013         controller_kl_ata3,     /* KeyLargo ATA-3 */
22014         controller_kl_ata4,     /* KeyLargo ATA-4 */
22015 -       controller_kl_ata4_80   /* KeyLargo ATA-4 with 80 conductor cable */
22016 +       controller_un_ata6      /* UniNorth2 ATA-6 */
22017 +};
22018 +
22019 +static const char* model_name[] = {
22020 +       "OHare ATA",            /* OHare based */
22021 +       "Heathrow ATA",         /* Heathrow/Paddington */
22022 +       "KeyLargo ATA-3",       /* KeyLargo ATA-3 */
22023 +       "KeyLargo ATA-4",       /* KeyLargo ATA-4 */
22024 +       "UniNorth ATA-6"        /* UniNorth2 ATA-6 */
22025  };
22026  
22027  /*
22028 @@ -91,6 +107,11 @@
22029  #define IDE_TIMING_CONFIG      0x200
22030  #define IDE_INTERRUPT          0x300
22031  
22032 +/* Kauai (U2) ATA has different register setup */
22033 +#define IDE_KAUAI_PIO_CONFIG   0x200
22034 +#define IDE_KAUAI_ULTRA_CONFIG 0x210
22035 +#define IDE_KAUAI_POLL_CONFIG  0x220
22036 +
22037  /*
22038   * Timing configuration register definitions
22039   */
22040 @@ -101,6 +122,28 @@
22041  #define IDE_SYSCLK_NS          30      /* 33Mhz cell */
22042  #define IDE_SYSCLK_66_NS       15      /* 66Mhz cell */
22043  
22044 +/* 100Mhz cell, found in Uninorth 2. I don't have much infos about
22045 + * this one yet, it appears as a pci device (106b/0033) on uninorth
22046 + * internal PCI bus and it's clock is controlled like gem or fw. It
22047 + * appears to be an evolution of keylargo ATA4 with a timing register
22048 + * extended to 2 32bits registers and a similar DBDMA channel. Other
22049 + * registers seem to exist but I can't tell much about them.
22050 + * 
22051 + * So far, I'm using pre-calculated tables for this extracted from
22052 + * the values used by the MacOS X driver.
22053 + * 
22054 + * The "PIO" register controls PIO and MDMA timings, the "ULTRA"
22055 + * register controls the UDMA timings. At least, it seems bit 0
22056 + * of this one enables UDMA vs. MDMA, and bits 4..7 are the
22057 + * cycle time in units of 10ns. Bits 8..15 are used by I don't
22058 + * know their meaning yet
22059 + */
22060 +#define TR_100_PIOREG_PIO_MASK         0xff000fff
22061 +#define TR_100_PIOREG_MDMA_MASK                0x00fff000
22062 +#define TR_100_UDMAREG_UDMA_MASK       0x0000ffff
22063 +#define TR_100_UDMAREG_UDMA_EN         0x00000001
22064 +
22065 +
22066  /* 66Mhz cell, found in KeyLargo. Can do ultra mode 0 to 2 on
22067   * 40 connector cable and to 4 on 80 connector one.
22068   * Clock unit is 15ns (66Mhz)
22069 @@ -115,8 +158,7 @@
22070   *    well, despite a comment that would lead to think it has a
22071   *    min value of 45ns.
22072   * Apple also add 60ns to the write data setup (or cycle time ?) on
22073 - * reads. I can't explain that, I tried it and it broke everything
22074 - * here.
22075 + * reads.
22076   */
22077  #define TR_66_UDMA_MASK                        0xfff00000
22078  #define TR_66_UDMA_EN                  0x00100000 /* Enable Ultra mode for DMA */
22079 @@ -220,12 +262,12 @@
22080      {   0,   0,   0 }
22081  };
22082  
22083 -/* Ultra DMA timings (rounded) */
22084 +/* KeyLargo ATA-4 Ultra DMA timings (rounded) */
22085  struct {
22086         int     addrSetup; /* ??? */
22087         int     rdy2pause;
22088         int     wrDataSetup;
22089 -} udma_timings[] __pmacdata =
22090 +} kl66_udma_timings[] __pmacdata =
22091  {
22092      {   0, 180,  120 },        /* Mode 0 */
22093      {   0, 150,  90 }, /*      1 */
22094 @@ -234,6 +276,63 @@
22095      {   0, 90,   30 }  /*      4 */
22096  };
22097  
22098 +/* UniNorth 2 ATA/100 timings */
22099 +struct kauai_timing {
22100 +       int     cycle_time;
22101 +       u32     timing_reg;
22102 +};
22103 +
22104 +static struct kauai_timing     kauai_pio_timings[] __pmacdata =
22105 +{
22106 +       { 930   , 0x08000fff },
22107 +       { 600   , 0x08000a92 },
22108 +       { 383   , 0x0800060f },
22109 +       { 360   , 0x08000492 },
22110 +       { 330   , 0x0800048f },
22111 +       { 300   , 0x080003cf },
22112 +       { 270   , 0x080003cc },
22113 +       { 240   , 0x0800038b },
22114 +       { 239   , 0x0800030c },
22115 +       { 180   , 0x05000249 },
22116 +       { 120   , 0x04000148 }
22117 +};
22118 +
22119 +static struct kauai_timing     kauai_mdma_timings[] __pmacdata =
22120 +{
22121 +       { 1260  , 0x00fff000 },
22122 +       { 480   , 0x00618000 },
22123 +       { 360   , 0x00492000 },
22124 +       { 270   , 0x0038e000 },
22125 +       { 240   , 0x0030c000 },
22126 +       { 210   , 0x002cb000 },
22127 +       { 180   , 0x00249000 },
22128 +       { 150   , 0x00209000 },
22129 +       { 120   , 0x00148000 },
22130 +       { 0     , 0 },
22131 +};
22132 +
22133 +static struct kauai_timing     kauai_udma_timings[] __pmacdata =
22134 +{
22135 +       { 120   , 0x000070c0 },
22136 +       { 90    , 0x00005d80 },
22137 +       { 60    , 0x00004a60 },
22138 +       { 45    , 0x00003a50 },
22139 +       { 30    , 0x00002a30 },
22140 +       { 20    , 0x00002921 },
22141 +       { 0     , 0 },
22142 +};
22143 +
22144 +static inline u32
22145 +kauai_lookup_timing(struct kauai_timing* table, int cycle_time)
22146 +{
22147 +       int i;
22148 +       
22149 +       for (i=0; table[i].cycle_time; i++)
22150 +               if (cycle_time > table[i+1].cycle_time)
22151 +                       return table[i].timing_reg;
22152 +       return 0;
22153 +}
22154 +
22155  /* allow up to 256 DBDMA commands per xfer */
22156  #define MAX_DCMDS              256
22157  
22158 @@ -242,24 +341,106 @@
22159   * NOTE: There is at least one case I know of a disk that needs about 10sec
22160   *       before anwering on the bus. I beleive we could add a kernel command
22161   *       line arg to override this delay for such cases.
22162 + *       
22163 + * NOTE2: This has to be fixed with a BSY wait loop. I'm working on adding
22164 + *        that to the generic probe code.
22165   */
22166  #define IDE_WAKEUP_DELAY_MS    2000
22167  
22168 -static void pmac_ide_setup_dma(struct device_node *np, int ix);
22169 -static int pmac_ide_build_dmatable(ide_drive_t *drive, int wr);
22170 +static void pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif);
22171 +static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq);
22172  static int pmac_ide_tune_chipset(ide_drive_t *drive, u8 speed);
22173  static void pmac_ide_tuneproc(ide_drive_t *drive, u8 pio);
22174  static void pmac_ide_selectproc(ide_drive_t *drive);
22175 +static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
22176  static int pmac_ide_dma_begin (ide_drive_t *drive);
22177  
22178  #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
22179  
22180 -#ifdef CONFIG_PMAC_PBOOK
22181 -static int idepmac_notify_sleep(struct pmu_sleep_notifier *self, int when);
22182 -struct pmu_sleep_notifier idepmac_sleep_notifier = {
22183 -       idepmac_notify_sleep, SLEEP_LEVEL_BLOCK,
22184 -};
22185 -#endif /* CONFIG_PMAC_PBOOK */
22186 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
22187 +
22188 +/* Set to 50ms */
22189 +#define PMU_HD_BLINK_TIME      (HZ/50)
22190 +
22191 +static struct adb_request pmu_blink_on, pmu_blink_off;
22192 +static spinlock_t pmu_blink_lock;
22193 +static unsigned long pmu_blink_stoptime;
22194 +static int pmu_blink_ledstate;
22195 +static struct timer_list pmu_blink_timer;
22196 +static int pmu_ide_blink_enabled;
22197 +
22198 +
22199 +static void
22200 +pmu_hd_blink_timeout(unsigned long data)
22201 +{
22202 +       unsigned long flags;
22203 +       
22204 +       spin_lock_irqsave(&pmu_blink_lock, flags);
22205 +
22206 +       /* We may have been triggered again in a racy way, check
22207 +        * that we really want to switch it off
22208 +        */
22209 +       if (time_after(pmu_blink_stoptime, jiffies))
22210 +               goto done;
22211 +
22212 +       /* Previous req. not complete, try 100ms more */
22213 +       if (pmu_blink_off.complete == 0)
22214 +               mod_timer(&pmu_blink_timer, jiffies + PMU_HD_BLINK_TIME);
22215 +       else if (pmu_blink_ledstate) {
22216 +               pmu_request(&pmu_blink_off, NULL, 4, 0xee, 4, 0, 0);
22217 +               pmu_blink_ledstate = 0;
22218 +       }
22219 +done:
22220 +       spin_unlock_irqrestore(&pmu_blink_lock, flags);
22221 +}
22222 +
22223 +static void
22224 +pmu_hd_kick_blink(void *data, int rw)
22225 +{
22226 +       unsigned long flags;
22227 +       
22228 +       pmu_blink_stoptime = jiffies + PMU_HD_BLINK_TIME;
22229 +       wmb();
22230 +       mod_timer(&pmu_blink_timer, pmu_blink_stoptime);
22231 +       if (pmu_blink_ledstate == 1)
22232 +               return;
22233 +       spin_lock_irqsave(&pmu_blink_lock, flags);
22234 +       if (pmu_blink_on.complete && !pmu_blink_ledstate) {
22235 +               pmu_request(&pmu_blink_on, NULL, 4, 0xee, 4, 0, 1);
22236 +               pmu_blink_ledstate = 1;
22237 +       }
22238 +       spin_unlock_irqrestore(&pmu_blink_lock, flags);
22239 +}
22240 +
22241 +static int
22242 +pmu_hd_blink_init(void)
22243 +{
22244 +       struct device_node *dt;
22245 +       const char *model;
22246 +
22247 +       if (pmu_get_model() != PMU_KEYLARGO_BASED)
22248 +               return 0;
22249 +       
22250 +       dt = find_devices("device-tree");
22251 +       if (dt == NULL)
22252 +               return 0;
22253 +       model = (const char *)get_property(dt, "model", NULL);
22254 +       if (model == NULL)
22255 +               return 0;
22256 +       if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
22257 +           strncmp(model, "iBook", strlen("iBook")) != 0)
22258 +               return 0;
22259 +       
22260 +       pmu_blink_on.complete = 1;
22261 +       pmu_blink_off.complete = 1;
22262 +       spin_lock_init(&pmu_blink_lock);
22263 +       init_timer(&pmu_blink_timer);
22264 +       pmu_blink_timer.function = pmu_hd_blink_timeout;
22265 +
22266 +       return 1;
22267 +}
22268 +
22269 +#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
22270  
22271  /*
22272   * N.B. this can't be an initfunc, because the media-bay task can
22273 @@ -315,6 +496,41 @@
22274         (void)readl((unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
22275  }
22276  
22277 +static void __pmac
22278 +pmac_ide_kauai_selectproc(ide_drive_t *drive)
22279 +{
22280 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
22281 +
22282 +       if (pmif == NULL)
22283 +               return;
22284 +
22285 +       if (drive->select.b.unit & 0x01) {
22286 +               writel(pmif->timings[1],
22287 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
22288 +               writel(pmif->timings[3],
22289 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_ULTRA_CONFIG));
22290 +       } else {
22291 +               writel(pmif->timings[0],
22292 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
22293 +               writel(pmif->timings[2],
22294 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_ULTRA_CONFIG));
22295 +       }
22296 +       (void)readl((unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
22297 +}
22298 +
22299 +static void __pmac
22300 +pmac_ide_do_update_timings(ide_drive_t *drive)
22301 +{
22302 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
22303 +
22304 +       if (pmif == NULL)
22305 +               return;
22306 +
22307 +       if (pmif->kind == controller_un_ata6)
22308 +               pmac_ide_kauai_selectproc(drive);
22309 +       else
22310 +               pmac_ide_selectproc(drive);
22311 +}
22312  
22313  static int __pmac
22314  pmac_ide_do_setfeature(ide_drive_t *drive, u8 command)
22315 @@ -322,7 +538,7 @@
22316         ide_hwif_t *hwif = HWIF(drive);
22317         int result = 1;
22318         
22319 -       disable_irq(hwif->irq); /* disable_irq_nosync ?? */
22320 +       disable_irq_nosync(hwif->irq);
22321         udelay(1);
22322         SELECT_DRIVE(drive);
22323         SELECT_MASK(drive, 0);
22324 @@ -332,22 +548,22 @@
22325         /* Timeout bumped for some powerbooks */
22326         if (wait_for_ready(drive, 2000)) {
22327                 /* Timeout bumped for some powerbooks */
22328 -               printk(KERN_ERR "pmac_ide_do_setfeature disk not ready "
22329 -                       "before SET_FEATURE!\n");
22330 +               printk(KERN_ERR "%s: pmac_ide_do_setfeature disk not ready "
22331 +                       "before SET_FEATURE!\n", drive->name);
22332                 goto out;
22333         }
22334         udelay(10);
22335         hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG);
22336         hwif->OUTB(command, IDE_NSECTOR_REG);
22337         hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG);
22338 -       hwif->OUTB(WIN_SETFEATURES, IDE_COMMAND_REG);
22339 +       hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG);
22340         udelay(1);
22341         /* Timeout bumped for some powerbooks */
22342         result = wait_for_ready(drive, 2000);
22343         hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
22344         if (result)
22345 -               printk(KERN_ERR "pmac_ide_do_setfeature disk not ready "
22346 -                       "after SET_FEATURE !\n");
22347 +               printk(KERN_ERR "%s: pmac_ide_do_setfeature disk not ready "
22348 +                       "after SET_FEATURE !\n", drive->name);
22349  out:
22350         SELECT_MASK(drive, 0);
22351         if (result == 0) {
22352 @@ -403,21 +619,27 @@
22353         if (pmif == NULL)
22354                 return;
22355                 
22356 +       /* which drive is it ? */
22357 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
22358 +
22359         pio = ide_get_best_pio_mode(drive, pio, 4, &d);
22360 -       accessTicks = SYSCLK_TICKS(ide_pio_timings[pio].active_time);
22361 -       if (drive->select.b.unit & 0x01)
22362 -               timings = &pmif->timings[1];
22363 -       else
22364 -               timings = &pmif->timings[0];
22365  
22366 -       recTime = d.cycle_time - ide_pio_timings[pio].active_time
22367 -                       - ide_pio_timings[pio].setup_time;
22368 -       recTime = max(recTime, 150U);
22369 -       accessTime = ide_pio_timings[pio].active_time;
22370 -       accessTime = max(accessTime, 150U);
22371 -       if (pmif->kind == controller_kl_ata4 ||
22372 -               pmif->kind == controller_kl_ata4_80) {
22373 +       switch (pmif->kind) {
22374 +       case controller_un_ata6: {
22375 +               /* 100Mhz cell */
22376 +               u32 tr = kauai_lookup_timing(kauai_pio_timings, d.cycle_time);
22377 +               if (tr == 0)
22378 +                       return;
22379 +               *timings = ((*timings) & ~TR_100_PIOREG_PIO_MASK) | tr;
22380 +               break;
22381 +               }
22382 +       case controller_kl_ata4:
22383                 /* 66Mhz cell */
22384 +               recTime = d.cycle_time - ide_pio_timings[pio].active_time
22385 +                               - ide_pio_timings[pio].setup_time;
22386 +               recTime = max(recTime, 150U);
22387 +               accessTime = ide_pio_timings[pio].active_time;
22388 +               accessTime = max(accessTime, 150U);
22389                 accessTicks = SYSCLK_TICKS_66(accessTime);
22390                 accessTicks = min(accessTicks, 0x1fU);
22391                 recTicks = SYSCLK_TICKS_66(recTime);
22392 @@ -425,9 +647,15 @@
22393                 *timings = ((*timings) & ~TR_66_PIO_MASK) |
22394                                 (accessTicks << TR_66_PIO_ACCESS_SHIFT) |
22395                                 (recTicks << TR_66_PIO_RECOVERY_SHIFT);
22396 -       } else {
22397 +               break;
22398 +       default: {
22399                 /* 33Mhz cell */
22400                 int ebit = 0;
22401 +               recTime = d.cycle_time - ide_pio_timings[pio].active_time
22402 +                               - ide_pio_timings[pio].setup_time;
22403 +               recTime = max(recTime, 150U);
22404 +               accessTime = ide_pio_timings[pio].active_time;
22405 +               accessTime = max(accessTime, 150U);
22406                 accessTicks = SYSCLK_TICKS(accessTime);
22407                 accessTicks = min(accessTicks, 0x1fU);
22408                 accessTicks = max(accessTicks, 4U);
22409 @@ -443,26 +671,31 @@
22410                                 (recTicks << TR_33_PIO_RECOVERY_SHIFT);
22411                 if (ebit)
22412                         *timings |= TR_33_PIO_E;
22413 +               break;
22414 +               }
22415         }
22416  
22417  #ifdef IDE_PMAC_DEBUG
22418 -       printk(KERN_ERR "ide_pmac: Set PIO timing for mode %d, reg: 0x%08x\n",
22419 -               pio,  *timings);
22420 +       printk(KERN_ERR "%s: Set PIO timing for mode %d, reg: 0x%08x\n",
22421 +               drive->name, pio,  *timings);
22422  #endif 
22423  
22424         if (drive->select.all == HWIF(drive)->INB(IDE_SELECT_REG))
22425 -               pmac_ide_selectproc(drive);
22426 +               pmac_ide_do_update_timings(drive);
22427  }
22428  
22429  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
22430  static int __pmac
22431 -set_timings_udma(u32 *timings, u8 speed)
22432 +set_timings_udma_ata4(u32 *timings, u8 speed)
22433  {
22434         unsigned rdyToPauseTicks, wrDataSetupTicks, addrTicks;
22435  
22436 -       rdyToPauseTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].rdy2pause);
22437 -       wrDataSetupTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].wrDataSetup);
22438 -       addrTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].addrSetup);
22439 +       if (speed > XFER_UDMA_4)
22440 +               return 1;
22441 +
22442 +       rdyToPauseTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].rdy2pause);
22443 +       wrDataSetupTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].wrDataSetup);
22444 +       addrTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].addrSetup);
22445  
22446         *timings = ((*timings) & ~(TR_66_UDMA_MASK | TR_66_MDMA_MASK)) |
22447                         (wrDataSetupTicks << TR_66_UDMA_WRDATASETUP_SHIFT) | 
22448 @@ -478,11 +711,29 @@
22449  }
22450  
22451  static int __pmac
22452 -set_timings_mdma(int intf_type, u32 *timings, u8 speed, int drive_cycle_time)
22453 +set_timings_udma_ata6(u32 *pio_timings, u32 *ultra_timings, u8 speed)
22454 +{
22455 +       struct ide_timing *t = ide_timing_find_mode(speed);
22456 +       u32 tr;
22457 +
22458 +       if (speed > XFER_UDMA_5 || t == NULL)
22459 +               return 1;
22460 +       tr = kauai_lookup_timing(kauai_udma_timings, (int)t->udma);
22461 +       if (tr == 0)
22462 +               return 1;
22463 +       *ultra_timings = ((*ultra_timings) & ~TR_100_UDMAREG_UDMA_MASK) | tr;
22464 +       *ultra_timings = (*ultra_timings) | TR_100_UDMAREG_UDMA_EN;
22465 +
22466 +       return 0;
22467 +}
22468 +
22469 +static int __pmac
22470 +set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2,
22471 +                       u8 speed, int drive_cycle_time)
22472  {
22473         int cycleTime, accessTime, recTime;
22474         unsigned accessTicks, recTicks;
22475 -       struct mdma_timings_t* tm;
22476 +       struct mdma_timings_t* tm = NULL;
22477         int i;
22478  
22479         /* Get default cycle time for mode */
22480 @@ -491,7 +742,7 @@
22481                 case 1: cycleTime = 150; break;
22482                 case 2: cycleTime = 120; break;
22483                 default:
22484 -                       return -1;
22485 +                       return 1;
22486         }
22487         /* Adjust for drive */
22488         if (drive_cycle_time && drive_cycle_time > cycleTime)
22489 @@ -501,8 +752,9 @@
22490                 cycleTime = 150;
22491         /* Get the proper timing array for this controller */
22492         switch(intf_type) {
22493 +               case controller_un_ata6:
22494 +                       break;
22495                 case controller_kl_ata4:
22496 -               case controller_kl_ata4_80:
22497                         tm = mdma_timings_66;
22498                         break;
22499                 case controller_kl_ata3:
22500 @@ -512,24 +764,36 @@
22501                         tm = mdma_timings_33;
22502                         break;
22503         }
22504 -       /* Lookup matching access & recovery times */
22505 -       i = -1;
22506 -       for (;;) {
22507 -               if (tm[i+1].cycleTime < cycleTime)
22508 -                       break;
22509 -               i++;
22510 -       }
22511 -       if (i < 0)
22512 -               return -1;
22513 -       cycleTime = tm[i].cycleTime;
22514 -       accessTime = tm[i].accessTime;
22515 -       recTime = tm[i].recoveryTime;
22516 +       if (tm != NULL) {
22517 +               /* Lookup matching access & recovery times */
22518 +               i = -1;
22519 +               for (;;) {
22520 +                       if (tm[i+1].cycleTime < cycleTime)
22521 +                               break;
22522 +                       i++;
22523 +               }
22524 +               if (i < 0)
22525 +                       return 1;
22526 +               cycleTime = tm[i].cycleTime;
22527 +               accessTime = tm[i].accessTime;
22528 +               recTime = tm[i].recoveryTime;
22529  
22530  #ifdef IDE_PMAC_DEBUG
22531 -       printk(KERN_ERR "ide_pmac: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n",
22532 -               cycleTime, accessTime, recTime);
22533 -#endif 
22534 -       if (intf_type == controller_kl_ata4 || intf_type == controller_kl_ata4_80) {
22535 +               printk(KERN_ERR "%s: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n",
22536 +                       drive->name, cycleTime, accessTime, recTime);
22537 +#endif
22538 +       }
22539 +       switch(intf_type) {
22540 +       case controller_un_ata6: {
22541 +               /* 100Mhz cell */
22542 +               u32 tr = kauai_lookup_timing(kauai_mdma_timings, cycleTime);
22543 +               if (tr == 0)
22544 +                       return 1;
22545 +               *timings = ((*timings) & ~TR_100_PIOREG_MDMA_MASK) | tr;
22546 +               *timings2 = (*timings2) & ~TR_100_UDMAREG_UDMA_EN;
22547 +               }
22548 +               break;
22549 +       case controller_kl_ata4:
22550                 /* 66Mhz cell */
22551                 accessTicks = SYSCLK_TICKS_66(accessTime);
22552                 accessTicks = min(accessTicks, 0x1fU);
22553 @@ -541,7 +805,8 @@
22554                 *timings = ((*timings) & ~(TR_66_MDMA_MASK | TR_66_UDMA_MASK)) |
22555                         (accessTicks << TR_66_MDMA_ACCESS_SHIFT) |
22556                         (recTicks << TR_66_MDMA_RECOVERY_SHIFT);
22557 -       } else if (intf_type == controller_kl_ata3) {
22558 +               break;
22559 +       case controller_kl_ata3:
22560                 /* 33Mhz cell on KeyLargo */
22561                 accessTicks = SYSCLK_TICKS(accessTime);
22562                 accessTicks = max(accessTicks, 1U);
22563 @@ -553,7 +818,8 @@
22564                 *timings = ((*timings) & ~TR_33_MDMA_MASK) |
22565                                 (accessTicks << TR_33_MDMA_ACCESS_SHIFT) |
22566                                 (recTicks << TR_33_MDMA_RECOVERY_SHIFT);
22567 -       } else {
22568 +               break;
22569 +       default: {
22570                 /* 33Mhz cell on others */
22571                 int halfTick = 0;
22572                 int origAccessTime = accessTime;
22573 @@ -578,10 +844,11 @@
22574                                 (recTicks << TR_33_MDMA_RECOVERY_SHIFT);
22575                 if (halfTick)
22576                         *timings |= TR_33_MDMA_HALFTICK;
22577 +               }
22578         }
22579  #ifdef IDE_PMAC_DEBUG
22580 -       printk(KERN_ERR "ide_pmac: Set MDMA timing for mode %d, reg: 0x%08x\n",
22581 -               speed & 0xf,  *timings);
22582 +       printk(KERN_ERR "%s: Set MDMA timing for mode %d, reg: 0x%08x\n",
22583 +               drive->name, speed & 0xf,  *timings);
22584  #endif 
22585         return 0;
22586  }
22587 @@ -591,36 +858,42 @@
22588   * our, normal mdma function is supposed to be more precise
22589   */
22590  static int __pmac
22591 -pmac_ide_tune_chipset (ide_drive_t *drive, u8 speed)
22592 +pmac_ide_tune_chipset (ide_drive_t *drive, byte speed)
22593  {
22594         int unit = (drive->select.b.unit & 0x01);
22595         int ret = 0;
22596         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
22597 -       u32 *timings;
22598 -       
22599 +       u32 *timings, *timings2;
22600 +
22601         if (pmif == NULL)
22602                 return 1;
22603 -
22604 +               
22605         timings = &pmif->timings[unit];
22606 +       timings2 = &pmif->timings[unit+2];
22607         
22608         switch(speed) {
22609  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
22610 +               case XFER_UDMA_5:
22611 +                       if (pmif->kind != controller_un_ata6)
22612 +                               return 1;
22613                 case XFER_UDMA_4:
22614                 case XFER_UDMA_3:
22615 -                       if (pmif->kind != controller_kl_ata4_80)
22616 +                       if (HWIF(drive)->udma_four == 0)
22617                                 return 1;               
22618                 case XFER_UDMA_2:
22619                 case XFER_UDMA_1:
22620                 case XFER_UDMA_0:
22621 -                       if (pmif->kind != controller_kl_ata4 &&
22622 -                               pmif->kind != controller_kl_ata4_80)
22623 -                               return 1;               
22624 -                       ret = set_timings_udma(timings, speed);
22625 +                       if (pmif->kind == controller_kl_ata4)
22626 +                               ret = set_timings_udma_ata4(timings, speed);
22627 +                       else if (pmif->kind == controller_un_ata6)
22628 +                               ret = set_timings_udma_ata6(timings, timings2, speed);
22629 +                       else
22630 +                               ret = 1;                
22631                         break;
22632                 case XFER_MW_DMA_2:
22633                 case XFER_MW_DMA_1:
22634                 case XFER_MW_DMA_0:
22635 -                       ret = set_timings_mdma(pmif->kind, timings, speed, 0);
22636 +                       ret = set_timings_mdma(drive, pmif->kind, timings, timings2, speed, 0);
22637                         break;
22638                 case XFER_SW_DMA_2:
22639                 case XFER_SW_DMA_1:
22640 @@ -644,7 +917,7 @@
22641         if (ret)
22642                 return ret;
22643                 
22644 -       pmac_ide_selectproc(drive);     
22645 +       pmac_ide_do_update_timings(drive);      
22646         drive->current_speed = speed;
22647  
22648         return 0;
22649 @@ -653,11 +926,14 @@
22650  static void __pmac
22651  sanitize_timings(pmac_ide_hwif_t *pmif)
22652  {
22653 -       unsigned value;
22654 +       unsigned int value, value2 = 0;
22655         
22656         switch(pmif->kind) {
22657 +               case controller_un_ata6:
22658 +                       value = 0x08618a92;
22659 +                       value2 = 0x00002921;
22660 +                       break;
22661                 case controller_kl_ata4:
22662 -               case controller_kl_ata4_80:
22663                         value = 0x0008438c;
22664                         break;
22665                 case controller_kl_ata3:
22666 @@ -670,6 +946,7 @@
22667                         break;
22668         }
22669         pmif->timings[0] = pmif->timings[1] = value;
22670 +       pmif->timings[2] = pmif->timings[3] = value2;
22671  }
22672  
22673  unsigned long __pmac
22674 @@ -724,214 +1001,474 @@
22675         return 0;
22676  }
22677  
22678 -void __init
22679 -pmac_ide_probe(void)
22680 +/* Suspend call back, should be called after the child devices
22681 + * have actually been suspended
22682 + */
22683 +static int
22684 +pmac_ide_do_suspend(ide_hwif_t *hwif)
22685  {
22686 -       struct device_node *np;
22687 -       int i;
22688 -       struct device_node *atas;
22689 -       struct device_node *p, **pp, *removables, **rp;
22690 -       unsigned long base;
22691 -       int irq, big_delay;
22692 -       ide_hwif_t *hwif;
22693 +       pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
22694 +       
22695 +       /* We clear the timings */
22696 +       pmif->timings[0] = 0;
22697 +       pmif->timings[1] = 0;
22698 +       
22699 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
22700 +       /* Note: This code will be called for every hwif, thus we'll
22701 +        * try several time to stop the LED blinker timer,  but that
22702 +        * should be harmless
22703 +        */
22704 +       if (pmu_ide_blink_enabled) {
22705 +               unsigned long flags;
22706  
22707 -       if (_machine != _MACH_Pmac)
22708 -               return;
22709 -       pp = &atas;
22710 -       rp = &removables;
22711 -       p = find_devices("ATA");
22712 -       if (p == NULL)
22713 -               p = find_devices("IDE");
22714 -       if (p == NULL)
22715 -               p = find_type_devices("ide");
22716 -       if (p == NULL)
22717 -               p = find_type_devices("ata");
22718 -       /* Move removable devices such as the media-bay CDROM
22719 -          on the PB3400 to the end of the list. */
22720 -       for (; p != NULL; p = p->next) {
22721 -               if (p->parent && p->parent->type
22722 -                   && strcasecmp(p->parent->type, "media-bay") == 0) {
22723 -                       *rp = p;
22724 -                       rp = &p->next;
22725 -               } else {
22726 -                       *pp = p;
22727 -                       pp = &p->next;
22728 -               }
22729 +               /* Make sure we don't hit the PMU blink */
22730 +               spin_lock_irqsave(&pmu_blink_lock, flags);
22731 +               if (pmu_blink_ledstate)
22732 +                       del_timer(&pmu_blink_timer);
22733 +               pmu_blink_ledstate = 0;
22734 +               spin_unlock_irqrestore(&pmu_blink_lock, flags);
22735         }
22736 -       *rp = NULL;
22737 -       *pp = removables;
22738 -       big_delay = 0;
22739 -
22740 -       for (i = 0, np = atas; i < MAX_HWIFS && np != NULL; np = np->next) {
22741 -               struct device_node *tp;
22742 -               struct pmac_ide_hwif* pmif;
22743 -               int *bidp;
22744 -               int in_bay = 0;
22745 -               u8 pbus, pid;
22746 -               struct pci_dev *pdev = NULL;
22747 -
22748 -               /*
22749 -                * If this node is not under a mac-io or dbdma node,
22750 -                * leave it to the generic PCI driver.
22751 -                */
22752 -               for (tp = np->parent; tp != 0; tp = tp->parent)
22753 -                       if (tp->type && (strcmp(tp->type, "mac-io") == 0
22754 -                                        || strcmp(tp->type, "dbdma") == 0))
22755 -                               break;
22756 -               if (tp == 0)
22757 -                       continue;
22758 +#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
22759  
22760 -               if (np->n_addrs == 0) {
22761 -                       printk(KERN_WARNING "ide: no address for device %s\n",
22762 -                              np->full_name);
22763 -                       continue;
22764 -               }
22765 +       /* The media bay will handle itself just fine */
22766 +       if (pmif->mediabay)
22767 +               return 0;
22768 +       
22769 +       /* Disable the bus */
22770 +       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 0);
22771  
22772 -               /* We need to find the pci_dev of the mac-io holding the
22773 -                * IDE interface
22774 -                */
22775 -               if (pci_device_from_OF_node(tp, &pbus, &pid) == 0)
22776 -                       pdev = pci_find_slot(pbus, pid);
22777 -               if (pdev == NULL)
22778 -                       printk(KERN_WARNING "ide: no PCI host for device %s, DMA disabled\n",
22779 -                              np->full_name);
22780 +       return 0;
22781 +}
22782  
22783 -               /*
22784 -                * If this slot is taken (e.g. by ide-pci.c) try the next one.
22785 -                */
22786 -               while (i < MAX_HWIFS
22787 -                      && ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0)
22788 -                       ++i;
22789 -               if (i >= MAX_HWIFS)
22790 -                       break;
22791 -               pmif = &pmac_ide[i];
22792 +/* Resume call back, should be called before the child devices
22793 + * are resumed
22794 + */
22795 +static int
22796 +pmac_ide_do_resume(ide_hwif_t *hwif)
22797 +{
22798 +       pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
22799 +       
22800 +       /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */
22801 +       if (!pmif->mediabay) {
22802 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1);
22803 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1);
22804 +               mdelay(10);
22805 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0);
22806 +               mdelay(100);
22807 +       }
22808  
22809 -               /*
22810 -                * Some older OFs have bogus sizes, causing request_OF_resource
22811 -                * to fail. We fix them up here
22812 -                */
22813 -               if (np->addrs[0].size > 0x1000)
22814 -                       np->addrs[0].size = 0x1000;
22815 -               if (np->n_addrs > 1 && np->addrs[1].size > 0x100)
22816 -                       np->addrs[1].size = 0x100;
22817 +       /* Sanitize drive timings */
22818 +       sanitize_timings(pmif);
22819  
22820 -               if (request_OF_resource(np, 0, "  (mac-io IDE IO)") == NULL) {
22821 -                       printk(KERN_ERR "ide-pmac(%s): can't request IO resource !\n", np->name);
22822 -                       continue;
22823 -               }
22824 +       return 0;
22825 +}
22826  
22827 -               base = (unsigned long) ioremap(np->addrs[0].address, 0x400);
22828 +static int
22829 +pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
22830 +{
22831 +       struct device_node *np = pmif->node;
22832 +       int *bidp, i;
22833  
22834 -               /* XXX This is bogus. Should be fixed in the registry by checking
22835 -                  the kind of host interrupt controller, a bit like gatwick
22836 -                  fixes in irq.c
22837 -                */
22838 -               if (np->n_intrs == 0) {
22839 -                       printk(KERN_WARNING "ide: no intrs for device %s, using 13\n",
22840 -                              np->full_name);
22841 -                       irq = 13;
22842 -               } else {
22843 -                       irq = np->intrs[0].line;
22844 -               }
22845 -               pmif->regbase = base;
22846 -               pmif->irq = irq;
22847 -               pmif->node = np;
22848 -               pmif->index = i;
22849 -               if (device_is_compatible(np, "keylargo-ata")) {
22850 -                       if (strcmp(np->name, "ata-4") == 0)
22851 -                               pmif->kind = controller_kl_ata4;
22852 -                       else
22853 -                               pmif->kind = controller_kl_ata3;
22854 -               } else if (device_is_compatible(np, "heathrow-ata"))
22855 -                       pmif->kind = controller_heathrow;
22856 +       pmif->cable_80 = 0;
22857 +       pmif->broken_dma = pmif->broken_dma_warn = 0;
22858 +       if (device_is_compatible(np, "kauai-ata"))
22859 +               pmif->kind = controller_un_ata6;
22860 +       else if (device_is_compatible(np, "keylargo-ata")) {
22861 +               if (strcmp(np->name, "ata-4") == 0)
22862 +                       pmif->kind = controller_kl_ata4;
22863                 else
22864 -                       pmif->kind = controller_ohare;
22865 +                       pmif->kind = controller_kl_ata3;
22866 +       } else if (device_is_compatible(np, "heathrow-ata"))
22867 +               pmif->kind = controller_heathrow;
22868 +       else {
22869 +               pmif->kind = controller_ohare;
22870 +               pmif->broken_dma = 1;
22871 +       }
22872  
22873 -               bidp = (int *)get_property(np, "AAPL,bus-id", NULL);
22874 -               pmif->aapl_bus_id =  bidp ? *bidp : 0;
22875 +       bidp = (int *)get_property(np, "AAPL,bus-id", NULL);
22876 +       pmif->aapl_bus_id =  bidp ? *bidp : 0;
22877  
22878 -               if (pmif->kind == controller_kl_ata4) {
22879 -                       char* cable = get_property(np, "cable-type", NULL);
22880 -                       if (cable && !strncmp(cable, "80-", 3))
22881 -                               pmif->kind = controller_kl_ata4_80;
22882 -               }
22883 +       /* Get cable type from device-tree */
22884 +       if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6) {
22885 +               char* cable = get_property(np, "cable-type", NULL);
22886 +               if (cable && !strncmp(cable, "80-", 3))
22887 +                       pmif->cable_80 = 1;
22888 +       }
22889  
22890 -               /* Make sure we have sane timings */
22891 -               sanitize_timings(pmif);
22892 +       pmif->mediabay = 0;
22893 +       
22894 +       /* Make sure we have sane timings */
22895 +       sanitize_timings(pmif);
22896  
22897 -               if (np->parent && np->parent->name
22898 -                   && strcasecmp(np->parent->name, "media-bay") == 0) {
22899 +       /* XXX FIXME: Media bay stuff need re-organizing */
22900 +       if (np->parent && np->parent->name
22901 +           && strcasecmp(np->parent->name, "media-bay") == 0) {
22902  #ifdef CONFIG_PMAC_PBOOK
22903 -                       media_bay_set_ide_infos(np->parent,base,irq,i);
22904 +               media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq, hwif->index);
22905  #endif /* CONFIG_PMAC_PBOOK */
22906 -                       in_bay = 1;
22907 -                       if (!bidp)
22908 -                               pmif->aapl_bus_id = 1;
22909 -               } else if (pmif->kind == controller_ohare) {
22910 -                       /* The code below is having trouble on some ohare machines
22911 -                        * (timing related ?). Until I can put my hand on one of these
22912 -                        * units, I keep the old way
22913 -                        */
22914 -                       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1);
22915 -               } else {
22916 -                       /* This is necessary to enable IDE when net-booting */
22917 -                       printk(KERN_INFO "pmac_ide: enabling IDE bus ID %d\n",
22918 -                               pmif->aapl_bus_id);
22919 -                       ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
22920 -                       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
22921 -                       mdelay(10);
22922 -                       ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
22923 -                       big_delay = 1;
22924 -               }
22925 +               pmif->mediabay = 1;
22926 +               if (!bidp)
22927 +                       pmif->aapl_bus_id = 1;
22928 +       } else if (pmif->kind == controller_ohare) {
22929 +               /* The code below is having trouble on some ohare machines
22930 +                * (timing related ?). Until I can put my hand on one of these
22931 +                * units, I keep the old way
22932 +                */
22933 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1);
22934 +       } else {
22935 +               /* This is necessary to enable IDE when net-booting */
22936 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
22937 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
22938 +               mdelay(10);
22939 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
22940 +               mdelay(100);
22941 +       }
22942  
22943 -               hwif = &ide_hwifs[i];
22944 -               /* Setup MMIO ops */
22945 -               default_hwif_mmiops(hwif);
22946 -               /* Tell common code _not_ to mess with resources */
22947 -               hwif->mmio = 2;
22948 -               hwif->hwif_data = pmif;
22949 -               pmac_ide_init_hwif_ports(&hwif->hw, base, 0, &hwif->irq);
22950 -               memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
22951 -               hwif->chipset = ide_pmac;
22952 -               hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || in_bay;
22953 -               hwif->udma_four = (pmif->kind == controller_kl_ata4_80);
22954 -               hwif->pci_dev = pdev;
22955 -               hwif->drives[0].unmask = 1;
22956 -               hwif->drives[1].unmask = 1;
22957 -               hwif->tuneproc = pmac_ide_tuneproc;
22958 +       /* Setup MMIO ops */
22959 +       default_hwif_mmiops(hwif);
22960 +
22961 +       /* Tell common code _not_ to mess with resources */
22962 +       hwif->mmio = 2;
22963 +       hwif->hwif_data = pmif;
22964 +       pmac_ide_init_hwif_ports(&hwif->hw, pmif->regbase, 0, &hwif->irq);
22965 +       memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
22966 +       hwif->chipset = ide_pmac;
22967 +       hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || pmif->mediabay;
22968 +       hwif->hold = pmif->mediabay;
22969 +       hwif->udma_four = pmif->cable_80;
22970 +       hwif->drives[0].unmask = 1;
22971 +       hwif->drives[1].unmask = 1;
22972 +       hwif->tuneproc = pmac_ide_tuneproc;
22973 +       if (pmif->kind == controller_un_ata6)
22974 +               hwif->selectproc = pmac_ide_kauai_selectproc;
22975 +       else
22976                 hwif->selectproc = pmac_ide_selectproc;
22977 -               hwif->speedproc = pmac_ide_tune_chipset;
22978 +       hwif->speedproc = pmac_ide_tune_chipset;
22979 +
22980 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
22981 +       pmu_ide_blink_enabled = pmu_hd_blink_init();
22982 +
22983 +       if (pmu_ide_blink_enabled)
22984 +               hwif->led_act = pmu_hd_kick_blink;
22985 +#endif
22986 +
22987 +       printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s\n",
22988 +                       hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
22989 +                       pmif->mediabay ? " (mediabay)" : "");
22990 +                       
22991  #ifdef CONFIG_PMAC_PBOOK
22992 -               if (in_bay && check_media_bay_by_base(base, MB_CD) == 0)
22993 -                       hwif->noprobe = 0;
22994 +       if (pmif->mediabay && check_media_bay_by_base(pmif->regbase, MB_CD) == 0)
22995 +               hwif->noprobe = 0;
22996  #endif /* CONFIG_PMAC_PBOOK */
22997  
22998  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
22999 -               if (np->n_addrs >= 2) {
23000 -                       /* has a DBDMA controller channel */
23001 -                       pmac_ide_setup_dma(np, i);
23002 -               }
23003 -               hwif->atapi_dma = 1;
23004 -               hwif->ultra_mask = 0x1f;
23005 -               hwif->mwdma_mask = 0x07;
23006 -               hwif->swdma_mask = 0x07;
23007 -
23008 +       /* has a DBDMA controller channel */
23009 +       if (pmif->dma_regs)
23010 +               pmac_ide_setup_dma(pmif, hwif);
23011  #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
23012  
23013 +       /* We probe the hwif now */
23014 +       probe_hwif_init(hwif);
23015 +
23016 +       /* The code IDE code will have set hwif->present if we have devices attached,
23017 +        * if we don't, the discard the interface except if we are on a media bay slot
23018 +        */
23019 +       if (!hwif->present && !pmif->mediabay) {
23020 +               printk(KERN_INFO "ide%d: Bus empty, interface released.\n",
23021 +                       hwif->index);
23022 +               default_hwif_iops(hwif);
23023 +               for (i = IDE_DATA_OFFSET; i <= IDE_CONTROL_OFFSET; ++i)
23024 +                       hwif->io_ports[i] = 0;
23025 +               hwif->chipset = ide_unknown;
23026 +               hwif->noprobe = 1;
23027 +               return -ENODEV;
23028 +       }
23029 +
23030 +       return 0;
23031 +}
23032 +
23033 +static int __devinit
23034 +pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_match *match)
23035 +{
23036 +       unsigned long base, regbase;
23037 +       int irq;
23038 +       ide_hwif_t *hwif;
23039 +       pmac_ide_hwif_t *pmif;
23040 +       int i, rc;
23041 +
23042 +       i = 0;
23043 +       while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0
23044 +           || pmac_ide[i].node != NULL))
23045                 ++i;
23046 +       if (i >= MAX_HWIFS) {
23047 +               printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n");
23048 +               printk(KERN_ERR "          %s\n", mdev->ofdev.node->full_name);
23049 +               return -ENODEV;
23050         }
23051 -       pmac_ide_count = i;
23052 -       if (big_delay)
23053 -               mdelay(IDE_WAKEUP_DELAY_MS);
23054  
23055 -#ifdef CONFIG_PMAC_PBOOK
23056 -       pmu_register_sleep_notifier(&idepmac_sleep_notifier);
23057 -#endif /* CONFIG_PMAC_PBOOK */
23058 +       pmif = &pmac_ide[i];
23059 +       hwif = &ide_hwifs[i];
23060 +
23061 +       if (mdev->ofdev.node->n_addrs == 0) {
23062 +               printk(KERN_WARNING "ide%d: no address for %s\n",
23063 +                      i, mdev->ofdev.node->full_name);
23064 +               return -ENXIO;
23065 +       }
23066 +
23067 +       /*
23068 +        * Some older OFs have bogus sizes, causing request_OF_resource
23069 +        * to fail. We fix them up here
23070 +        */
23071 +       if (mdev->ofdev.node->addrs[0].size > 0x1000)
23072 +               mdev->ofdev.node->addrs[0].size = 0x1000;
23073 +       if (mdev->ofdev.node->n_addrs > 1 && mdev->ofdev.node->addrs[1].size > 0x100)
23074 +               mdev->ofdev.node->addrs[1].size = 0x100;
23075 +
23076 +       /* Request memory resource for IO ports */
23077 +       if (request_OF_resource(mdev->ofdev.node, 0, "  (mac-io ata ports)") == NULL) {
23078 +               printk(KERN_ERR "ide%d: can't request mmio resource !\n", i);
23079 +               return -EBUSY;
23080 +       }
23081 +                       
23082 +       /* XXX This is bogus. Should be fixed in the registry by checking
23083 +        * the kind of host interrupt controller, a bit like gatwick
23084 +        * fixes in irq.c. That works well enough for the single case
23085 +        * where that happens though...
23086 +        */
23087 +       if (mdev->ofdev.node->n_intrs == 0) {
23088 +               printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n",
23089 +                       i, mdev->ofdev.node->full_name);
23090 +               irq = 13;
23091 +       } else
23092 +               irq = mdev->ofdev.node->intrs[0].line;
23093 +
23094 +       base =  (unsigned long) ioremap(mdev->ofdev.node->addrs[0].address, 0x400);
23095 +       regbase = base;
23096 +
23097 +       hwif->pci_dev = mdev->bus->pdev;
23098 +       hwif->gendev.parent = &mdev->ofdev.dev;
23099 +
23100 +       pmif->mdev = mdev;
23101 +       pmif->node = mdev->ofdev.node;
23102 +       pmif->regbase = regbase;
23103 +       pmif->irq = irq;
23104 +#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
23105 +       if (mdev->ofdev.node->n_addrs >= 2)
23106 +               pmif->dma_regs = (volatile struct dbdma_regs*)
23107 +                       ioremap(mdev->ofdev.node->addrs[1].address, 0x1000);
23108 +       else
23109 +               pmif->dma_regs = NULL;
23110 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
23111 +       dev_set_drvdata(&mdev->ofdev.dev, hwif);
23112 +
23113 +       rc = pmac_ide_setup_device(pmif, hwif);
23114 +       if (rc != 0) {
23115 +               /* The inteface is released to the common IDE layer */
23116 +               dev_set_drvdata(&mdev->ofdev.dev, NULL);
23117 +               iounmap((void *)base);
23118 +               if (pmif->dma_regs)
23119 +                       iounmap((void *)pmif->dma_regs);
23120 +               memset(pmif, 0, sizeof(*pmif));
23121 +               release_OF_resource(mdev->ofdev.node, 0);
23122 +       }
23123 +
23124 +       return rc;
23125  }
23126  
23127 +static int
23128 +pmac_ide_macio_suspend(struct macio_dev *mdev, u32 state)
23129 +{
23130 +       ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
23131 +       int             rc = 0;
23132 +
23133 +       if (state != mdev->ofdev.dev.power_state && state >= 2) {
23134 +               rc = pmac_ide_do_suspend(hwif);
23135 +               if (rc == 0)
23136 +                       mdev->ofdev.dev.power_state = state;
23137 +       }
23138 +
23139 +       return rc;
23140 +}
23141 +
23142 +static int
23143 +pmac_ide_macio_resume(struct macio_dev *mdev)
23144 +{
23145 +       ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
23146 +       int             rc = 0;
23147 +       
23148 +       if (mdev->ofdev.dev.power_state != 0) {
23149 +               rc = pmac_ide_do_resume(hwif);
23150 +               if (rc == 0)
23151 +                       mdev->ofdev.dev.power_state = 0;
23152 +       }
23153 +
23154 +       return rc;
23155 +}
23156 +
23157 +static int __devinit
23158 +pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
23159 +{
23160 +       ide_hwif_t *hwif;
23161 +       struct device_node *np;
23162 +       pmac_ide_hwif_t *pmif;
23163 +       unsigned long base;
23164 +       unsigned long rbase, rlen;
23165 +       int i, rc;
23166 +
23167 +       np = pci_device_to_OF_node(pdev);
23168 +       if (np == NULL) {
23169 +               printk(KERN_ERR "ide-pmac: cannot find MacIO node for Kauai ATA interface\n");
23170 +               return -ENODEV;
23171 +       }
23172 +       i = 0;
23173 +       while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0
23174 +           || pmac_ide[i].node != NULL))
23175 +               ++i;
23176 +       if (i >= MAX_HWIFS) {
23177 +               printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n");
23178 +               printk(KERN_ERR "          %s\n", np->full_name);
23179 +               return -ENODEV;
23180 +       }
23181 +
23182 +       pmif = &pmac_ide[i];
23183 +       hwif = &ide_hwifs[i];
23184 +
23185 +       if (pci_enable_device(pdev)) {
23186 +               printk(KERN_WARNING "ide%i: Can't enable PCI device for %s\n",
23187 +                       i, np->full_name);
23188 +               return -ENXIO;
23189 +       }
23190 +       pci_set_master(pdev);
23191 +                       
23192 +       if (pci_request_regions(pdev, "Kauai ATA")) {
23193 +               printk(KERN_ERR "ide%d: Cannot obtain PCI resources for %s\n",
23194 +                       i, np->full_name);
23195 +               return -ENXIO;
23196 +       }
23197 +
23198 +       hwif->pci_dev = pdev;
23199 +       hwif->gendev.parent = &pdev->dev;
23200 +       pmif->mdev = NULL;
23201 +       pmif->node = np;
23202 +
23203 +       rbase = pci_resource_start(pdev, 0);
23204 +       rlen = pci_resource_len(pdev, 0);
23205 +
23206 +       base = (unsigned long) ioremap(rbase, rlen);
23207 +       pmif->regbase = base + 0x2000;
23208  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
23209 +       pmif->dma_regs = (volatile struct dbdma_regs*)(base + 0x1000);
23210 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */        
23211 +       pmif->irq = pdev->irq;
23212 +
23213 +       pci_set_drvdata(pdev, hwif);
23214 +
23215 +       rc = pmac_ide_setup_device(pmif, hwif);
23216 +       if (rc != 0) {
23217 +               /* The inteface is released to the common IDE layer */
23218 +               pci_set_drvdata(pdev, NULL);
23219 +               iounmap((void *)base);
23220 +               memset(pmif, 0, sizeof(*pmif));
23221 +               pci_release_regions(pdev);
23222 +       }
23223 +
23224 +       return rc;
23225 +}
23226 +
23227 +static int
23228 +pmac_ide_pci_suspend(struct pci_dev *pdev, u32 state)
23229 +{
23230 +       ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
23231 +       int             rc = 0;
23232 +       
23233 +       if (state != pdev->dev.power_state && state >= 2) {
23234 +               rc = pmac_ide_do_suspend(hwif);
23235 +               if (rc == 0)
23236 +                       pdev->dev.power_state = state;
23237 +       }
23238 +
23239 +       return rc;
23240 +}
23241  
23242  static int
23243 +pmac_ide_pci_resume(struct pci_dev *pdev)
23244 +{
23245 +       ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
23246 +       int             rc = 0;
23247 +       
23248 +       if (pdev->dev.power_state != 0) {
23249 +               rc = pmac_ide_do_resume(hwif);
23250 +               if (rc == 0)
23251 +                       pdev->dev.power_state = 0;
23252 +       }
23253 +
23254 +       return rc;
23255 +}
23256 +
23257 +static struct of_match pmac_ide_macio_match[] = 
23258 +{
23259 +       {
23260 +       .name           = "IDE",
23261 +       .type           = OF_ANY_MATCH,
23262 +       .compatible     = OF_ANY_MATCH
23263 +       },
23264 +       {
23265 +       .name           = "ATA",
23266 +       .type           = OF_ANY_MATCH,
23267 +       .compatible     = OF_ANY_MATCH
23268 +       },
23269 +       {
23270 +       .name           = OF_ANY_MATCH,
23271 +       .type           = "ide",
23272 +       .compatible     = OF_ANY_MATCH
23273 +       },
23274 +       {
23275 +       .name           = OF_ANY_MATCH,
23276 +       .type           = "ata",
23277 +       .compatible     = OF_ANY_MATCH
23278 +       },
23279 +       {},
23280 +};
23281 +
23282 +static struct macio_driver pmac_ide_macio_driver = 
23283 +{
23284 +       .name           = "ide-pmac",
23285 +       .match_table    = pmac_ide_macio_match,
23286 +       .probe          = pmac_ide_macio_attach,
23287 +       .suspend        = pmac_ide_macio_suspend,
23288 +       .resume         = pmac_ide_macio_resume,
23289 +};
23290 +
23291 +static struct pci_device_id pmac_ide_pci_match[] __devinitdata = {
23292 +       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_KAUAI_ATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
23293 +};
23294 +
23295 +static struct pci_driver pmac_ide_pci_driver = {
23296 +       .name           = "ide-pmac",
23297 +       .id_table       = pmac_ide_pci_match,
23298 +       .probe          = pmac_ide_pci_attach,
23299 +       .suspend        = pmac_ide_pci_suspend,
23300 +       .resume         = pmac_ide_pci_resume,
23301 +};
23302 +
23303 +void __init
23304 +pmac_ide_probe(void)
23305 +{
23306 +       if (_machine != _MACH_Pmac)
23307 +               return;
23308 +
23309 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST
23310 +       pci_register_driver(&pmac_ide_pci_driver);
23311 +       macio_register_driver(&pmac_ide_macio_driver);
23312 +#else
23313 +       macio_register_driver(&pmac_ide_macio_driver);
23314 +       pci_register_driver(&pmac_ide_pci_driver);
23315 +#endif 
23316 +}
23317 +
23318 +#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
23319 +
23320 +static int __pmac
23321  pmac_ide_build_sglist(ide_drive_t *drive, struct request *rq)
23322  {
23323         ide_hwif_t *hwif = HWIF(drive);
23324 @@ -942,7 +1479,7 @@
23325         if (hwif->sg_dma_active)
23326                 BUG();
23327                 
23328 -       nents = blk_rq_map_sg(&drive->queue, rq, sg);
23329 +       nents = blk_rq_map_sg(drive->queue, rq, sg);
23330                 
23331         if (rq_data_dir(rq) == READ)
23332                 pmif->sg_dma_direction = PCI_DMA_FROMDEVICE;
23333 @@ -952,7 +1489,7 @@
23334         return pci_map_sg(hwif->pci_dev, sg, nents, pmif->sg_dma_direction);
23335  }
23336  
23337 -static int
23338 +static int __pmac
23339  pmac_ide_raw_build_sglist(ide_drive_t *drive, struct request *rq)
23340  {
23341         ide_hwif_t *hwif = HWIF(drive);
23342 @@ -968,14 +1505,14 @@
23343         else
23344                 pmif->sg_dma_direction = PCI_DMA_FROMDEVICE;
23345         
23346 -       if (sector_count > 127) {
23347 +       if (sector_count > 128) {
23348                 memset(&sg[nents], 0, sizeof(*sg));
23349                 sg[nents].page = virt_to_page(virt_addr);
23350                 sg[nents].offset = offset_in_page(virt_addr);
23351 -               sg[nents].length = 127  * SECTOR_SIZE;
23352 +               sg[nents].length = 128  * SECTOR_SIZE;
23353                 nents++;
23354 -               virt_addr = virt_addr + (127 * SECTOR_SIZE);
23355 -               sector_count -= 127;
23356 +               virt_addr = virt_addr + (128 * SECTOR_SIZE);
23357 +               sector_count -= 128;
23358         }
23359         memset(&sg[nents], 0, sizeof(*sg));
23360         sg[nents].page = virt_to_page(virt_addr);
23361 @@ -990,16 +1527,16 @@
23362   * pmac_ide_build_dmatable builds the DBDMA command list
23363   * for a transfer and sets the DBDMA channel to point to it.
23364   */
23365 -static int
23366 -pmac_ide_build_dmatable(ide_drive_t *drive, int wr)
23367 +static int __pmac
23368 +pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
23369  {
23370         struct dbdma_cmd *table;
23371         int i, count = 0;
23372 -       struct request *rq = HWGROUP(drive)->rq;
23373         ide_hwif_t *hwif = HWIF(drive);
23374         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
23375         volatile struct dbdma_regs *dma = pmif->dma_regs;
23376         struct scatterlist *sg;
23377 +       int wr = (rq_data_dir(rq) == WRITE);
23378  
23379         /* DMA table is already aligned */
23380         table = (struct dbdma_cmd *) pmif->dma_table_cpu;
23381 @@ -1026,10 +1563,18 @@
23382                 cur_addr = sg_dma_address(sg);
23383                 cur_len = sg_dma_len(sg);
23384  
23385 +               if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) {
23386 +                       if (pmif->broken_dma_warn == 0) {
23387 +                               printk(KERN_WARNING "%s: DMA on non aligned address,"
23388 +                                      "switching to PIO on Ohare chipset\n", drive->name);
23389 +                               pmif->broken_dma_warn = 1;
23390 +                       }
23391 +                       goto use_pio_instead;
23392 +               }
23393                 while (cur_len) {
23394                         unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
23395  
23396 -                       if (++count >= MAX_DCMDS) {
23397 +                       if (count++ >= MAX_DCMDS) {
23398                                 printk(KERN_WARNING "%s: DMA table too small\n",
23399                                        drive->name);
23400                                 goto use_pio_instead;
23401 @@ -1070,7 +1615,7 @@
23402  }
23403  
23404  /* Teardown mappings after DMA has completed.  */
23405 -static void
23406 +static void __pmac
23407  pmac_ide_destroy_dmatable (ide_drive_t *drive)
23408  {
23409         struct pci_dev *dev = HWIF(drive)->pci_dev;
23410 @@ -1081,67 +1626,25 @@
23411         if (nents) {
23412                 pci_unmap_sg(dev, sg, nents, pmif->sg_dma_direction);
23413                 pmif->sg_nents = 0;
23414 +               HWIF(drive)->sg_dma_active = 0;
23415         }
23416  }
23417  
23418 -static __inline__ unsigned char
23419 -dma_bits_to_command(unsigned char bits)
23420 -{
23421 -       if(bits & 0x04)
23422 -               return XFER_MW_DMA_2;
23423 -       if(bits & 0x02)
23424 -               return XFER_MW_DMA_1;
23425 -       if(bits & 0x01)
23426 -               return XFER_MW_DMA_0;
23427 -       return 0;
23428 -}
23429 -
23430 -static __inline__ unsigned char
23431 -udma_bits_to_command(unsigned char bits, int high_speed)
23432 -{
23433 -       if (high_speed) {
23434 -               if(bits & 0x10)
23435 -                       return XFER_UDMA_4;
23436 -               if(bits & 0x08)
23437 -                       return XFER_UDMA_3;
23438 -       }
23439 -       if(bits & 0x04)
23440 -               return XFER_UDMA_2;
23441 -       if(bits & 0x02)
23442 -               return XFER_UDMA_1;
23443 -       if(bits & 0x01)
23444 -               return XFER_UDMA_0;
23445 -       return 0;
23446 -}
23447 -
23448  /* Calculate MultiWord DMA timings */
23449  static int __pmac
23450 -pmac_ide_mdma_enable(ide_drive_t *drive)
23451 +pmac_ide_mdma_enable(ide_drive_t *drive, u16 mode)
23452  {
23453 -       u8 bits = drive->id->dma_mword & 0x07;
23454 -       u8 feature = dma_bits_to_command(bits);
23455 -       u32 *timings;
23456 +       ide_hwif_t *hwif = HWIF(drive);
23457 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
23458         int drive_cycle_time;
23459         struct hd_driveid *id = drive->id;
23460 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
23461 +       u32 *timings, *timings2;
23462 +       u32 timing_local[2];
23463         int ret;
23464  
23465 -       /* Set feature on drive */
23466 -       printk(KERN_INFO "%s: Enabling MultiWord DMA %d\n", drive->name, feature & 0xf);
23467 -       ret = pmac_ide_do_setfeature(drive, feature);
23468 -       if (ret) {
23469 -               printk(KERN_WARNING "%s: Failed !\n", drive->name);
23470 -               return 0;
23471 -       }
23472 -
23473 -       if (!drive->init_speed)
23474 -               drive->init_speed = feature;
23475 -       
23476         /* which drive is it ? */
23477 -       if (drive->select.b.unit & 0x01)
23478 -               timings = &pmif->timings[1];
23479 -       else
23480 -               timings = &pmif->timings[0];
23481 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
23482 +       timings2 = &pmif->timings[(drive->select.b.unit & 0x01) + 2];
23483  
23484         /* Check if drive provide explicit cycle time */
23485         if ((id->field_valid & 2) && (id->eide_dma_time))
23486 @@ -1149,201 +1652,220 @@
23487         else
23488                 drive_cycle_time = 0;
23489  
23490 +       /* Copy timings to local image */
23491 +       timing_local[0] = *timings;
23492 +       timing_local[1] = *timings2;
23493 +
23494         /* Calculate controller timings */
23495 -       set_timings_mdma(pmif->kind, timings, feature, drive_cycle_time);
23496 +       ret = set_timings_mdma( drive, pmif->kind,
23497 +                               &timing_local[0],
23498 +                               &timing_local[1],
23499 +                               mode,
23500 +                               drive_cycle_time);
23501 +       if (ret)
23502 +               return 0;
23503 +
23504 +       /* Set feature on drive */
23505 +       printk(KERN_INFO "%s: Enabling MultiWord DMA %d\n", drive->name, mode & 0xf);
23506 +       ret = pmac_ide_do_setfeature(drive, mode);
23507 +       if (ret) {
23508 +               printk(KERN_WARNING "%s: Failed !\n", drive->name);
23509 +               return 0;
23510 +       }
23511 +
23512 +       /* Apply timings to controller */
23513 +       *timings = timing_local[0];
23514 +       *timings2 = timing_local[1];
23515 +       
23516 +       /* Set speed info in drive */
23517 +       drive->current_speed = mode;    
23518 +       if (!drive->init_speed)
23519 +               drive->init_speed = mode;
23520  
23521 -       drive->current_speed = feature; 
23522         return 1;
23523  }
23524  
23525  /* Calculate Ultra DMA timings */
23526  static int __pmac
23527 -pmac_ide_udma_enable(ide_drive_t *drive, int high_speed)
23528 +pmac_ide_udma_enable(ide_drive_t *drive, u16 mode)
23529  {
23530 -       u8 bits = drive->id->dma_ultra & 0x1f;
23531 -       u8 feature = udma_bits_to_command(bits, high_speed);
23532 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
23533 -       u32 *timings;
23534 +       ide_hwif_t *hwif = HWIF(drive);
23535 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
23536 +       u32 *timings, *timings2;
23537 +       u32 timing_local[2];
23538         int ret;
23539 +               
23540 +       /* which drive is it ? */
23541 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
23542 +       timings2 = &pmif->timings[(drive->select.b.unit & 0x01) + 2];
23543  
23544 +       /* Copy timings to local image */
23545 +       timing_local[0] = *timings;
23546 +       timing_local[1] = *timings2;
23547 +       
23548 +       /* Calculate timings for interface */
23549 +       if (pmif->kind == controller_un_ata6)
23550 +               ret = set_timings_udma_ata6(    &timing_local[0],
23551 +                                               &timing_local[1],
23552 +                                               mode);
23553 +       else
23554 +               ret = set_timings_udma_ata4(&timing_local[0], mode);
23555 +       if (ret)
23556 +               return 0;
23557 +               
23558         /* Set feature on drive */
23559 -       printk(KERN_INFO "%s: Enabling Ultra DMA %d\n", drive->name, feature & 0xf);
23560 -       ret = pmac_ide_do_setfeature(drive, feature);
23561 +       printk(KERN_INFO "%s: Enabling Ultra DMA %d\n", drive->name, mode & 0x0f);
23562 +       ret = pmac_ide_do_setfeature(drive, mode);
23563         if (ret) {
23564                 printk(KERN_WARNING "%s: Failed !\n", drive->name);
23565                 return 0;
23566         }
23567  
23568 -       if (!drive->init_speed)
23569 -               drive->init_speed = feature;
23570 +       /* Apply timings to controller */
23571 +       *timings = timing_local[0];
23572 +       *timings2 = timing_local[1];
23573  
23574 -       /* which drive is it ? */
23575 -       if (drive->select.b.unit & 0x01)
23576 -               timings = &pmif->timings[1];
23577 -       else
23578 -               timings = &pmif->timings[0];
23579 -
23580 -       set_timings_udma(timings, feature);
23581 +       /* Set speed info in drive */
23582 +       drive->current_speed = mode;    
23583 +       if (!drive->init_speed)
23584 +               drive->init_speed = mode;
23585  
23586 -       drive->current_speed = feature; 
23587         return 1;
23588  }
23589  
23590 -int pmac_ide_dma_check(ide_drive_t *drive)
23591 +static int __pmac
23592 +pmac_ide_dma_check(ide_drive_t *drive)
23593  {
23594 -       int ata4, udma;
23595         struct hd_driveid *id = drive->id;
23596         ide_hwif_t *hwif = HWIF(drive);
23597         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
23598         int enable = 1;
23599 -
23600 +       int map;
23601         drive->using_dma = 0;
23602         
23603 -       if (pmif == NULL)
23604 -               return 0;
23605 -               
23606         if (drive->media == ide_floppy)
23607                 enable = 0;
23608 -       if (((id->capability & 1) == 0) &&
23609 -           !HWIF(drive)->ide_dma_good_drive(drive))
23610 +       if (((id->capability & 1) == 0) && !__ide_dma_good_drive(drive))
23611                 enable = 0;
23612 -       if (HWIF(drive)->ide_dma_bad_drive(drive))
23613 +       if (__ide_dma_bad_drive(drive))
23614                 enable = 0;
23615 -       udma = 0;
23616 -       ata4 = (pmif->kind == controller_kl_ata4 ||
23617 -               pmif->kind == controller_kl_ata4_80);
23618 -                       
23619 -       if(enable) {
23620 -               if (ata4 && (drive->media == ide_disk) &&
23621 -                   (id->field_valid & 0x0004) && (id->dma_ultra & 0x1f)) {
23622 -                       /* UltraDMA modes. */
23623 -                       drive->using_dma = pmac_ide_udma_enable(drive,
23624 -                               pmif->kind == controller_kl_ata4_80);
23625 -               }
23626 -               if (!drive->using_dma && (id->dma_mword & 0x0007)) {
23627 -                       /* Normal MultiWord DMA modes. */
23628 -                       drive->using_dma = pmac_ide_mdma_enable(drive);
23629 +
23630 +       if (enable) {
23631 +               short mode;
23632 +               
23633 +               map = XFER_MWDMA;
23634 +               if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6) {
23635 +                       map |= XFER_UDMA;
23636 +                       if (pmif->cable_80) {
23637 +                               map |= XFER_UDMA_66;
23638 +                               if (pmif->kind == controller_un_ata6)
23639 +                                       map |= XFER_UDMA_100;
23640 +                       }
23641                 }
23642 +               mode = ide_find_best_mode(drive, map);
23643 +               if (mode & XFER_UDMA)
23644 +                       drive->using_dma = pmac_ide_udma_enable(drive, mode);
23645 +               else if (mode & XFER_MWDMA)
23646 +                       drive->using_dma = pmac_ide_mdma_enable(drive, mode);
23647                 hwif->OUTB(0, IDE_CONTROL_REG);
23648                 /* Apply settings to controller */
23649 -               pmac_ide_selectproc(drive);
23650 +               pmac_ide_do_update_timings(drive);
23651         }
23652         return 0;
23653  }
23654  
23655 -static int
23656 -pmac_ide_dma_read (ide_drive_t *drive)
23657 +static int __pmac
23658 +pmac_ide_dma_start(ide_drive_t *drive, int reading)
23659  {
23660         ide_hwif_t *hwif = HWIF(drive);
23661         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
23662         struct request *rq = HWGROUP(drive)->rq;
23663 -//     ide_task_t *args = rq->special;
23664         u8 unit = (drive->select.b.unit & 0x01);
23665         u8 ata4;
23666 -       u8 lba48 = (drive->addressing == 1) ? 1 : 0;
23667 -       task_ioreg_t command = WIN_NOP;
23668  
23669         if (pmif == NULL)
23670                 return 1;
23671 +       ata4 = (pmif->kind == controller_kl_ata4);      
23672  
23673 -       ata4 = (pmif->kind == controller_kl_ata4 ||
23674 -               pmif->kind == controller_kl_ata4_80);
23675 -
23676 -       if (!pmac_ide_build_dmatable(drive, 0))
23677 +       if (!pmac_ide_build_dmatable(drive, rq))
23678                 return 1;
23679 +
23680         /* Apple adds 60ns to wrDataSetup on reads */
23681         if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
23682 -               writel(pmif->timings[unit]+0x00800000UL,
23683 +               writel(pmif->timings[unit] + (reading ? 0x00800000UL : 0),
23684                         (unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
23685                 (void)readl((unsigned *)(IDE_DATA_REG + IDE_TIMING_CONFIG));
23686         }
23687 +
23688         drive->waiting_for_dma = 1;
23689 +
23690 +       return 0;
23691 +}
23692 +
23693 +static int __pmac
23694 +pmac_ide_dma_read(ide_drive_t *drive)
23695 +{
23696 +       struct request *rq = HWGROUP(drive)->rq;
23697 +       u8 lba48 = (drive->addressing == 1) ? 1 : 0;
23698 +       task_ioreg_t command = WIN_NOP;
23699 +
23700 +       if (pmac_ide_dma_start(drive, 1))
23701 +               return 1;
23702 +
23703         if (drive->media != ide_disk)
23704                 return 0;
23705 -       if (HWGROUP(drive)->handler != NULL)    /* paranoia check */
23706 -               BUG();
23707 -       ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
23708 -       /*
23709 -        * FIX ME to use only ACB ide_task_t args Struct
23710 -        */
23711 -#if 0
23712 -       {
23713 -               ide_task_t *args = rq->special;
23714 -               command = args->tfRegister[IDE_COMMAND_OFFSET];
23715 -       }
23716 -#else
23717 +
23718         command = (lba48) ? WIN_READDMA_EXT : WIN_READDMA;
23719 +       
23720 +       if (drive->vdma)
23721 +               command = (lba48) ? WIN_READ_EXT: WIN_READ;
23722 +               
23723         if (rq->flags & REQ_DRIVE_TASKFILE) {
23724                 ide_task_t *args = rq->special;
23725                 command = args->tfRegister[IDE_COMMAND_OFFSET];
23726         }
23727 -#endif
23728 +
23729         /* issue cmd to drive */
23730 -       hwif->OUTB(command, IDE_COMMAND_REG);
23731 +       ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL);
23732  
23733         return pmac_ide_dma_begin(drive);
23734  }
23735  
23736 -static int
23737 +static int __pmac
23738  pmac_ide_dma_write (ide_drive_t *drive)
23739  {
23740 -       ide_hwif_t *hwif = HWIF(drive);
23741 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
23742         struct request *rq = HWGROUP(drive)->rq;
23743 -//     ide_task_t *args = rq->special;
23744 -       u8 unit = (drive->select.b.unit & 0x01);
23745 -       u8 ata4;
23746         u8 lba48 = (drive->addressing == 1) ? 1 : 0;
23747         task_ioreg_t command = WIN_NOP;
23748  
23749 -       if (pmif == NULL)
23750 +       if (pmac_ide_dma_start(drive, 0))
23751                 return 1;
23752  
23753 -       ata4 = (pmif->kind == controller_kl_ata4 ||
23754 -               pmif->kind == controller_kl_ata4_80);
23755 -
23756 -       if (!pmac_ide_build_dmatable(drive, 1))
23757 -               return 1;
23758 -       /* Apple adds 60ns to wrDataSetup on reads */
23759 -       if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
23760 -               writel(pmif->timings[unit],
23761 -                       (unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
23762 -               (void)readl((unsigned *)(IDE_DATA_REG + IDE_TIMING_CONFIG));
23763 -       }
23764 -       drive->waiting_for_dma = 1;
23765         if (drive->media != ide_disk)
23766                 return 0;
23767 -       if (HWGROUP(drive)->handler != NULL)    /* paranoia check */
23768 -               BUG();
23769 -       ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
23770 -       /*
23771 -        * FIX ME to use only ACB ide_task_t args Struct
23772 -        */
23773 -#if 0
23774 -       {
23775 -               ide_task_t *args = rq->special;
23776 -               command = args->tfRegister[IDE_COMMAND_OFFSET];
23777 -       }
23778 -#else
23779 +
23780         command = (lba48) ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
23781 +       if (drive->vdma)
23782 +               command = (lba48) ? WIN_WRITE_EXT: WIN_WRITE;
23783 +               
23784         if (rq->flags & REQ_DRIVE_TASKFILE) {
23785                 ide_task_t *args = rq->special;
23786                 command = args->tfRegister[IDE_COMMAND_OFFSET];
23787         }
23788 -#endif
23789 +
23790         /* issue cmd to drive */
23791 -       hwif->OUTB(command, IDE_COMMAND_REG);
23792 +       ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL);
23793  
23794         return pmac_ide_dma_begin(drive);
23795  }
23796  
23797 -static int
23798 +static int __pmac
23799  pmac_ide_dma_count (ide_drive_t *drive)
23800  {
23801         return HWIF(drive)->ide_dma_begin(drive);
23802  }
23803  
23804 -static int
23805 +static int __pmac
23806  pmac_ide_dma_begin (ide_drive_t *drive)
23807  {
23808         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
23809 @@ -1359,7 +1881,7 @@
23810         return 0;
23811  }
23812  
23813 -static int
23814 +static int __pmac
23815  pmac_ide_dma_end (ide_drive_t *drive)
23816  {
23817         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
23818 @@ -1378,7 +1900,7 @@
23819         return (dstat & (RUN|DEAD|ACTIVE)) != RUN;
23820  }
23821  
23822 -static int
23823 +static int __pmac
23824  pmac_ide_dma_test_irq (ide_drive_t *drive)
23825  {
23826         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
23827 @@ -1418,33 +1940,33 @@
23828                 return 1;
23829         if (!drive->waiting_for_dma)
23830                 printk(KERN_WARNING "ide%d, ide_dma_test_irq \
23831 -                       called while not waiting\n", pmif->index);
23832 +                       called while not waiting\n", HWIF(drive)->index);
23833  
23834         /* If dbdma didn't execute the STOP command yet, the
23835          * active bit is still set */
23836         drive->waiting_for_dma++;
23837         if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) {
23838                 printk(KERN_WARNING "ide%d, timeout waiting \
23839 -                       for dbdma command stop\n", pmif->index);
23840 +                       for dbdma command stop\n", HWIF(drive)->index);
23841                 return 1;
23842         }
23843 -       udelay(1);
23844 +       udelay(5);
23845         return 0;
23846  }
23847  
23848 -static int
23849 +static int __pmac
23850  pmac_ide_dma_host_off (ide_drive_t *drive)
23851  {
23852         return 0;
23853  }
23854  
23855 -static int
23856 +static int __pmac
23857  pmac_ide_dma_host_on (ide_drive_t *drive)
23858  {
23859         return 0;
23860  }
23861  
23862 -static int
23863 +static int __pmac
23864  pmac_ide_dma_lostirq (ide_drive_t *drive)
23865  {
23866         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
23867 @@ -1461,316 +1983,87 @@
23868  }
23869  
23870  static void __init 
23871 -pmac_ide_setup_dma(struct device_node *np, int ix)
23872 +pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
23873  {
23874 -       struct pmac_ide_hwif *pmif = &pmac_ide[ix];
23875 -
23876 -       if (request_OF_resource(np, 1, " (mac-io IDE DMA)") == NULL) {
23877 -               printk(KERN_ERR "ide-pmac(%s): can't request DMA resource !\n", np->name);
23878 +       /* We won't need pci_dev if we switch to generic consistent
23879 +        * DMA routines ...
23880 +        */
23881 +       if (hwif->pci_dev == NULL)
23882                 return;
23883 -       }
23884 -
23885 -       pmif->dma_regs =
23886 -               (volatile struct dbdma_regs*)ioremap(np->addrs[1].address, 0x200);
23887 -
23888         /*
23889          * Allocate space for the DBDMA commands.
23890          * The +2 is +1 for the stop command and +1 to allow for
23891          * aligning the start address to a multiple of 16 bytes.
23892          */
23893         pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent(
23894 -               ide_hwifs[ix].pci_dev,
23895 +               hwif->pci_dev,
23896                 (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
23897                 &pmif->dma_table_dma);
23898         if (pmif->dma_table_cpu == NULL) {
23899                 printk(KERN_ERR "%s: unable to allocate DMA command list\n",
23900 -                      ide_hwifs[ix].name);
23901 +                      hwif->name);
23902                 return;
23903         }
23904  
23905         pmif->sg_table = kmalloc(sizeof(struct scatterlist) * MAX_DCMDS,
23906                                  GFP_KERNEL);
23907         if (pmif->sg_table == NULL) {
23908 -               pci_free_consistent(    ide_hwifs[ix].pci_dev,
23909 +               pci_free_consistent(    hwif->pci_dev,
23910                                         (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
23911                                         pmif->dma_table_cpu, pmif->dma_table_dma);
23912                 return;
23913         }
23914 -       ide_hwifs[ix].ide_dma_off = &__ide_dma_off;
23915 -       ide_hwifs[ix].ide_dma_off_quietly = &__ide_dma_off_quietly;
23916 -       ide_hwifs[ix].ide_dma_on = &__ide_dma_on;
23917 -       ide_hwifs[ix].ide_dma_check = &pmac_ide_dma_check;
23918 -       ide_hwifs[ix].ide_dma_read = &pmac_ide_dma_read;
23919 -       ide_hwifs[ix].ide_dma_write = &pmac_ide_dma_write;
23920 -       ide_hwifs[ix].ide_dma_count = &pmac_ide_dma_count;
23921 -       ide_hwifs[ix].ide_dma_begin = &pmac_ide_dma_begin;
23922 -       ide_hwifs[ix].ide_dma_end = &pmac_ide_dma_end;
23923 -       ide_hwifs[ix].ide_dma_test_irq = &pmac_ide_dma_test_irq;
23924 -       ide_hwifs[ix].ide_dma_host_off = &pmac_ide_dma_host_off;
23925 -       ide_hwifs[ix].ide_dma_host_on = &pmac_ide_dma_host_on;
23926 -       ide_hwifs[ix].ide_dma_good_drive = &__ide_dma_good_drive;
23927 -       ide_hwifs[ix].ide_dma_bad_drive = &__ide_dma_bad_drive;
23928 -       ide_hwifs[ix].ide_dma_verbose = &__ide_dma_verbose;
23929 -       ide_hwifs[ix].ide_dma_timeout = &__ide_dma_timeout;
23930 -       ide_hwifs[ix].ide_dma_retune = &__ide_dma_retune;
23931 -       ide_hwifs[ix].ide_dma_lostirq = &pmac_ide_dma_lostirq;
23932 -       ide_hwifs[ix].ide_dma_queued_on = &__ide_dma_queued_on;
23933 -       ide_hwifs[ix].ide_dma_queued_off = &__ide_dma_queued_off;
23934 +       hwif->ide_dma_off = &__ide_dma_off;
23935 +       hwif->ide_dma_off_quietly = &__ide_dma_off_quietly;
23936 +       hwif->ide_dma_on = &__ide_dma_on;
23937 +       hwif->ide_dma_check = &pmac_ide_dma_check;
23938 +       hwif->ide_dma_read = &pmac_ide_dma_read;
23939 +       hwif->ide_dma_write = &pmac_ide_dma_write;
23940 +       hwif->ide_dma_count = &pmac_ide_dma_count;
23941 +       hwif->ide_dma_begin = &pmac_ide_dma_begin;
23942 +       hwif->ide_dma_end = &pmac_ide_dma_end;
23943 +       hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq;
23944 +       hwif->ide_dma_host_off = &pmac_ide_dma_host_off;
23945 +       hwif->ide_dma_host_on = &pmac_ide_dma_host_on;
23946 +       hwif->ide_dma_good_drive = &__ide_dma_good_drive;
23947 +       hwif->ide_dma_bad_drive = &__ide_dma_bad_drive;
23948 +       hwif->ide_dma_verbose = &__ide_dma_verbose;
23949 +       hwif->ide_dma_timeout = &__ide_dma_timeout;
23950 +       hwif->ide_dma_retune = &__ide_dma_retune;
23951 +       hwif->ide_dma_lostirq = &pmac_ide_dma_lostirq;
23952 +       hwif->ide_dma_queued_on = &__ide_dma_queued_on;
23953 +       hwif->ide_dma_queued_off = &__ide_dma_queued_off;
23954 +#ifdef CONFIG_BLK_DEV_IDE_TCQ
23955 +       hwif->ide_dma_queued_read = __ide_dma_queued_read;
23956 +       hwif->ide_dma_queued_write = __ide_dma_queued_write;
23957 +       hwif->ide_dma_queued_start = __ide_dma_queued_start;
23958 +#endif
23959  
23960  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO
23961         if (!noautodma)
23962 -               ide_hwifs[ix].autodma = 1;
23963 +               hwif->autodma = 1;
23964  #endif
23965 -       ide_hwifs[ix].drives[0].autodma = ide_hwifs[ix].autodma;
23966 -       ide_hwifs[ix].drives[1].autodma = ide_hwifs[ix].autodma;
23967 -}
23968 -
23969 -#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
23970 -
23971 -static void __pmac
23972 -idepmac_sleep_device(ide_drive_t *drive, unsigned base)
23973 -{
23974 -       ide_hwif_t *hwif = HWIF(drive);
23975 -       int j;
23976 -       
23977 -       /* FIXME: We only handle the master IDE disk, we shoud
23978 -        *        try to fix CD-ROMs here
23979 -        */
23980 -       switch (drive->media) {
23981 -       case ide_disk:
23982 -               /* Spin down the drive */
23983 -               hwif->OUTB(drive->select.all, base+0x60);
23984 -               (void) hwif->INB(base+0x60);
23985 -               udelay(100);
23986 -               hwif->OUTB(0x0, base+0x30);
23987 -               hwif->OUTB(0x0, base+0x20);
23988 -               hwif->OUTB(0x0, base+0x40);
23989 -               hwif->OUTB(0x0, base+0x50);
23990 -               hwif->OUTB(0xe0, base+0x70);
23991 -               hwif->OUTB(0x2, base+0x160);   
23992 -               for (j = 0; j < 10; j++) {
23993 -                       u8 status;
23994 -                       mdelay(100);
23995 -                       status = hwif->INB(base+0x70);
23996 -                       if (!(status & BUSY_STAT) && (status & DRQ_STAT))
23997 -                               break;
23998 -               }
23999 -               break;
24000 -       case ide_cdrom:
24001 -               // todo
24002 -               break;
24003 -       case ide_floppy:
24004 -               // todo
24005 -               break;
24006 -       }
24007 -}
24008 -
24009 -#ifdef CONFIG_PMAC_PBOOK
24010 -static void __pmac
24011 -idepmac_wake_device(ide_drive_t *drive, int used_dma)
24012 -{
24013 -       /* We force the IDE subdriver to check for a media change
24014 -        * This must be done first or we may lost the condition
24015 -        *
24016 -        * Problem: This can schedule. I moved the block device
24017 -        * wakeup almost late by priority because of that.
24018 -        */
24019 -       //if (DRIVER(drive))
24020 -       //      check_disk_change(MKDEV(drive->disk->major, drive->disk->first_minor));
24021 -       
24022 -#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
24023 -       /* We re-enable DMA on the drive if it was active. */
24024 -       /* This doesn't work with the CD-ROM in the media-bay, probably
24025 -        * because of a pending unit attention. The problem if that if I
24026 -        * clear the error, the filesystem dies.
24027 -        */
24028 -       if (used_dma && !ide_spin_wait_hwgroup(drive)) {
24029 -               /* Lock HW group */
24030 -               HWGROUP(drive)->busy = 1;
24031 -               pmac_ide_dma_check(drive);
24032 -               HWGROUP(drive)->busy = 0;
24033 -               if (!list_empty(&drive->queue.queue_head))
24034 -                       ide_do_request(HWGROUP(drive), 0);
24035 -               spin_unlock_irq(&ide_lock);
24036 -       }
24037 -#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
24038 -}
24039 -
24040 -static void __pmac
24041 -idepmac_sleep_interface(pmac_ide_hwif_t *pmif, unsigned base, int mediabay)
24042 -{
24043 -       struct device_node* np = pmif->node;
24044 -
24045 -       /* We clear the timings */
24046 -       pmif->timings[0] = 0;
24047 -       pmif->timings[1] = 0;
24048 -       
24049 -       /* The media bay will handle itself just fine */
24050 -       if (mediabay)
24051 -               return;
24052 -       
24053 -       /* Disable the bus */
24054 -       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 0);
24055 -}
24056 +       hwif->drives[0].autodma = hwif->autodma;
24057 +       hwif->drives[1].autodma = hwif->autodma;
24058  
24059 -static void __pmac
24060 -idepmac_wake_interface(pmac_ide_hwif_t *pmif, unsigned long base, int mediabay)
24061 -{
24062 -       struct device_node* np = pmif->node;
24063 -
24064 -       if (!mediabay) {
24065 -               /* Revive IDE disk and controller */
24066 -               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
24067 -               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
24068 -               mdelay(10);
24069 -               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
24070 -       }
24071 -}
24072 -
24073 -static void
24074 -idepmac_sleep_drive(ide_drive_t *drive, unsigned long base)
24075 -{
24076 -       int unlock = 0;
24077 -
24078 -       /* Wait for HW group to complete operations */
24079 -       if (ide_spin_wait_hwgroup(drive)) {
24080 -               // What can we do here ? Wake drive we had already
24081 -               // put to sleep and return an error ?
24082 -       } else {
24083 -               unlock = 1;
24084 -               /* Lock HW group */
24085 -               HWGROUP(drive)->busy = 1;
24086 -               /* Stop the device */
24087 -               idepmac_sleep_device(drive, base);
24088 -       }
24089 -       if (unlock)
24090 -               spin_unlock_irq(&ide_lock);
24091 -}
24092 -
24093 -static void
24094 -idepmac_wake_drive(ide_drive_t *drive, unsigned long base)
24095 -{
24096 -       ide_hwif_t *hwif = HWIF(drive);
24097 -       unsigned long flags;
24098 -       int j;
24099 -       
24100 -       /* Reset timings */
24101 -       pmac_ide_selectproc(drive);
24102 -       mdelay(10);
24103 -       
24104 -       /* Wait up to 20 seconds for the drive to be ready */
24105 -       for (j = 0; j < 200; j++) {
24106 -               u8 status = 0;
24107 -               mdelay(100);
24108 -               hwif->OUTB(drive->select.all, base + 0x60);
24109 -               if ((hwif->INB(base + 0x60)) != drive->select.all)
24110 -                       continue;
24111 -               status = hwif->INB(base + 0x70);
24112 -               if (!(status & BUSY_STAT))
24113 +       hwif->atapi_dma = 1;
24114 +       switch(pmif->kind) {
24115 +               case controller_un_ata6:
24116 +                       hwif->ultra_mask = pmif->cable_80 ? 0x3f : 0x07;
24117 +                       hwif->mwdma_mask = 0x07;
24118 +                       hwif->swdma_mask = 0x00;
24119                         break;
24120 -       }
24121 -
24122 -       /* We resume processing on the HW group */
24123 -       spin_lock_irqsave(&ide_lock, flags);
24124 -       HWGROUP(drive)->busy = 0;
24125 -       if (!list_empty(&drive->queue.queue_head))
24126 -               ide_do_request(HWGROUP(drive), 0);
24127 -       spin_unlock_irqrestore(&ide_lock, flags);
24128 +               case controller_kl_ata4:
24129 +                       hwif->ultra_mask = pmif->cable_80 ? 0x1f : 0x07;
24130 +                       hwif->mwdma_mask = 0x07;
24131 +                       hwif->swdma_mask = 0x00;
24132 +                       break;
24133 +               default:
24134 +                       hwif->ultra_mask = 0x00;
24135 +                       hwif->mwdma_mask = 0x07;
24136 +                       hwif->swdma_mask = 0x00;
24137 +                       break;
24138 +       }       
24139  }
24140  
24141 -/* Note: We support only master drives for now. This will have to be
24142 - * improved if we want to handle sleep on the iMacDV where the CD-ROM
24143 - * is a slave
24144 - */
24145 -static int __pmac
24146 -idepmac_notify_sleep(struct pmu_sleep_notifier *self, int when)
24147 -{
24148 -       int i, ret;
24149 -       unsigned long base;
24150 -       int big_delay;
24151
24152 -       switch (when) {
24153 -       case PBOOK_SLEEP_REQUEST:
24154 -               break;
24155 -       case PBOOK_SLEEP_REJECT:
24156 -               break;
24157 -       case PBOOK_SLEEP_NOW:
24158 -               for (i = 0; i < pmac_ide_count; ++i) {
24159 -                       ide_hwif_t *hwif;
24160 -                       int dn;
24161 -
24162 -                       if ((base = pmac_ide[i].regbase) == 0)
24163 -                               continue;
24164 -
24165 -                       hwif = &ide_hwifs[i];
24166 -                       for (dn=0; dn<MAX_DRIVES; dn++) {
24167 -                               if (!hwif->drives[dn].present)
24168 -                                       continue;
24169 -                               idepmac_sleep_drive(&hwif->drives[dn], base);
24170 -                       }
24171 -                       /* Disable irq during sleep */
24172 -                       disable_irq(pmac_ide[i].irq);
24173 -                       
24174 -                       /* Check if this is a media bay with an IDE device or not
24175 -                        * a media bay.
24176 -                        */
24177 -                       ret = check_media_bay_by_base(base, MB_CD);
24178 -                       if ((ret == 0) || (ret == -ENODEV))
24179 -                               idepmac_sleep_interface(&pmac_ide[i], base, (ret == 0));
24180 -               }
24181 -               break;
24182 -       case PBOOK_WAKE:
24183 -               big_delay = 0;
24184 -               for (i = 0; i < pmac_ide_count; ++i) {
24185 -
24186 -                       if ((base = pmac_ide[i].regbase) == 0)
24187 -                               continue;
24188 -                               
24189 -                       /* Make sure we have sane timings */            
24190 -                       sanitize_timings(&pmac_ide[i]);
24191 -
24192 -                       /* Check if this is a media bay with an IDE device or not
24193 -                        * a media bay
24194 -                        */
24195 -                       ret = check_media_bay_by_base(base, MB_CD);
24196 -                       if ((ret == 0) || (ret == -ENODEV)) {
24197 -                               idepmac_wake_interface(&pmac_ide[i], base, (ret == 0));                         
24198 -                               big_delay = 1;
24199 -                       }
24200 -
24201 -               }
24202 -               /* Let hardware get up to speed */
24203 -               if (big_delay)
24204 -                       mdelay(IDE_WAKEUP_DELAY_MS);
24205 -       
24206 -               for (i = 0; i < pmac_ide_count; ++i) {
24207 -                       ide_hwif_t *hwif;
24208 -                       int used_dma, dn;
24209 -                       int irq_on = 0;
24210 -                       
24211 -                       if ((base = pmac_ide[i].regbase) == 0)
24212 -                               continue;
24213 -                               
24214 -                       hwif = &ide_hwifs[i];
24215 -                       for (dn=0; dn<MAX_DRIVES; dn++) {
24216 -                               ide_drive_t *drive = &hwif->drives[dn];
24217 -                               if (!drive->present)
24218 -                                       continue;
24219 -                               /* We don't have re-configured DMA yet */
24220 -                               used_dma = drive->using_dma;
24221 -                               drive->using_dma = 0;
24222 -                               idepmac_wake_drive(drive, base);
24223 -                               if (!irq_on) {
24224 -                                       enable_irq(pmac_ide[i].irq);
24225 -                                       irq_on = 1;
24226 -                               }
24227 -                               idepmac_wake_device(drive, used_dma);
24228 -                       }
24229 -                       if (!irq_on)
24230 -                               enable_irq(pmac_ide[i].irq);
24231 -               }
24232 -               break;
24233 -       }
24234 -       return PBOOK_SLEEP_OK;
24235 -}
24236 -#endif /* CONFIG_PMAC_PBOOK */
24237 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
24238 diff -Nru a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
24239 --- a/drivers/ieee1394/csr.c    Wed Aug 20 14:21:56 2003
24240 +++ b/drivers/ieee1394/csr.c    Mon Sep  1 17:00:00 2003
24241 @@ -21,6 +21,7 @@
24242  #include <linux/module.h>
24243  #include <linux/moduleparam.h>
24244  #include <linux/param.h>
24245 +#include <linux/spinlock.h>
24246  
24247  #include "ieee1394_types.h"
24248  #include "hosts.h"
24249 diff -Nru a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
24250 --- a/drivers/ieee1394/eth1394.c        Tue Aug 19 20:56:01 2003
24251 +++ b/drivers/ieee1394/eth1394.c        Mon Sep  1 17:00:00 2003
24252 @@ -89,7 +89,7 @@
24253  #define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
24254  
24255  static char version[] __devinitdata =
24256 -       "$Rev: 1020 $ Ben Collins <bcollins@debian.org>";
24257 +       "$Rev: 1043 $ Ben Collins <bcollins@debian.org>";
24258  
24259  struct fragment_info {
24260         struct list_head list;
24261 @@ -1349,21 +1349,20 @@
24262                                                ptask->dest_node,
24263                                                ptask->addr, ptask->skb->data,
24264                                                tx_len)) {
24265 -               goto fail;
24266 +               free_hpsb_packet(packet);
24267 +               return -1;
24268         }
24269  
24270         ptask->packet = packet;
24271         hpsb_set_packet_complete_task(ptask->packet, ether1394_complete_cb,
24272                                       ptask);
24273  
24274 -       if (hpsb_send_packet(packet))
24275 -               return 0;
24276 -
24277 -fail:
24278 -       if (packet)
24279 +       if (!hpsb_send_packet(packet)) {
24280                 ether1394_free_packet(packet);
24281 +               return -1;
24282 +       }
24283  
24284 -       return -1;
24285 +       return 0;
24286  }
24287  
24288  
24289 @@ -1600,7 +1599,7 @@
24290                 case ETHTOOL_GDRVINFO: {
24291                         struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
24292                         strcpy (info.driver, driver_name);
24293 -                       strcpy (info.version, "$Rev: 1020 $");
24294 +                       strcpy (info.version, "$Rev: 1043 $");
24295                         /* FIXME XXX provide sane businfo */
24296                         strcpy (info.bus_info, "ieee1394");
24297                         if (copy_to_user (useraddr, &info, sizeof (info)))
24298 diff -Nru a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
24299 --- a/drivers/ieee1394/ieee1394_core.c  Sun Aug  3 17:00:00 2003
24300 +++ b/drivers/ieee1394/ieee1394_core.c  Mon Sep  1 17:00:00 2003
24301 @@ -1124,7 +1124,7 @@
24302            to get the index of the ieee1394_driver
24303            we want */
24304  
24305 -       blocknum = (minor(inode->i_rdev) >> 4) & 0xF;
24306 +       blocknum = (iminor(inode) >> 4) & 0xF;
24307  
24308         /* look up the driver */
24309  
24310 @@ -1237,6 +1237,7 @@
24311  EXPORT_SYMBOL(hpsb_free_tlabel);
24312  EXPORT_SYMBOL(hpsb_make_readpacket);
24313  EXPORT_SYMBOL(hpsb_make_writepacket);
24314 +EXPORT_SYMBOL(hpsb_make_streampacket);
24315  EXPORT_SYMBOL(hpsb_make_lockpacket);
24316  EXPORT_SYMBOL(hpsb_make_lock64packet);
24317  EXPORT_SYMBOL(hpsb_make_phypacket);
24318 diff -Nru a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h
24319 --- a/drivers/ieee1394/ieee1394_core.h  Thu Jul 24 17:00:00 2003
24320 +++ b/drivers/ieee1394/ieee1394_core.h  Tue Aug 26 09:25:41 2003
24321 @@ -202,7 +202,7 @@
24322  /* return the index (within a minor number block) of a file */
24323  static inline unsigned char ieee1394_file_to_instance(struct file *file)
24324  {
24325 -       unsigned char minor = minor(file->f_dentry->d_inode->i_rdev);
24326 +       unsigned char minor = iminor(file->f_dentry->d_inode);
24327         
24328         /* return lower 4 bits */
24329         return minor & 0xF;
24330 diff -Nru a/drivers/ieee1394/ieee1394_transactions.c b/drivers/ieee1394/ieee1394_transactions.c
24331 --- a/drivers/ieee1394/ieee1394_transactions.c  Tue Aug  5 10:11:00 2003
24332 +++ b/drivers/ieee1394/ieee1394_transactions.c  Mon Sep  1 17:00:00 2003
24333 @@ -104,7 +104,7 @@
24334                                      int channel, int tag, int sync)
24335  {
24336         packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
24337 -               | (TCODE_STREAM_DATA << 4) | sync;
24338 +                         | (TCODE_STREAM_DATA << 4) | sync;
24339  
24340         packet->header_size = 4;
24341         packet->data_size = length;
24342 @@ -317,6 +317,35 @@
24343         return packet;
24344  }
24345  
24346 +struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, int length,
24347 +                                           int channel, int tag, int sync)
24348 +{
24349 +       struct hpsb_packet *packet;
24350 +
24351 +       if (length == 0)
24352 +               return NULL;
24353 +
24354 +       packet = alloc_hpsb_packet(length + (length % 4 ? 4 - (length % 4) : 0));
24355 +       if (!packet)
24356 +               return NULL;
24357 +
24358 +       if (length % 4) { /* zero padding bytes */
24359 +               packet->data[length >> 2] = 0;
24360 +       }
24361 +       packet->host = host;
24362 +    
24363 +       if (hpsb_get_tlabel(packet)) {
24364 +               free_hpsb_packet(packet);
24365 +               return NULL;
24366 +       }
24367 +
24368 +       fill_async_stream_packet(packet, length, channel, tag, sync);
24369 +       if (buffer)
24370 +               memcpy(packet->data, buffer, length);
24371 +
24372 +       return packet;
24373 +}
24374 +
24375  struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
24376                                           u64 addr, int extcode, quadlet_t *data,
24377                                          quadlet_t arg)
24378 @@ -580,25 +609,18 @@
24379         u16 specifier_id_hi = (specifier_id & 0x00ffff00) >> 8;
24380         u8 specifier_id_lo = specifier_id & 0xff;
24381  
24382 -       HPSB_VERBOSE("Send GASP: channel = %d, length = %d", channel, length);
24383 +       HPSB_VERBOSE("Send GASP: channel = %d, length = %Zd", channel, length);
24384  
24385         length += 8;
24386 -
24387 -       packet = alloc_hpsb_packet(length + (length % 4 ? 4 - (length % 4) : 0));
24388 +    
24389 +       packet = hpsb_make_streampacket(host, NULL, length, channel, 3, 0);
24390         if (!packet)
24391                 return -ENOMEM;
24392  
24393 -       if (length % 4) {
24394 -               packet->data[length / 4] = 0;
24395 -       }
24396 -
24397 -       packet->host = host;
24398 -       fill_async_stream_packet(packet, length, channel, 3, 0);
24399 -        
24400         packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi);
24401         packet->data[1] = cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff));
24402  
24403 -       memcpy(&(packet->data[2]), buffer, length - 4);
24404 +       memcpy(&(packet->data[2]), buffer, length - 8);
24405  
24406         packet->generation = generation;
24407  
24408 diff -Nru a/drivers/ieee1394/ieee1394_transactions.h b/drivers/ieee1394/ieee1394_transactions.h
24409 --- a/drivers/ieee1394/ieee1394_transactions.h  Sun Aug  3 17:00:00 2003
24410 +++ b/drivers/ieee1394/ieee1394_transactions.h  Mon Sep  1 17:00:00 2003
24411 @@ -25,6 +25,8 @@
24412                                         int tag, int sync);
24413  struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node,
24414                                            u64 addr, quadlet_t *buffer, size_t length);
24415 +struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer,
24416 +                                           int length, int channel, int tag, int sync);
24417  
24418  /*
24419   * hpsb_packet_success - Make sense of the ack and reply codes and
24420 diff -Nru a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
24421 --- a/drivers/ieee1394/nodemgr.c        Sat Aug 16 05:08:09 2003
24422 +++ b/drivers/ieee1394/nodemgr.c        Mon Sep  1 17:00:00 2003
24423 @@ -1304,12 +1304,14 @@
24424                  * unregister all the unit directories. */
24425                 nodemgr_remove_node_uds(ne);
24426  
24427 +               /* With all the ud's gone, mark the generation current,
24428 +                * this way the probe will succeed. */
24429 +               ne->generation = generation;
24430 +
24431                 /* This will re-register our unitdir's */
24432                 nodemgr_process_config_rom (hi, ne, busoptions);
24433 -       }
24434 -
24435 -       /* Since that's done, we can declare this record current */
24436 -       ne->generation = generation;
24437 +       } else
24438 +               ne->generation = generation;
24439  
24440         /* Update unit_dirs with attached drivers */
24441         bus_for_each_dev(&ieee1394_bus_type, NULL, ne,
24442 diff -Nru a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
24443 --- a/drivers/ieee1394/ohci1394.c       Sun Aug  3 17:00:00 2003
24444 +++ b/drivers/ieee1394/ohci1394.c       Mon Sep  1 17:00:00 2003
24445 @@ -161,7 +161,7 @@
24446  printk(level "%s_%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
24447  
24448  static char version[] __devinitdata =
24449 -       "$Rev: 1023 $ Ben Collins <bcollins@debian.org>";
24450 +       "$Rev: 1045 $ Ben Collins <bcollins@debian.org>";
24451  
24452  /* Module Parameters */
24453  static int phys_dma = 1;
24454 @@ -1451,7 +1451,7 @@
24455         if (sync != -1) {
24456                 /* set sync flag on first DMA descriptor */
24457                 struct dma_cmd *cmd = &recv->block[recv->block_dma];
24458 -               cmd->control |= DMA_CTL_WAIT;
24459 +               cmd->control |= cpu_to_le32(DMA_CTL_WAIT);
24460  
24461                 /* match sync field */
24462                 contextMatch |= (sync&0xf)<<8;
24463 @@ -1675,10 +1675,10 @@
24464                 struct dma_cmd *im = &recv->block[recv->block_dma];
24465                 
24466                 /* check the DMA descriptor for new writes to xferStatus */
24467 -               u16 xferstatus = im->status >> 16;
24468 +               u16 xferstatus = le32_to_cpu(im->status) >> 16;
24469                 
24470                 /* rescount is the number of bytes *remaining to be written* in the block */
24471 -               u16 rescount = im->status & 0xFFFF;
24472 +               u16 rescount = le32_to_cpu(im->status) & 0xFFFF;
24473  
24474                 unsigned char event = xferstatus & 0x1F;
24475  
24476 diff -Nru a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
24477 --- a/drivers/ieee1394/pcilynx.c        Sat Aug 16 05:08:53 2003
24478 +++ b/drivers/ieee1394/pcilynx.c        Tue Aug 26 09:25:41 2003
24479 @@ -875,7 +875,7 @@
24480  
24481  static int mem_open(struct inode *inode, struct file *file)
24482  {
24483 -        int cid = minor(inode->i_rdev);
24484 +        int cid = iminor(inode);
24485          enum { t_rom, t_aux, t_ram } type;
24486          struct memdata *md;
24487          
24488 diff -Nru a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
24489 --- a/drivers/ieee1394/raw1394.c        Sun Aug  3 17:00:00 2003
24490 +++ b/drivers/ieee1394/raw1394.c        Tue Sep  2 06:26:59 2003
24491 @@ -38,6 +38,7 @@
24492  #include <linux/version.h>
24493  #include <linux/smp_lock.h>
24494  #include <linux/interrupt.h>
24495 +#include <linux/vmalloc.h>
24496  #include <asm/uaccess.h>
24497  #include <asm/atomic.h>
24498  #include <linux/devfs_fs_kernel.h>
24499 @@ -180,6 +181,7 @@
24500  
24501          if ((req->req.type == RAW1394_REQ_ASYNC_READ) ||
24502             (req->req.type == RAW1394_REQ_ASYNC_WRITE) ||
24503 +           (req->req.type == RAW1394_REQ_ASYNC_STREAM) ||
24504             (req->req.type == RAW1394_REQ_LOCK) ||
24505             (req->req.type == RAW1394_REQ_LOCK64))
24506                  hpsb_free_tlabel(packet);
24507 @@ -689,6 +691,21 @@
24508                 req->req.length = 0;
24509             break;
24510  
24511 +       case RAW1394_REQ_ASYNC_STREAM:
24512 +               DBGMSG("stream_request called");
24513 +
24514 +               packet = hpsb_make_streampacket(fi->host, NULL, req->req.length, node & 0x3f/*channel*/,
24515 +                                        (req->req.misc >> 16) & 0x3, req->req.misc & 0xf);
24516 +               if (!packet)
24517 +                       return -ENOMEM;
24518 +
24519 +               if (copy_from_user(packet->data, int2ptr(req->req.sendb),
24520 +                                  req->req.length))
24521 +                       req->req.error = RAW1394_ERROR_MEMFAULT;
24522 +                       
24523 +               req->req.length = 0;
24524 +               break;
24525 +
24526          case RAW1394_REQ_LOCK:
24527                  DBGMSG("lock_request called");
24528                  if ((req->req.misc == EXTCODE_FETCH_ADD)
24529 @@ -892,7 +909,7 @@
24530          struct arm_request_response *arm_req_resp = NULL;
24531  
24532          DBGMSG("arm_read  called by node: %X"
24533 -              "addr: %4.4x %8.8x length: %u", nodeid,
24534 +              "addr: %4.4x %8.8x length: %Zu", nodeid,
24535                (u16) ((addr >>32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
24536                length);
24537          spin_lock(&host_info_lock);
24538 @@ -1028,7 +1045,7 @@
24539          struct arm_request_response *arm_req_resp = NULL;
24540  
24541          DBGMSG("arm_write called by node: %X"
24542 -              "addr: %4.4x %8.8x length: %u", nodeid,
24543 +              "addr: %4.4x %8.8x length: %Zu", nodeid,
24544                (u16) ((addr >>32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
24545                length);
24546          spin_lock(&host_info_lock);
24547 @@ -1566,8 +1583,8 @@
24548                req->req.length, ((req->req.misc >> 8) & 0xFF),
24549                (req->req.misc & 0xFF),((req->req.misc >> 16) & 0xFFFF));
24550          /* check addressrange */
24551 -        if ((((req->req.address) & ~((u64)0xFFFFFFFFFFFFLL)) != 0) ||
24552 -                (((req->req.address + req->req.length) & ~((u64)0xFFFFFFFFFFFFLL)) != 0)) {
24553 +        if ((((req->req.address) & ~(0xFFFFFFFFFFFFULL)) != 0) ||
24554 +                (((req->req.address + req->req.length) & ~(0xFFFFFFFFFFFFULL)) != 0)) {
24555                  req->req.length = 0;
24556                  return (-EINVAL);
24557          }
24558 @@ -1578,7 +1595,7 @@
24559                  return (-ENOMEM);
24560          } 
24561          /* allocation of addr_space_buffer */
24562 -        addr->addr_space_buffer = (u8 *)kmalloc(req->req.length,SLAB_KERNEL);
24563 +        addr->addr_space_buffer = (u8 *)vmalloc(req->req.length);
24564          if (!(addr->addr_space_buffer)) {
24565                  kfree(addr);
24566                  req->req.length = 0;
24567 @@ -1592,7 +1609,7 @@
24568                  /* init: user -> kernel */
24569                  if (copy_from_user(addr->addr_space_buffer,int2ptr(req->req.sendb),
24570                          req->req.length)) {
24571 -                        kfree(addr->addr_space_buffer);
24572 +                        vfree(addr->addr_space_buffer);
24573                          kfree(addr);
24574                          return (-EFAULT);
24575                  }
24576 @@ -1633,7 +1650,7 @@
24577          }
24578          if (same_host) {
24579                  /* addressrange occupied by same host */
24580 -                kfree(addr->addr_space_buffer);
24581 +                vfree(addr->addr_space_buffer);
24582                  kfree(addr);
24583                  spin_unlock_irqrestore(&host_info_lock, flags);
24584                  return (-EALREADY);
24585 @@ -1668,7 +1685,7 @@
24586                          int2ptr(&addr->start),sizeof(u64))) {
24587                          printk(KERN_ERR "raw1394: arm_register failed "
24588                                " address-range-entry is invalid -> EFAULT !!!\n");
24589 -                        kfree(addr->addr_space_buffer);
24590 +                        vfree(addr->addr_space_buffer);
24591                          kfree(addr);
24592                          spin_unlock_irqrestore(&host_info_lock, flags);
24593                          return (-EFAULT);
24594 @@ -1686,7 +1703,7 @@
24595                 list_add_tail(&addr->addr_list, &fi->addr_list);
24596          } else {
24597                  DBGMSG("arm_register failed errno: %d \n",retval);
24598 -                kfree(addr->addr_space_buffer);
24599 +                vfree(addr->addr_space_buffer);
24600                  kfree(addr);
24601                  spin_unlock_irqrestore(&host_info_lock, flags);
24602                  return (-EALREADY); 
24603 @@ -1760,7 +1777,7 @@
24604          if (another_host) {
24605                  DBGMSG("delete entry from list -> success");
24606                  list_del(&addr->addr_list);
24607 -                kfree(addr->addr_space_buffer);
24608 +                vfree(addr->addr_space_buffer);
24609                  kfree(addr);
24610                  free_pending_request(req); /* immediate success or fail */
24611                  spin_unlock_irqrestore(&host_info_lock, flags);
24612 @@ -1775,7 +1792,7 @@
24613          DBGMSG("delete entry from list -> success");
24614          list_del(&addr->addr_list);
24615          spin_unlock_irqrestore(&host_info_lock, flags);
24616 -        kfree(addr->addr_space_buffer);
24617 +        vfree(addr->addr_space_buffer);
24618          kfree(addr);
24619          free_pending_request(req); /* immediate success or fail */
24620          return sizeof(struct raw1394_request);
24621 @@ -2440,7 +2457,7 @@
24622                  }
24623                  DBGMSG("raw1394_release: delete addr_entry from list");
24624                  list_del(&addr->addr_list);
24625 -                kfree(addr->addr_space_buffer);
24626 +                vfree(addr->addr_space_buffer);
24627                  kfree(addr);
24628          } /* while */
24629          spin_unlock_irq(&host_info_lock);
24630 diff -Nru a/drivers/ieee1394/raw1394.h b/drivers/ieee1394/raw1394.h
24631 --- a/drivers/ieee1394/raw1394.h        Wed Feb 12 20:57:18 2003
24632 +++ b/drivers/ieee1394/raw1394.h        Mon Sep  1 17:00:00 2003
24633 @@ -19,6 +19,7 @@
24634  #define RAW1394_REQ_LOCK64          103
24635  #define RAW1394_REQ_ISO_SEND        104
24636  #define RAW1394_REQ_ASYNC_SEND      105
24637 +#define RAW1394_REQ_ASYNC_STREAM    106
24638  
24639  #define RAW1394_REQ_ISO_LISTEN      200
24640  #define RAW1394_REQ_FCP_LISTEN      201
24641 diff -Nru a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
24642 --- a/drivers/ieee1394/sbp2.c   Sun Aug 10 22:11:01 2003
24643 +++ b/drivers/ieee1394/sbp2.c   Mon Sep  1 17:00:00 2003
24644 @@ -80,7 +80,7 @@
24645  #include "sbp2.h"
24646  
24647  static char version[] __devinitdata =
24648 -       "$Rev: 1018 $ Ben Collins <bcollins@debian.org>";
24649 +       "$Rev: 1034 $ Ben Collins <bcollins@debian.org>";
24650  
24651  /*
24652   * Module load parameter definitions
24653 @@ -1002,9 +1002,8 @@
24654         sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
24655  
24656         /* Remove it from the scsi layer now */
24657 -       if (sdev) {
24658 +       if (sdev)
24659                 scsi_remove_device(sdev);
24660 -       }
24661  
24662         sbp2util_remove_command_orb_pool(scsi_id);
24663  
24664 diff -Nru a/drivers/input/evdev.c b/drivers/input/evdev.c
24665 --- a/drivers/input/evdev.c     Tue Aug 12 16:21:11 2003
24666 +++ b/drivers/input/evdev.c     Sun Aug 31 16:14:28 2003
24667 @@ -122,7 +122,7 @@
24668  static int evdev_open(struct inode * inode, struct file * file)
24669  {
24670         struct evdev_list *list;
24671 -       int i = minor(inode->i_rdev) - EVDEV_MINOR_BASE;
24672 +       int i = iminor(inode) - EVDEV_MINOR_BASE;
24673         int accept_err;
24674  
24675         if (i >= EVDEV_MINORS || !evdev_table[i])
24676 @@ -305,6 +305,7 @@
24677                                         case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
24678                                         case EV_REL: bits = dev->relbit; len = REL_MAX; break;
24679                                         case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
24680 +                                       case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
24681                                         case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
24682                                         case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
24683                                         case EV_FF:  bits = dev->ffbit;  len = FF_MAX;  break;
24684 diff -Nru a/drivers/input/input.c b/drivers/input/input.c
24685 --- a/drivers/input/input.c     Tue Aug 12 13:29:25 2003
24686 +++ b/drivers/input/input.c     Tue Aug 26 09:25:41 2003
24687 @@ -280,7 +280,7 @@
24688                         if (id->id.product != dev->id.product)
24689                                 continue;
24690                 
24691 -               if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
24692 +               if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
24693                         if (id->id.version != dev->id.version)
24694                                 continue;
24695  
24696 @@ -527,7 +527,7 @@
24697  
24698  static int input_open_file(struct inode *inode, struct file *file)
24699  {
24700 -       struct input_handler *handler = input_table[minor(inode->i_rdev) >> 5];
24701 +       struct input_handler *handler = input_table[iminor(inode) >> 5];
24702         struct file_operations *old_fops, *new_fops = NULL;
24703         int err;
24704  
24705 diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
24706 --- a/drivers/input/joydev.c    Fri May  2 06:55:04 2003
24707 +++ b/drivers/input/joydev.c    Tue Aug 26 09:25:41 2003
24708 @@ -170,7 +170,7 @@
24709  static int joydev_open(struct inode *inode, struct file *file)
24710  {
24711         struct joydev_list *list;
24712 -       int i = minor(inode->i_rdev) - JOYDEV_MINOR_BASE;
24713 +       int i = iminor(inode) - JOYDEV_MINOR_BASE;
24714  
24715         if (i >= JOYDEV_MINORS || !joydev_table[i])
24716                 return -ENODEV;
24717 diff -Nru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
24718 --- a/drivers/input/mousedev.c  Fri May  2 06:55:04 2003
24719 +++ b/drivers/input/mousedev.c  Tue Aug 26 09:25:41 2003
24720 @@ -228,11 +228,11 @@
24721         int i;
24722  
24723  #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
24724 -       if (major(inode->i_rdev) == MISC_MAJOR)
24725 +       if (imajor(inode) == MISC_MAJOR)
24726                 i = MOUSEDEV_MIX;
24727         else
24728  #endif
24729 -               i = minor(inode->i_rdev) - MOUSEDEV_MINOR_BASE;
24730 +               i = iminor(inode) - MOUSEDEV_MINOR_BASE;
24731  
24732         if (i >= MOUSEDEV_MINORS || !mousedev_table[i])
24733                 return -ENODEV;
24734 diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
24735 --- a/drivers/input/serio/i8042.c       Wed Jul 23 07:37:45 2003
24736 +++ b/drivers/input/serio/i8042.c       Tue Sep  2 09:53:45 2003
24737 @@ -410,6 +410,7 @@
24738                         /* work around hardware that doubles key releases */
24739                         if (index == i8042_last_release) {
24740                                 dbg("i8042 skipped double release (%d)\n", index);
24741 +                               i8042_last_e0 = 0;
24742                                 continue;
24743                         }
24744                         if (index == 0xaa || index == 0xb6)
24745 diff -Nru a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c
24746 --- a/drivers/input/serio/sa1111ps2.c   Sat May 17 07:47:27 2003
24747 +++ b/drivers/input/serio/sa1111ps2.c   Sun Aug 24 07:45:05 2003
24748 @@ -62,9 +62,9 @@
24749  
24750                 serio_interrupt(&ps2if->io, scancode, flag, regs);
24751  
24752 -                       status = sa1111_readl(ps2if->base + SA1111_PS2STAT);
24753 +               status = sa1111_readl(ps2if->base + SA1111_PS2STAT);
24754  
24755 -                       handled = IRQ_HANDLED;
24756 +               handled = IRQ_HANDLED;
24757          }
24758  
24759          return handled;
24760 @@ -232,9 +232,8 @@
24761  /*
24762   * Add one device to this driver.
24763   */
24764 -static int ps2_probe(struct device *dev)
24765 +static int ps2_probe(struct sa1111_dev *dev)
24766  {
24767 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
24768         struct ps2if *ps2if;
24769         int ret;
24770  
24771 @@ -249,20 +248,20 @@
24772         ps2if->io.write         = ps2_write;
24773         ps2if->io.open          = ps2_open;
24774         ps2if->io.close         = ps2_close;
24775 -       ps2if->io.name          = dev->name;
24776 -       ps2if->io.phys          = dev->bus_id;
24777 +       ps2if->io.name          = dev->dev.bus_id;
24778 +       ps2if->io.phys          = dev->dev.bus_id;
24779         ps2if->io.driver        = ps2if;
24780 -       ps2if->dev              = sadev;
24781 -       dev->driver_data        = ps2if;
24782 +       ps2if->dev              = dev;
24783 +       sa1111_set_drvdata(dev, ps2if);
24784  
24785         spin_lock_init(&ps2if->lock);
24786  
24787         /*
24788          * Request the physical region for this PS2 port.
24789          */
24790 -       if (!request_mem_region(sadev->res.start,
24791 -                               sadev->res.end - sadev->res.start + 1,
24792 -                               SA1111_DRIVER_NAME(sadev))) {
24793 +       if (!request_mem_region(dev->res.start,
24794 +                               dev->res.end - dev->res.start + 1,
24795 +                               SA1111_DRIVER_NAME(dev))) {
24796                 ret = -EBUSY;
24797                 goto free;
24798         }
24799 @@ -270,7 +269,7 @@
24800         /*
24801          * Our parent device has already mapped the region.
24802          */
24803 -       ps2if->base = (unsigned long)sadev->mapbase;
24804 +       ps2if->base = (unsigned long)dev->mapbase;
24805  
24806         sa1111_enable_device(ps2if->dev);
24807  
24808 @@ -301,10 +300,10 @@
24809  
24810   out:
24811         sa1111_disable_device(ps2if->dev);
24812 -       release_mem_region(sadev->res.start,
24813 -                          sadev->res.end - sadev->res.start + 1);
24814 +       release_mem_region(dev->res.start,
24815 +                          dev->res.end - dev->res.start + 1);
24816   free:
24817 -       dev->driver_data = NULL;
24818 +       sa1111_set_drvdata(dev, NULL);
24819         kfree(ps2if);
24820         return ret;
24821  }
24822 @@ -312,31 +311,17 @@
24823  /*
24824   * Remove one device from this driver.
24825   */
24826 -static int ps2_remove(struct device *dev)
24827 +static int ps2_remove(struct sa1111_dev *dev)
24828  {
24829 -       struct ps2if *ps2if = dev->driver_data;
24830 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
24831 +       struct ps2if *ps2if = sa1111_get_drvdata(dev);
24832  
24833         serio_unregister_port(&ps2if->io);
24834 -       release_mem_region(sadev->res.start,
24835 -                          sadev->res.end - sadev->res.start + 1);
24836 -       kfree(ps2if);
24837 -
24838 -       dev->driver_data = NULL;
24839 -
24840 -       return 0;
24841 -}
24842 +       release_mem_region(dev->res.start,
24843 +                          dev->res.end - dev->res.start + 1);
24844 +       sa1111_set_drvdata(dev, NULL);
24845  
24846 -/*
24847 - * We should probably do something here, but what?
24848 - */
24849 -static int ps2_suspend(struct device *dev, u32 state, u32 level)
24850 -{
24851 -       return 0;
24852 -}
24853 +       kfree(ps2if);
24854  
24855 -static int ps2_resume(struct device *dev, u32 level)
24856 -{
24857         return 0;
24858  }
24859  
24860 @@ -345,24 +330,21 @@
24861   */
24862  static struct sa1111_driver ps2_driver = {
24863         .drv = {
24864 -               .name           = "sa1111-ps2",
24865 -               .bus            = &sa1111_bus_type,
24866 -               .probe          = ps2_probe,
24867 -               .remove         = ps2_remove,
24868 -               .suspend        = ps2_suspend,
24869 -               .resume         = ps2_resume,
24870 +               .name   = "sa1111-ps2",
24871         },
24872 -       .devid                  = SA1111_DEVID_PS2,
24873 +       .devid          = SA1111_DEVID_PS2,
24874 +       .probe          = ps2_probe,
24875 +       .remove         = ps2_remove,
24876  };
24877  
24878  static int __init ps2_init(void)
24879  {
24880 -       return driver_register(&ps2_driver.drv);
24881 +       return sa1111_driver_register(&ps2_driver);
24882  }
24883  
24884  static void __exit ps2_exit(void)
24885  {
24886 -       driver_unregister(&ps2_driver.drv);
24887 +       sa1111_driver_unregister(&ps2_driver);
24888  }
24889  
24890  module_init(ps2_init);
24891 diff -Nru a/drivers/input/tsdev.c b/drivers/input/tsdev.c
24892 --- a/drivers/input/tsdev.c     Fri May  2 06:55:04 2003
24893 +++ b/drivers/input/tsdev.c     Tue Aug 26 09:25:41 2003
24894 @@ -96,7 +96,7 @@
24895  
24896  static int tsdev_open(struct inode *inode, struct file *file)
24897  {
24898 -       int i = minor(inode->i_rdev) - TSDEV_MINOR_BASE;
24899 +       int i = iminor(inode) - TSDEV_MINOR_BASE;
24900         struct tsdev_list *list;
24901  
24902         if (i >= TSDEV_MINORS || !tsdev_table[i])
24903 diff -Nru a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig
24904 --- a/drivers/isdn/Kconfig      Tue Nov 12 12:48:13 2002
24905 +++ b/drivers/isdn/Kconfig      Mon Aug 25 05:49:31 2003
24906 @@ -22,7 +22,7 @@
24907  
24908  
24909  menu "Old ISDN4Linux"
24910 -       depends on NET && ISDN_BOOL
24911 +       depends on NET && ISDN_BOOL && BROKEN_ON_SMP
24912  
24913  config ISDN
24914         tristate "Old ISDN4Linux (obsolete)"
24915 diff -Nru a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
24916 --- a/drivers/isdn/capi/capi.c  Wed Jun 11 12:32:56 2003
24917 +++ b/drivers/isdn/capi/capi.c  Tue Aug 26 09:25:41 2003
24918 @@ -964,7 +964,7 @@
24919  {
24920         struct capiminor *mp;
24921  
24922 -       if ((mp = capiminor_find(minor(file->f_dentry->d_inode->i_rdev))) == 0)
24923 +       if ((mp = capiminor_find(iminor(file->f_dentry->d_inode))) == 0)
24924                 return -ENXIO;
24925         if (mp->nccip == 0)
24926                 return -ENXIO;
24927 diff -Nru a/drivers/isdn/hardware/avm/Kconfig b/drivers/isdn/hardware/avm/Kconfig
24928 --- a/drivers/isdn/hardware/avm/Kconfig Thu Nov 14 08:10:48 2002
24929 +++ b/drivers/isdn/hardware/avm/Kconfig Mon Aug 25 07:15:22 2003
24930 @@ -12,13 +12,13 @@
24931  
24932  config ISDN_DRV_AVMB1_B1ISA
24933         tristate "AVM B1 ISA support"
24934 -       depends on CAPI_AVM && ISDN_CAPI && ISA
24935 +       depends on CAPI_AVM && ISDN_CAPI && ISA && BROKEN_ON_SMP
24936         help
24937           Enable support for the ISA version of the AVM B1 card.
24938  
24939  config ISDN_DRV_AVMB1_B1PCI
24940         tristate "AVM B1 PCI support"
24941 -       depends on CAPI_AVM && ISDN_CAPI && PCI
24942 +       depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
24943         help
24944           Enable support for the PCI version of the AVM B1 card.
24945  
24946 @@ -30,14 +30,14 @@
24947  
24948  config ISDN_DRV_AVMB1_T1ISA
24949         tristate "AVM T1/T1-B ISA support"
24950 -       depends on CAPI_AVM && ISDN_CAPI && ISA
24951 +       depends on CAPI_AVM && ISDN_CAPI && ISA && BROKEN_ON_SMP
24952         help
24953           Enable support for the AVM T1 T1B card.
24954           Note: This is a PRI card and handle 30 B-channels.
24955  
24956  config ISDN_DRV_AVMB1_B1PCMCIA
24957         tristate "AVM B1/M1/M2 PCMCIA support"
24958 -       depends on CAPI_AVM && ISDN_CAPI
24959 +       depends on CAPI_AVM && ISDN_CAPI && BROKEN_ON_SMP
24960         help
24961           Enable support for the PCMCIA version of the AVM B1 card.
24962  
24963 @@ -50,14 +50,14 @@
24964  
24965  config ISDN_DRV_AVMB1_T1PCI
24966         tristate "AVM T1/T1-B PCI support"
24967 -       depends on CAPI_AVM && ISDN_CAPI && PCI
24968 +       depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
24969         help
24970           Enable support for the AVM T1 T1B card.
24971           Note: This is a PRI card and handle 30 B-channels.
24972  
24973  config ISDN_DRV_AVMB1_C4
24974         tristate "AVM C4/C2 support"
24975 -       depends on CAPI_AVM && ISDN_CAPI && PCI
24976 +       depends on CAPI_AVM && ISDN_CAPI && PCI && BROKEN_ON_SMP
24977         help
24978           Enable support for the AVM C4/C2 PCI cards.
24979           These cards handle 4/2 BRI ISDN lines (8/4 channels).
24980 diff -Nru a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c
24981 --- a/drivers/isdn/hardware/eicon/divasi.c      Mon Jul 21 12:08:32 2003
24982 +++ b/drivers/isdn/hardware/eicon/divasi.c      Tue Aug 26 09:25:41 2003
24983 @@ -432,7 +432,7 @@
24984  
24985  static int um_idi_release(struct inode *inode, struct file *file)
24986  {
24987 -       unsigned int adapter_nr = minor(inode->i_rdev);
24988 +       unsigned int adapter_nr = iminor(inode);
24989         int ret = 0;
24990  
24991         if (!(file->private_data)) {
24992 diff -Nru a/drivers/isdn/i4l/Kconfig b/drivers/isdn/i4l/Kconfig
24993 --- a/drivers/isdn/i4l/Kconfig  Sat Feb 22 09:17:33 2003
24994 +++ b/drivers/isdn/i4l/Kconfig  Sun Aug 24 00:59:46 2003
24995 @@ -106,6 +106,7 @@
24996  
24997  config ISDN_DIVERSION
24998         tristate "Support isdn diversion services"
24999 +       depends on BROKEN
25000         help
25001           This option allows you to use some supplementary diversion
25002           services in conjunction with the HiSax driver on an EURO/DSS1
25003 diff -Nru a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
25004 --- a/drivers/isdn/i4l/isdn_common.c    Mon Jul 21 11:39:14 2003
25005 +++ b/drivers/isdn/i4l/isdn_common.c    Tue Aug 26 09:25:41 2003
25006 @@ -1432,7 +1432,7 @@
25007  static int
25008  isdn_ctrl_open(struct inode *ino, struct file *file)
25009  {
25010 -       unsigned int minor = minor(ino->i_rdev);
25011 +       unsigned int minor = iminor(ino);
25012         struct isdn_slot *slot = get_slot_by_minor(minor - ISDN_MINOR_CTRL);
25013  
25014         if (!slot)
25015 @@ -1795,7 +1795,7 @@
25016  static int
25017  isdn_open(struct inode * inode, struct file * file)
25018  {
25019 -       int minor = minor(inode->i_rdev);
25020 +       int minor = iminor(inode);
25021         int err = -ENODEV;
25022         struct file_operations *old_fops, *new_fops = NULL;
25023         
25024 diff -Nru a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
25025 --- a/drivers/isdn/i4l/isdn_ppp.c       Tue Jul 15 10:01:29 2003
25026 +++ b/drivers/isdn/i4l/isdn_ppp.c       Tue Aug 26 09:25:41 2003
25027 @@ -119,7 +119,7 @@
25028  ipppd_open(struct inode *ino, struct file *file)
25029  {
25030         unsigned long flags;
25031 -       unsigned int minor = minor(ino->i_rdev) - ISDN_MINOR_PPP;
25032 +       unsigned int minor = iminor(ino) - ISDN_MINOR_PPP;
25033         struct ipppd *ipppd;
25034  
25035         ipppd = kmalloc(sizeof(*ipppd), GFP_KERNEL);
25036 diff -Nru a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
25037 --- a/drivers/macintosh/adb.c   Sat Jun  7 00:45:03 2003
25038 +++ b/drivers/macintosh/adb.c   Tue Aug 26 09:25:41 2003
25039 @@ -712,7 +712,7 @@
25040  {
25041         struct adbdev_state *state;
25042  
25043 -       if (minor(inode->i_rdev) > 0 || adb_controller == NULL)
25044 +       if (iminor(inode) > 0 || adb_controller == NULL)
25045                 return -ENXIO;
25046         state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
25047         if (state == 0)
25048 diff -Nru a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
25049 --- a/drivers/macintosh/macio_asic.c    Sat Aug 16 11:47:51 2003
25050 +++ b/drivers/macintosh/macio_asic.c    Tue Aug 26 06:35:38 2003
25051 @@ -23,6 +23,8 @@
25052  #include <asm/prom.h>
25053  #include <asm/pci-bridge.h>
25054  
25055 +static struct macio_chip      *macio_on_hold;
25056 +
25057  static int
25058  macio_bus_match(struct device *dev, struct device_driver *drv) 
25059  {
25060 @@ -36,21 +38,27 @@
25061         return of_match_device(matches, &macio_dev->ofdev) != NULL;
25062  }
25063  
25064 -struct bus_type macio_bus_type = {
25065 -       name:   "macio",
25066 -       match:  macio_bus_match,
25067 -};
25068 +struct macio_dev *macio_dev_get(struct macio_dev *dev)
25069 +{
25070 +       struct device *tmp;
25071  
25072 -static int __init
25073 -macio_bus_driver_init(void)
25074 +       if (!dev)
25075 +               return NULL;
25076 +       tmp = get_device(&dev->ofdev.dev);
25077 +       if (tmp)
25078 +               return to_macio_device(tmp);
25079 +       else
25080 +               return NULL;
25081 +}
25082 +
25083 +void macio_dev_put(struct macio_dev *dev)
25084  {
25085 -       return bus_register(&macio_bus_type);
25086 +       if (dev)
25087 +               put_device(&dev->ofdev.dev);
25088  }
25089  
25090 -postcore_initcall(macio_bus_driver_init);
25091  
25092 -static int
25093 -macio_device_probe(struct device *dev)
25094 +static int macio_device_probe(struct device *dev)
25095  {
25096         int error = -ENODEV;
25097         struct macio_driver *drv;
25098 @@ -63,55 +71,89 @@
25099         if (!drv->probe)
25100                 return error;
25101  
25102 -/*     if (!try_module_get(driver->owner)) {
25103 -               printk(KERN_ERR "Can't get a module reference for %s\n", driver->name);
25104 -               return error;
25105 -       }
25106 -*/
25107 +       macio_dev_get(macio_dev);
25108 +
25109         match = of_match_device(drv->match_table, &macio_dev->ofdev);
25110         if (match)
25111                 error = drv->probe(macio_dev, match);
25112 -/*
25113 -       module_put(driver->owner);
25114 -*/     
25115 +       if (error)
25116 +               macio_dev_put(macio_dev);
25117 +
25118         return error;
25119  }
25120  
25121 -static int
25122 -macio_device_remove(struct device *dev)
25123 +static int macio_device_remove(struct device *dev)
25124  {
25125         struct macio_dev * macio_dev = to_macio_device(dev);
25126         struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
25127  
25128         if (drv && drv->remove)
25129                 drv->remove(macio_dev);
25130 +       macio_dev_put(macio_dev);
25131 +
25132         return 0;
25133  }
25134  
25135 -static int
25136 -macio_device_suspend(struct device *dev, u32 state, u32 level)
25137 +static int macio_device_suspend(struct device *dev, u32 state)
25138  {
25139         struct macio_dev * macio_dev = to_macio_device(dev);
25140 -       struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
25141 +       struct macio_driver * drv;
25142         int error = 0;
25143  
25144 -       if (drv && drv->suspend)
25145 -               error = drv->suspend(macio_dev, state, level);
25146 +       if (macio_dev->ofdev.dev.driver == NULL)
25147 +               return 0;
25148 +       drv = to_macio_driver(macio_dev->ofdev.dev.driver);
25149 +       if (drv->suspend)
25150 +               error = drv->suspend(macio_dev, state);
25151         return error;
25152  }
25153  
25154 -static int
25155 -macio_device_resume(struct device * dev, u32 level)
25156 +static int macio_device_resume(struct device * dev)
25157  {
25158         struct macio_dev * macio_dev = to_macio_device(dev);
25159 -       struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
25160 +       struct macio_driver * drv;
25161         int error = 0;
25162  
25163 -       if (drv && drv->resume)
25164 -               error = drv->resume(macio_dev, level);
25165 +       if (macio_dev->ofdev.dev.driver == NULL)
25166 +               return 0;
25167 +       drv = to_macio_driver(macio_dev->ofdev.dev.driver);
25168 +       if (drv->resume)
25169 +               error = drv->resume(macio_dev);
25170         return error;
25171  }
25172  
25173 +struct bus_type macio_bus_type = {
25174 +       .name   = "macio",
25175 +       .match  = macio_bus_match,
25176 +       .suspend        = macio_device_suspend,
25177 +       .resume = macio_device_resume,
25178 +};
25179 +
25180 +static int __init
25181 +macio_bus_driver_init(void)
25182 +{
25183 +       return bus_register(&macio_bus_type);
25184 +}
25185 +
25186 +postcore_initcall(macio_bus_driver_init);
25187 +
25188 +
25189 +/**
25190 + * macio_release_dev - free a macio device structure when all users of it are finished.
25191 + * @dev: device that's been disconnected
25192 + *
25193 + * Will be called only by the device core when all users of this macio device are
25194 + * done. This currently means never as we don't hot remove any macio device yet,
25195 + * though that will happen with mediabay based devices in a later implementation.
25196 + */
25197 +static void macio_release_dev(struct device *dev)
25198 +{
25199 +       struct macio_dev *mdev;
25200 +
25201 +        mdev = to_macio_device(dev);
25202 +       kfree(mdev);
25203 +}
25204 +
25205  /**
25206   * macio_add_one_device - Add one device from OF node to the device tree
25207   * @chip: pointer to the macio_chip holding the device
25208 @@ -121,13 +163,15 @@
25209   * When media-bay is changed to hotswap drivers, this function will
25210   * be exposed to the bay driver some way...
25211   */
25212 -static struct macio_dev *
25213 -macio_add_one_device(struct macio_chip *chip, struct device *parent,
25214 +static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct device *parent,
25215                      struct device_node *np, struct macio_dev *in_bay)
25216  {
25217         struct macio_dev *dev;
25218         u32 *reg;
25219         
25220 +       if (np == NULL)
25221 +               return NULL;
25222 +
25223         dev = kmalloc(sizeof(*dev), GFP_KERNEL);
25224         if (!dev)
25225                 return NULL;
25226 @@ -140,6 +184,7 @@
25227         dev->ofdev.dev.dma_mask = &dev->ofdev.dma_mask;
25228         dev->ofdev.dev.parent = parent;
25229         dev->ofdev.dev.bus = &macio_bus_type;
25230 +       dev->ofdev.dev.release = macio_release_dev;
25231  
25232         /* MacIO itself has a different reg, we use it's PCI base */
25233         if (np == chip->of_node) {
25234 @@ -164,8 +209,7 @@
25235         return dev;
25236  }
25237  
25238 -static int
25239 -macio_skip_device(struct device_node *np)
25240 +static int macio_skip_device(struct device_node *np)
25241  {
25242         if (strncmp(np->name, "battery", 7) == 0)
25243                 return 1;
25244 @@ -185,10 +229,9 @@
25245   * For now, childs of media-bay are added now as well. This will
25246   * change rsn though.
25247   */
25248 -static void
25249 -macio_pci_add_devices(struct macio_chip *chip)
25250 +static void macio_pci_add_devices(struct macio_chip *chip)
25251  {
25252 -       struct device_node *np;
25253 +       struct device_node *np, *pnode;
25254         struct macio_dev *rdev, *mdev, *mbdev = NULL, *sdev = NULL;
25255         struct device *parent = NULL;
25256         
25257 @@ -196,16 +239,23 @@
25258  #ifdef CONFIG_PCI
25259         if (chip->lbus.pdev)
25260                 parent = &chip->lbus.pdev->dev;
25261 -#endif         
25262 -       rdev = macio_add_one_device(chip, parent, chip->of_node, NULL);
25263 +#endif
25264 +       pnode = of_node_get(chip->of_node);
25265 +       if (pnode == NULL)
25266 +               return;
25267 +
25268 +       rdev = macio_add_one_device(chip, parent, pnode, NULL);
25269         if (rdev == NULL)
25270                 return;
25271  
25272         /* First scan 1st level */
25273 -       for (np = chip->of_node->child; np != NULL; np = np->sibling) {
25274 +       for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) {
25275                 if (!macio_skip_device(np)) {
25276 +                       of_node_get(np);
25277                         mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL);
25278 -                       if (strncmp(np->name, "media-bay", 9) == 0)
25279 +                       if (mdev == NULL)
25280 +                               of_node_put(np);
25281 +                       else if (strncmp(np->name, "media-bay", 9) == 0)
25282                                 mbdev = mdev;
25283                         else if (strncmp(np->name, "escc", 4) == 0)
25284                                 sdev = mdev;
25285 @@ -213,17 +263,21 @@
25286         }
25287  
25288         /* Add media bay devices if any */
25289 -       if (mbdev) {
25290 -               for (np = mbdev->ofdev.node->child; np != NULL; np = np->sibling)
25291 -                       if (!macio_skip_device(np))
25292 -                               macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev);
25293 -       }
25294 +       if (mbdev)
25295 +               for (np = NULL; (np = of_get_next_child(mbdev->ofdev.node, np)) != NULL;)
25296 +                       if (!macio_skip_device(np)) {
25297 +                               of_node_get(np);
25298 +                               if (macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev) == NULL)
25299 +                                       of_node_put(np);
25300 +                       }
25301         /* Add serial ports if any */
25302 -       if (sdev) {
25303 -               for (np = sdev->ofdev.node->child; np != NULL; np = np->sibling)
25304 -                       if (!macio_skip_device(np))
25305 -                               macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL);
25306 -       }
25307 +       if (sdev)
25308 +               for (np = NULL; (np = of_get_next_child(sdev->ofdev.node, np)) != NULL;)
25309 +                       if (!macio_skip_device(np)) {
25310 +                               of_node_get(np);
25311 +                               if (macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL) == NULL)
25312 +                                       of_node_put(np);
25313 +                       }
25314  }
25315  
25316  
25317 @@ -231,8 +285,7 @@
25318   * macio_register_driver - Registers a new MacIO device driver
25319   * @drv: pointer to the driver definition structure
25320   */
25321 -int
25322 -macio_register_driver(struct macio_driver *drv)
25323 +int macio_register_driver(struct macio_driver *drv)
25324  {
25325         int count = 0;
25326  
25327 @@ -240,8 +293,6 @@
25328         drv->driver.name = drv->name;
25329         drv->driver.bus = &macio_bus_type;
25330         drv->driver.probe = macio_device_probe;
25331 -       drv->driver.resume = macio_device_resume;
25332 -       drv->driver.suspend = macio_device_suspend;
25333         drv->driver.remove = macio_device_remove;
25334  
25335         /* register with core */
25336 @@ -253,16 +304,14 @@
25337   * macio_unregister_driver - Unregisters a new MacIO device driver
25338   * @drv: pointer to the driver definition structure
25339   */
25340 -void
25341 -macio_unregister_driver(struct macio_driver *drv)
25342 +void macio_unregister_driver(struct macio_driver *drv)
25343  {
25344         driver_unregister(&drv->driver);
25345  }
25346  
25347  #ifdef CONFIG_PCI
25348  
25349 -static int __devinit
25350 -macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
25351 +static int __devinit macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
25352  {
25353         struct device_node* np;
25354         struct macio_chip* chip;
25355 @@ -270,19 +319,27 @@
25356         if (ent->vendor != PCI_VENDOR_ID_APPLE)
25357                 return -ENODEV;
25358  
25359 +       /* Note regarding refcounting: We assume pci_device_to_OF_node() is ported
25360 +        * to new OF APIs and returns a node with refcount incremented. This isn't
25361 +        * the case today, but on the other hand ppc32 doesn't do refcounting. This
25362 +        * will have to be fixed when going to ppc64. --BenH.
25363 +        */
25364         np = pci_device_to_OF_node(pdev);
25365         if (np == NULL)
25366                 return -ENODEV;
25367  
25368 +       /* We also assume that pmac_feature will have done a get() on nodes stored
25369 +        * in the macio chips array
25370 +        */
25371         chip = macio_find(np, macio_unknown);
25372 +               of_node_put(np);
25373         if (chip == NULL)
25374                 return -ENODEV;
25375  
25376 -       /* XXX Need locking */
25377 +       /* XXX Need locking ??? */
25378         if (chip->lbus.pdev == NULL) {
25379                 chip->lbus.pdev = pdev;
25380                 chip->lbus.chip = chip;
25381 -//             INIT_LIST_HEAD(&chip->lbus.devices);
25382                 pci_set_drvdata(pdev, &chip->lbus);
25383                 pci_set_master(pdev);
25384         }
25385 @@ -290,13 +347,28 @@
25386         printk(KERN_INFO "MacIO PCI driver attached to %s chipset\n",
25387                 chip->name);
25388  
25389 +       /*
25390 +        * HACK ALERT: The WallStreet PowerBook and some OHare based machines
25391 +        * have 2 macio ASICs. I must probe the "main" one first or IDE ordering
25392 +        * will be incorrect. So I put on "hold" the second one since it seem to
25393 +        * appear first on PCI
25394 +        */
25395 +       if (chip->type == macio_gatwick || chip->type == macio_ohareII)
25396 +               if (macio_chips[0].lbus.pdev == NULL) {
25397 +                       macio_on_hold = chip;
25398 +                       return 0;
25399 +               }
25400 +
25401         macio_pci_add_devices(chip);
25402 +       if (macio_on_hold && macio_chips[0].lbus.pdev != NULL) {
25403 +               macio_pci_add_devices(macio_on_hold);
25404 +               macio_on_hold = NULL;
25405 +       }
25406  
25407         return 0;
25408  }
25409  
25410 -static void __devexit
25411 -macio_pci_remove(struct pci_dev* pdev)
25412 +static void __devexit macio_pci_remove(struct pci_dev* pdev)
25413  {
25414         panic("removing of macio-asic not supported !\n");
25415  }
25416 @@ -306,10 +378,10 @@
25417   * will then decide wether it applies or not
25418   */
25419  static const struct pci_device_id __devinitdata pci_ids [] = { {
25420 -       .vendor =       PCI_VENDOR_ID_APPLE,
25421 -       .device =       PCI_ANY_ID,
25422 -       .subvendor =    PCI_ANY_ID,
25423 -       .subdevice =    PCI_ANY_ID,
25424 +       .vendor         = PCI_VENDOR_ID_APPLE,
25425 +       .device         = PCI_ANY_ID,
25426 +       .subvendor      = PCI_ANY_ID,
25427 +       .subdevice      = PCI_ANY_ID,
25428  
25429         }, { /* end: all zeroes */ }
25430  };
25431 @@ -317,17 +389,16 @@
25432  
25433  /* pci driver glue; this is a "new style" PCI driver module */
25434  static struct pci_driver macio_pci_driver = {
25435 -       .name =         (char *) "macio",
25436 -       .id_table =     pci_ids,
25437 +       .name           = (char *) "macio",
25438 +       .id_table       = pci_ids,
25439  
25440 -       .probe =        macio_pci_probe,
25441 -       .remove =       macio_pci_remove,
25442 +       .probe          = macio_pci_probe,
25443 +       .remove         = macio_pci_remove,
25444  };
25445  
25446  #endif /* CONFIG_PCI */
25447  
25448 -static int __init
25449 -macio_module_init (void) 
25450 +static int __init macio_module_init (void) 
25451  {
25452  #ifdef CONFIG_PCI
25453         int rc;
25454 @@ -339,17 +410,9 @@
25455         return 0;
25456  }
25457  
25458 -/*
25459 -static void __exit
25460 -macio_module_cleanup (void) 
25461 -{      
25462 -#ifdef CONFIG_PCI
25463 -       pci_unregister_driver(&macio_pci_driver);
25464 -#endif
25465 -}
25466 -module_exit(macio_module_cleanup);
25467 -*/
25468  module_init(macio_module_init);
25469  
25470  EXPORT_SYMBOL(macio_register_driver);
25471  EXPORT_SYMBOL(macio_unregister_driver);
25472 +EXPORT_SYMBOL(macio_dev_get);
25473 +EXPORT_SYMBOL(macio_dev_put);
25474 diff -Nru a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
25475 --- a/drivers/macintosh/mediabay.c      Sat Mar 22 01:11:14 2003
25476 +++ b/drivers/macintosh/mediabay.c      Mon Aug 25 09:51:43 2003
25477 @@ -37,15 +37,7 @@
25478  #include <linux/adb.h>
25479  #include <linux/pmu.h>
25480  
25481 -#ifdef CONFIG_PMAC_PBOOK
25482 -static int mb_notify_sleep(struct pmu_sleep_notifier *self, int when);
25483 -static struct pmu_sleep_notifier mb_sleep_notifier = {
25484 -       mb_notify_sleep,
25485 -       SLEEP_LEVEL_MEDIABAY,
25486 -};
25487 -#endif
25488  
25489 -#undef MB_USE_INTERRUPTS
25490  #define MB_DEBUG
25491  #define MB_IGNORE_SIGNALS
25492  
25493 @@ -55,13 +47,6 @@
25494  #define MBDBG(fmt, arg...)     do { } while (0)
25495  #endif
25496  
25497 -/* Type of media bay */
25498 -enum {
25499 -       mb_ohare,
25500 -       mb_heathrow,
25501 -       mb_keylargo
25502 -};
25503 -
25504  #define MB_FCR32(bay, r)       ((bay)->base + ((r) >> 2))
25505  #define MB_FCR8(bay, r)                (((volatile u8*)((bay)->base)) + (r))
25506  
25507 @@ -76,11 +61,12 @@
25508  
25509  struct mb_ops {
25510         char*   name;
25511 -       u8      (*content)(struct media_bay_info* bay);
25512 -       void    (*power)(struct media_bay_info* bay, int on_off);
25513 -       int     (*setup_bus)(struct media_bay_info* bay, u8 device_id);
25514 -       void    (*un_reset)(struct media_bay_info* bay);
25515 -       void    (*un_reset_ide)(struct media_bay_info* bay);
25516 +       void    (*init)(struct media_bay_info *bay);
25517 +       u8      (*content)(struct media_bay_info *bay);
25518 +       void    (*power)(struct media_bay_info *bay, int on_off);
25519 +       int     (*setup_bus)(struct media_bay_info *bay, u8 device_id);
25520 +       void    (*un_reset)(struct media_bay_info *bay);
25521 +       void    (*un_reset_ide)(struct media_bay_info *bay);
25522  };
25523  
25524  struct media_bay_info {
25525 @@ -90,11 +76,12 @@
25526         int                             last_value;
25527         int                             value_count;
25528         int                             timer;
25529 -       struct device_node*             dev_node;
25530 -       int                             mb_type;
25531 +       struct macio_dev                *mdev;
25532         struct mb_ops*                  ops;
25533         int                             index;
25534         int                             cached_gpio;
25535 +       int                             sleeping;
25536 +       struct semaphore                lock;
25537  #ifdef CONFIG_BLK_DEV_IDE
25538         unsigned long                   cd_base;
25539         int                             cd_index;
25540 @@ -111,13 +98,13 @@
25541  #ifdef CONFIG_BLK_DEV_IDE
25542  /* check the busy bit in the media-bay ide interface
25543     (assumes the media-bay contains an ide device) */
25544 -#define MB_IDE_READY(i)        ((inb(media_bays[i].cd_base + 0x70) & 0x80) == 0)
25545 +#define MB_IDE_READY(i)        ((readb(media_bays[i].cd_base + 0x70) & 0x80) == 0)
25546  #endif
25547  
25548  /* Note: All delays are not in milliseconds and converted to HZ relative
25549   * values by the macro below
25550   */
25551 -#define MS_TO_HZ(ms)   ((ms * HZ) / 1000)
25552 +#define MS_TO_HZ(ms)   ((ms * HZ + 999) / 1000)
25553  
25554  /*
25555   * Consider the media-bay ID value stable if it is the same for
25556 @@ -352,38 +339,37 @@
25557         MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
25558  }
25559  
25560 -static void __pmac
25561 -heathrow_mb_un_reset(struct media_bay_info* bay)
25562 +static void __pmac keylargo_mb_init(struct media_bay_info *bay)
25563 +{
25564 +       MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
25565 +}
25566 +
25567 +static void __pmac heathrow_mb_un_reset(struct media_bay_info* bay)
25568  {
25569         MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
25570  }
25571  
25572 -static void __pmac
25573 -keylargo_mb_un_reset(struct media_bay_info* bay)
25574 +static void __pmac keylargo_mb_un_reset(struct media_bay_info* bay)
25575  {
25576         MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
25577  }
25578  
25579 -static void __pmac
25580 -ohare_mb_un_reset_ide(struct media_bay_info* bay)
25581 +static void __pmac ohare_mb_un_reset_ide(struct media_bay_info* bay)
25582  {
25583         MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
25584  }
25585  
25586 -static void __pmac
25587 -heathrow_mb_un_reset_ide(struct media_bay_info* bay)
25588 +static void __pmac heathrow_mb_un_reset_ide(struct media_bay_info* bay)
25589  {
25590         MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
25591  }
25592  
25593 -static void __pmac
25594 -keylargo_mb_un_reset_ide(struct media_bay_info* bay)
25595 +static void __pmac keylargo_mb_un_reset_ide(struct media_bay_info* bay)
25596  {
25597         MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
25598  }
25599  
25600 -static inline void __pmac
25601 -set_mb_power(struct media_bay_info* bay, int onoff)
25602 +static inline void __pmac set_mb_power(struct media_bay_info* bay, int onoff)
25603  {
25604         /* Power up up and assert the bay reset line */
25605         if (onoff) {
25606 @@ -399,8 +385,7 @@
25607         bay->timer = MS_TO_HZ(MB_POWER_DELAY);
25608  }
25609  
25610 -static void __pmac
25611 -poll_media_bay(struct media_bay_info* bay)
25612 +static void __pmac poll_media_bay(struct media_bay_info* bay)
25613  {
25614         int id = bay->ops->content(bay);
25615  
25616 @@ -429,15 +414,13 @@
25617         }
25618  }
25619  
25620 -int __pmac
25621 -check_media_bay(struct device_node *which_bay, int what)
25622 +int __pmac check_media_bay(struct device_node *which_bay, int what)
25623  {
25624  #ifdef CONFIG_BLK_DEV_IDE
25625         int     i;
25626  
25627         for (i=0; i<media_bay_count; i++)
25628 -               if (which_bay == media_bays[i].dev_node)
25629 -               {
25630 +               if (media_bays[i].mdev && which_bay == media_bays[i].mdev->ofdev.node) {
25631                         if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
25632                                 return 0;
25633                         media_bays[i].cd_index = -1;
25634 @@ -447,15 +430,13 @@
25635         return -ENODEV;
25636  }
25637  
25638 -int __pmac
25639 -check_media_bay_by_base(unsigned long base, int what)
25640 +int __pmac check_media_bay_by_base(unsigned long base, int what)
25641  {
25642  #ifdef CONFIG_BLK_DEV_IDE
25643         int     i;
25644  
25645         for (i=0; i<media_bay_count; i++)
25646 -               if (base == media_bays[i].cd_base)
25647 -               {
25648 +               if (media_bays[i].mdev && base == media_bays[i].cd_base) {
25649                         if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
25650                                 return 0;
25651                         media_bays[i].cd_index = -1;
25652 @@ -466,42 +447,47 @@
25653         return -ENODEV;
25654  }
25655  
25656 -int __pmac
25657 -media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
25658 +int __pmac media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
25659         int irq, int index)
25660  {
25661  #ifdef CONFIG_BLK_DEV_IDE
25662         int     i;
25663  
25664 -       for (i=0; i<media_bay_count; i++)
25665 -               if (which_bay == media_bays[i].dev_node)
25666 -               {
25667 +       for (i=0; i<media_bay_count; i++) {
25668 +               struct media_bay_info* bay = &media_bays[i];
25669 +
25670 +               if (bay->mdev && which_bay == bay->mdev->ofdev.node) {
25671                         int timeout = 5000;
25672                         
25673 -                       media_bays[i].cd_base   = base;
25674 -                       media_bays[i].cd_irq    = irq;
25675 +                       down(&bay->lock);
25676  
25677 -                       if ((MB_CD != media_bays[i].content_id) || media_bays[i].state != mb_up)
25678 -                               return 0;
25679 +                       bay->cd_base    = base;
25680 +                       bay->cd_irq     = irq;
25681  
25682 -                       printk(KERN_DEBUG "Registered ide %d for media bay %d\n", index, i);
25683 +                       if ((MB_CD != bay->content_id) || bay->state != mb_up) {
25684 +                               up(&bay->lock);
25685 +                               return 0;
25686 +                       }
25687 +                       printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i);
25688                         do {
25689                                 if (MB_IDE_READY(i)) {
25690 -                                       media_bays[i].cd_index  = index;
25691 +                                       bay->cd_index   = index;
25692 +                                       up(&bay->lock);
25693                                         return 0;
25694                                 }
25695                                 mdelay(1);
25696                         } while(--timeout);
25697                         printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i);
25698 +                       up(&bay->lock);
25699                         return -ENODEV;
25700                 }
25701 -#endif
25702 +       }
25703 +#endif /* CONFIG_BLK_DEV_IDE */
25704         
25705         return -ENODEV;
25706  }
25707  
25708 -static void __pmac
25709 -media_bay_step(int i)
25710 +static void __pmac media_bay_step(int i)
25711  {
25712         struct media_bay_info* bay = &media_bays[i];
25713  
25714 @@ -567,6 +553,7 @@
25715                         if (bay->cd_index < 0) {
25716                                 hw_regs_t hw;
25717  
25718 +                               printk("mediabay %d, registering IDE...\n", i);
25719                                 pmu_suspend();
25720                                 ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL);
25721                                 hw.irq = bay->cd_irq;
25722 @@ -580,13 +567,15 @@
25723                                 printk("IDE register error\n");
25724                                 set_mb_power(bay, 0);
25725                         } else {
25726 -                               printk(KERN_DEBUG "media-bay %d is ide %d\n", i, bay->cd_index);
25727 +                               printk(KERN_DEBUG "media-bay %d is ide%d\n", i, bay->cd_index);
25728                                 MBDBG("mediabay %d IDE ready\n", i);
25729                         }
25730                         break;
25731 -               }
25732 +               } else if (bay->timer > 0)
25733 +                       bay->timer--;
25734                 if (bay->timer == 0) {
25735 -                       printk("\nIDE Timeout in bay %d !\n", i);
25736 +                       printk("\nIDE Timeout in bay %d !, IDE state is: 0x%02x\n",
25737 +                              i, readb(bay->cd_base + 0x70));
25738                         MBDBG("mediabay%d: nIDE Timeout !\n", i);
25739                         set_mb_power(bay, 0);
25740                 }
25741 @@ -623,8 +612,7 @@
25742   * with the IDE driver.  It needs to be a thread because
25743   * ide_register can't be called from interrupt context.
25744   */
25745 -static int __pmac
25746 -media_bay_task(void *x)
25747 +static int __pmac media_bay_task(void *x)
25748  {
25749         int     i;
25750  
25751 @@ -634,75 +622,140 @@
25752  #endif
25753  
25754         for (;;) {
25755 -               for (i = 0; i < media_bay_count; ++i)
25756 -                       media_bay_step(i);
25757 +               for (i = 0; i < media_bay_count; ++i) {
25758 +                       down(&media_bays[i].lock);
25759 +                       if (!media_bays[i].sleeping)
25760 +                               media_bay_step(i);
25761 +                       up(&media_bays[i].lock);
25762 +               }
25763  
25764                 current->state = TASK_INTERRUPTIBLE;
25765 -               schedule_timeout(1);
25766 +               schedule_timeout(MS_TO_HZ(10));
25767                 if (signal_pending(current))
25768                         return 0;
25769         }
25770  }
25771  
25772 -#ifdef MB_USE_INTERRUPTS
25773 -static void __pmac
25774 -media_bay_intr(int irq, void *devid, struct pt_regs *regs)
25775 -{
25776 -}
25777 -#endif
25778 -
25779 -#ifdef CONFIG_PMAC_PBOOK
25780 -/*
25781 - * notify clients before sleep and reset bus afterwards
25782 - */
25783 -int __pmac
25784 -mb_notify_sleep(struct pmu_sleep_notifier *self, int when)
25785 +static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_match *match)
25786  {
25787         struct media_bay_info* bay;
25788 +       volatile u32 *regbase;
25789 +       struct device_node *ofnode;
25790         int i;
25791 +
25792 +       ofnode = mdev->ofdev.node;
25793 +
25794 +       if (!request_OF_resource(ofnode, 0, NULL))
25795 +               return -ENXIO;
25796 +
25797 +       /* Media bay registers are located at the beginning of the
25798 +         * mac-io chip, we get the parent address for now (hrm...)
25799 +         */
25800 +       if (ofnode->parent->n_addrs == 0)
25801 +               return -ENODEV;
25802 +       regbase = (volatile u32 *)ioremap(ofnode->parent->addrs[0].address, 0x100);
25803 +       if (regbase == NULL) {
25804 +               release_OF_resource(ofnode, 0);
25805 +               return -ENOMEM;
25806 +       }
25807         
25808 -       switch (when) {
25809 -       case PBOOK_SLEEP_REQUEST:
25810 -       case PBOOK_SLEEP_REJECT:
25811 -               break;
25812 -               
25813 -       case PBOOK_SLEEP_NOW:
25814 -               for (i=0; i<media_bay_count; i++) {
25815 -                       bay = &media_bays[i];
25816 -                       set_mb_power(bay, 0);
25817 -                       mdelay(10);
25818 -               }
25819 -               break;
25820 -       case PBOOK_WAKE:
25821 -               for (i=0; i<media_bay_count; i++) {
25822 -                       bay = &media_bays[i];
25823 -                       /* We re-enable the bay using it's previous content
25824 -                          only if it did not change. Note those bozo timings,
25825 -                          they seem to help the 3400 get it right.
25826 -                        */
25827 -                       /* Force MB power to 0 */
25828 -                       set_mb_power(bay, 0);
25829 -                       mdelay(MB_POWER_DELAY);
25830 -                       if (bay->ops->content(bay) != bay->content_id)
25831 -                               continue;
25832 -                       set_mb_power(bay, 1);
25833 -                       bay->last_value = bay->content_id;
25834 -                       bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
25835 -                       bay->timer = MS_TO_HZ(MB_POWER_DELAY);
25836 -#ifdef CONFIG_BLK_DEV_IDE
25837 -                       bay->cd_retry = 0;
25838 -#endif
25839 -                       do {
25840 -                               mdelay(1000/HZ);
25841 -                               media_bay_step(i);
25842 -                       } while((media_bays[i].state != mb_empty) &&
25843 -                               (media_bays[i].state != mb_up));
25844 -               }
25845 -               break;
25846 +       i = media_bay_count++;
25847 +       bay = &media_bays[i];
25848 +       bay->mdev = mdev;
25849 +       bay->base = regbase;
25850 +       bay->index = i;
25851 +       bay->ops = match->data;
25852 +       bay->sleeping = 0;
25853 +       init_MUTEX(&bay->lock);
25854 +
25855 +       /* Init HW probing */
25856 +       if (bay->ops->init)
25857 +               bay->ops->init(bay);
25858 +
25859 +       printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", i, bay->ops->name);
25860 +
25861 +       /* Force an immediate detect */
25862 +       set_mb_power(bay, 0);
25863 +       set_current_state(TASK_UNINTERRUPTIBLE);
25864 +       schedule_timeout(MS_TO_HZ(MB_POWER_DELAY));
25865 +       bay->content_id = MB_NO;
25866 +       bay->last_value = bay->ops->content(bay);
25867 +       bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
25868 +       bay->state = mb_empty;
25869 +       do {
25870 +               set_current_state(TASK_UNINTERRUPTIBLE);
25871 +               schedule_timeout(MS_TO_HZ(10));
25872 +               media_bay_step(i);
25873 +       } while((bay->state != mb_empty) &&
25874 +               (bay->state != mb_up));
25875 +
25876 +       /* Mark us ready by filling our mdev data */
25877 +       dev_set_drvdata(&mdev->ofdev.dev, bay);
25878 +
25879 +       /* Startup kernel thread */
25880 +       if (i == 0)
25881 +               kernel_thread(media_bay_task, NULL,
25882 +                             CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
25883 +
25884 +       return 0;
25885 +
25886 +}
25887 +
25888 +static int __pmac media_bay_suspend(struct macio_dev *mdev, u32 state)
25889 +{
25890 +       struct media_bay_info   *bay = dev_get_drvdata(&mdev->ofdev.dev);
25891 +
25892 +       if (state != mdev->ofdev.dev.power_state && state >= 2) {
25893 +               down(&bay->lock);
25894 +               bay->sleeping = 1;
25895 +               set_mb_power(bay, 0);
25896 +               up(&bay->lock);
25897 +               set_current_state(TASK_UNINTERRUPTIBLE);
25898 +               schedule_timeout(MS_TO_HZ(10));
25899 +               mdev->ofdev.dev.power_state = state;
25900         }
25901 -       return PBOOK_SLEEP_OK;
25902 +       return 0;
25903 +}
25904 +
25905 +static int __pmac media_bay_resume(struct macio_dev *mdev)
25906 +{
25907 +       struct media_bay_info   *bay = dev_get_drvdata(&mdev->ofdev.dev);
25908 +
25909 +       if (mdev->ofdev.dev.power_state != 0) {
25910 +               mdev->ofdev.dev.power_state = 0;
25911 +
25912 +               /* We re-enable the bay using it's previous content
25913 +                  only if it did not change. Note those bozo timings,
25914 +                  they seem to help the 3400 get it right.
25915 +                */
25916 +               /* Force MB power to 0 */
25917 +               down(&bay->lock);
25918 +               set_mb_power(bay, 0);
25919 +               set_current_state(TASK_UNINTERRUPTIBLE);
25920 +               schedule_timeout(MS_TO_HZ(MB_POWER_DELAY));
25921 +               if (bay->ops->content(bay) != bay->content_id) {
25922 +                       printk("mediabay%d: content changed during sleep...\n", bay->index);
25923 +                       up(&bay->lock);
25924 +                       return 0;
25925 +               }
25926 +               set_mb_power(bay, 1);
25927 +               bay->last_value = bay->content_id;
25928 +               bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
25929 +               bay->timer = MS_TO_HZ(MB_POWER_DELAY);
25930 +#ifdef CONFIG_BLK_DEV_IDE
25931 +               bay->cd_retry = 0;
25932 +#endif
25933 +               do {
25934 +                       set_current_state(TASK_UNINTERRUPTIBLE);
25935 +                       schedule_timeout(MS_TO_HZ(10));
25936 +                       media_bay_step(bay->index);
25937 +               } while((bay->state != mb_empty) &&
25938 +                       (bay->state != mb_up));
25939 +               bay->sleeping = 0;
25940 +               up(&bay->lock);
25941 +       }
25942 +       return 0;
25943  }
25944 -#endif /* CONFIG_PMAC_PBOOK */
25945  
25946  
25947  /* Definitions of "ops" structures.
25948 @@ -727,6 +780,7 @@
25949  
25950  static struct mb_ops keylargo_mb_ops __pmacdata = {
25951         .name           = "KeyLargo",
25952 +       .init           = keylargo_mb_init,
25953         .content        = keylargo_mb_content,
25954         .power          = keylargo_mb_power,
25955         .setup_bus      = keylargo_mb_setup_bus,
25956 @@ -743,12 +797,42 @@
25957   * Therefore we do it all by polling the media bay once each tick.
25958   */
25959  
25960 -static int __init
25961 -media_bay_init(void)
25962 +static struct of_match media_bay_match[] =
25963  {
25964 -       struct device_node *np;
25965 -       int             n,i;
25966 -       
25967 +       {
25968 +       .name           = "media-bay",
25969 +       .type           = OF_ANY_MATCH,
25970 +       .compatible     = "keylargo-media-bay",
25971 +       .data           = &keylargo_mb_ops,
25972 +       },
25973 +       {
25974 +       .name           = "media-bay",
25975 +       .type           = OF_ANY_MATCH,
25976 +       .compatible     = "heathrow-media-bay",
25977 +       .data           = &heathrow_mb_ops,
25978 +       },
25979 +       {
25980 +       .name           = "media-bay",
25981 +       .type           = OF_ANY_MATCH,
25982 +       .compatible     = "ohare-media-bay",
25983 +       .data           = &ohare_mb_ops,
25984 +       },
25985 +       {},
25986 +};
25987 +
25988 +static struct macio_driver media_bay_driver =
25989 +{
25990 +       .name           = "media-bay",
25991 +       .match_table    = media_bay_match,
25992 +       .probe          = media_bay_attach,
25993 +       .suspend        = media_bay_suspend,
25994 +       .resume         = media_bay_resume
25995 +};
25996 +
25997 +static int __init media_bay_init(void)
25998 +{
25999 +       int i;
26000 +
26001         for (i=0; i<MAX_BAYS; i++) {
26002                 memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info));
26003                 media_bays[i].content_id        = -1;
26004 @@ -756,84 +840,12 @@
26005                 media_bays[i].cd_index          = -1;
26006  #endif
26007         }
26008 -       
26009 -       np = find_devices("media-bay");
26010 -       n = 0;
26011 -       while(np && (n<MAX_BAYS)) {
26012 -               struct media_bay_info* bay = &media_bays[n];
26013 -               if (!np->parent || np->n_addrs == 0 || !request_OF_resource(np, 0, NULL)) {
26014 -                       np = np->next;
26015 -                       printk(KERN_ERR "media-bay: Can't request IO resource !\n");
26016 -                       continue;
26017 -               }
26018 -               bay->mb_type = mb_ohare;
26019 -
26020 -               if (device_is_compatible(np, "keylargo-media-bay")) {
26021 -                       bay->mb_type = mb_keylargo;
26022 -                       bay->ops = &keylargo_mb_ops;
26023 -               } else if (device_is_compatible(np, "heathrow-media-bay")) {
26024 -                       bay->mb_type = mb_heathrow;
26025 -                       bay->ops = &heathrow_mb_ops;
26026 -               } else if (device_is_compatible(np, "ohare-media-bay")) {
26027 -                       bay->mb_type = mb_ohare;
26028 -                       bay->ops = &ohare_mb_ops;
26029 -               } else {
26030 -                       printk(KERN_ERR "mediabay: Unknown bay type !\n");
26031 -                       np = np->next;
26032 -                       continue;
26033 -               }
26034 -               bay->base = (volatile u32*)ioremap(np->parent->addrs[0].address, 0x1000);
26035 -
26036 -               /* Enable probe logic on keylargo */
26037 -               if (bay->mb_type == mb_keylargo)
26038 -                       MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
26039 -#ifdef MB_USE_INTERRUPTS
26040 -               if (np->n_intrs == 0) {
26041 -                       printk(KERN_ERR "media bay %d has no irq\n",n);
26042 -                       np = np->next;
26043 -                       continue;
26044 -               }
26045 -
26046 -               if (request_irq(np->intrs[0].line, media_bay_intr, 0, "Media bay", (void *)n)) {
26047 -                       printk(KERN_ERR "Couldn't get IRQ %d for media bay %d\n",
26048 -                               np->intrs[0].line, n);
26049 -                       np = np->next;
26050 -                       continue;
26051 -               }
26052 -#endif 
26053 -               media_bay_count++;
26054 -       
26055 -               printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", n, bay->ops->name);
26056 -               bay->dev_node = np;
26057 -               bay->index = n;
26058 -
26059 -               /* Force an immediate detect */
26060 -               set_mb_power(bay, 0);
26061 -               mdelay(MB_POWER_DELAY);
26062 -               bay->content_id = MB_NO;
26063 -               bay->last_value = bay->ops->content(bay);
26064 -               bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
26065 -               bay->state = mb_empty;
26066 -               do {
26067 -                       mdelay(1000/HZ);
26068 -                       media_bay_step(n);
26069 -               } while((bay->state != mb_empty) &&
26070 -                       (bay->state != mb_up));
26071 -
26072 -               n++;
26073 -               np=np->next;
26074 -       }
26075 +       if (_machine != _MACH_Pmac)
26076 +               return -ENODEV;
26077  
26078 -       if (media_bay_count)
26079 -       {
26080 -#ifdef CONFIG_PMAC_PBOOK
26081 -               pmu_register_sleep_notifier(&mb_sleep_notifier);
26082 -#endif /* CONFIG_PMAC_PBOOK */
26083 +       macio_register_driver(&media_bay_driver);       
26084  
26085 -               kernel_thread(media_bay_task, NULL,
26086 -                             CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
26087 -       }
26088         return 0;
26089  }
26090  
26091 -subsys_initcall(media_bay_init);
26092 +device_initcall(media_bay_init);
26093 diff -Nru a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
26094 --- a/drivers/macintosh/via-pmu.c       Sat Jun  7 00:46:48 2003
26095 +++ b/drivers/macintosh/via-pmu.c       Mon Aug 25 10:06:34 2003
26096 @@ -11,6 +11,14 @@
26097   * Copyright (C) 1998 Paul Mackerras and Fabio Riccardi.
26098   * Copyright (C) 2001-2002 Benjamin Herrenschmidt
26099   *
26100 + * THIS DRIVER IS BECOMING A TOTAL MESS !
26101 + *  - Cleanup atomically disabling reply to PMU events after
26102 + *    a sleep or a freq. switch
26103 + *  - Move sleep code out of here to pmac_pm, merge into new
26104 + *    common PM infrastructure
26105 + *  - Move backlight code out as well
26106 + *  - Save/Restore PCI space properly
26107 + *
26108   */
26109  #include <stdarg.h>
26110  #include <linux/config.h>
26111 @@ -34,6 +42,8 @@
26112  #include <linux/proc_fs.h>
26113  #include <linux/init.h>
26114  #include <linux/interrupt.h>
26115 +#include <linux/device.h>
26116 +#include <linux/suspend.h>
26117  #include <asm/prom.h>
26118  #include <asm/machdep.h>
26119  #include <asm/io.h>
26120 @@ -47,6 +57,7 @@
26121  #include <asm/mmu_context.h>
26122  #include <asm/cputable.h>
26123  #include <asm/time.h>
26124 +#include <asm/xmon.h>
26125  #ifdef CONFIG_PMAC_BACKLIGHT
26126  #include <asm/backlight.h>
26127  #endif
26128 @@ -55,7 +66,6 @@
26129  #undef SUSPEND_USES_PMU
26130  #define DEBUG_SLEEP
26131  #undef HACKED_PCI_SAVE
26132 -#define NEW_OHARE_CODE
26133  
26134  /* Misc minor number allocated for /dev/pmu */
26135  #define PMU_MINOR              154
26136 @@ -63,6 +73,13 @@
26137  /* How many iterations between battery polls */
26138  #define BATTERY_POLLING_COUNT  2
26139  
26140 +/* Some debugging tools */
26141 +#ifdef CONFIG_XMON
26142 +//#define LIVE_DEBUG(req) ((req) && (req)->data[0] == 0x7d)
26143 +#define LIVE_DEBUG(req) (0)
26144 +static int whacky_debug;
26145 +#endif /* CONFIG_XMON */
26146 +
26147  static volatile unsigned char *via;
26148  
26149  /* VIA registers - spaced 0x200 bytes apart */
26150 @@ -106,6 +123,7 @@
26151         intack,
26152         reading,
26153         reading_intr,
26154 +       locked,
26155  } pmu_state;
26156  
26157  static volatile enum int_data_state {
26158 @@ -133,6 +151,7 @@
26159  static int pmu_has_adb;
26160  static unsigned char *gpio_reg = NULL;
26161  static int gpio_irq = -1;
26162 +static int gpio_irq_enabled = -1;
26163  static volatile int pmu_suspended = 0;
26164  static spinlock_t pmu_lock;
26165  static u8 pmu_intr_mask;
26166 @@ -143,9 +162,11 @@
26167  static int sleep_in_progress;
26168  static int can_sleep;
26169  #endif /* CONFIG_PMAC_PBOOK */
26170 +static unsigned int pmu_irq_stats[11];
26171  
26172  static struct proc_dir_entry *proc_pmu_root;
26173  static struct proc_dir_entry *proc_pmu_info;
26174 +static struct proc_dir_entry *proc_pmu_irqstats;
26175  static struct proc_dir_entry *proc_pmu_options;
26176  
26177  #ifdef CONFIG_PMAC_PBOOK
26178 @@ -184,6 +205,8 @@
26179  static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
26180  static int proc_get_info(char *page, char **start, off_t off,
26181                           int count, int *eof, void *data);
26182 +static int proc_get_irqstats(char *page, char **start, off_t off,
26183 +                         int count, int *eof, void *data);
26184  #ifdef CONFIG_PMAC_BACKLIGHT
26185  static int pmu_set_backlight_level(int level, void* data);
26186  static int pmu_set_backlight_enable(int on, int level, void* data);
26187 @@ -205,16 +228,12 @@
26188         pmu_init,
26189         pmu_send_request,
26190         pmu_adb_autopoll,
26191 -       pmu_poll,
26192 +       pmu_poll_adb,
26193         pmu_adb_reset_bus
26194  };
26195  #endif /* CONFIG_ADB */
26196  
26197  extern void low_sleep_handler(void);
26198 -extern void pmac_sleep_save_intrs(int);
26199 -extern void pmac_sleep_restore_intrs(void);
26200 -extern void openpic_sleep_save_intrs(void);
26201 -extern void openpic_sleep_restore_intrs(void);
26202  extern void enable_kernel_altivec(void);
26203  extern void enable_kernel_fp(void);
26204  
26205 @@ -223,14 +242,6 @@
26206  int pmu_wink(struct adb_request *req);
26207  #endif
26208  
26209 -#if defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM)
26210 -static int generic_notify_sleep(struct pmu_sleep_notifier *self, int when);
26211 -static struct pmu_sleep_notifier generic_sleep_notifier = {
26212 -       generic_notify_sleep,
26213 -       SLEEP_LEVEL_MISC,
26214 -};
26215 -#endif /* defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM) */
26216 -
26217  /*
26218   * This table indicates for each PMU opcode:
26219   * - the number of data bytes to be sent with the command, or -1
26220 @@ -361,11 +372,6 @@
26221                
26222         sys_ctrler = SYS_CTRLER_PMU;
26223         
26224 -#if defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM)
26225 -       pmu_register_sleep_notifier(&generic_sleep_notifier);
26226 -       pm_active = 1;
26227 -#endif 
26228 -
26229         return 1;
26230  }
26231  
26232 @@ -416,6 +422,7 @@
26233         if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) {
26234                 if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1/ADB", (void *)0))
26235                         printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq);
26236 +               gpio_irq_enabled = 1;
26237         }
26238  
26239         /* Enable interrupts */
26240 @@ -489,6 +496,8 @@
26241                 int i;
26242                 proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root,
26243                                         proc_get_info, NULL);
26244 +               proc_pmu_irqstats = create_proc_read_entry("interrupts", 0, proc_pmu_root,
26245 +                                       proc_get_irqstats, NULL);
26246  #ifdef CONFIG_PMAC_PBOOK
26247                 for (i=0; i<pmu_battery_count; i++) {
26248                         char title[16];
26249 @@ -552,15 +561,14 @@
26250  
26251         /* Read PMU version */
26252         pmu_request(&req, NULL, 1, PMU_GET_VERSION);
26253 -       while (!req.complete)
26254 -               pmu_poll();
26255 +       pmu_wait_complete(&req);
26256         if (req.reply_len > 0)
26257                 pmu_version = req.reply[0];
26258  
26259         return 1;
26260  }
26261  
26262 -int __pmac
26263 +int
26264  pmu_get_model(void)
26265  {
26266         return pmu_kind;
26267 @@ -774,6 +782,33 @@
26268         return p - page;
26269  }
26270  
26271 +static int __pmac
26272 +proc_get_irqstats(char *page, char **start, off_t off,
26273 +                 int count, int *eof, void *data)
26274 +{
26275 +       int i;
26276 +       char* p = page;
26277 +       static const char *irq_names[] = {
26278 +               "Total CB1 triggered events",
26279 +               "Total GPIO1 triggered events",
26280 +               "PC-Card eject button",
26281 +               "Sound/Brightness button",
26282 +               "ADB message",
26283 +               "Battery state change",
26284 +               "Environment interrupt",
26285 +               "Tick timer",
26286 +               "Ghost interrupt (zero len)",
26287 +               "Empty interrupt (empty mask)",
26288 +               "Max irqs in a row"
26289 +        };
26290 +
26291 +       for (i=0; i<11; i++) {
26292 +               p += sprintf(p, " %2u: %10u (%s)\n",
26293 +                            i, pmu_irq_stats[i], irq_names[i]);
26294 +       }
26295 +       return p - page;
26296 +}
26297 +
26298  #ifdef CONFIG_PMAC_PBOOK
26299  static int __pmac
26300  proc_get_batt(char *page, char **start, off_t off,
26301 @@ -982,8 +1017,7 @@
26302                 printk(KERN_ERR "pmu_adb_reset_bus: pmu_queue_request failed\n");
26303                 return -EIO;
26304         }
26305 -       while (!req.complete)
26306 -               pmu_poll();
26307 +       pmu_wait_complete(&req);
26308  
26309         if (save_autopoll != 0)
26310                 pmu_adb_autopoll(save_autopoll);
26311 @@ -1133,6 +1167,12 @@
26312         wait_for_ack();
26313         /* set the shift register to shift out and send a byte */
26314         send_byte(req->data[0]);
26315 +#ifdef CONFIG_XMON
26316 +       if (LIVE_DEBUG(req))
26317 +               xmon_printf("R");
26318 +       else
26319 +               whacky_debug = 0;
26320 +#endif /* CONFIG_XMON */
26321  }
26322  
26323  void __openfirmware
26324 @@ -1142,15 +1182,33 @@
26325                 return;
26326         if (disable_poll)
26327                 return;
26328 +       via_pmu_interrupt(0, 0, 0);
26329 +}
26330 +
26331 +void __openfirmware
26332 +pmu_poll_adb(void)
26333 +{
26334 +       if (!via)
26335 +               return;
26336 +       if (disable_poll)
26337 +               return;
26338         /* Kicks ADB read when PMU is suspended */
26339 -       if (pmu_suspended)
26340 -               adb_int_pending = 1;
26341 +       adb_int_pending = 1;
26342         do {
26343                 via_pmu_interrupt(0, 0, 0);
26344         } while (pmu_suspended && (adb_int_pending || pmu_state != idle
26345                 || req_awaiting_reply));
26346  }
26347  
26348 +void __openfirmware
26349 +pmu_wait_complete(struct adb_request *req)
26350 +{
26351 +       if (!via)
26352 +               return;
26353 +       while((pmu_state != idle && pmu_state != locked) || !req->complete)
26354 +               via_pmu_interrupt(0, 0, 0);
26355 +}
26356 +
26357  /* This function loops until the PMU is idle and prevents it from
26358   * anwsering to ADB interrupts. pmu_request can still be called.
26359   * This is done to avoid spurrious shutdowns when we know we'll have
26360 @@ -1175,6 +1233,8 @@
26361  
26362         do {
26363                 spin_unlock_irqrestore(&pmu_lock, flags);
26364 +               if (req_awaiting_reply)
26365 +                       adb_int_pending = 1;
26366                 via_pmu_interrupt(0, 0, 0);
26367                 spin_lock_irqsave(&pmu_lock, flags);
26368                 if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
26369 @@ -1185,7 +1245,7 @@
26370                                 pmu_poll();
26371  #else /* SUSPEND_USES_PMU */
26372                         if (gpio_irq >= 0)
26373 -                               disable_irq(gpio_irq);
26374 +                               disable_irq_nosync(gpio_irq);
26375                         out_8(&via[IER], CB1_INT | IER_CLR);
26376                         spin_unlock_irqrestore(&pmu_lock, flags);
26377  #endif /* SUSPEND_USES_PMU */
26378 @@ -1227,16 +1287,47 @@
26379  static void __pmac
26380  pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
26381  {
26382 +       unsigned char ints, pirq;
26383 +       int i = 0;
26384 +
26385         asleep = 0;
26386         if (drop_interrupts || len < 1) {
26387                 adb_int_pending = 0;
26388 +               pmu_irq_stats[8]++;
26389 +               return;
26390 +       }
26391 +
26392 +       /* Get PMU interrupt mask */
26393 +       ints = data[0];
26394 +
26395 +       /* Record zero interrupts for stats */
26396 +       if (ints == 0)
26397 +               pmu_irq_stats[9]++;
26398 +
26399 +       /* Hack to deal with ADB autopoll flag */
26400 +       if (ints & PMU_INT_ADB)
26401 +               ints &= ~(PMU_INT_ADB_AUTO | PMU_INT_AUTO_SRQ_POLL);
26402 +
26403 +next:
26404 +
26405 +       if (ints == 0) {
26406 +               if (i > pmu_irq_stats[10])
26407 +                       pmu_irq_stats[10] = i;
26408                 return;
26409         }
26410 +
26411 +       for (pirq = 0; pirq < 8; pirq++)
26412 +               if (ints & (1 << pirq))
26413 +                       break;
26414 +       pmu_irq_stats[pirq]++;
26415 +       i++;
26416 +       ints &= ~(1 << pirq);
26417 +
26418         /* Note: for some reason, we get an interrupt with len=1,
26419          * data[0]==0 after each normal ADB interrupt, at least
26420          * on the Pismo. Still investigating...  --BenH
26421          */
26422 -       if (data[0] & PMU_INT_ADB) {
26423 +       if ((1 << pirq) & PMU_INT_ADB) {
26424                 if ((data[0] & PMU_INT_ADB_AUTO) == 0) {
26425                         struct adb_request *req = req_awaiting_reply;
26426                         if (req == 0) {
26427 @@ -1274,29 +1365,37 @@
26428                                 adb_input(data+1, len-1, regs, 1);
26429  #endif /* CONFIG_ADB */                
26430                 }
26431 -       } else {
26432 -               /* Sound/brightness button pressed */
26433 -               if ((data[0] & PMU_INT_SNDBRT) && len == 3) {
26434 +       }
26435 +       /* Sound/brightness button pressed */
26436 +       else if ((1 << pirq) & PMU_INT_SNDBRT) {
26437  #ifdef CONFIG_PMAC_BACKLIGHT
26438 +               if (len == 3)
26439  #ifdef CONFIG_INPUT_ADBHID
26440                         if (!disable_kernel_backlight)
26441  #endif /* CONFIG_INPUT_ADBHID */
26442                                 set_backlight_level(data[1] >> 4);
26443  #endif /* CONFIG_PMAC_BACKLIGHT */
26444 -               }
26445 +       }
26446 +       /* Tick interrupt */
26447 +       else if ((1 << pirq) & PMU_INT_TICK) {
26448  #ifdef CONFIG_PMAC_PBOOK
26449                 /* Environement or tick interrupt, query batteries */
26450 -               if (pmu_battery_count && (data[0] & PMU_INT_TICK)) {
26451 +               if (pmu_battery_count) {
26452                         if ((--query_batt_timer) == 0) {
26453                                 query_battery_state();
26454                                 query_batt_timer = BATTERY_POLLING_COUNT;
26455                         }
26456 -               } else if (pmu_battery_count && (data[0] & PMU_INT_ENVIRONMENT))
26457 +               }
26458 +        }
26459 +       else if ((1 << pirq) & PMU_INT_ENVIRONMENT) {
26460 +               if (pmu_battery_count)
26461                         query_battery_state();
26462 -               if (data[0])
26463 -                       pmu_pass_intr(data, len);
26464 +               pmu_pass_intr(data, len);
26465 +       } else
26466 +              pmu_pass_intr(data, len);
26467 +
26468  #endif /* CONFIG_PMAC_PBOOK */
26469 -       }
26470 +       goto next;
26471  }
26472  
26473  static struct adb_request* __pmac
26474 @@ -1326,17 +1425,29 @@
26475         case sending:
26476                 req = current_req;
26477                 if (data_len < 0) {
26478 +#ifdef CONFIG_XMON
26479 +                       if (LIVE_DEBUG(req))
26480 +                               xmon_printf("s");
26481 +#endif /* CONFIG_XMON */
26482                         data_len = req->nbytes - 1;
26483                         send_byte(data_len);
26484                         break;
26485                 }
26486                 if (data_index <= data_len) {
26487 +#ifdef CONFIG_XMON
26488 +                       if (LIVE_DEBUG(req))
26489 +                               xmon_printf("S");
26490 +#endif /* CONFIG_XMON */
26491                         send_byte(req->data[data_index++]);
26492                         break;
26493                 }
26494                 req->sent = 1;
26495                 data_len = pmu_data_len[req->data[0]][1];
26496                 if (data_len == 0) {
26497 +#ifdef CONFIG_XMON
26498 +                       if (LIVE_DEBUG(req))
26499 +                               xmon_printf("D");
26500 +#endif /* CONFIG_XMON */
26501                         pmu_state = idle;
26502                         current_req = req->next;
26503                         if (req->reply_expected)
26504 @@ -1344,6 +1455,10 @@
26505                         else
26506                                 return req;
26507                 } else {
26508 +#ifdef CONFIG_XMON
26509 +                       if (LIVE_DEBUG(req))
26510 +                               xmon_printf("-");
26511 +#endif /* CONFIG_XMON */
26512                         pmu_state = reading;
26513                         data_index = 0;
26514                         reply_ptr = req->reply + req->reply_len;
26515 @@ -1357,15 +1472,27 @@
26516                 pmu_state = reading_intr;
26517                 reply_ptr = interrupt_data[int_data_last];
26518                 recv_byte();
26519 +               if (gpio_irq >= 0 && !gpio_irq_enabled) {
26520 +                       enable_irq(gpio_irq);
26521 +                       gpio_irq_enabled = 1;
26522 +               }
26523                 break;
26524  
26525         case reading:
26526         case reading_intr:
26527                 if (data_len == -1) {
26528 +#ifdef CONFIG_XMON
26529 +                       if (LIVE_DEBUG(current_req))
26530 +                               xmon_printf("r");
26531 +#endif /* CONFIG_XMON */
26532                         data_len = bite;
26533                         if (bite > 32)
26534                                 printk(KERN_ERR "PMU: bad reply len %d\n", bite);
26535                 } else if (data_index < 32) {
26536 +#ifdef CONFIG_XMON
26537 +                       if (LIVE_DEBUG(current_req))
26538 +                               xmon_printf("R");
26539 +#endif /* CONFIG_XMON */
26540                         reply_ptr[data_index++] = bite;
26541                 }
26542                 if (data_index < data_len) {
26543 @@ -1373,15 +1500,29 @@
26544                         break;
26545                 }
26546  
26547 +#ifdef CONFIG_XMON
26548 +               if (LIVE_DEBUG(current_req)) {
26549 +                       whacky_debug = 1;
26550 +                       xmon_printf("D");
26551 +               }
26552 +#endif /* CONFIG_XMON */
26553                 if (pmu_state == reading_intr) {
26554                         pmu_state = idle;
26555                         int_data_state[int_data_last] = int_data_ready;
26556                         interrupt_data_len[int_data_last] = data_len;
26557                 } else {
26558                         req = current_req;
26559 +                       /* 
26560 +                        * For PMU sleep and freq change requests, we lock the
26561 +                        * PMU until it's explicitely unlocked. This avoids any
26562 +                        * spurrious event polling getting in
26563 +                        */
26564                         current_req = req->next;
26565                         req->reply_len += data_index;
26566 -                       pmu_state = idle;
26567 +                       if (req->data[0] == PMU_SLEEP || req->data[0] == PMU_CPU_SPEED)
26568 +                               pmu_state = locked;
26569 +                       else
26570 +                               pmu_state = idle;
26571                         return req;
26572                 }
26573                 break;
26574 @@ -1411,6 +1552,10 @@
26575                 intr = in_8(&via[IFR]) & (SR_INT | CB1_INT);
26576                 if (intr == 0)
26577                         break;
26578 +#ifdef CONFIG_XMON
26579 +               if (whacky_debug)
26580 +                       xmon_printf("|%02x|", intr);
26581 +#endif /* CONFIG_XMON */
26582                 handled = 1;
26583                 if (++nloop > 1000) {
26584                         printk(KERN_DEBUG "PMU: stuck in intr loop, "
26585 @@ -1419,8 +1564,10 @@
26586                         break;
26587                 }
26588                 out_8(&via[IFR], intr);
26589 -               if (intr & CB1_INT)
26590 +               if (intr & CB1_INT) {
26591                         adb_int_pending = 1;
26592 +                       pmu_irq_stats[0]++;
26593 +               }
26594                 if (intr & SR_INT) {
26595                         req = pmu_sr_intr(regs);
26596                         if (req)
26597 @@ -1431,6 +1578,10 @@
26598  recheck:
26599         if (pmu_state == idle) {
26600                 if (adb_int_pending) {
26601 +#ifdef CONFIG_XMON
26602 +                       if (whacky_debug)
26603 +                               xmon_printf("!A!");
26604 +#endif /* CONFIG_XMON */
26605                         if (int_data_state[0] == int_data_empty)
26606                                 int_data_last = 0;
26607                         else if (int_data_state[1] == int_data_empty)
26608 @@ -1479,11 +1630,33 @@
26609         return IRQ_RETVAL(handled);
26610  }
26611  
26612 +void __pmac
26613 +pmu_unlock(void)
26614 +{
26615 +       unsigned long flags;
26616 +
26617 +       spin_lock_irqsave(&pmu_lock, flags);
26618 +       if (pmu_state == locked)
26619 +               pmu_state = idle;
26620 +       adb_int_pending = 1;
26621 +       spin_unlock_irqrestore(&pmu_lock, flags);
26622 +}
26623 +
26624 +
26625  static irqreturn_t __pmac
26626  gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
26627  {
26628 +       unsigned long flags;
26629 +
26630         if ((in_8(gpio_reg + 0x9) & 0x02) == 0) {
26631 +               spin_lock_irqsave(&pmu_lock, flags);
26632 +               if (gpio_irq_enabled > 0) {
26633 +                       disable_irq_nosync(gpio_irq);
26634 +                       gpio_irq_enabled = 0;
26635 +               }
26636 +               pmu_irq_stats[1]++;
26637                 adb_int_pending = 1;
26638 +               spin_unlock_irqrestore(&pmu_lock, flags);
26639                 via_pmu_interrupt(0, 0, 0);
26640                 return IRQ_HANDLED;
26641         }
26642 @@ -1507,13 +1680,11 @@
26643         if (on) {
26644                 pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT,
26645                             backlight_to_bright[level]);
26646 -               while (!req.complete)
26647 -                       pmu_poll();
26648 +               pmu_wait_complete(&req);
26649         }
26650         pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
26651                     PMU_POW_BACKLIGHT | (on ? PMU_POW_ON : PMU_POW_OFF));
26652 -       while (!req.complete)
26653 -               pmu_poll();
26654 +               pmu_wait_complete(&req);
26655  
26656         return 0;
26657  }
26658 @@ -1549,8 +1720,7 @@
26659  
26660         pmu_request(&req, NULL, 2, PMU_POWER_CTRL, PMU_POW_IRLED |
26661             (on ? PMU_POW_ON : PMU_POW_OFF));
26662 -       while (!req.complete)
26663 -               pmu_poll();
26664 +       pmu_wait_complete(&req);
26665  }
26666  
26667  void __pmac
26668 @@ -1570,8 +1740,7 @@
26669         }
26670  
26671         pmu_request(&req, NULL, 1, PMU_RESET);
26672 -       while(!req.complete || (pmu_state != idle))
26673 -               pmu_poll();
26674 +       pmu_wait_complete(&req);
26675         for (;;)
26676                 ;
26677  }
26678 @@ -1588,14 +1757,12 @@
26679         if (pmu_kind != PMU_KEYLARGO_BASED) {
26680                 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, PMU_INT_ADB |
26681                                                 PMU_INT_TICK );
26682 -               while(!req.complete)
26683 -                       pmu_poll();
26684 +               pmu_wait_complete(&req);
26685         }
26686  
26687         pmu_request(&req, NULL, 5, PMU_SHUTDOWN,
26688                     'M', 'A', 'T', 'T');
26689 -       while(!req.complete || (pmu_state != idle))
26690 -               pmu_poll();
26691 +       pmu_wait_complete(&req);
26692         for (;;)
26693                 ;
26694  }
26695 @@ -1606,25 +1773,261 @@
26696         return via != 0;
26697  }
26698  
26699 -#ifdef CONFIG_PMAC_PBOOK
26700 +struct pmu_i2c_hdr {
26701 +       u8      bus;
26702 +       u8      mode;
26703 +       u8      bus2;
26704 +       u8      address;
26705 +       u8      sub_addr;
26706 +       u8      comb_addr;
26707 +       u8      count;
26708 +};
26709  
26710 -static LIST_HEAD(sleep_notifiers);
26711 +int
26712 +pmu_i2c_combined_read(int bus, int addr, int subaddr,  u8* data, int len)
26713 +{
26714 +       struct adb_request      req;
26715 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
26716 +       int retry;
26717 +       int rc;
26718 +
26719 +       for (retry=0; retry<16; retry++) {
26720 +               memset(&req, 0, sizeof(req));
26721 +
26722 +               hdr->bus = bus;
26723 +               hdr->address = addr & 0xfe;
26724 +               hdr->mode = PMU_I2C_MODE_COMBINED;
26725 +               hdr->bus2 = 0;
26726 +               hdr->sub_addr = subaddr;
26727 +               hdr->comb_addr = addr | 1;
26728 +               hdr->count = len;
26729 +               
26730 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
26731 +               req.reply_expected = 0;
26732 +               req.reply_len = 0;
26733 +               req.data[0] = PMU_I2C_CMD;
26734 +               req.reply[0] = 0xff;
26735 +               rc = pmu_queue_request(&req);
26736 +               if (rc)
26737 +                       return rc;
26738 +               while(!req.complete)
26739 +                       pmu_poll();
26740 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
26741 +                       break;
26742 +               mdelay(15);
26743 +       }
26744 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
26745 +               return -1;
26746  
26747 -#ifdef CONFIG_PM
26748 -static int __pmac
26749 -generic_notify_sleep(struct pmu_sleep_notifier *self, int when)
26750 +       for (retry=0; retry<16; retry++) {
26751 +               memset(&req, 0, sizeof(req));
26752 +
26753 +               mdelay(15);
26754 +
26755 +               hdr->bus = PMU_I2C_BUS_STATUS;
26756 +               req.reply[0] = 0xff;
26757 +               
26758 +               req.nbytes = 2;
26759 +               req.reply_expected = 0;
26760 +               req.reply_len = 0;
26761 +               req.data[0] = PMU_I2C_CMD;
26762 +               rc = pmu_queue_request(&req);
26763 +               if (rc)
26764 +                       return rc;
26765 +               while(!req.complete)
26766 +                       pmu_poll();
26767 +               if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
26768 +                       memcpy(data, &req.reply[1], req.reply_len - 1);
26769 +                       return req.reply_len - 1;
26770 +               }
26771 +       }
26772 +       return -1;
26773 +}
26774 +
26775 +int
26776 +pmu_i2c_stdsub_write(int bus, int addr, int subaddr,  u8* data, int len)
26777  {
26778 -       switch (when) {
26779 -               case PBOOK_SLEEP_NOW:
26780 -                       if (pm_send_all(PM_SUSPEND, (void *)3))
26781 -                               return PBOOK_SLEEP_REJECT;
26782 +       struct adb_request      req;
26783 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
26784 +       int retry;
26785 +       int rc;
26786 +
26787 +       for (retry=0; retry<16; retry++) {
26788 +               memset(&req, 0, sizeof(req));
26789 +
26790 +               hdr->bus = bus;
26791 +               hdr->address = addr & 0xfe;
26792 +               hdr->mode = PMU_I2C_MODE_STDSUB;
26793 +               hdr->bus2 = 0;
26794 +               hdr->sub_addr = subaddr;
26795 +               hdr->comb_addr = addr & 0xfe;
26796 +               hdr->count = len;
26797 +
26798 +               req.data[0] = PMU_I2C_CMD;
26799 +               memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
26800 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
26801 +               req.reply_expected = 0;
26802 +               req.reply_len = 0;
26803 +               req.reply[0] = 0xff;
26804 +               rc = pmu_queue_request(&req);
26805 +               if (rc)
26806 +                       return rc;
26807 +               while(!req.complete)
26808 +                       pmu_poll();
26809 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
26810                         break;
26811 -               case PBOOK_WAKE:
26812 -                       (void) pm_send_all(PM_RESUME, (void *)0);
26813 +               mdelay(15);
26814         }
26815 -       return PBOOK_SLEEP_OK;
26816 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
26817 +               return -1;
26818 +
26819 +       for (retry=0; retry<16; retry++) {
26820 +               memset(&req, 0, sizeof(req));
26821 +
26822 +               mdelay(15);
26823 +
26824 +               hdr->bus = PMU_I2C_BUS_STATUS;
26825 +               req.reply[0] = 0xff;
26826 +               
26827 +               req.nbytes = 2;
26828 +               req.reply_expected = 0;
26829 +               req.reply_len = 0;
26830 +               req.data[0] = PMU_I2C_CMD;
26831 +               rc = pmu_queue_request(&req);
26832 +               if (rc)
26833 +                       return rc;
26834 +               while(!req.complete)
26835 +                       pmu_poll();
26836 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
26837 +                       return len;
26838 +       }
26839 +       return -1;
26840  }
26841 -#endif /* CONFIG_PM */
26842 +
26843 +int
26844 +pmu_i2c_simple_read(int bus, int addr,  u8* data, int len)
26845 +{
26846 +       struct adb_request      req;
26847 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
26848 +       int retry;
26849 +       int rc;
26850 +
26851 +       for (retry=0; retry<16; retry++) {
26852 +               memset(&req, 0, sizeof(req));
26853 +
26854 +               hdr->bus = bus;
26855 +               hdr->address = addr | 1;
26856 +               hdr->mode = PMU_I2C_MODE_SIMPLE;
26857 +               hdr->bus2 = 0;
26858 +               hdr->sub_addr = 0;
26859 +               hdr->comb_addr = 0;
26860 +               hdr->count = len;
26861 +
26862 +               req.data[0] = PMU_I2C_CMD;
26863 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
26864 +               req.reply_expected = 0;
26865 +               req.reply_len = 0;
26866 +               req.reply[0] = 0xff;
26867 +               rc = pmu_queue_request(&req);
26868 +               if (rc)
26869 +                       return rc;
26870 +               while(!req.complete)
26871 +                       pmu_poll();
26872 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
26873 +                       break;
26874 +               mdelay(15);
26875 +       }
26876 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
26877 +               return -1;
26878 +
26879 +       for (retry=0; retry<16; retry++) {
26880 +               memset(&req, 0, sizeof(req));
26881 +
26882 +               mdelay(15);
26883 +
26884 +               hdr->bus = PMU_I2C_BUS_STATUS;
26885 +               req.reply[0] = 0xff;
26886 +               
26887 +               req.nbytes = 2;
26888 +               req.reply_expected = 0;
26889 +               req.reply_len = 0;
26890 +               req.data[0] = PMU_I2C_CMD;
26891 +               rc = pmu_queue_request(&req);
26892 +               if (rc)
26893 +                       return rc;
26894 +               while(!req.complete)
26895 +                       pmu_poll();
26896 +               if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
26897 +                       memcpy(data, &req.reply[1], req.reply_len - 1);
26898 +                       return req.reply_len - 1;
26899 +               }
26900 +       }
26901 +       return -1;
26902 +}
26903 +
26904 +int
26905 +pmu_i2c_simple_write(int bus, int addr,  u8* data, int len)
26906 +{
26907 +       struct adb_request      req;
26908 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
26909 +       int retry;
26910 +       int rc;
26911 +
26912 +       for (retry=0; retry<16; retry++) {
26913 +               memset(&req, 0, sizeof(req));
26914 +
26915 +               hdr->bus = bus;
26916 +               hdr->address = addr & 0xfe;
26917 +               hdr->mode = PMU_I2C_MODE_SIMPLE;
26918 +               hdr->bus2 = 0;
26919 +               hdr->sub_addr = 0;
26920 +               hdr->comb_addr = 0;
26921 +               hdr->count = len;
26922 +
26923 +               req.data[0] = PMU_I2C_CMD;
26924 +               memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
26925 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
26926 +               req.reply_expected = 0;
26927 +               req.reply_len = 0;
26928 +               req.reply[0] = 0xff;
26929 +               rc = pmu_queue_request(&req);
26930 +               if (rc)
26931 +                       return rc;
26932 +               while(!req.complete)
26933 +                       pmu_poll();
26934 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
26935 +                       break;
26936 +               mdelay(15);
26937 +       }
26938 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
26939 +               return -1;
26940 +
26941 +       for (retry=0; retry<16; retry++) {
26942 +               memset(&req, 0, sizeof(req));
26943 +
26944 +               mdelay(15);
26945 +
26946 +               hdr->bus = PMU_I2C_BUS_STATUS;
26947 +               req.reply[0] = 0xff;
26948 +               
26949 +               req.nbytes = 2;
26950 +               req.reply_expected = 0;
26951 +               req.reply_len = 0;
26952 +               req.data[0] = PMU_I2C_CMD;
26953 +               rc = pmu_queue_request(&req);
26954 +               if (rc)
26955 +                       return rc;
26956 +               while(!req.complete)
26957 +                       pmu_poll();
26958 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
26959 +                       return len;
26960 +       }
26961 +       return -1;
26962 +}
26963 +
26964 +#ifdef CONFIG_PMAC_PBOOK
26965 +
26966 +static LIST_HEAD(sleep_notifiers);
26967  
26968  int
26969  pmu_register_sleep_notifier(struct pmu_sleep_notifier *n)
26970 @@ -1885,90 +2288,166 @@
26971  }
26972  
26973  extern long sys_sync(void);
26974 +extern void pm_prepare_console(void);
26975 +extern void pm_restore_console(void);
26976  
26977 -#define        GRACKLE_PM      (1<<7)
26978 -#define GRACKLE_DOZE   (1<<5)
26979 -#define        GRACKLE_NAP     (1<<4)
26980 -#define        GRACKLE_SLEEP   (1<<3)
26981 -
26982 -int __pmac
26983 -powerbook_sleep_G3(void)
26984 +static int __pmac
26985 +pmac_suspend_devices(void)
26986  {
26987 -       unsigned long save_l2cr;
26988 -       unsigned short pmcr1;
26989 -       struct adb_request req;
26990         int ret;
26991 -       struct pci_dev *grackle;
26992 -
26993 -       grackle = pci_find_slot(0, 0);
26994 -       if (!grackle)
26995 -               return -ENODEV;
26996 -
26997 -       /* Notify device drivers */
26998 +       
26999 +       pm_prepare_console();
27000 +       
27001 +       /* Notify old-style device drivers & userland */
27002         ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
27003         if (ret != PBOOK_SLEEP_OK) {
27004 -               printk("pmu: sleep rejected\n");
27005 +               printk(KERN_ERR "Sleep rejected by drivers\n");
27006                 return -EBUSY;
27007         }
27008  
27009         /* Sync the disks. */
27010         /* XXX It would be nice to have some way to ensure that
27011 -        * nobody is dirtying any new buffers while we wait.
27012 -        * BenH: Moved to _after_ sleep request and changed video
27013 -        * drivers to vmalloc() during sleep request. This way, all
27014 -        * vmalloc's are done before actual sleep of block drivers */
27015 +        * nobody is dirtying any new buffers while we wait. That
27016 +        * could be acheived using the refrigerator for processes
27017 +        * that swsusp uses
27018 +        */
27019         sys_sync();
27020  
27021         /* Sleep can fail now. May not be very robust but useful for debugging */
27022         ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
27023         if (ret != PBOOK_SLEEP_OK) {
27024 -               printk("pmu: sleep failed\n");
27025 +               printk(KERN_ERR "Driver sleep failed\n");
27026                 return -EBUSY;
27027         }
27028  
27029 -       /* Wait for completion of async backlight requests */
27030 -       while (!bright_req_1.complete || !bright_req_2.complete ||
27031 -               !bright_req_3.complete || !batt_req.complete)
27032 -               pmu_poll();
27033 +       /* Send suspend call to devices, hold the device core's dpm_sem */
27034 +       ret = device_suspend(PM_SUSPEND_MEM);
27035 +       if (ret) {
27036 +               printk(KERN_ERR "Driver sleep failed\n");
27037 +               broadcast_wake();
27038 +               return -EBUSY;
27039 +       }
27040         
27041 -       /* Turn off various things. Darwin does some retry tests here... */
27042 -       pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
27043 -       while (!req.complete)
27044 -               pmu_poll();
27045 -       pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
27046 -               PMU_POW_OFF|PMU_POW_BACKLIGHT|PMU_POW_IRLED|PMU_POW_MEDIABAY);
27047 -       while (!req.complete)
27048 -               pmu_poll();
27049 -
27050 -       /* Disable all interrupts */
27051 -       pmac_sleep_save_intrs(-1);
27052 -
27053 -       /* Make sure the PMU is idle */
27054 -       while (pmu_state != idle)
27055 -               pmu_poll();
27056 -
27057         /* Make sure the decrementer won't interrupt us */
27058         asm volatile("mtdec %0" : : "r" (0x7fffffff));
27059         /* Make sure any pending DEC interrupt occurring while we did
27060          * the above didn't re-enable the DEC */
27061         mb();
27062         asm volatile("mtdec %0" : : "r" (0x7fffffff));
27063 -       
27064 -       /* We can now disable MSR_EE */
27065 +
27066 +       /* We can now disable MSR_EE. This code of course works properly only
27067 +        * on UP machines... For SMP, if we ever implement sleep, we'll have to
27068 +        * stop the "other" CPUs way before we do all that stuff.
27069 +        */
27070         local_irq_disable();
27071  
27072 -       /* Giveup the FPU */
27073 +       /* Broadcast power down irq
27074 +        * This isn't that useful in most cases (only directly wired devices can
27075 +        * use this but still... This will take care of sysdev's as well, so
27076 +        * we exit from here with local irqs disabled and PIC off.
27077 +        */
27078 +       ret = device_power_down(PM_SUSPEND_MEM);
27079 +       if (ret) {
27080 +               wakeup_decrementer();
27081 +               local_irq_enable();
27082 +               device_resume();
27083 +               broadcast_wake();
27084 +               printk(KERN_ERR "Driver powerdown failed\n");
27085 +               return -EBUSY;
27086 +       }
27087 +
27088 +       /* Wait for completion of async backlight requests */
27089 +       while (!bright_req_1.complete || !bright_req_2.complete ||
27090 +               !bright_req_3.complete || !batt_req.complete)
27091 +               pmu_poll();
27092 +
27093 +       /* Giveup the lazy FPU & vec so we don't have to back them
27094 +        * up from the low level code
27095 +        */
27096         enable_kernel_fp();
27097  
27098 +#ifdef CONFIG_ALTIVEC
27099 +       if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
27100 +               enable_kernel_altivec();
27101 +#endif /* CONFIG_ALTIVEC */
27102 +
27103 +       return 0;
27104 +}
27105 +
27106 +static int __pmac
27107 +pmac_wakeup_devices(void)
27108 +{
27109 +       mdelay(100);
27110 +
27111 +       /* Power back up system devices (including the PIC) */
27112 +       device_power_up();
27113 +
27114 +       pmu_blink(1);
27115 +
27116 +       /* Force a poll of ADB interrupts */
27117 +       adb_int_pending = 1;
27118 +       via_pmu_interrupt(0, 0, 0);
27119 +
27120 +       /* Restart jiffies & scheduling */
27121 +       wakeup_decrementer();
27122 +
27123 +       /* Re-enable local CPU interrupts */
27124 +       local_irq_enable();
27125 +
27126 +       pmu_blink(1);
27127 +
27128 +       /* Resume devices */
27129 +       device_resume();
27130 +
27131 +       /* Notify old style drivers */
27132 +       broadcast_wake();
27133 +
27134 +       pm_restore_console();
27135 +
27136 +       return 0;
27137 +}
27138 +
27139 +#define        GRACKLE_PM      (1<<7)
27140 +#define GRACKLE_DOZE   (1<<5)
27141 +#define        GRACKLE_NAP     (1<<4)
27142 +#define        GRACKLE_SLEEP   (1<<3)
27143 +
27144 +int __pmac
27145 +powerbook_sleep_grackle(void)
27146 +{
27147 +       unsigned long save_l2cr;
27148 +       unsigned short pmcr1;
27149 +       struct adb_request req;
27150 +       int ret;
27151 +       struct pci_dev *grackle;
27152 +
27153 +       grackle = pci_find_slot(0, 0);
27154 +       if (!grackle)
27155 +               return -ENODEV;
27156 +
27157 +       ret = pmac_suspend_devices();
27158 +       if (ret) {
27159 +               printk(KERN_ERR "Sleep rejected by devices\n");
27160 +               return ret;
27161 +       }
27162 +       
27163 +       /* Turn off various things. Darwin does some retry tests here... */
27164 +       pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
27165 +       pmu_wait_complete(&req);
27166 +       pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
27167 +               PMU_POW_OFF|PMU_POW_BACKLIGHT|PMU_POW_IRLED|PMU_POW_MEDIABAY);
27168 +       pmu_wait_complete(&req);
27169 +
27170         /* For 750, save backside cache setting and disable it */
27171         save_l2cr = _get_L2CR();        /* (returns -1 if not available) */
27172         if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
27173                 _set_L2CR(save_l2cr & 0x7fffffff);
27174  
27175 -       /* Ask the PMU to put us to sleep */
27176 -       pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
27177 -       while (!req.complete)
27178 -               pmu_poll();
27179 +       if (!__fake_sleep) {
27180 +               /* Ask the PMU to put us to sleep */
27181 +               pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
27182 +               pmu_wait_complete(&req);
27183 +       }
27184  
27185         /* The VIA is supposed not to be restored correctly*/
27186         save_via_state();
27187 @@ -1982,7 +2461,10 @@
27188         pci_write_config_word(grackle, 0x70, pmcr1);
27189  
27190         /* Call low-level ASM sleep handler */
27191 -       low_sleep_handler();
27192 +       if (__fake_sleep)
27193 +               mdelay(5000);
27194 +       else
27195 +               low_sleep_handler();
27196  
27197         /* We're awake again, stop grackle PM */
27198         pci_read_config_word(grackle, 0x70, &pmcr1);
27199 @@ -2001,36 +2483,17 @@
27200         set_context(current->active_mm->context, current->active_mm->pgd);
27201  
27202         /* Power things up */
27203 -       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc);
27204 -       while (!req.complete)
27205 -               pmu_poll();
27206 +       pmu_unlock();
27207 +       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
27208 +       pmu_wait_complete(&req);
27209         pmu_request(&req, NULL, 2, PMU_POWER_CTRL0,
27210                         PMU_POW0_ON|PMU_POW0_HARD_DRIVE);
27211 -       while (!req.complete)
27212 -               pmu_poll();
27213 +       pmu_wait_complete(&req);
27214         pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
27215                         PMU_POW_ON|PMU_POW_BACKLIGHT|PMU_POW_CHARGER|PMU_POW_IRLED|PMU_POW_MEDIABAY);
27216 -       while (!req.complete)
27217 -               pmu_poll();
27218 -
27219 -       /* reenable interrupt controller */
27220 -       pmac_sleep_restore_intrs();
27221 +       pmu_wait_complete(&req);
27222  
27223 -       /* Leave some time for HW to settle down */
27224 -       mdelay(100);
27225 -
27226 -       /* Restart jiffies & scheduling */
27227 -       wakeup_decrementer();
27228 -
27229 -       /* Force a poll of ADB interrupts */
27230 -       adb_int_pending = 1;
27231 -       via_pmu_interrupt(0, 0, 0);
27232 -
27233 -       /* Re-enable local CPU interrupts */
27234 -       local_irq_enable();
27235 -
27236 -       /* Notify drivers */
27237 -       broadcast_wake();
27238 +       pmac_wakeup_devices();
27239  
27240         return 0;
27241  }
27242 @@ -2048,68 +2511,20 @@
27243                 return -ENOSYS;
27244         }
27245         
27246 -       /* Notify device drivers */
27247 -       ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
27248 -       if (ret != PBOOK_SLEEP_OK) {
27249 -               printk("pmu: sleep rejected\n");
27250 -               return -EBUSY;
27251 -       }
27252 -
27253 -       /* Sync the disks. */
27254 -       /* XXX It would be nice to have some way to ensure that
27255 -        * nobody is dirtying any new buffers while we wait.
27256 -        * BenH: Moved to _after_ sleep request and changed video
27257 -        * drivers to vmalloc() during sleep request. This way, all
27258 -        * vmalloc's are done before actual sleep of block drivers */
27259 -       sys_sync();
27260 -
27261 -       /* Sleep can fail now. May not be very robust but useful for debugging */
27262 -       ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
27263 -       if (ret != PBOOK_SLEEP_OK) {
27264 -               printk("pmu: sleep failed\n");
27265 -               return -EBUSY;
27266 +       ret = pmac_suspend_devices();
27267 +       if (ret) {
27268 +               printk(KERN_ERR "Sleep rejected by devices\n");
27269 +               return ret;
27270         }
27271 -       /* Wait for completion of async backlight requests */
27272 -       while (!bright_req_1.complete || !bright_req_2.complete ||
27273 -               !bright_req_3.complete || !batt_req.complete)
27274 -               pmu_poll();
27275 -
27276 +       
27277         /* Tell PMU what events will wake us up */
27278         pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_CLR_WAKEUP_EVENTS,
27279                 0xff, 0xff);
27280 -       while (!req.complete)
27281 -               pmu_poll();
27282 -
27283 +       pmu_wait_complete(&req);
27284         pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_SET_WAKEUP_EVENTS,
27285                 0, PMU_PWR_WAKEUP_KEY |
27286                 (option_lid_wakeup ? PMU_PWR_WAKEUP_LID_OPEN : 0));
27287 -       while (!req.complete)
27288 -               pmu_poll();
27289 -               
27290 -       /* Save & disable all interrupts */
27291 -       openpic_sleep_save_intrs();
27292 -
27293 -       /* Make sure the PMU is idle */
27294 -       while (pmu_state != idle)
27295 -               pmu_poll();
27296 -
27297 -       /* Make sure the decrementer won't interrupt us */
27298 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
27299 -       /* Make sure any pending DEC interrupt occurring while we did
27300 -        * the above didn't re-enable the DEC */
27301 -       mb();
27302 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
27303 -
27304 -       /* We can now disable MSR_EE */
27305 -       local_irq_disable();
27306 -
27307 -       /* Giveup the FPU & vec */
27308 -       enable_kernel_fp();
27309 -
27310 -#ifdef CONFIG_ALTIVEC
27311 -       if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
27312 -               enable_kernel_altivec();
27313 -#endif /* CONFIG_ALTIVEC */
27314 +       pmu_wait_complete(&req);
27315  
27316         /* Save & disable L2 and L3 caches*/
27317         save_l3cr = _get_L3CR();        /* (returns -1 if not available) */
27318 @@ -2125,13 +2540,9 @@
27319         if (!__fake_sleep) {
27320                 /* Ask the PMU to put us to sleep */
27321                 pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
27322 -               while (!req.complete && pmu_state != idle)
27323 -                       pmu_poll();
27324 +               pmu_wait_complete(&req);
27325         }
27326  
27327 -       out_8(&via[B], in_8(&via[B]) | TREQ);
27328 -       wait_for_ack();
27329 -
27330         /* The VIA is supposed not to be restored correctly*/
27331         save_via_state();
27332  
27333 @@ -2161,8 +2572,6 @@
27334         /* Don't restore PCI for now, it crashes. Maybe unnecessary on pbook */
27335         //pbook_pci_restore();
27336  
27337 -       pmu_blink(2);
27338 -               
27339         /* Restore L2 cache */
27340         if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
27341                 _set_L2CR(save_l2cr);
27342 @@ -2174,31 +2583,15 @@
27343         set_context(current->active_mm->context, current->active_mm->pgd);
27344  
27345         /* Tell PMU we are ready */
27346 +       pmu_unlock();
27347         pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2);
27348 -       while (!req.complete)
27349 -               pmu_poll();
27350 -       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc);
27351 -       while (!req.complete)
27352 -               pmu_poll();
27353 -               
27354 -       /* reenable interrupt controller */
27355 -       openpic_sleep_restore_intrs();
27356 -
27357 -       /* Leave some time for HW to settle down */
27358 -       mdelay(100);
27359 -
27360 -       /* Restart jiffies & scheduling */
27361 -       wakeup_decrementer();
27362 +       pmu_wait_complete(&req);
27363 +       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
27364 +       pmu_wait_complete(&req);
27365  
27366 -       /* Force a poll of ADB interrupts */
27367 -       adb_int_pending = 1;
27368 -       via_pmu_interrupt(0, 0, 0);
27369 +       pmu_blink(1);
27370  
27371 -       /* Re-enable local CPU interrupts */
27372 -       local_irq_enable();
27373 -
27374 -       /* Notify drivers */
27375 -       broadcast_wake();
27376 +       pmac_wakeup_devices();
27377  
27378         return 0;
27379  }
27380 @@ -2227,45 +2620,13 @@
27381         /* Allocate room for PCI save */
27382         pbook_alloc_pci_save();
27383  
27384 -       /* Notify device drivers */
27385 -       ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
27386 -       if (ret != PBOOK_SLEEP_OK) {
27387 -               pbook_free_pci_save();
27388 -               printk("pmu: sleep rejected\n");
27389 -               return -EBUSY;
27390 -       }
27391 -
27392 -       /* Sync the disks. */
27393 -       /* XXX It would be nice to have some way to ensure that
27394 -        * nobody is dirtying any new buffers while we wait.
27395 -        * BenH: Moved to _after_ sleep request and changed video
27396 -        * drivers to vmalloc() during sleep request. This way, all
27397 -        * vmalloc's are done before actual sleep of block drivers */
27398 -       sys_sync();
27399 -
27400 -       /* Sleep can fail now. May not be very robust but useful for debugging */
27401 -       ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
27402 -       if (ret != PBOOK_SLEEP_OK) {
27403 -               printk("pmu: sleep failed\n");
27404 +       ret = pmac_suspend_devices();
27405 +       if (ret) {
27406                 pbook_free_pci_save();
27407 -               return -EBUSY;
27408 +               printk(KERN_ERR "Sleep rejected by devices\n");
27409 +               return ret;
27410         }
27411  
27412 -       /* Wait for completion of async backlight requests */
27413 -       while (!bright_req_1.complete || !bright_req_2.complete ||
27414 -               !bright_req_3.complete || !batt_req.complete)
27415 -               pmu_poll();
27416 -
27417 -       /* Disable all interrupts except pmu */
27418 -       pmac_sleep_save_intrs(vias->intrs[0].line);
27419 -
27420 -       /* Make sure the decrementer won't interrupt us */
27421 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
27422 -       /* Make sure any pending DEC interrupt occurring while we did
27423 -        * the above didn't re-enable the DEC */
27424 -       mb();
27425 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
27426 -
27427         /* Save the state of PCI config space for some slots */
27428         pbook_pci_save();
27429  
27430 @@ -2303,25 +2664,13 @@
27431         out_be32(mem_ctrl_sleep, 0x3f);
27432         pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0);
27433         pbook_pci_restore();
27434 +       pmu_unlock();
27435  
27436         /* wait for the PMU interrupt sequence to complete */
27437         while (asleep)
27438                 mb();
27439  
27440 -       /* reenable interrupts */
27441 -       pmac_sleep_restore_intrs();
27442 -
27443 -       /* Leave some time for HW to settle down */
27444 -       mdelay(100);
27445 -
27446 -       /* Restart jiffies & scheduling */
27447 -       wakeup_decrementer();
27448 -
27449 -       /* Re-enable local CPU interrupts */
27450 -       local_irq_enable();
27451 -
27452 -       /* Notify drivers */
27453 -       broadcast_wake();
27454 +       pmac_wakeup_devices();
27455  
27456         pbook_free_pci_save();
27457         iounmap(mem_ctrl);
27458 @@ -2524,7 +2873,7 @@
27459                         break;
27460                 case PMU_HEATHROW_BASED:
27461                 case PMU_PADDINGTON_BASED:
27462 -                       error = powerbook_sleep_G3();
27463 +                       error = powerbook_sleep_grackle();
27464                         break;
27465                 case PMU_KEYLARGO_BASED:
27466                         error = powerbook_sleep_Core99();
27467 @@ -2676,8 +3025,15 @@
27468  
27469  EXPORT_SYMBOL(pmu_request);
27470  EXPORT_SYMBOL(pmu_poll);
27471 +EXPORT_SYMBOL(pmu_poll_adb);
27472 +EXPORT_SYMBOL(pmu_wait_complete);
27473  EXPORT_SYMBOL(pmu_suspend);
27474  EXPORT_SYMBOL(pmu_resume);
27475 +EXPORT_SYMBOL(pmu_unlock);
27476 +EXPORT_SYMBOL(pmu_i2c_combined_read);
27477 +EXPORT_SYMBOL(pmu_i2c_stdsub_write);
27478 +EXPORT_SYMBOL(pmu_i2c_simple_read);
27479 +EXPORT_SYMBOL(pmu_i2c_simple_write);
27480  #ifdef CONFIG_PMAC_PBOOK
27481  EXPORT_SYMBOL(pmu_register_sleep_notifier);
27482  EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
27483 diff -Nru a/drivers/md/md.c b/drivers/md/md.c
27484 --- a/drivers/md/md.c   Thu Aug  7 02:25:25 2003
27485 +++ b/drivers/md/md.c   Tue Aug 26 09:25:41 2003
27486 @@ -179,7 +179,6 @@
27487                 mddev_map[mdidx(mddev)] = NULL;
27488                 blk_put_queue(mddev->queue);
27489                 kfree(mddev);
27490 -               MOD_DEC_USE_COUNT;
27491         }
27492         spin_unlock(&all_mddevs_lock);
27493  }
27494 @@ -201,7 +200,6 @@
27495                 mddev_map[unit] = new;
27496                 list_add(&new->all_mddevs, &all_mddevs);
27497                 spin_unlock(&all_mddevs_lock);
27498 -               MOD_INC_USE_COUNT;
27499                 return new;
27500         }
27501         spin_unlock(&all_mddevs_lock);
27502 @@ -640,14 +638,13 @@
27503         /* make rdev->sb match mddev data..
27504          *
27505          * 1/ zero out disks
27506 -        * 2/ Add info for each disk, keeping track of highest desc_nr
27507 -        * 3/ any empty disks < highest become removed
27508 +        * 2/ Add info for each disk, keeping track of highest desc_nr (next_spare);
27509 +        * 3/ any empty disks < next_spare become removed
27510          *
27511          * disks[0] gets initialised to REMOVED because
27512          * we cannot be sure from other fields if it has
27513          * been initialised or not.
27514          */
27515 -       int highest = 0;
27516         int i;
27517         int active=0, working=0,failed=0,spare=0,nr_disks=0;
27518  
27519 @@ -718,17 +715,17 @@
27520                         spare++;
27521                         working++;
27522                 }
27523 -               if (rdev2->desc_nr > highest)
27524 -                       highest = rdev2->desc_nr;
27525         }
27526         
27527 -       /* now set the "removed" bit on any non-trailing holes */
27528 -       for (i=0; i<highest; i++) {
27529 +       /* now set the "removed" and "faulty" bits on any missing devices */
27530 +       for (i=0 ; i < mddev->raid_disks ; i++) {
27531                 mdp_disk_t *d = &sb->disks[i];
27532                 if (d->state == 0 && d->number == 0) {
27533                         d->number = i;
27534                         d->raid_disk = i;
27535                         d->state = (1<<MD_DISK_REMOVED);
27536 +                       d->state |= (1<<MD_DISK_FAULTY);
27537 +                       failed++;
27538                 }
27539         }
27540         sb->nr_disks = nr_disks;
27541 @@ -1612,12 +1609,6 @@
27542         spin_unlock(&pers_lock);
27543  
27544         blk_queue_make_request(mddev->queue, mddev->pers->make_request);
27545 -       printk("%s: setting max_sectors to %d, segment boundary to %d\n",
27546 -               disk->disk_name,
27547 -               chunk_size >> 9,
27548 -               (chunk_size>>1)-1);
27549 -       blk_queue_max_sectors(mddev->queue, chunk_size >> 9);
27550 -       blk_queue_segment_boundary(mddev->queue, (chunk_size>>1) - 1);
27551         mddev->queue->queuedata = mddev;
27552  
27553         err = mddev->pers->run(mddev);
27554 @@ -2366,17 +2357,14 @@
27555                         unsigned int cmd, unsigned long arg)
27556  {
27557         char b[BDEVNAME_SIZE];
27558 -       unsigned int minor;
27559 +       unsigned int minor = iminor(inode);
27560         int err = 0;
27561         struct hd_geometry *loc = (struct hd_geometry *) arg;
27562         mddev_t *mddev = NULL;
27563 -       kdev_t dev;
27564  
27565         if (!capable(CAP_SYS_ADMIN))
27566                 return -EACCES;
27567  
27568 -       dev = inode->i_rdev;
27569 -       minor = minor(dev);
27570         if (minor >= MAX_MD_DEVS) {
27571                 MD_BUG();
27572                 return -EINVAL;
27573 @@ -2615,7 +2603,7 @@
27574         /*
27575          * Succeed if we can find or allocate a mddev structure.
27576          */
27577 -       mddev_t *mddev = mddev_find(minor(inode->i_rdev));
27578 +       mddev_t *mddev = mddev_find(iminor(inode));
27579         int err = -ENOMEM;
27580  
27581         if (!mddev)
27582 @@ -3590,6 +3578,7 @@
27583                 if (!disks[i])
27584                         continue;
27585                 mddev = disk->private_data;
27586 +               export_array(mddev);
27587                 del_gendisk(disk);
27588                 put_disk(disk);
27589                 mddev_put(mddev);
27590 diff -Nru a/drivers/md/raid0.c b/drivers/md/raid0.c
27591 --- a/drivers/md/raid0.c        Thu Aug 14 18:16:17 2003
27592 +++ b/drivers/md/raid0.c        Sat Aug 23 15:07:18 2003
27593 @@ -231,6 +231,13 @@
27594         mdk_rdev_t *rdev;
27595         struct list_head *tmp;
27596  
27597 +       printk("md%d: setting max_sectors to %d, segment boundary to %d\n",
27598 +              mdidx(mddev),
27599 +              mddev->chunk_size >> 9,
27600 +              (mddev->chunk_size>>1)-1);
27601 +       blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9);
27602 +       blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1);
27603 +
27604         conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
27605         if (!conf)
27606                 goto out;
27607 diff -Nru a/drivers/md/raid5.c b/drivers/md/raid5.c
27608 --- a/drivers/md/raid5.c        Sun Aug 10 16:01:44 2003
27609 +++ b/drivers/md/raid5.c        Sat Aug 23 15:07:16 2003
27610 @@ -1326,7 +1326,7 @@
27611                         (unsigned long long)new_sector, 
27612                         (unsigned long long)logical_sector);
27613  
27614 -               sh = get_active_stripe(conf, new_sector, pd_idx, 0/*(bi->bi_rw&RWA_MASK)*/);
27615 +               sh = get_active_stripe(conf, new_sector, pd_idx, (bi->bi_rw&RWA_MASK));
27616                 if (sh) {
27617  
27618                         add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK));
27619 @@ -1334,7 +1334,12 @@
27620                         raid5_plug_device(conf);
27621                         handle_stripe(sh);
27622                         release_stripe(sh);
27623 +               } else {
27624 +                       /* cannot get stripe for read-ahead, just give-up */
27625 +                       clear_bit(BIO_UPTODATE, &bi->bi_flags);
27626 +                       break;
27627                 }
27628 +                       
27629         }
27630         spin_lock_irq(&conf->device_lock);
27631         if (--bi->bi_phys_segments == 0) {
27632 diff -Nru a/drivers/md/xor.c b/drivers/md/xor.c
27633 --- a/drivers/md/xor.c  Wed Jul 24 08:36:02 2002
27634 +++ b/drivers/md/xor.c  Sat Aug 23 15:07:12 2003
27635 @@ -134,7 +134,10 @@
27636         return 0;
27637  }
27638  
27639 +static __exit void xor_exit(void) { }
27640 +
27641  EXPORT_SYMBOL(xor_block);
27642  MODULE_LICENSE("GPL");
27643  
27644  module_init(calibrate_xor_block);
27645 +module_exit(xor_exit);
27646 diff -Nru a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
27647 --- a/drivers/media/common/saa7146_fops.c       Mon Jul  7 04:28:54 2003
27648 +++ b/drivers/media/common/saa7146_fops.c       Tue Aug 26 09:25:41 2003
27649 @@ -157,7 +157,7 @@
27650  
27651  static int fops_open(struct inode *inode, struct file *file)
27652  {
27653 -       unsigned int minor = minor(inode->i_rdev);
27654 +       unsigned int minor = iminor(inode);
27655         struct saa7146_dev *h = NULL, *dev = NULL;
27656         struct list_head *list;
27657         struct saa7146_fh *fh = NULL;
27658 diff -Nru a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
27659 --- a/drivers/media/common/saa7146_video.c      Thu Jul 31 16:47:19 2003
27660 +++ b/drivers/media/common/saa7146_video.c      Sun Aug 31 16:14:08 2003
27661 @@ -359,41 +359,41 @@
27662  
27663  static struct v4l2_queryctrl controls[] = {
27664         {
27665 -               id:            V4L2_CID_BRIGHTNESS,
27666 -               name:          "Brightness",
27667 -               minimum:       0,
27668 -               maximum:       255,
27669 -               step:          1,
27670 -               default_value: 128,
27671 -               type:          V4L2_CTRL_TYPE_INTEGER,
27672 +               .id            = V4L2_CID_BRIGHTNESS,
27673 +               .name          = "Brightness",
27674 +               .minimum       = 0,
27675 +               .maximum       = 255,
27676 +               .step          = 1,
27677 +               .default_value = 128,
27678 +               .type          = V4L2_CTRL_TYPE_INTEGER,
27679         },{
27680 -               id:            V4L2_CID_CONTRAST,
27681 -               name:          "Contrast",
27682 -               minimum:       0,
27683 -               maximum:       127,
27684 -               step:          1,
27685 -               default_value: 64,
27686 -               type:          V4L2_CTRL_TYPE_INTEGER,
27687 +               .id            = V4L2_CID_CONTRAST,
27688 +               .name          = "Contrast",
27689 +               .minimum       = 0,
27690 +               .maximum       = 127,
27691 +               .step          = 1,
27692 +               .default_value = 64,
27693 +               .type          = V4L2_CTRL_TYPE_INTEGER,
27694         },{
27695 -               id:            V4L2_CID_SATURATION,
27696 -               name:          "Saturation",
27697 -               minimum:       0,
27698 -               maximum:       127,
27699 -               step:          1,
27700 -               default_value: 64,
27701 -               type:          V4L2_CTRL_TYPE_INTEGER,
27702 +               .id            = V4L2_CID_SATURATION,
27703 +               .name          = "Saturation",
27704 +               .minimum       = 0,
27705 +               .maximum       = 127,
27706 +               .step          = 1,
27707 +               .default_value = 64,
27708 +               .type          = V4L2_CTRL_TYPE_INTEGER,
27709         },{
27710 -               id:            V4L2_CID_VFLIP,
27711 -               name:          "Vertical flip",
27712 -               minimum:       0,
27713 -               maximum:       1,
27714 -               type:          V4L2_CTRL_TYPE_BOOLEAN,
27715 +               .id            = V4L2_CID_VFLIP,
27716 +               .name          = "Vertical flip",
27717 +               .minimum       = 0,
27718 +               .maximum       = 1,
27719 +               .type          = V4L2_CTRL_TYPE_BOOLEAN,
27720         },{
27721 -               id:            V4L2_CID_HFLIP,
27722 -               name:          "Horizontal flip",
27723 -               minimum:       0,
27724 -               maximum:       1,
27725 -               type:          V4L2_CTRL_TYPE_BOOLEAN,
27726 +               .id            = V4L2_CID_HFLIP,
27727 +               .name          = "Horizontal flip",
27728 +               .minimum       = 0,
27729 +               .maximum       = 1,
27730 +               .type          = V4L2_CTRL_TYPE_BOOLEAN,
27731         },
27732  };
27733  static int NUM_CONTROLS = sizeof(controls)/sizeof(struct v4l2_queryctrl);
27734 diff -Nru a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
27735 --- a/drivers/media/dvb/dvb-core/dvbdev.c       Tue Aug 12 13:25:49 2003
27736 +++ b/drivers/media/dvb/dvb-core/dvbdev.c       Tue Aug 26 09:25:41 2003
27737 @@ -73,7 +73,7 @@
27738  {
27739         struct dvb_device *dvbdev;
27740         
27741 -       dvbdev = dvbdev_find_device (minor(inode->i_rdev));
27742 +       dvbdev = dvbdev_find_device (iminor(inode));
27743  
27744         if (dvbdev && dvbdev->fops) {
27745                 int err = 0;
27746 diff -Nru a/drivers/media/dvb/frontends/grundig_29504-401.c b/drivers/media/dvb/frontends/grundig_29504-401.c
27747 --- a/drivers/media/dvb/frontends/grundig_29504-401.c   Wed Jun 18 05:03:14 2003
27748 +++ b/drivers/media/dvb/frontends/grundig_29504-401.c   Sun Aug 31 16:14:08 2003
27749 @@ -37,15 +37,15 @@
27750  
27751  
27752  struct dvb_frontend_info grundig_29504_401_info = {
27753 -       name: "Grundig 29504-401",
27754 -       type: FE_OFDM,
27755 -/*     frequency_min: ???,*/
27756 -/*     frequency_max: ???,*/
27757 -       frequency_stepsize: 166666,
27758 -/*      frequency_tolerance: ???,*/
27759 -/*      symbol_rate_tolerance: ???,*/
27760 -       notifier_delay: 0,
27761 -       caps: FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 
27762 +       .name = "Grundig 29504-401",
27763 +       .type = FE_OFDM,
27764 +/*     .frequency_min = ???,*/
27765 +/*     .frequency_max = ???,*/
27766 +       .frequency_stepsize = 166666,
27767 +/*      .frequency_tolerance = ???,*/
27768 +/*      .symbol_rate_tolerance = ???,*/
27769 +       .notifier_delay = 0,
27770 +       .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
27771               FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
27772               FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
27773               FE_CAN_MUTE_TS /*| FE_CAN_CLEAN_SETUP*/
27774 diff -Nru a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
27775 --- a/drivers/media/dvb/frontends/ves1820.c     Thu Jun 19 23:48:36 2003
27776 +++ b/drivers/media/dvb/frontends/ves1820.c     Sun Aug 31 16:14:08 2003
27777 @@ -81,9 +81,9 @@
27778         .symbol_rate_min = (XIN/2)/64,     /* SACLK/64 == (XIN/2)/64 */
27779         .symbol_rate_max = (XIN/2)/4,      /* SACLK/4 */
27780  #if 0
27781 -       frequency_tolerance: ???,
27782 -       symbol_rate_tolerance: ???,  /* ppm */  /* == 8% (spec p. 5) */
27783 -       notifier_delay: ?,
27784 +       .frequency_tolerance = ???,
27785 +       .symbol_rate_tolerance = ???,  /* ppm */  /* == 8% (spec p. 5) */
27786 +       .notifier_delay = ?,
27787  #endif
27788         .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
27789                 FE_CAN_QAM_128 | FE_CAN_QAM_256 | 
27790 diff -Nru a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
27791 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c Mon Aug 11 07:56:25 2003
27792 +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c Sat Aug 23 12:49:46 2003
27793 @@ -1249,7 +1249,7 @@
27794         if ((err = usb_register(&ttusb_driver)) < 0) {
27795                 printk("%s: usb_register failed! Error number %d",
27796                        __FILE__, err);
27797 -               return -1;
27798 +               return err;
27799         }
27800  
27801         return 0;
27802 diff -Nru a/drivers/media/dvb/ttusb-dec/dec2000_frontend.c b/drivers/media/dvb/ttusb-dec/dec2000_frontend.c
27803 --- a/drivers/media/dvb/ttusb-dec/dec2000_frontend.c    Mon Jul 14 02:56:39 2003
27804 +++ b/drivers/media/dvb/ttusb-dec/dec2000_frontend.c    Sun Aug 31 16:14:08 2003
27805 @@ -30,12 +30,12 @@
27806  #define dprintk        if (debug) printk
27807  
27808  static struct dvb_frontend_info dec2000_frontend_info = {
27809 -       name:                   "TechnoTrend/Hauppauge DEC-2000-t Frontend",
27810 -       type:                   FE_OFDM,
27811 -       frequency_min:          51000000,
27812 -       frequency_max:          858000000,
27813 -       frequency_stepsize:     62500,
27814 -       caps:   FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
27815 +       .name                   = "TechnoTrend/Hauppauge DEC-2000-t Frontend",
27816 +       .type                   = FE_OFDM,
27817 +       .frequency_min          = 51000000,
27818 +       .frequency_max          = 858000000,
27819 +       .frequency_stepsize     = 62500,
27820 +       .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
27821                 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
27822                 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
27823                 FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
27824 diff -Nru a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
27825 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c   Sat Aug  9 06:43:04 2003
27826 +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c   Sun Aug 31 16:14:08 2003
27827 @@ -1003,10 +1003,10 @@
27828  };
27829  
27830  static struct usb_driver ttusb_dec_driver = {
27831 -      name:            DRIVER_NAME,
27832 -      probe:           ttusb_dec_probe,
27833 -      disconnect:      ttusb_dec_disconnect,
27834 -      id_table:                ttusb_dec_table,
27835 +      .name            = DRIVER_NAME,
27836 +      .probe           = ttusb_dec_probe,
27837 +      .disconnect      = ttusb_dec_disconnect,
27838 +      .id_table                = ttusb_dec_table,
27839  };
27840  
27841  static int __init ttusb_dec_init(void)
27842 diff -Nru a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
27843 --- a/drivers/media/video/Kconfig       Thu Aug 21 09:02:59 2003
27844 +++ b/drivers/media/video/Kconfig       Sun Aug 24 01:26:51 2003
27845 @@ -201,7 +201,7 @@
27846  
27847  config VIDEO_ZR36120
27848         tristate "Zoran ZR36120/36125 Video For Linux"
27849 -       depends on VIDEO_DEV && PCI && I2C
27850 +       depends on VIDEO_DEV && PCI && I2C && BROKEN
27851         help
27852           Support for ZR36120/ZR36125 based frame grabber/overlay boards.
27853           This includes the Victor II, WaveWatcher, Video Wonder, Maxi-TV,
27854 diff -Nru a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
27855 --- a/drivers/media/video/adv7170.c     Wed Aug 20 15:29:21 2003
27856 +++ b/drivers/media/video/adv7170.c     Sun Aug 31 16:14:05 2003
27857 @@ -104,6 +104,7 @@
27858                u8                 value)
27859  {
27860         struct adv7170 *encoder = i2c_get_clientdata(client);
27861 +
27862         encoder->reg[reg] = value;
27863         return i2c_smbus_write_byte_data(client, reg, value);
27864  }
27865 @@ -130,6 +131,7 @@
27866                 struct adv7170 *encoder = i2c_get_clientdata(client);
27867                 struct i2c_msg msg;
27868                 u8 block_data[32];
27869 +
27870                 msg.addr = client->addr;
27871                 msg.flags = client->flags;
27872                 while (len >= 2) {
27873 @@ -143,16 +145,16 @@
27874                                 data += 2;
27875                         } while (len >= 2 && data[0] == reg &&
27876                                  msg.len < 32);
27877 -                       if ((ret =
27878 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
27879 +                       if ((ret = i2c_transfer(client->adapter,
27880 +                                               &msg, 1)) < 0)
27881                                 break;
27882                 }
27883         } else {
27884                 /* do some slow I2C emulation kind of thing */
27885                 while (len >= 2) {
27886                         reg = *data++;
27887 -                       if ((ret =
27888 -                            adv7170_write(client, reg, *data++)) < 0)
27889 +                       if ((ret = adv7170_write(client, reg,
27890 +                                                *data++)) < 0)
27891                                 break;
27892                         len -= 2;
27893                 }
27894 @@ -442,6 +444,7 @@
27895                 dname = adv7171_name;
27896         } else {
27897                 /* We should never get here!!! */
27898 +               kfree(client);
27899                 return 0;
27900         }
27901         snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
27902 @@ -449,6 +452,7 @@
27903  
27904         encoder = kmalloc(sizeof(struct adv7170), GFP_KERNEL);
27905         if (encoder == NULL) {
27906 +               kfree(client);
27907                 return -ENOMEM;
27908         }
27909         memset(encoder, 0, sizeof(struct adv7170));
27910 diff -Nru a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
27911 --- a/drivers/media/video/adv7175.c     Wed Aug 20 15:29:21 2003
27912 +++ b/drivers/media/video/adv7175.c     Sun Aug 31 16:14:05 2003
27913 @@ -100,6 +100,7 @@
27914                u8                 value)
27915  {
27916         struct adv7175 *encoder = i2c_get_clientdata(client);
27917 +
27918         encoder->reg[reg] = value;
27919         return i2c_smbus_write_byte_data(client, reg, value);
27920  }
27921 @@ -126,6 +127,7 @@
27922                 struct adv7175 *encoder = i2c_get_clientdata(client);
27923                 struct i2c_msg msg;
27924                 u8 block_data[32];
27925 +
27926                 msg.addr = client->addr;
27927                 msg.flags = client->flags;
27928                 while (len >= 2) {
27929 @@ -139,16 +141,16 @@
27930                                 data += 2;
27931                         } while (len >= 2 && data[0] == reg &&
27932                                  msg.len < 32);
27933 -                       if ((ret =
27934 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
27935 +                       if ((ret = i2c_transfer(client->adapter,
27936 +                                               &msg, 1)) < 0)
27937                                 break;
27938                 }
27939         } else {
27940                 /* do some slow I2C emulation kind of thing */
27941                 while (len >= 2) {
27942                         reg = *data++;
27943 -                       if ((ret =
27944 -                            adv7175_write(client, reg, *data++)) < 0)
27945 +                       if ((ret = adv7175_write(client, reg,
27946 +                                                *data++)) < 0)
27947                                 break;
27948                         len -= 2;
27949                 }
27950 @@ -163,6 +165,7 @@
27951  {
27952         struct adv7175 *encoder = i2c_get_clientdata(client);
27953         int i, j;
27954 +
27955         printk(KERN_INFO "%s: registry dump\n", I2C_NAME(client));
27956         for (i = 0; i < 182 / 8; i++) {
27957                 printk("%s: 0x%02x -", I2C_NAME(client), i * 8);
27958 @@ -463,6 +466,7 @@
27959                 dname = adv7176_name;
27960         } else {
27961                 /* We should never get here!!! */
27962 +               kfree(client);
27963                 return 0;
27964         }
27965         snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
27966 @@ -470,6 +474,7 @@
27967  
27968         encoder = kmalloc(sizeof(struct adv7175), GFP_KERNEL);
27969         if (encoder == NULL) {
27970 +               kfree(client);
27971                 return -ENOMEM;
27972         }
27973         memset(encoder, 0, sizeof(struct adv7175));
27974 diff -Nru a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
27975 --- a/drivers/media/video/bt819.c       Wed Aug 20 15:29:21 2003
27976 +++ b/drivers/media/video/bt819.c       Sun Aug 31 16:14:05 2003
27977 @@ -113,6 +113,7 @@
27978              u8                 value)
27979  {
27980         struct bt819 *decoder = i2c_get_clientdata(client);
27981 +
27982         decoder->reg[reg] = value;
27983         return i2c_smbus_write_byte_data(client, reg, value);
27984  }
27985 @@ -124,6 +125,7 @@
27986               u8                 value)
27987  {
27988         struct bt819 *decoder = i2c_get_clientdata(client);
27989 +
27990         return bt819_write(client, reg,
27991                            (decoder->
27992                             reg[reg] & ~(1 << bit)) |
27993 @@ -145,6 +147,7 @@
27994                 struct bt819 *decoder = i2c_get_clientdata(client);
27995                 struct i2c_msg msg;
27996                 u8 block_data[32];
27997 +
27998                 msg.addr = client->addr;
27999                 msg.flags = client->flags;
28000                 while (len >= 2) {
28001 @@ -158,8 +161,8 @@
28002                                 data += 2;
28003                         } while (len >= 2 && data[0] == reg &&
28004                                  msg.len < 32);
28005 -                       if ((ret =
28006 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
28007 +                       if ((ret = i2c_transfer(client->adapter,
28008 +                                               &msg, 1)) < 0)
28009                                 break;
28010                 }
28011         } else {
28012 diff -Nru a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
28013 --- a/drivers/media/video/bt856.c       Wed Aug 20 15:29:21 2003
28014 +++ b/drivers/media/video/bt856.c       Sun Aug 31 16:14:05 2003
28015 @@ -98,6 +98,7 @@
28016              u8                 value)
28017  {
28018         struct bt856 *encoder = i2c_get_clientdata(client);
28019 +
28020         encoder->reg[reg - REG_OFFSET] = value;
28021         return i2c_smbus_write_byte_data(client, reg, value);
28022  }
28023 @@ -109,6 +110,7 @@
28024               u8                 value)
28025  {
28026         struct bt856 *encoder = i2c_get_clientdata(client);
28027 +
28028         return bt856_write(client, reg,
28029                            (encoder->
28030                             reg[reg - REG_OFFSET] & ~(1 << bit)) |
28031 @@ -120,6 +122,7 @@
28032  {
28033         int i;
28034         struct bt856 *encoder = i2c_get_clientdata(client);
28035 +
28036         printk(KERN_INFO "%s: register dump:", I2C_NAME(client));
28037         for (i = 0xd6; i <= 0xde; i += 2)
28038                 printk(" %02x", encoder->reg[i - REG_OFFSET]);
28039 @@ -341,6 +344,7 @@
28040  
28041         encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
28042         if (encoder == NULL) {
28043 +               kfree(client);
28044                 return -ENOMEM;
28045         }
28046         memset(encoder, 0, sizeof(struct bt856));
28047 diff -Nru a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
28048 --- a/drivers/media/video/bttv-driver.c Thu Aug  7 14:20:17 2003
28049 +++ b/drivers/media/video/bttv-driver.c Tue Aug 26 09:25:41 2003
28050 @@ -2758,7 +2758,7 @@
28051  
28052  static int bttv_open(struct inode *inode, struct file *file)
28053  {
28054 -       int minor = minor(inode->i_rdev);
28055 +       int minor = iminor(inode);
28056         struct bttv *btv = NULL;
28057         struct bttv_fh *fh;
28058         enum v4l2_buf_type type = 0;
28059 @@ -2894,7 +2894,7 @@
28060  
28061  static int radio_open(struct inode *inode, struct file *file)
28062  {
28063 -       int minor = minor(inode->i_rdev);
28064 +       int minor = iminor(inode);
28065         struct bttv *btv = NULL;
28066         u32 v = 400*16;
28067         unsigned int i;
28068 diff -Nru a/drivers/media/video/meye.c b/drivers/media/video/meye.c
28069 --- a/drivers/media/video/meye.c        Thu Jul 31 08:59:04 2003
28070 +++ b/drivers/media/video/meye.c        Wed Aug 27 04:24:51 2003
28071 @@ -920,7 +920,7 @@
28072  
28073         case VIDIOCGCAP: {
28074                 struct video_capability *b = arg;
28075 -               strcpy(b->name,meye.video_dev.name);
28076 +               strcpy(b->name,meye.video_dev->name);
28077                 b->type = VID_TYPE_CAPTURE;
28078                 b->channels = 1;
28079                 b->audios = 0;
28080 @@ -1225,6 +1225,8 @@
28081         .type           = VID_TYPE_CAPTURE,
28082         .hardware       = VID_HARDWARE_MEYE,
28083         .fops           = &meye_fops,
28084 +       .release        = video_device_release,
28085 +       .minor          = -1,
28086  };
28087  
28088  #ifdef CONFIG_PM
28089 @@ -1275,10 +1277,17 @@
28090                 goto out1;
28091         }
28092  
28093 -       sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1);
28094 -
28095         meye.mchip_dev = pcidev;
28096 -       memcpy(&meye.video_dev, &meye_template, sizeof(meye_template));
28097 +       meye.video_dev = video_device_alloc();
28098 +       if (!meye.video_dev) {
28099 +               printk(KERN_ERR "meye: video_device_alloc() failed!\n");
28100 +               ret = -EBUSY;
28101 +               goto out1;
28102 +       }
28103 +       memcpy(meye.video_dev, &meye_template, sizeof(meye_template));
28104 +       meye.video_dev->dev = &meye.mchip_dev->dev;
28105 +
28106 +       sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1);
28107  
28108         if ((ret = pci_enable_device(meye.mchip_dev))) {
28109                 printk(KERN_ERR "meye: pci_enable_device failed\n");
28110 @@ -1335,7 +1344,7 @@
28111         wait_ms(1);
28112         mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK);
28113  
28114 -       if (video_register_device(&meye.video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
28115 +       if (video_register_device(meye.video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
28116  
28117                 printk(KERN_ERR "meye: video_register_device failed\n");
28118                 ret = -EIO;
28119 @@ -1383,6 +1392,9 @@
28120  out3:
28121         pci_disable_device(meye.mchip_dev);
28122  out2:
28123 +       video_device_release(meye.video_dev);
28124 +       meye.video_dev = NULL;
28125 +
28126         sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 0);
28127  out1:
28128         return ret;
28129 @@ -1390,7 +1402,7 @@
28130  
28131  static void __devexit meye_remove(struct pci_dev *pcidev) {
28132  
28133 -       video_unregister_device(&meye.video_dev);
28134 +       video_unregister_device(meye.video_dev);
28135  
28136         mchip_hic_stop();
28137  
28138 diff -Nru a/drivers/media/video/meye.h b/drivers/media/video/meye.h
28139 --- a/drivers/media/video/meye.h        Wed Apr 16 03:01:38 2003
28140 +++ b/drivers/media/video/meye.h        Tue Aug 26 09:48:06 2003
28141 @@ -312,7 +312,7 @@
28142  
28143         struct meye_queue grabq;        /* queue for buffers to be grabbed */
28144  
28145 -       struct video_device video_dev;  /* video device parameters */
28146 +       struct video_device *video_dev; /* video device parameters */
28147         struct video_picture picture;   /* video picture parameters */
28148         struct meye_params params;      /* additional parameters */
28149  #ifdef CONFIG_PM
28150 diff -Nru a/drivers/media/video/planb.c b/drivers/media/video/planb.c
28151 --- a/drivers/media/video/planb.c       Tue Aug 12 13:24:31 2003
28152 +++ b/drivers/media/video/planb.c       Mon Sep  1 08:41:30 2003
28153 @@ -2158,6 +2158,7 @@
28154         unsigned int            old_base, new_base;
28155         unsigned int            irq;
28156         struct pci_dev          *pdev;
28157 +       int rc;
28158  
28159         if (_machine != _MACH_Pmac)
28160                 return 0;
28161 @@ -2211,18 +2212,25 @@
28162  
28163         pdev = pci_find_slot (bus, dev_fn);
28164         if (!pdev) {
28165 -               printk(KERN_ERR "cannot find slot\n");
28166 -               /* XXX handle error */
28167 +               printk(KERN_ERR "planb: cannot find slot\n");
28168 +               goto err_out;
28169         }
28170  
28171         /* Enable response in memory space, bus mastering,
28172            use memory write and invalidate */
28173 -       pci_write_config_word (pdev, PCI_COMMAND,
28174 -               PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
28175 -               PCI_COMMAND_INVALIDATE);
28176 -       /* Set PCI Cache line size & latency timer */
28177 -       pci_write_config_byte (pdev, PCI_CACHE_LINE_SIZE, 0x8);
28178 -       pci_write_config_byte (pdev, PCI_LATENCY_TIMER, 0x40);
28179 +       rc = pci_enable_device(pdev);
28180 +       if (rc) {
28181 +               printk(KERN_ERR "planb: cannot enable PCI device %s\n",
28182 +                      pci_name(pdev));
28183 +               goto err_out;
28184 +       }
28185 +       rc = pci_set_mwi(pdev);
28186 +       if (rc) {
28187 +               printk(KERN_ERR "planb: cannot enable MWI on PCI device %s\n",
28188 +                      pci_name(pdev));
28189 +               goto err_out_disable;
28190 +       }
28191 +       pci_set_master(pdev);
28192  
28193         /* Set the new base address */
28194         pci_write_config_dword (pdev, confreg, new_base);
28195 @@ -2234,6 +2242,12 @@
28196         pb->irq = irq;
28197         
28198         return planb_num;
28199 +
28200 +err_out_disable:
28201 +       pci_disable_device(pdev);
28202 +err_out:
28203 +       /* FIXME handle error */   /* comment moved from pci_find_slot, above */
28204 +       return 0;
28205  }
28206  
28207  static void release_planb(void)
28208 diff -Nru a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
28209 --- a/drivers/media/video/saa7110.c     Wed Aug 20 15:29:21 2003
28210 +++ b/drivers/media/video/saa7110.c     Sun Aug 31 16:14:05 2003
28211 @@ -86,6 +86,7 @@
28212                u8                 value)
28213  {
28214         struct saa7110 *decoder = i2c_get_clientdata(client);
28215 +
28216         decoder->reg[reg] = value;
28217         return i2c_smbus_write_byte_data(client, reg, value);
28218  }
28219 @@ -97,6 +98,7 @@
28220  {
28221         int ret = -1;
28222         u8 reg = *data++;
28223 +
28224         len--;
28225  
28226         /* the saa7110 has an autoincrement function, use it if
28227 @@ -105,6 +107,7 @@
28228                 struct saa7110 *decoder = i2c_get_clientdata(client);
28229                 struct i2c_msg msg;
28230                 u8 block_data[54];
28231 +
28232                 msg.len = 0;
28233                 msg.buf = (char *) block_data;
28234                 msg.addr = client->addr;
28235 @@ -119,8 +122,8 @@
28236                 }
28237         } else {
28238                 while (len-- >= 1) {
28239 -                       if ((ret =
28240 -                            saa7110_write(client, reg++, *data++)) < 0)
28241 +                       if ((ret = saa7110_write(client, reg++,
28242 +                                                *data++)) < 0)
28243                                 break;
28244                 }
28245         }
28246 @@ -279,6 +282,7 @@
28247         case DECODER_GET_CAPABILITIES:
28248         {
28249                 struct video_decoder_capability *dc = arg;
28250 +
28251                 dc->flags =
28252                     VIDEO_DECODER_PAL | VIDEO_DECODER_NTSC |
28253                     VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO;
28254 diff -Nru a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
28255 --- a/drivers/media/video/saa7111.c     Thu Aug 21 10:13:46 2003
28256 +++ b/drivers/media/video/saa7111.c     Sun Aug 31 16:14:05 2003
28257 @@ -93,6 +93,7 @@
28258                u8                 value)
28259  {
28260         struct saa7111 *decoder = i2c_get_clientdata(client);
28261 +
28262         decoder->reg[reg] = value;
28263         return i2c_smbus_write_byte_data(client, reg, value);
28264  }
28265 @@ -112,6 +113,7 @@
28266                 struct saa7111 *decoder = i2c_get_clientdata(client);
28267                 struct i2c_msg msg;
28268                 u8 block_data[32];
28269 +
28270                 msg.addr = client->addr;
28271                 msg.flags = client->flags;
28272                 while (len >= 2) {
28273 @@ -125,16 +127,16 @@
28274                                 data += 2;
28275                         } while (len >= 2 && data[0] == reg &&
28276                                  msg.len < 32);
28277 -                       if ((ret =
28278 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
28279 +                       if ((ret = i2c_transfer(client->adapter,
28280 +                                               &msg, 1)) < 0)
28281                                 break;
28282                 }
28283         } else {
28284                 /* do some slow I2C emulation kind of thing */
28285                 while (len >= 2) {
28286                         reg = *data++;
28287 -                       if ((ret =
28288 -                            saa7111_write(client, reg, *data++)) < 0)
28289 +                       if ((ret = saa7111_write(client, reg,
28290 +                                                *data++)) < 0)
28291                                 break;
28292                         len -= 2;
28293                 }
28294 diff -Nru a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
28295 --- a/drivers/media/video/saa7114.c     Wed Aug 20 15:29:21 2003
28296 +++ b/drivers/media/video/saa7114.c     Sun Aug 31 16:14:05 2003
28297 @@ -144,6 +144,7 @@
28298                u8                 value)
28299  {
28300         /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
28301 +
28302         /*decoder->reg[reg] = value;*/
28303         return i2c_smbus_write_byte_data(client, reg, value);
28304  }
28305 @@ -163,6 +164,7 @@
28306                 /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
28307                 struct i2c_msg msg;
28308                 u8 block_data[32];
28309 +
28310                 msg.addr = client->addr;
28311                 msg.flags = client->flags;
28312                 while (len >= 2) {
28313 @@ -176,16 +178,16 @@
28314                                 data += 2;
28315                         } while (len >= 2 && data[0] == reg &&
28316                                  msg.len < 32);
28317 -                       if ((ret =
28318 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
28319 +                       if ((ret = i2c_transfer(client->adapter,
28320 +                                               &msg, 1)) < 0)
28321                                 break;
28322                 }
28323         } else {
28324                 /* do some slow I2C emulation kind of thing */
28325                 while (len >= 2) {
28326                         reg = *data++;
28327 -                       if ((ret =
28328 -                            saa7114_write(client, reg, *data++)) < 0)
28329 +                       if ((ret = saa7114_write(client, reg,
28330 +                                                *data++)) < 0)
28331                                 break;
28332                         len -= 2;
28333                 }
28334 @@ -995,6 +997,8 @@
28335                                 KERN_ERR
28336                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
28337                                 I2C_NAME(client), i, err[i]);
28338 +                       kfree(decoder);
28339 +                       kfree(client);
28340                         return 0;
28341                 }
28342         }
28343 @@ -1022,6 +1026,8 @@
28344                                 KERN_ERR
28345                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
28346                                 I2C_NAME(client), i, err[i]);
28347 +                       kfree(decoder);
28348 +                       kfree(client);
28349                         return 0;
28350                 }
28351         }
28352 @@ -1068,6 +1074,8 @@
28353                                 KERN_ERR
28354                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
28355                                 I2C_NAME(client), i, err[i]);
28356 +                       kfree(decoder);
28357 +                       kfree(client);
28358                         return 0;
28359                 }
28360         }
28361 @@ -1107,6 +1115,8 @@
28362                                 KERN_ERR
28363                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
28364                                 I2C_NAME(client), i, err[i]);
28365 +                       kfree(decoder);
28366 +                       kfree(client);
28367                         return 0;
28368                 }
28369         }
28370 @@ -1127,6 +1137,8 @@
28371                                 KERN_ERR
28372                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
28373                                 I2C_NAME(client), i, err[i]);
28374 +                       kfree(decoder);
28375 +                       kfree(client);
28376                         return 0;
28377                 }
28378         }
28379 diff -Nru a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
28380 --- a/drivers/media/video/saa7134/saa7134-oss.c Sun May 25 17:00:00 2003
28381 +++ b/drivers/media/video/saa7134/saa7134-oss.c Tue Aug 26 09:25:41 2003
28382 @@ -215,7 +215,7 @@
28383  
28384  static int dsp_open(struct inode *inode, struct file *file)
28385  {
28386 -       int minor = minor(inode->i_rdev);
28387 +       int minor = iminor(inode);
28388         struct saa7134_dev *h,*dev = NULL;
28389         struct list_head *list;
28390         int err;
28391 @@ -598,7 +598,7 @@
28392  
28393  static int mixer_open(struct inode *inode, struct file *file)
28394  {
28395 -       int minor = minor(inode->i_rdev);
28396 +       int minor = iminor(inode);
28397         struct saa7134_dev *h,*dev = NULL;
28398         struct list_head *list;
28399  
28400 diff -Nru a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
28401 --- a/drivers/media/video/saa7134/saa7134-ts.c  Thu Jul 31 16:47:19 2003
28402 +++ b/drivers/media/video/saa7134/saa7134-ts.c  Tue Aug 26 09:25:41 2003
28403 @@ -166,7 +166,7 @@
28404  
28405  static int ts_open(struct inode *inode, struct file *file)
28406  {
28407 -       int minor = minor(inode->i_rdev);
28408 +       int minor = iminor(inode);
28409         struct saa7134_dev *h,*dev = NULL;
28410         struct list_head *list;
28411         int err;
28412 diff -Nru a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
28413 --- a/drivers/media/video/saa7134/saa7134-video.c       Thu Jul 31 16:47:19 2003
28414 +++ b/drivers/media/video/saa7134/saa7134-video.c       Tue Aug 26 09:25:41 2003
28415 @@ -1131,7 +1131,7 @@
28416  
28417  static int video_open(struct inode *inode, struct file *file)
28418  {
28419 -       int minor = minor(inode->i_rdev);
28420 +       int minor = iminor(inode);
28421         struct saa7134_dev *h,*dev = NULL;
28422         struct saa7134_fh *fh;
28423         struct list_head *list;
28424 diff -Nru a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
28425 --- a/drivers/media/video/saa7185.c     Wed Aug 20 15:29:21 2003
28426 +++ b/drivers/media/video/saa7185.c     Sun Aug 31 16:14:05 2003
28427 @@ -98,6 +98,7 @@
28428                u8                 value)
28429  {
28430         struct saa7185 *encoder = i2c_get_clientdata(client);
28431 +
28432         dprintk(1, KERN_DEBUG "SAA7185: %02x set to %02x\n", reg, value);
28433         encoder->reg[reg] = value;
28434         return i2c_smbus_write_byte_data(client, reg, value);
28435 @@ -118,6 +119,7 @@
28436                 struct saa7185 *encoder = i2c_get_clientdata(client);
28437                 struct i2c_msg msg;
28438                 u8 block_data[32];
28439 +
28440                 msg.addr = client->addr;
28441                 msg.flags = client->flags;
28442                 while (len >= 2) {
28443 @@ -131,16 +133,16 @@
28444                                 data += 2;
28445                         } while (len >= 2 && data[0] == reg &&
28446                                  msg.len < 32);
28447 -                       if ((ret =
28448 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
28449 +                       if ((ret = i2c_transfer(client->adapter,
28450 +                                               &msg, 1)) < 0)
28451                                 break;
28452                 }
28453         } else {
28454                 /* do some slow I2C emulation kind of thing */
28455                 while (len >= 2) {
28456                         reg = *data++;
28457 -                       if ((ret =
28458 -                            saa7185_write(client, reg, *data++)) < 0)
28459 +                       if ((ret = saa7185_write(client, reg,
28460 +                                                *data++)) < 0)
28461                                 break;
28462                         len -= 2;
28463                 }
28464 @@ -434,6 +436,7 @@
28465  
28466         encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL);
28467         if (encoder == NULL) {
28468 +               kfree(client);
28469                 return -ENOMEM;
28470         }
28471         memset(encoder, 0, sizeof(struct saa7185));
28472 diff -Nru a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
28473 --- a/drivers/media/video/stradis.c     Thu Apr 24 03:35:23 2003
28474 +++ b/drivers/media/video/stradis.c     Tue Aug 26 09:25:41 2003
28475 @@ -1946,7 +1946,7 @@
28476  static int saa_open(struct inode *inode, struct file *file)
28477  {
28478         struct saa7146 *saa = NULL;
28479 -       unsigned int minor = minor(inode->i_rdev);
28480 +       unsigned int minor = iminor(inode);
28481         int i;
28482  
28483         for (i = 0; i < SAA7146_MAX; i++) {
28484 diff -Nru a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c
28485 --- a/drivers/media/video/tvmixer.c     Wed Aug 20 15:29:21 2003
28486 +++ b/drivers/media/video/tvmixer.c     Tue Aug 26 09:25:41 2003
28487 @@ -173,7 +173,7 @@
28488  
28489  static int tvmixer_open(struct inode *inode, struct file *file)
28490  {
28491 -        int i, minor = minor(inode->i_rdev);
28492 +        int i, minor = iminor(inode);
28493          struct TVMIXER *mix = NULL;
28494         struct i2c_client *client = NULL;
28495  
28496 diff -Nru a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
28497 --- a/drivers/media/video/videodev.c    Wed Aug  6 02:51:26 2003
28498 +++ b/drivers/media/video/videodev.c    Tue Sep  2 11:40:27 2003
28499 @@ -99,7 +99,7 @@
28500  
28501  struct video_device* video_devdata(struct file *file)
28502  {
28503 -       return video_device[minor(file->f_dentry->d_inode->i_rdev)];
28504 +       return video_device[iminor(file->f_dentry->d_inode)];
28505  }
28506  
28507  /*
28508 @@ -107,7 +107,7 @@
28509   */
28510  static int video_open(struct inode *inode, struct file *file)
28511  {
28512 -       unsigned int minor = minor(inode->i_rdev);
28513 +       unsigned int minor = iminor(inode);
28514         int err = 0;
28515         struct video_device *vfl;
28516         struct file_operations *old_fops;
28517 @@ -349,9 +349,9 @@
28518         if(video_device[vfd->minor]!=vfd)
28519                 panic("videodev: bad unregister");
28520  
28521 -       class_device_unregister(&vfd->class_dev);
28522         devfs_remove(vfd->devfs_name);
28523         video_device[vfd->minor]=NULL;
28524 +       class_device_unregister(&vfd->class_dev);
28525         up(&videodev_lock);
28526  }
28527  
28528 diff -Nru a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
28529 --- a/drivers/media/video/vpx3220.c     Wed Aug 20 15:29:21 2003
28530 +++ b/drivers/media/video/vpx3220.c     Sun Aug 31 16:14:05 2003
28531 @@ -76,6 +76,7 @@
28532                u8                 value)
28533  {
28534         struct vpx3220 *decoder = i2c_get_clientdata(client);
28535 +
28536         decoder->reg[reg] = value;
28537         return i2c_smbus_write_byte_data(client, reg, value);
28538  }
28539 @@ -294,6 +295,7 @@
28540  {
28541         int len = sizeof(init_common);
28542         const unsigned char *data = init_common;
28543 +
28544         while (len > 1) {
28545                 dprintk(1,
28546                         KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n",
28547 diff -Nru a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
28548 --- a/drivers/media/video/zoran.h       Wed Aug 20 15:29:21 2003
28549 +++ b/drivers/media/video/zoran.h       Sun Aug 31 16:14:06 2003
28550 @@ -146,7 +146,7 @@
28551  
28552  #define ZORAN_NAME    "ZORAN"  /* name of the device */
28553  
28554 -#define ZR_DEVNAME(zr) pci_name((zr)->pci_dev)
28555 +#define ZR_DEVNAME(zr) ((zr)->name)
28556  
28557  #define   BUZ_MAX_WIDTH   (zr->timing->Wa)
28558  #define   BUZ_MAX_HEIGHT  (zr->timing->Ha)
28559 @@ -383,7 +383,7 @@
28560  };
28561  
28562  struct zoran {
28563 -       struct video_device video_dev;
28564 +       struct video_device *video_dev;
28565  
28566         struct i2c_adapter i2c_adapter; /* */
28567         struct i2c_algo_bit_data i2c_algo;      /* */
28568 @@ -403,9 +403,7 @@
28569         struct tvnorm *timing;
28570  
28571         unsigned short id;      /* number of this device */
28572 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
28573         char name[32];          /* name of this device */
28574 -#endif
28575         struct pci_dev *pci_dev;        /* PCI device */
28576         unsigned char revision; /* revision of zr36057 */
28577         unsigned int zr36057_adr;       /* bus address of IO mem returned by PCI BIOS */
28578 diff -Nru a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
28579 --- a/drivers/media/video/zoran_card.c  Wed Aug 20 15:29:21 2003
28580 +++ b/drivers/media/video/zoran_card.c  Sun Aug 31 16:14:05 2003
28581 @@ -136,7 +136,8 @@
28582  MODULE_PARM_DESC(pass_through,
28583                  "Pass TV signal through to TV-out when idling");
28584  
28585 -int debug = 1;
28586 +static int debug = 1;
28587 +int *zr_debug = &debug;
28588  MODULE_PARM(debug, "i");
28589  MODULE_PARM_DESC(debug, "Debug level (0-4)");
28590  
28591 @@ -153,7 +154,7 @@
28592  
28593  #define dprintk(num, format, args...) \
28594         do { \
28595 -               if (debug >= num) \
28596 +               if (*zr_debug >= num) \
28597                         printk(format, ##args); \
28598         } while (0)
28599  
28600 @@ -623,6 +624,7 @@
28601  zoran_i2c_getsda (void *data)
28602  {
28603         struct zoran *zr = (struct zoran *) data;
28604 +
28605         return (btread(ZR36057_I2CBR) >> 1) & 1;
28606  }
28607  
28608 @@ -630,6 +632,7 @@
28609  zoran_i2c_getscl (void *data)
28610  {
28611         struct zoran *zr = (struct zoran *) data;
28612 +
28613         return btread(ZR36057_I2CBR) & 1;
28614  }
28615  
28616 @@ -638,6 +641,7 @@
28617                   int   state)
28618  {
28619         struct zoran *zr = (struct zoran *) data;
28620 +
28621         if (state)
28622                 zr->i2cbr |= 2;
28623         else
28624 @@ -650,6 +654,7 @@
28625                   int   state)
28626  {
28627         struct zoran *zr = (struct zoran *) data;
28628 +
28629         if (state)
28630                 zr->i2cbr |= 1;
28631         else
28632 @@ -766,6 +771,7 @@
28633                           struct zoran_jpg_settings *settings)
28634  {
28635         int err = 0, err0 = 0;
28636 +
28637         dprintk(4,
28638                 KERN_DEBUG
28639                 "%s: check_jpg_settings() - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
28640 @@ -977,7 +983,7 @@
28641         if (timeout) {
28642                 dprintk(1, ": time spent: %d\n", 1 * HZ - timeout);
28643         }
28644 -       if (debug > 1)
28645 +       if (*zr_debug > 1)
28646                 print_interrupts(zr);
28647         btwrite(icr, ZR36057_ICR);
28648  }
28649 @@ -986,6 +992,7 @@
28650  zr36057_init (struct zoran *zr)
28651  {
28652         unsigned long mem;
28653 +       void *vdev;
28654         unsigned mem_needed;
28655         int j;
28656         int two = 2;
28657 @@ -1040,11 +1047,16 @@
28658          * in case allocation fails */
28659         mem_needed = BUZ_NUM_STAT_COM * 4;
28660         mem = (unsigned long) kmalloc(mem_needed, GFP_KERNEL);
28661 -       if (!mem) {
28662 +       vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
28663 +       if (!mem || !vdev) {
28664                 dprintk(1,
28665                         KERN_ERR
28666                         "%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
28667                         ZR_DEVNAME(zr));
28668 +               if (vdev)
28669 +                       kfree(vdev);
28670 +               if (mem)
28671 +                       kfree((void *)mem);
28672                 return -ENOMEM;
28673         }
28674         memset((void *) mem, 0, mem_needed);
28675 @@ -1056,17 +1068,19 @@
28676         /*
28677          *   Now add the template and register the device unit.
28678          */
28679 -       memcpy(&zr->video_dev, &zoran_template, sizeof(zoran_template));
28680 -       strcpy(zr->video_dev.name, ZR_DEVNAME(zr));
28681 -       if (video_register_device
28682 -           (&zr->video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
28683 +       zr->video_dev = vdev;
28684 +       memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
28685 +       strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
28686 +       if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER,
28687 +                                 video_nr) < 0) {
28688                 zoran_unregister_i2c(zr);
28689                 kfree((void *) zr->stat_com);
28690 +               kfree(vdev);
28691                 return -1;
28692         }
28693  
28694         zoran_init_hardware(zr);
28695 -       if (debug > 2)
28696 +       if (*zr_debug > 2)
28697                 detect_guest_activity(zr);
28698         test_interrupts(zr);
28699         if (!pass_through) {
28700 @@ -1109,7 +1123,14 @@
28701         kfree((void *) zr->stat_com);
28702         zoran_proc_cleanup(zr);
28703         iounmap(zr->zr36057_mem);
28704 -       video_unregister_device(&zr->video_dev);
28705 +       pci_disable_device(zr->pci_dev);
28706 +       video_unregister_device(zr->video_dev);
28707 +}
28708 +
28709 +void
28710 +zoran_vdev_release (struct video_device *vdev)
28711 +{
28712 +       kfree(vdev);
28713  }
28714  
28715  static struct videocodec_master * __devinit
28716 @@ -1207,6 +1228,7 @@
28717                 } else {
28718                         int i;
28719                         unsigned short ss_vendor, ss_device;
28720 +
28721                         ss_vendor = zr->pci_dev->subsystem_vendor;
28722                         ss_device = zr->pci_dev->subsystem_device;
28723                         dprintk(1,
28724 @@ -1467,6 +1489,7 @@
28725  init_dc10_cards (void)
28726  {
28727         int i;
28728 +
28729         memset(zoran, 0, sizeof(zoran));
28730         printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n",
28731                MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION);
28732 @@ -1523,6 +1546,7 @@
28733         /* take care of Natoma chipset and a revision 1 zr36057 */
28734         for (i = 0; i < zoran_num; i++) {
28735                 struct zoran *zr = &zoran[i];
28736 +
28737                 if (pci_pci_problems & PCIPCI_NATOMA && zr->revision <= 1) {
28738                         zr->jpg_buffers.need_contiguous = 1;
28739                         dprintk(1,
28740 @@ -1546,6 +1570,7 @@
28741  unload_dc10_cards (void)
28742  {
28743         int i;
28744 +
28745         for (i = 0; i < zoran_num; i++)
28746                 zoran_release(&zoran[i]);
28747  }
28748 diff -Nru a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h
28749 --- a/drivers/media/video/zoran_card.h  Wed Aug 20 14:29:31 2003
28750 +++ b/drivers/media/video/zoran_card.h  Sun Aug 31 16:14:03 2003
28751 @@ -40,5 +40,6 @@
28752  extern int zoran_check_jpg_settings(struct zoran *zr,
28753                                     struct zoran_jpg_settings *settings);
28754  extern void zoran_open_init_params(struct zoran *zr);
28755 +extern void zoran_vdev_release(struct video_device *vdev);
28756  
28757  #endif                         /* __ZORAN_CARD_H__ */
28758 diff -Nru a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
28759 --- a/drivers/media/video/zoran_device.c        Wed Aug 20 14:29:31 2003
28760 +++ b/drivers/media/video/zoran_device.c        Sun Aug 31 16:14:05 2003
28761 @@ -58,11 +58,11 @@
28762  extern const struct zoran_format zoran_formats[];
28763  extern const int zoran_num_formats;
28764  
28765 -extern int debug;
28766 +extern int *zr_debug;
28767  
28768  #define dprintk(num, format, args...) \
28769         do { \
28770 -               if (debug >= num) \
28771 +               if (*zr_debug >= num) \
28772                         printk(format, ##args); \
28773         } while (0)
28774  
28775 @@ -170,7 +170,7 @@
28776  static void
28777  dump_guests (struct zoran *zr)
28778  {
28779 -       if (debug > 2) {
28780 +       if (*zr_debug > 2) {
28781                 int i, guest[8];
28782  
28783                 for (i = 1; i < 8; i++) {       // Don't read jpeg codec here
28784 @@ -190,6 +190,7 @@
28785  get_time (void)
28786  {
28787         struct timeval tv;
28788 +
28789         do_gettimeofday(&tv);
28790         return (1000000 * tv.tv_sec + tv.tv_usec);
28791  }
28792 @@ -868,8 +869,8 @@
28793  void
28794  print_interrupts (struct zoran *zr)
28795  {
28796 -       int res, noerr;
28797 -       noerr = 0;
28798 +       int res, noerr = 0;
28799 +
28800         printk(KERN_INFO "%s: interrupts received:", ZR_DEVNAME(zr));
28801         if ((res = zr->field_counter) < -1 || res > 1) {
28802                 printk(" FD:%d", res);
28803 @@ -931,6 +932,7 @@
28804  count_reset_interrupt (struct zoran *zr)
28805  {
28806         u32 isr;
28807 +
28808         if ((isr = btread(ZR36057_ISR) & 0x78000000)) {
28809                 if (isr & ZR36057_ISR_GIRQ1) {
28810                         btwrite(ZR36057_ISR_GIRQ1, ZR36057_ISR);
28811 @@ -961,6 +963,7 @@
28812  jpeg_start (struct zoran *zr)
28813  {
28814         int reg;
28815 +
28816         zr->frame_num = 0;
28817  
28818         /* deassert P_reset, disable code transfer, deassert Active */
28819 @@ -1272,7 +1275,7 @@
28820                 zr->num_errors++;
28821  
28822                 /* Report error */
28823 -               if (debug > 1 && zr->num_errors <= 8) {
28824 +               if (*zr_debug > 1 && zr->num_errors <= 8) {
28825                         long frame;
28826                         frame =
28827                             zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME];
28828 @@ -1453,38 +1456,23 @@
28829                                             0) {
28830                                                 /* it is finished, notify the user */
28831  
28832 -                                               zr->v4l_buffers.buffer[zr->
28833 -                                                                      v4l_grab_frame].
28834 -                                                   state = BUZ_STATE_DONE;
28835 -                                               zr->v4l_buffers.buffer[zr->
28836 -                                                                      v4l_grab_frame].
28837 -                                                   bs.seq =
28838 -                                                   zr->v4l_grab_seq;
28839 -                                               do_gettimeofday(&zr->
28840 -                                                               v4l_buffers.
28841 -                                                               buffer[zr->
28842 -                                                                      v4l_grab_frame].
28843 -                                                               bs.
28844 -                                                               timestamp);
28845 -                                               zr->v4l_grab_frame =
28846 -                                                   NO_GRAB_ACTIVE;
28847 +                                               zr->v4l_buffers.buffer[zr->v4l_grab_frame].state = BUZ_STATE_DONE;
28848 +                                               zr->v4l_buffers.buffer[zr->v4l_grab_frame].bs.seq = zr->v4l_grab_seq;
28849 +                                               do_gettimeofday(&zr->v4l_buffers.buffer[zr->v4l_grab_frame].bs.timestamp);
28850 +                                               zr->v4l_grab_frame = NO_GRAB_ACTIVE;
28851                                                 zr->v4l_pend_tail++;
28852                                         }
28853                                 }
28854  
28855                                 if (zr->v4l_grab_frame == NO_GRAB_ACTIVE)
28856 -                                       wake_up_interruptible(&zr->
28857 -                                                             v4l_capq);
28858 +                                       wake_up_interruptible(&zr->v4l_capq);
28859  
28860                                 /* Check if there is another grab queued */
28861  
28862                                 if (zr->v4l_grab_frame == NO_GRAB_ACTIVE &&
28863 -                                   zr->v4l_pend_tail !=
28864 -                                   zr->v4l_pend_head) {
28865 +                                   zr->v4l_pend_tail != zr->v4l_pend_head) {
28866  
28867 -                                       int frame =
28868 -                                           zr->v4l_pend[zr->
28869 -                                                        v4l_pend_tail &
28870 +                                       int frame = zr->v4l_pend[zr->v4l_pend_tail &
28871                                                          V4L_MASK_FRAME];
28872                                         u32 reg;
28873  
28874 @@ -1544,7 +1532,7 @@
28875  
28876                         if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS ||
28877                             zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
28878 -                               if (debug > 1 &&
28879 +                               if (*zr_debug > 1 &&
28880                                     (!zr->frame_num || zr->JPEG_error)) {
28881                                         printk(KERN_INFO
28882                                                "%s: first frame ready: state=0x%08x odd_even=%d field_per_buff=%d delay=%d\n",
28883 @@ -1559,11 +1547,8 @@
28884                                                 int i;
28885                                                 strcpy(sv, sc);
28886                                                 for (i = 0; i < 4; i++) {
28887 -                                                       if (zr->
28888 -                                                           stat_com[i] &
28889 -                                                           1)
28890 -                                                               sv[i] =
28891 -                                                                   '1';
28892 +                                                       if (zr->stat_com[i] & 1)
28893 +                                                               sv[i] = '1';
28894                                                 }
28895                                                 sv[4] = 0;
28896                                                 printk(KERN_INFO
28897 @@ -1584,7 +1569,7 @@
28898                                                     zr->JPEG_missed;
28899                                 }
28900  
28901 -                               if (debug > 2 && zr->frame_num < 6) {
28902 +                               if (*zr_debug > 2 && zr->frame_num < 6) {
28903                                         int i;
28904                                         printk("%s: seq=%ld stat_com:",
28905                                                ZR_DEVNAME(zr), zr->jpg_seq_num);
28906 @@ -1643,10 +1628,11 @@
28907  zoran_set_pci_master (struct zoran *zr,
28908                       int           set_master)
28909  {
28910 -       u16 command;
28911         if (set_master) {
28912                 pci_set_master(zr->pci_dev);
28913         } else {
28914 +               u16 command;
28915 +
28916                 pci_read_config_word(zr->pci_dev, PCI_COMMAND, &command);
28917                 command &= ~PCI_COMMAND_MASTER;
28918                 pci_write_config_word(zr->pci_dev, PCI_COMMAND, command);
28919 @@ -1657,6 +1643,7 @@
28920  zoran_init_hardware (struct zoran *zr)
28921  {
28922         int j, zero = 0;
28923 +
28924         /* Enable bus-mastering */
28925         zoran_set_pci_master(zr, 1);
28926  
28927 @@ -1718,6 +1705,7 @@
28928  zr36057_init_vfe (struct zoran *zr)
28929  {
28930         u32 reg;
28931 +
28932         reg = btread(ZR36057_VFESPFR);
28933         reg |= ZR36057_VFESPFR_LittleEndian;
28934         reg &= ~ZR36057_VFESPFR_VCLKPol;
28935 @@ -1748,6 +1736,7 @@
28936         if (zr->card.type == LML33 &&
28937             (cmd == DECODER_SET_NORM || DECODER_SET_INPUT)) {
28938                 int res;
28939 +
28940                 // Bt819 needs to reset its FIFO buffer using #FRST pin and
28941                 // LML33 card uses GPIO(7) for that.
28942                 GPIO(zr, 7, 0);
28943 diff -Nru a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
28944 --- a/drivers/media/video/zoran_driver.c        Wed Aug 20 14:29:31 2003
28945 +++ b/drivers/media/video/zoran_driver.c        Sun Aug 31 16:14:05 2003
28946 @@ -51,6 +51,7 @@
28947  #include <linux/delay.h>
28948  #include <linux/slab.h>
28949  #include <linux/pci.h>
28950 +#include <linux/vmalloc.h>
28951  
28952  #include <linux/interrupt.h>
28953  #include <linux/i2c.h>
28954 @@ -187,11 +188,11 @@
28955  #   include <linux/bigphysarea.h>
28956  #endif
28957  
28958 -extern int debug;
28959 +extern int *zr_debug;
28960  
28961  #define dprintk(num, format, args...) \
28962         do { \
28963 -               if (debug >= num) \
28964 +               if (*zr_debug >= num) \
28965                         printk(format, ##args); \
28966         } while (0)
28967  
28968 @@ -370,6 +371,7 @@
28969                         int n =
28970                             (fh->v4l_buffers.buffer_size + PAGE_SIZE -
28971                              1) / PAGE_SIZE;
28972 +
28973                         mem =
28974                             (unsigned char *) bigphysarea_alloc_pages(n, 0,
28975                                                                       GFP_KERNEL);
28976 @@ -412,6 +414,7 @@
28977                                 int size =
28978                                     fh->v4l_buffers.num_buffers *
28979                                     fh->v4l_buffers.buffer_size;
28980 +
28981                                 pmem = get_high_mem(size);
28982                                 if (pmem == 0) {
28983                                         dprintk(1,
28984 @@ -847,9 +850,10 @@
28985                 if (res)
28986                         return res;
28987         }
28988 -       if ((res =
28989 -            zoran_v4l_set_format(file, mp->width, mp->height,
28990 -                                 &zoran_formats[i])))
28991 +       if ((res = zoran_v4l_set_format(file,
28992 +                                       mp->width,
28993 +                                       mp->height,
28994 +                                       &zoran_formats[i])))
28995                 return res;
28996         zr->v4l_settings = fh->v4l_settings;
28997  
28998 @@ -1144,7 +1148,7 @@
28999                 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME];
29000  
29001         /* buffer should now be in BUZ_STATE_DONE */
29002 -       if (debug > 0)
29003 +       if (*zr_debug > 0)
29004                 if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE)
29005                         dprintk(2,
29006                                 KERN_ERR
29007 @@ -1268,7 +1272,7 @@
29008  
29009         /* find the device */
29010         for (i = 0; i < zoran_num; i++) {
29011 -               if (zoran[i].video_dev.minor == minor) {
29012 +               if (zoran[i].video_dev->minor == minor) {
29013                         zr = &zoran[i];
29014                         break;
29015                 }
29016 @@ -1424,7 +1428,7 @@
29017                 /* disable interrupts */
29018                 btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
29019  
29020 -               if (debug > 1)
29021 +               if (*zr_debug > 1)
29022                         print_interrupts(zr);
29023  
29024                 /* Overlay off */
29025 @@ -2032,6 +2036,7 @@
29026         case VIDIOCGCAP:
29027         {
29028                 struct video_capability *vcap = arg;
29029 +
29030                 dprintk(3, KERN_DEBUG "%s: VIDIOCGCAP\n", ZR_DEVNAME(zr));
29031  
29032                 memset(vcap, 0, sizeof(struct video_capability));
29033 @@ -2154,6 +2159,7 @@
29034  
29035                 for (i = 0; i < zoran_num_formats; i++) {
29036                         const struct zoran_format *fmt = &zoran_formats[i];
29037 +
29038                         if (fmt->palette != -1 &&
29039                             fmt->flags & ZORAN_FORMAT_OVERLAY &&
29040                             fmt->palette == vpict->palette &&
29041 @@ -2203,7 +2209,9 @@
29042         case VIDIOCGWIN:
29043         {
29044                 struct video_window *vwin = arg;
29045 +
29046                 dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr));
29047 +
29048                 memset(vwin, 0, sizeof(struct video_window));
29049                 down(&zr->resource_lock);
29050                 vwin->x = fh->overlay_settings.x;
29051 @@ -2241,7 +2249,9 @@
29052         case VIDIOCGFBUF:
29053         {
29054                 struct video_buffer *vbuf = arg;
29055 +
29056                 dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr));
29057 +
29058                 down(&zr->resource_lock);
29059                 *vbuf = zr->buffer;
29060                 up(&zr->resource_lock);
29061 @@ -2285,8 +2295,10 @@
29062         case VIDIOCSYNC:
29063         {
29064                 int *frame = arg, res;
29065 +
29066                 dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n",
29067                         ZR_DEVNAME(zr), *frame);
29068 +
29069                 down(&zr->resource_lock);
29070                 res = v4l_sync(file, *frame);
29071                 up(&zr->resource_lock);
29072 @@ -2300,11 +2312,13 @@
29073         {
29074                 struct video_mmap *vmap = arg;
29075                 int res;
29076 +
29077                 dprintk(3,
29078                         KERN_DEBUG
29079                         "%s: VIDIOCMCAPTURE - frame=%d, geom=%dx%d, fmt=%d\n",
29080                         ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height,
29081                         vmap->format);
29082 +
29083                 down(&zr->resource_lock);
29084                 res = v4l_grab(file, vmap);
29085                 up(&zr->resource_lock);
29086 @@ -2358,7 +2372,8 @@
29087                 struct video_unit *vunit = arg;
29088  
29089                 dprintk(3, KERN_DEBUG "%s: VIDIOCGUNIT\n", ZR_DEVNAME(zr));
29090 -               vunit->video = zr->video_dev.minor;
29091 +
29092 +               vunit->video = zr->video_dev->minor;
29093                 vunit->vbi = VIDEO_NO_UNIT;
29094                 vunit->radio = VIDEO_NO_UNIT;
29095                 vunit->audio = VIDEO_NO_UNIT;
29096 @@ -2393,6 +2408,7 @@
29097         case BUZIOC_G_PARAMS:
29098         {
29099                 struct zoran_params *bparams = arg;
29100 +
29101                 dprintk(3, KERN_DEBUG "%s: BUZIOC_G_PARAMS\n", ZR_DEVNAME(zr));
29102  
29103                 memset(bparams, 0, sizeof(struct zoran_params));
29104 @@ -2686,6 +2702,7 @@
29105                 struct v4l2_fmtdesc *fmt = arg;
29106                 int index = fmt->index, num = -1, i, flag = 0, type =
29107                     fmt->type;
29108 +
29109                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUM_FMT - index=%d\n",
29110                         ZR_DEVNAME(zr), fmt->index);
29111  
29112 @@ -3530,6 +3547,7 @@
29113         case VIDIOC_QUERYCTRL:
29114         {
29115                 struct v4l2_queryctrl *ctrl = arg;
29116 +
29117                 dprintk(3, KERN_DEBUG "%s: VIDIOC_QUERYCTRL - id=%d\n",
29118                         ZR_DEVNAME(zr), ctrl->id);
29119  
29120 @@ -3571,6 +3589,7 @@
29121         case VIDIOC_G_CTRL:
29122         {
29123                 struct v4l2_control *ctrl = arg;
29124 +
29125                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_CTRL - id=%d\n",
29126                         ZR_DEVNAME(zr), ctrl->id);
29127  
29128 @@ -3652,6 +3671,7 @@
29129         case VIDIOC_ENUMSTD:
29130         {
29131                 struct v4l2_standard *std = arg;
29132 +
29133                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUMSTD - index=%d\n",
29134                         ZR_DEVNAME(zr), std->index);
29135  
29136 @@ -3707,6 +3727,7 @@
29137         {
29138                 v4l2_std_id *std = arg;
29139                 int norm;
29140 +
29141                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr));
29142  
29143                 down(&zr->resource_lock);
29144 @@ -3804,6 +3825,7 @@
29145         case VIDIOC_G_INPUT:
29146         {
29147                 int *input = arg;
29148 +
29149                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr));
29150  
29151                 down(&zr->resource_lock);
29152 @@ -3817,6 +3839,7 @@
29153         case VIDIOC_S_INPUT:
29154         {
29155                 int *input = arg, res = 0;
29156 +
29157                 dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n",
29158                         ZR_DEVNAME(zr), *input);
29159  
29160 @@ -3835,6 +3858,7 @@
29161         case VIDIOC_ENUMOUTPUT:
29162         {
29163                 struct v4l2_output *outp = arg;
29164 +
29165                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUMOUTPUT - index=%d\n",
29166                         ZR_DEVNAME(zr), outp->index);
29167  
29168 @@ -4005,7 +4029,9 @@
29169         case VIDIOC_G_JPEGCOMP:
29170         {
29171                 struct v4l2_jpegcompression *params = arg;
29172 -               dprintk(3, KERN_DEBUG "%s: VIDIOC_G_JPEGCOMP\n", ZR_DEVNAME(zr));
29173 +
29174 +               dprintk(3, KERN_DEBUG "%s: VIDIOC_G_JPEGCOMP\n",
29175 +                       ZR_DEVNAME(zr));
29176  
29177                 memset(params, 0, sizeof(*params));
29178  
29179 @@ -4175,6 +4201,7 @@
29180                         } else if (fmt->type ==
29181                                    V4L2_BUF_TYPE_VIDEO_CAPTURE) {
29182                                 int i;
29183 +
29184                                 for (i = 0; i < zoran_num_formats; i++)
29185                                         if (zoran_formats[i].fourcc ==
29186                                             fmt->fmt.pix.pixelformat)
29187 @@ -4321,6 +4348,7 @@
29188  zoran_vm_open (struct vm_area_struct *vma)
29189  {
29190         struct zoran_mapping *map = vma->vm_private_data;
29191 +
29192         map->count++;
29193  }
29194  
29195 @@ -4665,5 +4693,6 @@
29196  #endif
29197         .hardware = ZORAN_HARDWARE,
29198         .fops = &zoran_fops,
29199 +       .release = &zoran_vdev_release,
29200         .minor = -1
29201  };
29202 diff -Nru a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c
29203 --- a/drivers/media/video/zoran_procfs.c        Wed Aug 20 15:38:07 2003
29204 +++ b/drivers/media/video/zoran_procfs.c        Sun Aug 31 16:14:05 2003
29205 @@ -49,11 +49,11 @@
29206  #include "zoran.h"
29207  #include "zoran_procfs.h"
29208  
29209 -extern int debug;
29210 +extern int *zr_debug;
29211  
29212  #define dprintk(num, format, args...) \
29213         do { \
29214 -               if (debug >= num) \
29215 +               if (*zr_debug >= num) \
29216                         printk(format, ##args); \
29217         } while (0)
29218  
29219 @@ -248,6 +248,7 @@
29220  {
29221  #ifdef CONFIG_PROC_FS
29222         char name[8];
29223 +
29224         snprintf(name, 7, "zoran%d", zr->id);
29225         if ((zr->zoran_proc = create_proc_entry(name, 0, 0))) {
29226                 zr->zoran_proc->read_proc = zoran_read_proc;
29227 @@ -272,6 +273,7 @@
29228  {
29229  #ifdef CONFIG_PROC_FS
29230         char name[8];
29231 +
29232         snprintf(name, 7, "zoran%d", zr->id);
29233         if (zr->zoran_proc) {
29234                 remove_proc_entry(name, 0);
29235 diff -Nru a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
29236 --- a/drivers/mtd/devices/Kconfig       Mon Aug 18 11:25:06 2003
29237 +++ b/drivers/mtd/devices/Kconfig       Sun Aug 24 03:43:25 2003
29238 @@ -102,7 +102,7 @@
29239  
29240  config MTD_BLKMTD
29241         tristate "MTD emulation using block device"
29242 -       depends on MTD && BROKEN
29243 +       depends on MTD
29244         help
29245           This driver allows a block device to appear as an MTD. It would
29246           generally be used in the following cases:
29247 diff -Nru a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c
29248 --- a/drivers/mtd/maps/ceiva.c  Wed May 28 08:01:03 2003
29249 +++ b/drivers/mtd/maps/ceiva.c  Sun Aug 31 16:14:08 2003
29250 @@ -64,23 +64,23 @@
29251  
29252  static struct mtd_partition ceiva_partitions[] = {
29253         {
29254 -               name: "Ceiva BOOT partition",
29255 -               size:   BOOT_PARTITION_SIZE_KiB*1024,
29256 -               offset: 0,
29257 +               .name = "Ceiva BOOT partition",
29258 +               .size   = BOOT_PARTITION_SIZE_KiB*1024,
29259 +               .offset = 0,
29260  
29261         },{
29262 -               name: "Ceiva parameters partition",
29263 -               size:   PARAMS_PARTITION_SIZE_KiB*1024,
29264 -               offset: (16 + 8) * 1024,
29265 +               .name = "Ceiva parameters partition",
29266 +               .size   = PARAMS_PARTITION_SIZE_KiB*1024,
29267 +               .offset = (16 + 8) * 1024,
29268         },{
29269 -               name: "Ceiva kernel partition",
29270 -               size: (KERNEL_PARTITION_SIZE_KiB)*1024,
29271 -               offset: 0x20000,
29272 +               .name = "Ceiva kernel partition",
29273 +               .size = (KERNEL_PARTITION_SIZE_KiB)*1024,
29274 +               .offset = 0x20000,
29275  
29276         },{
29277 -               name: "Ceiva root filesystem partition",
29278 -               offset: MTDPART_OFS_APPEND,
29279 -               size: (ROOT_PARTITION_SIZE_KiB)*1024,
29280 +               .name = "Ceiva root filesystem partition",
29281 +               .offset = MTDPART_OFS_APPEND,
29282 +               .size = (ROOT_PARTITION_SIZE_KiB)*1024,
29283         }
29284  };
29285  #endif
29286 diff -Nru a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
29287 --- a/drivers/mtd/maps/pcmciamtd.c      Wed Jun 25 03:30:03 2003
29288 +++ b/drivers/mtd/maps/pcmciamtd.c      Sat Aug 23 08:27:27 2003
29289 @@ -344,9 +344,8 @@
29290   * still open, this will be postponed until it is closed.
29291   */
29292  
29293 -static void pcmciamtd_release(u_long arg)
29294 +static void pcmciamtd_release(dev_link_t *link)
29295  {
29296 -       dev_link_t *link = (dev_link_t *)arg;
29297         struct pcmciamtd_dev *dev = link->priv;
29298  
29299         DEBUG(3, "link = 0x%p", link);
29300 @@ -564,7 +563,7 @@
29301  
29302         if(!dev->win_size) {
29303                 err("Cant allocate memory window");
29304 -               pcmciamtd_release((u_long)link);
29305 +               pcmciamtd_release(link);
29306                 return;
29307         }
29308         DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10);
29309 @@ -576,7 +575,7 @@
29310         dev->win_base = ioremap(req.Base, req.Size);
29311         if(!dev->win_base) {
29312                 err("ioremap(%lu, %u) failed", req.Base, req.Size);
29313 -               pcmciamtd_release((u_long)link);
29314 +               pcmciamtd_release(link);
29315                 return;
29316         }
29317         DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x",
29318 @@ -631,7 +630,7 @@
29319         
29320         if(!mtd) {
29321                 DEBUG(1, "Cant find an MTD");
29322 -               pcmciamtd_release((u_long)link);
29323 +               pcmciamtd_release(link);
29324                 return;
29325         }
29326  
29327 @@ -671,7 +670,7 @@
29328                 map_destroy(mtd);
29329                 dev->mtd_info = NULL;
29330                 err("Couldnt register MTD device");
29331 -               pcmciamtd_release((u_long)link);
29332 +               pcmciamtd_release(link);
29333                 return;
29334         }
29335         snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index);
29336 @@ -683,7 +682,7 @@
29337   cs_failed:
29338         cs_error(link->handle, last_fn, last_ret);
29339         err("CS Error, exiting");
29340 -       pcmciamtd_release((u_long)link);
29341 +       pcmciamtd_release(link);
29342         return;
29343  }
29344  
29345 @@ -710,7 +709,7 @@
29346                                 del_mtd_device(dev->mtd_info);
29347                                 info("mtd%d: Removed", dev->mtd_info->index);
29348                         }
29349 -                       mod_timer(&link->release, jiffies + HZ/20);
29350 +                       pcmciamtd_release(link);
29351                 }
29352                 break;
29353         case CS_EVENT_CARD_INSERTION:
29354 @@ -751,10 +750,8 @@
29355  {
29356         DEBUG(3, "link=0x%p", link);
29357  
29358 -       del_timer(&link->release);
29359 -
29360         if(link->state & DEV_CONFIG) {
29361 -               pcmciamtd_release((u_long)link);
29362 +               pcmciamtd_release(link);
29363         }
29364  
29365         if (link->handle) {
29366 @@ -789,10 +786,6 @@
29367         memset(dev, 0, sizeof(*dev));
29368         link = &dev->link;
29369         link->priv = dev;
29370 -
29371 -       init_timer(&link->release);
29372 -       link->release.function = &pcmciamtd_release;
29373 -       link->release.data = (u_long)link;
29374  
29375         link->conf.Attributes = 0;
29376         link->conf.IntType = INT_MEMORY;
29377 diff -Nru a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
29378 --- a/drivers/mtd/mtdchar.c     Wed May 28 08:01:05 2003
29379 +++ b/drivers/mtd/mtdchar.c     Tue Aug 26 09:25:41 2003
29380 @@ -59,7 +59,7 @@
29381  
29382  static int mtd_open(struct inode *inode, struct file *file)
29383  {
29384 -       int minor = minor(inode->i_rdev);
29385 +       int minor = iminor(inode);
29386         int devnum = minor >> 1;
29387         struct mtd_info *mtd;
29388  
29389 diff -Nru a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c
29390 --- a/drivers/mtd/nand/autcpu12.c       Mon Jun 23 05:34:08 2003
29391 +++ b/drivers/mtd/nand/autcpu12.c       Sun Aug 31 16:14:08 2003
29392 @@ -73,39 +73,39 @@
29393  extern struct nand_oobinfo jffs2_oobinfo;
29394  
29395  static struct mtd_partition partition_info16k[] = {
29396 -       { name: "AUTCPU12 flash partition 1",
29397 -         offset:  0,
29398 -         size:    8 * SZ_1M },
29399 -       { name: "AUTCPU12 flash partition 2",
29400 -         offset:  8 * SZ_1M,
29401 -         size:    8 * SZ_1M },
29402 +       { .name = "AUTCPU12 flash partition 1",
29403 +         .offset  = 0,
29404 +         .size =    8 * SZ_1M },
29405 +       { .name = "AUTCPU12 flash partition 2",
29406 +         .offset =  8 * SZ_1M,
29407 +         .size =    8 * SZ_1M },
29408  };
29409  
29410  static struct mtd_partition partition_info32k[] = {
29411 -       { name: "AUTCPU12 flash partition 1",
29412 -         offset:  0,
29413 -         size:    8 * SZ_1M },
29414 -       { name: "AUTCPU12 flash partition 2",
29415 -         offset:  8 * SZ_1M,
29416 -         size:   24 * SZ_1M },
29417 +       { .name = "AUTCPU12 flash partition 1",
29418 +         .offset  = 0,
29419 +         .size =    8 * SZ_1M },
29420 +       { .name = "AUTCPU12 flash partition 2",
29421 +         .offset =  8 * SZ_1M,
29422 +         .size =   24 * SZ_1M },
29423  };
29424  
29425  static struct mtd_partition partition_info64k[] = {
29426 -       { name: "AUTCPU12 flash partition 1",
29427 -         offset:  0,
29428 -         size:   16 * SZ_1M },
29429 -       { name: "AUTCPU12 flash partition 2",
29430 -         offset: 16 * SZ_1M,
29431 -         size:   48 * SZ_1M },
29432 +       { .name = "AUTCPU12 flash partition 1",
29433 +         .offset  = 0,
29434 +         .size =   16 * SZ_1M },
29435 +       { .name = "AUTCPU12 flash partition 2",
29436 +         .offset = 16 * SZ_1M,
29437 +         .size =   48 * SZ_1M },
29438  };
29439  
29440  static struct mtd_partition partition_info128k[] = {
29441 -       { name: "AUTCPU12 flash partition 1",
29442 -         offset:  0,
29443 -         size:   16 * SZ_1M },
29444 -       { name: "AUTCPU12 flash partition 2",
29445 -         offset: 16 * SZ_1M,
29446 -         size:   112 * SZ_1M },
29447 +       { .name = "AUTCPU12 flash partition 1",
29448 +         .offset  = 0,
29449 +         .size =   16 * SZ_1M },
29450 +       { .name = "AUTCPU12 flash partition 2",
29451 +         .offset = 16 * SZ_1M,
29452 +         .size =   112 * SZ_1M },
29453  };
29454  
29455  #define NUM_PARTITIONS16K 2
29456 diff -Nru a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
29457 --- a/drivers/mtd/nand/edb7312.c        Wed May 28 08:01:25 2003
29458 +++ b/drivers/mtd/nand/edb7312.c        Sun Aug 31 16:14:08 2003
29459 @@ -71,9 +71,9 @@
29460   * Define static partitions for flash device
29461   */
29462  static struct mtd_partition partition_info[] = {
29463 -       { name: "EP7312 Nand Flash",
29464 -                 offset: 0,
29465 -                 size: 8*1024*1024 }
29466 +       { .name = "EP7312 Nand Flash",
29467 +                 .offset = 0,
29468 +                 .size = 8*1024*1024 }
29469  };
29470  #define NUM_PARTITIONS 1
29471  
29472 diff -Nru a/drivers/net/3c501.c b/drivers/net/3c501.c
29473 --- a/drivers/net/3c501.c       Sun Apr 20 22:41:08 2003
29474 +++ b/drivers/net/3c501.c       Tue Aug 26 13:21:28 2003
29475 @@ -307,7 +307,7 @@
29476         dev->stop = &el1_close;
29477         dev->get_stats = &el1_get_stats;
29478         dev->set_multicast_list = &set_multicast_list;
29479 -       dev->do_ioctl = netdev_ioctl;
29480 +       dev->ethtool_ops = &netdev_ethtool_ops;
29481  
29482         /*
29483          *      Setup the generic properties
29484 @@ -857,86 +857,31 @@
29485         }
29486  }
29487  
29488 -/**
29489 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
29490 - * @dev: network interface on which out-of-band action is to be performed
29491 - * @useraddr: userspace address to which data is to be read and returned
29492 - *
29493 - * Process the various commands of the SIOCETHTOOL interface.
29494 - */
29495  
29496 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
29497 +static void netdev_get_drvinfo(struct net_device *dev,
29498 +                              struct ethtool_drvinfo *info)
29499  {
29500 -       u32 ethcmd;
29501 -
29502 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
29503 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
29504 -
29505 -       if (get_user(ethcmd, (u32 *)useraddr))
29506 -               return -EFAULT;
29507 -
29508 -       switch (ethcmd) {
29509 -
29510 -       case ETHTOOL_GDRVINFO: {
29511 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
29512 -               strcpy (info.driver, DRV_NAME);
29513 -               strcpy (info.version, DRV_VERSION);
29514 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
29515 -               if (copy_to_user (useraddr, &info, sizeof (info)))
29516 -                       return -EFAULT;
29517 -               return 0;
29518 -       }
29519 -
29520 -       /* get message-level */
29521 -       case ETHTOOL_GMSGLVL: {
29522 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
29523 -               edata.data = debug;
29524 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
29525 -                       return -EFAULT;
29526 -               return 0;
29527 -       }
29528 -       /* set message-level */
29529 -       case ETHTOOL_SMSGLVL: {
29530 -               struct ethtool_value edata;
29531 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
29532 -                       return -EFAULT;
29533 -               debug = edata.data;
29534 -               return 0;
29535 -       }
29536 -
29537 -       default:
29538 -               break;
29539 -       }
29540 -
29541 -       return -EOPNOTSUPP;
29542 +       strcpy(info->driver, DRV_NAME);
29543 +       strcpy(info->version, DRV_VERSION);
29544 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
29545  }
29546  
29547 -/**
29548 - * netdev_ioctl: Handle network interface ioctls
29549 - * @dev: network interface on which out-of-band action is to be performed
29550 - * @rq: user request data
29551 - * @cmd: command issued by user
29552 - *
29553 - * Process the various out-of-band ioctls passed to this driver.
29554 - */
29555 +static u32 netdev_get_msglevel(struct net_device *dev)
29556 +{
29557 +       return debug;
29558 +}
29559  
29560 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
29561 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
29562  {
29563 -       int rc = 0;
29564 +       debug = level;
29565 +}
29566  
29567 -       switch (cmd) {
29568 -       case SIOCETHTOOL:
29569 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
29570 -               break;
29571 -
29572 -       default:
29573 -               rc = -EOPNOTSUPP;
29574 -               break;
29575 -       }
29576 +static struct ethtool_ops netdev_ethtool_ops = {
29577 +       .get_drvinfo            = netdev_get_drvinfo,
29578 +       .get_msglevel           = netdev_get_msglevel,
29579 +       .set_msglevel           = netdev_set_msglevel,
29580 +};
29581  
29582 -       return rc;
29583 -}
29584
29585  #ifdef MODULE
29586  
29587  static struct net_device dev_3c501 = {
29588 diff -Nru a/drivers/net/3c501.h b/drivers/net/3c501.h
29589 --- a/drivers/net/3c501.h       Sun Apr 20 22:41:08 2003
29590 +++ b/drivers/net/3c501.h       Tue Aug 26 13:21:28 2003
29591 @@ -14,7 +14,7 @@
29592  static int  el1_close(struct net_device *dev);
29593  static struct net_device_stats *el1_get_stats(struct net_device *dev);
29594  static void set_multicast_list(struct net_device *dev);
29595 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
29596 +static struct ethtool_ops netdev_ethtool_ops;
29597  
29598  #define EL1_IO_EXTENT  16
29599  
29600 diff -Nru a/drivers/net/3c503.c b/drivers/net/3c503.c
29601 --- a/drivers/net/3c503.c       Mon Feb 24 10:34:15 2003
29602 +++ b/drivers/net/3c503.c       Tue Aug 26 13:29:32 2003
29603 @@ -80,7 +80,7 @@
29604                            int ring_offset);
29605  static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
29606                          int ring_page);
29607 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
29608 +static struct ethtool_ops netdev_ethtool_ops;
29609  
29610  \f
29611  /* This routine probes for a memory-mapped 3c503 board by looking for
29612 @@ -308,7 +308,7 @@
29613  
29614      dev->open = &el2_open;
29615      dev->stop = &el2_close;
29616 -    dev->do_ioctl = &netdev_ioctl;
29617 +    dev->ethtool_ops = &netdev_ethtool_ops;
29618  
29619      if (dev->mem_start)
29620         printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
29621 @@ -617,69 +617,18 @@
29622      return;
29623  }
29624  
29625 -/**
29626 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
29627 - * @dev: network interface on which out-of-band action is to be performed
29628 - * @useraddr: userspace address to which data is to be read and returned
29629 - *
29630 - * Process the various commands of the SIOCETHTOOL interface.
29631 - */
29632  
29633 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
29634 +static void netdev_get_drvinfo(struct net_device *dev,
29635 +                              struct ethtool_drvinfo *info)
29636  {
29637 -       u32 ethcmd;
29638 -
29639 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
29640 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
29641 -
29642 -       if (get_user(ethcmd, (u32 *)useraddr))
29643 -               return -EFAULT;
29644 -
29645 -       switch (ethcmd) {
29646 -
29647 -       case ETHTOOL_GDRVINFO: {
29648 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
29649 -               strcpy (info.driver, DRV_NAME);
29650 -               strcpy (info.version, DRV_VERSION);
29651 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
29652 -               if (copy_to_user (useraddr, &info, sizeof (info)))
29653 -                       return -EFAULT;
29654 -               return 0;
29655 -       }
29656 -
29657 -       default:
29658 -               break;
29659 -       }
29660 -
29661 -       return -EOPNOTSUPP;
29662 +       strcpy(info->driver, DRV_NAME);
29663 +       strcpy(info->version, DRV_VERSION);
29664 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
29665  }
29666  
29667 -/**
29668 - * netdev_ioctl: Handle network interface ioctls
29669 - * @dev: network interface on which out-of-band action is to be performed
29670 - * @rq: user request data
29671 - * @cmd: command issued by user
29672 - *
29673 - * Process the various out-of-band ioctls passed to this driver.
29674 - */
29675 -
29676 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
29677 -{
29678 -       int rc = 0;
29679 -
29680 -       switch (cmd) {
29681 -       case SIOCETHTOOL:
29682 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
29683 -               break;
29684 -
29685 -       default:
29686 -               rc = -EOPNOTSUPP;
29687 -               break;
29688 -       }
29689 -
29690 -       return rc;
29691 -}
29692
29693 +static struct ethtool_ops netdev_ethtool_ops = {
29694 +       .get_drvinfo            = netdev_get_drvinfo,
29695 +};
29696  
29697  #ifdef MODULE
29698  #define MAX_EL2_CARDS  4       /* Max number of EL2 cards per module */
29699 diff -Nru a/drivers/net/3c505.c b/drivers/net/3c505.c
29700 --- a/drivers/net/3c505.c       Wed Jun  4 06:07:40 2003
29701 +++ b/drivers/net/3c505.c       Tue Aug 26 13:29:32 2003
29702 @@ -1163,86 +1163,30 @@
29703         return &adapter->stats;
29704  }
29705  
29706 -/**
29707 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
29708 - * @dev: network interface on which out-of-band action is to be performed
29709 - * @useraddr: userspace address to which data is to be read and returned
29710 - *
29711 - * Process the various commands of the SIOCETHTOOL interface.
29712 - */
29713 -
29714 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
29715 -{
29716 -       u32 ethcmd;
29717 -
29718 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
29719 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
29720 -
29721 -       if (get_user(ethcmd, (u32 *)useraddr))
29722 -               return -EFAULT;
29723 -
29724 -       switch (ethcmd) {
29725 -
29726 -       case ETHTOOL_GDRVINFO: {
29727 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
29728 -               strcpy (info.driver, DRV_NAME);
29729 -               strcpy (info.version, DRV_VERSION);
29730 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
29731 -               if (copy_to_user (useraddr, &info, sizeof (info)))
29732 -                       return -EFAULT;
29733 -               return 0;
29734 -       }
29735 -
29736 -       /* get message-level */
29737 -       case ETHTOOL_GMSGLVL: {
29738 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
29739 -               edata.data = debug;
29740 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
29741 -                       return -EFAULT;
29742 -               return 0;
29743 -       }
29744 -       /* set message-level */
29745 -       case ETHTOOL_SMSGLVL: {
29746 -               struct ethtool_value edata;
29747 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
29748 -                       return -EFAULT;
29749 -               debug = edata.data;
29750 -               return 0;
29751 -       }
29752 -
29753 -       default:
29754 -               break;
29755 -       }
29756  
29757 -       return -EOPNOTSUPP;
29758 +static void netdev_get_drvinfo(struct net_device *dev,
29759 +                              struct ethtool_drvinfo *info)
29760 +{
29761 +       strcpy(info->driver, DRV_NAME);
29762 +       strcpy(info->version, DRV_VERSION);
29763 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
29764  }
29765  
29766 -/**
29767 - * netdev_ioctl: Handle network interface ioctls
29768 - * @dev: network interface on which out-of-band action is to be performed
29769 - * @rq: user request data
29770 - * @cmd: command issued by user
29771 - *
29772 - * Process the various out-of-band ioctls passed to this driver.
29773 - */
29774 -
29775 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
29776 -{
29777 -       int rc = 0;
29778 -
29779 -       switch (cmd) {
29780 -       case SIOCETHTOOL:
29781 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
29782 -               break;
29783 -
29784 -       default:
29785 -               rc = -EOPNOTSUPP;
29786 -               break;
29787 -       }
29788 +static u32 netdev_get_msglevel(struct net_device *dev)
29789 +{
29790 +       return debug;
29791 +}
29792  
29793 -       return rc;
29794 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
29795 +{
29796 +       debug = level;
29797  }
29798
29799 +
29800 +static struct ethtool_ops netdev_ethtool_ops = {
29801 +       .get_drvinfo            = netdev_get_drvinfo,
29802 +       .get_msglevel           = netdev_get_msglevel,
29803 +       .set_msglevel           = netdev_set_msglevel,
29804 +};
29805  
29806  /******************************************************
29807   *
29808 @@ -1373,7 +1317,7 @@
29809         dev->tx_timeout = elp_timeout;                  /* local */
29810         dev->watchdog_timeo = 10*HZ;
29811         dev->set_multicast_list = elp_set_mc_list;      /* local */
29812 -       dev->do_ioctl = netdev_ioctl;                   /* local */
29813 +       dev->ethtool_ops = &netdev_ethtool_ops;         /* local */
29814  
29815         /* Setup the generic properties */
29816         ether_setup(dev);
29817 diff -Nru a/drivers/net/3c507.c b/drivers/net/3c507.c
29818 --- a/drivers/net/3c507.c       Sun Apr 20 22:41:08 2003
29819 +++ b/drivers/net/3c507.c       Tue Aug 26 13:29:32 2003
29820 @@ -299,7 +299,7 @@
29821  
29822  static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad);
29823  static void init_82586_mem(struct net_device *dev);
29824 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
29825 +static struct ethtool_ops netdev_ethtool_ops;
29826  
29827  \f
29828  /* Check for a network adaptor of this type, and return '0' iff one exists.
29829 @@ -431,7 +431,7 @@
29830         dev->get_stats  = el16_get_stats;
29831         dev->tx_timeout = el16_tx_timeout;
29832         dev->watchdog_timeo = TX_TIMEOUT;
29833 -       dev->do_ioctl = netdev_ioctl;
29834 +       dev->ethtool_ops = &netdev_ethtool_ops;
29835  
29836         ether_setup(dev);       /* Generic ethernet behaviour */
29837  
29838 @@ -874,86 +874,29 @@
29839         lp->rx_tail = rx_tail;
29840  }
29841  
29842 -/**
29843 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
29844 - * @dev: network interface on which out-of-band action is to be performed
29845 - * @useraddr: userspace address to which data is to be read and returned
29846 - *
29847 - * Process the various commands of the SIOCETHTOOL interface.
29848 - */
29849 -
29850 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
29851 -{
29852 -       u32 ethcmd;
29853 -
29854 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
29855 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
29856 -
29857 -       if (get_user(ethcmd, (u32 *)useraddr))
29858 -               return -EFAULT;
29859 -
29860 -       switch (ethcmd) {
29861 -
29862 -       case ETHTOOL_GDRVINFO: {
29863 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
29864 -               strcpy (info.driver, DRV_NAME);
29865 -               strcpy (info.version, DRV_VERSION);
29866 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
29867 -               if (copy_to_user (useraddr, &info, sizeof (info)))
29868 -                       return -EFAULT;
29869 -               return 0;
29870 -       }
29871 -
29872 -       /* get message-level */
29873 -       case ETHTOOL_GMSGLVL: {
29874 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
29875 -               edata.data = debug;
29876 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
29877 -                       return -EFAULT;
29878 -               return 0;
29879 -       }
29880 -       /* set message-level */
29881 -       case ETHTOOL_SMSGLVL: {
29882 -               struct ethtool_value edata;
29883 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
29884 -                       return -EFAULT;
29885 -               debug = edata.data;
29886 -               return 0;
29887 -       }
29888 -
29889 -       default:
29890 -               break;
29891 -       }
29892 -
29893 -       return -EOPNOTSUPP;
29894 +static void netdev_get_drvinfo(struct net_device *dev,
29895 +                              struct ethtool_drvinfo *info)
29896 +{
29897 +       strcpy(info->driver, DRV_NAME);
29898 +       strcpy(info->version, DRV_VERSION);
29899 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
29900  }
29901  
29902 -/**
29903 - * netdev_ioctl: Handle network interface ioctls
29904 - * @dev: network interface on which out-of-band action is to be performed
29905 - * @rq: user request data
29906 - * @cmd: command issued by user
29907 - *
29908 - * Process the various out-of-band ioctls passed to this driver.
29909 - */
29910 -
29911 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
29912 +static u32 netdev_get_msglevel(struct net_device *dev)
29913  {
29914 -       int rc = 0;
29915 -
29916 -       switch (cmd) {
29917 -       case SIOCETHTOOL:
29918 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
29919 -               break;
29920 -
29921 -       default:
29922 -               rc = -EOPNOTSUPP;
29923 -               break;
29924 -       }
29925 +       return debug;
29926 +}
29927  
29928 -       return rc;
29929 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
29930 +{
29931 +       debug = level;
29932  }
29933
29934 +
29935 +static struct ethtool_ops netdev_ethtool_ops = {
29936 +       .get_drvinfo            = netdev_get_drvinfo,
29937 +       .get_msglevel           = netdev_get_msglevel,
29938 +       .set_msglevel           = netdev_set_msglevel,
29939 +};
29940  
29941  #ifdef MODULE
29942  static struct net_device dev_3c507;
29943 diff -Nru a/drivers/net/3c509.c b/drivers/net/3c509.c
29944 --- a/drivers/net/3c509.c       Tue Aug 19 20:53:14 2003
29945 +++ b/drivers/net/3c509.c       Sun Aug 31 22:52:48 2003
29946 @@ -300,10 +300,11 @@
29947   *
29948   * Both call el3_common_init/el3_common_remove. */
29949  
29950 -static void __init el3_common_init(struct net_device *dev)
29951 +static int __init el3_common_init(struct net_device *dev)
29952  {
29953         struct el3_private *lp = dev->priv;
29954         short i;
29955 +       int err;
29956  
29957         spin_lock_init(&lp->lock);
29958  
29959 @@ -314,10 +315,29 @@
29960                 dev->if_port |= (dev->mem_start & 0x08);
29961         }
29962  
29963 +       /* The EL3-specific entries in the device structure. */
29964 +       dev->open = &el3_open;
29965 +       dev->hard_start_xmit = &el3_start_xmit;
29966 +       dev->stop = &el3_close;
29967 +       dev->get_stats = &el3_get_stats;
29968 +       dev->set_multicast_list = &set_multicast_list;
29969 +       dev->tx_timeout = el3_tx_timeout;
29970 +       dev->watchdog_timeo = TX_TIMEOUT;
29971 +       dev->do_ioctl = netdev_ioctl;
29972 +
29973 +       err = register_netdev(dev);
29974 +       if (err) {
29975 +               printk(KERN_ERR "Failed to register 3c5x9 at %#3.3lx, IRQ %d.\n",
29976 +                       dev->base_addr, dev->irq);
29977 +               release_region(dev->base_addr, EL3_IO_EXTENT);
29978 +               return err;
29979 +       }
29980 +
29981         {
29982                 const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
29983 -               printk("%s: 3c5x9 at %#3.3lx, %s port, address ",
29984 -                       dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)]);
29985 +               printk("%s: 3c5x9 found at %#3.3lx, %s port, address ",
29986 +                       dev->name, dev->base_addr, 
29987 +                       if_names[(dev->if_port & 0x03)]);
29988         }
29989  
29990         /* Read in the station address. */
29991 @@ -327,16 +347,8 @@
29992  
29993         if (el3_debug > 0)
29994                 printk(KERN_INFO "%s" KERN_INFO "%s", versionA, versionB);
29995 +       return 0;
29996  
29997 -       /* The EL3-specific entries in the device structure. */
29998 -       dev->open = &el3_open;
29999 -       dev->hard_start_xmit = &el3_start_xmit;
30000 -       dev->stop = &el3_close;
30001 -       dev->get_stats = &el3_get_stats;
30002 -       dev->set_multicast_list = &set_multicast_list;
30003 -       dev->tx_timeout = el3_tx_timeout;
30004 -       dev->watchdog_timeo = TX_TIMEOUT;
30005 -       dev->do_ioctl = netdev_ioctl;
30006  }
30007  
30008  static void el3_common_remove (struct net_device *dev)
30009 @@ -564,9 +576,8 @@
30010  #if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
30011         lp->dev = &idev->dev;
30012  #endif
30013 -       el3_common_init(dev);
30014 +       err = el3_common_init(dev);
30015  
30016 -       err = register_netdev(dev);
30017         if (err)
30018                 goto out1;
30019  
30020 @@ -588,7 +599,6 @@
30021         return 0;
30022  
30023  out1:
30024 -       release_region(ioaddr, EL3_IO_EXTENT);
30025  #if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
30026         if (idev)
30027                 pnp_device_detach(idev);
30028 @@ -629,8 +639,8 @@
30029                            el3_mca_adapter_names[mdev->index], slot + 1);
30030  
30031                 /* claim the slot */
30032 -               strncpy(device->name, el3_mca_adapter_names[mdev->index],
30033 -                               sizeof(device->name));
30034 +               strncpy(mdev->name, el3_mca_adapter_names[mdev->index],
30035 +                               sizeof(mdev->name));
30036                 mca_device_set_claim(mdev, 1);
30037  
30038                 if_port = pos4 & 0x03;
30039 @@ -662,11 +672,9 @@
30040                 lp->dev = device;
30041                 lp->type = EL3_MCA;
30042                 device->driver_data = dev;
30043 -               el3_common_init(dev);
30044 +               err = el3_common_init(dev);
30045  
30046 -               err = register_netdev(dev);
30047                 if (err) {
30048 -                       release_region(ioaddr, EL3_IO_EXTENT);
30049                         return -ENOMEM;
30050                 }
30051  
30052 @@ -723,11 +731,9 @@
30053         lp->dev = device;
30054         lp->type = EL3_EISA;
30055         eisa_set_drvdata (edev, dev);
30056 -       el3_common_init(dev);
30057 +       err = el3_common_init(dev);
30058  
30059 -       err = register_netdev(dev);
30060         if (err) {
30061 -               release_region(ioaddr, EL3_IO_EXTENT);
30062                 return err;
30063         }
30064  
30065 diff -Nru a/drivers/net/3c515.c b/drivers/net/3c515.c
30066 --- a/drivers/net/3c515.c       Tue Aug 19 20:53:14 2003
30067 +++ b/drivers/net/3c515.c       Tue Sep  2 06:44:18 2003
30068 @@ -392,7 +392,7 @@
30069  static void update_stats(int addr, struct net_device *dev);
30070  static struct net_device_stats *corkscrew_get_stats(struct net_device *dev);
30071  static void set_rx_mode(struct net_device *dev);
30072 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
30073 +static struct ethtool_ops netdev_ethtool_ops;
30074  \f
30075  
30076  /* 
30077 @@ -718,7 +718,7 @@
30078         dev->stop = &corkscrew_close;
30079         dev->get_stats = &corkscrew_get_stats;
30080         dev->set_multicast_list = &set_rx_mode;
30081 -       dev->do_ioctl = netdev_ioctl;
30082 +       dev->ethtool_ops = &netdev_ethtool_ops;
30083  
30084         return 0;
30085  }
30086 @@ -1580,86 +1580,30 @@
30087         outw(new_mode, ioaddr + EL3_CMD);
30088  }
30089  
30090 -/**
30091 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
30092 - * @dev: network interface on which out-of-band action is to be performed
30093 - * @useraddr: userspace address to which data is to be read and returned
30094 - *
30095 - * Process the various commands of the SIOCETHTOOL interface.
30096 - */
30097 -
30098 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
30099 +static void netdev_get_drvinfo(struct net_device *dev,
30100 +                              struct ethtool_drvinfo *info)
30101  {
30102 -       u32 ethcmd;
30103 -
30104 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
30105 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
30106 -
30107 -       if (get_user(ethcmd, (u32 *)useraddr))
30108 -               return -EFAULT;
30109 -
30110 -       switch (ethcmd) {
30111 -
30112 -       case ETHTOOL_GDRVINFO: {
30113 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
30114 -               strcpy (info.driver, DRV_NAME);
30115 -               strcpy (info.version, DRV_VERSION);
30116 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
30117 -               if (copy_to_user (useraddr, &info, sizeof (info)))
30118 -                       return -EFAULT;
30119 -               return 0;
30120 -       }
30121 -
30122 -       /* get message-level */
30123 -       case ETHTOOL_GMSGLVL: {
30124 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
30125 -               edata.data = corkscrew_debug;
30126 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
30127 -                       return -EFAULT;
30128 -               return 0;
30129 -       }
30130 -       /* set message-level */
30131 -       case ETHTOOL_SMSGLVL: {
30132 -               struct ethtool_value edata;
30133 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
30134 -                       return -EFAULT;
30135 -               corkscrew_debug = edata.data;
30136 -               return 0;
30137 -       }
30138 -
30139 -       default:
30140 -               break;
30141 -       }
30142 -
30143 -       return -EOPNOTSUPP;
30144 +       strcpy(info->driver, DRV_NAME);
30145 +       strcpy(info->version, DRV_VERSION);
30146 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
30147  }
30148  
30149 -/**
30150 - * netdev_ioctl: Handle network interface ioctls
30151 - * @dev: network interface on which out-of-band action is to be performed
30152 - * @rq: user request data
30153 - * @cmd: command issued by user
30154 - *
30155 - * Process the various out-of-band ioctls passed to this driver.
30156 - */
30157 -
30158 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
30159 +static u32 netdev_get_msglevel(struct net_device *dev)
30160  {
30161 -       int rc = 0;
30162 +       return corkscrew_debug;
30163 +}
30164  
30165 -       switch (cmd) {
30166 -       case SIOCETHTOOL:
30167 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
30168 -               break;
30169 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
30170 +{
30171 +       corkscrew_debug = level;
30172 +}
30173  
30174 -       default:
30175 -               rc = -EOPNOTSUPP;
30176 -               break;
30177 -       }
30178 +static struct ethtool_ops netdev_ethtool_ops = {
30179 +       .get_drvinfo            = netdev_get_drvinfo,
30180 +       .get_msglevel           = netdev_get_msglevel,
30181 +       .set_msglevel           = netdev_set_msglevel,
30182 +};
30183  
30184 -       return rc;
30185 -}
30186
30187  \f
30188  #ifdef MODULE
30189  void cleanup_module(void)
30190 diff -Nru a/drivers/net/3c523.c b/drivers/net/3c523.c
30191 --- a/drivers/net/3c523.c       Sun Apr 27 20:36:18 2003
30192 +++ b/drivers/net/3c523.c       Tue Aug 26 13:42:22 2003
30193 @@ -188,7 +188,7 @@
30194  #ifdef ELMC_MULTICAST
30195  static void set_multicast_list(struct net_device *dev);
30196  #endif
30197 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
30198 +static struct ethtool_ops netdev_ethtool_ops;
30199  
30200  /* helper-functions */
30201  static int init586(struct net_device *dev);
30202 @@ -571,7 +571,7 @@
30203  #else
30204         dev->set_multicast_list = NULL;
30205  #endif
30206 -       dev->do_ioctl = netdev_ioctl;
30207 +       dev->ethtool_ops = &netdev_ethtool_ops;
30208         
30209         ether_setup(dev);
30210  
30211 @@ -1228,70 +1228,17 @@
30212  }
30213  #endif
30214  
30215 -/**
30216 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
30217 - * @dev: network interface on which out-of-band action is to be performed
30218 - * @useraddr: userspace address to which data is to be read and returned
30219 - *
30220 - * Process the various commands of the SIOCETHTOOL interface.
30221 - */
30222 -
30223 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
30224 +static void netdev_get_drvinfo(struct net_device *dev,
30225 +                              struct ethtool_drvinfo *info)
30226  {
30227 -       u32 ethcmd;
30228 -
30229 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
30230 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
30231 -
30232 -       if (get_user(ethcmd, (u32 *)useraddr))
30233 -               return -EFAULT;
30234 -
30235 -       switch (ethcmd) {
30236 -
30237 -       case ETHTOOL_GDRVINFO: {
30238 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
30239 -               strcpy (info.driver, DRV_NAME);
30240 -               strcpy (info.version, DRV_VERSION);
30241 -               sprintf(info.bus_info, "MCA 0x%lx", dev->base_addr);
30242 -               if (copy_to_user (useraddr, &info, sizeof (info)))
30243 -                       return -EFAULT;
30244 -               return 0;
30245 -       }
30246 -
30247 -       default:
30248 -               break;
30249 -       }
30250 -
30251 -       return -EOPNOTSUPP;
30252 +       strcpy(info->driver, DRV_NAME);
30253 +       strcpy(info->version, DRV_VERSION);
30254 +       sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr);
30255  }
30256  
30257 -/**
30258 - * netdev_ioctl: Handle network interface ioctls
30259 - * @dev: network interface on which out-of-band action is to be performed
30260 - * @rq: user request data
30261 - * @cmd: command issued by user
30262 - *
30263 - * Process the various out-of-band ioctls passed to this driver.
30264 - */
30265 -
30266 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
30267 -{
30268 -       int rc = 0;
30269 -
30270 -       switch (cmd) {
30271 -       case SIOCETHTOOL:
30272 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
30273 -               break;
30274 -
30275 -       default:
30276 -               rc = -EOPNOTSUPP;
30277 -               break;
30278 -       }
30279 -
30280 -       return rc;
30281 -}
30282
30283 -/*************************************************************************/
30284 +static struct ethtool_ops netdev_ethtool_ops = {
30285 +       .get_drvinfo            = netdev_get_drvinfo,
30286 +};
30287  
30288  #ifdef MODULE
30289  
30290 diff -Nru a/drivers/net/3c527.c b/drivers/net/3c527.c
30291 --- a/drivers/net/3c527.c       Sun Apr 27 20:36:18 2003
30292 +++ b/drivers/net/3c527.c       Sun Aug 31 06:34:16 2003
30293 @@ -218,7 +218,7 @@
30294  static struct  net_device_stats *mc32_get_stats(struct net_device *dev);
30295  static void    mc32_set_multicast_list(struct net_device *dev);
30296  static void    mc32_reset_multicast_list(struct net_device *dev);
30297 -static int     netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
30298 +static struct ethtool_ops netdev_ethtool_ops;
30299  
30300  /**
30301   * mc32_probe  -       Search for supported boards
30302 @@ -508,7 +508,7 @@
30303         dev->set_multicast_list = mc32_set_multicast_list;
30304         dev->tx_timeout         = mc32_timeout;
30305         dev->watchdog_timeo     = HZ*5; /* Board does all the work */
30306 -       dev->do_ioctl           = netdev_ioctl;
30307 +       dev->ethtool_ops        = &netdev_ethtool_ops;
30308         
30309         lp->xceiver_state = HALTED; 
30310         
30311 @@ -1081,14 +1081,15 @@
30312         /* NP is the buffer we will be loading */
30313         np=lp->tx_ring[lp->tx_ring_head].p; 
30314  
30315 -       /* We will need this to flush the buffer out */
30316 -       lp->tx_ring[lp->tx_ring_head].skb=skb;
30317 -          
30318         if (skb->len < ETH_ZLEN) {
30319                 skb = skb_padto(skb, ETH_ZLEN);
30320                 if (skb == NULL)
30321                         goto out;
30322         }
30323 +
30324 +       /* We will need this to flush the buffer out */
30325 +       lp->tx_ring[lp->tx_ring_head].skb = skb;
30326 +          
30327         np->length = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len; 
30328                         
30329         np->data        = isa_virt_to_bus(skb->data);
30330 @@ -1655,86 +1656,30 @@
30331         do_mc32_set_multicast_list(dev,1);
30332  }
30333  
30334 -/**
30335 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
30336 - * @dev: network interface on which out-of-band action is to be performed
30337 - * @useraddr: userspace address to which data is to be read and returned
30338 - *
30339 - * Process the various commands of the SIOCETHTOOL interface.
30340 - */
30341 -
30342 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
30343 +static void netdev_get_drvinfo(struct net_device *dev,
30344 +                              struct ethtool_drvinfo *info)
30345  {
30346 -       u32 ethcmd;
30347 -
30348 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
30349 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
30350 -
30351 -       if (get_user(ethcmd, (u32 *)useraddr))
30352 -               return -EFAULT;
30353 -
30354 -       switch (ethcmd) {
30355 -
30356 -       case ETHTOOL_GDRVINFO: {
30357 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
30358 -               strcpy (info.driver, DRV_NAME);
30359 -               strcpy (info.version, DRV_VERSION);
30360 -               sprintf(info.bus_info, "MCA 0x%lx", dev->base_addr);
30361 -               if (copy_to_user (useraddr, &info, sizeof (info)))
30362 -                       return -EFAULT;
30363 -               return 0;
30364 -       }
30365 -
30366 -       /* get message-level */
30367 -       case ETHTOOL_GMSGLVL: {
30368 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
30369 -               edata.data = mc32_debug;
30370 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
30371 -                       return -EFAULT;
30372 -               return 0;
30373 -       }
30374 -       /* set message-level */
30375 -       case ETHTOOL_SMSGLVL: {
30376 -               struct ethtool_value edata;
30377 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
30378 -                       return -EFAULT;
30379 -               mc32_debug = edata.data;
30380 -               return 0;
30381 -       }
30382 -
30383 -       default:
30384 -               break;
30385 -       }
30386 -
30387 -       return -EOPNOTSUPP;
30388 +       strcpy(info->driver, DRV_NAME);
30389 +       strcpy(info->version, DRV_VERSION);
30390 +       sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr);
30391  }
30392  
30393 -/**
30394 - * netdev_ioctl: Handle network interface ioctls
30395 - * @dev: network interface on which out-of-band action is to be performed
30396 - * @rq: user request data
30397 - * @cmd: command issued by user
30398 - *
30399 - * Process the various out-of-band ioctls passed to this driver.
30400 - */
30401 +static u32 netdev_get_msglevel(struct net_device *dev)
30402 +{
30403 +       return mc32_debug;
30404 +}
30405  
30406 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
30407 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
30408  {
30409 -       int rc = 0;
30410 +       mc32_debug = level;
30411 +}
30412  
30413 -       switch (cmd) {
30414 -       case SIOCETHTOOL:
30415 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
30416 -               break;
30417 +static struct ethtool_ops netdev_ethtool_ops = {
30418 +       .get_drvinfo            = netdev_get_drvinfo,
30419 +       .get_msglevel           = netdev_get_msglevel,
30420 +       .set_msglevel           = netdev_set_msglevel,
30421 +};
30422  
30423 -       default:
30424 -               rc = -EOPNOTSUPP;
30425 -               break;
30426 -       }
30427 -
30428 -       return rc;
30429 -}
30430
30431  #ifdef MODULE
30432  
30433  static struct net_device this_device;
30434 diff -Nru a/drivers/net/3c59x.c b/drivers/net/3c59x.c
30435 --- a/drivers/net/3c59x.c       Tue Aug 19 20:53:15 2003
30436 +++ b/drivers/net/3c59x.c       Tue Aug 26 11:23:22 2003
30437 @@ -900,6 +900,7 @@
30438  static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
30439  static void vortex_tx_timeout(struct net_device *dev);
30440  static void acpi_set_WOL(struct net_device *dev);
30441 +static struct ethtool_ops vortex_ethtool_ops;
30442  \f
30443  /* This driver uses 'options' to pass the media type, full-duplex flag, etc. */
30444  /* Option count limit only -- unlimited interfaces are supported. */
30445 @@ -1445,6 +1446,7 @@
30446         dev->stop = vortex_close;
30447         dev->get_stats = vortex_get_stats;
30448         dev->do_ioctl = vortex_ioctl;
30449 +       dev->ethtool_ops = &vortex_ethtool_ops;
30450         dev->set_multicast_list = set_rx_mode;
30451         dev->tx_timeout = vortex_tx_timeout;
30452         dev->watchdog_timeo = (watchdog * HZ) / 1000;
30453 @@ -2816,38 +2818,28 @@
30454  }
30455  
30456  
30457 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
30458 +static void vortex_get_drvinfo(struct net_device *dev,
30459 +                                       struct ethtool_drvinfo *info)
30460  {
30461         struct vortex_private *vp = dev->priv;
30462 -       u32 ethcmd;
30463 -               
30464 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
30465 -               return -EFAULT;
30466  
30467 -        switch (ethcmd) {
30468 -        case ETHTOOL_GDRVINFO: {
30469 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
30470 -               strcpy(info.driver, DRV_NAME);
30471 -               strcpy(info.version, DRV_VERSION);
30472 -               if (VORTEX_PCI(vp))
30473 -                       strcpy(info.bus_info, pci_name(VORTEX_PCI(vp)));
30474 -               else {
30475 -                       if (VORTEX_EISA(vp))
30476 -                               sprintf (info.bus_info, vp->gendev->bus_id);
30477 -                       else
30478 -                               sprintf(info.bus_info, "EISA 0x%lx %d",
30479 -                                               dev->base_addr, dev->irq);
30480 -               }
30481 -               if (copy_to_user(useraddr, &info, sizeof(info)))
30482 -                       return -EFAULT;
30483 -               return 0;
30484 +       strcpy(info->driver, DRV_NAME);
30485 +       strcpy(info->version, DRV_VERSION);
30486 +       if (VORTEX_PCI(vp)) {
30487 +               strcpy(info->bus_info, pci_name(VORTEX_PCI(vp)));
30488 +       } else {
30489 +               if (VORTEX_EISA(vp))
30490 +                       sprintf(info->bus_info, vp->gendev->bus_id);
30491 +               else
30492 +                       sprintf(info->bus_info, "EISA 0x%lx %d",
30493 +                                       dev->base_addr, dev->irq);
30494         }
30495 -
30496 -        }
30497 -       
30498 -       return -EOPNOTSUPP;
30499  }
30500  
30501 +static struct ethtool_ops vortex_ethtool_ops = {
30502 +       .get_drvinfo =          vortex_get_drvinfo,
30503 +};
30504 +
30505  static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
30506  {
30507         struct vortex_private *vp = (struct vortex_private *)dev->priv;
30508 @@ -2857,9 +2849,6 @@
30509         int retval;
30510  
30511         switch(cmd) {
30512 -       case SIOCETHTOOL:
30513 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
30514 -
30515         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
30516                 data->phy_id = phy;
30517  
30518 diff -Nru a/drivers/net/8139cp.c b/drivers/net/8139cp.c
30519 --- a/drivers/net/8139cp.c      Tue Aug 19 20:13:55 2003
30520 +++ b/drivers/net/8139cp.c      Mon Sep  1 17:25:54 2003
30521 @@ -24,15 +24,13 @@
30522                 PCI suspend/resume  - Felipe Damasio <felipewd@terra.com.br>
30523                 LinkChg interrupt   - Felipe Damasio <felipewd@terra.com.br>
30524                         
30525 -       TODO, in rough priority order:
30526 +       TODO:
30527         * Test Tx checksumming thoroughly
30528 -       * dev->tx_timeout
30529 -       * Constants (module parms?) for Rx work limit
30530 +       * Implement dev->tx_timeout
30531 +
30532 +       Low priority TODO:
30533         * Complete reset on PciErr
30534         * Consider Rx interrupt mitigation using TimerIntr
30535 -       * Implement 8139C+ statistics dump; maybe not...
30536 -         h/w stats can be reset only by software reset
30537 -       * Handle netif_rx return value
30538         * Investigate using skb->priority with h/w VLAN priority
30539         * Investigate using High Priority Tx Queue with skb->priority
30540         * Adjust Rx FIFO threshold and Max Rx DMA burst on Rx FIFO error
30541 @@ -41,14 +39,17 @@
30542           Tx descriptor bit
30543         * The real minimum of CP_MIN_MTU is 4 bytes.  However,
30544           for this to be supported, one must(?) turn on packet padding.
30545 -       * Support 8169 GMII
30546 -       * Support external MII transceivers
30547 +       * Support external MII transceivers (patch available)
30548 +
30549 +       NOTES:
30550 +       * TX checksumming is considered experimental.  It is off by
30551 +         default, use ethtool to turn it on.
30552  
30553   */
30554  
30555  #define DRV_NAME               "8139cp"
30556 -#define DRV_VERSION            "0.3.0"
30557 -#define DRV_RELDATE            "Sep 29, 2002"
30558 +#define DRV_VERSION            "1.1"
30559 +#define DRV_RELDATE            "Aug 30, 2003"
30560  
30561  
30562  #include <linux/config.h>
30563 @@ -71,9 +72,6 @@
30564  #include <asm/io.h>
30565  #include <asm/uaccess.h>
30566  
30567 -/* experimental TX checksumming feature enable/disable */
30568 -#undef CP_TX_CHECKSUM
30569 -
30570  /* VLAN tagging feature enable/disable */
30571  #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
30572  #define CP_VLAN_TAG_USED 1
30573 @@ -86,7 +84,7 @@
30574  #endif
30575  
30576  /* These identify the driver base version and may not be removed. */
30577 -static char version[] __devinitdata =
30578 +static char version[] =
30579  KERN_INFO DRV_NAME ": 10/100 PCI Ethernet driver v" DRV_VERSION " (" DRV_RELDATE ")\n";
30580  
30581  MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>");
30582 @@ -160,6 +158,7 @@
30583         TxConfig        = 0x40, /* Tx configuration */
30584         ChipVersion     = 0x43, /* 8-bit chip version, inside TxConfig */
30585         RxConfig        = 0x44, /* Rx configuration */
30586 +       RxMissed        = 0x4C, /* 24 bits valid, write clears */
30587         Cfg9346         = 0x50, /* EEPROM select/control; Cfg reg [un]lock */
30588         Config1         = 0x52, /* Config1 */
30589         Config3         = 0x59, /* Config3 */
30590 @@ -292,12 +291,11 @@
30591         UWF             = (1 << 4),  /* Accept Unicast wakeup frame */
30592         LANWake         = (1 << 1),  /* Enable LANWake signal */
30593         PMEStatus       = (1 << 0),  /* PME status can be reset by PCI RST# */
30594 -};
30595  
30596 -static const unsigned int cp_intr_mask =
30597 -       PciErr | LinkChg |
30598 -       RxOK | RxErr | RxEmpty | RxFIFOOvr |
30599 -       TxOK | TxErr | TxEmpty;
30600 +       cp_norx_intr_mask = PciErr | LinkChg | TxOK | TxErr | TxEmpty,
30601 +       cp_rx_intr_mask = RxOK | RxErr | RxEmpty | RxFIFOOvr,
30602 +       cp_intr_mask = cp_rx_intr_mask | cp_norx_intr_mask,
30603 +};
30604  
30605  static const unsigned int cp_rx_config =
30606           (RX_FIFO_THRESH << RxCfgFIFOShift) |
30607 @@ -364,11 +362,7 @@
30608  
30609         struct pci_dev          *pdev;
30610         u32                     rx_config;
30611 -
30612 -       struct sk_buff          *frag_skb;
30613 -       unsigned                dropping_frag : 1;
30614 -       unsigned                pci_using_dac : 1;
30615 -       unsigned int            board_type;
30616 +       u16                     cpcmd;
30617  
30618         unsigned int            wol_enabled : 1; /* Is Wake-on-LAN enabled? */
30619         u32                     power_state[16];
30620 @@ -400,28 +394,9 @@
30621  static void cp_tx (struct cp_private *cp);
30622  static void cp_clean_rings (struct cp_private *cp);
30623  
30624 -enum board_type {
30625 -       RTL8139Cp,
30626 -       RTL8169,
30627 -};
30628 -
30629 -static struct cp_board_info {
30630 -       const char *name;
30631 -} cp_board_tbl[] __devinitdata = {
30632 -       /* RTL8139Cp */
30633 -       { "RTL-8139C+" },
30634 -
30635 -       /* RTL8169 */
30636 -       { "RTL-8169" },
30637 -};
30638 -
30639  static struct pci_device_id cp_pci_tbl[] = {
30640         { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
30641 -         PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139Cp },
30642 -#if 0
30643 -       { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8169,
30644 -         PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8169 },
30645 -#endif
30646 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
30647         { },
30648  };
30649  MODULE_DEVICE_TABLE(pci, cp_pci_tbl);
30650 @@ -446,6 +421,31 @@
30651  };
30652  
30653  
30654 +#if CP_VLAN_TAG_USED
30655 +static void cp_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
30656 +{
30657 +       struct cp_private *cp = dev->priv;
30658 +
30659 +       spin_lock_irq(&cp->lock);
30660 +       cp->vlgrp = grp;
30661 +       cp->cpcmd |= RxVlanOn;
30662 +       cpw16(CpCmd, cp->cpcmd);
30663 +       spin_unlock_irq(&cp->lock);
30664 +}
30665 +
30666 +static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
30667 +{
30668 +       struct cp_private *cp = dev->priv;
30669 +
30670 +       spin_lock_irq(&cp->lock);
30671 +       cp->cpcmd &= ~RxVlanOn;
30672 +       cpw16(CpCmd, cp->cpcmd);
30673 +       if (cp->vlgrp)
30674 +               cp->vlgrp->vlan_devices[vid] = NULL;
30675 +       spin_unlock_irq(&cp->lock);
30676 +}
30677 +#endif /* CP_VLAN_TAG_USED */
30678 +
30679  static inline void cp_set_rxbufsize (struct cp_private *cp)
30680  {
30681         unsigned int mtu = cp->dev->mtu;
30682 @@ -468,10 +468,11 @@
30683  
30684  #if CP_VLAN_TAG_USED
30685         if (cp->vlgrp && (desc->opts2 & RxVlanTagged)) {
30686 -               vlan_hwaccel_rx(skb, cp->vlgrp, be16_to_cpu(desc->opts2 & 0xffff));
30687 +               vlan_hwaccel_receive_skb(skb, cp->vlgrp,
30688 +                                        be16_to_cpu(desc->opts2 & 0xffff));
30689         } else
30690  #endif
30691 -               netif_rx(skb);
30692 +               netif_receive_skb(skb);
30693  }
30694  
30695  static void cp_rx_err_acct (struct cp_private *cp, unsigned rx_tail,
30696 @@ -486,81 +487,14 @@
30697                 cp->net_stats.rx_frame_errors++;
30698         if (status & RxErrCRC)
30699                 cp->net_stats.rx_crc_errors++;
30700 -       if (status & RxErrRunt)
30701 +       if ((status & RxErrRunt) || (status & RxErrLong))
30702                 cp->net_stats.rx_length_errors++;
30703 -       if (status & RxErrLong)
30704 +       if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag))
30705                 cp->net_stats.rx_length_errors++;
30706         if (status & RxErrFIFO)
30707                 cp->net_stats.rx_fifo_errors++;
30708  }
30709  
30710 -static void cp_rx_frag (struct cp_private *cp, unsigned rx_tail,
30711 -                       struct sk_buff *skb, u32 status, u32 len)
30712 -{
30713 -       struct sk_buff *copy_skb, *frag_skb = cp->frag_skb;
30714 -       unsigned orig_len = frag_skb ? frag_skb->len : 0;
30715 -       unsigned target_len = orig_len + len;
30716 -       unsigned first_frag = status & FirstFrag;
30717 -       unsigned last_frag = status & LastFrag;
30718 -
30719 -       if (netif_msg_rx_status (cp))
30720 -               printk (KERN_DEBUG "%s: rx %s%sfrag, slot %d status 0x%x len %d\n",
30721 -                       cp->dev->name,
30722 -                       cp->dropping_frag ? "dropping " : "",
30723 -                       first_frag ? "first " :
30724 -                       last_frag ? "last " : "",
30725 -                       rx_tail, status, len);
30726 -
30727 -       cp->cp_stats.rx_frags++;
30728 -
30729 -       if (!frag_skb && !first_frag)
30730 -               cp->dropping_frag = 1;
30731 -       if (cp->dropping_frag)
30732 -               goto drop_frag;
30733 -
30734 -       copy_skb = dev_alloc_skb (target_len + RX_OFFSET);
30735 -       if (!copy_skb) {
30736 -               printk(KERN_WARNING "%s: rx slot %d alloc failed\n",
30737 -                      cp->dev->name, rx_tail);
30738 -
30739 -               cp->dropping_frag = 1;
30740 -drop_frag:
30741 -               if (frag_skb) {
30742 -                       dev_kfree_skb_irq(frag_skb);
30743 -                       cp->frag_skb = NULL;
30744 -               }
30745 -               if (last_frag) {
30746 -                       cp->net_stats.rx_dropped++;
30747 -                       cp->dropping_frag = 0;
30748 -               }
30749 -               return;
30750 -       }
30751 -
30752 -       copy_skb->dev = cp->dev;
30753 -       skb_reserve(copy_skb, RX_OFFSET);
30754 -       skb_put(copy_skb, target_len);
30755 -       if (frag_skb) {
30756 -               memcpy(copy_skb->data, frag_skb->data, orig_len);
30757 -               dev_kfree_skb_irq(frag_skb);
30758 -       }
30759 -       pci_dma_sync_single(cp->pdev, cp->rx_skb[rx_tail].mapping,
30760 -                           len, PCI_DMA_FROMDEVICE);
30761 -       memcpy(copy_skb->data + orig_len, skb->data, len);
30762 -
30763 -       copy_skb->ip_summed = CHECKSUM_NONE;
30764 -
30765 -       if (last_frag) {
30766 -               if (status & (RxError | RxErrFIFO)) {
30767 -                       cp_rx_err_acct(cp, rx_tail, status, len);
30768 -                       dev_kfree_skb_irq(copy_skb);
30769 -               } else
30770 -                       cp_rx_skb(cp, copy_skb, &cp->rx_ring[rx_tail]);
30771 -               cp->frag_skb = NULL;
30772 -       } else {
30773 -               cp->frag_skb = copy_skb;
30774 -       }
30775 -}
30776 -
30777  static inline unsigned int cp_rx_csum_ok (u32 status)
30778  {
30779         unsigned int protocol = (status >> 16) & 0x3;
30780 @@ -574,12 +508,18 @@
30781         return 0;
30782  }
30783  
30784 -static void cp_rx (struct cp_private *cp)
30785 +static int cp_rx_poll (struct net_device *dev, int *budget)
30786  {
30787 +       struct cp_private *cp = dev->priv;
30788         unsigned rx_tail = cp->rx_tail;
30789 -       unsigned rx_work = 100;
30790 +       unsigned rx_work = dev->quota;
30791 +       unsigned rx;
30792 +
30793 +rx_status_loop:
30794 +       rx = 0;
30795 +       cpw16(IntrStatus, cp_rx_intr_mask);
30796  
30797 -       while (rx_work--) {
30798 +       while (1) {
30799                 u32 status, len;
30800                 dma_addr_t mapping;
30801                 struct sk_buff *skb, *new_skb;
30802 @@ -599,7 +539,14 @@
30803                 mapping = cp->rx_skb[rx_tail].mapping;
30804  
30805                 if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag)) {
30806 -                       cp_rx_frag(cp, rx_tail, skb, status, len);
30807 +                       /* we don't support incoming fragmented frames.
30808 +                        * instead, we attempt to ensure that the
30809 +                        * pre-allocated RX skbs are properly sized such
30810 +                        * that RX fragments are never encountered
30811 +                        */
30812 +                       cp_rx_err_acct(cp, rx_tail, status, len);
30813 +                       cp->net_stats.rx_dropped++;
30814 +                       cp->cp_stats.rx_frags++;
30815                         goto rx_next;
30816                 }
30817  
30818 @@ -640,6 +587,7 @@
30819                 cp->rx_skb[rx_tail].skb = new_skb;
30820  
30821                 cp_rx_skb(cp, skb, desc);
30822 +               rx++;
30823  
30824  rx_next:
30825                 cp->rx_ring[rx_tail].opts2 = 0;
30826 @@ -650,12 +598,30 @@
30827                 else
30828                         desc->opts1 = cpu_to_le32(DescOwn | cp->rx_buf_sz);
30829                 rx_tail = NEXT_RX(rx_tail);
30830 -       }
30831  
30832 -       if (!rx_work)
30833 -               printk(KERN_WARNING "%s: rx work limit reached\n", cp->dev->name);
30834 +               if (!rx_work--)
30835 +                       break;
30836 +       }
30837  
30838         cp->rx_tail = rx_tail;
30839 +
30840 +       dev->quota -= rx;
30841 +       *budget -= rx;
30842 +
30843 +       /* if we did not reach work limit, then we're done with
30844 +        * this round of polling
30845 +        */
30846 +       if (rx_work) {
30847 +               if (cpr16(IntrStatus) & cp_rx_intr_mask)
30848 +                       goto rx_status_loop;
30849 +
30850 +               cpw16_f(IntrMask, cp_intr_mask);
30851 +               netif_rx_complete(dev);
30852 +
30853 +               return 0;       /* done */
30854 +       }
30855 +
30856 +       return 1;               /* not done */
30857  }
30858  
30859  static irqreturn_t
30860 @@ -673,12 +639,16 @@
30861                 printk(KERN_DEBUG "%s: intr, status %04x cmd %02x cpcmd %04x\n",
30862                         dev->name, status, cpr8(Cmd), cpr16(CpCmd));
30863  
30864 -       cpw16_f(IntrStatus, status);
30865 +       cpw16(IntrStatus, status & ~cp_rx_intr_mask);
30866  
30867         spin_lock(&cp->lock);
30868  
30869 -       if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr))
30870 -               cp_rx(cp);
30871 +       if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr)) {
30872 +               if (netif_rx_schedule_prep(dev)) {
30873 +                       cpw16_f(IntrMask, cp_norx_intr_mask);
30874 +                       __netif_rx_schedule(dev);
30875 +               }
30876 +       }
30877         if (status & (TxOK | TxErr | TxEmpty | SWInt))
30878                 cp_tx(cp);
30879         if (status & LinkChg)
30880 @@ -691,6 +661,8 @@
30881                 pci_write_config_word(cp->pdev, PCI_STATUS, pci_status);
30882                 printk(KERN_ERR "%s: PCI bus error, status=%04x, PCI status=%04x\n",
30883                        dev->name, status, pci_status);
30884 +
30885 +               /* TODO: reset hardware */
30886         }
30887  
30888         spin_unlock(&cp->lock);
30889 @@ -750,7 +722,7 @@
30890  
30891         cp->tx_tail = tx_tail;
30892  
30893 -       if (netif_queue_stopped(cp->dev) && (TX_BUFFS_AVAIL(cp) > (MAX_SKB_FRAGS + 1)))
30894 +       if (TX_BUFFS_AVAIL(cp) > (MAX_SKB_FRAGS + 1))
30895                 netif_wake_queue(cp->dev);
30896  }
30897  
30898 @@ -792,7 +764,6 @@
30899                 txd->addr = cpu_to_le64(mapping);
30900                 wmb();
30901  
30902 -#ifdef CP_TX_CHECKSUM
30903                 if (skb->ip_summed == CHECKSUM_HW) {
30904                         const struct iphdr *ip = skb->nh.iph;
30905                         if (ip->protocol == IPPROTO_TCP)
30906 @@ -806,7 +777,6 @@
30907                         else
30908                                 BUG();
30909                 } else
30910 -#endif
30911                         txd->opts1 = cpu_to_le32(eor | len | DescOwn |
30912                                                  FirstFrag | LastFrag);
30913                 wmb();
30914 @@ -820,9 +790,7 @@
30915                 u32 first_len, first_eor;
30916                 dma_addr_t first_mapping;
30917                 int frag, first_entry = entry;
30918 -#ifdef CP_TX_CHECKSUM
30919                 const struct iphdr *ip = skb->nh.iph;
30920 -#endif
30921  
30922                 /* We must give this initial chunk to the device last.
30923                  * Otherwise we could race with the device.
30924 @@ -848,7 +816,7 @@
30925                                                   this_frag->page_offset),
30926                                                  len, PCI_DMA_TODEVICE);
30927                         eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
30928 -#ifdef CP_TX_CHECKSUM
30929 +
30930                         if (skb->ip_summed == CHECKSUM_HW) {
30931                                 ctrl = eor | len | DescOwn | IPCS;
30932                                 if (ip->protocol == IPPROTO_TCP)
30933 @@ -858,7 +826,6 @@
30934                                 else
30935                                         BUG();
30936                         } else
30937 -#endif
30938                                 ctrl = eor | len | DescOwn;
30939  
30940                         if (frag == skb_shinfo(skb)->nr_frags - 1)
30941 @@ -883,7 +850,6 @@
30942                 txd->addr = cpu_to_le64(first_mapping);
30943                 wmb();
30944  
30945 -#ifdef CP_TX_CHECKSUM
30946                 if (skb->ip_summed == CHECKSUM_HW) {
30947                         if (ip->protocol == IPPROTO_TCP)
30948                                 txd->opts1 = cpu_to_le32(first_eor | first_len |
30949 @@ -896,7 +862,6 @@
30950                         else
30951                                 BUG();
30952                 } else
30953 -#endif
30954                         txd->opts1 = cpu_to_le32(first_eor | first_len |
30955                                                  FirstFrag | DescOwn);
30956                 wmb();
30957 @@ -975,7 +940,9 @@
30958  
30959  static void __cp_get_stats(struct cp_private *cp)
30960  {
30961 -       /* XXX implement */
30962 +       /* only lower 24 bits valid; write any value to clear */
30963 +       cp->net_stats.rx_missed_errors += (cpr32 (RxMissed) & 0xffffff);
30964 +       cpw32 (RxMissed, 0);
30965  }
30966  
30967  static struct net_device_stats *cp_get_stats(struct net_device *dev)
30968 @@ -995,11 +962,10 @@
30969  {
30970         struct net_device *dev = cp->dev;
30971  
30972 -       cpw16(IntrMask, 0);
30973 -       cpr16(IntrMask);
30974 +       cpw16(IntrStatus, ~(cpr16(IntrStatus)));
30975 +       cpw16_f(IntrMask, 0);
30976         cpw8(Cmd, 0);
30977 -       cpw16(CpCmd, 0);
30978 -       cpr16(CpCmd);
30979 +       cpw16_f(CpCmd, 0);
30980         cpw16(IntrStatus, ~(cpr16(IntrStatus)));
30981         synchronize_irq(dev->irq);
30982         udelay(10);
30983 @@ -1031,11 +997,7 @@
30984  
30985  static inline void cp_start_hw (struct cp_private *cp)
30986  {
30987 -       u16 pci_dac = cp->pci_using_dac ? PCIDAC : 0;
30988 -       if (cp->board_type == RTL8169)
30989 -               cpw16(CpCmd, pci_dac | PCIMulRW | RxChkSum);
30990 -       else
30991 -               cpw16(CpCmd, pci_dac | PCIMulRW | RxChkSum | CpRxOn | CpTxOn);
30992 +       cpw16(CpCmd, cp->cpcmd);
30993         cpw8(Cmd, RxOn | TxOn);
30994  }
30995  
30996 @@ -1059,13 +1021,10 @@
30997  
30998         cpw8(Config1, cpr8(Config1) | DriverLoaded | PMEnable);
30999         /* Disable Wake-on-LAN. Can be turned on with ETHTOOL_SWOL */
31000 -       if (cp->board_type == RTL8139Cp) {
31001 -               cpw8(Config3, PARMEnable);
31002 -               cp->wol_enabled = 0;
31003 -       }
31004 +       cpw8(Config3, PARMEnable);
31005 +       cp->wol_enabled = 0;
31006 +
31007         cpw8(Config5, cpr8(Config5) & PMEStatus); 
31008 -       if (cp->board_type == RTL8169)
31009 -               cpw16(RxMaxSize, cp->rx_buf_sz);
31010  
31011         cpw32_f(HiTxRingAddr, 0);
31012         cpw32_f(HiTxRingAddr + 4, 0);
31013 @@ -1258,8 +1217,6 @@
31014  
31015         dev->mtu = new_mtu;
31016         cp_set_rxbufsize(cp);           /* set new rx buf size */
31017 -       if (cp->board_type == RTL8169)
31018 -               cpw16(RxMaxSize, cp->rx_buf_sz);
31019  
31020         rc = cp_init_rings(cp);         /* realloc and restart h/w */
31021         cp_start_hw(cp);
31022 @@ -1304,8 +1261,8 @@
31023  }
31024  
31025  /* Set the ethtool Wake-on-LAN settings */
31026 -static void netdev_set_wol (struct cp_private *cp,
31027 -                     const struct ethtool_wolinfo *wol)
31028 +static int netdev_set_wol (struct cp_private *cp,
31029 +                          const struct ethtool_wolinfo *wol)
31030  {
31031         u8 options;
31032  
31033 @@ -1332,6 +1289,8 @@
31034         cpw8 (Config5, options);
31035  
31036         cp->wol_enabled = (wol->wolopts) ? 1 : 0;
31037 +
31038 +       return 0;
31039  }
31040  
31041  /* Get the ethtool Wake-on-LAN settings */
31042 @@ -1357,308 +1316,205 @@
31043         if (options & MWF)           wol->wolopts |= WAKE_MCAST;
31044  }
31045  
31046 -static int cp_ethtool_ioctl (struct cp_private *cp, void *useraddr)
31047 +static void cp_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
31048  {
31049 -       u32 ethcmd;
31050 +       struct cp_private *cp = dev->priv;
31051  
31052 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
31053 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
31054 +       strcpy (info->driver, DRV_NAME);
31055 +       strcpy (info->version, DRV_VERSION);
31056 +       strcpy (info->bus_info, pci_name(cp->pdev));
31057 +}
31058  
31059 -       if (get_user(ethcmd, (u32 *)useraddr))
31060 -               return -EFAULT;
31061 -
31062 -       switch (ethcmd) {
31063 -
31064 -       case ETHTOOL_GDRVINFO: {
31065 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
31066 -               strcpy (info.driver, DRV_NAME);
31067 -               strcpy (info.version, DRV_VERSION);
31068 -               strcpy (info.bus_info, pci_name(cp->pdev));
31069 -               info.regdump_len = CP_REGS_SIZE;
31070 -               info.n_stats = CP_NUM_STATS;
31071 -               if (copy_to_user (useraddr, &info, sizeof (info)))
31072 -                       return -EFAULT;
31073 -               return 0;
31074 -       }
31075 +static int cp_get_regs_len(struct net_device *dev)
31076 +{
31077 +       return CP_REGS_SIZE;
31078 +}
31079  
31080 -       /* get settings */
31081 -       case ETHTOOL_GSET: {
31082 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
31083 -               spin_lock_irq(&cp->lock);
31084 -               mii_ethtool_gset(&cp->mii_if, &ecmd);
31085 -               spin_unlock_irq(&cp->lock);
31086 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
31087 -                       return -EFAULT;
31088 -               return 0;
31089 -       }
31090 -       /* set settings */
31091 -       case ETHTOOL_SSET: {
31092 -               int r;
31093 -               struct ethtool_cmd ecmd;
31094 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
31095 -                       return -EFAULT;
31096 -               spin_lock_irq(&cp->lock);
31097 -               r = mii_ethtool_sset(&cp->mii_if, &ecmd);
31098 -               spin_unlock_irq(&cp->lock);
31099 -               return r;
31100 -       }
31101 -       /* restart autonegotiation */
31102 -       case ETHTOOL_NWAY_RST: {
31103 -               return mii_nway_restart(&cp->mii_if);
31104 -       }
31105 -       /* get link status */
31106 -       case ETHTOOL_GLINK: {
31107 -               struct ethtool_value edata = {ETHTOOL_GLINK};
31108 -               edata.data = mii_link_ok(&cp->mii_if);
31109 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
31110 -                       return -EFAULT;
31111 -               return 0;
31112 -       }
31113 +static int cp_get_stats_count (struct net_device *dev)
31114 +{
31115 +       return CP_NUM_STATS;
31116 +}
31117  
31118 -       /* get message-level */
31119 -       case ETHTOOL_GMSGLVL: {
31120 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
31121 -               edata.data = cp->msg_enable;
31122 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
31123 -                       return -EFAULT;
31124 -               return 0;
31125 -       }
31126 -       /* set message-level */
31127 -       case ETHTOOL_SMSGLVL: {
31128 -               struct ethtool_value edata;
31129 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
31130 -                       return -EFAULT;
31131 -               cp->msg_enable = edata.data;
31132 -               return 0;
31133 -       }
31134 +static int cp_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
31135 +{
31136 +       struct cp_private *cp = dev->priv;
31137 +       int rc;
31138  
31139 -       /* NIC register dump */
31140 -       case ETHTOOL_GREGS: {
31141 -                struct ethtool_regs regs;
31142 -                u8 *regbuf = kmalloc(CP_REGS_SIZE, GFP_KERNEL);
31143 -                int rc;
31144 -
31145 -               if (!regbuf)
31146 -                       return -ENOMEM;
31147 -               memset(regbuf, 0, CP_REGS_SIZE);
31148 +       spin_lock_irq(&cp->lock);
31149 +       rc = mii_ethtool_gset(&cp->mii_if, cmd);
31150 +       spin_unlock_irq(&cp->lock);
31151  
31152 -                rc = copy_from_user(&regs, useraddr, sizeof(regs));
31153 -               if (rc) {
31154 -                       rc = -EFAULT;
31155 -                       goto err_out_gregs;
31156 -               }
31157 -                
31158 -                if (regs.len > CP_REGS_SIZE)
31159 -                        regs.len = CP_REGS_SIZE;
31160 -                if (regs.len < CP_REGS_SIZE) {
31161 -                       rc = -EINVAL;
31162 -                       goto err_out_gregs;
31163 -               }
31164 +       return rc;
31165 +}
31166  
31167 -                regs.version = CP_REGS_VER;
31168 -                rc = copy_to_user(useraddr, &regs, sizeof(regs));
31169 -               if (rc) {
31170 -                       rc = -EFAULT;
31171 -                       goto err_out_gregs;
31172 -               }
31173 +static int cp_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
31174 +{
31175 +       struct cp_private *cp = dev->priv;
31176 +       int rc;
31177  
31178 -                useraddr += offsetof(struct ethtool_regs, data);
31179 +       spin_lock_irq(&cp->lock);
31180 +       rc = mii_ethtool_sset(&cp->mii_if, cmd);
31181 +       spin_unlock_irq(&cp->lock);
31182  
31183 -                spin_lock_irq(&cp->lock);
31184 -                memcpy_fromio(regbuf, cp->regs, CP_REGS_SIZE);
31185 -                spin_unlock_irq(&cp->lock);
31186 +       return rc;
31187 +}
31188  
31189 -                if (copy_to_user(useraddr, regbuf, regs.len))
31190 -                        rc = -EFAULT;
31191 +static int cp_nway_reset(struct net_device *dev)
31192 +{
31193 +       struct cp_private *cp = dev->priv;
31194 +       return mii_nway_restart(&cp->mii_if);
31195 +}
31196  
31197 -err_out_gregs:
31198 -               kfree(regbuf);
31199 -               return rc;
31200 -       }
31201 +static u32 cp_get_msglevel(struct net_device *dev)
31202 +{
31203 +       struct cp_private *cp = dev->priv;
31204 +       return cp->msg_enable;
31205 +}
31206  
31207 -       /* get/set RX checksumming */
31208 -       case ETHTOOL_GRXCSUM: {
31209 -               struct ethtool_value edata = { ETHTOOL_GRXCSUM };
31210 -               u16 cmd = cpr16(CpCmd) & RxChkSum;
31211 -
31212 -               edata.data = cmd ? 1 : 0;
31213 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
31214 -                       return -EFAULT;
31215 -               return 0;
31216 -       }
31217 -       case ETHTOOL_SRXCSUM: {
31218 -               struct ethtool_value edata;
31219 -               u16 cmd = cpr16(CpCmd), newcmd;
31220 +static void cp_set_msglevel(struct net_device *dev, u32 value)
31221 +{
31222 +       struct cp_private *cp = dev->priv;
31223 +       cp->msg_enable = value;
31224 +}
31225  
31226 -               newcmd = cmd;
31227 +static u32 cp_get_rx_csum(struct net_device *dev)
31228 +{
31229 +       struct cp_private *cp = dev->priv;
31230 +       return (cpr16(CpCmd) & RxChkSum) ? 1 : 0;
31231 +}
31232  
31233 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
31234 -                       return -EFAULT;
31235 +static int cp_set_rx_csum(struct net_device *dev, u32 data)
31236 +{
31237 +       struct cp_private *cp = dev->priv;
31238 +       u16 cmd = cp->cpcmd, newcmd;
31239  
31240 -               if (edata.data)
31241 -                       newcmd |= RxChkSum;
31242 -               else
31243 -                       newcmd &= ~RxChkSum;
31244 +       newcmd = cmd;
31245  
31246 -               if (newcmd == cmd)
31247 -                       return 0;
31248 +       if (data)
31249 +               newcmd |= RxChkSum;
31250 +       else
31251 +               newcmd &= ~RxChkSum;
31252  
31253 +       if (newcmd != cmd) {
31254                 spin_lock_irq(&cp->lock);
31255 +               cp->cpcmd = newcmd;
31256                 cpw16_f(CpCmd, newcmd);
31257                 spin_unlock_irq(&cp->lock);
31258         }
31259  
31260 -       /* get/set TX checksumming */
31261 -       case ETHTOOL_GTXCSUM: {
31262 -               struct ethtool_value edata = { ETHTOOL_GTXCSUM };
31263 -
31264 -               edata.data = (cp->dev->features & NETIF_F_IP_CSUM) != 0;
31265 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
31266 -                       return -EFAULT;
31267 -               return 0;
31268 -       }
31269 -       case ETHTOOL_STXCSUM: {
31270 -               struct ethtool_value edata;
31271 -
31272 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
31273 -                       return -EFAULT;
31274 -
31275 -               if (edata.data)
31276 -                       cp->dev->features |= NETIF_F_IP_CSUM;
31277 -               else
31278 -                       cp->dev->features &= ~NETIF_F_IP_CSUM;
31279 -
31280 -               return 0;
31281 -       }
31282 +       return 0;
31283 +}
31284  
31285 -       /* get/set scatter-gather */
31286 -       case ETHTOOL_GSG: {
31287 -               struct ethtool_value edata = { ETHTOOL_GSG };
31288 -
31289 -               edata.data = (cp->dev->features & NETIF_F_SG) != 0;
31290 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
31291 -                       return -EFAULT;
31292 -               return 0;
31293 -       }
31294 -       case ETHTOOL_SSG: {
31295 -               struct ethtool_value edata;
31296 +static void cp_get_regs(struct net_device *dev, struct ethtool_regs *regs,
31297 +                       void *p)
31298 +{
31299 +       struct cp_private *cp = dev->priv;
31300  
31301 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
31302 -                       return -EFAULT;
31303 +       if (regs->len < CP_REGS_SIZE)
31304 +               return /* -EINVAL */;
31305  
31306 -               if (edata.data)
31307 -                       cp->dev->features |= NETIF_F_SG;
31308 -               else
31309 -                       cp->dev->features &= ~NETIF_F_SG;
31310 +       regs->version = CP_REGS_VER;
31311  
31312 -               return 0;
31313 -       }
31314 +       spin_lock_irq(&cp->lock);
31315 +       memcpy_fromio(p, cp->regs, CP_REGS_SIZE);
31316 +       spin_unlock_irq(&cp->lock);
31317 +}
31318  
31319 -       /* get string list(s) */
31320 -       case ETHTOOL_GSTRINGS: {
31321 -               struct ethtool_gstrings estr = { ETHTOOL_GSTRINGS };
31322 -
31323 -               if (copy_from_user(&estr, useraddr, sizeof(estr)))
31324 -                       return -EFAULT;
31325 -               if (estr.string_set != ETH_SS_STATS)
31326 -                       return -EINVAL;
31327 -
31328 -               estr.len = CP_NUM_STATS;
31329 -               if (copy_to_user(useraddr, &estr, sizeof(estr)))
31330 -                       return -EFAULT;
31331 -               if (copy_to_user(useraddr + sizeof(estr),
31332 -                                &ethtool_stats_keys,
31333 -                                sizeof(ethtool_stats_keys)))
31334 -                       return -EFAULT;
31335 -               return 0;
31336 -       }
31337 +static void cp_get_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
31338 +{
31339 +       struct cp_private *cp = dev->priv;
31340  
31341 -       /* get NIC-specific statistics */
31342 -       case ETHTOOL_GSTATS: {
31343 -               struct ethtool_stats estats = { ETHTOOL_GSTATS };
31344 -               u64 *tmp_stats;
31345 -               unsigned int work = 100;
31346 -               const unsigned int sz = sizeof(u64) * CP_NUM_STATS;
31347 -               int i;
31348 -
31349 -               /* begin NIC statistics dump */
31350 -               cpw32(StatsAddr + 4, 0); /* FIXME: 64-bit PCI */
31351 -               cpw32(StatsAddr, cp->nic_stats_dma | DumpStats);
31352 -               cpr32(StatsAddr);
31353 -
31354 -               estats.n_stats = CP_NUM_STATS;
31355 -               if (copy_to_user(useraddr, &estats, sizeof(estats)))
31356 -                       return -EFAULT;
31357 -
31358 -               while (work-- > 0) {
31359 -                       if ((cpr32(StatsAddr) & DumpStats) == 0)
31360 -                               break;
31361 -                       cpu_relax();
31362 -               }
31363 +       spin_lock_irq (&cp->lock);
31364 +       netdev_get_wol (cp, wol);
31365 +       spin_unlock_irq (&cp->lock);
31366 +}
31367  
31368 -               if (cpr32(StatsAddr) & DumpStats)
31369 -                       return -EIO;
31370 +static int cp_set_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
31371 +{
31372 +       struct cp_private *cp = dev->priv;
31373 +       int rc;
31374  
31375 -               tmp_stats = kmalloc(sz, GFP_KERNEL);
31376 -               if (!tmp_stats)
31377 -                       return -ENOMEM;
31378 -               memset(tmp_stats, 0, sz);
31379 -
31380 -               i = 0;
31381 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);
31382 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok);
31383 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_err);
31384 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_err);
31385 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->rx_fifo);
31386 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->frame_align);
31387 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_1col);
31388 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_mcol);
31389 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_phys);
31390 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_bcast);
31391 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_ok_mcast);
31392 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_abort);
31393 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_underrun);
31394 -               tmp_stats[i++] = cp->cp_stats.rx_frags;
31395 -               if (i != CP_NUM_STATS)
31396 -                       BUG();
31397 +       spin_lock_irq (&cp->lock);
31398 +       rc = netdev_set_wol (cp, wol);
31399 +       spin_unlock_irq (&cp->lock);
31400  
31401 -               i = copy_to_user(useraddr + sizeof(estats),
31402 -                                tmp_stats, sz);
31403 -               kfree(tmp_stats);
31404 +       return rc;
31405 +}
31406  
31407 -               if (i)
31408 -                       return -EFAULT;
31409 -               return 0;
31410 +static void cp_get_strings (struct net_device *dev, u32 stringset, u8 *buf)
31411 +{
31412 +       switch (stringset) {
31413 +       case ETH_SS_STATS:
31414 +               memcpy(buf, &ethtool_stats_keys, sizeof(ethtool_stats_keys));
31415 +               break;
31416 +       default:
31417 +               BUG();
31418 +               break;
31419         }
31420 +}
31421  
31422 -       /* get/set Wake-on-LAN settings */
31423 -       case ETHTOOL_GWOL: {
31424 -               struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
31425 -               
31426 -               spin_lock_irq (&cp->lock);
31427 -               netdev_get_wol (cp, &wol);
31428 -               spin_unlock_irq (&cp->lock);
31429 -               return ((copy_to_user (useraddr, &wol, sizeof (wol)))? -EFAULT : 0);
31430 -       }
31431 -       
31432 -       case ETHTOOL_SWOL: {
31433 -               struct ethtool_wolinfo wol;
31434 +static void cp_get_ethtool_stats (struct net_device *dev,
31435 +                                 struct ethtool_stats *estats, u64 *tmp_stats)
31436 +{
31437 +       struct cp_private *cp = dev->priv;
31438 +       unsigned int work = 100;
31439 +       int i;
31440  
31441 -               if (copy_from_user (&wol, useraddr, sizeof (wol)))
31442 -                       return -EFAULT;
31443 -               spin_lock_irq (&cp->lock);
31444 -               netdev_set_wol (cp, &wol);
31445 -               spin_unlock_irq (&cp->lock);
31446 -               return 0;
31447 -       }
31448 +       /* begin NIC statistics dump */
31449 +       cpw32(StatsAddr + 4, 0); /* FIXME: 64-bit PCI */
31450 +       cpw32(StatsAddr, cp->nic_stats_dma | DumpStats);
31451 +       cpr32(StatsAddr);
31452  
31453 -       default:
31454 -               break;
31455 +       while (work-- > 0) {
31456 +               if ((cpr32(StatsAddr) & DumpStats) == 0)
31457 +                       break;
31458 +               cpu_relax();
31459         }
31460  
31461 -       return -EOPNOTSUPP;
31462 +       if (cpr32(StatsAddr) & DumpStats)
31463 +               return /* -EIO */;
31464 +
31465 +       i = 0;
31466 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);
31467 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok);
31468 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_err);
31469 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_err);
31470 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->rx_fifo);
31471 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->frame_align);
31472 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_1col);
31473 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_mcol);
31474 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_phys);
31475 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_bcast);
31476 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_ok_mcast);
31477 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_abort);
31478 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_underrun);
31479 +       tmp_stats[i++] = cp->cp_stats.rx_frags;
31480 +       if (i != CP_NUM_STATS)
31481 +               BUG();
31482  }
31483  
31484 +static struct ethtool_ops cp_ethtool_ops = {
31485 +       .get_drvinfo            = cp_get_drvinfo,
31486 +       .get_regs_len           = cp_get_regs_len,
31487 +       .get_stats_count        = cp_get_stats_count,
31488 +       .get_settings           = cp_get_settings,
31489 +       .set_settings           = cp_set_settings,
31490 +       .nway_reset             = cp_nway_reset,
31491 +       .get_link               = ethtool_op_get_link,
31492 +       .get_msglevel           = cp_get_msglevel,
31493 +       .set_msglevel           = cp_set_msglevel,
31494 +       .get_rx_csum            = cp_get_rx_csum,
31495 +       .set_rx_csum            = cp_set_rx_csum,
31496 +       .get_tx_csum            = ethtool_op_get_tx_csum,
31497 +       .set_tx_csum            = ethtool_op_set_tx_csum, /* local! */
31498 +       .get_sg                 = ethtool_op_get_sg,
31499 +       .set_sg                 = ethtool_op_set_sg,
31500 +       .get_regs               = cp_get_regs,
31501 +       .get_wol                = cp_get_wol,
31502 +       .set_wol                = cp_set_wol,
31503 +       .get_strings            = cp_get_strings,
31504 +       .get_ethtool_stats      = cp_get_ethtool_stats,
31505 +};
31506  
31507  static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
31508  {
31509 @@ -1669,38 +1525,12 @@
31510         if (!netif_running(dev))
31511                 return -EINVAL;
31512  
31513 -       if (cmd == SIOCETHTOOL)
31514 -               return cp_ethtool_ioctl(cp, (void *) rq->ifr_data);
31515 -
31516         spin_lock_irq(&cp->lock);
31517         rc = generic_mii_ioctl(&cp->mii_if, mii, cmd, NULL);
31518         spin_unlock_irq(&cp->lock);
31519         return rc;
31520  }
31521  
31522 -#if CP_VLAN_TAG_USED
31523 -static void cp_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
31524 -{
31525 -       struct cp_private *cp = dev->priv;
31526 -
31527 -       spin_lock_irq(&cp->lock);
31528 -       cp->vlgrp = grp;
31529 -       cpw16(CpCmd, cpr16(CpCmd) | RxVlanOn);
31530 -       spin_unlock_irq(&cp->lock);
31531 -}
31532 -
31533 -static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
31534 -{
31535 -       struct cp_private *cp = dev->priv;
31536 -
31537 -       spin_lock_irq(&cp->lock);
31538 -       cpw16(CpCmd, cpr16(CpCmd) & ~RxVlanOn);
31539 -       if (cp->vlgrp)
31540 -               cp->vlgrp->vlan_devices[vid] = NULL;
31541 -       spin_unlock_irq(&cp->lock);
31542 -}
31543 -#endif
31544 -
31545  /* Serial EEPROM section. */
31546  
31547  /*  EEPROM_Ctrl bits. */
31548 @@ -1723,7 +1553,7 @@
31549  #define EE_READ_CMD            (6)
31550  #define EE_ERASE_CMD   (7)
31551  
31552 -static int __devinit read_eeprom (void *ioaddr, int location, int addr_len)
31553 +static int read_eeprom (void *ioaddr, int location, int addr_len)
31554  {
31555         int i;
31556         unsigned retval = 0;
31557 @@ -1769,17 +1599,15 @@
31558         pci_set_power_state (cp->pdev, 3);
31559  }
31560  
31561 -static int __devinit cp_init_one (struct pci_dev *pdev,
31562 -                                 const struct pci_device_id *ent)
31563 +static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
31564  {
31565         struct net_device *dev;
31566         struct cp_private *cp;
31567         int rc;
31568         void *regs;
31569         long pciaddr;
31570 -       unsigned int addr_len, i;
31571 -       u8 pci_rev, cache_size;
31572 -       unsigned int board_type = (unsigned int) ent->driver_data;
31573 +       unsigned int addr_len, i, pci_using_dac;
31574 +       u8 pci_rev;
31575  
31576  #ifndef MODULE
31577         static int version_printed;
31578 @@ -1805,7 +1633,6 @@
31579  
31580         cp = dev->priv;
31581         cp->pdev = pdev;
31582 -       cp->board_type = board_type;
31583         cp->dev = dev;
31584         cp->msg_enable = (debug < 0 ? CP_DEF_MSG_ENABLE : debug);
31585         spin_lock_init (&cp->lock);
31586 @@ -1821,10 +1648,14 @@
31587         if (rc)
31588                 goto err_out_free;
31589  
31590 -       rc = pci_request_regions(pdev, DRV_NAME);
31591 +       rc = pci_set_mwi(pdev);
31592         if (rc)
31593                 goto err_out_disable;
31594  
31595 +       rc = pci_request_regions(pdev, DRV_NAME);
31596 +       if (rc)
31597 +               goto err_out_mwi;
31598 +
31599         if (pdev->irq < 2) {
31600                 rc = -EIO;
31601                 printk(KERN_ERR PFX "invalid irq (%d) for pci dev %s\n",
31602 @@ -1846,18 +1677,22 @@
31603         }
31604  
31605         /* Configure DMA attributes. */
31606 -       if (!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) {
31607 -               cp->pci_using_dac = 1;
31608 +       if ((sizeof(dma_addr_t) > 32) &&
31609 +           !pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) {
31610 +               pci_using_dac = 1;
31611         } else {
31612 -               rc = pci_set_dma_mask(pdev, (u64) 0xffffffff);
31613 +               rc = pci_set_dma_mask(pdev, 0xffffffffULL);
31614                 if (rc) {
31615                         printk(KERN_ERR PFX "No usable DMA configuration, "
31616                                "aborting.\n");
31617                         goto err_out_res;
31618                 }
31619 -               cp->pci_using_dac = 0;
31620 +               pci_using_dac = 0;
31621         }
31622  
31623 +       cp->cpcmd = (pci_using_dac ? PCIDAC : 0) |
31624 +                   PCIMulRW | RxChkSum | CpRxOn | CpTxOn;
31625 +
31626         regs = ioremap_nocache(pciaddr, CP_REGS_SIZE);
31627         if (!regs) {
31628                 rc = -EIO;
31629 @@ -1882,16 +1717,17 @@
31630         dev->hard_start_xmit = cp_start_xmit;
31631         dev->get_stats = cp_get_stats;
31632         dev->do_ioctl = cp_ioctl;
31633 +       dev->poll = cp_rx_poll;
31634 +       dev->weight = 16;       /* arbitrary? from NAPI_HOWTO.txt. */
31635  #ifdef BROKEN
31636         dev->change_mtu = cp_change_mtu;
31637  #endif
31638 +       dev->ethtool_ops = &cp_ethtool_ops;
31639  #if 0
31640         dev->tx_timeout = cp_tx_timeout;
31641         dev->watchdog_timeo = TX_TIMEOUT;
31642  #endif
31643 -#ifdef CP_TX_CHECKSUM
31644 -       dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
31645 -#endif
31646 +
31647  #if CP_VLAN_TAG_USED
31648         dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
31649         dev->vlan_rx_register = cp_vlan_rx_register;
31650 @@ -1904,11 +1740,10 @@
31651         if (rc)
31652                 goto err_out_iomap;
31653  
31654 -       printk (KERN_INFO "%s: %s at 0x%lx, "
31655 +       printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, "
31656                 "%02x:%02x:%02x:%02x:%02x:%02x, "
31657                 "IRQ %d\n",
31658                 dev->name,
31659 -               cp_board_tbl[board_type].name,
31660                 dev->base_addr,
31661                 dev->dev_addr[0], dev->dev_addr[1],
31662                 dev->dev_addr[2], dev->dev_addr[3],
31663 @@ -1917,29 +1752,8 @@
31664  
31665         pci_set_drvdata(pdev, dev);
31666  
31667 -       /*
31668 -        * Looks like this is necessary to deal with on all architectures,
31669 -        * even this %$#%$# N440BX Intel based thing doesn't get it right.
31670 -        * Ie. having two NICs in the machine, one will have the cache
31671 -        * line set at boot time, the other will not.
31672 -        */
31673 -       pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache_size);
31674 -       cache_size <<= 2;
31675 -       if (cache_size != SMP_CACHE_BYTES) {
31676 -               printk(KERN_INFO "%s: PCI cache line size set incorrectly "
31677 -                      "(%i bytes) by BIOS/FW, ", dev->name, cache_size);
31678 -               if (cache_size > SMP_CACHE_BYTES)
31679 -                       printk("expecting %i\n", SMP_CACHE_BYTES);
31680 -               else {
31681 -                       printk("correcting to %i\n", SMP_CACHE_BYTES);
31682 -                       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
31683 -                                             SMP_CACHE_BYTES >> 2);
31684 -               }
31685 -       }
31686 -
31687         /* enable busmastering and memory-write-invalidate */
31688         pci_set_master(pdev);
31689 -       pci_set_mwi(pdev);
31690  
31691         if (cp->wol_enabled) cp_set_d3_state (cp);
31692  
31693 @@ -1949,6 +1763,8 @@
31694         iounmap(regs);
31695  err_out_res:
31696         pci_release_regions(pdev);
31697 +err_out_mwi:
31698 +       pci_clear_mwi(pdev);
31699  err_out_disable:
31700         pci_disable_device(pdev);
31701  err_out_free:
31702 @@ -1956,7 +1772,7 @@
31703         return rc;
31704  }
31705  
31706 -static void __devexit cp_remove_one (struct pci_dev *pdev)
31707 +static void cp_remove_one (struct pci_dev *pdev)
31708  {
31709         struct net_device *dev = pci_get_drvdata(pdev);
31710         struct cp_private *cp = dev->priv;
31711 @@ -1967,6 +1783,7 @@
31712         iounmap(cp->regs);
31713         if (cp->wol_enabled) pci_set_power_state (pdev, 0);
31714         pci_release_regions(pdev);
31715 +       pci_clear_mwi(pdev);
31716         pci_disable_device(pdev);
31717         pci_set_drvdata(pdev, NULL);
31718         free_netdev(dev);
31719 @@ -2029,7 +1846,7 @@
31720         .name         = DRV_NAME,
31721         .id_table     = cp_pci_tbl,
31722         .probe        = cp_init_one,
31723 -       .remove       = __devexit_p(cp_remove_one),
31724 +       .remove       = cp_remove_one,
31725  #ifdef CONFIG_PM
31726         .resume       = cp_resume,
31727         .suspend      = cp_suspend,
31728 diff -Nru a/drivers/net/8139too.c b/drivers/net/8139too.c
31729 --- a/drivers/net/8139too.c     Tue Aug 19 20:13:55 2003
31730 +++ b/drivers/net/8139too.c     Sun Aug 31 12:38:16 2003
31731 @@ -123,6 +123,11 @@
31732  #define USE_IO_OPS 1
31733  #endif
31734  
31735 +/* use a 16K rx ring buffer instead of the default 32K */
31736 +#ifdef CONFIG_SH_DREAMCAST
31737 +#define USE_BUF16K 1
31738 +#endif
31739 +
31740  /* define to 1 to enable copious debugging info */
31741  #undef RTL8139_DEBUG
31742  
31743 @@ -165,7 +170,11 @@
31744  static int debug = -1;
31745  
31746  /* Size of the in-memory receive ring. */
31747 +#ifdef USE_BUF16K
31748 +#define RX_BUF_LEN_IDX 1       /* 0==8K, 1==16K, 2==32K, 3==64K */
31749 +#else
31750  #define RX_BUF_LEN_IDX 2       /* 0==8K, 1==16K, 2==32K, 3==64K */
31751 +#endif
31752  #define RX_BUF_LEN     (8192 << RX_BUF_LEN_IDX)
31753  #define RX_BUF_PAD     16
31754  #define RX_BUF_WRAP_PAD 2048 /* spare padding to handle lack of packet wrap */
31755 @@ -212,18 +221,7 @@
31756  
31757  typedef enum {
31758         RTL8139 = 0,
31759 -       RTL8139_CB,
31760 -       SMC1211TX,
31761 -       /*MPX5030,*/
31762 -       DELTA8139,
31763 -       ADDTRON8139,
31764 -       DFE538TX,
31765 -       DFE690TXD,
31766 -       FE2000VX,
31767 -       ALLIED8139,
31768         RTL8129,
31769 -       FNW3603TX,
31770 -       FNW3800TX,
31771  } board_t;
31772  
31773  
31774 @@ -232,36 +230,29 @@
31775         const char *name;
31776         u32 hw_flags;
31777  } board_info[] __devinitdata = {
31778 -       { "RealTek RTL8139 Fast Ethernet", RTL8139_CAPS },
31779 -       { "RealTek RTL8139B PCI/CardBus", RTL8139_CAPS },
31780 -       { "SMC1211TX EZCard 10/100 (RealTek RTL8139)", RTL8139_CAPS },
31781 -/*     { MPX5030, "Accton MPX5030 (RealTek RTL8139)", RTL8139_CAPS },*/
31782 -       { "Delta Electronics 8139 10/100BaseTX", RTL8139_CAPS },
31783 -       { "Addtron Technolgy 8139 10/100BaseTX", RTL8139_CAPS },
31784 -       { "D-Link DFE-538TX (RealTek RTL8139)", RTL8139_CAPS },
31785 -       { "D-Link DFE-690TXD (RealTek RTL8139)", RTL8139_CAPS },
31786 -       { "AboCom FE2000VX (RealTek RTL8139)", RTL8139_CAPS },
31787 -       { "Allied Telesyn 8139 CardBus", RTL8139_CAPS },
31788 +       { "RealTek RTL8139", RTL8139_CAPS },
31789         { "RealTek RTL8129", RTL8129_CAPS },
31790 -       { "Planex FNW-3603-TX 10/100 CardBus", RTL8139_CAPS },
31791 -       { "Planex FNW-3800-TX 10/100 CardBus", RTL8139_CAPS },
31792  };
31793  
31794  
31795  static struct pci_device_id rtl8139_pci_tbl[] = {
31796         {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31797 -       {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139_CB },
31798 -       {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SMC1211TX },
31799 -/*     {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MPX5030 },*/
31800 -       {0x1500, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DELTA8139 },
31801 -       {0x4033, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ADDTRON8139 },
31802 -       {0x1186, 0x1300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DFE538TX },
31803 -       {0x1186, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DFE690TXD },
31804 -       {0x13d1, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FE2000VX },
31805 -       {0x1259, 0xa117, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ALLIED8139 },
31806 -       {0x14ea, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FNW3603TX },
31807 -       {0x14ea, 0xab07, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FNW3800TX },
31808 -
31809 +       {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31810 +       {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31811 +       {0x1500, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31812 +       {0x4033, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31813 +       {0x1186, 0x1300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31814 +       {0x1186, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31815 +       {0x13d1, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31816 +       {0x1259, 0xa117, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31817 +       {0x14ea, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31818 +       {0x14ea, 0xab07, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31819 +       {0x11db, 0x1234, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31820 +
31821 +#ifdef CONFIG_SH_SECUREEDGE5410
31822 +       /* Bogus 8139 silicon reports 8129 without external PROM :-( */
31823 +       {0x10ec, 0x8129, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
31824 +#endif
31825  #ifdef CONFIG_8139TOO_8129
31826         {0x10ec, 0x8129, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8129 },
31827  #endif
31828 @@ -271,8 +262,8 @@
31829          * so we simply don't match on the main vendor id.
31830          */
31831         {PCI_ANY_ID, 0x8139, 0x10ec, 0x8139, 0, 0, RTL8139 },
31832 -       {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, DFE538TX },
31833 -       {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, FE2000VX },
31834 +       {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, RTL8139 },
31835 +       {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, RTL8139 },
31836  
31837         {0,}
31838  };
31839 @@ -302,7 +293,6 @@
31840         IntrMask = 0x3C,
31841         IntrStatus = 0x3E,
31842         TxConfig = 0x40,
31843 -       ChipVersion = 0x43,
31844         RxConfig = 0x44,
31845         Timer = 0x48,           /* A general-purpose counter. */
31846         RxMissed = 0x4C,        /* 24 bits valid, write clears. */
31847 @@ -461,7 +451,6 @@
31848         RxNoWrap = (1 << 7),
31849  };
31850  
31851 -
31852  /* Twister tuning parameters from RealTek.
31853     Completely undocumented, but required to tune bad links on some boards. */
31854  enum CSCRBits {
31855 @@ -472,36 +461,22 @@
31856         CSCR_LinkDownCmd = 0x0f3c0,
31857  };
31858  
31859 -
31860  enum Cfg9346Bits {
31861         Cfg9346_Lock = 0x00,
31862         Cfg9346_Unlock = 0xC0,
31863  };
31864  
31865 -#ifdef CONFIG_8139TOO_TUNE_TWISTER
31866 -
31867 -enum TwisterParamVals {
31868 -       PARA78_default  = 0x78fa8388,
31869 -       PARA7c_default  = 0xcb38de43,   /* param[0][3] */
31870 -       PARA7c_xxx      = 0xcb38de43,
31871 -};
31872 -
31873 -static const unsigned long param[4][4] = {
31874 -       {0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43},
31875 -       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
31876 -       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
31877 -       {0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83}
31878 -};
31879 -
31880 -#endif /* CONFIG_8139TOO_TUNE_TWISTER */
31881 -
31882  typedef enum {
31883         CH_8139 = 0,
31884         CH_8139_K,
31885         CH_8139A,
31886 +       CH_8139A_G,
31887         CH_8139B,
31888         CH_8130,
31889         CH_8139C,
31890 +       CH_8100,
31891 +       CH_8100B_8139D,
31892 +       CH_8101,
31893  } chip_t;
31894  
31895  enum chip_flags {
31896 @@ -509,50 +484,65 @@
31897         HasLWake = (1 << 1),
31898  };
31899  
31900 +#define HW_REVID(b30, b29, b28, b27, b26, b23, b22) \
31901 +       (b30<<30 | b29<<29 | b28<<28 | b27<<27 | b26<<26 | b23<<23 | b22<<22)
31902 +#define HW_REVID_MASK  HW_REVID(1, 1, 1, 1, 1, 1, 1)
31903  
31904  /* directly indexed by chip_t, above */
31905  const static struct {
31906         const char *name;
31907 -       u8 version; /* from RTL8139C docs */
31908 -       u32 RxConfigMask; /* should clear the bits supported by this chip */
31909 +       u32 version; /* from RTL8139C/RTL8139D docs */
31910         u32 flags;
31911  } rtl_chip_info[] = {
31912         { "RTL-8139",
31913 -         0x40,
31914 -         0xf0fe0040, /* XXX copied from RTL8139A, verify */
31915 +         HW_REVID(1, 0, 0, 0, 0, 0, 0),
31916           HasHltClk,
31917         },
31918  
31919         { "RTL-8139 rev K",
31920 -         0x60,
31921 -         0xf0fe0040,
31922 +         HW_REVID(1, 1, 0, 0, 0, 0, 0),
31923           HasHltClk,
31924         },
31925  
31926         { "RTL-8139A",
31927 -         0x70,
31928 -         0xf0fe0040,
31929 +         HW_REVID(1, 1, 1, 0, 0, 0, 0),
31930 +         HasHltClk, /* XXX undocumented? */
31931 +       },
31932 +
31933 +       { "RTL-8139A rev G",
31934 +         HW_REVID(1, 1, 1, 0, 0, 1, 0),
31935           HasHltClk, /* XXX undocumented? */
31936         },
31937  
31938         { "RTL-8139B",
31939 -         0x78,
31940 -         0xf0fc0040,
31941 +         HW_REVID(1, 1, 1, 1, 0, 0, 0),
31942           HasLWake,
31943         },
31944  
31945         { "RTL-8130",
31946 -         0x7C,
31947 -         0xf0fe0040, /* XXX copied from RTL8139A, verify */
31948 +         HW_REVID(1, 1, 1, 1, 1, 0, 0),
31949           HasLWake,
31950         },
31951  
31952         { "RTL-8139C",
31953 -         0x74,
31954 -         0xf0fc0040, /* XXX copied from RTL8139B, verify */
31955 +         HW_REVID(1, 1, 1, 0, 1, 0, 0),
31956           HasLWake,
31957         },
31958  
31959 +       { "RTL-8100",
31960 +         HW_REVID(1, 1, 1, 1, 0, 1, 0),
31961 +         HasLWake,
31962 +       },
31963 +
31964 +       { "RTL-8100B/8139D",
31965 +         HW_REVID(1, 1, 1, 0, 1, 0, 1),
31966 +         HasLWake,
31967 +       },
31968 +
31969 +       { "RTL-8101",
31970 +         HW_REVID(1, 1, 1, 0, 1, 1, 1),
31971 +         HasLWake,
31972 +       },
31973  };
31974  
31975  struct rtl_extra_stats {
31976 @@ -612,7 +602,7 @@
31977  static int mdio_read (struct net_device *dev, int phy_id, int location);
31978  static void mdio_write (struct net_device *dev, int phy_id, int location,
31979                         int val);
31980 -static int rtl8139_thread (void *data);
31981 +static inline void rtl8139_start_thread(struct net_device *dev);
31982  static void rtl8139_tx_timeout (struct net_device *dev);
31983  static void rtl8139_init_ring (struct net_device *dev);
31984  static int rtl8139_start_xmit (struct sk_buff *skb,
31985 @@ -625,6 +615,7 @@
31986  static void rtl8139_set_rx_mode (struct net_device *dev);
31987  static void __set_rx_mode (struct net_device *dev);
31988  static void rtl8139_hw_start (struct net_device *dev);
31989 +static struct ethtool_ops rtl8139_ethtool_ops;
31990  
31991  #ifdef USE_IO_OPS
31992  
31993 @@ -688,10 +679,17 @@
31994         PCIErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver |
31995         TxErr | TxOK | RxErr | RxOK;
31996  
31997 +#ifdef USE_BUF16K 
31998 +static const unsigned int rtl8139_rx_config =
31999 +       RxCfgRcv16K | RxNoWrap |
32000 +       (RX_FIFO_THRESH << RxCfgFIFOShift) |
32001 +       (RX_DMA_BURST << RxCfgDMAShift);
32002 +#else
32003  static const unsigned int rtl8139_rx_config =
32004         RxCfgRcv32K | RxNoWrap |
32005         (RX_FIFO_THRESH << RxCfgFIFOShift) |
32006         (RX_DMA_BURST << RxCfgDMAShift);
32007 +#endif
32008  
32009  static const unsigned int rtl8139_tx_config =
32010         (TX_DMA_BURST << TxDMAShift) | (TX_RETRY << TxRetryShift);
32011 @@ -716,13 +714,6 @@
32012         /* it's ok to call this even if we have no regions to free */
32013         pci_release_regions (pdev);
32014  
32015 -#ifndef RTL8139_NDEBUG
32016 -       /* poison memory before freeing */
32017 -       memset (dev, 0xBC,
32018 -               sizeof (struct net_device) +
32019 -               sizeof (struct rtl8139_private));
32020 -#endif /* RTL8139_NDEBUG */
32021 -
32022         free_netdev(dev);
32023  
32024         pci_set_drvdata (pdev, NULL);
32025 @@ -757,7 +748,7 @@
32026         unsigned int i;
32027         u32 pio_start, pio_end, pio_flags, pio_len;
32028         unsigned long mmio_start, mmio_end, mmio_flags, mmio_len;
32029 -       u32 tmp;
32030 +       u32 version;
32031  
32032         assert (pdev != NULL);
32033  
32034 @@ -859,9 +850,9 @@
32035         }
32036  
32037         /* identify chip attached to board */
32038 -       tmp = RTL_R8 (ChipVersion);
32039 +       version = RTL_R32 (TxConfig) & HW_REVID_MASK;
32040         for (i = 0; i < ARRAY_SIZE (rtl_chip_info); i++)
32041 -               if (tmp == rtl_chip_info[i].version) {
32042 +               if (version == rtl_chip_info[i].version) {
32043                         tp->chipset = i;
32044                         goto match;
32045                 }
32046 @@ -892,8 +883,11 @@
32047                 }
32048                 if (rtl_chip_info[tp->chipset].flags & HasLWake) {
32049                         tmp8 = RTL_R8 (Config4);
32050 -                       if (tmp8 & LWPTN)
32051 +                       if (tmp8 & LWPTN) {
32052 +                               RTL_W8 (Cfg9346, Cfg9346_Unlock);
32053                                 RTL_W8 (Config4, tmp8 & ~LWPTN);
32054 +                               RTL_W8 (Cfg9346, Cfg9346_Lock);
32055 +                       }
32056                 }
32057         } else {
32058                 DPRINTK("Old chip wakeup\n");
32059 @@ -971,6 +965,7 @@
32060         dev->get_stats = rtl8139_get_stats;
32061         dev->set_multicast_list = rtl8139_set_rx_mode;
32062         dev->do_ioctl = netdev_ioctl;
32063 +       dev->ethtool_ops = &rtl8139_ethtool_ops;
32064         dev->tx_timeout = rtl8139_tx_timeout;
32065         dev->watchdog_timeo = TX_TIMEOUT;
32066  
32067 @@ -1318,8 +1313,6 @@
32068  
32069         tp->mii.full_duplex = tp->mii.force_media;
32070         tp->tx_flag = (TX_FIFO_THRESH << 11) & 0x003f0000;
32071 -       tp->twistie = (tp->chipset == CH_8139_K) ? 1 : 0;
32072 -       tp->time_to_die = 0;
32073  
32074         rtl8139_init_ring (dev);
32075         rtl8139_hw_start (dev);
32076 @@ -1330,32 +1323,18 @@
32077                         dev->irq, RTL_R8 (MediaStatus),
32078                         tp->mii.full_duplex ? "full" : "half");
32079  
32080 -       tp->thr_pid = kernel_thread (rtl8139_thread, dev, CLONE_FS | CLONE_FILES);
32081 -       if (tp->thr_pid < 0)
32082 -               printk (KERN_WARNING "%s: unable to start kernel thread\n",
32083 -                       dev->name);
32084 +       rtl8139_start_thread(dev);
32085  
32086         return 0;
32087  }
32088  
32089  
32090 -static void rtl_check_media (struct net_device *dev)
32091 +static void rtl_check_media (struct net_device *dev, unsigned int init_media)
32092  {
32093         struct rtl8139_private *tp = dev->priv;
32094  
32095         if (tp->phys[0] >= 0) {
32096 -               u16 mii_lpa = mdio_read(dev, tp->phys[0], MII_LPA);
32097 -               if (mii_lpa == 0xffff)
32098 -                       ;                                       /* Not there */
32099 -               else if ((mii_lpa & LPA_100FULL) == LPA_100FULL
32100 -                                || (mii_lpa & 0x00C0) == LPA_10FULL)
32101 -                       tp->mii.full_duplex = 1;
32102 -
32103 -               printk (KERN_INFO"%s: Setting %s%s-duplex based on"
32104 -                               " auto-negotiated partner ability %4.4x.\n",
32105 -                       dev->name, mii_lpa == 0 ? "" :
32106 -                               (mii_lpa & 0x0180) ? "100mbps " : "10mbps ",
32107 -                       tp->mii.full_duplex ? "full" : "half", mii_lpa);
32108 +               mii_check_media(&tp->mii, 1, init_media);
32109         }
32110  }
32111  
32112 @@ -1390,7 +1369,7 @@
32113  
32114         tp->cur_rx = 0;
32115  
32116 -       rtl_check_media (dev);
32117 +       rtl_check_media (dev, 1);
32118  
32119         if (tp->chipset >= CH_8139B) {
32120                 /* Disable magic packet scanning, which is enabled
32121 @@ -1452,6 +1431,19 @@
32122  static inline void rtl8139_tune_twister (struct net_device *dev,
32123                                   struct rtl8139_private *tp) {}
32124  #else
32125 +enum TwisterParamVals {
32126 +       PARA78_default  = 0x78fa8388,
32127 +       PARA7c_default  = 0xcb38de43,   /* param[0][3] */
32128 +       PARA7c_xxx      = 0xcb38de43,
32129 +};
32130 +
32131 +static const unsigned long param[4][4] = {
32132 +       {0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43},
32133 +       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
32134 +       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
32135 +       {0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83}
32136 +};
32137 +
32138  static void rtl8139_tune_twister (struct net_device *dev,
32139                                   struct rtl8139_private *tp)
32140  {
32141 @@ -1538,7 +1530,6 @@
32142  }
32143  #endif /* CONFIG_8139TOO_TUNE_TWISTER */
32144  
32145 -
32146  static inline void rtl8139_thread_iter (struct net_device *dev,
32147                                  struct rtl8139_private *tp,
32148                                  void *ioaddr)
32149 @@ -1585,7 +1576,6 @@
32150                  RTL_R8 (Config1));
32151  }
32152  
32153 -
32154  static int rtl8139_thread (void *data)
32155  {
32156         struct net_device *dev = data;
32157 @@ -1619,6 +1609,24 @@
32158         complete_and_exit (&tp->thr_exited, 0);
32159  }
32160  
32161 +static inline void rtl8139_start_thread(struct net_device *dev)
32162 +{
32163 +       struct rtl8139_private *tp = dev->priv;
32164 +
32165 +       tp->thr_pid = -1;
32166 +       tp->twistie = 0;
32167 +       tp->time_to_die = 0;
32168 +       if (tp->chipset == CH_8139_K)
32169 +               tp->twistie = 1;
32170 +       else if (tp->drv_flags & HAS_LNK_CHNG)
32171 +               return;
32172 +
32173 +       tp->thr_pid = kernel_thread(rtl8139_thread, dev, CLONE_FS|CLONE_FILES);
32174 +       if (tp->thr_pid < 0) {
32175 +               printk (KERN_WARNING "%s: unable to start kernel thread\n",
32176 +                       dev->name);
32177 +       }
32178 +}
32179  
32180  static void rtl8139_tx_clear (struct rtl8139_private *tp)
32181  {
32182 @@ -1999,18 +2007,7 @@
32183  
32184         if ((status & RxUnderrun) && link_changed &&
32185             (tp->drv_flags & HAS_LNK_CHNG)) {
32186 -               /* Really link-change on new chips. */
32187 -               int lpar = RTL_R16 (NWayLPAR);
32188 -               int duplex = (lpar & LPA_100FULL) || (lpar & 0x01C0) == 0x0040
32189 -                               || tp->mii.force_media;
32190 -               if (tp->mii.full_duplex != duplex) {
32191 -                       tp->mii.full_duplex = duplex;
32192 -#if 0
32193 -                       RTL_W8 (Cfg9346, Cfg9346_Unlock);
32194 -                       RTL_W8 (Config1, tp->mii.full_duplex ? 0x60 : 0x20);
32195 -                       RTL_W8 (Cfg9346, Cfg9346_Lock);
32196 -#endif
32197 -               }
32198 +               rtl_check_media(dev, 0);
32199                 status &= ~RxUnderrun;
32200         }
32201  
32202 @@ -2173,11 +2170,12 @@
32203  /* Get the ethtool Wake-on-LAN settings.  Assumes that wol points to
32204     kernel memory, *wol has been initialized as {ETHTOOL_GWOL}, and
32205     other threads or interrupts aren't messing with the 8139.  */
32206 -static void netdev_get_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
32207 +static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
32208  {
32209         struct rtl8139_private *np = dev->priv;
32210         void *ioaddr = np->mmio_addr;
32211  
32212 +       spin_lock_irq(&np->lock);
32213         if (rtl_chip_info[np->chipset].flags & HasLWake) {
32214                 u8 cfg3 = RTL_R8 (Config3);
32215                 u8 cfg5 = RTL_R8 (Config5);
32216 @@ -2199,14 +2197,14 @@
32217                 if (cfg5 & Cfg5_BWF)
32218                         wol->wolopts |= WAKE_BCAST;
32219         }
32220 +       spin_unlock_irq(&np->lock);
32221  }
32222  
32223  
32224  /* Set the ethtool Wake-on-LAN settings.  Return 0 or -errno.  Assumes
32225     that wol points to kernel memory and other threads or interrupts
32226     aren't messing with the 8139.  */
32227 -static int netdev_set_wol (struct net_device *dev,
32228 -                          const struct ethtool_wolinfo *wol)
32229 +static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
32230  {
32231         struct rtl8139_private *np = dev->priv;
32232         void *ioaddr = np->mmio_addr;
32233 @@ -2220,6 +2218,7 @@
32234         if (wol->wolopts & ~support)
32235                 return -EINVAL;
32236  
32237 +       spin_lock_irq(&np->lock);
32238         cfg3 = RTL_R8 (Config3) & ~(Cfg3_LinkUp | Cfg3_Magic);
32239         if (wol->wolopts & WAKE_PHY)
32240                 cfg3 |= Cfg3_LinkUp;
32241 @@ -2240,213 +2239,120 @@
32242         if (wol->wolopts & WAKE_BCAST)
32243                 cfg5 |= Cfg5_BWF;
32244         RTL_W8 (Config5, cfg5); /* need not unlock via Cfg9346 */
32245 +       spin_unlock_irq(&np->lock);
32246  
32247         return 0;
32248  }
32249  
32250 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
32251 +static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
32252  {
32253         struct rtl8139_private *np = dev->priv;
32254 -       u32 ethcmd;
32255 -
32256 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
32257 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
32258 +       strcpy(info->driver, DRV_NAME);
32259 +       strcpy(info->version, DRV_VERSION);
32260 +       strcpy(info->bus_info, pci_name(np->pci_dev));
32261 +       info->regdump_len = np->regs_len;
32262 +}
32263  
32264 -       if (get_user(ethcmd, (u32 *)useraddr))
32265 -               return -EFAULT;
32266 +static int rtl8139_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
32267 +{
32268 +       struct rtl8139_private *np = dev->priv;
32269 +       spin_lock_irq(&np->lock);
32270 +       mii_ethtool_gset(&np->mii, cmd);
32271 +       spin_unlock_irq(&np->lock);
32272 +       return 0;
32273 +}
32274  
32275 -       switch (ethcmd) {
32276 -
32277 -       case ETHTOOL_GDRVINFO: {
32278 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
32279 -               strcpy (info.driver, DRV_NAME);
32280 -               strcpy (info.version, DRV_VERSION);
32281 -               strcpy (info.bus_info, pci_name(np->pci_dev));
32282 -               info.regdump_len = np->regs_len;
32283 -               if (copy_to_user (useraddr, &info, sizeof (info)))
32284 -                       return -EFAULT;
32285 -               return 0;
32286 -       }
32287 +static int rtl8139_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
32288 +{
32289 +       struct rtl8139_private *np = dev->priv;
32290 +       int rc;
32291 +       spin_lock_irq(&np->lock);
32292 +       rc = mii_ethtool_sset(&np->mii, cmd);
32293 +       spin_unlock_irq(&np->lock);
32294 +       return rc;
32295 +}
32296  
32297 -       /* get settings */
32298 -       case ETHTOOL_GSET: {
32299 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
32300 -               spin_lock_irq(&np->lock);
32301 -               mii_ethtool_gset(&np->mii, &ecmd);
32302 -               spin_unlock_irq(&np->lock);
32303 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
32304 -                       return -EFAULT;
32305 -               return 0;
32306 -       }
32307 -       /* set settings */
32308 -       case ETHTOOL_SSET: {
32309 -               int r;
32310 -               struct ethtool_cmd ecmd;
32311 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
32312 -                       return -EFAULT;
32313 -               spin_lock_irq(&np->lock);
32314 -               r = mii_ethtool_sset(&np->mii, &ecmd);
32315 -               spin_unlock_irq(&np->lock);
32316 -               return r;
32317 -       }
32318 -       /* restart autonegotiation */
32319 -       case ETHTOOL_NWAY_RST: {
32320 -               return mii_nway_restart(&np->mii);
32321 -       }
32322 -       /* get link status */
32323 -       case ETHTOOL_GLINK: {
32324 -               struct ethtool_value edata = {ETHTOOL_GLINK};
32325 -               edata.data = mii_link_ok(&np->mii);
32326 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
32327 -                       return -EFAULT;
32328 -               return 0;
32329 -       }
32330 +static int rtl8139_nway_reset(struct net_device *dev)
32331 +{
32332 +       struct rtl8139_private *np = dev->priv;
32333 +       return mii_nway_restart(&np->mii);
32334 +}
32335  
32336 -       /* get message-level */
32337 -       case ETHTOOL_GMSGLVL: {
32338 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
32339 -               edata.data = debug;
32340 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
32341 -                       return -EFAULT;
32342 -               return 0;
32343 -       }
32344 -       /* set message-level */
32345 -       case ETHTOOL_SMSGLVL: {
32346 -               struct ethtool_value edata;
32347 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
32348 -                       return -EFAULT;
32349 -               debug = edata.data;
32350 -               return 0;
32351 -       }
32352 +static u32 rtl8139_get_link(struct net_device *dev)
32353 +{
32354 +       struct rtl8139_private *np = dev->priv;
32355 +       return mii_link_ok(&np->mii);
32356 +}
32357  
32358 -       case ETHTOOL_GWOL:
32359 -               {
32360 -                       struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
32361 -                       spin_lock_irq (&np->lock);
32362 -                       netdev_get_wol (dev, &wol);
32363 -                       spin_unlock_irq (&np->lock);
32364 -                       if (copy_to_user (useraddr, &wol, sizeof (wol)))
32365 -                               return -EFAULT;
32366 -                       return 0;
32367 -               }
32368 +static u32 rtl8139_get_msglevel(struct net_device *dev)
32369 +{
32370 +       return debug;
32371 +}
32372  
32373 -       case ETHTOOL_SWOL:
32374 -               {
32375 -                       struct ethtool_wolinfo wol;
32376 -                       int rc;
32377 -                       if (copy_from_user (&wol, useraddr, sizeof (wol)))
32378 -                               return -EFAULT;
32379 -                       spin_lock_irq (&np->lock);
32380 -                       rc = netdev_set_wol (dev, &wol);
32381 -                       spin_unlock_irq (&np->lock);
32382 -                       return rc;
32383 -               }
32384 +static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
32385 +{
32386 +       debug = datum;
32387 +}
32388  
32389  /* TODO: we are too slack to do reg dumping for pio, for now */
32390 -#ifndef CONFIG_8139TOO_PIO
32391 -       /* NIC register dump */
32392 -       case ETHTOOL_GREGS: {
32393 -                struct ethtool_regs regs;
32394 -               unsigned int regs_len = np->regs_len;
32395 -                u8 *regbuf = kmalloc(regs_len, GFP_KERNEL);
32396 -                int rc;
32397 -
32398 -               if (!regbuf)
32399 -                       return -ENOMEM;
32400 -               memset(regbuf, 0, regs_len);
32401 -
32402 -                rc = copy_from_user(&regs, useraddr, sizeof(regs));
32403 -               if (rc) {
32404 -                       rc = -EFAULT;
32405 -                       goto err_out_gregs;
32406 -               }
32407 -                
32408 -                if (regs.len > regs_len)
32409 -                        regs.len = regs_len;
32410 -                if (regs.len < regs_len) {
32411 -                       rc = -EINVAL;
32412 -                       goto err_out_gregs;
32413 -               }
32414 -
32415 -                regs.version = RTL_REGS_VER;
32416 -                rc = copy_to_user(useraddr, &regs, sizeof(regs));
32417 -               if (rc) {
32418 -                       rc = -EFAULT;
32419 -                       goto err_out_gregs;
32420 -               }
32421 -
32422 -                useraddr += offsetof(struct ethtool_regs, data);
32423 -
32424 -                spin_lock_irq(&np->lock);
32425 -                memcpy_fromio(regbuf, np->mmio_addr, regs_len);
32426 -                spin_unlock_irq(&np->lock);
32427 -
32428 -                if (copy_to_user(useraddr, regbuf, regs_len))
32429 -                        rc = -EFAULT;
32430 -
32431 -err_out_gregs:
32432 -               kfree(regbuf);
32433 -               return rc;
32434 -       }
32435 -#endif /* CONFIG_8139TOO_PIO */
32436 -
32437 -       /* get string list(s) */
32438 -       case ETHTOOL_GSTRINGS: {
32439 -               struct ethtool_gstrings estr = { ETHTOOL_GSTRINGS };
32440 -
32441 -               if (copy_from_user(&estr, useraddr, sizeof(estr)))
32442 -                       return -EFAULT;
32443 -               if (estr.string_set != ETH_SS_STATS)
32444 -                       return -EINVAL;
32445 -
32446 -               estr.len = RTL_NUM_STATS;
32447 -               if (copy_to_user(useraddr, &estr, sizeof(estr)))
32448 -                       return -EFAULT;
32449 -               if (copy_to_user(useraddr + sizeof(estr),
32450 -                                &ethtool_stats_keys,
32451 -                                sizeof(ethtool_stats_keys)))
32452 -                       return -EFAULT;
32453 -               return 0;
32454 -       }
32455 +#ifdef CONFIG_8139TOO_PIO
32456 +#define rtl8139_get_regs_len   NULL
32457 +#define rtl8139_get_regs       NULL
32458 +#else
32459 +static int rtl8139_get_regs_len(struct net_device *dev)
32460 +{
32461 +       struct rtl8139_private *np = dev->priv;
32462 +       return np->regs_len;
32463 +}
32464  
32465 -       /* get NIC-specific statistics */
32466 -       case ETHTOOL_GSTATS: {
32467 -               struct ethtool_stats estats = { ETHTOOL_GSTATS };
32468 -               u64 *tmp_stats;
32469 -               const unsigned int sz = sizeof(u64) * RTL_NUM_STATS;
32470 -               int i;
32471 -
32472 -               estats.n_stats = RTL_NUM_STATS;
32473 -               if (copy_to_user(useraddr, &estats, sizeof(estats)))
32474 -                       return -EFAULT;
32475 -
32476 -               tmp_stats = kmalloc(sz, GFP_KERNEL);
32477 -               if (!tmp_stats)
32478 -                       return -ENOMEM;
32479 -               memset(tmp_stats, 0, sz);
32480 -
32481 -               i = 0;
32482 -               tmp_stats[i++] = np->xstats.early_rx;
32483 -               tmp_stats[i++] = np->xstats.tx_buf_mapped;
32484 -               tmp_stats[i++] = np->xstats.tx_timeouts;
32485 -               tmp_stats[i++] = np->xstats.rx_lost_in_ring;
32486 -               if (i != RTL_NUM_STATS)
32487 -                       BUG();
32488 +static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
32489 +{
32490 +       struct rtl8139_private *np = dev->priv;
32491  
32492 -               i = copy_to_user(useraddr + sizeof(estats), tmp_stats, sz);
32493 -               kfree(tmp_stats);
32494 +       regs->version = RTL_REGS_VER;
32495  
32496 -               if (i)
32497 -                       return -EFAULT;
32498 -               return 0;
32499 -       }
32500 -       default:
32501 -               break;
32502 -       }
32503 +       spin_lock_irq(&np->lock);
32504 +       memcpy_fromio(regbuf, np->mmio_addr, regs->len);
32505 +       spin_unlock_irq(&np->lock);
32506 +}
32507 +#endif /* CONFIG_8139TOO_MMIO */
32508  
32509 -       return -EOPNOTSUPP;
32510 +static int rtl8139_get_stats_count(struct net_device *dev)
32511 +{
32512 +       return RTL_NUM_STATS;
32513  }
32514  
32515 +static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
32516 +{
32517 +       struct rtl8139_private *np = dev->priv;
32518 +
32519 +       data[0] = np->xstats.early_rx;
32520 +       data[1] = np->xstats.tx_buf_mapped;
32521 +       data[2] = np->xstats.tx_timeouts;
32522 +       data[3] = np->xstats.rx_lost_in_ring;
32523 +}
32524 +
32525 +static void rtl8139_get_strings(struct net_device *dev, u32 stringset, u8 *data)
32526 +{
32527 +       memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
32528 +}
32529 +
32530 +static struct ethtool_ops rtl8139_ethtool_ops = {
32531 +       .get_drvinfo            = rtl8139_get_drvinfo,
32532 +       .get_settings           = rtl8139_get_settings,
32533 +       .set_settings           = rtl8139_set_settings,
32534 +       .get_regs_len           = rtl8139_get_regs_len,
32535 +       .get_regs               = rtl8139_get_regs,
32536 +       .nway_reset             = rtl8139_nway_reset,
32537 +       .get_link               = rtl8139_get_link,
32538 +       .get_msglevel           = rtl8139_get_msglevel,
32539 +       .set_msglevel           = rtl8139_set_msglevel,
32540 +       .get_wol                = rtl8139_get_wol,
32541 +       .set_wol                = rtl8139_set_wol,
32542 +       .get_strings            = rtl8139_get_strings,
32543 +       .get_stats_count        = rtl8139_get_stats_count,
32544 +       .get_ethtool_stats      = rtl8139_get_ethtool_stats,
32545 +};
32546  
32547  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
32548  {
32549 @@ -2457,14 +2363,9 @@
32550         if (!netif_running(dev))
32551                 return -EINVAL;
32552  
32553 -       if (cmd == SIOCETHTOOL)
32554 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32555 -
32556 -       else {
32557 -               spin_lock_irq(&np->lock);
32558 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
32559 -               spin_unlock_irq(&np->lock);
32560 -       }
32561 +       spin_lock_irq(&np->lock);
32562 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
32563 +       spin_unlock_irq(&np->lock);
32564  
32565         return rc;
32566  }
32567 diff -Nru a/drivers/net/8390.c b/drivers/net/8390.c
32568 --- a/drivers/net/8390.c        Sun Apr 20 21:26:41 2003
32569 +++ b/drivers/net/8390.c        Mon Sep  1 09:50:20 2003
32570 @@ -997,6 +997,11 @@
32571         spin_unlock_irqrestore(&ei_local->page_lock, flags);
32572  }      
32573  
32574 +static inline void ei_device_init(struct ei_device *ei_local)
32575 +{
32576 +       spin_lock_init(&ei_local->page_lock);
32577 +}
32578 +
32579  /**
32580   * ethdev_init - init rest of 8390 device struct
32581   * @dev: network device structure to init
32582 @@ -1012,14 +1017,11 @@
32583      
32584         if (dev->priv == NULL) 
32585         {
32586 -               struct ei_device *ei_local;
32587 -               
32588                 dev->priv = kmalloc(sizeof(struct ei_device), GFP_KERNEL);
32589                 if (dev->priv == NULL)
32590                         return -ENOMEM;
32591                 memset(dev->priv, 0, sizeof(struct ei_device));
32592 -               ei_local = (struct ei_device *)dev->priv;
32593 -               spin_lock_init(&ei_local->page_lock);
32594 +               ei_device_init(dev->priv);
32595         }
32596      
32597         dev->hard_start_xmit = &ei_start_xmit;
32598 @@ -1030,6 +1032,29 @@
32599          
32600         return 0;
32601  }
32602 +
32603 +/* wrapper to make alloc_netdev happy; probably should just cast... */
32604 +static void __ethdev_init(struct net_device *dev)
32605 +{
32606 +       ethdev_init(dev);
32607 +}
32608 +
32609 +/**
32610 + * alloc_ei_netdev - alloc_etherdev counterpart for 8390
32611 + *
32612 + * Allocate 8390-specific net_device.
32613 + */
32614 +struct net_device *alloc_ei_netdev(void)
32615 +{
32616 +       struct net_device *dev;
32617 +       
32618 +       dev = alloc_netdev(sizeof(struct ei_device), "eth%d", __ethdev_init);
32619 +       if (dev)
32620 +               ei_device_init(dev->priv);
32621 +
32622 +       return dev;
32623 +}
32624 +
32625  \f
32626  
32627  
32628 @@ -1133,6 +1158,7 @@
32629  EXPORT_SYMBOL(ei_tx_timeout);
32630  EXPORT_SYMBOL(ethdev_init);
32631  EXPORT_SYMBOL(NS8390_init);
32632 +EXPORT_SYMBOL(alloc_ei_netdev);
32633  
32634  #if defined(MODULE)
32635  
32636 diff -Nru a/drivers/net/8390.h b/drivers/net/8390.h
32637 --- a/drivers/net/8390.h        Sat Jun 28 10:57:01 2003
32638 +++ b/drivers/net/8390.h        Mon Sep  1 09:50:20 2003
32639 @@ -44,6 +44,7 @@
32640  extern int ei_open(struct net_device *dev);
32641  extern int ei_close(struct net_device *dev);
32642  extern irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs *regs);
32643 +extern struct net_device *alloc_ei_netdev(void);
32644  
32645  /* You have one of these per-board */
32646  struct ei_device {
32647 diff -Nru a/drivers/net/Kconfig b/drivers/net/Kconfig
32648 --- a/drivers/net/Kconfig       Mon Aug 18 20:59:59 2003
32649 +++ b/drivers/net/Kconfig       Tue Sep  2 15:05:18 2003
32650 @@ -132,8 +132,8 @@
32651           If you don't know what to use this for, you don't need it.
32652  
32653  config ETHERTAP
32654 -       tristate "Ethertap network tap (OBSOLETE)"
32655 -       depends on NETDEVICES && EXPERIMENTAL
32656 +       tristate "Ethertap network tap"
32657 +       depends on NETDEVICES && EXPERIMENTAL && NETLINK_DEV
32658         ---help---
32659           If you say Y here (and have said Y to "Kernel/User network link
32660           driver", above) and create a character special file /dev/tap0 with
32661 @@ -502,7 +502,7 @@
32662  
32663  config SGI_IOC3_ETH
32664         bool "SGI IOC3 Ethernet"
32665 -       depends on NET_ETHERNET && (IA64_SGI_SN1 || SGI_IP27)
32666 +       depends on NET_ETHERNET && SGI_IP27
32667         help
32668           If you have a network (Ethernet) card of this type, say Y and read
32669           the Ethernet-HOWTO, available from
32670 @@ -704,7 +704,7 @@
32671  
32672  config ELMC_II
32673         tristate "3c527 \"EtherLink/MC 32\" support (EXPERIMENTAL)"
32674 -       depends on NET_VENDOR_3COM && MCA && EXPERIMENTAL
32675 +       depends on NET_VENDOR_3COM && MCA && EXPERIMENTAL && BROKEN_ON_SMP
32676         help
32677           If you have a network (Ethernet) card of this type, say Y and read
32678           the Ethernet-HOWTO, available from
32679 @@ -882,7 +882,7 @@
32680  
32681  config NI5010
32682         tristate "NI5010 support (EXPERIMENTAL)"
32683 -       depends on NET_VENDOR_RACAL && ISA && EXPERIMENTAL
32684 +       depends on NET_VENDOR_RACAL && ISA && EXPERIMENTAL && BROKEN_ON_SMP
32685         ---help---
32686           If you have a network (Ethernet) card of this type, say Y and read
32687           the Ethernet-HOWTO, available from
32688 @@ -1221,7 +1221,7 @@
32689  
32690  config SKMC
32691         tristate "SKnet MCA support"
32692 -       depends on NET_ETHERNET && MCA
32693 +       depends on NET_ETHERNET && MCA && BROKEN
32694         ---help---
32695           These are Micro Channel Ethernet adapters. You need to say Y to "MCA
32696           support" in order to use this driver.  Supported cards are the SKnet
32697 @@ -2670,7 +2670,7 @@
32698  
32699  config IPHASE5526
32700         tristate "Interphase 5526 Tachyon chipset based adapter support"
32701 -       depends on NET_FC && SCSI && PCI
32702 +       depends on NET_FC && SCSI && PCI && BROKEN
32703         help
32704           Say Y here if you have a Fibre Channel adaptor of this kind.
32705  
32706 diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
32707 --- a/drivers/net/Space.c       Wed Jun 25 14:00:07 2003
32708 +++ b/drivers/net/Space.c       Tue Sep  2 12:19:07 2003
32709 @@ -89,7 +89,6 @@
32710  extern int bionet_probe(struct net_device *);
32711  extern int pamsnet_probe(struct net_device *);
32712  extern int cs89x0_probe(struct net_device *dev);
32713 -extern int ethertap_probe(struct net_device *dev);
32714  extern int hplance_probe(struct net_device *dev);
32715  extern int bagetlance_probe(struct net_device *);
32716  extern int mvme147lance_probe(struct net_device *dev);
32717 @@ -386,17 +385,6 @@
32718                 return 0;
32719         return -ENODEV;
32720  }
32721 -
32722 -#ifdef CONFIG_ETHERTAP
32723 -static struct net_device tap0_dev = {
32724 -       .name           = "tap0",
32725 -       .base_addr      = NETLINK_TAPBASE,
32726 -       .next           = NEXT_DEV,
32727 -       .init           = ethertap_probe,
32728 -};
32729 -#undef NEXT_DEV
32730 -#define NEXT_DEV       (&tap0_dev)
32731 -#endif
32732  
32733  #ifdef CONFIG_SDLA
32734  extern int sdla_init(struct net_device *);
32735 diff -Nru a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
32736 --- a/drivers/net/arcnet/arcnet.c       Mon Jul 21 05:31:03 2003
32737 +++ b/drivers/net/arcnet/arcnet.c       Sun Aug 31 16:14:40 2003
32738 @@ -135,7 +135,7 @@
32739                 arc_proto_map[count] = arc_proto_default;
32740  
32741         BUGLVL(D_DURING)
32742 -           printk("arcnet: struct sizes: %d %d %d %d %d\n",
32743 +           printk("arcnet: struct sizes: %Zd %Zd %Zd %Zd %Zd\n",
32744                  sizeof(struct arc_hardware), sizeof(struct arc_rfc1201),
32745                 sizeof(struct arc_rfc1051), sizeof(struct arc_eth_encap),
32746                    sizeof(struct archdr));
32747 diff -Nru a/drivers/net/arm/ether00.c b/drivers/net/arm/ether00.c
32748 --- a/drivers/net/arm/ether00.c Tue Aug 19 20:53:15 2003
32749 +++ b/drivers/net/arm/ether00.c Sun Aug 31 16:14:08 2003
32750 @@ -991,9 +991,9 @@
32751  }
32752  
32753  static struct pld_hotswap_ops ether00_pldhs_ops={
32754 -       name: ETHER00_NAME,
32755 -       add_device: ether00_add_device,
32756 -       remove_devices: ether00_remove_devices,
32757 +       .name = ETHER00_NAME,
32758 +       .add_device = ether00_add_device,
32759 +       .remove_devices = ether00_remove_devices,
32760  };
32761  
32762  
32763 diff -Nru a/drivers/net/dummy.c b/drivers/net/dummy.c
32764 --- a/drivers/net/dummy.c       Tue Aug 19 20:53:15 2003
32765 +++ b/drivers/net/dummy.c       Sun Aug 24 04:54:46 2003
32766 @@ -28,8 +28,6 @@
32767                         Alan Cox, 30th May 1994
32768  */
32769  
32770 -/* To have statistics (just packets sent) define this */
32771 -
32772  #include <linux/config.h>
32773  #include <linux/module.h>
32774  #include <linux/kernel.h>
32775 diff -Nru a/drivers/net/epic100.c b/drivers/net/epic100.c
32776 --- a/drivers/net/epic100.c     Tue Aug 19 20:53:15 2003
32777 +++ b/drivers/net/epic100.c     Mon Sep  1 14:05:11 2003
32778 @@ -362,6 +362,7 @@
32779  static int epic_rx(struct net_device *dev);
32780  static irqreturn_t epic_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
32781  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
32782 +static struct ethtool_ops netdev_ethtool_ops;
32783  static int epic_close(struct net_device *dev);
32784  static struct net_device_stats *epic_get_stats(struct net_device *dev);
32785  static void set_rx_mode(struct net_device *dev);
32786 @@ -539,6 +540,7 @@
32787         dev->get_stats = &epic_get_stats;
32788         dev->set_multicast_list = &set_rx_mode;
32789         dev->do_ioctl = &netdev_ioctl;
32790 +       dev->ethtool_ops = &netdev_ethtool_ops;
32791         dev->watchdog_timeo = TX_TIMEOUT;
32792         dev->tx_timeout = &epic_tx_timeout;
32793  
32794 @@ -1361,82 +1363,73 @@
32795         return;
32796  }
32797  
32798 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
32799 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
32800  {
32801         struct epic_private *np = dev->priv;
32802 -       u32 ethcmd;
32803  
32804 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
32805 -               return -EFAULT;
32806 +       strcpy (info->driver, DRV_NAME);
32807 +       strcpy (info->version, DRV_VERSION);
32808 +       strcpy (info->bus_info, pci_name(np->pci_dev));
32809 +}
32810  
32811 -       switch (ethcmd) {
32812 -       case ETHTOOL_GDRVINFO: {
32813 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
32814 -               strcpy (info.driver, DRV_NAME);
32815 -               strcpy (info.version, DRV_VERSION);
32816 -               strcpy (info.bus_info, pci_name(np->pci_dev));
32817 -               if (copy_to_user (useraddr, &info, sizeof (info)))
32818 -                       return -EFAULT;
32819 -               return 0;
32820 -       }
32821 -
32822 -       /* get settings */
32823 -       case ETHTOOL_GSET: {
32824 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
32825 -               spin_lock_irq(&np->lock);
32826 -               mii_ethtool_gset(&np->mii, &ecmd);
32827 -               spin_unlock_irq(&np->lock);
32828 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
32829 -                       return -EFAULT;
32830 -               return 0;
32831 -       }
32832 -       /* set settings */
32833 -       case ETHTOOL_SSET: {
32834 -               int r;
32835 -               struct ethtool_cmd ecmd;
32836 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
32837 -                       return -EFAULT;
32838 -               spin_lock_irq(&np->lock);
32839 -               r = mii_ethtool_sset(&np->mii, &ecmd);
32840 -               spin_unlock_irq(&np->lock);
32841 -               return r;
32842 -       }
32843 -       /* restart autonegotiation */
32844 -       case ETHTOOL_NWAY_RST: {
32845 -               return mii_nway_restart(&np->mii);
32846 -       }
32847 -       /* get link status */
32848 -       case ETHTOOL_GLINK: {
32849 -               struct ethtool_value edata = {ETHTOOL_GLINK};
32850 -               edata.data = mii_link_ok(&np->mii);
32851 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
32852 -                       return -EFAULT;
32853 -               return 0;
32854 -       }
32855 -
32856 -       /* get message-level */
32857 -       case ETHTOOL_GMSGLVL: {
32858 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
32859 -               edata.data = debug;
32860 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
32861 -                       return -EFAULT;
32862 -               return 0;
32863 -       }
32864 -       /* set message-level */
32865 -       case ETHTOOL_SMSGLVL: {
32866 -               struct ethtool_value edata;
32867 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
32868 -                       return -EFAULT;
32869 -               debug = edata.data;
32870 -               return 0;
32871 -       }
32872 -       default:
32873 -               break;
32874 -       }
32875 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
32876 +{
32877 +       struct epic_private *np = dev->priv;
32878 +       int rc;
32879 +
32880 +       spin_lock_irq(&np->lock);
32881 +       rc = mii_ethtool_gset(&np->mii, cmd);
32882 +       spin_unlock_irq(&np->lock);
32883 +
32884 +       return rc;
32885 +}
32886 +
32887 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
32888 +{
32889 +       struct epic_private *np = dev->priv;
32890 +       int rc;
32891 +
32892 +       spin_lock_irq(&np->lock);
32893 +       rc = mii_ethtool_sset(&np->mii, cmd);
32894 +       spin_unlock_irq(&np->lock);
32895 +
32896 +       return rc;
32897 +}
32898 +
32899 +static int netdev_nway_reset(struct net_device *dev)
32900 +{
32901 +       struct epic_private *np = dev->priv;
32902 +       return mii_nway_restart(&np->mii);
32903 +}
32904  
32905 -       return -EOPNOTSUPP;
32906 +static u32 netdev_get_link(struct net_device *dev)
32907 +{
32908 +       struct epic_private *np = dev->priv;
32909 +       return mii_link_ok(&np->mii);
32910  }
32911  
32912 +static u32 netdev_get_msglevel(struct net_device *dev)
32913 +{
32914 +       return debug;
32915 +}
32916 +
32917 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
32918 +{
32919 +       debug = value;
32920 +}
32921 +
32922 +static struct ethtool_ops netdev_ethtool_ops = {
32923 +       .get_drvinfo            = netdev_get_drvinfo,
32924 +       .get_settings           = netdev_get_settings,
32925 +       .set_settings           = netdev_set_settings,
32926 +       .nway_reset             = netdev_nway_reset,
32927 +       .get_link               = netdev_get_link,
32928 +       .get_msglevel           = netdev_get_msglevel,
32929 +       .set_msglevel           = netdev_set_msglevel,
32930 +       .get_sg                 = ethtool_op_get_sg,
32931 +       .get_tx_csum            = ethtool_op_get_tx_csum,
32932 +};
32933 +
32934  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
32935  {
32936         struct epic_private *np = dev->priv;
32937 @@ -1450,16 +1443,10 @@
32938                 outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL);
32939         }
32940  
32941 -       /* ethtool commands */
32942 -       if (cmd == SIOCETHTOOL)
32943 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32944 -
32945 -       /* all other ioctls (the SIOC[GS]MIIxxx ioctls) */
32946 -       else {
32947 -               spin_lock_irq(&np->lock);
32948 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
32949 -               spin_unlock_irq(&np->lock);
32950 -       }
32951 +       /* all non-ethtool ioctls (the SIOC[GS]MIIxxx ioctls) */
32952 +       spin_lock_irq(&np->lock);
32953 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
32954 +       spin_unlock_irq(&np->lock);
32955  
32956         /* power-down, if interface is down */
32957         if (! netif_running(dev)) {
32958 diff -Nru a/drivers/net/eth16i.c b/drivers/net/eth16i.c
32959 --- a/drivers/net/eth16i.c      Sun Apr 27 20:36:19 2003
32960 +++ b/drivers/net/eth16i.c      Sun Aug 31 06:34:16 2003
32961 @@ -1053,7 +1053,7 @@
32962         int ioaddr = dev->base_addr;
32963         int status = 0;
32964         ushort length = skb->len;
32965 -       unsigned char *buf = skb->data;
32966 +       unsigned char *buf;
32967         unsigned long flags;
32968  
32969         if (length < ETH_ZLEN) {
32970 @@ -1062,6 +1062,7 @@
32971                         return 0;
32972                 length = ETH_ZLEN;
32973         }
32974 +       buf = skb->data;
32975  
32976         netif_stop_queue(dev);
32977                 
32978 diff -Nru a/drivers/net/ethertap.c b/drivers/net/ethertap.c
32979 --- a/drivers/net/ethertap.c    Sat Jun  7 14:14:59 2003
32980 +++ b/drivers/net/ethertap.c    Tue Sep  2 13:28:19 2003
32981 @@ -33,7 +33,6 @@
32982   *     Index to functions.
32983   */
32984  
32985 -int        ethertap_probe(struct net_device *dev);
32986  static int  ethertap_open(struct net_device *dev);
32987  static int  ethertap_start_xmit(struct sk_buff *skb, struct net_device *dev);
32988  static int  ethertap_close(struct net_device *dev);
32989 @@ -45,7 +44,11 @@
32990  
32991  static int ethertap_debug;
32992  
32993 -static struct net_device *tap_map[32]; /* Returns the tap device for a given netlink */
32994 +static int max_taps = 1;
32995 +MODULE_PARM(max_taps, "i");
32996 +MODULE_PARM_DESC(max_taps,"Max number of ethernet tap devices");
32997 +
32998 +static struct net_device **tap_map;    /* Returns the tap device for a given netlink */
32999  
33000  /*
33001   *     Board-specific info in dev->priv.
33002 @@ -64,25 +67,29 @@
33003   *     To call this a probe is a bit misleading, however for real
33004   *     hardware it would have to check what was present.
33005   */
33006
33007 -int __init ethertap_probe(struct net_device *dev)
33008 +static int  __init ethertap_probe(int unit)
33009  {
33010 +       struct net_device *dev;
33011 +       int err = -ENOMEM;
33012 +
33013 +       dev = alloc_netdev(sizeof(struct net_local), "tap%d",
33014 +                          ether_setup);
33015 +
33016 +       if (!dev)
33017 +               goto out;
33018 +
33019         SET_MODULE_OWNER(dev);
33020  
33021 +       sprintf(dev->name, "tap%d", unit);
33022 +       dev->base_addr = unit + NETLINK_TAPBASE;
33023 +
33024 +       netdev_boot_setup_check(dev);
33025 +
33026         memcpy(dev->dev_addr, "\xFE\xFD\x00\x00\x00\x00", 6);
33027         if (dev->mem_start & 0xf)
33028                 ethertap_debug = dev->mem_start & 0x7;
33029  
33030         /*
33031 -        *      Initialize the device structure.
33032 -        */
33033 -
33034 -       dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
33035 -       if (dev->priv == NULL)
33036 -               return -ENOMEM;
33037 -       memset(dev->priv, 0, sizeof(struct net_local));
33038 -
33039 -       /*
33040          *      The tap specific entries in the device structure.
33041          */
33042  
33043 @@ -94,17 +101,19 @@
33044         dev->set_multicast_list = set_multicast_list;
33045  #endif
33046  
33047 -       /*
33048 -        *      Setup the generic properties
33049 -        */
33050 -
33051 -       ether_setup(dev);
33052 -
33053         dev->tx_queue_len = 0;
33054         dev->flags|=IFF_NOARP;
33055 -       tap_map[dev->base_addr]=dev;
33056  
33057 +       err = register_netdev(dev);
33058 +       if (err)
33059 +               goto out_free;
33060 +
33061 +       tap_map[unit]=dev;
33062         return 0;
33063 +out_free:
33064 +       free_netdev(dev);
33065 +out:
33066 +       return err;
33067  }
33068  
33069  /*
33070 @@ -116,11 +125,12 @@
33071         struct net_local *lp = (struct net_local*)dev->priv;
33072  
33073         if (ethertap_debug > 2)
33074 -               printk("%s: Doing ethertap_open()...", dev->name);
33075 +               printk(KERN_DEBUG "%s: Doing ethertap_open()...", dev->name);
33076  
33077         lp->nl = netlink_kernel_create(dev->base_addr, ethertap_rx);
33078         if (lp->nl == NULL)
33079                 return -ENOBUFS;
33080 +
33081         netif_start_queue(dev);
33082         return 0;
33083  }
33084 @@ -302,7 +312,7 @@
33085         }
33086  
33087         if (ethertap_debug > 3)
33088 -               printk("%s: ethertap_rx()\n", dev->name);
33089 +               printk(KERN_DEBUG "%s: ethertap_rx()\n", dev->name);
33090  
33091         while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL)
33092                 ethertap_rx_skb(skb, dev);
33093 @@ -314,7 +324,7 @@
33094         struct sock *sk = lp->nl;
33095  
33096         if (ethertap_debug > 2)
33097 -               printk("%s: Shutting down.\n", dev->name);
33098 +               printk(KERN_DEBUG "%s: Shutting down.\n", dev->name);
33099  
33100         netif_stop_queue(dev);
33101  
33102 @@ -332,45 +342,49 @@
33103         return &lp->stats;
33104  }
33105  
33106 -#ifdef MODULE
33107 -
33108 -static int unit;
33109 -MODULE_PARM(unit,"i");
33110 -MODULE_PARM_DESC(unit,"Ethertap device number");
33111  
33112 -static struct net_device dev_ethertap =
33113 +int __init ethertap_init(void)
33114  {
33115 -       .name           =       " ",
33116 -       .init           =        ethertap_probe
33117 -};
33118 +       int i, err = 0;
33119  
33120 -int init_module(void)
33121 -{
33122 -       dev_ethertap.base_addr=unit+NETLINK_TAPBASE;
33123 -       sprintf(dev_ethertap.name,"tap%d",unit);
33124 -       if (dev_get(dev_ethertap.name))
33125 -       {
33126 -               printk(KERN_INFO "%s already loaded.\n", dev_ethertap.name);
33127 -               return -EBUSY;
33128 -       }
33129 -       if (register_netdev(&dev_ethertap) != 0)
33130 -               return -EIO;
33131 -       return 0;
33132 -}
33133 -
33134 -void cleanup_module(void)
33135 -{
33136 -       tap_map[dev_ethertap.base_addr]=NULL;
33137 -       unregister_netdev(&dev_ethertap);
33138 +       /* netlink can only hande 16 entries unless modified */
33139 +       if (max_taps > MAX_LINKS - NETLINK_TAPBASE)
33140 +               return -E2BIG;
33141  
33142 -       /*
33143 -        *      Free up the private structure.
33144 -        */
33145 +       tap_map = kmalloc(sizeof(struct net_device *)*max_taps, GFP_KERNEL);
33146 +       if (!tap_map)
33147 +               return -ENOMEM;
33148  
33149 -       kfree(dev_ethertap.priv);
33150 -       dev_ethertap.priv = NULL;       /* gets re-allocated by ethertap_probe */
33151 +       for (i = 0; i < max_taps; i++) {
33152 +               err = ethertap_probe(i);
33153 +               if (err) {
33154 +                       while (--i > 0) {
33155 +                               unregister_netdev(tap_map[i]);
33156 +                               free_netdev(tap_map[i]);
33157 +                       }
33158 +                       break;
33159 +               }
33160 +       }
33161 +       if (err)
33162 +               kfree(tap_map);
33163 +       return err;
33164 +}
33165 +module_init(ethertap_init);
33166 +
33167 +void __exit ethertap_cleanup(void)
33168 +{
33169 +       int i;
33170 +
33171 +       for (i = 0; i < max_taps; i++) {
33172 +               struct net_device *dev = tap_map[i];
33173 +               if (dev) {
33174 +                       tap_map[i] = NULL;
33175 +                       unregister_netdev(dev);
33176 +                       free_netdev(dev);
33177 +               }
33178 +       }
33179 +       kfree(tap_map);
33180  }
33181 +module_exit(ethertap_cleanup);
33182  
33183 -#endif /* MODULE */
33184  MODULE_LICENSE("GPL");
33185 -
33186 diff -Nru a/drivers/net/fealnx.c b/drivers/net/fealnx.c
33187 --- a/drivers/net/fealnx.c      Tue Aug 19 20:53:16 2003
33188 +++ b/drivers/net/fealnx.c      Mon Sep  1 14:18:01 2003
33189 @@ -443,6 +443,7 @@
33190  static void set_rx_mode(struct net_device *dev);
33191  static struct net_device_stats *get_stats(struct net_device *dev);
33192  static int mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
33193 +static struct ethtool_ops netdev_ethtool_ops;
33194  static int netdev_close(struct net_device *dev);
33195  static void reset_rx_descriptors(struct net_device *dev);
33196  
33197 @@ -667,6 +668,7 @@
33198         dev->get_stats = &get_stats;
33199         dev->set_multicast_list = &set_rx_mode;
33200         dev->do_ioctl = &mii_ioctl;
33201 +       dev->ethtool_ops = &netdev_ethtool_ops;
33202         dev->tx_timeout = tx_timeout;
33203         dev->watchdog_timeo = TX_TIMEOUT;
33204         
33205 @@ -938,7 +940,7 @@
33206  // 89/9/1 modify,
33207  //   np->bcrvalue=0x38;
33208         np->bcrvalue = 0x10;
33209 -       np->cralue = 0xe00;     /* rx 128 burst length */
33210 +       np->crvalue = 0xe00;    /* rx 128 burst length */
33211  #warning Processor architecture undefined!
33212  #endif
33213  // 89/12/29 add,
33214 @@ -1760,82 +1762,72 @@
33215         writel(np->crvalue, ioaddr + TCRRCR);
33216  }
33217  
33218 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
33219 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
33220  {
33221         struct netdev_private *np = dev->priv;
33222 -       u32 ethcmd;
33223  
33224 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
33225 -               return -EFAULT;
33226 +       strcpy (info->driver, DRV_NAME);
33227 +       strcpy (info->version, DRV_VERSION);
33228 +       strcpy (info->bus_info, pci_name(np->pci_dev));
33229 +}
33230  
33231 -       switch (ethcmd) {
33232 -       case ETHTOOL_GDRVINFO: {
33233 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
33234 -               strcpy (info.driver, DRV_NAME);
33235 -               strcpy (info.version, DRV_VERSION);
33236 -               strcpy (info.bus_info, pci_name(np->pci_dev));
33237 -               if (copy_to_user (useraddr, &info, sizeof (info)))
33238 -                       return -EFAULT;
33239 -               return 0;
33240 -       }
33241 -
33242 -       /* get settings */
33243 -       case ETHTOOL_GSET: {
33244 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
33245 -               spin_lock_irq(&np->lock);
33246 -               mii_ethtool_gset(&np->mii, &ecmd);
33247 -               spin_unlock_irq(&np->lock);
33248 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
33249 -                       return -EFAULT;
33250 -               return 0;
33251 -       }
33252 -       /* set settings */
33253 -       case ETHTOOL_SSET: {
33254 -               int r;
33255 -               struct ethtool_cmd ecmd;
33256 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
33257 -                       return -EFAULT;
33258 -               spin_lock_irq(&np->lock);
33259 -               r = mii_ethtool_sset(&np->mii, &ecmd);
33260 -               spin_unlock_irq(&np->lock);
33261 -               return r;
33262 -       }
33263 -       /* restart autonegotiation */
33264 -       case ETHTOOL_NWAY_RST: {
33265 -               return mii_nway_restart(&np->mii);
33266 -       }
33267 -       /* get link status */
33268 -       case ETHTOOL_GLINK: {
33269 -               struct ethtool_value edata = {ETHTOOL_GLINK};
33270 -               edata.data = mii_link_ok(&np->mii);
33271 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
33272 -                       return -EFAULT;
33273 -               return 0;
33274 -       }
33275 -
33276 -       /* get message-level */
33277 -       case ETHTOOL_GMSGLVL: {
33278 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
33279 -               edata.data = debug;
33280 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
33281 -                       return -EFAULT;
33282 -               return 0;
33283 -       }
33284 -       /* set message-level */
33285 -       case ETHTOOL_SMSGLVL: {
33286 -               struct ethtool_value edata;
33287 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
33288 -                       return -EFAULT;
33289 -               debug = edata.data;
33290 -               return 0;
33291 -       }
33292 -       default:
33293 -               break;
33294 -       }
33295 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
33296 +{
33297 +       struct netdev_private *np = dev->priv;
33298 +       int rc;
33299 +
33300 +       spin_lock_irq(&np->lock);
33301 +       rc = mii_ethtool_gset(&np->mii, cmd);
33302 +       spin_unlock_irq(&np->lock);
33303 +
33304 +       return rc;
33305 +}
33306 +
33307 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
33308 +{
33309 +       struct netdev_private *np = dev->priv;
33310 +       int rc;
33311 +
33312 +       spin_lock_irq(&np->lock);
33313 +       rc = mii_ethtool_sset(&np->mii, cmd);
33314 +       spin_unlock_irq(&np->lock);
33315 +
33316 +       return rc;
33317 +}
33318 +
33319 +static int netdev_nway_reset(struct net_device *dev)
33320 +{
33321 +       struct netdev_private *np = dev->priv;
33322 +       return mii_nway_restart(&np->mii);
33323 +}
33324 +
33325 +static u32 netdev_get_link(struct net_device *dev)
33326 +{
33327 +       struct netdev_private *np = dev->priv;
33328 +       return mii_link_ok(&np->mii);
33329 +}
33330 +
33331 +static u32 netdev_get_msglevel(struct net_device *dev)
33332 +{
33333 +       return debug;
33334 +}
33335  
33336 -       return -EOPNOTSUPP;
33337 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
33338 +{
33339 +       debug = value;
33340  }
33341  
33342 +static struct ethtool_ops netdev_ethtool_ops = {
33343 +       .get_drvinfo            = netdev_get_drvinfo,
33344 +       .get_settings           = netdev_get_settings,
33345 +       .set_settings           = netdev_set_settings,
33346 +       .nway_reset             = netdev_nway_reset,
33347 +       .get_link               = netdev_get_link,
33348 +       .get_msglevel           = netdev_get_msglevel,
33349 +       .set_msglevel           = netdev_set_msglevel,
33350 +       .get_sg                 = ethtool_op_get_sg,
33351 +       .get_tx_csum            = ethtool_op_get_tx_csum,
33352 +};
33353  
33354  static int mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
33355  {
33356 @@ -1846,14 +1838,9 @@
33357         if (!netif_running(dev))
33358                 return -EINVAL;
33359  
33360 -       if (cmd == SIOCETHTOOL)
33361 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
33362 -
33363 -       else {
33364 -               spin_lock_irq(&np->lock);
33365 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
33366 -               spin_unlock_irq(&np->lock);
33367 -       }
33368 +       spin_lock_irq(&np->lock);
33369 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
33370 +       spin_unlock_irq(&np->lock);
33371  
33372         return rc;
33373  }
33374 diff -Nru a/drivers/net/fmv18x.c b/drivers/net/fmv18x.c
33375 --- a/drivers/net/fmv18x.c      Sun May 11 19:48:01 2003
33376 +++ b/drivers/net/fmv18x.c      Sun Aug 31 06:34:16 2003
33377 @@ -367,7 +367,7 @@
33378         struct net_local *lp = dev->priv;
33379         int ioaddr = dev->base_addr;
33380         short length = skb->len;
33381 -       unsigned char *buf = skb->data;
33382 +       unsigned char *buf;
33383         unsigned long flags;
33384  
33385         /* Block a transmit from overlapping.  */
33386 @@ -385,6 +385,7 @@
33387                         return 0;
33388                 length = ETH_ZLEN;
33389         }
33390 +       buf = skb->data;
33391         
33392         if (net_debug > 4)
33393                 printk("%s: Transmitting a packet of length %lu.\n", dev->name,
33394 diff -Nru a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
33395 --- a/drivers/net/hamradio/Kconfig      Sun Apr 20 12:56:51 2003
33396 +++ b/drivers/net/hamradio/Kconfig      Mon Aug 25 05:52:13 2003
33397 @@ -1,6 +1,6 @@
33398  config MKISS
33399         tristate "Serial port KISS driver"
33400 -       depends on AX25
33401 +       depends on AX25 && BROKEN_ON_SMP
33402         ---help---
33403           KISS is a protocol used for the exchange of data between a computer
33404           and a Terminal Node Controller (a small embedded system commonly
33405 @@ -19,7 +19,7 @@
33406  
33407  config 6PACK
33408         tristate "Serial port 6PACK driver"
33409 -       depends on AX25
33410 +       depends on AX25 && BROKEN_ON_SMP
33411         ---help---
33412           6pack is a transmission protocol for the data exchange between your
33413           PC and your TNC (the Terminal Node Controller acts as a kind of
33414 @@ -49,7 +49,7 @@
33415  
33416  config DMASCC
33417         tristate "High-speed (DMA) SCC driver for AX.25"
33418 -       depends on ISA && AX25
33419 +       depends on ISA && AX25 && BROKEN_ON_SMP
33420         ---help---
33421           This is a driver for high-speed SCC boards, i.e. those supporting
33422           DMA on one port. You usually use those boards to connect your
33423 diff -Nru a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
33424 --- a/drivers/net/hamradio/bpqether.c   Tue Aug 19 20:58:55 2003
33425 +++ b/drivers/net/hamradio/bpqether.c   Wed Aug 27 23:48:03 2003
33426 @@ -605,6 +605,7 @@
33427  
33428         printk(banner);
33429  
33430 +#ifdef CONFIG_PROC_FS
33431         if (!proc_net_fops_create("bpqether", S_IRUGO, &bpq_info_fops)) {
33432                 printk(KERN_ERR
33433                         "bpq: cannot create /proc/net/bpqether entry.\n");
33434 @@ -612,6 +613,7 @@
33435                 dev_remove_pack(&bpq_packet_type);
33436                 return -ENOENT;
33437         }
33438 +#endif  /* CONFIG_PROC_FS */
33439  
33440         rtnl_lock();
33441         for (dev = dev_base; dev != NULL; dev = dev->next) {
33442 diff -Nru a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
33443 --- a/drivers/net/hamradio/yam.c        Tue Aug 19 20:53:16 2003
33444 +++ b/drivers/net/hamradio/yam.c        Thu Aug 28 01:23:35 2003
33445 @@ -807,7 +807,7 @@
33446         seq_printf(seq, "  RxInt    %u\n", yp->nb_rxint);
33447         seq_printf(seq, "  RxOver   %lu\n", yp->stats.rx_fifo_errors);
33448         seq_printf(seq, "\n");
33449 -
33450 +       return 0;
33451  }
33452  
33453  static struct seq_operations yam_seqops = {
33454 diff -Nru a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
33455 --- a/drivers/net/irda/Kconfig  Tue Aug 19 21:06:58 2003
33456 +++ b/drivers/net/irda/Kconfig  Mon Aug 25 05:53:24 2003
33457 @@ -256,7 +256,7 @@
33458  
33459  config TOSHIBA_OLD
33460         tristate "Toshiba Type-O IR Port (old driver)"
33461 -       depends on IRDA
33462 +       depends on IRDA && BROKEN_ON_SMP
33463         help
33464           Say Y here if you want to build support for the Toshiba Type-O IR
33465           chipset.  This chipset is used by the Toshiba Libretto 100CT, and
33466 @@ -319,7 +319,7 @@
33467  
33468  config VLSI_FIR
33469         tristate "VLSI 82C147 SIR/MIR/FIR (EXPERIMENTAL)"
33470 -       depends on EXPERIMENTAL && IRDA
33471 +       depends on EXPERIMENTAL && IRDA && PCI
33472         help
33473           Say Y here if you want to build support for the VLSI 82C147
33474           PCI-IrDA Controller. This controller is used by the HP OmniBook 800
33475 diff -Nru a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
33476 --- a/drivers/net/irda/via-ircc.c       Fri Aug  8 18:15:54 2003
33477 +++ b/drivers/net/irda/via-ircc.c       Sun Aug 31 16:14:08 2003
33478 @@ -134,10 +134,10 @@
33479  
33480  
33481  static struct pci_driver via_driver = {
33482 -       name:           VIA_MODULE_NAME,
33483 -       id_table:       via_pci_tbl,
33484 -       probe:          via_init_one,
33485 -       remove:         via_remove_one,
33486 +       .name           = VIA_MODULE_NAME,
33487 +       .id_table       = via_pci_tbl,
33488 +       .probe          = via_init_one,
33489 +       .remove         = via_remove_one,
33490  };
33491  
33492  
33493 diff -Nru a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
33494 --- a/drivers/net/irda/vlsi_ir.c        Wed Aug 20 15:31:21 2003
33495 +++ b/drivers/net/irda/vlsi_ir.c        Sun Aug 24 04:45:26 2003
33496 @@ -21,18 +21,20 @@
33497   *
33498   ********************************************************************/
33499  
33500 +#include <linux/config.h>
33501  #include <linux/module.h>
33502   
33503 -MODULE_DESCRIPTION("IrDA SIR/MIR/FIR driver for VLSI 82C147");
33504 -MODULE_AUTHOR("Martin Diehl <info@mdiehl.de>");
33505 -MODULE_LICENSE("GPL");
33506 +#define DRIVER_NAME            "vlsi_ir"
33507 +#define DRIVER_VERSION         "v0.5"
33508 +#define DRIVER_DESCRIPTION     "IrDA SIR/MIR/FIR driver for VLSI 82C147"
33509 +#define DRIVER_AUTHOR          "Martin Diehl <info@mdiehl.de>"
33510  
33511 -#define DRIVER_NAME "vlsi_ir"
33512 -#define DRIVER_VERSION "v0.4a"
33513 +MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
33514 +MODULE_AUTHOR(DRIVER_AUTHOR);
33515 +MODULE_LICENSE("GPL");
33516  
33517  /********************************************************/
33518  
33519 -#include <linux/config.h>
33520  #include <linux/kernel.h>
33521  #include <linux/init.h>
33522  #include <linux/pci.h>
33523 @@ -44,10 +46,12 @@
33524  #include <linux/proc_fs.h>
33525  #include <linux/smp_lock.h>
33526  #include <asm/uaccess.h>
33527 +#include <asm/byteorder.h>
33528  
33529  #include <net/irda/irda.h>
33530  #include <net/irda/irda_device.h>
33531  #include <net/irda/wrapper.h>
33532 +#include <net/irda/crc.h>
33533  
33534  #include <net/irda/vlsi_ir.h>
33535  
33536 @@ -55,14 +59,16 @@
33537  
33538  static /* const */ char drivername[] = DRIVER_NAME;
33539  
33540 -#define PCI_CLASS_WIRELESS_IRDA 0x0d00
33541 -
33542 -static struct pci_device_id vlsi_irda_table [] = { {
33543 -
33544 -       .class =        PCI_CLASS_WIRELESS_IRDA << 8,
33545 -       .vendor =       PCI_VENDOR_ID_VLSI,
33546 -       .device =       PCI_DEVICE_ID_VLSI_82C147,
33547 -       }, { /* all zeroes */ }
33548 +static struct pci_device_id vlsi_irda_table [] = {
33549 +       {
33550 +               .class =        PCI_CLASS_WIRELESS_IRDA << 8,
33551 +               .class_mask =   PCI_CLASS_SUBCLASS_MASK << 8, 
33552 +               .vendor =       PCI_VENDOR_ID_VLSI,
33553 +               .device =       PCI_DEVICE_ID_VLSI_82C147,
33554 +               .subvendor =    PCI_ANY_ID,
33555 +               .subdevice =    PCI_ANY_ID,
33556 +       },
33557 +       { /* all zeroes */ }
33558  };
33559  
33560  MODULE_DEVICE_TABLE(pci, vlsi_irda_table);
33561 @@ -114,7 +120,7 @@
33562  
33563  MODULE_PARM(qos_mtt_bits, "i");
33564  MODULE_PARM_DESC(qos_mtt_bits, "IrLAP bitfield representing min-turn-time");
33565 -static int qos_mtt_bits = 0x04;                /* default is 1 ms */
33566 +static int qos_mtt_bits = 0x07;                /* default is 1 ms or more */
33567  
33568  /********************************************************/
33569  
33570 @@ -164,7 +170,7 @@
33571                 return 0;
33572  
33573         out += sprintf(out, "\n%s (vid/did: %04x/%04x)\n",
33574 -                       pci_name(pdev), (int)pdev->vendor, (int)pdev->device);
33575 +                       PCIDEV_NAME(pdev), (int)pdev->vendor, (int)pdev->device);
33576         out += sprintf(out, "pci-power-state: %u\n", (unsigned) pdev->current_state);
33577         out += sprintf(out, "resources: irq=%u / io=0x%04x / dma_mask=0x%016Lx\n",
33578                         pdev->irq, (unsigned)pci_resource_start(pdev, 0), (u64)pdev->dma_mask);
33579 @@ -198,13 +204,13 @@
33580  
33581         out += sprintf(out, "\nhw-state:\n");
33582         pci_read_config_byte(idev->pdev, VLSI_PCI_IRMISC, &byte);
33583 -       out += sprintf(out, "IRMISC:%s%s%s UART%s",
33584 +       out += sprintf(out, "IRMISC:%s%s%s uart%s",
33585                 (byte&IRMISC_IRRAIL) ? " irrail" : "",
33586                 (byte&IRMISC_IRPD) ? " irpd" : "",
33587                 (byte&IRMISC_UARTTST) ? " uarttest" : "",
33588 -               (byte&IRMISC_UARTEN) ? "" : " disabled\n");
33589 +               (byte&IRMISC_UARTEN) ? "@" : " disabled\n");
33590         if (byte&IRMISC_UARTEN) {
33591 -               out += sprintf(out, "@0x%s\n",
33592 +               out += sprintf(out, "0x%s\n",
33593                         (byte&2) ? ((byte&1) ? "3e8" : "2e8")
33594                                  : ((byte&1) ? "3f8" : "2f8"));
33595         }
33596 @@ -254,7 +260,7 @@
33597                 (word&IRCFG_RXPOL) ? " RXPOL" : "");
33598         word = inw(iobase+VLSI_PIO_IRENABLE);
33599         out += sprintf(out, "IRENABLE:%s%s%s%s%s%s%s%s\n",
33600 -               (word&IRENABLE_IREN) ? " IRENABLE" : "",
33601 +               (word&IRENABLE_PHYANDCLOCK) ? " PHYANDCLOCK" : "",
33602                 (word&IRENABLE_CFGER) ? " CFGERR" : "",
33603                 (word&IRENABLE_FIR_ON) ? " FIR_ON" : "",
33604                 (word&IRENABLE_MIR_ON) ? " MIR_ON" : "",
33605 @@ -358,7 +364,7 @@
33606         char *out = buf;
33607  
33608         if (!ndev || !ndev->priv) {
33609 -               printk(KERN_ERR "%s: invalid ptr!\n", __FUNCTION__);
33610 +               ERROR("%s: invalid ptr!\n", __FUNCTION__);
33611                 return 0;
33612         }
33613  
33614 @@ -539,7 +545,14 @@
33615                 memset(rd, 0, sizeof(*rd));
33616                 rd->hw = hwmap + i;
33617                 rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA);
33618 -               if (rd->buf == NULL) {
33619 +               if (rd->buf == NULL
33620 +                   ||  !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) {
33621 +                       if (rd->buf) {
33622 +                               ERROR("%s: failed to create PCI-MAP for %p",
33623 +                                       __FUNCTION__, rd->buf);
33624 +                               kfree(rd->buf);
33625 +                               rd->buf = NULL;
33626 +                       }
33627                         for (j = 0; j < i; j++) {
33628                                 rd = r->rd + j;
33629                                 busaddr = rd_get_addr(rd);
33630 @@ -552,12 +565,6 @@
33631                         kfree(r);
33632                         return NULL;
33633                 }
33634 -               busaddr = pci_map_single(pdev, rd->buf, len, dir);
33635 -               if (!busaddr) {
33636 -                       printk(KERN_ERR "%s: failed to create PCI-MAP for %p",
33637 -                               __FUNCTION__, rd->buf);
33638 -                       BUG();
33639 -               }
33640                 rd_set_addr_status(rd, busaddr, 0);
33641                 pci_dma_sync_single(pdev, busaddr, len, dir);
33642                 /* initially, the dma buffer is owned by the CPU */
33643 @@ -597,8 +604,7 @@
33644  
33645         ringarea = pci_alloc_consistent(idev->pdev, HW_RING_AREA_SIZE, &idev->busaddr);
33646         if (!ringarea) {
33647 -               printk(KERN_ERR "%s: insufficient memory for descriptor rings\n",
33648 -                       __FUNCTION__);
33649 +               ERROR("%s: insufficient memory for descriptor rings\n", __FUNCTION__);
33650                 goto out;
33651         }
33652         memset(ringarea, 0, HW_RING_AREA_SIZE);
33653 @@ -666,33 +672,52 @@
33654                         ret |= VLSI_RX_FRAME;
33655                 if (status & RD_RX_CRCERR)  
33656                         ret |= VLSI_RX_CRC;
33657 +               goto done;
33658         }
33659 -       else {
33660 -               len = rd_get_count(rd);
33661 -               crclen = (idev->mode==IFF_FIR) ? sizeof(u32) : sizeof(u16);
33662 -               len -= crclen;          /* remove trailing CRC */
33663 -               if (len <= 0) {
33664 -                       printk(KERN_ERR "%s: strange frame (len=%d)\n",
33665 -                               __FUNCTION__, len);
33666 -                       ret |= VLSI_RX_DROP;
33667 -               }
33668 -               else if (!rd->skb) {
33669 -                       printk(KERN_ERR "%s: rx packet dropped\n", __FUNCTION__);
33670 -                       ret |= VLSI_RX_DROP;
33671 -               }
33672 -               else {
33673 -                       skb = rd->skb;
33674 -                       rd->skb = NULL;
33675 -                       skb->dev = ndev;
33676 -                       memcpy(skb_put(skb,len), rd->buf, len);
33677 -                       skb->mac.raw = skb->data;
33678 -                       if (in_interrupt())
33679 -                               netif_rx(skb);
33680 -                       else
33681 -                               netif_rx_ni(skb);
33682 -                       ndev->last_rx = jiffies;
33683 +
33684 +       len = rd_get_count(rd);
33685 +       crclen = (idev->mode==IFF_FIR) ? sizeof(u32) : sizeof(u16);
33686 +       len -= crclen;          /* remove trailing CRC */
33687 +       if (len <= 0) {
33688 +               IRDA_DEBUG(0, "%s: strange frame (len=%d)\n", __FUNCTION__, len);
33689 +               ret |= VLSI_RX_DROP;
33690 +               goto done;
33691 +       }
33692 +
33693 +       if (idev->mode == IFF_SIR) {    /* hw checks CRC in MIR, FIR mode */
33694 +
33695 +               /* rd->buf is a streaming PCI_DMA_FROMDEVICE map. Doing the
33696 +                * endian-adjustment there just in place will dirty a cache line
33697 +                * which belongs to the map and thus we must be sure it will
33698 +                * get flushed before giving the buffer back to hardware.
33699 +                * vlsi_fill_rx() will do this anyway - but here we rely on.
33700 +                */
33701 +               le16_to_cpus(rd->buf+len);
33702 +               if (irda_calc_crc16(INIT_FCS,rd->buf,len+crclen) != GOOD_FCS) {
33703 +                       IRDA_DEBUG(0, "%s: crc error\n", __FUNCTION__);
33704 +                       ret |= VLSI_RX_CRC;
33705 +                       goto done;
33706                 }
33707         }
33708 +
33709 +       if (!rd->skb) {
33710 +               WARNING("%s: rx packet lost\n", __FUNCTION__);
33711 +               ret |= VLSI_RX_DROP;
33712 +               goto done;
33713 +       }
33714 +
33715 +       skb = rd->skb;
33716 +       rd->skb = NULL;
33717 +       skb->dev = ndev;
33718 +       memcpy(skb_put(skb,len), rd->buf, len);
33719 +       skb->mac.raw = skb->data;
33720 +       if (in_interrupt())
33721 +               netif_rx(skb);
33722 +       else
33723 +               netif_rx_ni(skb);
33724 +       ndev->last_rx = jiffies;
33725 +
33726 +done:
33727         rd_set_status(rd, 0);
33728         rd_set_count(rd, 0);
33729         /* buffer still owned by CPU */
33730 @@ -706,7 +731,9 @@
33731  
33732         for (rd = ring_last(r); rd != NULL; rd = ring_put(r)) {
33733                 if (rd_is_active(rd)) {
33734 -                       BUG();
33735 +                       WARNING("%s: driver bug: rx descr race with hw\n",
33736 +                               __FUNCTION__);
33737 +                       vlsi_ring_debug(r);
33738                         break;
33739                 }
33740                 if (!rd->skb) {
33741 @@ -764,7 +791,7 @@
33742  
33743         if (ring_first(r) == NULL) {
33744                 /* we are in big trouble, if this should ever happen */
33745 -               printk(KERN_ERR "%s: rx ring exhausted!\n", __FUNCTION__);
33746 +               ERROR("%s: rx ring exhausted!\n", __FUNCTION__);
33747                 vlsi_ring_debug(r);
33748         }
33749         else
33750 @@ -785,7 +812,7 @@
33751                 if (rd_is_active(rd)) {
33752                         rd_set_status(rd, 0);
33753                         if (rd_get_count(rd)) {
33754 -                               printk(KERN_INFO "%s - dropping rx packet\n", __FUNCTION__);
33755 +                               IRDA_DEBUG(0, "%s - dropping rx packet\n", __FUNCTION__);
33756                                 ret = -VLSI_RX_DROP;
33757                         }
33758                         rd_set_count(rd, 0);
33759 @@ -850,24 +877,17 @@
33760         return (ret) ? -ret : len;
33761  }
33762  
33763 -static int vlsi_set_baud(struct net_device *ndev, int dolock)
33764 +static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
33765  {
33766 -       vlsi_irda_dev_t *idev = ndev->priv;
33767 -       unsigned long flags;
33768         u16 nphyctl;
33769 -       unsigned iobase; 
33770         u16 config;
33771         unsigned mode;
33772 -       unsigned idle_retry;
33773         int     ret;
33774         int     baudrate;
33775 -       int     fifocnt = 0;    /* Keep compiler happy */
33776 +       int     fifocnt;
33777  
33778         baudrate = idev->new_baud;
33779 -       iobase = ndev->base_addr;
33780 -#if 0
33781 -       printk(KERN_DEBUG "%s: %d -> %d\n", __FUNCTION__, idev->baud, idev->new_baud);
33782 -#endif
33783 +       IRDA_DEBUG(2, "%s: %d -> %d\n", __FUNCTION__, idev->baud, idev->new_baud);
33784         if (baudrate == 4000000) {
33785                 mode = IFF_FIR;
33786                 config = IRCFG_FIR;
33787 @@ -883,7 +903,7 @@
33788                 config = IRCFG_SIR | IRCFG_SIRFILT  | IRCFG_RXANY;
33789                 switch(baudrate) {
33790                         default:
33791 -                               printk(KERN_ERR "%s: undefined baudrate %d - fallback to 9600!\n",
33792 +                               WARNING("%s: undefined baudrate %d - fallback to 9600!\n",
33793                                         __FUNCTION__, baudrate);
33794                                 baudrate = 9600;
33795                                 /* fallthru */
33796 @@ -897,40 +917,18 @@
33797                                 break;
33798                 }
33799         }
33800 +       config |= IRCFG_MSTR | IRCFG_ENRX;
33801  
33802 -       if (dolock)
33803 -               spin_lock_irqsave(&idev->lock, flags);
33804 -       else
33805 -               flags = 0xdead; /* prevent bogus warning about possible uninitialized use */
33806 -
33807 -       for (idle_retry=0; idle_retry < 100; idle_retry++) {
33808 -               fifocnt = inw(ndev->base_addr+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
33809 -               if (fifocnt == 0)
33810 -                       break;
33811 -               if (!idle_retry)
33812 -                       printk(KERN_WARNING "%s: waiting for rx fifo to become empty(%d)\n",
33813 -                               __FUNCTION__, fifocnt);
33814 -               if (dolock) {
33815 -                       spin_unlock_irqrestore(&idev->lock, flags);
33816 -                       udelay(100);
33817 -                       spin_lock_irqsave(&idev->lock, flags);
33818 -               }
33819 -               else
33820 -                       udelay(100);
33821 +       fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
33822 +       if (fifocnt != 0) {
33823 +               IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
33824         }
33825 -       if (fifocnt != 0)
33826 -               printk(KERN_ERR "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
33827  
33828         outw(0, iobase+VLSI_PIO_IRENABLE);
33829 -       wmb();
33830 -
33831 -       config |= IRCFG_MSTR | IRCFG_ENRX;
33832 -
33833         outw(config, iobase+VLSI_PIO_IRCFG);
33834 -
33835         outw(nphyctl, iobase+VLSI_PIO_NPHYCTL);
33836         wmb();
33837 -       outw(IRENABLE_IREN, iobase+VLSI_PIO_IRENABLE);
33838 +       outw(IRENABLE_PHYANDCLOCK, iobase+VLSI_PIO_IRENABLE);
33839         mb();
33840  
33841         udelay(1);      /* chip applies IRCFG on next rising edge of its 8MHz clock */
33842 @@ -946,14 +944,14 @@
33843         else
33844                 config ^= IRENABLE_SIR_ON;
33845  
33846 -       if (config != (IRENABLE_IREN|IRENABLE_ENRXST)) {
33847 -               printk(KERN_ERR "%s: failed to set %s mode!\n", __FUNCTION__,
33848 +       if (config != (IRENABLE_PHYANDCLOCK|IRENABLE_ENRXST)) {
33849 +               WARNING("%s: failed to set %s mode!\n", __FUNCTION__,
33850                         (mode==IFF_SIR)?"SIR":((mode==IFF_MIR)?"MIR":"FIR"));
33851                 ret = -1;
33852         }
33853         else {
33854                 if (inw(iobase+VLSI_PIO_PHYCTL) != nphyctl) {
33855 -                       printk(KERN_ERR "%s: failed to apply baudrate %d\n",
33856 +                       WARNING("%s: failed to apply baudrate %d\n",
33857                                 __FUNCTION__, baudrate);
33858                         ret = -1;
33859                 }
33860 @@ -964,8 +962,6 @@
33861                         ret = 0;
33862                 }
33863         }
33864 -       if (dolock)
33865 -               spin_unlock_irqrestore(&idev->lock, flags);
33866  
33867         if (ret)
33868                 vlsi_reg_debug(iobase,__FUNCTION__);
33869 @@ -973,16 +969,6 @@
33870         return ret;
33871  }
33872  
33873 -static inline int vlsi_set_baud_lock(struct net_device *ndev)
33874 -{
33875 -       return vlsi_set_baud(ndev, 1);
33876 -}
33877 -
33878 -static inline int vlsi_set_baud_nolock(struct net_device *ndev)
33879 -{
33880 -       return vlsi_set_baud(ndev, 0);
33881 -}
33882 -
33883  static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
33884  {
33885         vlsi_irda_dev_t *idev = ndev->priv;
33886 @@ -995,79 +981,100 @@
33887         int mtt;
33888         int len, speed;
33889         struct timeval  now, ready;
33890 +       char *msg = NULL;
33891  
33892         speed = irda_get_next_speed(skb);
33893 +       spin_lock_irqsave(&idev->lock, flags);
33894         if (speed != -1  &&  speed != idev->baud) {
33895                 netif_stop_queue(ndev);
33896                 idev->new_baud = speed;
33897 -               if (!skb->len) {
33898 -                       dev_kfree_skb_any(skb);
33899 -
33900 -                       /* due to the completely asynch tx operation we might have
33901 -                        * IrLAP racing with the hardware here, f.e. if the controller
33902 -                        * is just sending the last packet with current speed while
33903 -                        * the LAP is already switching the speed using synchronous
33904 -                        * len=0 packet. Immediate execution would lead to hw lockup
33905 -                        * requiring a powercycle to reset. Good candidate to trigger
33906 -                        * this is the final UA:RSP packet after receiving a DISC:CMD
33907 -                        * when getting the LAP down.
33908 -                        * Note that we are not protected by the queue_stop approach
33909 -                        * because the final UA:RSP arrives _without_ request to apply
33910 -                        * new-speed-after-this-packet - hence the driver doesn't know
33911 -                        * this was the last packet and doesn't stop the queue. So the
33912 -                        * forced switch to default speed from LAP gets through as fast
33913 -                        * as only some 10 usec later while the UA:RSP is still processed
33914 -                        * by the hardware and we would get screwed.
33915 -                        * Note: no locking required since we (netdev->xmit) are the only
33916 -                        * supplier for tx and the network layer provides serialization
33917 -                        */
33918 -                       spin_lock_irqsave(&idev->lock, flags);
33919 -                       if (ring_first(idev->tx_ring) == NULL) {
33920 -                               /* no race - tx-ring already empty */
33921 -                               vlsi_set_baud_nolock(ndev);
33922 -                               netif_wake_queue(ndev);
33923 -                       }
33924 -                       else
33925 -                               ; /* keep the speed change pending like it would
33926 -                                  * for any len>0 packet. tx completion interrupt
33927 -                                  * will apply it when the tx ring becomes empty.
33928 -                                  */
33929 -                       spin_unlock_irqrestore(&idev->lock, flags);
33930 -                       return 0;
33931 -               }
33932                 status = RD_TX_CLRENTX;  /* stop tx-ring after this frame */
33933         }
33934         else
33935                 status = 0;
33936  
33937         if (skb->len == 0) {
33938 -               printk(KERN_ERR "%s: dropping len=0 packet\n", __FUNCTION__);
33939 -               goto drop;
33940 +               /* handle zero packets - should be speed change */
33941 +               if (status == 0) {
33942 +                       msg = "bogus zero-length packet";
33943 +                       goto drop_unlock;
33944 +               }
33945 +
33946 +               /* due to the completely asynch tx operation we might have
33947 +                * IrLAP racing with the hardware here, f.e. if the controller
33948 +                * is just sending the last packet with current speed while
33949 +                * the LAP is already switching the speed using synchronous
33950 +                * len=0 packet. Immediate execution would lead to hw lockup
33951 +                * requiring a powercycle to reset. Good candidate to trigger
33952 +                * this is the final UA:RSP packet after receiving a DISC:CMD
33953 +                * when getting the LAP down.
33954 +                * Note that we are not protected by the queue_stop approach
33955 +                * because the final UA:RSP arrives _without_ request to apply
33956 +                * new-speed-after-this-packet - hence the driver doesn't know
33957 +                * this was the last packet and doesn't stop the queue. So the
33958 +                * forced switch to default speed from LAP gets through as fast
33959 +                * as only some 10 usec later while the UA:RSP is still processed
33960 +                * by the hardware and we would get screwed.
33961 +                */
33962 +
33963 +               if (ring_first(idev->tx_ring) == NULL) {
33964 +                       /* no race - tx-ring already empty */
33965 +                       vlsi_set_baud(idev, iobase);
33966 +                       netif_wake_queue(ndev);
33967 +               }
33968 +               else
33969 +                       ;
33970 +                       /* keep the speed change pending like it would
33971 +                        * for any len>0 packet. tx completion interrupt
33972 +                        * will apply it when the tx ring becomes empty.
33973 +                        */
33974 +               spin_unlock_irqrestore(&idev->lock, flags);
33975 +               dev_kfree_skb_any(skb);
33976 +               return 0;
33977         }
33978  
33979 -       /* sanity checks - should never happen!
33980 -        * simply BUGging the violation and dropping the packet
33981 -        */
33982 +       /* sanity checks - simply drop the packet */
33983  
33984         rd = ring_last(r);
33985 -       if (!rd) {                              /* ring full - queue should have been stopped! */
33986 -               BUG();
33987 -               goto drop;
33988 +       if (!rd) {
33989 +               msg = "ring full, but queue wasn't stopped";
33990 +               goto drop_unlock;
33991         }
33992  
33993 -       if (rd_is_active(rd)) {                 /* entry still owned by hw! */
33994 -               BUG();
33995 -               goto drop;
33996 +       if (rd_is_active(rd)) {
33997 +               msg = "entry still owned by hw";
33998 +               goto drop_unlock;
33999         }
34000  
34001 -       if (!rd->buf) {                         /* no memory for this tx entry - weird! */
34002 -               BUG();
34003 -               goto drop;
34004 +       if (!rd->buf) {
34005 +               msg = "tx ring entry without pci buffer";
34006 +               goto drop_unlock;
34007         }
34008  
34009 -       if (rd->skb) {                          /* hm, associated old skb still there */
34010 -               BUG();
34011 -               goto drop;
34012 +       if (rd->skb) {
34013 +               msg = "ring entry with old skb still attached";
34014 +               goto drop_unlock;
34015 +       }
34016 +
34017 +       /* no need for serialization or interrupt disable during mtt */
34018 +       spin_unlock_irqrestore(&idev->lock, flags);
34019 +
34020 +       if ((mtt = irda_get_mtt(skb)) > 0) {
34021 +       
34022 +               ready.tv_usec = idev->last_rx.tv_usec + mtt;
34023 +               ready.tv_sec = idev->last_rx.tv_sec;
34024 +               if (ready.tv_usec >= 1000000) {
34025 +                       ready.tv_usec -= 1000000;
34026 +                       ready.tv_sec++;         /* IrLAP 1.1: mtt always < 1 sec */
34027 +               }
34028 +               for(;;) {
34029 +                       do_gettimeofday(&now);
34030 +                       if (now.tv_sec > ready.tv_sec
34031 +                           ||  (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
34032 +                               break;
34033 +                       udelay(100);
34034 +                       /* must not sleep here - we are called under xmit_lock! */
34035 +               }
34036         }
34037  
34038         /* tx buffer already owned by CPU due to pci_dma_sync_single() either
34039 @@ -1089,7 +1096,7 @@
34040                  */
34041  
34042                 if (len >= r->len-5)
34043 -                        printk(KERN_WARNING "%s: possible buffer overflow with SIR wrapping!\n",
34044 +                        WARNING("%s: possible buffer overflow with SIR wrapping!\n",
34045                                 __FUNCTION__);
34046         }
34047         else {
34048 @@ -1097,34 +1104,13 @@
34049                 status |= RD_TX_PULSE;          /* send 2 us highspeed indication pulse */
34050                 len = skb->len;
34051                 if (len > r->len) {
34052 -                       printk(KERN_ERR "%s: no space - skb too big (%d)\n",
34053 -                               __FUNCTION__, skb->len);
34054 +                       msg = "frame exceeds tx buffer length";
34055                         goto drop;
34056                 }
34057                 else
34058                         memcpy(rd->buf, skb->data, len);
34059         }
34060  
34061 -       /* do mtt delay before we need to disable interrupts! */
34062 -
34063 -       if ((mtt = irda_get_mtt(skb)) > 0) {
34064 -       
34065 -               ready.tv_usec = idev->last_rx.tv_usec + mtt;
34066 -               ready.tv_sec = idev->last_rx.tv_sec;
34067 -               if (ready.tv_usec >= 1000000) {
34068 -                       ready.tv_usec -= 1000000;
34069 -                       ready.tv_sec++;         /* IrLAP 1.1: mtt always < 1 sec */
34070 -               }
34071 -               for(;;) {
34072 -                       do_gettimeofday(&now);
34073 -                       if (now.tv_sec > ready.tv_sec
34074 -                           ||  (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
34075 -                               break;
34076 -                       udelay(100);
34077 -                       /* must not sleep here - we are called under xmit_lock! */
34078 -               }
34079 -       }
34080 -
34081         rd->skb = skb;                  /* remember skb for tx-complete stats */
34082  
34083         rd_set_count(rd, len);
34084 @@ -1136,10 +1122,7 @@
34085  
34086         pci_dma_prep_single(r->pdev, rd_get_addr(rd), r->len, r->dir);
34087  
34088 -/*
34089 - *     We need to disable IR output in order to switch to TX mode.
34090 - *     Better not do this blindly anytime we want to transmit something
34091 - *     because TX may already run. However we are racing with the controller
34092 +/*     Switching to TX mode here races with the controller
34093   *     which may stop TX at any time when fetching an inactive descriptor
34094   *     or one with CLR_ENTX set. So we switch on TX only, if TX was not running
34095   *     _after_ the new descriptor was activated on the ring. This ensures
34096 @@ -1158,31 +1141,39 @@
34097                 int fifocnt;
34098  
34099                 fifocnt = inw(ndev->base_addr+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
34100 -               if (fifocnt != 0)
34101 -                       printk(KERN_WARNING "%s: rx fifo not empty(%d)\n",
34102 -                               __FUNCTION__, fifocnt);
34103 +               if (fifocnt != 0) {
34104 +                       IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
34105 +               }
34106  
34107                 config = inw(iobase+VLSI_PIO_IRCFG);
34108 -               rmb();
34109 -               outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
34110                 mb();
34111 +               outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
34112 +               wmb();
34113                 outw(0, iobase+VLSI_PIO_PROMPT);
34114         }
34115         ndev->trans_start = jiffies;
34116  
34117         if (ring_put(r) == NULL) {
34118                 netif_stop_queue(ndev);
34119 -               printk(KERN_DEBUG "%s: tx ring full - queue stopped\n", __FUNCTION__);
34120 +               IRDA_DEBUG(3, "%s: tx ring full - queue stopped\n", __FUNCTION__);
34121         }
34122         spin_unlock_irqrestore(&idev->lock, flags);
34123  
34124         return 0;
34125  
34126 +drop_unlock:
34127 +       spin_unlock_irqrestore(&idev->lock, flags);
34128  drop:
34129 +       WARNING("%s: dropping packet - %s\n", __FUNCTION__, msg);
34130         dev_kfree_skb_any(skb);
34131         idev->stats.tx_errors++;
34132         idev->stats.tx_dropped++;
34133 -       return 1;
34134 +       /* Don't even think about returning NET_XMIT_DROP (=1) here!
34135 +        * In fact any retval!=0 causes the packet scheduler to requeue the
34136 +        * packet for later retry of transmission - which isn't exactly
34137 +        * what we want after we've just called dev_kfree_skb_any ;-)
34138 +        */
34139 +       return 0;
34140  }
34141  
34142  static void vlsi_tx_interrupt(struct net_device *ndev)
34143 @@ -1215,12 +1206,12 @@
34144                 }
34145         }
34146  
34147 +       iobase = ndev->base_addr;
34148 +
34149         if (idev->new_baud  &&  rd == NULL)     /* tx ring empty and speed change pending */
34150 -               vlsi_set_baud_lock(ndev);
34151 +               vlsi_set_baud(idev, iobase);
34152  
34153 -       iobase = ndev->base_addr;
34154         config = inw(iobase+VLSI_PIO_IRCFG);
34155 -
34156         if (rd == NULL)                 /* tx ring empty: re-enable rx */
34157                 outw((config & ~IRCFG_ENTX) | IRCFG_ENRX, iobase+VLSI_PIO_IRCFG);
34158  
34159 @@ -1228,9 +1219,10 @@
34160                 int fifocnt;
34161  
34162                 fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
34163 -               if (fifocnt != 0)
34164 -                       printk(KERN_WARNING "%s: rx fifo not empty(%d)\n",
34165 +               if (fifocnt != 0) {
34166 +                       IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n",
34167                                 __FUNCTION__, fifocnt);
34168 +               }
34169                 outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
34170         }
34171  
34172 @@ -1238,7 +1230,7 @@
34173  
34174         if (netif_queue_stopped(ndev)  &&  !idev->new_baud) {
34175                 netif_wake_queue(ndev);
34176 -               printk(KERN_DEBUG "%s: queue awoken\n", __FUNCTION__);
34177 +               IRDA_DEBUG(3, "%s: queue awoken\n", __FUNCTION__);
34178         }
34179  }
34180  
34181 @@ -1261,7 +1253,7 @@
34182                                 dev_kfree_skb_any(rd->skb);
34183                                 rd->skb = NULL;
34184                         }
34185 -                       printk(KERN_INFO "%s - dropping tx packet\n", __FUNCTION__);
34186 +                       IRDA_DEBUG(0, "%s - dropping tx packet\n", __FUNCTION__);
34187                         ret = -VLSI_TX_DROP;
34188                 }
34189                 else
34190 @@ -1310,8 +1302,7 @@
34191                 }
34192                 if (count < 3) {
34193                         if (clksrc == 1) { /* explicitly asked for PLL hence bail out */
34194 -                               printk(KERN_ERR "%s: no PLL or failed to lock!\n",
34195 -                                       __FUNCTION__);
34196 +                               ERROR("%s: no PLL or failed to lock!\n", __FUNCTION__);
34197                                 clkctl = CLKCTL_CLKSTP;
34198                                 pci_write_config_byte(pdev, VLSI_PCI_CLKCTL, clkctl);
34199                                 return -1;
34200 @@ -1319,7 +1310,7 @@
34201                         else                    /* was: clksrc=0(auto) */
34202                                 clksrc = 3;     /* fallback to 40MHz XCLK (OB800) */
34203  
34204 -                       printk(KERN_INFO "%s: PLL not locked, fallback to clksrc=%d\n",
34205 +                       IRDA_DEBUG(0, "%s: PLL not locked, fallback to clksrc=%d\n",
34206                                 __FUNCTION__, clksrc);
34207                 }
34208                 else
34209 @@ -1392,9 +1383,7 @@
34210         /* start the clock and clean the registers */
34211  
34212         if (vlsi_start_clock(pdev)) {
34213 -               printk(KERN_ERR "%s: no valid clock source\n",
34214 -                       __FUNCTION__);
34215 -               pci_disable_device(pdev);
34216 +               ERROR("%s: no valid clock source\n", __FUNCTION__);
34217                 return -1;
34218         }
34219         iobase = ndev->base_addr;
34220 @@ -1422,7 +1411,7 @@
34221         atomic_set(&idev->tx_ring->head, RINGPTR_GET_TX(ptr));
34222         atomic_set(&idev->tx_ring->tail, RINGPTR_GET_TX(ptr));
34223  
34224 -       vlsi_set_baud_lock(ndev);       /* idev->new_baud used as provided by caller */
34225 +       vlsi_set_baud(idev, iobase);    /* idev->new_baud used as provided by caller */
34226  
34227         outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);  /* just in case - w/c pending IRQ's */
34228         wmb();
34229 @@ -1455,7 +1444,10 @@
34230         pci_write_config_byte(pdev, VLSI_PCI_MSTRPAGE, MSTRPAGE_VALUE);
34231         pci_set_master(pdev);
34232  
34233 -       vlsi_init_chip(pdev);
34234 +       if (vlsi_init_chip(pdev) < 0) {
34235 +               pci_disable_device(pdev);
34236 +               return -1;
34237 +       }
34238  
34239         vlsi_fill_rx(idev->rx_ring);
34240  
34241 @@ -1476,10 +1468,11 @@
34242         spin_lock_irqsave(&idev->lock,flags);
34243         outw(0, iobase+VLSI_PIO_IRENABLE);
34244         outw(0, iobase+VLSI_PIO_IRCFG);                 /* disable everything */
34245 -       wmb();
34246  
34247 -       outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);  /* w/c pending + disable further IRQ */
34248 -       mb();
34249 +       /* disable and w/c irqs */
34250 +       outb(0, iobase+VLSI_PIO_IRINTR);
34251 +       wmb();
34252 +       outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);
34253         spin_unlock_irqrestore(&idev->lock,flags);
34254  
34255         vlsi_unarm_tx(idev);
34256 @@ -1521,8 +1514,8 @@
34257                 idev->new_baud = idev->baud;            /* keep current baudrate */
34258  
34259         if (vlsi_start_hw(idev))
34260 -               printk(KERN_CRIT "%s: failed to restart hw - %s(%s) unusable!\n",
34261 -                       __FUNCTION__, pci_name(idev->pdev), ndev->name);
34262 +               ERROR("%s: failed to restart hw - %s(%s) unusable!\n",
34263 +                       __FUNCTION__, PCIDEV_NAME(idev->pdev), ndev->name);
34264         else
34265                 netif_start_queue(ndev);
34266  }
34267 @@ -1547,7 +1540,7 @@
34268                          * if the stack tries to change speed concurrently - which would be
34269                          * pretty strange anyway with the userland having full control...
34270                          */
34271 -                       vlsi_set_baud_nolock(ndev);
34272 +                       vlsi_set_baud(idev, ndev->base_addr);
34273                         spin_unlock_irqrestore(&idev->lock, flags);
34274                         break;
34275                 case SIOCSMEDIABUSY:
34276 @@ -1566,8 +1559,7 @@
34277                         irq->ifr_receiving = (fifocnt!=0) ? 1 : 0;
34278                         break;
34279                 default:
34280 -                       printk(KERN_ERR "%s: notsupp - cmd=%04x\n",
34281 -                               __FUNCTION__, cmd);
34282 +                       WARNING("%s: notsupp - cmd=%04x\n", __FUNCTION__, cmd);
34283                         ret = -EOPNOTSUPP;
34284         }       
34285         
34286 @@ -1583,41 +1575,36 @@
34287         vlsi_irda_dev_t *idev = ndev->priv;
34288         unsigned        iobase;
34289         u8              irintr;
34290 -       int             boguscount = 32;
34291 -       unsigned        got_act;
34292 +       int             boguscount = 5;
34293         unsigned long   flags;
34294         int             handled = 0;
34295  
34296 -       got_act = 0;
34297         iobase = ndev->base_addr;
34298 +       spin_lock_irqsave(&idev->lock,flags);
34299         do {
34300 -               spin_lock_irqsave(&idev->lock,flags);
34301                 irintr = inb(iobase+VLSI_PIO_IRINTR);
34302 -               rmb();
34303 -               outb(irintr, iobase+VLSI_PIO_IRINTR); /* acknowledge asap */
34304 -               spin_unlock_irqrestore(&idev->lock,flags);
34305 +               mb();
34306 +               outb(irintr, iobase+VLSI_PIO_IRINTR);   /* acknowledge asap */
34307  
34308                 if (!(irintr&=IRINTR_INT_MASK))         /* not our INT - probably shared */
34309                         break;
34310 +
34311                 handled = 1;
34312 +
34313 +               if (unlikely(!(irintr & ~IRINTR_ACTIVITY)))
34314 +                       break;                          /* nothing todo if only activity */
34315 +
34316                 if (irintr&IRINTR_RPKTINT)
34317                         vlsi_rx_interrupt(ndev);
34318  
34319                 if (irintr&IRINTR_TPKTINT)
34320                         vlsi_tx_interrupt(ndev);
34321  
34322 -               if (!(irintr & ~IRINTR_ACTIVITY))
34323 -                       break;          /* done if only activity remaining */
34324 -       
34325 -               if (irintr & ~(IRINTR_RPKTINT|IRINTR_TPKTINT|IRINTR_ACTIVITY)) {
34326 -                       printk(KERN_DEBUG "%s: IRINTR = %02x\n",
34327 -                               __FUNCTION__, (unsigned)irintr);
34328 -                       vlsi_reg_debug(iobase,__FUNCTION__);
34329 -               }                       
34330         } while (--boguscount > 0);
34331 +       spin_unlock_irqrestore(&idev->lock,flags);
34332  
34333         if (boguscount <= 0)
34334 -               printk(KERN_WARNING "%s: too much work in interrupt!\n", __FUNCTION__);
34335 +               MESSAGE("%s: too much work in interrupt!\n", __FUNCTION__);
34336         return IRQ_RETVAL(handled);
34337  }
34338  
34339 @@ -1630,7 +1617,7 @@
34340         char    hwname[32];
34341  
34342         if (pci_request_regions(idev->pdev, drivername)) {
34343 -               printk(KERN_ERR "%s: io resource busy\n", __FUNCTION__);
34344 +               WARNING("%s: io resource busy\n", __FUNCTION__);
34345                 goto errout;
34346         }
34347         ndev->base_addr = pci_resource_start(idev->pdev,0);
34348 @@ -1644,8 +1631,7 @@
34349  
34350         if (request_irq(ndev->irq, vlsi_interrupt, SA_SHIRQ,
34351                         drivername, ndev)) {
34352 -               printk(KERN_ERR "%s: couldn't get IRQ: %d\n",
34353 -                       __FUNCTION__, ndev->irq);
34354 +               WARNING("%s: couldn't get IRQ: %d\n", __FUNCTION__, ndev->irq);
34355                 goto errout_io;
34356         }
34357  
34358 @@ -1666,7 +1652,7 @@
34359  
34360         netif_start_queue(ndev);
34361  
34362 -       printk(KERN_INFO "%s: device %s operational\n", __FUNCTION__, ndev->name);
34363 +       MESSAGE("%s: device %s operational\n", __FUNCTION__, ndev->name);
34364  
34365         return 0;
34366  
34367 @@ -1700,7 +1686,7 @@
34368  
34369         pci_release_regions(idev->pdev);
34370  
34371 -       printk(KERN_INFO "%s: device %s stopped\n", __FUNCTION__, ndev->name);
34372 +       MESSAGE("%s: device %s stopped\n", __FUNCTION__, ndev->name);
34373  
34374         return 0;
34375  }
34376 @@ -1721,8 +1707,7 @@
34377  
34378         if (pci_set_dma_mask(pdev,DMA_MASK_USED_BY_HW)
34379             || pci_set_dma_mask(pdev,DMA_MASK_MSTRPAGE)) {
34380 -               printk(KERN_ERR "%s: aborting due to PCI BM-DMA address limitations\n",
34381 -                       __FUNCTION__);
34382 +               ERROR("%s: aborting due to PCI BM-DMA address limitations\n", __FUNCTION__);
34383                 return -1;
34384         }
34385  
34386 @@ -1771,12 +1756,12 @@
34387         else
34388                 pdev->current_state = 0; /* hw must be running now */
34389  
34390 -       printk(KERN_INFO "%s: IrDA PCI controller %s detected\n",
34391 -               drivername, pci_name(pdev));
34392 +       MESSAGE("%s: IrDA PCI controller %s detected\n",
34393 +               drivername, PCIDEV_NAME(pdev));
34394  
34395         if ( !pci_resource_start(pdev,0)
34396              || !(pci_resource_flags(pdev,0) & IORESOURCE_IO) ) {
34397 -               printk(KERN_ERR "%s: bar 0 invalid", __FUNCTION__);
34398 +               ERROR("%s: bar 0 invalid", __FUNCTION__);
34399                 goto out_disable;
34400         }
34401  
34402 @@ -1784,8 +1769,7 @@
34403  
34404         ndev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL);
34405         if (ndev==NULL) {
34406 -               printk(KERN_ERR "%s: Unable to allocate device memory.\n",
34407 -                       __FUNCTION__);
34408 +               ERROR("%s: Unable to allocate device memory.\n", __FUNCTION__);
34409                 goto out_disable;
34410         }
34411  
34412 @@ -1801,37 +1785,33 @@
34413         ndev->init = vlsi_irda_init;
34414         strcpy(ndev->name,"irda%d");
34415         if (register_netdev(ndev)) {
34416 -               printk(KERN_ERR "%s: register_netdev failed\n",
34417 -                       __FUNCTION__);
34418 +               ERROR("%s: register_netdev failed\n", __FUNCTION__);
34419                 goto out_freedev;
34420         }
34421  
34422 +       idev->proc_entry = NULL;
34423         if (vlsi_proc_root != NULL) {
34424                 struct proc_dir_entry *ent;
34425  
34426                 ent = create_proc_entry(ndev->name, S_IFREG|S_IRUGO, vlsi_proc_root);
34427                 if (!ent) {
34428 -                       printk(KERN_ERR "%s: failed to create proc entry\n", __FUNCTION__);
34429 -                       goto out_unregister;
34430 +                       WARNING("%s: failed to create proc entry\n", __FUNCTION__);
34431 +                       idev->proc_entry = NULL;
34432                 }
34433 -               ent->data = ndev;
34434 -               ent->proc_fops = VLSI_PROC_FOPS;
34435 -               ent->size = 0;
34436 -               idev->proc_entry = ent;
34437 -       } else
34438 -               idev->proc_entry = NULL;
34439 -
34440 -       printk(KERN_INFO "%s: registered device %s\n", drivername, ndev->name);
34441 +               else {
34442 +                       ent->data = ndev;
34443 +                       ent->proc_fops = VLSI_PROC_FOPS;
34444 +                       ent->size = 0;
34445 +                       idev->proc_entry = ent;
34446 +               }
34447 +       }
34448 +       MESSAGE("%s: registered device %s\n", drivername, ndev->name);
34449  
34450         pci_set_drvdata(pdev, ndev);
34451         up(&idev->sem);
34452  
34453         return 0;
34454  
34455 -out_unregister:
34456 -       up(&idev->sem);
34457 -       unregister_netdev(ndev);
34458 -       goto out_disable;
34459  out_freedev:
34460         up(&idev->sem);
34461         kfree(ndev);
34462 @@ -1848,14 +1828,12 @@
34463         vlsi_irda_dev_t *idev;
34464  
34465         if (!ndev) {
34466 -               printk(KERN_CRIT "%s: lost netdevice?\n", drivername);
34467 +               ERROR("%s: lost netdevice?\n", drivername);
34468                 return;
34469         }
34470  
34471         idev = ndev->priv;
34472         down(&idev->sem);
34473 -       pci_set_drvdata(pdev, NULL);
34474 -       pci_disable_device(pdev);
34475         if (idev->proc_entry) {
34476                 remove_proc_entry(ndev->name, vlsi_proc_root);
34477                 idev->proc_entry = NULL;
34478 @@ -1867,7 +1845,9 @@
34479          * ndev->destructor called (if present) when going to free
34480          */
34481  
34482 -       printk(KERN_INFO "%s: %s removed\n", drivername, pci_name(pdev));
34483 +       pci_set_drvdata(pdev, NULL);
34484 +
34485 +       MESSAGE("%s: %s removed\n", drivername, PCIDEV_NAME(pdev));
34486  }
34487  
34488  #ifdef CONFIG_PM
34489 @@ -1882,8 +1862,8 @@
34490  static int vlsi_irda_save_state(struct pci_dev *pdev, u32 state)
34491  {
34492         if (state < 1 || state > 3 ) {
34493 -               printk( KERN_ERR "%s - %s: invalid pm state request: %u\n",
34494 -                       __FUNCTION__, pci_name(pdev), state);
34495 +               ERROR("%s - %s: invalid pm state request: %u\n",
34496 +                       __FUNCTION__, PCIDEV_NAME(pdev), state);
34497                 return -1;
34498         }
34499         return 0;
34500 @@ -1895,12 +1875,12 @@
34501         vlsi_irda_dev_t *idev;
34502  
34503         if (state < 1 || state > 3 ) {
34504 -               printk( KERN_ERR "%s - %s: invalid pm state request: %u\n",
34505 -                       __FUNCTION__, pci_name(pdev), state);
34506 +               ERROR("%s - %s: invalid pm state request: %u\n",
34507 +                       __FUNCTION__, PCIDEV_NAME(pdev), state);
34508                 return 0;
34509         }
34510         if (!ndev) {
34511 -               printk(KERN_ERR "%s - %s: no netdevice \n", __FUNCTION__, pci_name(pdev));
34512 +               ERROR("%s - %s: no netdevice \n", __FUNCTION__, PCIDEV_NAME(pdev));
34513                 return 0;
34514         }
34515         idev = ndev->priv;      
34516 @@ -1911,8 +1891,8 @@
34517                         pdev->current_state = state;
34518                 }
34519                 else
34520 -                       printk(KERN_ERR "%s - %s: invalid suspend request %u -> %u\n",
34521 -                               __FUNCTION__, pci_name(pdev), pdev->current_state, state);
34522 +                       ERROR("%s - %s: invalid suspend request %u -> %u\n",
34523 +                               __FUNCTION__, PCIDEV_NAME(pdev), pdev->current_state, state);
34524                 up(&idev->sem);
34525                 return 0;
34526         }
34527 @@ -1939,14 +1919,14 @@
34528         vlsi_irda_dev_t *idev;
34529  
34530         if (!ndev) {
34531 -               printk(KERN_ERR "%s - %s: no netdevice \n", __FUNCTION__, pci_name(pdev));
34532 +               ERROR("%s - %s: no netdevice \n", __FUNCTION__, PCIDEV_NAME(pdev));
34533                 return 0;
34534         }
34535         idev = ndev->priv;      
34536         down(&idev->sem);
34537         if (pdev->current_state == 0) {
34538                 up(&idev->sem);
34539 -               printk(KERN_ERR "%s - %s: already resumed\n", __FUNCTION__, pci_name(pdev));
34540 +               WARNING("%s - %s: already resumed\n", __FUNCTION__, PCIDEV_NAME(pdev));
34541                 return 0;
34542         }
34543         
34544 @@ -1965,7 +1945,7 @@
34545                  * now we explicitly set pdev->current_state = 0 after enabling the
34546                  * device and independently resume_ok should catch any garbage config.
34547                  */
34548 -               printk(KERN_ERR "%s - hm, nothing to resume?\n", __FUNCTION__);
34549 +               WARNING("%s - hm, nothing to resume?\n", __FUNCTION__);
34550                 up(&idev->sem);
34551                 return 0;
34552         }
34553 @@ -2003,7 +1983,7 @@
34554         int     i, ret;
34555  
34556         if (clksrc < 0  ||  clksrc > 3) {
34557 -               printk(KERN_ERR "%s: invalid clksrc=%d\n", drivername, clksrc);
34558 +               ERROR("%s: invalid clksrc=%d\n", drivername, clksrc);
34559                 return -1;
34560         }
34561  
34562 @@ -2016,9 +1996,8 @@
34563                         case 64:
34564                                 break;
34565                         default:
34566 -                               printk(KERN_WARNING "%s: invalid %s ringsize %d",
34567 +                               WARNING("%s: invalid %s ringsize %d, using default=8",
34568                                         drivername, (i)?"rx":"tx", ringsize[i]);
34569 -                               printk(", using default=8\n");
34570                                 ringsize[i] = 8;
34571                                 break;
34572                 }
34573 diff -Nru a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
34574 --- a/drivers/net/ixgb/ixgb_main.c      Tue Aug 19 20:53:16 2003
34575 +++ b/drivers/net/ixgb/ixgb_main.c      Sun Aug 31 08:08:53 2003
34576 @@ -1914,10 +1914,8 @@
34577                 skb->protocol = eth_type_trans(skb, netdev);
34578                 if (adapter->vlgrp
34579                     && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
34580 -                       vlan_hwaccel_rx(skb, adapter->vlgrp,
34581 -                                       (rx_desc->
34582 -                                        special &
34583 -                                        IXGB_RX_DESC_SPECIAL_VLAN_MASK));
34584 +                       vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
34585 +                               (rx_desc-> special & IXGB_RX_DESC_SPECIAL_VLAN_MASK));
34586                 } else {
34587                         netif_receive_skb(skb);
34588                 }
34589 diff -Nru a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
34590 --- a/drivers/net/ne2k-pci.c    Tue Aug 19 20:53:16 2003
34591 +++ b/drivers/net/ne2k-pci.c    Mon Sep  1 10:03:04 2003
34592 @@ -174,7 +174,7 @@
34593                           struct sk_buff *skb, int ring_offset);
34594  static void ne2k_pci_block_output(struct net_device *dev, const int count,
34595                 const unsigned char *buf, const int start_page);
34596 -static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
34597 +static struct ethtool_ops ne2k_pci_ethtool_ops;
34598  
34599  \f
34600  
34601 @@ -259,7 +259,8 @@
34602                 }
34603         }
34604  
34605 -       dev = alloc_etherdev(0);
34606 +       /* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */
34607 +       dev = alloc_ei_netdev();
34608         if (!dev) {
34609                 printk (KERN_ERR PFX "cannot allocate ethernet device\n");
34610                 goto err_out_free_res;
34611 @@ -331,13 +332,6 @@
34612         dev->base_addr = ioaddr;
34613         pci_set_drvdata(pdev, dev);
34614  
34615 -       /* Allocate dev->priv and fill in 8390 specific dev fields. */
34616 -       if (ethdev_init(dev)) {
34617 -               printk (KERN_ERR "ne2kpci(%s): unable to get memory for dev->priv.\n",
34618 -                       pci_name(pdev));
34619 -               goto err_out_free_netdev;
34620 -       }
34621 -
34622         ei_status.name = pci_clone_list[chip_idx].name;
34623         ei_status.tx_start_page = start_page;
34624         ei_status.stop_page = stop_page;
34625 @@ -361,12 +355,12 @@
34626         ei_status.priv = (unsigned long) pdev;
34627         dev->open = &ne2k_pci_open;
34628         dev->stop = &ne2k_pci_close;
34629 -       dev->do_ioctl = &netdev_ioctl;
34630 +       dev->ethtool_ops = &ne2k_pci_ethtool_ops;
34631         NS8390_init(dev, 0);
34632  
34633         i = register_netdev(dev);
34634         if (i)
34635 -               goto err_out_free_8390;
34636 +               goto err_out_free_netdev;
34637  
34638         printk("%s: %s found at %#lx, IRQ %d, ",
34639                    dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq);
34640 @@ -377,10 +371,8 @@
34641  
34642         return 0;
34643  
34644 -err_out_free_8390:
34645 -       kfree(dev->priv);
34646  err_out_free_netdev:
34647 -       kfree (dev);
34648 +       free_netdev (dev);
34649  err_out_free_res:
34650         release_region (ioaddr, NE_IO_EXTENT);
34651         pci_set_drvdata (pdev, NULL);
34652 @@ -591,41 +583,23 @@
34653         return;
34654  }
34655  
34656 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
34657 +static void ne2k_pci_get_drvinfo(struct net_device *dev,
34658 +                                struct ethtool_drvinfo *info)
34659  {
34660         struct ei_device *ei = dev->priv;
34661         struct pci_dev *pci_dev = (struct pci_dev *) ei->priv;
34662 -       u32 ethcmd;
34663 -               
34664 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
34665 -               return -EFAULT;
34666 -
34667 -        switch (ethcmd) {
34668 -        case ETHTOOL_GDRVINFO: {
34669 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
34670 -               strcpy(info.driver, DRV_NAME);
34671 -               strcpy(info.version, DRV_VERSION);
34672 -               strcpy(info.bus_info, pci_name(pci_dev));
34673 -               if (copy_to_user(useraddr, &info, sizeof(info)))
34674 -                       return -EFAULT;
34675 -               return 0;
34676 -       }
34677 -
34678 -        }
34679 -       
34680 -       return -EOPNOTSUPP;
34681 -}
34682  
34683 -static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
34684 -{
34685 -       switch(cmd) {
34686 -       case SIOCETHTOOL:
34687 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
34688 -       default:
34689 -               return -EOPNOTSUPP;
34690 -       }
34691 +       strcpy(info->driver, DRV_NAME);
34692 +       strcpy(info->version, DRV_VERSION);
34693 +       strcpy(info->bus_info, pci_name(pci_dev));
34694  }
34695  
34696 +static struct ethtool_ops ne2k_pci_ethtool_ops = {
34697 +       .get_drvinfo            = ne2k_pci_get_drvinfo,
34698 +       .get_tx_csum            = ethtool_op_get_tx_csum,
34699 +       .get_sg                 = ethtool_op_get_sg,
34700 +};
34701 +
34702  static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
34703  {
34704         struct net_device *dev = pci_get_drvdata(pdev);
34705 @@ -635,8 +609,8 @@
34706  
34707         unregister_netdev(dev);
34708         release_region(dev->base_addr, NE_IO_EXTENT);
34709 -       kfree(dev->priv);
34710         free_netdev(dev);
34711 +       pci_disable_device(pdev);
34712         pci_set_drvdata(pdev, NULL);
34713  }
34714  
34715 diff -Nru a/drivers/net/ni5010.c b/drivers/net/ni5010.c
34716 --- a/drivers/net/ni5010.c      Sun Apr 20 23:00:41 2003
34717 +++ b/drivers/net/ni5010.c      Sun Aug 31 16:14:15 2003
34718 @@ -96,6 +96,7 @@
34719         struct net_device_stats stats;
34720         int o_pkt_size;
34721         int i_pkt_size;
34722 +       spinlock_t lock;
34723  };
34724  
34725  /* Index to functions, as function prototypes. */
34726 @@ -280,11 +281,16 @@
34727         /* DMA is not supported (yet?), so no use detecting it */
34728  
34729         if (dev->priv == NULL) {
34730 +               struct ni5010_local* lp;
34731 +
34732                 dev->priv = kmalloc(sizeof(struct ni5010_local), GFP_KERNEL|GFP_DMA);
34733                 if (dev->priv == NULL) {
34734                         printk(KERN_WARNING "%s: Failed to allocate private memory\n", dev->name);
34735                         return -ENOMEM;
34736                 }
34737 +
34738 +               lp = (struct ni5010_local*)dev->priv;
34739 +               spin_lock_init(&lp->lock);
34740         }
34741  
34742         PRINTK2((KERN_DEBUG "%s: I/O #10 passed!\n", dev->name));
34743 @@ -463,6 +469,7 @@
34744         ioaddr = dev->base_addr;
34745         lp = (struct ni5010_local *)dev->priv;
34746         
34747 +       spin_lock(&lp->lock);
34748         status = inb(IE_ISTAT); 
34749         PRINTK3((KERN_DEBUG "%s: IE_ISTAT = %#02x\n", dev->name, status));
34750                 
34751 @@ -479,6 +486,7 @@
34752  
34753         if (!xmit_was_error) 
34754                 reset_receiver(dev); 
34755 +       spin_unlock(&lp->lock);
34756         return IRQ_HANDLED;
34757  }
34758  
34759 @@ -693,8 +701,7 @@
34760          buf_offs = NI5010_BUFSIZE - length - pad;
34761          lp->o_pkt_size = length + pad;
34762  
34763 -       save_flags(flags);      
34764 -       cli();
34765 +       spin_lock_irqsave(&lp->lock, flags);
34766  
34767         outb(0, EDLC_RMASK);    /* Mask all receive interrupts */
34768         outb(0, IE_MMODE);      /* Put Xmit buffer on system bus */
34769 @@ -712,7 +719,7 @@
34770         outb(MM_EN_XMT | MM_MUX, IE_MMODE); /* Begin transmission */
34771         outb(XM_ALL, EDLC_XMASK); /* Cause interrupt after completion or fail */
34772  
34773 -       restore_flags(flags);
34774 +       spin_unlock_irqrestore(&lp->lock, flags);
34775  
34776         netif_wake_queue(dev);
34777         
34778 diff -Nru a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
34779 --- a/drivers/net/pcmcia/3c574_cs.c     Tue Aug 19 20:55:09 2003
34780 +++ b/drivers/net/pcmcia/3c574_cs.c     Sun Aug 31 05:20:57 2003
34781 @@ -253,6 +253,7 @@
34782  static int el3_close(struct net_device *dev);
34783  static void el3_tx_timeout(struct net_device *dev);
34784  static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
34785 +static struct ethtool_ops netdev_ethtool_ops;
34786  static void set_rx_mode(struct net_device *dev);
34787  
34788  static dev_info_t dev_info = "3c574_cs";
34789 @@ -319,6 +320,7 @@
34790         dev->hard_start_xmit = &el3_start_xmit;
34791         dev->get_stats = &el3_get_stats;
34792         dev->do_ioctl = &el3_ioctl;
34793 +       SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
34794         dev->set_multicast_list = &set_rx_mode;
34795         dev->open = &el3_open;
34796         dev->stop = &el3_close;
34797 @@ -1202,26 +1204,16 @@
34798         return worklimit;
34799  }
34800  
34801 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
34802 +static void netdev_get_drvinfo(struct net_device *dev,
34803 +                              struct ethtool_drvinfo *info)
34804  {
34805 -       u32 ethcmd;
34806 -               
34807 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
34808 -               return -EFAULT;
34809 -       
34810 -       switch (ethcmd) {
34811 -       case ETHTOOL_GDRVINFO: {
34812 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
34813 -               strncpy(info.driver, "3c574_cs", sizeof(info.driver)-1);
34814 -               if (copy_to_user(useraddr, &info, sizeof(info)))
34815 -                       return -EFAULT;
34816 -               return 0;
34817 -       }
34818 -       }
34819 -       
34820 -       return -EOPNOTSUPP;
34821 +       strcpy(info->driver, "3c574_cs");
34822  }
34823  
34824 +static struct ethtool_ops netdev_ethtool_ops = {
34825 +       .get_drvinfo            = netdev_get_drvinfo,
34826 +};
34827 +
34828  /* Provide ioctl() calls to examine the MII xcvr state. */
34829  static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
34830  {
34831 @@ -1235,11 +1227,9 @@
34832                   data[0], data[1], data[2], data[3]);
34833  
34834         switch(cmd) {
34835 -       case SIOCETHTOOL:
34836 -               return netdev_ethtool_ioctl(dev, (void *)rq->ifr_data);
34837 -       case SIOCDEVPRIVATE:            /* Get the address of the PHY in use. */
34838 +       case SIOCGMIIPHY:               /* Get the address of the PHY in use. */
34839                 data[0] = phy;
34840 -       case SIOCDEVPRIVATE+1:          /* Read the specified MII register. */
34841 +       case SIOCGMIIREG:               /* Read the specified MII register. */
34842                 {
34843                         int saved_window;
34844                         unsigned long flags;
34845 @@ -1252,7 +1242,7 @@
34846                         spin_unlock_irqrestore(&lp->window_lock, flags);
34847                         return 0;
34848                 }
34849 -       case SIOCDEVPRIVATE+2:          /* Write the specified MII register */
34850 +       case SIOCSMIIREG:               /* Write the specified MII register */
34851                 {
34852                         int saved_window;
34853                         unsigned long flags;
34854 diff -Nru a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
34855 --- a/drivers/net/pcmcia/3c589_cs.c     Tue Aug 19 20:55:09 2003
34856 +++ b/drivers/net/pcmcia/3c589_cs.c     Tue Aug 26 14:27:07 2003
34857 @@ -165,7 +165,7 @@
34858  static int el3_close(struct net_device *dev);
34859  static void el3_tx_timeout(struct net_device *dev);
34860  static void set_multicast_list(struct net_device *dev);
34861 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
34862 +static struct ethtool_ops netdev_ethtool_ops;
34863  
34864  static dev_info_t dev_info = "3c589_cs";
34865  
34866 @@ -249,7 +249,7 @@
34867      dev->tx_timeout = el3_tx_timeout;
34868      dev->watchdog_timeo = TX_TIMEOUT;
34869  #endif
34870 -    dev->do_ioctl = netdev_ioctl;
34871 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
34872  
34873      /* Register with Card Services */
34874      link->next = dev_list;
34875 @@ -639,70 +639,33 @@
34876          | AdapterFailure, ioaddr + EL3_CMD);
34877  }
34878  
34879 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
34880 +static void netdev_get_drvinfo(struct net_device *dev,
34881 +                              struct ethtool_drvinfo *info)
34882  {
34883 -       u32 ethcmd;
34884 -
34885 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
34886 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
34887 -
34888 -       if (get_user(ethcmd, (u32 *)useraddr))
34889 -               return -EFAULT;
34890 -
34891 -       switch (ethcmd) {
34892 -
34893 -       case ETHTOOL_GDRVINFO: {
34894 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
34895 -               strcpy (info.driver, DRV_NAME);
34896 -               strcpy (info.version, DRV_VERSION);
34897 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
34898 -               if (copy_to_user (useraddr, &info, sizeof (info)))
34899 -                       return -EFAULT;
34900 -               return 0;
34901 -       }
34902 +       strcpy(info->driver, DRV_NAME);
34903 +       strcpy(info->version, DRV_VERSION);
34904 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
34905 +}
34906  
34907  #ifdef PCMCIA_DEBUG
34908 -       /* get message-level */
34909 -       case ETHTOOL_GMSGLVL: {
34910 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
34911 -               edata.data = pc_debug;
34912 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
34913 -                       return -EFAULT;
34914 -               return 0;
34915 -       }
34916 -       /* set message-level */
34917 -       case ETHTOOL_SMSGLVL: {
34918 -               struct ethtool_value edata;
34919 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
34920 -                       return -EFAULT;
34921 -               pc_debug = edata.data;
34922 -               return 0;
34923 -       }
34924 -#endif
34925 -
34926 -       default:
34927 -               break;
34928 -       }
34929 -
34930 -       return -EOPNOTSUPP;
34931 +static u32 netdev_get_msglevel(struct net_device *dev)
34932 +{
34933 +       return pc_debug;
34934  }
34935  
34936 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
34937 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
34938  {
34939 -       int rc;
34940 -
34941 -       switch (cmd) {
34942 -       case SIOCETHTOOL:
34943 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
34944 -               break;
34945 -
34946 -       default:
34947 -               rc = -EOPNOTSUPP;
34948 -               break;
34949 -       }
34950 -
34951 -       return rc;
34952 +       pc_debug = level;
34953  }
34954 +#endif /* PCMCIA_DEBUG */
34955 +
34956 +static struct ethtool_ops netdev_ethtool_ops = {
34957 +       .get_drvinfo            = netdev_get_drvinfo,
34958 +#ifdef PCMCIA_DEBUG
34959 +       .get_msglevel           = netdev_get_msglevel,
34960 +       .set_msglevel           = netdev_set_msglevel,
34961 +#endif /* PCMCIA_DEBUG */
34962 +};
34963  
34964  static int el3_config(struct net_device *dev, struct ifmap *map)
34965  {
34966 diff -Nru a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
34967 --- a/drivers/net/pcmcia/axnet_cs.c     Tue Aug 19 20:55:09 2003
34968 +++ b/drivers/net/pcmcia/axnet_cs.c     Sun Aug 31 05:20:58 2003
34969 @@ -98,6 +98,7 @@
34970  static int axnet_open(struct net_device *dev);
34971  static int axnet_close(struct net_device *dev);
34972  static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
34973 +static struct ethtool_ops netdev_ethtool_ops;
34974  static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
34975  static void ei_watchdog(u_long arg);
34976  static void axnet_reset_8390(struct net_device *dev);
34977 @@ -209,6 +210,7 @@
34978      dev->open = &axnet_open;
34979      dev->stop = &axnet_close;
34980      dev->do_ioctl = &axnet_ioctl;
34981 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
34982  
34983      /* Register with Card Services */
34984      link->next = dev_list;
34985 @@ -807,26 +809,16 @@
34986      add_timer(&info->watchdog);
34987  }
34988  
34989 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
34990 +static void netdev_get_drvinfo(struct net_device *dev,
34991 +                              struct ethtool_drvinfo *info)
34992  {
34993 -       u32 ethcmd;
34994 -               
34995 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
34996 -               return -EFAULT;
34997 -       
34998 -       switch (ethcmd) {
34999 -       case ETHTOOL_GDRVINFO: {
35000 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
35001 -               strncpy(info.driver, "axnet_cs", sizeof(info.driver)-1);
35002 -               if (copy_to_user(useraddr, &info, sizeof(info)))
35003 -                       return -EFAULT;
35004 -               return 0;
35005 -       }
35006 -       }
35007 -       
35008 -       return -EOPNOTSUPP;
35009 +       strcpy(info->driver, "axnet_cs");
35010  }
35011  
35012 +static struct ethtool_ops netdev_ethtool_ops = {
35013 +       .get_drvinfo            = netdev_get_drvinfo,
35014 +};
35015 +
35016  /*====================================================================*/
35017  
35018  static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
35019 @@ -835,14 +827,12 @@
35020      u16 *data = (u16 *)&rq->ifr_data;
35021      ioaddr_t mii_addr = dev->base_addr + AXNET_MII_EEP;
35022      switch (cmd) {
35023 -    case SIOCETHTOOL:
35024 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
35025 -    case SIOCDEVPRIVATE:
35026 +    case SIOCGMIIPHY:
35027         data[0] = info->phy_id;
35028 -    case SIOCDEVPRIVATE+1:
35029 +    case SIOCGMIIREG:          /* Read MII PHY register. */
35030         data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
35031         return 0;
35032 -    case SIOCDEVPRIVATE+2:
35033 +    case SIOCSMIIREG:          /* Write MII PHY register. */
35034         if (!capable(CAP_NET_ADMIN))
35035             return -EPERM;
35036         mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
35037 diff -Nru a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
35038 --- a/drivers/net/pcmcia/fmvj18x_cs.c   Tue Aug 19 20:55:09 2003
35039 +++ b/drivers/net/pcmcia/fmvj18x_cs.c   Tue Aug 26 14:51:25 2003
35040 @@ -113,7 +113,7 @@
35041  static struct net_device_stats *fjn_get_stats(struct net_device *dev);
35042  static void set_rx_mode(struct net_device *dev);
35043  static void fjn_tx_timeout(struct net_device *dev);
35044 -static int fjn_ioctl(struct net_device *, struct ifreq *, int);
35045 +static struct ethtool_ops netdev_ethtool_ops;
35046  
35047  static dev_info_t dev_info = "fmvj18x_cs";
35048  static dev_link_t *dev_list;
35049 @@ -312,7 +312,7 @@
35050      dev->tx_timeout = fjn_tx_timeout;
35051      dev->watchdog_timeo = TX_TIMEOUT;
35052  #endif
35053 -    dev->do_ioctl = fjn_ioctl;
35054 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
35055      
35056      /* Register with Card Services */
35057      link->next = dev_list;
35058 @@ -1186,64 +1186,33 @@
35059  
35060  /*====================================================================*/
35061  
35062 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
35063 +static void netdev_get_drvinfo(struct net_device *dev,
35064 +                              struct ethtool_drvinfo *info)
35065  {
35066 -       u32 ethcmd;
35067 -
35068 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
35069 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
35070 -
35071 -       if (get_user(ethcmd, (u32 *)useraddr))
35072 -               return -EFAULT;
35073 -
35074 -       switch (ethcmd) {
35075 -
35076 -       case ETHTOOL_GDRVINFO: {
35077 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
35078 -               strcpy (info.driver, DRV_NAME);
35079 -               strcpy (info.version, DRV_VERSION);
35080 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
35081 -               if (copy_to_user (useraddr, &info, sizeof (info)))
35082 -                       return -EFAULT;
35083 -               return 0;
35084 -       }
35085 +       strcpy(info->driver, DRV_NAME);
35086 +       strcpy(info->version, DRV_VERSION);
35087 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
35088 +}
35089  
35090  #ifdef PCMCIA_DEBUG
35091 -       /* get message-level */
35092 -       case ETHTOOL_GMSGLVL: {
35093 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
35094 -               edata.data = pc_debug;
35095 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
35096 -                       return -EFAULT;
35097 -               return 0;
35098 -       }
35099 -       /* set message-level */
35100 -       case ETHTOOL_SMSGLVL: {
35101 -               struct ethtool_value edata;
35102 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
35103 -                       return -EFAULT;
35104 -               pc_debug = edata.data;
35105 -               return 0;
35106 -       }
35107 -#endif
35108 -
35109 -       default:
35110 -               break;
35111 -       }
35112 -
35113 -       return -EOPNOTSUPP;
35114 +static u32 netdev_get_msglevel(struct net_device *dev)
35115 +{
35116 +       return pc_debug;
35117  }
35118  
35119 -static int fjn_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
35120 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
35121  {
35122 -       switch (cmd) {
35123 -       case SIOCETHTOOL:
35124 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
35125 -
35126 -       default:
35127 -               return -EOPNOTSUPP;
35128 -       }
35129 +       pc_debug = level;
35130  }
35131 +#endif /* PCMCIA_DEBUG */
35132 +
35133 +static struct ethtool_ops netdev_ethtool_ops = {
35134 +       .get_drvinfo            = netdev_get_drvinfo,
35135 +#ifdef PCMCIA_DEBUG
35136 +       .get_msglevel           = netdev_get_msglevel,
35137 +       .set_msglevel           = netdev_set_msglevel,
35138 +#endif /* PCMCIA_DEBUG */
35139 +};
35140  
35141  static int fjn_config(struct net_device *dev, struct ifmap *map){
35142      return 0;
35143 diff -Nru a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
35144 --- a/drivers/net/pcmcia/ibmtr_cs.c     Tue Aug 19 20:55:09 2003
35145 +++ b/drivers/net/pcmcia/ibmtr_cs.c     Tue Aug 26 14:51:25 2003
35146 @@ -157,36 +157,15 @@
35147      }
35148  }
35149  
35150 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
35151 +static void netdev_get_drvinfo(struct net_device *dev,
35152 +                              struct ethtool_drvinfo *info)
35153  {
35154 -       u32 ethcmd;
35155 -               
35156 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
35157 -               return -EFAULT;
35158 -       
35159 -       switch (ethcmd) {
35160 -       case ETHTOOL_GDRVINFO: {
35161 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
35162 -               strncpy(info.driver, "ibmtr_cs", sizeof(info.driver)-1);
35163 -               if (copy_to_user(useraddr, &info, sizeof(info)))
35164 -                       return -EFAULT;
35165 -               return 0;
35166 -       }
35167 -       }
35168 -       
35169 -       return -EOPNOTSUPP;
35170 +       strcpy(info->driver, "ibmtr_cs");
35171  }
35172  
35173 -static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
35174 -{
35175 -
35176 -       switch(cmd) {
35177 -       case SIOCETHTOOL:
35178 -              return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
35179 -       default:
35180 -           return -EOPNOTSUPP;
35181 -       }
35182 -}
35183 +static struct ethtool_ops netdev_ethtool_ops = {
35184 +       .get_drvinfo            = netdev_get_drvinfo,
35185 +};
35186  
35187  /*======================================================================
35188  
35189 @@ -235,7 +214,7 @@
35190      link->irq.Instance = info->dev = dev;
35191      
35192      dev->init = &ibmtr_probe;
35193 -    dev->do_ioctl = &private_ioctl;
35194 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
35195  
35196      /* Register with Card Services */
35197      link->next = dev_list;
35198 diff -Nru a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
35199 --- a/drivers/net/pcmcia/nmclan_cs.c    Tue Aug 19 20:55:09 2003
35200 +++ b/drivers/net/pcmcia/nmclan_cs.c    Tue Aug 26 14:51:25 2003
35201 @@ -442,7 +442,8 @@
35202  static int mace_rx(struct net_device *dev, unsigned char RxCnt);
35203  static void restore_multicast_list(struct net_device *dev);
35204  static void set_multicast_list(struct net_device *dev);
35205 -static int mace_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
35206 +static struct ethtool_ops netdev_ethtool_ops;
35207 +
35208  
35209  static dev_link_t *nmclan_attach(void);
35210  static void nmclan_detach(dev_link_t *);
35211 @@ -515,7 +516,7 @@
35212      dev->set_config = &mace_config;
35213      dev->get_stats = &mace_get_stats;
35214      dev->set_multicast_list = &set_multicast_list;
35215 -    dev->do_ioctl = &mace_ioctl;
35216 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
35217      dev->open = &mace_open;
35218      dev->stop = &mace_close;
35219  #ifdef HAVE_TX_TIMEOUT
35220 @@ -1014,65 +1015,33 @@
35221    return 0;
35222  } /* mace_close */
35223  
35224 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
35225 +static void netdev_get_drvinfo(struct net_device *dev,
35226 +                              struct ethtool_drvinfo *info)
35227  {
35228 -       u32 ethcmd;
35229 -
35230 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
35231 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
35232 -
35233 -       if (get_user(ethcmd, (u32 *)useraddr))
35234 -               return -EFAULT;
35235 -
35236 -       switch (ethcmd) {
35237 -
35238 -       case ETHTOOL_GDRVINFO: {
35239 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
35240 -               strcpy (info.driver, DRV_NAME);
35241 -               strcpy (info.version, DRV_VERSION);
35242 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
35243 -               if (copy_to_user (useraddr, &info, sizeof (info)))
35244 -                       return -EFAULT;
35245 -               return 0;
35246 -       }
35247 +       strcpy(info->driver, DRV_NAME);
35248 +       strcpy(info->version, DRV_VERSION);
35249 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
35250 +}
35251  
35252  #ifdef PCMCIA_DEBUG
35253 -       /* get message-level */
35254 -       case ETHTOOL_GMSGLVL: {
35255 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
35256 -               edata.data = pc_debug;
35257 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
35258 -                       return -EFAULT;
35259 -               return 0;
35260 -       }
35261 -       /* set message-level */
35262 -       case ETHTOOL_SMSGLVL: {
35263 -               struct ethtool_value edata;
35264 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
35265 -                       return -EFAULT;
35266 -               pc_debug = edata.data;
35267 -               return 0;
35268 -       }
35269 -#endif
35270 -
35271 -       default:
35272 -               break;
35273 -       }
35274 -
35275 -       return -EOPNOTSUPP;
35276 +static u32 netdev_get_msglevel(struct net_device *dev)
35277 +{
35278 +       return pc_debug;
35279  }
35280  
35281 -static int mace_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
35282 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
35283  {
35284 -       switch (cmd) {
35285 -       case SIOCETHTOOL:
35286 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
35287 -
35288 -       default:
35289 -               return -EOPNOTSUPP;
35290 -       }
35291 -       return 0;
35292 +       pc_debug = level;
35293  }
35294 +#endif /* PCMCIA_DEBUG */
35295 +
35296 +static struct ethtool_ops netdev_ethtool_ops = {
35297 +       .get_drvinfo            = netdev_get_drvinfo,
35298 +#ifdef PCMCIA_DEBUG
35299 +       .get_msglevel           = netdev_get_msglevel,
35300 +       .set_msglevel           = netdev_set_msglevel,
35301 +#endif /* PCMCIA_DEBUG */
35302 +};
35303  
35304  /* ----------------------------------------------------------------------------
35305  mace_start_xmit
35306 diff -Nru a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
35307 --- a/drivers/net/pcmcia/pcnet_cs.c     Tue Aug 19 20:55:09 2003
35308 +++ b/drivers/net/pcmcia/pcnet_cs.c     Sun Aug 31 05:20:58 2003
35309 @@ -116,7 +116,7 @@
35310  static int pcnet_open(struct net_device *dev);
35311  static int pcnet_close(struct net_device *dev);
35312  static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
35313 -static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd);
35314 +static struct ethtool_ops netdev_ethtool_ops;
35315  static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
35316  static void ei_watchdog(u_long arg);
35317  static void pcnet_reset_8390(struct net_device *dev);
35318 @@ -756,6 +756,7 @@
35319  
35320      strcpy(info->node.dev_name, dev->name);
35321      link->dev = &info->node;
35322 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
35323  
35324      if (info->flags & (IS_DL10019|IS_DL10022)) {
35325         u_char id = inb(dev->base_addr + 0x1a);
35326 @@ -769,7 +770,6 @@
35327             printk("PNA, ");
35328      } else {
35329         printk(KERN_INFO "%s: NE2000 Compatible: ", dev->name);
35330 -       dev->do_ioctl = &do_ioctl_light;        
35331      }
35332      printk("io %#3lx, irq %d,", dev->base_addr, dev->irq);
35333      if (info->flags & USE_SHMEM)
35334 @@ -1205,26 +1205,16 @@
35335  
35336  /*====================================================================*/
35337  
35338 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
35339 +static void netdev_get_drvinfo(struct net_device *dev,
35340 +                              struct ethtool_drvinfo *info)
35341  {
35342 -       u32 ethcmd;
35343 -       
35344 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
35345 -               return -EFAULT;
35346 -       
35347 -       switch (ethcmd) {
35348 -       case ETHTOOL_GDRVINFO: {
35349 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
35350 -               strncpy(info.driver, "pcnet_cs", sizeof(info.driver)-1);
35351 -               if (copy_to_user(useraddr, &info, sizeof(info)))
35352 -                       return -EFAULT;
35353 -               return 0;
35354 -       }
35355 -       }
35356 -       
35357 -       return -EOPNOTSUPP;
35358 +       strcpy(info->driver, "pcnet_cs");
35359  }
35360  
35361 +static struct ethtool_ops netdev_ethtool_ops = {
35362 +       .get_drvinfo            = netdev_get_drvinfo,
35363 +};
35364 +
35365  /*====================================================================*/
35366  
35367  
35368 @@ -1234,31 +1224,18 @@
35369      u16 *data = (u16 *)&rq->ifr_data;
35370      ioaddr_t mii_addr = dev->base_addr + DLINK_GPIO;
35371      switch (cmd) {
35372 -    case SIOCETHTOOL:
35373 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
35374 -    case SIOCDEVPRIVATE:
35375 +    case SIOCGMIIPHY:
35376         data[0] = info->phy_id;
35377 -    case SIOCDEVPRIVATE+1:
35378 +    case SIOCGMIIREG:          /* Read MII PHY register. */
35379         data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
35380         return 0;
35381 -    case SIOCDEVPRIVATE+2:
35382 +    case SIOCSMIIREG:          /* Write MII PHY register. */
35383         if (!capable(CAP_NET_ADMIN))
35384             return -EPERM;
35385         mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
35386         return 0;
35387      }
35388      return -EOPNOTSUPP;
35389 -}
35390 -
35391 -/*====================================================================*/
35392 -
35393 -static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd)
35394 -{
35395 -    switch (cmd) {
35396 -        case SIOCETHTOOL:
35397 -            return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
35398 -    }      
35399 -    return -EOPNOTSUPP;    
35400  }
35401  
35402  /*====================================================================*/
35403 diff -Nru a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
35404 --- a/drivers/net/pcmcia/xirc2ps_cs.c   Tue Aug 19 20:55:09 2003
35405 +++ b/drivers/net/pcmcia/xirc2ps_cs.c   Sun Aug 31 05:20:58 2003
35406 @@ -382,6 +382,7 @@
35407  static int do_config(struct net_device *dev, struct ifmap *map);
35408  static int do_open(struct net_device *dev);
35409  static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
35410 +static struct ethtool_ops netdev_ethtool_ops;
35411  static void hardreset(struct net_device *dev);
35412  static void do_reset(struct net_device *dev, int full);
35413  static int init_mii(struct net_device *dev);
35414 @@ -626,6 +627,7 @@
35415      dev->set_config = &do_config;
35416      dev->get_stats = &do_get_stats;
35417      dev->do_ioctl = &do_ioctl;
35418 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
35419      dev->set_multicast_list = &set_multicast_list;
35420      dev->open = &do_open;
35421      dev->stop = &do_stop;
35422 @@ -1699,26 +1701,16 @@
35423      return 0;
35424  }
35425  
35426 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
35427 +static void netdev_get_drvinfo(struct net_device *dev,
35428 +                              struct ethtool_drvinfo *info)
35429  {
35430 -       u32 ethcmd;
35431 -               
35432 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
35433 -               return -EFAULT;
35434 -       
35435 -       switch (ethcmd) {
35436 -       case ETHTOOL_GDRVINFO: {
35437 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
35438 -               strncpy(info.driver, "xirc2ps_cs", sizeof(info.driver)-1);
35439 -               if (copy_to_user(useraddr, &info, sizeof(info)))
35440 -                       return -EFAULT;
35441 -               return 0;
35442 -       }
35443 -       }
35444 -       
35445 -       return -EOPNOTSUPP;
35446 +       strcpy(info->driver, "xirc2ps_cs");
35447  }
35448  
35449 +static struct ethtool_ops netdev_ethtool_ops = {
35450 +       .get_drvinfo            = netdev_get_drvinfo,
35451 +};
35452 +
35453  static int
35454  do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
35455  {
35456 @@ -1734,15 +1726,13 @@
35457         return -EOPNOTSUPP;
35458  
35459      switch(cmd) {
35460 -      case SIOCETHTOOL:
35461 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
35462 -      case SIOCDEVPRIVATE:     /* Get the address of the PHY in use. */
35463 +      case SIOCGMIIPHY:                /* Get the address of the PHY in use. */
35464         data[0] = 0;            /* we have only this address */
35465         /* fall trough */
35466 -      case SIOCDEVPRIVATE+1:   /* Read the specified MII register. */
35467 +      case SIOCGMIIREG:                /* Read the specified MII register. */
35468         data[3] = mii_rd(ioaddr, data[0] & 0x1f, data[1] & 0x1f);
35469         break;
35470 -      case SIOCDEVPRIVATE+2:   /* Write the specified MII register */
35471 +      case SIOCSMIIREG:                /* Write the specified MII register */
35472         if (!capable(CAP_NET_ADMIN))
35473             return -EPERM;
35474         mii_wr(ioaddr, data[0] & 0x1f, data[1] & 0x1f, data[2], 16);
35475 diff -Nru a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
35476 --- a/drivers/net/pcnet32.c     Tue Aug 19 20:53:16 2003
35477 +++ b/drivers/net/pcnet32.c     Sun Aug 31 16:14:08 2003
35478 @@ -1726,6 +1726,7 @@
35479  /* An additional parameter that may be passed in... */
35480  static int debug = -1;
35481  static int tx_start_pt = -1;
35482 +static int pcnet32_have_pci;
35483  
35484  static int __init pcnet32_init_module(void)
35485  {
35486 @@ -1738,7 +1739,8 @@
35487         tx_start = tx_start_pt;
35488  
35489      /* find the PCI devices */
35490 -    pci_module_init(&pcnet32_driver);
35491 +    if (!pci_module_init(&pcnet32_driver))
35492 +       pcnet32_have_pci = 1;
35493  
35494      /* should we find any remaining VLbus devices ? */
35495      if (pcnet32vlb)
35496 @@ -1747,7 +1749,7 @@
35497      if (cards_found)
35498         printk(KERN_INFO PFX "%d cards_found.\n", cards_found);
35499      
35500 -    return cards_found ? 0 : -ENODEV;
35501 +    return (pcnet32_have_pci + cards_found) ? 0 : -ENODEV;
35502  }
35503  
35504  static void __exit pcnet32_cleanup_module(void)
35505 @@ -1765,6 +1767,9 @@
35506         free_netdev(pcnet32_dev);
35507         pcnet32_dev = next_dev;
35508      }
35509 +
35510 +    if (pcnet32_have_pci)
35511 +       pci_unregister_driver(&pcnet32_driver);
35512  }
35513  
35514  module_init(pcnet32_init_module);
35515 diff -Nru a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
35516 --- a/drivers/net/seeq8005.c    Thu Aug 21 00:05:02 2003
35517 +++ b/drivers/net/seeq8005.c    Sun Aug 31 06:34:16 2003
35518 @@ -378,7 +378,7 @@
35519  {
35520         struct net_local *lp = (struct net_local *)dev->priv;
35521         short length = skb->len;
35522 -       unsigned char *buf = skb->data;
35523 +       unsigned char *buf;
35524  
35525         if (length < ETH_ZLEN) {
35526                 skb = skb_padto(skb, ETH_ZLEN);
35527 @@ -386,6 +386,8 @@
35528                         return 0;
35529                 length = ETH_ZLEN;
35530         }
35531 +       buf = skb->data;
35532 +
35533         /* Block a timer-based transmit from overlapping */
35534         netif_stop_queue(dev);
35535         
35536 diff -Nru a/drivers/net/sis190.c b/drivers/net/sis190.c
35537 --- a/drivers/net/sis190.c      Tue Aug 19 20:53:16 2003
35538 +++ b/drivers/net/sis190.c      Sun Aug 31 14:10:18 2003
35539 @@ -76,6 +76,8 @@
35540  
35541  #define NUM_TX_DESC    64      /* Number of Tx descriptor registers */
35542  #define NUM_RX_DESC    64      /* Number of Rx descriptor registers */
35543 +#define TX_DESC_TOTAL_SIZE     (NUM_TX_DESC * sizeof (struct TxDesc))
35544 +#define RX_DESC_TOTAL_SIZE     (NUM_RX_DESC * sizeof (struct RxDesc))
35545  #define RX_BUF_SIZE    1536    /* Rx Buffer size */
35546  
35547  #define SiS190_MIN_IO_SIZE 0x80
35548 @@ -311,12 +313,8 @@
35549         unsigned long cur_rx;   /* Index into the Rx descriptor buffer of next Rx pkt. */
35550         unsigned long cur_tx;   /* Index into the Tx descriptor buffer of next Rx pkt. */
35551         unsigned long dirty_tx;
35552 -       void *tx_desc_raw;              /* Tx descriptor buffer */
35553 -       dma_addr_t tx_dma_raw;
35554 -       dma_addr_t tx_dma_aligned;
35555 -       void *rx_desc_raw;              /* Rx descriptor buffer */
35556 -       dma_addr_t rx_dma_raw;
35557 -       dma_addr_t rx_dma_aligned;
35558 +       dma_addr_t tx_dma;
35559 +       dma_addr_t rx_dma;
35560         struct TxDesc *TxDescArray;     /* Index of 256-alignment Tx Descriptor buffer */
35561         struct RxDesc *RxDescArray;     /* Index of 256-alignment Rx Descriptor buffer */
35562         unsigned char *RxBufferRings;   /* Index of Rx Buffer  */
35563 @@ -470,6 +468,10 @@
35564         if (rc)
35565                 goto err_out;
35566  
35567 +       rc = pci_set_dma_mask(pdev, 0xffffffffULL);
35568 +       if (rc)
35569 +               goto err_out;
35570 +
35571         mmio_start = pci_resource_start(pdev, 0);
35572         mmio_end = pci_resource_end(pdev, 0);
35573         mmio_flags = pci_resource_flags(pdev, 0);
35574 @@ -521,7 +523,6 @@
35575  
35576  err_out:
35577         pci_disable_device(pdev);
35578 -       unregister_netdev(dev);
35579         kfree(dev);
35580         return rc;
35581  }
35582 @@ -536,6 +537,7 @@
35583         static int printed_version = 0;
35584         int i, rc;
35585         u16 reg31;
35586 +       int val;
35587  
35588         assert(pdev != NULL);
35589         assert(ent != NULL);
35590 @@ -620,7 +622,7 @@
35591                dev->dev_addr[2], dev->dev_addr[3],
35592                dev->dev_addr[4], dev->dev_addr[5], dev->irq);
35593  
35594 -       int val = smdio_read(ioaddr, PHY_AUTO_NEGO_REG);
35595 +       val = smdio_read(ioaddr, PHY_AUTO_NEGO_REG);
35596  
35597         printk(KERN_INFO "%s: Auto-negotiation Enabled.\n", dev->name);
35598  
35599 @@ -714,54 +716,50 @@
35600  SiS190_open(struct net_device *dev)
35601  {
35602         struct sis190_private *tp = dev->priv;
35603 -       int retval;
35604 -       u8 diff;
35605         int rc;
35606  
35607 -       retval =
35608 -           request_irq(dev->irq, SiS190_interrupt, SA_SHIRQ, dev->name, dev);
35609 -       if (retval) {
35610 -               return retval;
35611 -       }
35612 +       rc = request_irq(dev->irq, SiS190_interrupt, SA_SHIRQ, dev->name, dev);
35613 +       if (rc)
35614 +               goto out;
35615  
35616 -       tp->tx_desc_raw = pci_alloc_consistent(tp->pci_dev,
35617 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
35618 -               &tp->tx_dma_raw);
35619 -       if (!tp->tx_desc_raw) {
35620 +       /*
35621 +        * Rx and Tx descriptors need 256 bytes alignment.
35622 +        * pci_alloc_consistent() guarantees a stronger alignment.
35623 +        */
35624 +       tp->TxDescArray = pci_alloc_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE,
35625 +               &tp->tx_dma);
35626 +       if (!tp->TxDescArray) {
35627                 rc = -ENOMEM;
35628                 goto err_out;
35629         }
35630 -       // Tx Desscriptor needs 256 bytes alignment;
35631 -       diff = 256 - (tp->tx_dma_raw - ((tp->tx_dma_raw >> 8) << 8));
35632 -       tp->tx_dma_aligned = tp->tx_dma_raw + diff;
35633 -       tp->TxDescArray = (struct TxDesc *) (tp->tx_desc_raw + diff);
35634 -
35635 -       tp->rx_desc_raw = pci_alloc_consistent(tp->pci_dev,
35636 -               (NUM_RX_DESC * sizeof (struct RxDesc)) + 256,
35637 -               &tp->rx_dma_raw);
35638 -       if (!tp->rx_desc_raw) {
35639 +
35640 +       tp->RxDescArray = pci_alloc_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE,
35641 +               &tp->rx_dma);
35642 +       if (!tp->RxDescArray) {
35643                 rc = -ENOMEM;
35644                 goto err_out_free_tx;
35645         }
35646 -       // Rx Desscriptor needs 256 bytes alignment;
35647 -       diff = 256 - (tp->rx_dma_raw - ((tp->rx_dma_raw >> 8) << 8));
35648 -       tp->rx_dma_aligned = tp->rx_dma_raw + diff;
35649 -       tp->RxDescArray = (struct RxDesc *) (tp->rx_desc_raw + diff);
35650  
35651         tp->RxBufferRings = kmalloc(RX_BUF_SIZE * NUM_RX_DESC, GFP_KERNEL);
35652         if (tp->RxBufferRings == NULL) {
35653 -               printk(KERN_INFO "Allocate RxBufferRing failed\n");
35654 +               printk(KERN_INFO "%s: allocate RxBufferRing failed\n",
35655 +                       dev->name);
35656 +               rc = -ENOMEM;
35657 +               goto err_out_free_rx;
35658         }
35659  
35660         SiS190_init_ring(dev);
35661         SiS190_hw_start(dev);
35662  
35663 -       return 0;
35664 +out:
35665 +       return rc;
35666  
35667 +err_out_free_rx:
35668 +       pci_free_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE, tp->RxDescArray,
35669 +               tp->rx_dma);
35670  err_out_free_tx:
35671 -       pci_free_consistent(tp->pci_dev,
35672 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
35673 -               tp->tx_desc_raw, tp->tx_dma_raw);
35674 +       pci_free_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE, tp->TxDescArray,
35675 +               tp->tx_dma);
35676  err_out:
35677         free_irq(dev->irq, dev);
35678         return rc;
35679 @@ -780,10 +778,10 @@
35680         SiS_W32(IntrControl, 0x0);
35681  
35682         SiS_W32(0x0, 0x01a00);
35683 -       SiS_W32(0x4, tp->tx_dma_aligned);
35684 +       SiS_W32(0x4, tp->tx_dma);
35685  
35686         SiS_W32(0x10, 0x1a00);
35687 -       SiS_W32(0x14, tp->rx_dma_aligned);
35688 +       SiS_W32(0x14, tp->rx_dma);
35689  
35690         SiS_W32(0x20, 0xffffffff);
35691         SiS_W32(0x24, 0x0);
35692 @@ -830,19 +828,19 @@
35693                 tp->Tx_skbuff[i] = NULL;
35694         }
35695         for (i = 0; i < NUM_RX_DESC; i++) {
35696 +               struct RxDesc *desc = tp->RxDescArray + i;
35697  
35698 -               tp->RxDescArray[i].PSize = 0x0;
35699 +               desc->PSize = 0x0;
35700  
35701                 if (i == (NUM_RX_DESC - 1))
35702 -                       tp->RxDescArray[i].buf_Len = BIT_31 + RX_BUF_SIZE;      //bit 31 is End bit
35703 +                       desc->buf_Len = BIT_31 + RX_BUF_SIZE;   //bit 31 is End bit
35704                 else
35705 -                       tp->RxDescArray[i].buf_Len = RX_BUF_SIZE;
35706 -
35707 -#warning Replace virt_to_bus with DMA mapping
35708 -               tp->RxBufferRing[i] = &(tp->RxBufferRings[i * RX_BUF_SIZE]);
35709 -               tp->RxDescArray[i].buf_addr = virt_to_bus(tp->RxBufferRing[i]);
35710 -               tp->RxDescArray[i].status = OWNbit | INTbit;
35711 +                       desc->buf_Len = RX_BUF_SIZE;
35712  
35713 +               tp->RxBufferRing[i] = tp->RxBufferRings + i * RX_BUF_SIZE;
35714 +               desc->buf_addr = pci_map_single(tp->pci_dev,
35715 +                       tp->RxBufferRing[i], RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
35716 +               desc->status = OWNbit | INTbit;
35717         }
35718  
35719  }
35720 @@ -855,7 +853,14 @@
35721         tp->cur_tx = 0;
35722         for (i = 0; i < NUM_TX_DESC; i++) {
35723                 if (tp->Tx_skbuff[i] != NULL) {
35724 -                       dev_kfree_skb(tp->Tx_skbuff[i]);
35725 +                       struct sk_buff *skb;
35726 +
35727 +                       skb = tp->Tx_skbuff[i];
35728 +                       pci_unmap_single(tp->pci_dev,
35729 +                               le32_to_cpu(tp->TxDescArray[i].buf_addr),
35730 +                               skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len,
35731 +                               PCI_DMA_TODEVICE);
35732 +                       dev_kfree_skb(skb);
35733                         tp->Tx_skbuff[i] = NULL;
35734                         tp->stats.tx_dropped++;
35735                 }
35736 @@ -894,46 +899,58 @@
35737         struct sis190_private *tp = dev->priv;
35738         void *ioaddr = tp->mmio_addr;
35739         int entry = tp->cur_tx % NUM_TX_DESC;
35740 +       u32 len;
35741  
35742 -       if (skb->len < ETH_ZLEN) {
35743 +       if (unlikely(skb->len < ETH_ZLEN)) {
35744                 skb = skb_padto(skb, ETH_ZLEN);
35745                 if (skb == NULL)
35746 -                       return 0;
35747 +                       goto drop_tx;
35748 +               len = ETH_ZLEN;
35749 +       } else {
35750 +               len = skb->len;
35751         }
35752  
35753         spin_lock_irq(&tp->lock);
35754  
35755 -       if ((tp->TxDescArray[entry].status & OWNbit) == 0) {
35756 -#warning Replace virt_to_bus with DMA mapping
35757 +       if ((le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit) == 0) {
35758 +               dma_addr_t mapping;
35759 +
35760 +               mapping = pci_map_single(tp->pci_dev, skb->data, len,
35761 +                                        PCI_DMA_TODEVICE);
35762 +
35763                 tp->Tx_skbuff[entry] = skb;
35764 -               tp->TxDescArray[entry].buf_addr = virt_to_bus(skb->data);
35765 -               tp->TxDescArray[entry].PSize =
35766 -                   ((skb->len > ETH_ZLEN) ? skb->len : ETH_ZLEN);
35767 +               tp->TxDescArray[entry].buf_addr = cpu_to_le32(mapping);
35768 +               tp->TxDescArray[entry].PSize = cpu_to_le32(len);
35769  
35770 -               if (entry != (NUM_TX_DESC - 1)) {
35771 -                       tp->TxDescArray[entry].buf_Len =
35772 -                           tp->TxDescArray[entry].PSize;
35773 -               } else {
35774 +               if (entry != (NUM_TX_DESC - 1))
35775 +                       tp->TxDescArray[entry].buf_Len = cpu_to_le32(len);
35776 +               else
35777                         tp->TxDescArray[entry].buf_Len =
35778 -                           tp->TxDescArray[entry].PSize | ENDbit;
35779 -               }
35780 +                               cpu_to_le32(len | ENDbit);
35781  
35782                 tp->TxDescArray[entry].status |=
35783 -                   (OWNbit | INTbit | DEFbit | CRCbit | PADbit);
35784 +                   cpu_to_le32(OWNbit | INTbit | DEFbit | CRCbit | PADbit);
35785  
35786                 SiS_W32(TxControl, 0x1a11);     //Start Send
35787  
35788                 dev->trans_start = jiffies;
35789  
35790                 tp->cur_tx++;
35791 +       } else {
35792 +               spin_unlock_irq(&tp->lock);
35793 +               goto drop_tx;
35794         }
35795  
35796 +       if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
35797 +               netif_stop_queue(dev);
35798 +
35799         spin_unlock_irq(&tp->lock);
35800  
35801 -       if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx) {
35802 -               netif_stop_queue(dev);
35803 -       }
35804 +       return 0;
35805  
35806 +drop_tx:
35807 +       tp->stats.tx_dropped++;
35808 +       dev_kfree_skb(skb);
35809         return 0;
35810  }
35811  
35812 @@ -952,10 +969,18 @@
35813         tx_left = tp->cur_tx - dirty_tx;
35814  
35815         while (tx_left > 0) {
35816 -               if ((tp->TxDescArray[entry].status & OWNbit) == 0) {
35817 -                       dev_kfree_skb_irq(tp->
35818 -                                         Tx_skbuff[dirty_tx % NUM_TX_DESC]);
35819 -                       tp->Tx_skbuff[dirty_tx % NUM_TX_DESC] = NULL;
35820 +               if ((le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit) == 0) {
35821 +                       struct sk_buff *skb;
35822 +
35823 +                       skb = tp->Tx_skbuff[entry];
35824 +
35825 +                       pci_unmap_single(tp->pci_dev,
35826 +                               le32_to_cpu(tp->TxDescArray[entry].buf_addr),
35827 +                               skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len,
35828 +                               PCI_DMA_TODEVICE);
35829 +
35830 +                       dev_kfree_skb_irq(skb);
35831 +                       tp->Tx_skbuff[entry] = NULL;
35832                         tp->stats.tx_packets++;
35833                         dirty_tx++;
35834                         tx_left--;
35835 @@ -965,8 +990,7 @@
35836  
35837         if (tp->dirty_tx != dirty_tx) {
35838                 tp->dirty_tx = dirty_tx;
35839 -               if (netif_queue_stopped(dev))
35840 -                       netif_wake_queue(dev);
35841 +               netif_wake_queue(dev);
35842         }
35843  }
35844  
35845 @@ -974,29 +998,30 @@
35846  SiS190_rx_interrupt(struct net_device *dev, struct sis190_private *tp,
35847                     void *ioaddr)
35848  {
35849 -       int cur_rx;
35850 -       struct sk_buff *skb;
35851 -       int pkt_size = 0;
35852 +       int cur_rx = tp->cur_rx;
35853 +       struct RxDesc *desc = tp->RxDescArray + cur_rx;
35854  
35855         assert(dev != NULL);
35856         assert(tp != NULL);
35857         assert(ioaddr != NULL);
35858  
35859 -       cur_rx = tp->cur_rx;
35860 -       while ((tp->RxDescArray[cur_rx].status & OWNbit) == 0) {
35861 +       while ((desc->status & OWNbit) == 0) {
35862  
35863 -               if (tp->RxDescArray[cur_rx].PSize & 0x0080000) {
35864 +               if (desc->PSize & 0x0080000) {
35865                         printk(KERN_INFO "%s: Rx ERROR!!!\n", dev->name);
35866                         tp->stats.rx_errors++;
35867                         tp->stats.rx_length_errors++;
35868 -               } else if (!(tp->RxDescArray[cur_rx].PSize & 0x0010000)) {
35869 +               } else if (!(desc->PSize & 0x0010000)) {
35870                         printk(KERN_INFO "%s: Rx ERROR!!!\n", dev->name);
35871                         tp->stats.rx_errors++;
35872                         tp->stats.rx_crc_errors++;
35873                 } else {
35874 -                       pkt_size =
35875 -                           (int) (tp->RxDescArray[cur_rx].
35876 -                                  PSize & 0x0000FFFF) - 4;
35877 +                       struct sk_buff *skb;
35878 +                       int pkt_size;
35879 +
35880 +                       pkt_size = (int) (desc->PSize & 0x0000FFFF) - 4;
35881 +                       pci_dma_sync_single(tp->pci_dev, desc->buf_addr,
35882 +                               RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
35883                         skb = dev_alloc_skb(pkt_size + 2);
35884                         if (skb != NULL) {
35885                                 skb->dev = dev;
35886 @@ -1007,24 +1032,18 @@
35887                                 skb->protocol = eth_type_trans(skb, dev);
35888                                 netif_rx(skb);
35889  
35890 -                               tp->RxDescArray[cur_rx].PSize = 0x0;
35891 +                               desc->PSize = 0x0;
35892  
35893                                 if (cur_rx == (NUM_RX_DESC - 1))
35894 -                                       tp->RxDescArray[cur_rx].buf_Len =
35895 -                                           ENDbit + RX_BUF_SIZE;
35896 +                                       desc->buf_Len = ENDbit + RX_BUF_SIZE;
35897                                 else
35898 -                                       tp->RxDescArray[cur_rx].buf_Len =
35899 -                                           RX_BUF_SIZE;
35900 +                                       desc->buf_Len = RX_BUF_SIZE;
35901  
35902 -#warning Replace virt_to_bus with DMA mapping
35903 -                               tp->RxDescArray[cur_rx].buf_addr =
35904 -                                   virt_to_bus(tp->RxBufferRing[cur_rx]);
35905                                 dev->last_rx = jiffies;
35906                                 tp->stats.rx_bytes += pkt_size;
35907                                 tp->stats.rx_packets++;
35908  
35909 -                               tp->RxDescArray[cur_rx].status =
35910 -                                   OWNbit | INTbit;
35911 +                               desc->status = OWNbit | INTbit;
35912                         } else {
35913                                 printk(KERN_WARNING
35914                                        "%s: Memory squeeze, deferring packet.\n",
35915 @@ -1036,7 +1055,7 @@
35916                 }
35917  
35918                 cur_rx = (cur_rx + 1) % NUM_RX_DESC;
35919 -
35920 +               desc = tp->RxDescArray + cur_rx;
35921         }
35922  
35923         tp->cur_rx = cur_rx;
35924 @@ -1111,22 +1130,22 @@
35925  
35926         spin_unlock_irq(&tp->lock);
35927  
35928 -       synchronize_irq();
35929 +       synchronize_irq(dev->irq);
35930         free_irq(dev->irq, dev);
35931  
35932         SiS190_tx_clear(tp);
35933 -       pci_free_consistent(tp->pci_dev,
35934 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
35935 -               tp->tx_desc_raw, tp->tx_dma_raw);
35936 -       pci_free_consistent(tp->pci_dev,
35937 -               (NUM_RX_DESC * sizeof (struct RxDesc)) + 256,
35938 -               tp->rx_desc_raw, tp->rx_dma_raw);
35939 +       pci_free_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE, tp->TxDescArray,
35940 +               tp->tx_dma);
35941 +       pci_free_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE, tp->RxDescArray,
35942 +               tp->rx_dma);
35943         tp->TxDescArray = NULL;
35944 -       tp->RxDescArray = NULL;
35945 -       kfree(tp->RxBufferRings);
35946         for (i = 0; i < NUM_RX_DESC; i++) {
35947 +               pci_unmap_single(tp->pci_dev, tp->RxDescArray[i].buf_addr,
35948 +                       RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
35949                 tp->RxBufferRing[i] = NULL;
35950         }
35951 +       tp->RxDescArray = NULL;
35952 +       kfree(tp->RxBufferRings);
35953  
35954         return 0;
35955  }
35956 diff -Nru a/drivers/net/sis900.c b/drivers/net/sis900.c
35957 --- a/drivers/net/sis900.c      Tue Aug 19 20:53:16 2003
35958 +++ b/drivers/net/sis900.c      Tue Aug 26 16:37:16 2003
35959 @@ -169,6 +169,7 @@
35960         dma_addr_t rx_ring_dma;
35961  
35962         unsigned int tx_full;                   /* The Tx queue is full.    */
35963 +       u8 host_bridge_rev;
35964  };
35965  
35966  MODULE_AUTHOR("Jim Huang <cmhuang@sis.com.tw>, Ollie Lho <ollie@sis.com.tw>");
35967 @@ -210,6 +211,7 @@
35968  static u16 sis900_reset_phy(struct net_device *net_dev, int phy_addr);
35969  static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr);
35970  static void sis900_set_mode (long ioaddr, int speed, int duplex);
35971 +static struct ethtool_ops sis900_ethtool_ops;
35972  
35973  /**
35974   *     sis900_get_mac_addr - Get MAC address for stand alone SiS900 model
35975 @@ -367,6 +369,7 @@
35976  {
35977         struct sis900_private *sis_priv;
35978         struct net_device *net_dev;
35979 +       struct pci_dev *dev;
35980         dma_addr_t ring_dma;
35981         void *ring_space;
35982         long ioaddr;
35983 @@ -440,6 +443,7 @@
35984         net_dev->do_ioctl = &mii_ioctl;
35985         net_dev->tx_timeout = sis900_tx_timeout;
35986         net_dev->watchdog_timeo = TX_TIMEOUT;
35987 +       net_dev->ethtool_ops = &sis900_ethtool_ops;
35988         
35989         ret = register_netdev(net_dev);
35990         if (ret)
35991 @@ -473,6 +477,11 @@
35992                 goto err_out_unregister;
35993         }
35994  
35995 +       /* save our host bridge revision */
35996 +       dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
35997 +       if (dev)
35998 +               pci_read_config_byte(dev, PCI_CLASS_REVISION, &sis_priv->host_bridge_rev);
35999 +
36000         /* print some information about our NIC */
36001         printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ", net_dev->name,
36002                card_name, ioaddr, net_dev->irq);
36003 @@ -1108,18 +1117,12 @@
36004  {
36005         struct sis900_private *sis_priv = net_dev->priv;
36006         u16 reg14h, eq_value=0, max_value=0, min_value=0;
36007 -       u8 host_bridge_rev;
36008         int i, maxcount=10;
36009 -       struct pci_dev *dev=NULL;
36010  
36011         if ( !(revision == SIS630E_900_REV || revision == SIS630EA1_900_REV ||
36012                revision == SIS630A_900_REV || revision ==  SIS630ET_900_REV) )
36013                 return;
36014  
36015 -       dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, dev);
36016 -       if (dev)
36017 -               pci_read_config_byte(dev, PCI_CLASS_REVISION, &host_bridge_rev);
36018 -
36019         if (netif_carrier_ok(net_dev)) {
36020                 reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
36021                 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (0x2200 | reg14h) & 0xBFFF);
36022 @@ -1142,7 +1145,8 @@
36023                 }
36024                 /* 630B0&B1 rule to determine the equalizer value */
36025                 if (revision == SIS630A_900_REV && 
36026 -                   (host_bridge_rev == SIS630B0 || host_bridge_rev == SIS630B1)) {
36027 +                   (sis_priv->host_bridge_rev == SIS630B0 || 
36028 +                    sis_priv->host_bridge_rev == SIS630B1)) {
36029                         if (max_value == 0)
36030                                 eq_value=3;
36031                         else
36032 @@ -1157,7 +1161,8 @@
36033         else {
36034                 reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
36035                 if (revision == SIS630A_900_REV && 
36036 -                   (host_bridge_rev == SIS630B0 || host_bridge_rev == SIS630B1)) 
36037 +                   (sis_priv->host_bridge_rev == SIS630B0 || 
36038 +                    sis_priv->host_bridge_rev == SIS630B1)) 
36039                         mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (reg14h | 0x2200) & 0xBFFF);
36040                 else
36041                         mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (reg14h | 0x2000) & 0xBFFF);
36042 @@ -1853,39 +1858,27 @@
36043  }
36044  
36045  /**
36046 - *     netdev_ethtool_ioctl - For the basic support of ethtool
36047 - *     @net_dev: the net device to command for
36048 - *     @useraddr: start address of interface request
36049 + *     sis900_get_drvinfo - Return information about driver
36050 + *     @net_dev: the net device to probe
36051 + *     @info: container for info returned
36052   *
36053   *     Process ethtool command such as "ehtool -i" to show information
36054   */
36055 -
36056 -static int netdev_ethtool_ioctl (struct net_device *net_dev, void *useraddr)
36057
36058 +static void sis900_get_drvinfo(struct net_device *net_dev,
36059 +                              struct ethtool_drvinfo *info)
36060  {
36061         struct sis900_private *sis_priv = net_dev->priv;
36062 -       u32 ethcmd;
36063  
36064 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
36065 -               return -EFAULT;
36066 -       
36067 -       switch (ethcmd) {
36068 -       case ETHTOOL_GDRVINFO:
36069 -               {
36070 -                       struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
36071 -                       strcpy (info.driver, SIS900_MODULE_NAME);
36072 -                       strcpy (info.version, SIS900_DRV_VERSION);
36073 -                       strcpy (info.bus_info, pci_name(sis_priv->pci_dev));
36074 -                       if (copy_to_user (useraddr, &info, sizeof (info)))
36075 -                               return -EFAULT;
36076 -                       return 0;
36077 -               }
36078 -       default:
36079 -               break;
36080 -       }
36081 -
36082 -       return -EOPNOTSUPP;
36083 +       strcpy (info->driver, SIS900_MODULE_NAME);
36084 +       strcpy (info->version, SIS900_DRV_VERSION);
36085 +       strcpy (info->bus_info, pci_name(sis_priv->pci_dev));
36086  }
36087  
36088 +static struct ethtool_ops sis900_ethtool_ops = {
36089 +       .get_drvinfo =          sis900_get_drvinfo,
36090 +};
36091 +
36092  /**
36093   *     mii_ioctl - process MII i/o control command 
36094   *     @net_dev: the net device to command for
36095 @@ -1901,9 +1894,6 @@
36096         struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
36097  
36098         switch(cmd) {
36099 -       case SIOCETHTOOL:
36100 -               return netdev_ethtool_ioctl(net_dev, (void *) rq->ifr_data);
36101 -
36102         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
36103                 data->phy_id = sis_priv->mii->phy_addr;
36104                 /* Fall Through */
36105 diff -Nru a/drivers/net/sk_mca.c b/drivers/net/sk_mca.c
36106 --- a/drivers/net/sk_mca.c      Fri Jul 25 17:15:35 2003
36107 +++ b/drivers/net/sk_mca.c      Sun Aug 31 22:50:10 2003
36108 @@ -124,7 +124,7 @@
36109  /* dump parts of shared memory - only needed during debugging */
36110  
36111  #ifdef DEBUG
36112 -static void dumpmem(struct SKMCA_NETDEV *dev, u32 start, u32 len)
36113 +static void dumpmem(struct net_device *dev, u32 start, u32 len)
36114  {
36115         int z;
36116  
36117 @@ -217,7 +217,7 @@
36118  
36119  /* reset the whole board */
36120  
36121 -static void ResetBoard(struct SKMCA_NETDEV *dev)
36122 +static void ResetBoard(struct net_device *dev)
36123  {
36124         skmca_priv *priv = (skmca_priv *) dev->priv;
36125  
36126 @@ -228,7 +228,7 @@
36127  
36128  /* wait for LANCE interface to become not busy */
36129  
36130 -static int WaitLANCE(struct SKMCA_NETDEV *dev)
36131 +static int WaitLANCE(struct net_device *dev)
36132  {
36133         skmca_priv *priv = (skmca_priv *) dev->priv;
36134         int t = 0;
36135 @@ -247,7 +247,7 @@
36136  
36137  /* set LANCE register - must be atomic */
36138  
36139 -static void SetLANCE(struct SKMCA_NETDEV *dev, u16 addr, u16 value)
36140 +static void SetLANCE(struct net_device *dev, u16 addr, u16 value)
36141  {
36142         skmca_priv *priv = (skmca_priv *) dev->priv;
36143         unsigned long flags;
36144 @@ -280,12 +280,12 @@
36145  
36146         /* reenable interrupts */
36147  
36148 -       spin_lock_irqrestore(&priv->lock, flags);
36149 +       spin_unlock_irqrestore(&priv->lock, flags);
36150  }
36151  
36152  /* get LANCE register */
36153  
36154 -static u16 GetLANCE(struct SKMCA_NETDEV *dev, u16 addr)
36155 +static u16 GetLANCE(struct net_device *dev, u16 addr)
36156  {
36157         skmca_priv *priv = (skmca_priv *) dev->priv;
36158         unsigned long flags;
36159 @@ -319,14 +319,14 @@
36160  
36161         /* reenable interrupts */
36162  
36163 -       spin_lock_irqrestore(&priv->lock, flags);
36164 +       spin_unlock_irqrestore(&priv->lock, flags);
36165  
36166         return res;
36167  }
36168  
36169  /* build up descriptors in shared RAM */
36170  
36171 -static void InitDscrs(struct SKMCA_NETDEV *dev)
36172 +static void InitDscrs(struct net_device *dev)
36173  {
36174         u32 bufaddr;
36175  
36176 @@ -422,7 +422,7 @@
36177  
36178  /* feed ready-built initialization block into LANCE */
36179  
36180 -static void InitLANCE(struct SKMCA_NETDEV *dev)
36181 +static void InitLANCE(struct net_device *dev)
36182  {
36183         skmca_priv *priv = (skmca_priv *) dev->priv;
36184  
36185 @@ -452,11 +452,7 @@
36186  
36187         /* we don't get ready until the LANCE has read the init block */
36188  
36189 -#if (LINUX_VERSION_CODE >= 0x02032a)
36190         netif_stop_queue(dev);
36191 -#else
36192 -       dev->tbusy = 1;
36193 -#endif
36194  
36195         /* let LANCE read the initialization block.  LANCE is ready
36196            when we receive the corresponding interrupt. */
36197 @@ -466,15 +462,11 @@
36198  
36199  /* stop the LANCE so we can reinitialize it */
36200  
36201 -static void StopLANCE(struct SKMCA_NETDEV *dev)
36202 +static void StopLANCE(struct net_device *dev)
36203  {
36204         /* can't take frames any more */
36205  
36206 -#if (LINUX_VERSION_CODE >= 0x02032a)
36207         netif_stop_queue(dev);
36208 -#else
36209 -       dev->tbusy = 1;
36210 -#endif
36211  
36212         /* disable interrupts, stop it */
36213  
36214 @@ -483,7 +475,7 @@
36215  
36216  /* initialize card and LANCE for proper operation */
36217  
36218 -static void InitBoard(struct SKMCA_NETDEV *dev)
36219 +static void InitBoard(struct net_device *dev)
36220  {
36221         LANCE_InitBlock block;
36222  
36223 @@ -508,7 +500,7 @@
36224  
36225  /* deinitialize card and LANCE */
36226  
36227 -static void DeinitBoard(struct SKMCA_NETDEV *dev)
36228 +static void DeinitBoard(struct net_device *dev)
36229  {
36230         /* stop LANCE */
36231  
36232 @@ -521,7 +513,7 @@
36233  
36234  /* probe for device's irq */
36235  
36236 -static int __init ProbeIRQ(struct SKMCA_NETDEV *dev)
36237 +static int __init ProbeIRQ(struct net_device *dev)
36238  {
36239         unsigned long imaskval, njiffies, irq;
36240         u16 csr0val;
36241 @@ -563,15 +555,11 @@
36242  
36243  /* LANCE has read initialization block -> start it */
36244  
36245 -static u16 irqstart_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
36246 +static u16 irqstart_handler(struct net_device *dev, u16 oldcsr0)
36247  {
36248         /* now we're ready to transmit */
36249  
36250 -#if (LINUX_VERSION_CODE >= 0x02032a)
36251         netif_wake_queue(dev);
36252 -#else
36253 -       dev->tbusy = 0;
36254 -#endif
36255  
36256         /* reset IDON bit, start LANCE */
36257  
36258 @@ -581,7 +569,7 @@
36259  
36260  /* did we lose blocks due to a FIFO overrun ? */
36261  
36262 -static u16 irqmiss_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
36263 +static u16 irqmiss_handler(struct net_device *dev, u16 oldcsr0)
36264  {
36265         skmca_priv *priv = (skmca_priv *) dev->priv;
36266  
36267 @@ -597,7 +585,7 @@
36268  
36269  /* receive interrupt */
36270  
36271 -static u16 irqrx_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
36272 +static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0)
36273  {
36274         skmca_priv *priv = (skmca_priv *) dev->priv;
36275         LANCE_RxDescr descr;
36276 @@ -678,7 +666,7 @@
36277  
36278  /* transmit interrupt */
36279  
36280 -static u16 irqtx_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
36281 +static u16 irqtx_handler(struct net_device *dev, u16 oldcsr0)
36282  {
36283         skmca_priv *priv = (skmca_priv *) dev->priv;
36284         LANCE_TxDescr descr;
36285 @@ -740,12 +728,7 @@
36286            a new one */
36287         /* inform upper layers we're in business again */
36288  
36289 -#if (LINUX_VERSION_CODE >= 0x02032a)
36290         netif_wake_queue(dev);
36291 -#else
36292 -       dev->tbusy = 0;
36293 -       mark_bh(NET_BH);
36294 -#endif
36295  
36296         return oldcsr0;
36297  }
36298 @@ -754,7 +737,7 @@
36299  
36300  static irqreturn_t irq_handler(int irq, void *device, struct pt_regs *regs)
36301  {
36302 -       struct SKMCA_NETDEV *dev = (struct SKMCA_NETDEV *) device;
36303 +       struct net_device *dev = (struct net_device *) device;
36304         u16 csr0val;
36305  
36306         /* read CSR0 to get interrupt cause */
36307 @@ -766,13 +749,9 @@
36308         if ((csr0val & CSR0_INTR) == 0)
36309                 return IRQ_NONE;
36310  
36311 -#if (LINUX_VERSION_CODE >= 0x02032a)
36312  #if 0
36313         set_bit(LINK_STATE_RXSEM, &dev->state);
36314  #endif
36315 -#else
36316 -       dev->interrupt = 1;
36317 -#endif
36318  
36319         /* loop through the interrupt bits until everything is clear */
36320  
36321 @@ -796,13 +775,9 @@
36322         }
36323         while ((csr0val & CSR0_INTR) != 0);
36324  
36325 -#if (LINUX_VERSION_CODE >= 0x02032a)
36326  #if 0
36327         clear_bit(LINK_STATE_RXSEM, &dev->state);
36328  #endif
36329 -#else
36330 -       dev->interrupt = 0;
36331 -#endif
36332         return IRQ_HANDLED;
36333  }
36334  
36335 @@ -815,7 +790,7 @@
36336  static int skmca_getinfo(char *buf, int slot, void *d)
36337  {
36338         int len = 0, i;
36339 -       struct SKMCA_NETDEV *dev = (struct SKMCA_NETDEV *) d;
36340 +       struct net_device *dev = (struct net_device *) d;
36341         skmca_priv *priv;
36342  
36343         /* can't say anything about an uninitialized device... */
36344 @@ -846,7 +821,7 @@
36345  
36346  /* open driver.  Means also initialization and start of LANCE */
36347  
36348 -static int skmca_open(struct SKMCA_NETDEV *dev)
36349 +static int skmca_open(struct net_device *dev)
36350  {
36351         int result;
36352         skmca_priv *priv = (skmca_priv *) dev->priv;
36353 @@ -868,21 +843,14 @@
36354  
36355         /* set up flags */
36356  
36357 -#if (LINUX_VERSION_CODE >= 0x02032a)
36358         netif_start_queue(dev);
36359 -#else
36360 -       dev->interrupt = 0;
36361 -       dev->tbusy = 0;
36362 -       dev->start = 0;
36363 -       MOD_INC_USE_COUNT;
36364 -#endif
36365  
36366         return 0;
36367  }
36368  
36369  /* close driver.  Shut down board and free allocated resources */
36370  
36371 -static int skmca_close(struct SKMCA_NETDEV *dev)
36372 +static int skmca_close(struct net_device *dev)
36373  {
36374         /* turn off board */
36375         DeinitBoard(dev);
36376 @@ -892,16 +860,12 @@
36377                 free_irq(dev->irq, dev);
36378         dev->irq = 0;
36379  
36380 -#if (LINUX_VERSION_CODE < 0x02032a)
36381 -       MOD_DEC_USE_COUNT;
36382 -#endif
36383 -
36384         return 0;
36385  }
36386  
36387  /* transmit a block. */
36388  
36389 -static int skmca_tx(struct sk_buff *skb, struct SKMCA_NETDEV *dev)
36390 +static int skmca_tx(struct sk_buff *skb, struct net_device *dev)
36391  {
36392         skmca_priv *priv = (skmca_priv *) dev->priv;
36393         LANCE_TxDescr descr;
36394 @@ -977,11 +941,7 @@
36395         /* are we saturated ? */
36396  
36397         if (priv->txbusy >= TXCOUNT)
36398 -#if (LINUX_VERSION_CODE >= 0x02032a)
36399                 netif_stop_queue(dev);
36400 -#else
36401 -               dev->tbusy = 1;
36402 -#endif
36403  
36404         /* write descriptor back to RAM */
36405         SKMCA_TOIO(dev->mem_start + address, &descr,
36406 @@ -993,7 +953,7 @@
36407         if (priv->txbusy == 0)
36408                 SetLANCE(dev, LANCE_CSR0, CSR0_INEA | CSR0_TDMD);
36409  
36410 -       spin_lock_irqrestore(&priv->lock, flags);
36411 +       spin_unlock_irqrestore(&priv->lock, flags);
36412  
36413        tx_done:
36414  
36415 @@ -1004,7 +964,7 @@
36416  
36417  /* return pointer to Ethernet statistics */
36418  
36419 -static struct net_device_stats *skmca_stats(struct SKMCA_NETDEV *dev)
36420 +static struct net_device_stats *skmca_stats(struct net_device *dev)
36421  {
36422         skmca_priv *priv = (skmca_priv *) dev->priv;
36423  
36424 @@ -1014,7 +974,7 @@
36425  /* we don't support runtime reconfiguration, since an MCA card can
36426     be unambigously identified by its POS registers. */
36427  
36428 -static int skmca_config(struct SKMCA_NETDEV *dev, struct ifmap *map)
36429 +static int skmca_config(struct net_device *dev, struct ifmap *map)
36430  {
36431         return 0;
36432  }
36433 @@ -1022,7 +982,7 @@
36434  /* switch receiver mode.  We use the LANCE's multicast filter to prefilter
36435     multicast addresses. */
36436  
36437 -static void skmca_set_multicast_list(struct SKMCA_NETDEV *dev)
36438 +static void skmca_set_multicast_list(struct net_device *dev)
36439  {
36440         LANCE_InitBlock block;
36441  
36442 @@ -1062,7 +1022,7 @@
36443  
36444  static int startslot;          /* counts through slots when probing multiple devices */
36445  
36446 -int __init skmca_probe(struct SKMCA_NETDEV *dev)
36447 +int __init skmca_probe(struct net_device *dev)
36448  {
36449         int force_detect = 0;
36450         int junior, slot, i;
36451 @@ -1095,14 +1055,12 @@
36452  
36453                 getaddrs(slot, junior, &base, &irq, &medium);
36454  
36455 -#if LINUX_VERSION_CODE >= 0x020300
36456                 /* slot already in use ? */
36457  
36458                 if (mca_is_adapter_used(slot)) {
36459                         slot = dofind(&junior, slot + 1);
36460                         continue;
36461                 }
36462 -#endif
36463  
36464                 /* were we looking for something different ? */
36465  
36466 @@ -1221,24 +1179,13 @@
36467  
36468  #define DEVMAX 5
36469  
36470 -#if (LINUX_VERSION_CODE >= 0x020369)
36471 -static struct SKMCA_NETDEV moddevs[DEVMAX] =
36472 -    { {"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
36473 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
36474 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
36475 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
36476 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe}
36477 -};
36478 -#else
36479 -static char NameSpace[8 * DEVMAX];
36480 -static struct SKMCA_NETDEV moddevs[DEVMAX] =
36481 -    { {NameSpace + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
36482 -{NameSpace + 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
36483 -{NameSpace + 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
36484 -{NameSpace + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
36485 -{NameSpace + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe}
36486 +static struct net_device moddevs[DEVMAX] = {
36487 +       { .name = "    ", .init = skmca_probe },
36488 +       { .name = "    ", .init = skmca_probe },
36489 +       { .name = "    ", .init = skmca_probe },
36490 +       { .name = "    ", .init = skmca_probe },
36491 +       { .name = "    ", .init = skmca_probe }
36492  };
36493 -#endif
36494  
36495  int irq;
36496  int io;
36497 @@ -1260,7 +1207,7 @@
36498  
36499  void cleanup_module(void)
36500  {
36501 -       struct SKMCA_NETDEV *dev;
36502 +       struct net_device *dev;
36503         skmca_priv *priv;
36504         int z;
36505  
36506 diff -Nru a/drivers/net/sk_mca.h b/drivers/net/sk_mca.h
36507 --- a/drivers/net/sk_mca.h      Tue Jul 15 08:10:44 2003
36508 +++ b/drivers/net/sk_mca.h      Sun Aug 31 08:29:49 2003
36509 @@ -5,7 +5,6 @@
36510  
36511  /* version-dependent functions/structures */
36512  
36513 -#if LINUX_VERSION_CODE >= 0x020318
36514  #define SKMCA_READB(addr) isa_readb(addr)
36515  #define SKMCA_READW(addr) isa_readw(addr)
36516  #define SKMCA_WRITEB(data, addr) isa_writeb(data, addr)
36517 @@ -13,17 +12,6 @@
36518  #define SKMCA_TOIO(dest, src, len) isa_memcpy_toio(dest, src, len)
36519  #define SKMCA_FROMIO(dest, src, len) isa_memcpy_fromio(dest, src, len)
36520  #define SKMCA_SETIO(dest, val, len) isa_memset_io(dest, val, len)
36521 -#define SKMCA_NETDEV net_device
36522 -#else
36523 -#define SKMCA_READB(addr) readb(addr)
36524 -#define SKMCA_READW(addr) readw(addr)
36525 -#define SKMCA_WRITEB(data, addr) writeb(data, addr)
36526 -#define SKMCA_WRITEW(data, addr) writew(data, addr)
36527 -#define SKMCA_TOIO(dest, src, len) memcpy_toio(dest, src, len)
36528 -#define SKMCA_FROMIO(dest, src, len) memcpy_fromio(dest, src, len)
36529 -#define SKMCA_SETIO(dest, val, len) memset_io(dest, val, len)
36530 -#define SKMCA_NETDEV device
36531 -#endif
36532  
36533  /* Adapter ID's */
36534  #define SKNET_MCA_ID 0x6afd
36535 @@ -188,7 +176,7 @@
36536  
36537  #endif                         /* _SK_MCA_DRIVER_ */
36538  
36539 -extern int skmca_probe(struct SKMCA_NETDEV *);
36540 +extern int skmca_probe(struct net_device *);
36541  
36542  
36543  #endif /* _SK_MCA_INCLUDE_ */
36544 diff -Nru a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
36545 --- a/drivers/net/sunbmac.c     Tue Aug 19 20:53:16 2003
36546 +++ b/drivers/net/sunbmac.c     Sun Aug 24 05:58:18 2003
36547 @@ -1,7 +1,7 @@
36548  /* $Id$
36549   * sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters.
36550   *
36551 - * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com)
36552 + * Copyright (C) 1997, 1998, 1999, 2003 David S. Miller (davem@redhat.com)
36553   */
36554  
36555  #include <linux/module.h>
36556 @@ -18,6 +18,7 @@
36557  #include <linux/init.h>
36558  #include <linux/crc32.h>
36559  #include <linux/errno.h>
36560 +#include <linux/ethtool.h>
36561  #include <linux/netdevice.h>
36562  #include <linux/etherdevice.h>
36563  #include <linux/skbuff.h>
36564 @@ -37,7 +38,7 @@
36565  #include "sunbmac.h"
36566  
36567  static char version[] __initdata =
36568 -        "sunbmac.c:v1.9 11/Sep/99 David S. Miller (davem@redhat.com)\n";
36569 +        "sunbmac.c:v2.0 24/Nov/03 David S. Miller (davem@redhat.com)\n";
36570  
36571  #undef DEBUG_PROBE
36572  #undef DEBUG_TX
36573 @@ -1035,6 +1036,33 @@
36574         sbus_writel(tmp, bregs + BMAC_RXCFG);
36575  }
36576  
36577 +/* Ethtool support... */
36578 +static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
36579 +{
36580 +       struct bigmac *bp = dev->priv;
36581 +
36582 +       strcpy(info->driver, "sunbmac");
36583 +       strcpy(info->version, "2.0");
36584 +       sprintf(info->bus_info, "SBUS:%d",
36585 +               bp->qec_sdev->slot);
36586 +}
36587 +
36588 +static u32 bigmac_get_link(struct net_device *dev)
36589 +{
36590 +       struct bigmac *bp = dev->priv;
36591 +
36592 +       spin_lock_irq(&bp->lock);
36593 +       bp->sw_bmsr = bigmac_tcvr_read(bp, bp->tregs, BIGMAC_BMSR);
36594 +       spin_unlock_irq(&bp->lock);
36595 +
36596 +       return (bp->sw_bmsr & BMSR_LSTATUS);
36597 +}
36598 +
36599 +static struct ethtool_ops bigmac_ethtool_ops = {
36600 +       .get_drvinfo            = bigmac_get_drvinfo,
36601 +       .get_link               = bigmac_get_link,
36602 +};
36603 +
36604  static int __init bigmac_ether_init(struct sbus_dev *qec_sdev)
36605  {
36606         struct net_device *dev;
36607 @@ -1169,6 +1197,7 @@
36608         dev->open = &bigmac_open;
36609         dev->stop = &bigmac_close;
36610         dev->hard_start_xmit = &bigmac_start_xmit;
36611 +       dev->ethtool_ops = &bigmac_ethtool_ops;
36612  
36613         /* Set links to BigMAC statistic and multi-cast loading code. */
36614         dev->get_stats = &bigmac_get_stats;
36615 diff -Nru a/drivers/net/sungem.c b/drivers/net/sungem.c
36616 --- a/drivers/net/sungem.c      Tue Aug 19 20:53:16 2003
36617 +++ b/drivers/net/sungem.c      Sun Aug 24 05:58:18 2003
36618 @@ -1,7 +1,7 @@
36619  /* $Id$
36620   * sungem.c: Sun GEM ethernet driver.
36621   *
36622 - * Copyright (C) 2000, 2001, 2002 David S. Miller (davem@redhat.com)
36623 + * Copyright (C) 2000, 2001, 2002, 2003 David S. Miller (davem@redhat.com)
36624   * 
36625   * Support for Apple GMAC and assorted PHYs by
36626   * Benjamin Herrenscmidt (benh@kernel.crashing.org)
36627 @@ -70,8 +70,8 @@
36628                          SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full)
36629  
36630  #define DRV_NAME       "sungem"
36631 -#define DRV_VERSION    "0.97"
36632 -#define DRV_RELDATE    "3/20/02"
36633 +#define DRV_VERSION    "0.98"
36634 +#define DRV_RELDATE    "8/24/03"
36635  #define DRV_AUTHOR     "David S. Miller (davem@redhat.com)"
36636  
36637  static char version[] __devinitdata =
36638 @@ -2317,177 +2317,134 @@
36639         spin_unlock_irq(&gp->lock);
36640  }
36641  
36642 -/* Eventually add support for changing the advertisement
36643 - * on autoneg.
36644 - */
36645 -static int gem_ethtool_ioctl(struct net_device *dev, void *ep_user)
36646 +static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
36647 +{
36648 +       struct gem *gp = dev->priv;
36649 +  
36650 +       strcpy(info->driver, DRV_NAME);
36651 +       strcpy(info->version, DRV_VERSION);
36652 +       strcpy(info->bus_info, pci_name(gp->pdev));
36653 +}
36654 +  
36655 +static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
36656  {
36657         struct gem *gp = dev->priv;
36658 -       struct ethtool_cmd ecmd;
36659 -
36660 -       if (copy_from_user(&ecmd, ep_user, sizeof(ecmd)))
36661 -               return -EFAULT;
36662 -               
36663 -       switch(ecmd.cmd) {
36664 -        case ETHTOOL_GDRVINFO: {
36665 -               struct ethtool_drvinfo info = { .cmd = ETHTOOL_GDRVINFO };
36666 -
36667 -               strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN);
36668 -               strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN);
36669 -               info.fw_version[0] = '\0';
36670 -               strncpy(info.bus_info, pci_name(gp->pdev), ETHTOOL_BUSINFO_LEN);
36671 -               info.regdump_len = 0; /*SUNGEM_NREGS;*/
36672  
36673 -               if (copy_to_user(ep_user, &info, sizeof(info)))
36674 -                       return -EFAULT;
36675 +       if (gp->phy_type == phy_mii_mdio0 ||
36676 +           gp->phy_type == phy_mii_mdio1) {
36677 +               if (gp->phy_mii.def)
36678 +                       cmd->supported = gp->phy_mii.def->features;
36679 +               else
36680 +                       cmd->supported = (SUPPORTED_10baseT_Half |
36681 +                                         SUPPORTED_10baseT_Full);
36682  
36683 -               return 0;
36684 -       }
36685 +               /* XXX hardcoded stuff for now */
36686 +               cmd->port = PORT_MII;
36687 +               cmd->transceiver = XCVR_EXTERNAL;
36688 +               cmd->phy_address = 0; /* XXX fixed PHYAD */
36689  
36690 -       case ETHTOOL_GSET:
36691 -               if (gp->phy_type == phy_mii_mdio0 ||
36692 -                   gp->phy_type == phy_mii_mdio1) {
36693 -                       if (gp->phy_mii.def)
36694 -                               ecmd.supported = gp->phy_mii.def->features;
36695 -                       else
36696 -                               ecmd.supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full;
36697 -
36698 -                       /* XXX hardcoded stuff for now */
36699 -                       ecmd.port = PORT_MII;
36700 -                       ecmd.transceiver = XCVR_EXTERNAL;
36701 -                       ecmd.phy_address = 0; /* XXX fixed PHYAD */
36702 -
36703 -                       /* Return current PHY settings */
36704 -                       spin_lock_irq(&gp->lock);
36705 -                       ecmd.autoneg = gp->want_autoneg;
36706 -                       ecmd.speed = gp->phy_mii.speed;
36707 -                       ecmd.duplex = gp->phy_mii.duplex;                       
36708 -                       ecmd.advertising = gp->phy_mii.advertising;
36709 -                       /* If we started with a forced mode, we don't have a default
36710 -                        * advertise set, we need to return something sensible so
36711 -                        * userland can re-enable autoneg properly */
36712 -                       if (ecmd.advertising == 0)
36713 -                               ecmd.advertising = ecmd.supported;
36714 -                       spin_unlock_irq(&gp->lock);
36715 -               } else { // XXX PCS ?
36716 -                   ecmd.supported =
36717 +               /* Return current PHY settings */
36718 +               spin_lock_irq(&gp->lock);
36719 +               cmd->autoneg = gp->want_autoneg;
36720 +               cmd->speed = gp->phy_mii.speed;
36721 +               cmd->duplex = gp->phy_mii.duplex;                       
36722 +               cmd->advertising = gp->phy_mii.advertising;
36723 +
36724 +               /* If we started with a forced mode, we don't have a default
36725 +                * advertise set, we need to return something sensible so
36726 +                * userland can re-enable autoneg properly.
36727 +                */
36728 +               if (cmd->advertising == 0)
36729 +                       cmd->advertising = cmd->supported;
36730 +               spin_unlock_irq(&gp->lock);
36731 +       } else { // XXX PCS ?
36732 +               cmd->supported =
36733                         (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
36734                          SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
36735                          SUPPORTED_Autoneg);
36736 -                   ecmd.advertising = ecmd.supported;
36737 -               }
36738 -               if (copy_to_user(ep_user, &ecmd, sizeof(ecmd)))
36739 -                       return -EFAULT;
36740 -               return 0;
36741 +               cmd->advertising = cmd->supported;
36742 +               cmd->speed = 0;
36743 +               cmd->duplex = cmd->port = cmd->phy_address =
36744 +                       cmd->transceiver = cmd->autoneg = 0;
36745 +       }
36746 +       cmd->maxtxpkt = cmd->maxrxpkt = 0;
36747  
36748 -       case ETHTOOL_SSET:
36749 -               /* Verify the settings we care about. */
36750 -               if (ecmd.autoneg != AUTONEG_ENABLE &&
36751 -                   ecmd.autoneg != AUTONEG_DISABLE)
36752 -                       return -EINVAL;
36753 -
36754 -               if (ecmd.autoneg == AUTONEG_ENABLE &&
36755 -                   ecmd.advertising == 0)
36756 -                       return -EINVAL;
36757 -
36758 -               if (ecmd.autoneg == AUTONEG_DISABLE &&
36759 -                   ((ecmd.speed != SPEED_1000 &&
36760 -                     ecmd.speed != SPEED_100 &&
36761 -                     ecmd.speed != SPEED_10) ||
36762 -                    (ecmd.duplex != DUPLEX_HALF &&
36763 -                     ecmd.duplex != DUPLEX_FULL)))
36764 -                       return -EINVAL;
36765 -             
36766 -               /* Apply settings and restart link process. */
36767 -               spin_lock_irq(&gp->lock);
36768 -               gem_begin_auto_negotiation(gp, &ecmd);
36769 -               spin_unlock_irq(&gp->lock);
36770 +       return 0;
36771 +}
36772  
36773 -               return 0;
36774 +static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
36775 +{
36776 +       struct gem *gp = dev->priv;
36777  
36778 -       case ETHTOOL_NWAY_RST:
36779 -               if (!gp->want_autoneg)
36780 -                       return -EINVAL;
36781 +       /* Verify the settings we care about. */
36782 +       if (cmd->autoneg != AUTONEG_ENABLE &&
36783 +           cmd->autoneg != AUTONEG_DISABLE)
36784 +               return -EINVAL;
36785  
36786 -               /* Restart link process. */
36787 -               spin_lock_irq(&gp->lock);
36788 -               gem_begin_auto_negotiation(gp, NULL);
36789 -               spin_unlock_irq(&gp->lock);
36790 +       if (cmd->autoneg == AUTONEG_ENABLE &&
36791 +           cmd->advertising == 0)
36792 +               return -EINVAL;
36793  
36794 -               return 0;
36795 +       if (cmd->autoneg == AUTONEG_DISABLE &&
36796 +           ((cmd->speed != SPEED_1000 &&
36797 +             cmd->speed != SPEED_100 &&
36798 +             cmd->speed != SPEED_10) ||
36799 +            (cmd->duplex != DUPLEX_HALF &&
36800 +             cmd->duplex != DUPLEX_FULL)))
36801 +               return -EINVAL;
36802 +             
36803 +       /* Apply settings and restart link process. */
36804 +       spin_lock_irq(&gp->lock);
36805 +       gem_begin_auto_negotiation(gp, cmd);
36806 +       spin_unlock_irq(&gp->lock);
36807  
36808 -       case ETHTOOL_GWOL:
36809 -       case ETHTOOL_SWOL:
36810 -               break; /* todo */
36811 -
36812 -       /* get link status */
36813 -       case ETHTOOL_GLINK: {
36814 -               struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
36815 -
36816 -               edata.data = (gp->lstate == link_up);
36817 -               if (copy_to_user(ep_user, &edata, sizeof(edata)))
36818 -                       return -EFAULT;
36819 -               return 0;
36820 -       }
36821 +       return 0;
36822 +}
36823  
36824 -       /* get message-level */
36825 -       case ETHTOOL_GMSGLVL: {
36826 -               struct ethtool_value edata = { .cmd = ETHTOOL_GMSGLVL };
36827 -
36828 -               edata.data = gp->msg_enable;
36829 -               if (copy_to_user(ep_user, &edata, sizeof(edata)))
36830 -                       return -EFAULT;
36831 -               return 0;
36832 -       }
36833 +static int gem_nway_reset(struct net_device *dev)
36834 +{
36835 +       struct gem *gp = dev->priv;
36836  
36837 -       /* set message-level */
36838 -       case ETHTOOL_SMSGLVL: {
36839 -               struct ethtool_value edata;
36840 -
36841 -               if (copy_from_user(&edata, ep_user, sizeof(edata)))
36842 -                       return -EFAULT;
36843 -               gp->msg_enable = edata.data;
36844 -               return 0;
36845 -       }
36846 +       if (!gp->want_autoneg)
36847 +               return -EINVAL;
36848  
36849 -#if 0
36850 -       case ETHTOOL_GREGS: {
36851 -               struct ethtool_regs regs;
36852 -               u32 *regbuf;
36853 -               int r = 0;
36854 +       /* Restart link process. */
36855 +       spin_lock_irq(&gp->lock);
36856 +       gem_begin_auto_negotiation(gp, NULL);
36857 +       spin_unlock_irq(&gp->lock);
36858  
36859 -               if (copy_from_user(&regs, useraddr, sizeof(regs)))
36860 -                       return -EFAULT;
36861 -               
36862 -               if (regs.len > SUNGEM_NREGS) {
36863 -                       regs.len = SUNGEM_NREGS;
36864 -               }
36865 -               regs.version = 0;
36866 -               if (copy_to_user(useraddr, &regs, sizeof(regs)))
36867 -                       return -EFAULT;
36868 +       return 0;
36869 +}
36870  
36871 -               if (!gp->hw_running)
36872 -                       return -ENODEV;
36873 -               useraddr += offsetof(struct ethtool_regs, data);
36874 +static u32 gem_get_link(struct net_device *dev)
36875 +{
36876 +       struct gem *gp = dev->priv;
36877  
36878 -               /* Use kmalloc to avoid bloating the stack */
36879 -               regbuf = kmalloc(4 * SUNGEM_NREGS, GFP_KERNEL);
36880 -               if (!regbuf)
36881 -                       return -ENOMEM;
36882 -               spin_lock_irq(&np->lock);
36883 -               gem_get_regs(gp, regbuf);
36884 -               spin_unlock_irq(&np->lock);
36885 -
36886 -               if (copy_to_user(useraddr, regbuf, regs.len*sizeof(u32)))
36887 -                       r = -EFAULT;
36888 -               kfree(regbuf);
36889 -               return r;
36890 -       }
36891 -#endif 
36892 -       };
36893 +       return (gp->lstate == link_up);
36894 +}
36895  
36896 -       return -EOPNOTSUPP;
36897 +static u32 gem_get_msglevel(struct net_device *dev)
36898 +{
36899 +       struct gem *gp = dev->priv;
36900 +       return gp->msg_enable;
36901 +}
36902 +  
36903 +static void gem_set_msglevel(struct net_device *dev, u32 value)
36904 +{
36905 +       struct gem *gp = dev->priv;
36906 +       gp->msg_enable = value;
36907  }
36908 +  
36909 +static struct ethtool_ops gem_ethtool_ops = {
36910 +       .get_drvinfo            = gem_get_drvinfo,
36911 +       .get_link               = ethtool_op_get_link,
36912 +       .get_settings           = gem_get_settings,
36913 +       .set_settings           = gem_set_settings,
36914 +       .nway_reset             = gem_nway_reset,
36915 +       .get_link               = gem_get_link,
36916 +       .get_msglevel           = gem_get_msglevel,
36917 +       .set_msglevel           = gem_set_msglevel,
36918 +};
36919  
36920  static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36921  {
36922 @@ -2501,10 +2458,6 @@
36923         down(&gp->pm_sem);
36924         
36925         switch (cmd) {
36926 -       case SIOCETHTOOL:
36927 -               rc = gem_ethtool_ioctl(dev, ifr->ifr_data);
36928 -               break;
36929 -
36930         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
36931                 data->phy_id = gp->mii_phy_addr;
36932                 /* Fallthrough... */
36933 @@ -2812,6 +2765,7 @@
36934         dev->get_stats = gem_get_stats;
36935         dev->set_multicast_list = gem_set_multicast;
36936         dev->do_ioctl = gem_ioctl;
36937 +       dev->ethtool_ops = &gem_ethtool_ops;
36938         dev->tx_timeout = gem_tx_timeout;
36939         dev->watchdog_timeo = 5 * HZ;
36940         dev->change_mtu = gem_change_mtu;
36941 diff -Nru a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
36942 --- a/drivers/net/sungem_phy.c  Mon May 19 23:38:25 2003
36943 +++ b/drivers/net/sungem_phy.c  Sun Aug 31 16:14:08 2003
36944 @@ -634,116 +634,116 @@
36945  
36946  /* Broadcom BCM 5201 */
36947  static struct mii_phy_ops bcm5201_phy_ops = {
36948 -       init:           bcm5201_init,
36949 -       suspend:        bcm5201_suspend,
36950 -       setup_aneg:     genmii_setup_aneg,
36951 -       setup_forced:   genmii_setup_forced,
36952 -       poll_link:      genmii_poll_link,
36953 -       read_link:      genmii_read_link,
36954 +       .init           = bcm5201_init,
36955 +       .suspend        = bcm5201_suspend,
36956 +       .setup_aneg     = genmii_setup_aneg,
36957 +       .setup_forced   = genmii_setup_forced,
36958 +       .poll_link      = genmii_poll_link,
36959 +       .read_link      = genmii_read_link,
36960  };
36961  
36962  static struct mii_phy_def bcm5201_phy_def = {
36963 -       phy_id:         0x00406210,
36964 -       phy_id_mask:    0xfffffff0,
36965 -       name:           "BCM5201",
36966 -       features:       MII_BASIC_FEATURES,
36967 -       magic_aneg:     0,
36968 -       ops:            &bcm5201_phy_ops
36969 +       .phy_id         = 0x00406210,
36970 +       .phy_id_mask    = 0xfffffff0,
36971 +       .name           = "BCM5201",
36972 +       .features       = MII_BASIC_FEATURES,
36973 +       .magic_aneg     = 0,
36974 +       .ops            = &bcm5201_phy_ops
36975  };
36976  
36977  /* Broadcom BCM 5221 */
36978  static struct mii_phy_ops bcm5221_phy_ops = {
36979 -       suspend:        bcm5201_suspend,
36980 -       init:           bcm5221_init,
36981 -       setup_aneg:     genmii_setup_aneg,
36982 -       setup_forced:   genmii_setup_forced,
36983 -       poll_link:      genmii_poll_link,
36984 -       read_link:      genmii_read_link,
36985 +       .suspend        = bcm5201_suspend,
36986 +       .init           = bcm5221_init,
36987 +       .setup_aneg     = genmii_setup_aneg,
36988 +       .setup_forced   = genmii_setup_forced,
36989 +       .poll_link      = genmii_poll_link,
36990 +       .read_link      = genmii_read_link,
36991  };
36992  
36993  static struct mii_phy_def bcm5221_phy_def = {
36994 -       phy_id:         0x004061e0,
36995 -       phy_id_mask:    0xfffffff0,
36996 -       name:           "BCM5221",
36997 -       features:       MII_BASIC_FEATURES,
36998 -       magic_aneg:     0,
36999 -       ops:            &bcm5221_phy_ops
37000 +       .phy_id         = 0x004061e0,
37001 +       .phy_id_mask    = 0xfffffff0,
37002 +       .name           = "BCM5221",
37003 +       .features       = MII_BASIC_FEATURES,
37004 +       .magic_aneg     = 0,
37005 +       .ops            = &bcm5221_phy_ops
37006  };
37007  
37008  /* Broadcom BCM 5400 */
37009  static struct mii_phy_ops bcm5400_phy_ops = {
37010 -       init:           bcm5400_init,
37011 -       suspend:        bcm5400_suspend,
37012 -       setup_aneg:     bcm54xx_setup_aneg,
37013 -       setup_forced:   bcm54xx_setup_forced,
37014 -       poll_link:      genmii_poll_link,
37015 -       read_link:      bcm54xx_read_link,
37016 +       .init           = bcm5400_init,
37017 +       .suspend        = bcm5400_suspend,
37018 +       .setup_aneg     = bcm54xx_setup_aneg,
37019 +       .setup_forced   = bcm54xx_setup_forced,
37020 +       .poll_link      = genmii_poll_link,
37021 +       .read_link      = bcm54xx_read_link,
37022  };
37023  
37024  static struct mii_phy_def bcm5400_phy_def = {
37025 -       phy_id:         0x00206040,
37026 -       phy_id_mask:    0xfffffff0,
37027 -       name:           "BCM5400",
37028 -       features:       MII_GBIT_FEATURES,
37029 -       magic_aneg:     1,
37030 -       ops:            &bcm5400_phy_ops
37031 +       .phy_id         = 0x00206040,
37032 +       .phy_id_mask    = 0xfffffff0,
37033 +       .name           = "BCM5400",
37034 +       .features       = MII_GBIT_FEATURES,
37035 +       .magic_aneg     = 1,
37036 +       .ops            = &bcm5400_phy_ops
37037  };
37038  
37039  /* Broadcom BCM 5401 */
37040  static struct mii_phy_ops bcm5401_phy_ops = {
37041 -       init:           bcm5401_init,
37042 -       suspend:        bcm5401_suspend,
37043 -       setup_aneg:     bcm54xx_setup_aneg,
37044 -       setup_forced:   bcm54xx_setup_forced,
37045 -       poll_link:      genmii_poll_link,
37046 -       read_link:      bcm54xx_read_link,
37047 +       .init           = bcm5401_init,
37048 +       .suspend        = bcm5401_suspend,
37049 +       .setup_aneg     = bcm54xx_setup_aneg,
37050 +       .setup_forced   = bcm54xx_setup_forced,
37051 +       .poll_link      = genmii_poll_link,
37052 +       .read_link      = bcm54xx_read_link,
37053  };
37054  
37055  static struct mii_phy_def bcm5401_phy_def = {
37056 -       phy_id:         0x00206050,
37057 -       phy_id_mask:    0xfffffff0,
37058 -       name:           "BCM5401",
37059 -       features:       MII_GBIT_FEATURES,
37060 -       magic_aneg:     1,
37061 -       ops:            &bcm5401_phy_ops
37062 +       .phy_id         = 0x00206050,
37063 +       .phy_id_mask    = 0xfffffff0,
37064 +       .name           = "BCM5401",
37065 +       .features       = MII_GBIT_FEATURES,
37066 +       .magic_aneg     = 1,
37067 +       .ops            = &bcm5401_phy_ops
37068  };
37069  
37070  /* Broadcom BCM 5411 */
37071  static struct mii_phy_ops bcm5411_phy_ops = {
37072 -       init:           bcm5411_init,
37073 -       suspend:        bcm5411_suspend,
37074 -       setup_aneg:     bcm54xx_setup_aneg,
37075 -       setup_forced:   bcm54xx_setup_forced,
37076 -       poll_link:      genmii_poll_link,
37077 -       read_link:      bcm54xx_read_link,
37078 +       .init           = bcm5411_init,
37079 +       .suspend        = bcm5411_suspend,
37080 +       .setup_aneg     = bcm54xx_setup_aneg,
37081 +       .setup_forced   = bcm54xx_setup_forced,
37082 +       .poll_link      = genmii_poll_link,
37083 +       .read_link      = bcm54xx_read_link,
37084  };
37085  
37086  static struct mii_phy_def bcm5411_phy_def = {
37087 -       phy_id:         0x00206070,
37088 -       phy_id_mask:    0xfffffff0,
37089 -       name:           "BCM5411",
37090 -       features:       MII_GBIT_FEATURES,
37091 -       magic_aneg:     1,
37092 -       ops:            &bcm5411_phy_ops
37093 +       .phy_id         = 0x00206070,
37094 +       .phy_id_mask    = 0xfffffff0,
37095 +       .name           = "BCM5411",
37096 +       .features       = MII_GBIT_FEATURES,
37097 +       .magic_aneg     = 1,
37098 +       .ops            = &bcm5411_phy_ops
37099  };
37100  
37101  /* Broadcom BCM 5421 */
37102  static struct mii_phy_ops bcm5421_phy_ops = {
37103 -       init:           bcm5421_init,
37104 -       suspend:        bcm5411_suspend,
37105 -       setup_aneg:     bcm54xx_setup_aneg,
37106 -       setup_forced:   bcm54xx_setup_forced,
37107 -       poll_link:      genmii_poll_link,
37108 -       read_link:      bcm54xx_read_link,
37109 +       .init           = bcm5421_init,
37110 +       .suspend        = bcm5411_suspend,
37111 +       .setup_aneg     = bcm54xx_setup_aneg,
37112 +       .setup_forced   = bcm54xx_setup_forced,
37113 +       .poll_link      = genmii_poll_link,
37114 +       .read_link      = bcm54xx_read_link,
37115  };
37116  
37117  static struct mii_phy_def bcm5421_phy_def = {
37118 -       phy_id:         0x002060e0,
37119 -       phy_id_mask:    0xfffffff0,
37120 -       name:           "BCM5421",
37121 -       features:       MII_GBIT_FEATURES,
37122 -       magic_aneg:     1,
37123 -       ops:            &bcm5421_phy_ops
37124 +       .phy_id         = 0x002060e0,
37125 +       .phy_id_mask    = 0xfffffff0,
37126 +       .name           = "BCM5421",
37127 +       .features       = MII_GBIT_FEATURES,
37128 +       .magic_aneg     = 1,
37129 +       .ops            = &bcm5421_phy_ops
37130  };
37131  
37132  /* Marvell 88E1101 (Apple seem to deal with 2 different revs,
37133 @@ -751,36 +751,36 @@
37134   * would be useful here) --BenH.
37135   */
37136  static struct mii_phy_ops marvell_phy_ops = {
37137 -       setup_aneg:     marvell_setup_aneg,
37138 -       setup_forced:   marvell_setup_forced,
37139 -       poll_link:      genmii_poll_link,
37140 -       read_link:      marvell_read_link
37141 +       .setup_aneg     = marvell_setup_aneg,
37142 +       .setup_forced   = marvell_setup_forced,
37143 +       .poll_link      = genmii_poll_link,
37144 +       .read_link      = marvell_read_link
37145  };
37146  
37147  static struct mii_phy_def marvell_phy_def = {
37148 -       phy_id:         0x01410c00,
37149 -       phy_id_mask:    0xffffff00,
37150 -       name:           "Marvell 88E1101",
37151 -       features:       MII_GBIT_FEATURES,
37152 -       magic_aneg:     1,
37153 -       ops:            &marvell_phy_ops
37154 +       .phy_id         = 0x01410c00,
37155 +       .phy_id_mask    = 0xffffff00,
37156 +       .name           = "Marvell 88E1101",
37157 +       .features       = MII_GBIT_FEATURES,
37158 +       .magic_aneg     = 1,
37159 +       .ops            = &marvell_phy_ops
37160  };
37161  
37162  /* Generic implementation for most 10/100 PHYs */
37163  static struct mii_phy_ops generic_phy_ops = {
37164 -       setup_aneg:     genmii_setup_aneg,
37165 -       setup_forced:   genmii_setup_forced,
37166 -       poll_link:      genmii_poll_link,
37167 -       read_link:      genmii_read_link
37168 +       .setup_aneg     = genmii_setup_aneg,
37169 +       .setup_forced   = genmii_setup_forced,
37170 +       .poll_link      = genmii_poll_link,
37171 +       .read_link      = genmii_read_link
37172  };
37173  
37174  static struct mii_phy_def genmii_phy_def = {
37175 -       phy_id:         0x00000000,
37176 -       phy_id_mask:    0x00000000,
37177 -       name:           "Generic MII",
37178 -       features:       MII_BASIC_FEATURES,
37179 -       magic_aneg:     0,
37180 -       ops:            &generic_phy_ops
37181 +       .phy_id         = 0x00000000,
37182 +       .phy_id_mask    = 0x00000000,
37183 +       .name           = "Generic MII",
37184 +       .features       = MII_BASIC_FEATURES,
37185 +       .magic_aneg     = 0,
37186 +       .ops            = &generic_phy_ops
37187  };
37188  
37189  static struct mii_phy_def* mii_phy_table[] = {
37190 diff -Nru a/drivers/net/sunhme.c b/drivers/net/sunhme.c
37191 --- a/drivers/net/sunhme.c      Tue Aug 19 20:53:16 2003
37192 +++ b/drivers/net/sunhme.c      Tue Sep  2 04:22:42 2003
37193 @@ -3,7 +3,7 @@
37194   *           auto carrier detecting ethernet driver.  Also known as the
37195   *           "Happy Meal Ethernet" found on SunSwift SBUS cards.
37196   *
37197 - * Copyright (C) 1996, 1998, 1999, 2002 David S. Miller (davem@redhat.com)
37198 + * Copyright (C) 1996, 1998, 1999, 2002, 2003 David S. Miller (davem@redhat.com)
37199   *
37200   * Changes :
37201   * 2000/11/11 Willy Tarreau <willy AT meta-x.org>
37202 @@ -14,10 +14,10 @@
37203   */
37204  
37205  static char version[] =
37206 -        "sunhme.c:v2.01 26/Mar/2002 David S. Miller (davem@redhat.com)\n";
37207 +        "sunhme.c:v2.02 24/Aug/2003 David S. Miller (davem@redhat.com)\n";
37208  
37209 -#include <linux/module.h>
37210  #include <linux/config.h>
37211 +#include <linux/module.h>
37212  #include <linux/kernel.h>
37213  #include <linux/types.h>
37214  #include <linux/fcntl.h>
37215 @@ -2426,85 +2426,112 @@
37216  }
37217  
37218  /* Ethtool support... */
37219 -static int happy_meal_ioctl(struct net_device *dev,
37220 -                           struct ifreq *rq, int cmd)
37221 +static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
37222  {
37223         struct happy_meal *hp = dev->priv;
37224 -       struct ethtool_cmd *ep_user = (struct ethtool_cmd *) rq->ifr_data;
37225 -       struct ethtool_cmd ecmd;
37226  
37227 -       if (cmd != SIOCETHTOOL)
37228 -               return -EOPNOTSUPP;
37229 -       if (copy_from_user(&ecmd, ep_user, sizeof(ecmd)))
37230 -               return -EFAULT;
37231 -
37232 -       if (ecmd.cmd == ETHTOOL_GSET) {
37233 -               ecmd.supported =
37234 -                       (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
37235 -                        SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
37236 -                        SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
37237 -
37238 -               /* XXX hardcoded stuff for now */
37239 -               ecmd.port = PORT_TP; /* XXX no MII support */
37240 -               ecmd.transceiver = XCVR_INTERNAL; /* XXX no external xcvr support */
37241 -               ecmd.phy_address = 0; /* XXX fixed PHYAD */
37242 -
37243 -               /* Record PHY settings. */
37244 -               spin_lock_irq(&hp->happy_lock);
37245 -               hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
37246 -               hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA);
37247 -               spin_unlock_irq(&hp->happy_lock);
37248 +       cmd->supported =
37249 +               (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
37250 +                SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
37251 +                SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
37252 +
37253 +       /* XXX hardcoded stuff for now */
37254 +       cmd->port = PORT_TP; /* XXX no MII support */
37255 +       cmd->transceiver = XCVR_INTERNAL; /* XXX no external xcvr support */
37256 +       cmd->phy_address = 0; /* XXX fixed PHYAD */
37257  
37258 -               if (hp->sw_bmcr & BMCR_ANENABLE) {
37259 -                       ecmd.autoneg = AUTONEG_ENABLE;
37260 -                       ecmd.speed =
37261 -                               (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
37262 -                               SPEED_100 : SPEED_10;
37263 -                       if (ecmd.speed == SPEED_100)
37264 -                               ecmd.duplex =
37265 -                                       (hp->sw_lpa & (LPA_100FULL)) ?
37266 -                                       DUPLEX_FULL : DUPLEX_HALF;
37267 -                       else
37268 -                               ecmd.duplex =
37269 -                                       (hp->sw_lpa & (LPA_10FULL)) ?
37270 -                                       DUPLEX_FULL : DUPLEX_HALF;
37271 -               } else {
37272 -                       ecmd.autoneg = AUTONEG_DISABLE;
37273 -                       ecmd.speed =
37274 -                               (hp->sw_bmcr & BMCR_SPEED100) ?
37275 -                               SPEED_100 : SPEED_10;
37276 -                       ecmd.duplex =
37277 -                               (hp->sw_bmcr & BMCR_FULLDPLX) ?
37278 +       /* Record PHY settings. */
37279 +       spin_lock_irq(&hp->happy_lock);
37280 +       hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
37281 +       hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA);
37282 +       spin_unlock_irq(&hp->happy_lock);
37283 +
37284 +       if (hp->sw_bmcr & BMCR_ANENABLE) {
37285 +               cmd->autoneg = AUTONEG_ENABLE;
37286 +               cmd->speed =
37287 +                       (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
37288 +                       SPEED_100 : SPEED_10;
37289 +               if (cmd->speed == SPEED_100)
37290 +                       cmd->duplex =
37291 +                               (hp->sw_lpa & (LPA_100FULL)) ?
37292                                 DUPLEX_FULL : DUPLEX_HALF;
37293 -               }
37294 -               if (copy_to_user(ep_user, &ecmd, sizeof(ecmd)))
37295 -                       return -EFAULT;
37296 -               return 0;
37297 -       } else if (ecmd.cmd == ETHTOOL_SSET) {
37298 -               /* Verify the settings we care about. */
37299 -               if (ecmd.autoneg != AUTONEG_ENABLE &&
37300 -                   ecmd.autoneg != AUTONEG_DISABLE)
37301 -                       return -EINVAL;
37302 -               if (ecmd.autoneg == AUTONEG_DISABLE &&
37303 -                   ((ecmd.speed != SPEED_100 &&
37304 -                     ecmd.speed != SPEED_10) ||
37305 -                    (ecmd.duplex != DUPLEX_HALF &&
37306 -                     ecmd.duplex != DUPLEX_FULL)))
37307 -                       return -EINVAL;
37308 -
37309 -               /* Ok, do it to it. */
37310 -               spin_lock_irq(&hp->happy_lock);
37311 -               del_timer(&hp->happy_timer);
37312 -               happy_meal_begin_auto_negotiation(hp,
37313 -                                                 hp->tcvregs,
37314 -                                                 &ecmd);
37315 -               spin_unlock_irq(&hp->happy_lock);
37316 +               else
37317 +                       cmd->duplex =
37318 +                               (hp->sw_lpa & (LPA_10FULL)) ?
37319 +                               DUPLEX_FULL : DUPLEX_HALF;
37320 +       } else {
37321 +               cmd->autoneg = AUTONEG_DISABLE;
37322 +               cmd->speed =
37323 +                       (hp->sw_bmcr & BMCR_SPEED100) ?
37324 +                       SPEED_100 : SPEED_10;
37325 +               cmd->duplex =
37326 +                       (hp->sw_bmcr & BMCR_FULLDPLX) ?
37327 +                       DUPLEX_FULL : DUPLEX_HALF;
37328 +       }
37329 +       return 0;
37330 +}
37331  
37332 -               return 0;
37333 -       } else
37334 -               return -EOPNOTSUPP;
37335 +static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
37336 +{
37337 +       struct happy_meal *hp = dev->priv;
37338 +
37339 +       /* Verify the settings we care about. */
37340 +       if (cmd->autoneg != AUTONEG_ENABLE &&
37341 +           cmd->autoneg != AUTONEG_DISABLE)
37342 +               return -EINVAL;
37343 +       if (cmd->autoneg == AUTONEG_DISABLE &&
37344 +           ((cmd->speed != SPEED_100 &&
37345 +             cmd->speed != SPEED_10) ||
37346 +            (cmd->duplex != DUPLEX_HALF &&
37347 +             cmd->duplex != DUPLEX_FULL)))
37348 +               return -EINVAL;
37349 +
37350 +       /* Ok, do it to it. */
37351 +       spin_lock_irq(&hp->happy_lock);
37352 +       del_timer(&hp->happy_timer);
37353 +       happy_meal_begin_auto_negotiation(hp, hp->tcvregs, cmd);
37354 +       spin_unlock_irq(&hp->happy_lock);
37355 +
37356 +       return 0;
37357  }
37358  
37359 +static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
37360 +{
37361 +       struct happy_meal *hp = dev->priv;
37362 +
37363 +       strcpy(info->driver, "sunhme");
37364 +       strcpy(info->version, "2.02");
37365 +       if (hp->happy_flags & HFLAG_PCI) {
37366 +               struct pci_dev *pdev = hp->happy_dev;
37367 +               strcpy(info->bus_info, pci_name(pdev));
37368 +       }
37369 +#ifdef CONFIG_SBUS
37370 +       else {
37371 +               struct sbus_dev *sdev = hp->happy_dev;
37372 +               sprintf(info->bus_info, "SBUS:%d",
37373 +                       sdev->slot);
37374 +       }
37375 +#endif
37376 +}
37377 +
37378 +static u32 hme_get_link(struct net_device *dev)
37379 +{
37380 +       struct happy_meal *hp = dev->priv;
37381 +
37382 +       spin_lock_irq(&hp->happy_lock);
37383 +       hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
37384 +       spin_unlock_irq(&hp->happy_lock);
37385 +
37386 +       return (hp->sw_bmsr & BMSR_LSTATUS);
37387 +}
37388 +
37389 +static struct ethtool_ops hme_ethtool_ops = {
37390 +       .get_settings           = hme_get_settings,
37391 +       .set_settings           = hme_set_settings,
37392 +       .get_drvinfo            = hme_get_drvinfo,
37393 +       .get_link               = hme_get_link,
37394 +};
37395 +
37396  static int hme_version_printed;
37397  
37398  #ifdef CONFIG_SBUS
37399 @@ -2797,7 +2824,7 @@
37400         dev->set_multicast_list = &happy_meal_set_multicast;
37401         dev->tx_timeout = &happy_meal_tx_timeout;
37402         dev->watchdog_timeo = 5*HZ;
37403 -       dev->do_ioctl = &happy_meal_ioctl;
37404 +       dev->ethtool_ops = &hme_ethtool_ops;
37405  
37406         /* Happy Meal can do it all... except VLAN. */
37407         dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_VLAN_CHALLENGED;
37408 @@ -3141,7 +3168,7 @@
37409         dev->set_multicast_list = &happy_meal_set_multicast;
37410         dev->tx_timeout = &happy_meal_tx_timeout;
37411         dev->watchdog_timeo = 5*HZ;
37412 -       dev->do_ioctl = &happy_meal_ioctl;
37413 +       dev->ethtool_ops = &hme_ethtool_ops;
37414         dev->irq = pdev->irq;
37415         dev->dma = 0;
37416  
37417 diff -Nru a/drivers/net/sunlance.c b/drivers/net/sunlance.c
37418 --- a/drivers/net/sunlance.c    Tue Aug 19 20:53:17 2003
37419 +++ b/drivers/net/sunlance.c    Sun Aug 24 05:58:18 2003
37420 @@ -70,7 +70,7 @@
37421  #undef DEBUG_DRIVER
37422  
37423  static char version[] =
37424 -       "sunlance.c:v2.01 08/Nov/01 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
37425 +       "sunlance.c:v2.02 24/Aug/03 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
37426  
37427  static char lancestr[] = "LANCE";
37428  
37429 @@ -93,6 +93,7 @@
37430  #include <linux/netdevice.h>
37431  #include <linux/etherdevice.h>
37432  #include <linux/skbuff.h>
37433 +#include <linux/ethtool.h>
37434  
37435  #include <asm/system.h>
37436  #include <asm/bitops.h>
37437 @@ -1287,6 +1288,30 @@
37438         }
37439  }
37440  
37441 +/* Ethtool support... */
37442 +static void sparc_lance_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
37443 +{
37444 +       struct lance_private *lp = dev->priv;
37445 +
37446 +       strcpy(info->driver, "sunlance");
37447 +       strcpy(info->version, "2.02");
37448 +       sprintf(info->bus_info, "SBUS:%d",
37449 +               lp->sdev->slot);
37450 +}
37451 +
37452 +static u32 sparc_lance_get_link(struct net_device *dev)
37453 +{
37454 +       /* We really do not keep track of this, but this
37455 +        * is better than not reporting anything at all.
37456 +        */
37457 +       return 1;
37458 +}
37459 +
37460 +static struct ethtool_ops sparc_lance_ethtool_ops = {
37461 +       .get_drvinfo            = sparc_lance_get_drvinfo,
37462 +       .get_link               = sparc_lance_get_link,
37463 +};
37464 +
37465  static int __init sparc_lance_init(struct net_device *dev,
37466                                    struct sbus_dev *sdev,
37467                                    struct sbus_dma *ledma,
37468 @@ -1456,6 +1481,7 @@
37469         dev->watchdog_timeo = 5*HZ;
37470         dev->get_stats = &lance_get_stats;
37471         dev->set_multicast_list = &lance_set_multicast;
37472 +       dev->ethtool_ops = &sparc_lance_ethtool_ops;
37473  
37474         dev->irq = sdev->irqs[0];
37475  
37476 diff -Nru a/drivers/net/sunqe.c b/drivers/net/sunqe.c
37477 --- a/drivers/net/sunqe.c       Tue Aug 19 20:53:17 2003
37478 +++ b/drivers/net/sunqe.c       Sun Aug 24 05:58:18 2003
37479 @@ -4,11 +4,11 @@
37480   *          controller out there can be most efficiently programmed
37481   *          if you make it look like a LANCE.
37482   *
37483 - * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com)
37484 + * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com)
37485   */
37486  
37487  static char version[] =
37488 -        "sunqe.c:v2.9 9/11/99 David S. Miller (davem@redhat.com)\n";
37489 +        "sunqe.c:v3.0 8/24/03 David S. Miller (davem@redhat.com)\n";
37490  
37491  #include <linux/module.h>
37492  #include <linux/kernel.h>
37493 @@ -26,6 +26,7 @@
37494  #include <linux/netdevice.h>
37495  #include <linux/etherdevice.h>
37496  #include <linux/skbuff.h>
37497 +#include <linux/ethtool.h>
37498  
37499  #include <asm/system.h>
37500  #include <asm/bitops.h>
37501 @@ -684,6 +685,35 @@
37502         netif_wake_queue(dev);
37503  }
37504  
37505 +/* Ethtool support... */
37506 +static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
37507 +{
37508 +       struct sunqe *qep = dev->priv;
37509 +
37510 +       strcpy(info->driver, "sunqe");
37511 +       strcpy(info->version, "3.0");
37512 +       sprintf(info->bus_info, "SBUS:%d",
37513 +               qep->qe_sdev->slot);
37514 +}
37515 +
37516 +static u32 qe_get_link(struct net_device *dev)
37517 +{
37518 +       struct sunqe *qep = dev->priv;
37519 +       unsigned long mregs = qep->mregs;
37520 +       u8 phyconfig;
37521 +
37522 +       spin_lock_irq(&qep->lock);
37523 +       phyconfig = sbus_readb(mregs + MREGS_PHYCONFIG);
37524 +       spin_unlock_irq(&qep->lock);
37525 +
37526 +       return (phyconfig & MREGS_PHYCONFIG_LSTAT);
37527 +}
37528 +
37529 +static struct ethtool_ops qe_ethtool_ops = {
37530 +       .get_drvinfo            = qe_get_drvinfo,
37531 +       .get_link               = qe_get_link,
37532 +};
37533 +
37534  /* This is only called once at boot time for each card probed. */
37535  static inline void qec_init_once(struct sunqec *qecp, struct sbus_dev *qsdev)
37536  {
37537 @@ -850,6 +880,7 @@
37538                 qe_devs[i]->watchdog_timeo = 5*HZ;
37539                 qe_devs[i]->irq = sdev->irqs[0];
37540                 qe_devs[i]->dma = 0;
37541 +               qe_devs[i]->ethtool_ops = &qe_ethtool_ops;
37542         }
37543  
37544         /* QEC receives interrupts from each QE, then it sends the actual
37545 diff -Nru a/drivers/net/tg3.c b/drivers/net/tg3.c
37546 --- a/drivers/net/tg3.c Tue Aug 19 20:53:17 2003
37547 +++ b/drivers/net/tg3.c Mon Sep  1 12:14:20 2003
37548 @@ -2,7 +2,7 @@
37549   * tg3.c: Broadcom Tigon3 ethernet driver.
37550   *
37551   * Copyright (C) 2001, 2002, 2003 David S. Miller (davem@redhat.com)
37552 - * Copyright (C) 2001, 2002 Jeff Garzik (jgarzik@pobox.com)
37553 + * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com)
37554   */
37555  
37556  #include <linux/config.h>
37557 @@ -27,6 +27,8 @@
37558  #include <linux/tcp.h>
37559  #include <linux/workqueue.h>
37560  
37561 +#include <net/checksum.h>
37562 +
37563  #include <asm/system.h>
37564  #include <asm/io.h>
37565  #include <asm/byteorder.h>
37566 @@ -45,20 +47,17 @@
37567  #endif
37568  
37569  #ifdef NETIF_F_TSO
37570 -/* XXX Works but still disabled, decreases TCP performance to 7MB/sec even
37571 - * XXX over gigabit.
37572 - */
37573 -#define TG3_DO_TSO     0
37574 +#define TG3_TSO_SUPPORT        1
37575  #else
37576 -#define TG3_DO_TSO     0
37577 +#define TG3_TSO_SUPPORT        0
37578  #endif
37579  
37580  #include "tg3.h"
37581  
37582  #define DRV_MODULE_NAME                "tg3"
37583  #define PFX DRV_MODULE_NAME    ": "
37584 -#define DRV_MODULE_VERSION     "1.9"
37585 -#define DRV_MODULE_RELDATE     "August 3, 2003"
37586 +#define DRV_MODULE_VERSION     "2.2"
37587 +#define DRV_MODULE_RELDATE     "August 24, 2003"
37588  
37589  #define TG3_DEF_MAC_MODE       0
37590  #define TG3_DEF_RX_MODE                0
37591 @@ -80,7 +79,8 @@
37592  
37593  /* hardware minimum and maximum for a single frame's data payload */
37594  #define TG3_MIN_MTU                    60
37595 -#define TG3_MAX_MTU                    9000
37596 +#define TG3_MAX_MTU(tp)        \
37597 +       (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 ? 9000 : 1500)
37598  
37599  /* These numbers seem to be hard coded in the NIC firmware somehow.
37600   * You can't change the ring sizes, but you can change where you place
37601 @@ -90,7 +90,17 @@
37602  #define TG3_DEF_RX_RING_PENDING                200
37603  #define TG3_RX_JUMBO_RING_SIZE         256
37604  #define TG3_DEF_RX_JUMBO_RING_PENDING  100
37605 -#define TG3_RX_RCB_RING_SIZE           1024
37606 +
37607 +/* Do not place this n-ring entries value into the tp struct itself,
37608 + * we really want to expose these constants to GCC so that modulo et
37609 + * al.  operations are done with shifts and masks instead of with
37610 + * hw multiply/modulo instructions.  Another solution would be to
37611 + * replace things like '% foo' with '& (foo - 1)'.
37612 + */
37613 +#define TG3_RX_RCB_RING_SIZE(tp)       \
37614 +       (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ? \
37615 +        512 : 1024)
37616 +
37617  #define TG3_TX_RING_SIZE               512
37618  #define TG3_DEF_TX_RING_PENDING                (TG3_TX_RING_SIZE - 1)
37619  
37620 @@ -98,8 +108,8 @@
37621                                  TG3_RX_RING_SIZE)
37622  #define TG3_RX_JUMBO_RING_BYTES        (sizeof(struct tg3_rx_buffer_desc) * \
37623                                  TG3_RX_JUMBO_RING_SIZE)
37624 -#define TG3_RX_RCB_RING_BYTES  (sizeof(struct tg3_rx_buffer_desc) * \
37625 -                                TG3_RX_RCB_RING_SIZE)
37626 +#define TG3_RX_RCB_RING_BYTES(tp) (sizeof(struct tg3_rx_buffer_desc) * \
37627 +                                  TG3_RX_RCB_RING_SIZE(tp))
37628  #define TG3_TX_RING_BYTES      (sizeof(struct tg3_tx_buffer_desc) * \
37629                                  TG3_TX_RING_SIZE)
37630  #define TX_RING_GAP(TP)        \
37631 @@ -140,6 +150,14 @@
37632           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37633         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5702FE,
37634           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37635 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705,
37636 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37637 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705_2,
37638 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37639 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705M,
37640 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37641 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705M_2,
37642 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37643         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5702X,
37644           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37645         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5703X,
37646 @@ -150,12 +168,24 @@
37647           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37648         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5703A3,
37649           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37650 -       { PCI_VENDOR_ID_SYSKONNECT, 0x4400,
37651 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5782,
37652 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37653 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5788,
37654 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37655 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5901,
37656 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37657 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5901_2,
37658 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37659 +       { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX,
37660 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37661 +       { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9MXX,
37662           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37663         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1000,
37664           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37665         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1001,
37666           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37667 +       { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1003,
37668 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37669         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC9100,
37670           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
37671         { 0, }
37672 @@ -237,38 +267,6 @@
37673         tg3_cond_int(tp);
37674  }
37675  
37676 -/* these netif_xxx funcs should be moved into generic net layer */
37677 -static void netif_poll_disable(struct net_device *dev)
37678 -{
37679 -       while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
37680 -               current->state = TASK_INTERRUPTIBLE;
37681 -               schedule_timeout(1);
37682 -       }
37683 -}
37684 -
37685 -static inline void netif_poll_enable(struct net_device *dev)
37686 -{
37687 -       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
37688 -}
37689 -
37690 -/* same as netif_rx_complete, except that local_irq_save(flags)
37691 - * has already been issued
37692 - */
37693 -static inline void __netif_rx_complete(struct net_device *dev)
37694 -{
37695 -       if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
37696 -       list_del(&dev->poll_list);
37697 -       smp_mb__before_clear_bit();
37698 -       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
37699 -}
37700 -
37701 -static inline void netif_tx_disable(struct net_device *dev)
37702 -{
37703 -       spin_lock_bh(&dev->xmit_lock);
37704 -       netif_stop_queue(dev);
37705 -       spin_unlock_bh(&dev->xmit_lock);
37706 -}
37707 -
37708  static inline void tg3_netif_stop(struct tg3 *tp)
37709  {
37710         netif_poll_disable(tp->dev);
37711 @@ -288,17 +286,28 @@
37712  
37713  static void tg3_switch_clocks(struct tg3 *tp)
37714  {
37715 -       if (tr32(TG3PCI_CLOCK_CTRL) & CLOCK_CTRL_44MHZ_CORE) {
37716 +       u32 clock_ctrl = tr32(TG3PCI_CLOCK_CTRL);
37717 +       u32 orig_clock_ctrl;
37718 +
37719 +       orig_clock_ctrl = clock_ctrl;
37720 +       clock_ctrl &= (CLOCK_CTRL_FORCE_CLKRUN |
37721 +                      CLOCK_CTRL_CLKRUN_OENABLE |
37722 +                      0x1f);
37723 +       tp->pci_clock_ctrl = clock_ctrl;
37724 +
37725 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
37726 +           (orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) {
37727                 tw32(TG3PCI_CLOCK_CTRL,
37728 +                    clock_ctrl |
37729                      (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK));
37730                 tr32(TG3PCI_CLOCK_CTRL);
37731                 udelay(40);
37732                 tw32(TG3PCI_CLOCK_CTRL,
37733 -                    (CLOCK_CTRL_ALTCLK));
37734 +                    clock_ctrl | (CLOCK_CTRL_ALTCLK));
37735                 tr32(TG3PCI_CLOCK_CTRL);
37736                 udelay(40);
37737         }
37738 -       tw32(TG3PCI_CLOCK_CTRL, 0);
37739 +       tw32(TG3PCI_CLOCK_CTRL, clock_ctrl);
37740         tr32(TG3PCI_CLOCK_CTRL);
37741         udelay(40);
37742  }
37743 @@ -401,24 +410,22 @@
37744         return ret;
37745  }
37746  
37747 -/* This will reset the tigon3 PHY if there is no valid
37748 - * link unless the FORCE argument is non-zero.
37749 - */
37750 -static int tg3_phy_reset(struct tg3 *tp, int force)
37751 +static void tg3_phy_set_wirespeed(struct tg3 *tp)
37752  {
37753 -       u32 phy_status, phy_control;
37754 -       int err, limit;
37755 +       u32 val;
37756  
37757 -       err  = tg3_readphy(tp, MII_BMSR, &phy_status);
37758 -       err |= tg3_readphy(tp, MII_BMSR, &phy_status);
37759 -       if (err != 0)
37760 -               return -EBUSY;
37761 +       if (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED)
37762 +               return;
37763  
37764 -       /* If we have link, and not forcing a reset, then nothing
37765 -        * to do.
37766 -        */
37767 -       if ((phy_status & BMSR_LSTATUS) != 0 && (force == 0))
37768 -               return 0;
37769 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007);
37770 +       tg3_readphy(tp, MII_TG3_AUX_CTRL, &val);
37771 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, (val | (1 << 15) | (1 << 4)));
37772 +}
37773 +
37774 +static int tg3_bmcr_reset(struct tg3 *tp)
37775 +{
37776 +       u32 phy_control;
37777 +       int limit, err;
37778  
37779         /* OK, reset it, and poll the BMCR_RESET bit until it
37780          * clears or we time out.
37781 @@ -436,12 +443,303 @@
37782  
37783                 if ((phy_control & BMCR_RESET) == 0) {
37784                         udelay(40);
37785 -                       return 0;
37786 +                       break;
37787                 }
37788                 udelay(10);
37789         }
37790 +       if (limit <= 0)
37791 +               return -EBUSY;
37792 +
37793 +       return 0;
37794 +}
37795 +
37796 +static int tg3_wait_macro_done(struct tg3 *tp)
37797 +{
37798 +       int limit = 100;
37799 +
37800 +       while (limit--) {
37801 +               u32 tmp32;
37802 +
37803 +               tg3_readphy(tp, 0x16, &tmp32);
37804 +               if ((tmp32 & 0x1000) == 0)
37805 +                       break;
37806 +       }
37807 +       if (limit <= 0)
37808 +               return -EBUSY;
37809 +
37810 +       return 0;
37811 +}
37812 +
37813 +static int tg3_phy_write_and_check_testpat(struct tg3 *tp, int *resetp)
37814 +{
37815 +       static const u32 test_pat[4][6] = {
37816 +       { 0x00005555, 0x00000005, 0x00002aaa, 0x0000000a, 0x00003456, 0x00000003 },
37817 +       { 0x00002aaa, 0x0000000a, 0x00003333, 0x00000003, 0x0000789a, 0x00000005 },
37818 +       { 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
37819 +       { 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
37820 +       };
37821 +       int chan;
37822 +
37823 +       for (chan = 0; chan < 4; chan++) {
37824 +               int i;
37825 +
37826 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
37827 +                            (chan * 0x2000) | 0x0200);
37828 +               tg3_writephy(tp, 0x16, 0x0002);
37829 +
37830 +               for (i = 0; i < 6; i++)
37831 +                       tg3_writephy(tp, MII_TG3_DSP_RW_PORT,
37832 +                                    test_pat[chan][i]);
37833 +
37834 +               tg3_writephy(tp, 0x16, 0x0202);
37835 +               if (tg3_wait_macro_done(tp)) {
37836 +                       *resetp = 1;
37837 +                       return -EBUSY;
37838 +               }
37839 +
37840 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
37841 +                            (chan * 0x2000) | 0x0200);
37842 +               tg3_writephy(tp, 0x16, 0x0082);
37843 +               if (tg3_wait_macro_done(tp)) {
37844 +                       *resetp = 1;
37845 +                       return -EBUSY;
37846 +               }
37847 +
37848 +               tg3_writephy(tp, 0x16, 0x0802);
37849 +               if (tg3_wait_macro_done(tp)) {
37850 +                       *resetp = 1;
37851 +                       return -EBUSY;
37852 +               }
37853 +
37854 +               for (i = 0; i < 6; i += 2) {
37855 +                       u32 low, high;
37856 +
37857 +                       tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &low);
37858 +                       tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &high);
37859 +                       if (tg3_wait_macro_done(tp)) {
37860 +                               *resetp = 1;
37861 +                               return -EBUSY;
37862 +                       }
37863 +                       low &= 0x7fff;
37864 +                       high &= 0x000f;
37865 +                       if (low != test_pat[chan][i] ||
37866 +                           high != test_pat[chan][i+1]) {
37867 +                               tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
37868 +                               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
37869 +                               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);
37870 +
37871 +                               return -EBUSY;
37872 +                       }
37873 +               }
37874 +       }
37875  
37876 -       return -EBUSY;
37877 +       return 0;
37878 +}
37879 +
37880 +static int tg3_phy_reset_chanpat(struct tg3 *tp)
37881 +{
37882 +       int chan;
37883 +
37884 +       for (chan = 0; chan < 4; chan++) {
37885 +               int i;
37886 +
37887 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
37888 +                            (chan * 0x2000) | 0x0200);
37889 +               tg3_writephy(tp, 0x16, 0x0002);
37890 +               for (i = 0; i < 6; i++)
37891 +                       tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x000);
37892 +               tg3_writephy(tp, 0x16, 0x0202);
37893 +               if (tg3_wait_macro_done(tp))
37894 +                       return -EBUSY;
37895 +       }
37896 +
37897 +       return 0;
37898 +}
37899 +
37900 +static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
37901 +{
37902 +       u32 reg32, phy9_orig;
37903 +       int retries, do_phy_reset, err;
37904 +
37905 +       retries = 10;
37906 +       do_phy_reset = 1;
37907 +       do {
37908 +               if (do_phy_reset) {
37909 +                       err = tg3_bmcr_reset(tp);
37910 +                       if (err)
37911 +                               return err;
37912 +                       do_phy_reset = 0;
37913 +               }
37914 +
37915 +               /* Disable transmitter and interrupt.  */
37916 +               tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
37917 +               reg32 |= 0x3000;
37918 +               tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
37919 +
37920 +               /* Set full-duplex, 1000 mbps.  */
37921 +               tg3_writephy(tp, MII_BMCR,
37922 +                            BMCR_FULLDPLX | TG3_BMCR_SPEED1000);
37923 +
37924 +               /* Set to master mode.  */
37925 +               tg3_readphy(tp, MII_TG3_CTRL, &phy9_orig);
37926 +               tg3_writephy(tp, MII_TG3_CTRL,
37927 +                            (MII_TG3_CTRL_AS_MASTER |
37928 +                             MII_TG3_CTRL_ENABLE_AS_MASTER));
37929 +
37930 +               /* Enable SM_DSP_CLOCK and 6dB.  */
37931 +               tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
37932 +
37933 +               /* Block the PHY control access.  */
37934 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
37935 +               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0800);
37936 +
37937 +               err = tg3_phy_write_and_check_testpat(tp, &do_phy_reset);
37938 +               if (!err)
37939 +                       break;
37940 +       } while (--retries);
37941 +
37942 +       err = tg3_phy_reset_chanpat(tp);
37943 +       if (err)
37944 +               return err;
37945 +
37946 +       tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
37947 +       tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0000);
37948 +
37949 +       tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200);
37950 +       tg3_writephy(tp, 0x16, 0x0000);
37951 +
37952 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400);
37953 +
37954 +       tg3_writephy(tp, MII_TG3_CTRL, phy9_orig);
37955 +
37956 +       tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
37957 +       reg32 &= ~0x3000;
37958 +       tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
37959 +
37960 +       return err;
37961 +}
37962 +
37963 +/* This will reset the tigon3 PHY if there is no valid
37964 + * link unless the FORCE argument is non-zero.
37965 + */
37966 +static int tg3_phy_reset(struct tg3 *tp, int force)
37967 +{
37968 +       u32 phy_status;
37969 +       int err;
37970 +
37971 +       err  = tg3_readphy(tp, MII_BMSR, &phy_status);
37972 +       err |= tg3_readphy(tp, MII_BMSR, &phy_status);
37973 +       if (err != 0)
37974 +               return -EBUSY;
37975 +
37976 +       /* If we have link, and not forcing a reset, then nothing
37977 +        * to do.
37978 +        */
37979 +       if ((phy_status & BMSR_LSTATUS) != 0 && (force == 0))
37980 +               return 0;
37981 +
37982 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
37983 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
37984 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
37985 +               err = tg3_phy_reset_5703_4_5(tp);
37986 +               if (err)
37987 +                       return err;
37988 +               goto out;
37989 +       }
37990 +
37991 +       err = tg3_bmcr_reset(tp);
37992 +       if (err)
37993 +               return err;
37994 +
37995 +out:
37996 +       tg3_phy_set_wirespeed(tp);
37997 +       return 0;
37998 +}
37999 +
38000 +static void tg3_frob_aux_power(struct tg3 *tp)
38001 +{
38002 +       struct tg3 *tp_peer = tp;
38003 +
38004 +       if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0)
38005 +               return;
38006 +
38007 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
38008 +               tp_peer = pci_get_drvdata(tp->pdev_peer);
38009 +               if (!tp_peer)
38010 +                       BUG();
38011 +       }
38012 +
38013 +
38014 +       if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
38015 +           (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0) {
38016 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
38017 +                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
38018 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
38019 +                            (GRC_LCLCTRL_GPIO_OE0 |
38020 +                             GRC_LCLCTRL_GPIO_OE1 |
38021 +                             GRC_LCLCTRL_GPIO_OE2 |
38022 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
38023 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
38024 +                       tr32(GRC_LOCAL_CTRL);
38025 +                       udelay(100);
38026 +               } else {
38027 +                       if (tp_peer != tp &&
38028 +                           (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
38029 +                               return;
38030 +
38031 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
38032 +                            (GRC_LCLCTRL_GPIO_OE0 |
38033 +                             GRC_LCLCTRL_GPIO_OE1 |
38034 +                             GRC_LCLCTRL_GPIO_OE2 |
38035 +                             GRC_LCLCTRL_GPIO_OUTPUT1 |
38036 +                             GRC_LCLCTRL_GPIO_OUTPUT2));
38037 +                       tr32(GRC_LOCAL_CTRL);
38038 +                       udelay(100);
38039 +
38040 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
38041 +                            (GRC_LCLCTRL_GPIO_OE0 |
38042 +                             GRC_LCLCTRL_GPIO_OE1 |
38043 +                             GRC_LCLCTRL_GPIO_OE2 |
38044 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
38045 +                             GRC_LCLCTRL_GPIO_OUTPUT1 |
38046 +                             GRC_LCLCTRL_GPIO_OUTPUT2));
38047 +                       tr32(GRC_LOCAL_CTRL);
38048 +                       udelay(100);
38049 +
38050 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
38051 +                            (GRC_LCLCTRL_GPIO_OE0 |
38052 +                             GRC_LCLCTRL_GPIO_OE1 |
38053 +                             GRC_LCLCTRL_GPIO_OE2 |
38054 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
38055 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
38056 +                       tr32(GRC_LOCAL_CTRL);
38057 +                       udelay(100);
38058 +               }
38059 +       } else {
38060 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
38061 +                   GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
38062 +                       if (tp_peer != tp &&
38063 +                           (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
38064 +                               return;
38065 +
38066 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
38067 +                            (GRC_LCLCTRL_GPIO_OE1 |
38068 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
38069 +                       tr32(GRC_LOCAL_CTRL);
38070 +                       udelay(100);
38071 +
38072 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
38073 +                            (GRC_LCLCTRL_GPIO_OE1));
38074 +                       tr32(GRC_LOCAL_CTRL);
38075 +                       udelay(100);
38076 +
38077 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
38078 +                            (GRC_LCLCTRL_GPIO_OE1 |
38079 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
38080 +                       tr32(GRC_LOCAL_CTRL);
38081 +                       udelay(100);
38082 +               }
38083 +       }
38084  }
38085  
38086  static int tg3_setup_phy(struct tg3 *);
38087 @@ -547,89 +845,65 @@
38088                 udelay(10);
38089         }
38090  
38091 -       if (tp->tg3_flags & TG3_FLAG_WOL_SPEED_100MB) {
38092 +       if (!(tp->tg3_flags & TG3_FLAG_WOL_SPEED_100MB) &&
38093 +           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
38094 +            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) {
38095                 u32 base_val;
38096  
38097 -               base_val = 0;
38098 -               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
38099 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)
38100 -                       base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
38101 -                                    CLOCK_CTRL_TXCLK_DISABLE);
38102 -
38103 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
38104 -                    CLOCK_CTRL_ALTCLK);
38105 -               tr32(TG3PCI_CLOCK_CTRL);
38106 -               udelay(40);
38107 +               base_val = tp->pci_clock_ctrl;
38108 +               base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
38109 +                            CLOCK_CTRL_TXCLK_DISABLE);
38110  
38111                 tw32(TG3PCI_CLOCK_CTRL, base_val |
38112                      CLOCK_CTRL_ALTCLK |
38113 -                    CLOCK_CTRL_44MHZ_CORE);
38114 -               tr32(TG3PCI_CLOCK_CTRL);
38115 -               udelay(40);
38116 -
38117 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
38118 -                    CLOCK_CTRL_44MHZ_CORE);
38119 +                    CLOCK_CTRL_PWRDOWN_PLL133);
38120                 tr32(TG3PCI_CLOCK_CTRL);
38121                 udelay(40);
38122         } else {
38123 -               u32 base_val;
38124 +               u32 newbits1, newbits2;
38125  
38126 -               base_val = 0;
38127                 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
38128 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)
38129 -                       base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
38130 -                                    CLOCK_CTRL_TXCLK_DISABLE);
38131 +                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
38132 +                       newbits1 = (CLOCK_CTRL_RXCLK_DISABLE |
38133 +                                   CLOCK_CTRL_TXCLK_DISABLE |
38134 +                                   CLOCK_CTRL_ALTCLK);
38135 +                       newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
38136 +               } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
38137 +                       newbits1 = CLOCK_CTRL_625_CORE;
38138 +                       newbits2 = newbits1 | CLOCK_CTRL_ALTCLK;
38139 +               } else {
38140 +                       newbits1 = CLOCK_CTRL_ALTCLK;
38141 +                       newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
38142 +               }
38143  
38144 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
38145 -                    CLOCK_CTRL_ALTCLK |
38146 -                    CLOCK_CTRL_PWRDOWN_PLL133);
38147 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1);
38148                 tr32(TG3PCI_CLOCK_CTRL);
38149                 udelay(40);
38150 -       }
38151  
38152 -       if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) &&
38153 -           (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)) {
38154 -               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
38155 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
38156 -                       tw32(GRC_LOCAL_CTRL,
38157 -                            (GRC_LCLCTRL_GPIO_OE0 |
38158 -                             GRC_LCLCTRL_GPIO_OE1 |
38159 -                             GRC_LCLCTRL_GPIO_OE2 |
38160 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
38161 -                             GRC_LCLCTRL_GPIO_OUTPUT1));
38162 -                       tr32(GRC_LOCAL_CTRL);
38163 -                       udelay(100);
38164 -               } else {
38165 -                       tw32(GRC_LOCAL_CTRL,
38166 -                            (GRC_LCLCTRL_GPIO_OE0 |
38167 -                             GRC_LCLCTRL_GPIO_OE1 |
38168 -                             GRC_LCLCTRL_GPIO_OE2 |
38169 -                             GRC_LCLCTRL_GPIO_OUTPUT1 |
38170 -                             GRC_LCLCTRL_GPIO_OUTPUT2));
38171 -                       tr32(GRC_LOCAL_CTRL);
38172 -                       udelay(100);
38173 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2);
38174 +               tr32(TG3PCI_CLOCK_CTRL);
38175 +               udelay(40);
38176  
38177 -                       tw32(GRC_LOCAL_CTRL,
38178 -                            (GRC_LCLCTRL_GPIO_OE0 |
38179 -                             GRC_LCLCTRL_GPIO_OE1 |
38180 -                             GRC_LCLCTRL_GPIO_OE2 |
38181 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
38182 -                             GRC_LCLCTRL_GPIO_OUTPUT1 |
38183 -                             GRC_LCLCTRL_GPIO_OUTPUT2));
38184 -                       tr32(GRC_LOCAL_CTRL);
38185 -                       udelay(100);
38186 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
38187 +                       u32 newbits3;
38188  
38189 -                       tw32(GRC_LOCAL_CTRL,
38190 -                            (GRC_LCLCTRL_GPIO_OE0 |
38191 -                             GRC_LCLCTRL_GPIO_OE1 |
38192 -                             GRC_LCLCTRL_GPIO_OE2 |
38193 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
38194 -                             GRC_LCLCTRL_GPIO_OUTPUT1));
38195 -                       tr32(GRC_LOCAL_CTRL);
38196 -                       udelay(100);
38197 +                       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
38198 +                           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
38199 +                               newbits3 = (CLOCK_CTRL_RXCLK_DISABLE |
38200 +                                           CLOCK_CTRL_TXCLK_DISABLE |
38201 +                                           CLOCK_CTRL_44MHZ_CORE);
38202 +                       } else {
38203 +                               newbits3 = CLOCK_CTRL_44MHZ_CORE;
38204 +                       }
38205 +
38206 +                       tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits3);
38207 +                       tr32(TG3PCI_CLOCK_CTRL);
38208 +                       udelay(40);
38209                 }
38210         }
38211  
38212 +       tg3_frob_aux_power(tp);
38213 +
38214         /* Finally, set the new power state. */
38215         pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
38216  
38217 @@ -948,11 +1222,10 @@
38218  
38219         /* Some third-party PHYs need to be reset on link going
38220          * down.
38221 -        *
38222 -        * XXX 5705 note: This workaround also applies to 5705_a0
38223          */
38224         if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
38225 -            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) &&
38226 +            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
38227 +            tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) &&
38228             netif_carrier_ok(tp->dev)) {
38229                 tg3_readphy(tp, MII_BMSR, &bmsr);
38230                 tg3_readphy(tp, MII_BMSR, &bmsr);
38231 @@ -1942,7 +2215,7 @@
38232         int received;
38233  
38234         hw_idx = tp->hw_status->idx[0].rx_producer;
38235 -       sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE;
38236 +       sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
38237         work_mask = 0;
38238         received = 0;
38239         while (sw_idx != hw_idx && budget > 0) {
38240 @@ -2043,13 +2316,13 @@
38241                 (*post_ptr)++;
38242  next_pkt_nopost:
38243                 rx_rcb_ptr++;
38244 -               sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE;
38245 +               sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
38246         }
38247  
38248         /* ACK the status ring. */
38249         tp->rx_rcb_ptr = rx_rcb_ptr;
38250         tw32_mailbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW,
38251 -                    (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE));
38252 +                    (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp)));
38253         if (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)
38254                 tr32(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW);
38255  
38256 @@ -2388,19 +2661,34 @@
38257         base_flags = 0;
38258         if (skb->ip_summed == CHECKSUM_HW)
38259                 base_flags |= TXD_FLAG_TCPUDP_CSUM;
38260 -#if TG3_DO_TSO != 0
38261 -       if ((mss = skb_shinfo(skb)->tso_size) != 0) {
38262 -               static int times = 0;
38263 +#if TG3_TSO_SUPPORT != 0
38264 +       mss = 0;
38265 +       if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
38266 +           (mss = skb_shinfo(skb)->tso_size) != 0) {
38267 +               int tcp_opt_len, ip_tcp_len;
38268 +
38269 +               tcp_opt_len = ((skb->h.th->doff - 5) * 4);
38270 +               ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
38271  
38272 -               mss += ((skb->h.th->doff * 4) - 20);
38273                 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
38274                                TXD_FLAG_CPU_POST_DMA);
38275  
38276 -               if (times++ < 5) {
38277 -                       printk("tg3_xmit: tso_size[%u] tso_segs[%u] len[%u]\n",
38278 -                              (unsigned int) skb_shinfo(skb)->tso_size,
38279 -                              (unsigned int) skb_shinfo(skb)->tso_segs,
38280 -                              skb->len);
38281 +               skb->nh.iph->check = 0;
38282 +               skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len);
38283 +               skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
38284 +                                                     skb->nh.iph->daddr,
38285 +                                                     0, IPPROTO_TCP, 0);
38286 +
38287 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
38288 +                       if (tcp_opt_len || skb->nh.iph->ihl > 5) {
38289 +                               int tsflags;
38290 +
38291 +                               tsflags = ((skb->nh.iph->ihl - 5) +
38292 +                                          (tcp_opt_len >> 2));
38293 +                               mss |= (tsflags << 11);
38294 +                       }
38295 +               } else {
38296 +                       mss += tcp_opt_len;
38297                 }
38298         }
38299  #else
38300 @@ -2580,23 +2868,34 @@
38301         base_flags = 0;
38302         if (skb->ip_summed == CHECKSUM_HW)
38303                 base_flags |= TXD_FLAG_TCPUDP_CSUM;
38304 -#if TG3_DO_TSO != 0
38305 -       if ((mss = skb_shinfo(skb)->tso_size) != 0) {
38306 -               static int times = 0;
38307 +#if TG3_TSO_SUPPORT != 0
38308 +       mss = 0;
38309 +       if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
38310 +           (mss = skb_shinfo(skb)->tso_size) != 0) {
38311 +               int tcp_opt_len, ip_tcp_len;
38312  
38313 -               /* TSO firmware wants TCP options included in
38314 -                * tx descriptor MSS value.
38315 -                */
38316 -               mss += ((skb->h.th->doff * 4) - 20);
38317 +               tcp_opt_len = ((skb->h.th->doff - 5) * 4);
38318 +               ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
38319  
38320                 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
38321                                TXD_FLAG_CPU_POST_DMA);
38322  
38323 -               if (times++ < 5) {
38324 -                       printk("tg3_xmit: tso_size[%u] tso_segs[%u] len[%u]\n",
38325 -                              (unsigned int) skb_shinfo(skb)->tso_size,
38326 -                              (unsigned int) skb_shinfo(skb)->tso_segs,
38327 -                              skb->len);
38328 +               skb->nh.iph->check = 0;
38329 +               skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len);
38330 +               skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
38331 +                                                     skb->nh.iph->daddr,
38332 +                                                     0, IPPROTO_TCP, 0);
38333 +
38334 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
38335 +                       if (tcp_opt_len || skb->nh.iph->ihl > 5) {
38336 +                               int tsflags;
38337 +
38338 +                               tsflags = ((skb->nh.iph->ihl - 5) +
38339 +                                          (tcp_opt_len >> 2));
38340 +                               mss |= (tsflags << 11);
38341 +                       }
38342 +               } else {
38343 +                       mss += tcp_opt_len;
38344                 }
38345         }
38346  #else
38347 @@ -2698,7 +2997,7 @@
38348  {
38349         struct tg3 *tp = dev->priv;
38350  
38351 -       if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU)
38352 +       if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU(tp))
38353                 return -EINVAL;
38354  
38355         if (!netif_running(dev)) {
38356 @@ -2816,7 +3115,7 @@
38357         /* Zero out all descriptors. */
38358         memset(tp->rx_std, 0, TG3_RX_RING_BYTES);
38359         memset(tp->rx_jumbo, 0, TG3_RX_JUMBO_RING_BYTES);
38360 -       memset(tp->rx_rcb, 0, TG3_RX_RCB_RING_BYTES);
38361 +       memset(tp->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp));
38362  
38363         if (tp->tg3_flags & TG3_FLAG_HOST_TXDS) {
38364                 memset(tp->tx_ring, 0, TG3_TX_RING_BYTES);
38365 @@ -2899,7 +3198,7 @@
38366                 tp->rx_jumbo = NULL;
38367         }
38368         if (tp->rx_rcb) {
38369 -               pci_free_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES,
38370 +               pci_free_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp),
38371                                     tp->rx_rcb, tp->rx_rcb_mapping);
38372                 tp->rx_rcb = NULL;
38373         }
38374 @@ -2957,7 +3256,7 @@
38375         if (!tp->rx_jumbo)
38376                 goto err_out;
38377  
38378 -       tp->rx_rcb = pci_alloc_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES,
38379 +       tp->rx_rcb = pci_alloc_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp),
38380                                           &tp->rx_rcb_mapping);
38381         if (!tp->rx_rcb)
38382                 goto err_out;
38383 @@ -3004,6 +3303,23 @@
38384         unsigned int i;
38385         u32 val;
38386  
38387 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
38388 +               switch (ofs) {
38389 +               case RCVLSC_MODE:
38390 +               case DMAC_MODE:
38391 +               case MBFREE_MODE:
38392 +               case BUFMGR_MODE:
38393 +               case MEMARB_MODE:
38394 +                       /* We can't enable/disable these bits of the
38395 +                        * 5705, just say success.
38396 +                        */
38397 +                       return 0;
38398 +
38399 +               default:
38400 +                       break;
38401 +               };
38402 +       }
38403 +
38404         val = tr32(ofs);
38405         val &= ~enable_bit;
38406         tw32(ofs, val);
38407 @@ -3127,7 +3443,10 @@
38408         tp->tg3_flags &= ~TG3_FLAG_5701_REG_WRITE_BUG;
38409  
38410         /* do the reset */
38411 -       tw32(GRC_MISC_CFG, GRC_MISC_CFG_CORECLK_RESET);
38412 +       val = GRC_MISC_CFG_CORECLK_RESET;
38413 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
38414 +               val |= GRC_MISC_CFG_KEEP_GPHY_POWER;
38415 +       tw32(GRC_MISC_CFG, val);
38416  
38417         /* restore 5701 hardware bug workaround flag */
38418         tp->tg3_flags = flags_save;
38419 @@ -3163,6 +3482,13 @@
38420  
38421         tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
38422  
38423 +       if ((tp->nic_sram_data_cfg & NIC_SRAM_DATA_CFG_MINI_PCI) != 0 &&
38424 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
38425 +               tp->pci_clock_ctrl |=
38426 +                       (CLOCK_CTRL_FORCE_CLKRUN | CLOCK_CTRL_CLKRUN_OENABLE);
38427 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
38428 +       }
38429 +
38430         tw32(TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl);
38431  }
38432  
38433 @@ -3358,28 +3684,32 @@
38434  #define TX_CPU_SCRATCH_SIZE    0x04000
38435  
38436  /* tp->lock is held. */
38437 -static int tg3_reset_cpu(struct tg3 *tp, u32 offset)
38438 +static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
38439  {
38440         int i;
38441  
38442 -       tw32(offset + CPU_STATE, 0xffffffff);
38443 -       tw32(offset + CPU_MODE,  CPU_MODE_RESET);
38444 +       if (offset == TX_CPU_BASE &&
38445 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
38446 +               BUG();
38447 +
38448         if (offset == RX_CPU_BASE) {
38449 -               for (i = 0; i < 10000; i++)
38450 -                       if (!(tr32(offset + CPU_MODE) & CPU_MODE_RESET))
38451 +               for (i = 0; i < 10000; i++) {
38452 +                       tw32(offset + CPU_STATE, 0xffffffff);
38453 +                       tw32(offset + CPU_MODE,  CPU_MODE_HALT);
38454 +                       if (tr32(offset + CPU_MODE) & CPU_MODE_HALT)
38455                                 break;
38456 +               }
38457 +
38458                 tw32(offset + CPU_STATE, 0xffffffff);
38459 -               tw32(offset + CPU_MODE,  CPU_MODE_RESET);
38460 +               tw32(offset + CPU_MODE,  CPU_MODE_HALT);
38461                 tr32(offset + CPU_MODE);
38462                 udelay(10);
38463         } else {
38464                 for (i = 0; i < 10000; i++) {
38465 -                       if (!(tr32(offset + CPU_MODE) & CPU_MODE_RESET))
38466 -                               break;
38467                         tw32(offset + CPU_STATE, 0xffffffff);
38468 -                       tw32(offset + CPU_MODE,  CPU_MODE_RESET);
38469 -                       tr32(offset + CPU_MODE);
38470 -                       udelay(10);
38471 +                       tw32(offset + CPU_MODE,  CPU_MODE_HALT);
38472 +                       if (tr32(offset + CPU_MODE) & CPU_MODE_HALT)
38473 +                               break;
38474                 }
38475         }
38476  
38477 @@ -3411,38 +3741,52 @@
38478  {
38479         int err, i;
38480         u32 orig_tg3_flags = tp->tg3_flags;
38481 +       void (*write_op)(struct tg3 *, u32, u32);
38482 +
38483 +       if (cpu_base == TX_CPU_BASE &&
38484 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
38485 +               printk(KERN_ERR PFX "tg3_load_firmware_cpu: Trying to load "
38486 +                      "TX cpu firmware on %s which is 5705.\n",
38487 +                      tp->dev->name);
38488 +               return -EINVAL;
38489 +       }
38490 +
38491 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
38492 +               write_op = tg3_write_mem;
38493 +       else
38494 +               write_op = tg3_write_indirect_reg32;
38495  
38496         /* Force use of PCI config space for indirect register
38497          * write calls.
38498          */
38499         tp->tg3_flags |= TG3_FLAG_PCIX_TARGET_HWBUG;
38500  
38501 -       err = tg3_reset_cpu(tp, cpu_base);
38502 +       err = tg3_halt_cpu(tp, cpu_base);
38503         if (err)
38504                 goto out;
38505  
38506         for (i = 0; i < cpu_scratch_size; i += sizeof(u32))
38507 -               tg3_write_indirect_reg32(tp, cpu_scratch_base + i, 0);
38508 +               write_op(tp, cpu_scratch_base + i, 0);
38509         tw32(cpu_base + CPU_STATE, 0xffffffff);
38510         tw32(cpu_base + CPU_MODE, tr32(cpu_base+CPU_MODE)|CPU_MODE_HALT);
38511         for (i = 0; i < (info->text_len / sizeof(u32)); i++)
38512 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
38513 -                                             (info->text_base & 0xffff) +
38514 -                                             (i * sizeof(u32))),
38515 -                                        (info->text_data ?
38516 -                                         info->text_data[i] : 0));
38517 +               write_op(tp, (cpu_scratch_base +
38518 +                             (info->text_base & 0xffff) +
38519 +                             (i * sizeof(u32))),
38520 +                        (info->text_data ?
38521 +                         info->text_data[i] : 0));
38522         for (i = 0; i < (info->rodata_len / sizeof(u32)); i++)
38523 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
38524 -                                             (info->rodata_base & 0xffff) +
38525 -                                             (i * sizeof(u32))),
38526 -                                        (info->rodata_data ?
38527 -                                         info->rodata_data[i] : 0));
38528 +               write_op(tp, (cpu_scratch_base +
38529 +                             (info->rodata_base & 0xffff) +
38530 +                             (i * sizeof(u32))),
38531 +                        (info->rodata_data ?
38532 +                         info->rodata_data[i] : 0));
38533         for (i = 0; i < (info->data_len / sizeof(u32)); i++)
38534 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
38535 -                                             (info->data_base & 0xffff) +
38536 -                                             (i * sizeof(u32))),
38537 -                                        (info->data_data ?
38538 -                                         info->data_data[i] : 0));
38539 +               write_op(tp, (cpu_scratch_base +
38540 +                             (info->data_base & 0xffff) +
38541 +                             (i * sizeof(u32))),
38542 +                        (info->data_data ?
38543 +                         info->data_data[i] : 0));
38544  
38545         err = 0;
38546  
38547 @@ -3513,269 +3857,318 @@
38548         return 0;
38549  }
38550  
38551 -#if TG3_DO_TSO != 0
38552 +#if TG3_TSO_SUPPORT != 0
38553  
38554  #define TG3_TSO_FW_RELEASE_MAJOR       0x1
38555 -#define TG3_TSO_FW_RELASE_MINOR                0x8
38556 +#define TG3_TSO_FW_RELASE_MINOR                0x3
38557  #define TG3_TSO_FW_RELEASE_FIX         0x0
38558  #define TG3_TSO_FW_START_ADDR          0x08000000
38559  #define TG3_TSO_FW_TEXT_ADDR           0x08000000
38560 -#define TG3_TSO_FW_TEXT_LEN            0x1650
38561 +#define TG3_TSO_FW_TEXT_LEN            0x1ac0
38562  #define TG3_TSO_FW_RODATA_ADDR         0x08001650
38563 -#define TG3_TSO_FW_RODATA_LEN          0x30
38564 +#define TG3_TSO_FW_RODATA_LEN          0x60
38565  #define TG3_TSO_FW_DATA_ADDR           0x080016a0
38566  #define TG3_TSO_FW_DATA_LEN            0x20
38567  #define TG3_TSO_FW_SBSS_ADDR           0x080016c0
38568 -#define TG3_TSO_FW_SBSS_LEN            0x14
38569 +#define TG3_TSO_FW_SBSS_LEN            0x2c
38570  #define TG3_TSO_FW_BSS_ADDR            0x080016e0
38571 -#define TG3_TSO_FW_BSS_LEN             0x8fc
38572 +#define TG3_TSO_FW_BSS_LEN             0x890
38573  
38574  static u32 tg3TsoFwText[] = {
38575         0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c1d0800,
38576         0x37bd4000, 0x03a0f021, 0x3c100800, 0x26100000, 0x0e000010, 0x00000000,
38577 -       0x0000000d, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0x3c1bc000,
38578 -       0xafbf0018, 0x0e000058, 0xaf60680c, 0x3c040800, 0x24841650, 0x03602821,
38579 -       0x24060001, 0x24070004, 0xafa00010, 0x0e00006c, 0xafa00014, 0x8f625c50,
38580 -       0x34420001, 0xaf625c50, 0x8f625c90, 0x34420001, 0xaf625c90, 0x2402ffff,
38581 -       0x0e000098, 0xaf625404, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x00000000,
38582 -       0x00000000, 0x00000000, 0x24030b60, 0x24050fff, 0xac000b50, 0x00002021,
38583 -       0xac640000, 0x24630004, 0x0065102b, 0x1440fffc, 0x24840001, 0x24030b60,
38584 -       0x0065102b, 0x10400011, 0x00002021, 0x24090b54, 0x3c06dead, 0x34c6beef,
38585 -       0x24080b58, 0x24070b5c, 0x8c620000, 0x50440006, 0x24630004, 0xad260000,
38586 -       0x8c620000, 0xace40000, 0xad020000, 0x24630004, 0x0065102b, 0x1440fff6,
38587 -       0x24840001, 0x03e00008, 0x00000000, 0x27bdfff8, 0x18800009, 0x00002821,
38588 -       0x8f63680c, 0x8f62680c, 0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a,
38589 -       0x1440fff9, 0x00000000, 0x03e00008, 0x27bd0008, 0x3c020800, 0x34423000,
38590 -       0x3c030800, 0x34633000, 0x3c040800, 0x348437ff, 0x3c010800, 0xac2216c4,
38591 -       0x24020040, 0x3c010800, 0xac2216c8, 0x3c010800, 0xac2016c0, 0xac600000,
38592 -       0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
38593 -       0x00804821, 0x8faa0010, 0x3c020800, 0x8c4216c0, 0x3c040800, 0x8c8416c8,
38594 -       0x8fab0014, 0x24430001, 0x0044102b, 0x3c010800, 0xac2316c0, 0x14400003,
38595 -       0x00004021, 0x3c010800, 0xac2016c0, 0x3c020800, 0x8c4216c0, 0x3c030800,
38596 -       0x8c6316c4, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
38597 -       0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020800, 0x8c4216c0,
38598 -       0x3c030800, 0x8c6316c4, 0x8f64680c, 0x00021140, 0x00431021, 0xac440008,
38599 -       0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
38600 -       0x00000000, 0x00000000, 0x27bdffe0, 0xafbf0018, 0xafb10014, 0x0e0000b6,
38601 -       0xafb00010, 0x24110001, 0x8f706820, 0x32020100, 0x10400003, 0x00000000,
38602 -       0x0e000127, 0x00000000, 0x8f706820, 0x32022000, 0x10400004, 0x32020001,
38603 -       0x0e00025a, 0x24040001, 0x32020001, 0x10400003, 0x00000000, 0x0e0000e6,
38604 -       0x00000000, 0x0a00009e, 0xaf715028, 0x8fbf0018, 0x8fb10014, 0x8fb00010,
38605 -       0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x24841660, 0x00002821,
38606 -       0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00006c, 0xafa00014,
38607 -       0x3c010800, 0xa4201fb8, 0x3c010800, 0xa02016f8, 0x3c010800, 0xac2016fc,
38608 -       0x3c010800, 0xac201700, 0x3c010800, 0xac201704, 0x3c010800, 0xac20170c,
38609 -       0x3c010800, 0xac201718, 0x3c010800, 0xac20171c, 0x8f624434, 0x3c010800,
38610 -       0xac2216e8, 0x8f624438, 0x3c010800, 0xac2216ec, 0x8f624410, 0x3c010800,
38611 -       0xac2016e0, 0x3c010800, 0xac2016e4, 0x3c010800, 0xac201fc0, 0x3c010800,
38612 -       0xac201f68, 0x3c010800, 0xac201f6c, 0x3c010800, 0xac2216f0, 0x8fbf0018,
38613 -       0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x2484166c, 0x00002821,
38614 -       0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00006c, 0xafa00014,
38615 -       0x3c040800, 0x24841660, 0x00002821, 0x00003021, 0x00003821, 0xafa00010,
38616 -       0x0e00006c, 0xafa00014, 0x3c010800, 0xa4201fb8, 0x3c010800, 0xa02016f8,
38617 -       0x3c010800, 0xac2016fc, 0x3c010800, 0xac201700, 0x3c010800, 0xac201704,
38618 -       0x3c010800, 0xac20170c, 0x3c010800, 0xac201718, 0x3c010800, 0xac20171c,
38619 -       0x8f624434, 0x3c010800, 0xac2216e8, 0x8f624438, 0x3c010800, 0xac2216ec,
38620 -       0x8f624410, 0x3c010800, 0xac2016e0, 0x3c010800, 0xac2016e4, 0x3c010800,
38621 -       0xac201fc0, 0x3c010800, 0xac201f68, 0x3c010800, 0xac201f6c, 0x3c010800,
38622 -       0xac2216f0, 0x0e000120, 0x00002021, 0x8fbf0018, 0x03e00008, 0x27bd0020,
38623 -       0x24020001, 0x8f636820, 0x00821004, 0x00021027, 0x00621824, 0x03e00008,
38624 -       0xaf636820, 0x27bdffd0, 0x3c0300ff, 0xafbf002c, 0xafb60028, 0xafb50024,
38625 -       0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x8f665c5c,
38626 -       0x3c040800, 0x2484171c, 0x8c820000, 0x3463fff8, 0x14460005, 0x00c38824,
38627 -       0x3c020800, 0x904216f8, 0x14400115, 0x00000000, 0x00111902, 0x306300ff,
38628 -       0x30c20003, 0x000211c0, 0x00623825, 0x00e02821, 0x00061602, 0xac860000,
38629 -       0x3c030800, 0x906316f8, 0x3044000f, 0x1460002b, 0x00804021, 0x24020001,
38630 -       0x3c010800, 0xa02216f8, 0x00071100, 0x00821025, 0x3c010800, 0xac2016fc,
38631 -       0x3c010800, 0xac201700, 0x3c010800, 0xac201704, 0x3c010800, 0xac20170c,
38632 -       0x3c010800, 0xac201718, 0x3c010800, 0xac201710, 0x3c010800, 0xac201714,
38633 -       0x3c010800, 0xa4221fb8, 0x9623000c, 0x30628000, 0x10400008, 0x30627fff,
38634 -       0x2442003e, 0x3c010800, 0xa42216f6, 0x24020001, 0x3c010800, 0x0a00016e,
38635 -       0xac221fd4, 0x24620036, 0x3c010800, 0xa42216f6, 0x3c010800, 0xac201fd4,
38636 -       0x3c010800, 0xac201fd0, 0x3c010800, 0x0a000176, 0xac201fd8, 0x9622000c,
38637 -       0x3c010800, 0xa4221fcc, 0x3c040800, 0x248416fc, 0x8c820000, 0x00021100,
38638 -       0x3c010800, 0x00220821, 0xac311728, 0x8c820000, 0x00021100, 0x3c010800,
38639 -       0x00220821, 0xac26172c, 0x8c820000, 0x24a30001, 0x306701ff, 0x00021100,
38640 -       0x3c010800, 0x00220821, 0xac271730, 0x8c820000, 0x00021100, 0x3c010800,
38641 -       0x00220821, 0xac281734, 0x96230008, 0x3c020800, 0x8c42170c, 0x00432821,
38642 -       0x3c010800, 0xac25170c, 0x9622000a, 0x30420004, 0x14400019, 0x00071100,
38643 -       0x3c02c000, 0x00c21825, 0xaf635c5c, 0x8f625c50, 0x30420002, 0x1440fffc,
38644 -       0x00000000, 0x8f630c14, 0x3063000f, 0x2c620002, 0x1440001e, 0x00000000,
38645 -       0x8f630c14, 0x3c020800, 0x8c4216b4, 0x3063000f, 0x24420001, 0x3c010800,
38646 -       0xac2216b4, 0x2c620002, 0x1040fff7, 0x00000000, 0x0a0001c1, 0x00000000,
38647 -       0x3c030800, 0x8c6316e0, 0x3c040800, 0x948416f4, 0x01021025, 0x3c010800,
38648 -       0xa4221fba, 0x24020001, 0x3c010800, 0xac221718, 0x24630001, 0x0085202a,
38649 -       0x3c010800, 0x10800003, 0xac2316e0, 0x3c010800, 0xa42516f4, 0x3c030800,
38650 -       0x246316fc, 0x8c620000, 0x24420001, 0xac620000, 0x28420080, 0x14400005,
38651 -       0x24020001, 0x0e0002df, 0x24040002, 0x0a000250, 0x00000000, 0x3c030800,
38652 -       0x906316f8, 0x1462007c, 0x24020003, 0x3c160800, 0x96d616f6, 0x3c050800,
38653 -       0x8ca5170c, 0x32c4ffff, 0x00a4102a, 0x14400078, 0x00000000, 0x3c020800,
38654 -       0x8c421718, 0x10400005, 0x32c2ffff, 0x14a40003, 0x00000000, 0x3c010800,
38655 -       0xac231fd0, 0x10400062, 0x00009021, 0x0040a021, 0x3c150800, 0x26b51700,
38656 -       0x26b30010, 0x8ea20000, 0x00028100, 0x3c110800, 0x02308821, 0x0e0002e1,
38657 -       0x8e311728, 0x00403021, 0x10c00059, 0x00000000, 0x9628000a, 0x31020040,
38658 -       0x10400004, 0x2407180c, 0x8e22000c, 0x2407188c, 0xacc20018, 0x31021000,
38659 -       0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825, 0x3c030800,
38660 -       0x00701821, 0x8c631730, 0x3c020800, 0x00501021, 0x8c421734, 0x00031d00,
38661 -       0x00021400, 0x00621825, 0xacc30014, 0x8ea30004, 0x96220008, 0x00432023,
38662 -       0x3242ffff, 0x3083ffff, 0x00431021, 0x0282102a, 0x14400002, 0x02d22823,
38663 -       0x00802821, 0x8e620000, 0x30a4ffff, 0x00441021, 0xae620000, 0x8e220000,
38664 -       0xacc20000, 0x8e220004, 0x8e63fff4, 0x00431021, 0xacc20004, 0xa4c5000e,
38665 -       0x8e62fff4, 0x00441021, 0xae62fff4, 0x96230008, 0x0043102a, 0x14400005,
38666 -       0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001, 0xae62fff0, 0xacc00008,
38667 -       0x3242ffff, 0x14540008, 0x24020305, 0x31020080, 0x54400001, 0x34e70010,
38668 -       0x24020905, 0xa4c2000c, 0x0a000233, 0x34e70020, 0xa4c2000c, 0x30e2ffff,
38669 -       0xacc20010, 0x3c020800, 0x8c421fd0, 0x10400003, 0x3c024b65, 0x0a00023d,
38670 -       0x34427654, 0x3c02b49a, 0x344289ab, 0xacc2001c, 0x0e000560, 0x00c02021,
38671 -       0x3242ffff, 0x0054102b, 0x1440ffa4, 0x00000000, 0x24020002, 0x3c010800,
38672 -       0x0a000250, 0xa02216f8, 0x8ea208bc, 0x24420001, 0x0a000250, 0xaea208bc,
38673 -       0x14620003, 0x00000000, 0x0e000450, 0x00000000, 0x8fbf002c, 0x8fb60028,
38674 -       0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
38675 -       0x03e00008, 0x27bd0030, 0x27bdffd8, 0xafb3001c, 0x00809821, 0xafbf0020,
38676 -       0xafb20018, 0xafb10014, 0xafb00010, 0x8f725c9c, 0x3c0200ff, 0x3442fff8,
38677 -       0x3c040800, 0x24841714, 0x02428824, 0x9623000e, 0x8c820000, 0x00431021,
38678 -       0xac820000, 0x8e220010, 0x30420020, 0x14400011, 0x00000000, 0x0e0002f7,
38679 +       0x0000000d, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0x3c04fefe,
38680 +       0xafbf0018, 0x0e0005e0, 0x34840002, 0x0e000670, 0x00000000, 0x3c030800,
38681 +       0x90631b78, 0x24020002, 0x3c040800, 0x24841acc, 0x14620003, 0x24050001,
38682 +       0x3c040800, 0x24841ac0, 0x24060002, 0x00003821, 0xafa00010, 0x0e000684,
38683 +       0xafa00014, 0x8f625c50, 0x34420001, 0xaf625c50, 0x8f625c90, 0x34420001,
38684 +       0xaf625c90, 0x2402ffff, 0x0e000034, 0xaf625404, 0x8fbf0018, 0x03e00008,
38685 +       0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0xafbf0018,
38686 +       0xafb10014, 0x0e000052, 0xafb00010, 0x24110001, 0x8f706820, 0x32020100,
38687 +       0x10400003, 0x00000000, 0x0e0000b2, 0x00000000, 0x8f706820, 0x32022000,
38688 +       0x10400004, 0x32020001, 0x0e0001e3, 0x24040001, 0x32020001, 0x10400003,
38689 +       0x00000000, 0x0e00009a, 0x00000000, 0x0a00003a, 0xaf715028, 0x8fbf0018,
38690 +       0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800,
38691 +       0x24841ae0, 0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
38692 +       0x0e000684, 0xafa00014, 0x3c040800, 0x248423e8, 0xa4800000, 0x3c010800,
38693 +       0xa0201ba8, 0x3c010800, 0xac201bac, 0x3c010800, 0xac201bb0, 0x3c010800,
38694 +       0xac201bb4, 0x3c010800, 0xac201bbc, 0x3c010800, 0xac201bc8, 0x3c010800,
38695 +       0xac201bcc, 0x8f624434, 0x3c010800, 0xac221b98, 0x8f624438, 0x3c010800,
38696 +       0xac221b9c, 0x8f624410, 0xac80f7a8, 0x3c010800, 0xac201b94, 0x3c010800,
38697 +       0xac2023f0, 0x3c010800, 0xac2023d8, 0x3c010800, 0xac2023dc, 0x3c010800,
38698 +       0xac202410, 0x3c010800, 0xac221ba0, 0x8f620068, 0x24030007, 0x00021702,
38699 +       0x10430005, 0x00000000, 0x8f620068, 0x00021702, 0x14400004, 0x24020001,
38700 +       0x3c010800, 0x0a00008e, 0xac20241c, 0xac820034, 0x3c040800, 0x24841aec,
38701 +       0x3c050800, 0x8ca5241c, 0x00003021, 0x00003821, 0xafa00010, 0x0e000684,
38702 +       0xafa00014, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800,
38703 +       0x24841af8, 0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
38704 +       0x0e000684, 0xafa00014, 0x0e000052, 0x00000000, 0x0e0000ab, 0x00002021,
38705 +       0x8fbf0018, 0x03e00008, 0x27bd0020, 0x24020001, 0x8f636820, 0x00821004,
38706 +       0x00021027, 0x00621824, 0x03e00008, 0xaf636820, 0x27bdffd0, 0xafbf002c,
38707 +       0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014,
38708 +       0xafb00010, 0x8f665c5c, 0x3c030800, 0x24631bcc, 0x8c620000, 0x14460005,
38709 +       0x3c0200ff, 0x3c020800, 0x90421ba8, 0x14400115, 0x3c0200ff, 0x3442fff8,
38710 +       0x00c28824, 0xac660000, 0x00111902, 0x306300ff, 0x30c20003, 0x000211c0,
38711 +       0x00623825, 0x00e02821, 0x00061602, 0x3c030800, 0x90631ba8, 0x3044000f,
38712 +       0x1460002b, 0x00804021, 0x24020001, 0x3c010800, 0xa0221ba8, 0x00071100,
38713 +       0x00821025, 0x3c010800, 0xac201bac, 0x3c010800, 0xac201bb0, 0x3c010800,
38714 +       0xac201bb4, 0x3c010800, 0xac201bbc, 0x3c010800, 0xac201bc8, 0x3c010800,
38715 +       0xac201bc0, 0x3c010800, 0xac201bc4, 0x3c010800, 0xa42223e8, 0x9623000c,
38716 +       0x30628000, 0x10400008, 0x30627fff, 0x2442003e, 0x3c010800, 0xa4221ba6,
38717 +       0x24020001, 0x3c010800, 0x0a0000f9, 0xac222404, 0x24620036, 0x3c010800,
38718 +       0xa4221ba6, 0x3c010800, 0xac202404, 0x3c010800, 0xac202400, 0x3c010800,
38719 +       0x0a000101, 0xac202408, 0x9622000c, 0x3c010800, 0xa42223fc, 0x3c040800,
38720 +       0x24841bac, 0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac311bd8,
38721 +       0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac261bdc, 0x8c820000,
38722 +       0x24a30001, 0x306701ff, 0x00021100, 0x3c010800, 0x00220821, 0xac271be0,
38723 +       0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac281be4, 0x96230008,
38724 +       0x3c020800, 0x8c421bbc, 0x00432821, 0x3c010800, 0xac251bbc, 0x9622000a,
38725 +       0x30420004, 0x14400018, 0x00071100, 0x8f630c14, 0x3063000f, 0x2c620002,
38726 +       0x1440000b, 0x3c02c000, 0x8f630c14, 0x3c020800, 0x8c421b50, 0x3063000f,
38727 +       0x24420001, 0x3c010800, 0xac221b50, 0x2c620002, 0x1040fff7, 0x3c02c000,
38728 +       0x00c21825, 0xaf635c5c, 0x8f625c50, 0x30420002, 0x10400014, 0x00000000,
38729 +       0x0a000133, 0x00000000, 0x3c030800, 0x8c631b90, 0x3c040800, 0x94841ba4,
38730 +       0x01021025, 0x3c010800, 0xa42223ea, 0x24020001, 0x3c010800, 0xac221bc8,
38731 +       0x24630001, 0x0085202a, 0x3c010800, 0x10800003, 0xac231b90, 0x3c010800,
38732 +       0xa4251ba4, 0x3c060800, 0x24c61bac, 0x8cc20000, 0x24420001, 0xacc20000,
38733 +       0x28420080, 0x14400005, 0x00000000, 0x0e00065e, 0x24040002, 0x0a0001d9,
38734 +       0x00000000, 0x3c020800, 0x8c421bc8, 0x1040007f, 0x24020001, 0x3c040800,
38735 +       0x90841ba8, 0x14820077, 0x24020003, 0x3c150800, 0x96b51ba6, 0x3c050800,
38736 +       0x8ca51bbc, 0x32a3ffff, 0x00a3102a, 0x14400073, 0x00000000, 0x14a30003,
38737 +       0x00000000, 0x3c010800, 0xac242400, 0x10600061, 0x00009021, 0x24d60004,
38738 +       0x0060a021, 0x24d30014, 0x8ec20000, 0x00028100, 0x3c110800, 0x02308821,
38739 +       0x0e00062d, 0x8e311bd8, 0x00403021, 0x10c00059, 0x00000000, 0x9628000a,
38740 +       0x31020040, 0x10400004, 0x2407180c, 0x8e22000c, 0x2407188c, 0xacc20018,
38741 +       0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825,
38742 +       0x3c030800, 0x00701821, 0x8c631be0, 0x3c020800, 0x00501021, 0x8c421be4,
38743 +       0x00031d00, 0x00021400, 0x00621825, 0xacc30014, 0x8ec30004, 0x96220008,
38744 +       0x00432023, 0x3242ffff, 0x3083ffff, 0x00431021, 0x0282102a, 0x14400002,
38745 +       0x02b22823, 0x00802821, 0x8e620000, 0x30a4ffff, 0x00441021, 0xae620000,
38746 +       0x8e220000, 0xacc20000, 0x8e220004, 0x8e63fff4, 0x00431021, 0xacc20004,
38747 +       0xa4c5000e, 0x8e62fff4, 0x00441021, 0xae62fff4, 0x96230008, 0x0043102a,
38748 +       0x14400005, 0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001, 0xae62fff0,
38749 +       0xacc00008, 0x3242ffff, 0x14540008, 0x24020305, 0x31020080, 0x54400001,
38750 +       0x34e70010, 0x24020905, 0xa4c2000c, 0x0a0001bc, 0x34e70020, 0xa4c2000c,
38751 +       0x3c020800, 0x8c422400, 0x10400003, 0x3c024b65, 0x0a0001c4, 0x34427654,
38752 +       0x3c02b49a, 0x344289ab, 0xacc2001c, 0x30e2ffff, 0xacc20010, 0x0e0005aa,
38753 +       0x00c02021, 0x3242ffff, 0x0054102b, 0x1440ffa4, 0x00000000, 0x24020002,
38754 +       0x3c010800, 0x0a0001d9, 0xa0221ba8, 0x8ec2083c, 0x24420001, 0x0a0001d9,
38755 +       0xaec2083c, 0x14820003, 0x00000000, 0x0e0004b9, 0x00000000, 0x8fbf002c,
38756 +       0x8fb60028, 0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
38757 +       0x8fb00010, 0x03e00008, 0x27bd0030, 0x27bdffd0, 0xafbf0028, 0xafb30024,
38758 +       0xafb20020, 0xafb1001c, 0xafb00018, 0x8f725c9c, 0x3c0200ff, 0x3442fff8,
38759 +       0x3c060800, 0x24c61bc4, 0x02428824, 0x9623000e, 0x8cc20000, 0x00431021,
38760 +       0xacc20000, 0x8e220010, 0x30420020, 0x14400011, 0x00809821, 0x0e000643,
38761         0x02202021, 0x3c02c000, 0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002,
38762 -       0x10400061, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1040005c,
38763 -       0x00000000, 0x0a000278, 0x00000000, 0x8e220008, 0x00021c02, 0x000321c0,
38764 -       0x3042ffff, 0x3c030800, 0x906316f8, 0x000229c0, 0x24020002, 0x14620003,
38765 -       0x3c034b65, 0x0a000290, 0x00008021, 0x8e22001c, 0x34637654, 0x10430002,
38766 -       0x24100002, 0x24100001, 0x0e000300, 0x02003021, 0x24020003, 0x3c010800,
38767 -       0xa02216f8, 0x24020002, 0x1202000a, 0x24020001, 0x3c030800, 0x8c631fd0,
38768 -       0x10620006, 0x00000000, 0x3c020800, 0x94421fb8, 0x00021400, 0x0a0002cd,
38769 -       0xae220014, 0x3c040800, 0x24841fba, 0x94820000, 0x00021400, 0xae220014,
38770 -       0x3c020800, 0x8c42171c, 0x3c03c000, 0x3c010800, 0xa02016f8, 0x00431025,
38771 -       0xaf625c5c, 0x8f625c50, 0x30420002, 0x10400009, 0x00000000, 0x2484f762,
38772 +       0x10400121, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1040011c,
38773 +       0x00000000, 0x0a000200, 0x00000000, 0x8e240008, 0x8e230014, 0x00041402,
38774 +       0x000241c0, 0x00031502, 0x304201ff, 0x2442ffff, 0x3042007f, 0x00031942,
38775 +       0x30637800, 0x00021100, 0x24424000, 0x00625021, 0x9542000a, 0x3084ffff,
38776 +       0x30420008, 0x104000b3, 0x000429c0, 0x3c020800, 0x8c422410, 0x1440002d,
38777 +       0x25050008, 0x95020014, 0x3c010800, 0xa42223e0, 0x8d070010, 0x00071402,
38778 +       0x3c010800, 0xa42223e2, 0x3c010800, 0xa42723e4, 0x9502000e, 0x30e3ffff,
38779 +       0x00431023, 0x3c010800, 0xac222418, 0x8f626800, 0x3c030010, 0x00431024,
38780 +       0x10400005, 0x00000000, 0x9503001a, 0x9502001c, 0x0a000235, 0x00431021,
38781 +       0x9502001a, 0x3c010800, 0xac22240c, 0x3c02c000, 0x02421825, 0x3c010800,
38782 +       0xac282410, 0x3c010800, 0xac322414, 0xaf635c9c, 0x8f625c90, 0x30420002,
38783 +       0x104000df, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x104000da,
38784 +       0x00000000, 0x0a000242, 0x00000000, 0x9502000e, 0x3c030800, 0x946323e4,
38785 +       0x00434823, 0x3123ffff, 0x2c620008, 0x1040001c, 0x00000000, 0x95020014,
38786 +       0x24420028, 0x00a22821, 0x00031042, 0x1840000b, 0x00002021, 0x24c60848,
38787 +       0x00403821, 0x94a30000, 0x8cc20000, 0x24840001, 0x00431021, 0xacc20000,
38788 +       0x0087102a, 0x1440fff9, 0x24a50002, 0x31220001, 0x1040001f, 0x3c024000,
38789 +       0x3c040800, 0x2484240c, 0xa0a00001, 0x94a30000, 0x8c820000, 0x00431021,
38790 +       0x0a000281, 0xac820000, 0x8f626800, 0x3c030010, 0x00431024, 0x10400009,
38791 +       0x00000000, 0x9502001a, 0x3c030800, 0x8c63240c, 0x00431021, 0x3c010800,
38792 +       0xac22240c, 0x0a000282, 0x3c024000, 0x9502001a, 0x9504001c, 0x3c030800,
38793 +       0x8c63240c, 0x00441023, 0x00621821, 0x3c010800, 0xac23240c, 0x3c024000,
38794 +       0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1440fffc, 0x00000000,
38795 +       0x9542000a, 0x30420010, 0x10400095, 0x00000000, 0x3c060800, 0x24c62410,
38796 +       0x3c020800, 0x944223e4, 0x8cc50000, 0x3c040800, 0x8c842418, 0x24420030,
38797 +       0x00a22821, 0x94a20004, 0x3c030800, 0x8c63240c, 0x00441023, 0x00621821,
38798 +       0x00603821, 0x00032402, 0x30e2ffff, 0x00823821, 0x00071402, 0x00e23821,
38799 +       0x00071027, 0x3c010800, 0xac23240c, 0xa4a20006, 0x3c030800, 0x8c632414,
38800 +       0x3c0200ff, 0x3442fff8, 0x00628824, 0x96220008, 0x24040001, 0x24034000,
38801 +       0x000241c0, 0x00e01021, 0xa502001a, 0xa500001c, 0xacc00000, 0x3c010800,
38802 +       0xac241b70, 0xaf635cb8, 0x8f625cb0, 0x30420002, 0x10400003, 0x00000000,
38803 +       0x3c010800, 0xac201b70, 0x8e220008, 0xaf625cb8, 0x8f625cb0, 0x30420002,
38804 +       0x10400003, 0x00000000, 0x3c010800, 0xac201b70, 0x3c020800, 0x8c421b70,
38805 +       0x1040ffec, 0x00000000, 0x3c040800, 0x0e000643, 0x8c842414, 0x0a000320,
38806 +       0x00000000, 0x3c030800, 0x90631ba8, 0x24020002, 0x14620003, 0x3c034b65,
38807 +       0x0a0002d7, 0x00008021, 0x8e22001c, 0x34637654, 0x10430002, 0x24100002,
38808 +       0x24100001, 0x01002021, 0x0e000346, 0x02003021, 0x24020003, 0x3c010800,
38809 +       0xa0221ba8, 0x24020002, 0x1202000a, 0x24020001, 0x3c030800, 0x8c632400,
38810 +       0x10620006, 0x00000000, 0x3c020800, 0x944223e8, 0x00021400, 0x0a000315,
38811 +       0xae220014, 0x3c040800, 0x248423ea, 0x94820000, 0x00021400, 0xae220014,
38812 +       0x3c020800, 0x8c421bcc, 0x3c03c000, 0x3c010800, 0xa0201ba8, 0x00431025,
38813 +       0xaf625c5c, 0x8f625c50, 0x30420002, 0x10400009, 0x00000000, 0x2484f7e2,
38814         0x8c820000, 0x00431025, 0xaf625c5c, 0x8f625c50, 0x30420002, 0x1440fffa,
38815 -       0x00000000, 0x3c020800, 0x244216e4, 0x8c430000, 0x24630001, 0xac430000,
38816 -       0x8f630c14, 0x3063000f, 0x2c620002, 0x1440000b, 0x00009821, 0x8f630c14,
38817 -       0x3c020800, 0x8c4216b4, 0x3063000f, 0x24420001, 0x3c010800, 0xac2216b4,
38818 -       0x2c620002, 0x1040fff7, 0x00009821, 0x3c024000, 0x02421825, 0xaf635c9c,
38819 +       0x00000000, 0x3c020800, 0x24421b94, 0x8c430000, 0x24630001, 0xac430000,
38820 +       0x8f630c14, 0x3063000f, 0x2c620002, 0x1440000c, 0x3c024000, 0x8f630c14,
38821 +       0x3c020800, 0x8c421b50, 0x3063000f, 0x24420001, 0x3c010800, 0xac221b50,
38822 +       0x2c620002, 0x1040fff7, 0x00000000, 0x3c024000, 0x02421825, 0xaf635c9c,
38823         0x8f625c90, 0x30420002, 0x1440fffc, 0x00000000, 0x12600003, 0x00000000,
38824 -       0x0e000450, 0x00000000, 0x8fbf0020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
38825 -       0x8fb00010, 0x03e00008, 0x27bd0028, 0x0a0002df, 0x00000000, 0x8f634450,
38826 -       0x3c040800, 0x248416e8, 0x8c820000, 0x00031c02, 0x0043102b, 0x14400007,
38827 -       0x3c038000, 0x8c840004, 0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc,
38828 -       0x3c038000, 0xaf634444, 0x8f624444, 0x00431024, 0x1440fffd, 0x00000000,
38829 -       0x8f624448, 0x03e00008, 0x3042ffff, 0x3c024000, 0x00822025, 0xaf645c38,
38830 -       0x8f625c30, 0x30420002, 0x1440fffc, 0x00000000, 0x03e00008, 0x00000000,
38831 -       0x27bdffe0, 0x00805021, 0x14c00017, 0x254c0008, 0x3c020800, 0x8c421fd4,
38832 -       0x1040000a, 0x2402003e, 0x3c010800, 0xa4221fb0, 0x24020016, 0x3c010800,
38833 -       0xa4221fb2, 0x2402002a, 0x3c010800, 0x0a00031a, 0xa4221fb4, 0x95420014,
38834 -       0x3c010800, 0xa4221fb0, 0x8d430010, 0x00031402, 0x3c010800, 0xa4221fb2,
38835 -       0x3c010800, 0xa4231fb4, 0x3c040800, 0x94841fb4, 0x3c030800, 0x94631fb2,
38836 -       0x958d0006, 0x3c020800, 0x94421fb0, 0x00832023, 0x01a27023, 0x3065ffff,
38837 -       0x24a20028, 0x01824021, 0x3082ffff, 0x14c0001a, 0x01025821, 0x9562000c,
38838 -       0x3042003f, 0x3c010800, 0xa4221fb6, 0x95620004, 0x95630006, 0x3c010800,
38839 -       0xac201fc4, 0x3c010800, 0xac201fc8, 0x00021400, 0x00431025, 0x3c010800,
38840 -       0xac221720, 0x95020004, 0x3c010800, 0xa4221724, 0x95030002, 0x01a51023,
38841 -       0x0043102a, 0x10400010, 0x24020001, 0x3c010800, 0x0a00034e, 0xac221fd8,
38842 -       0x3c030800, 0x8c631fc8, 0x3c020800, 0x94421724, 0x00431021, 0xa5020004,
38843 -       0x3c020800, 0x94421720, 0xa5620004, 0x3c020800, 0x8c421720, 0xa5620006,
38844 -       0x3c020800, 0x8c421fd0, 0x3c070800, 0x8ce71fc4, 0x3c050800, 0x144000c7,
38845 -       0x8ca51fc8, 0x3c020800, 0x94421724, 0x00451821, 0x3063ffff, 0x0062182b,
38846 -       0x24020002, 0x10c2000d, 0x00a32823, 0x3c020800, 0x94421fb6, 0x30420009,
38847 -       0x10400008, 0x00000000, 0x9562000c, 0x3042fff6, 0xa562000c, 0x3c020800,
38848 -       0x94421fb6, 0x30420009, 0x00e23823, 0x3c020800, 0x8c421fd8, 0x1040004b,
38849 -       0x24020002, 0x01003021, 0x3c020800, 0x94421fb2, 0x00003821, 0xa500000a,
38850 -       0x01a21023, 0xa5020002, 0x3082ffff, 0x00021042, 0x18400008, 0x00002821,
38851 -       0x00401821, 0x94c20000, 0x24e70001, 0x00a22821, 0x00e3102a, 0x1440fffb,
38852 -       0x24c60002, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
38853 -       0x00a04821, 0x00051027, 0xa502000a, 0x00002821, 0x2506000c, 0x00003821,
38854 -       0x94c20000, 0x24e70001, 0x00a22821, 0x2ce20004, 0x1440fffb, 0x24c60002,
38855 -       0x95020002, 0x00003821, 0x91030009, 0x00442023, 0x01603021, 0x3082ffff,
38856 -       0xa4c00010, 0x00621821, 0x00021042, 0x18400010, 0x00a32821, 0x00404021,
38857 -       0x94c20000, 0x24c60002, 0x00a22821, 0x30c2007f, 0x14400006, 0x24e70001,
38858 -       0x8d430000, 0x3c02007f, 0x3442ff80, 0x00625024, 0x25460008, 0x00e8102a,
38859 -       0x1440fff3, 0x00000000, 0x30820001, 0x10400005, 0x00051c02, 0xa0c00001,
38860 -       0x94c20000, 0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
38861 -       0x00a22821, 0x0a000415, 0x30a5ffff, 0x14c20063, 0x00000000, 0x3c090800,
38862 -       0x95291fb2, 0x95030002, 0x01a91023, 0x1062005d, 0x01003021, 0x00003821,
38863 -       0x00002821, 0x01a91023, 0xa5020002, 0x3082ffff, 0x00021042, 0x18400008,
38864 -       0xa500000a, 0x00401821, 0x94c20000, 0x24e70001, 0x00a22821, 0x00e3102a,
38865 -       0x1440fffb, 0x24c60002, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
38866 -       0x00a22821, 0x00a04821, 0x00051027, 0xa502000a, 0x00002821, 0x2506000c,
38867 -       0x00003821, 0x94c20000, 0x24e70001, 0x00a22821, 0x2ce20004, 0x1440fffb,
38868 -       0x24c60002, 0x95020002, 0x00003821, 0x91030009, 0x00442023, 0x01603021,
38869 -       0x3082ffff, 0xa4c00010, 0x3c040800, 0x94841fb4, 0x00621821, 0x00a32821,
38870 -       0x00051c02, 0x30a2ffff, 0x00622821, 0x00051c02, 0x3c020800, 0x94421fb0,
38871 -       0x00a34021, 0x00441023, 0x00021fc2, 0x00431021, 0x00021043, 0x18400010,
38872 -       0x00002821, 0x00402021, 0x94c20000, 0x24c60002, 0x00a22821, 0x30c2007f,
38873 -       0x14400006, 0x24e70001, 0x8d430000, 0x3c02007f, 0x3442ff80, 0x00625024,
38874 -       0x25460008, 0x00e4102a, 0x1440fff3, 0x00000000, 0x3c020800, 0x94421fcc,
38875 -       0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
38876 -       0x3102ffff, 0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
38877 -       0x00a22821, 0x00a02021, 0x00051027, 0xa5620010, 0xad800014, 0x0a000435,
38878 -       0xad800000, 0x8d830010, 0x00602021, 0x10a00007, 0x00034c02, 0x01252821,
38879 -       0x00051402, 0x30a3ffff, 0x00432821, 0x00051402, 0x00a24821, 0x00091027,
38880 -       0xa502000a, 0x3c030800, 0x94631fb4, 0x3082ffff, 0x01a21021, 0x00432823,
38881 -       0x00a72821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
38882 -       0x00a02021, 0x00051027, 0xa5620010, 0x3082ffff, 0x00091c00, 0x00431025,
38883 -       0xad820010, 0x3c020800, 0x8c421fd4, 0x10400002, 0x25a2fff2, 0xa5820034,
38884 -       0x3c020800, 0x8c421fc8, 0x3c030800, 0x8c631720, 0x24420001, 0x3c010800,
38885 -       0xac221fc8, 0x3c020800, 0x8c421fc4, 0x31c4ffff, 0x00641821, 0x3c010800,
38886 -       0xac231720, 0x00441021, 0x3c010800, 0xac221fc4, 0x03e00008, 0x27bd0020,
38887 -       0x27bdffc8, 0x3c040800, 0x248416f8, 0xafbf0034, 0xafbe0030, 0xafb7002c,
38888 -       0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014,
38889 -       0xafb00010, 0x90830000, 0x24020003, 0x146200f4, 0x00000000, 0x3c020800,
38890 -       0x8c421710, 0x3c030800, 0x8c63170c, 0x3c1e0800, 0x97de16f6, 0x0043102a,
38891 -       0x104000eb, 0x3c168000, 0x249708c4, 0x33d5ffff, 0x24920018, 0x3c020800,
38892 -       0x8c421718, 0x104000e4, 0x00000000, 0x3c140800, 0x96941fb0, 0x3282ffff,
38893 -       0x104000d6, 0x00008021, 0x00409821, 0x00008821, 0x8f634450, 0x3c020800,
38894 -       0x8c4216e8, 0x00031c02, 0x0043102b, 0x14400008, 0x00000000, 0x3c040800,
38895 -       0x8c8416ec, 0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x00000000,
38896 -       0xaf764444, 0x8f624444, 0x00561024, 0x10400006, 0x00000000, 0x3c038000,
38897 -       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x3046ffff,
38898 -       0x10c0005f, 0x00000000, 0x3c090800, 0x01314821, 0x8d291728, 0x9528000a,
38899 -       0x31020040, 0x10400004, 0x2407180c, 0x8d22000c, 0x2407188c, 0xacc20018,
38900 -       0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825,
38901 -       0x31020080, 0x54400001, 0x34e70010, 0x3c020800, 0x00511021, 0x8c421730,
38902 -       0x3c030800, 0x00711821, 0x8c631734, 0x00021500, 0x00031c00, 0x00431025,
38903 -       0xacc20014, 0x95240008, 0x3202ffff, 0x00821021, 0x0262102a, 0x14400002,
38904 -       0x02902823, 0x00802821, 0x8d220000, 0x02058021, 0xacc20000, 0x8d220004,
38905 -       0x00c02021, 0x26310010, 0xac820004, 0x30e2ffff, 0xac800008, 0xa485000e,
38906 -       0xac820010, 0x24020305, 0x0e000560, 0xa482000c, 0x3202ffff, 0x0053102b,
38907 -       0x1440ffaf, 0x3202ffff, 0x0a00054c, 0x00000000, 0x8e420000, 0x8e43fffc,
38908 -       0x0043102a, 0x10400084, 0x00000000, 0x8e45fff0, 0x8f644450, 0x3c030800,
38909 -       0x8c6316e8, 0x00051100, 0x3c090800, 0x01224821, 0x8d291728, 0x00041402,
38910 -       0x0062182b, 0x14600008, 0x00000000, 0x3c030800, 0x8c6316ec, 0x8f624450,
38911 -       0x00021402, 0x0062102b, 0x1040fffc, 0x00000000, 0xaf764444, 0x8f624444,
38912 -       0x00561024, 0x10400006, 0x00000000, 0x3c038000, 0x8f624444, 0x00431024,
38913 -       0x1440fffd, 0x00000000, 0x8f624448, 0x3046ffff, 0x14c00005, 0x00000000,
38914 -       0x8ee20000, 0x24420001, 0x0a000554, 0xaee20000, 0x9528000a, 0x31020040,
38915 -       0x10400004, 0x2407180c, 0x8d22000c, 0x2407188c, 0xacc20018, 0x31021000,
38916 -       0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825, 0x00051900,
38917 -       0x3c020800, 0x00431021, 0x8c421730, 0x3c010800, 0x00230821, 0x8c231734,
38918 -       0x00021500, 0x00031c00, 0x00431025, 0xacc20014, 0x3c030800, 0x8c631704,
38919 -       0x95220008, 0x00432023, 0x3202ffff, 0x3083ffff, 0x00431021, 0x02a2102a,
38920 -       0x14400002, 0x03d02823, 0x00802821, 0x8e420000, 0x30a4ffff, 0x00441021,
38921 -       0xae420000, 0xa4c5000e, 0x8d220000, 0xacc20000, 0x8d220004, 0x8e43fff4,
38922 -       0x00431021, 0xacc20004, 0x8e43fff4, 0x95220008, 0x00641821, 0x0062102a,
38923 -       0x14400006, 0x02058021, 0x8e42fff0, 0xae40fff4, 0x24420001, 0x0a000530,
38924 -       0xae42fff0, 0xae43fff4, 0xacc00008, 0x3202ffff, 0x10550003, 0x31020004,
38925 -       0x10400006, 0x24020305, 0x31020080, 0x54400001, 0x34e70010, 0x34e70020,
38926 -       0x24020905, 0xa4c2000c, 0x30e2ffff, 0xacc20010, 0x3c030800, 0x8c63170c,
38927 -       0x3c020800, 0x8c421710, 0x54620004, 0x3c02b49a, 0x3c024b65, 0x0a000548,
38928 -       0x34427654, 0x344289ab, 0xacc2001c, 0x0e000560, 0x00c02021, 0x3202ffff,
38929 -       0x0055102b, 0x1440ff7e, 0x00000000, 0x8e420000, 0x8e43fffc, 0x0043102a,
38930 -       0x1440ff1a, 0x00000000, 0x8fbf0034, 0x8fbe0030, 0x8fb7002c, 0x8fb60028,
38931 -       0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
38932 -       0x03e00008, 0x27bd0038, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f624450,
38933 -       0x8f634410, 0x0a00056f, 0x00808021, 0x8f626820, 0x30422000, 0x10400003,
38934 -       0x00000000, 0x0e00025a, 0x00002021, 0x8f624450, 0x8f634410, 0x3042ffff,
38935 -       0x0043102b, 0x1440fff5, 0x00000000, 0x8f630c14, 0x3063000f, 0x2c620002,
38936 -       0x1440000b, 0x00000000, 0x8f630c14, 0x3c020800, 0x8c4216b4, 0x3063000f,
38937 -       0x24420001, 0x3c010800, 0xac2216b4, 0x2c620002, 0x1040fff7, 0x00000000,
38938 -       0xaf705c18, 0x8f625c10, 0x30420002, 0x10400009, 0x00000000, 0x8f626820,
38939 -       0x30422000, 0x1040fff8, 0x00000000, 0x0e00025a, 0x00002021, 0x0a000582,
38940 -       0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x00000000,
38941 -       0x00000000
38942 +       0x0e0004b9, 0x00000000, 0x8fbf0028, 0x8fb30024, 0x8fb20020, 0x8fb1001c,
38943 +       0x8fb00018, 0x03e00008, 0x27bd0030, 0x8f634450, 0x3c040800, 0x24841b98,
38944 +       0x8c820000, 0x00031c02, 0x0043102b, 0x14400007, 0x3c038000, 0x8c840004,
38945 +       0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444,
38946 +       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008,
38947 +       0x3042ffff, 0x3c024000, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002,
38948 +       0x1440fffc, 0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00805821,
38949 +       0x14c00017, 0x256e0008, 0x3c020800, 0x8c422404, 0x1040000a, 0x2402003e,
38950 +       0x3c010800, 0xa42223e0, 0x24020016, 0x3c010800, 0xa42223e2, 0x2402002a,
38951 +       0x3c010800, 0x0a000360, 0xa42223e4, 0x95620014, 0x3c010800, 0xa42223e0,
38952 +       0x8d670010, 0x00071402, 0x3c010800, 0xa42223e2, 0x3c010800, 0xa42723e4,
38953 +       0x3c040800, 0x948423e4, 0x3c030800, 0x946323e2, 0x95cf0006, 0x3c020800,
38954 +       0x944223e0, 0x00832023, 0x01e2c023, 0x3065ffff, 0x24a20028, 0x01c24821,
38955 +       0x3082ffff, 0x14c0001a, 0x01226021, 0x9582000c, 0x3042003f, 0x3c010800,
38956 +       0xa42223e6, 0x95820004, 0x95830006, 0x3c010800, 0xac2023f4, 0x3c010800,
38957 +       0xac2023f8, 0x00021400, 0x00431025, 0x3c010800, 0xac221bd0, 0x95220004,
38958 +       0x3c010800, 0xa4221bd4, 0x95230002, 0x01e51023, 0x0043102a, 0x10400010,
38959 +       0x24020001, 0x3c010800, 0x0a000394, 0xac222408, 0x3c030800, 0x8c6323f8,
38960 +       0x3c020800, 0x94421bd4, 0x00431021, 0xa5220004, 0x3c020800, 0x94421bd0,
38961 +       0xa5820004, 0x3c020800, 0x8c421bd0, 0xa5820006, 0x3c020800, 0x8c422400,
38962 +       0x3c0d0800, 0x8dad23f4, 0x3c0a0800, 0x144000e5, 0x8d4a23f8, 0x3c020800,
38963 +       0x94421bd4, 0x004a1821, 0x3063ffff, 0x0062182b, 0x24020002, 0x10c2000d,
38964 +       0x01435023, 0x3c020800, 0x944223e6, 0x30420009, 0x10400008, 0x00000000,
38965 +       0x9582000c, 0x3042fff6, 0xa582000c, 0x3c020800, 0x944223e6, 0x30420009,
38966 +       0x01a26823, 0x3c020800, 0x8c422408, 0x1040004a, 0x01203821, 0x3c020800,
38967 +       0x944223e2, 0x00004021, 0xa520000a, 0x01e21023, 0xa5220002, 0x3082ffff,
38968 +       0x00021042, 0x18400008, 0x00003021, 0x00401821, 0x94e20000, 0x25080001,
38969 +       0x00c23021, 0x0103102a, 0x1440fffb, 0x24e70002, 0x00061c02, 0x30c2ffff,
38970 +       0x00623021, 0x00061402, 0x00c23021, 0x00c02821, 0x00061027, 0xa522000a,
38971 +       0x00003021, 0x2527000c, 0x00004021, 0x94e20000, 0x25080001, 0x00c23021,
38972 +       0x2d020004, 0x1440fffb, 0x24e70002, 0x95220002, 0x00004021, 0x91230009,
38973 +       0x00442023, 0x01803821, 0x3082ffff, 0xa4e00010, 0x00621821, 0x00021042,
38974 +       0x18400010, 0x00c33021, 0x00404821, 0x94e20000, 0x24e70002, 0x00c23021,
38975 +       0x30e2007f, 0x14400006, 0x25080001, 0x8d630000, 0x3c02007f, 0x3442ff80,
38976 +       0x00625824, 0x25670008, 0x0109102a, 0x1440fff3, 0x00000000, 0x30820001,
38977 +       0x10400005, 0x00061c02, 0xa0e00001, 0x94e20000, 0x00c23021, 0x00061c02,
38978 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x0a000479, 0x30c6ffff,
38979 +       0x24020002, 0x14c20081, 0x00000000, 0x3c020800, 0x8c42241c, 0x14400007,
38980 +       0x00000000, 0x3c020800, 0x944223e2, 0x95230002, 0x01e21023, 0x10620077,
38981 +       0x00000000, 0x3c020800, 0x944223e2, 0x01e21023, 0xa5220002, 0x3c020800,
38982 +       0x8c42241c, 0x1040001a, 0x31e3ffff, 0x8dc70010, 0x3c020800, 0x94421ba6,
38983 +       0x00e04021, 0x00072c02, 0x00aa2021, 0x00431023, 0x00823823, 0x00072402,
38984 +       0x30e2ffff, 0x00823821, 0x00071027, 0xa522000a, 0x3102ffff, 0x3c040800,
38985 +       0x948423e4, 0x00453023, 0x00e02821, 0x00641823, 0x006d1821, 0x00c33021,
38986 +       0x00061c02, 0x30c2ffff, 0x0a000479, 0x00623021, 0x01203821, 0x00004021,
38987 +       0x3082ffff, 0x00021042, 0x18400008, 0x00003021, 0x00401821, 0x94e20000,
38988 +       0x25080001, 0x00c23021, 0x0103102a, 0x1440fffb, 0x24e70002, 0x00061c02,
38989 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c02821, 0x00061027,
38990 +       0xa522000a, 0x00003021, 0x2527000c, 0x00004021, 0x94e20000, 0x25080001,
38991 +       0x00c23021, 0x2d020004, 0x1440fffb, 0x24e70002, 0x95220002, 0x00004021,
38992 +       0x91230009, 0x00442023, 0x01803821, 0x3082ffff, 0xa4e00010, 0x3c040800,
38993 +       0x948423e4, 0x00621821, 0x00c33021, 0x00061c02, 0x30c2ffff, 0x00623021,
38994 +       0x00061c02, 0x3c020800, 0x944223e0, 0x00c34821, 0x00441023, 0x00021fc2,
38995 +       0x00431021, 0x00021043, 0x18400010, 0x00003021, 0x00402021, 0x94e20000,
38996 +       0x24e70002, 0x00c23021, 0x30e2007f, 0x14400006, 0x25080001, 0x8d630000,
38997 +       0x3c02007f, 0x3442ff80, 0x00625824, 0x25670008, 0x0104102a, 0x1440fff3,
38998 +       0x00000000, 0x3c020800, 0x944223fc, 0x00c23021, 0x3122ffff, 0x00c23021,
38999 +       0x00061c02, 0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c04021,
39000 +       0x00061027, 0xa5820010, 0xadc00014, 0x0a000499, 0xadc00000, 0x8dc70010,
39001 +       0x00e04021, 0x11400007, 0x00072c02, 0x00aa3021, 0x00061402, 0x30c3ffff,
39002 +       0x00433021, 0x00061402, 0x00c22821, 0x00051027, 0xa522000a, 0x3c030800,
39003 +       0x946323e4, 0x3102ffff, 0x01e21021, 0x00433023, 0x00cd3021, 0x00061c02,
39004 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c04021, 0x00061027,
39005 +       0xa5820010, 0x3102ffff, 0x00051c00, 0x00431025, 0xadc20010, 0x3c020800,
39006 +       0x8c422404, 0x10400002, 0x25e2fff2, 0xa5c20034, 0x3c020800, 0x8c4223f8,
39007 +       0x3c040800, 0x8c8423f4, 0x24420001, 0x3c010800, 0xac2223f8, 0x3c020800,
39008 +       0x8c421bd0, 0x3303ffff, 0x00832021, 0x3c010800, 0xac2423f4, 0x00431821,
39009 +       0x0062102b, 0x10400003, 0x2482ffff, 0x3c010800, 0xac2223f4, 0x3c010800,
39010 +       0xac231bd0, 0x03e00008, 0x27bd0020, 0x27bdffb8, 0x3c050800, 0x24a51ba8,
39011 +       0xafbf0044, 0xafbe0040, 0xafb7003c, 0xafb60038, 0xafb50034, 0xafb40030,
39012 +       0xafb3002c, 0xafb20028, 0xafb10024, 0xafb00020, 0x90a30000, 0x24020003,
39013 +       0x146200d5, 0x00000000, 0x3c090800, 0x95291ba6, 0x3c020800, 0x944223e0,
39014 +       0x3c030800, 0x8c631bc0, 0x3c040800, 0x8c841bbc, 0x01221023, 0x0064182a,
39015 +       0xa7a9001e, 0x106000c8, 0xa7a20016, 0x24be0020, 0x97b6001e, 0x24b30018,
39016 +       0x24b70014, 0x8fc20000, 0x14400008, 0x00000000, 0x8fc2fff8, 0x97a30016,
39017 +       0x8fc4fff4, 0x00431021, 0x0082202a, 0x148000ba, 0x00000000, 0x97d50818,
39018 +       0x32a2ffff, 0x104000ad, 0x00009021, 0x0040a021, 0x00008821, 0x0e00062d,
39019 +       0x00000000, 0x00403021, 0x14c00007, 0x00000000, 0x3c020800, 0x8c4223ec,
39020 +       0x24420001, 0x3c010800, 0x0a00059e, 0xac2223ec, 0x3c100800, 0x02118021,
39021 +       0x8e101bd8, 0x9608000a, 0x31020040, 0x10400004, 0x2407180c, 0x8e02000c,
39022 +       0x2407188c, 0xacc20018, 0x31021000, 0x10400004, 0x34e32000, 0x00081040,
39023 +       0x3042c000, 0x00623825, 0x31020080, 0x54400001, 0x34e70010, 0x3c020800,
39024 +       0x00511021, 0x8c421be0, 0x3c030800, 0x00711821, 0x8c631be4, 0x00021500,
39025 +       0x00031c00, 0x00431025, 0xacc20014, 0x96040008, 0x3242ffff, 0x00821021,
39026 +       0x0282102a, 0x14400002, 0x02b22823, 0x00802821, 0x8e020000, 0x02459021,
39027 +       0xacc20000, 0x8e020004, 0x00c02021, 0x26310010, 0xac820004, 0x30e2ffff,
39028 +       0xac800008, 0xa485000e, 0xac820010, 0x24020305, 0x0e0005aa, 0xa482000c,
39029 +       0x3242ffff, 0x0054102b, 0x1440ffc0, 0x3242ffff, 0x0a000596, 0x00000000,
39030 +       0x8e620000, 0x8e63fffc, 0x0043102a, 0x1040006c, 0x00000000, 0x8e62fff0,
39031 +       0x00028900, 0x3c100800, 0x02118021, 0x0e00062d, 0x8e101bd8, 0x00403021,
39032 +       0x14c00005, 0x00000000, 0x8e62082c, 0x24420001, 0x0a00059e, 0xae62082c,
39033 +       0x9608000a, 0x31020040, 0x10400004, 0x2407180c, 0x8e02000c, 0x2407188c,
39034 +       0xacc20018, 0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000,
39035 +       0x00623825, 0x3c020800, 0x00511021, 0x8c421be0, 0x3c030800, 0x00711821,
39036 +       0x8c631be4, 0x00021500, 0x00031c00, 0x00431025, 0xacc20014, 0x8e63fff4,
39037 +       0x96020008, 0x00432023, 0x3242ffff, 0x3083ffff, 0x00431021, 0x02c2102a,
39038 +       0x10400003, 0x00802821, 0x97a9001e, 0x01322823, 0x8e620000, 0x30a4ffff,
39039 +       0x00441021, 0xae620000, 0xa4c5000e, 0x8e020000, 0xacc20000, 0x8e020004,
39040 +       0x8e63fff4, 0x00431021, 0xacc20004, 0x8e63fff4, 0x96020008, 0x00641821,
39041 +       0x0062102a, 0x14400006, 0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001,
39042 +       0x0a000579, 0xae62fff0, 0xae63fff4, 0xacc00008, 0x3242ffff, 0x10560003,
39043 +       0x31020004, 0x10400006, 0x24020305, 0x31020080, 0x54400001, 0x34e70010,
39044 +       0x34e70020, 0x24020905, 0xa4c2000c, 0x8ee30000, 0x8ee20004, 0x14620007,
39045 +       0x3c02b49a, 0x8ee20860, 0x54400001, 0x34e70400, 0x3c024b65, 0x0a000590,
39046 +       0x34427654, 0x344289ab, 0xacc2001c, 0x30e2ffff, 0xacc20010, 0x0e0005aa,
39047 +       0x00c02021, 0x3242ffff, 0x0056102b, 0x1440ff96, 0x00000000, 0x8e620000,
39048 +       0x8e63fffc, 0x0043102a, 0x1440ff3e, 0x00000000, 0x8fbf0044, 0x8fbe0040,
39049 +       0x8fb7003c, 0x8fb60038, 0x8fb50034, 0x8fb40030, 0x8fb3002c, 0x8fb20028,
39050 +       0x8fb10024, 0x8fb00020, 0x03e00008, 0x27bd0048, 0x27bdffe8, 0xafbf0014,
39051 +       0xafb00010, 0x8f624450, 0x8f634410, 0x0a0005b9, 0x00808021, 0x8f626820,
39052 +       0x30422000, 0x10400003, 0x00000000, 0x0e0001e3, 0x00002021, 0x8f624450,
39053 +       0x8f634410, 0x3042ffff, 0x0043102b, 0x1440fff5, 0x00000000, 0x8f630c14,
39054 +       0x3063000f, 0x2c620002, 0x1440000b, 0x00000000, 0x8f630c14, 0x3c020800,
39055 +       0x8c421b50, 0x3063000f, 0x24420001, 0x3c010800, 0xac221b50, 0x2c620002,
39056 +       0x1040fff7, 0x00000000, 0xaf705c18, 0x8f625c10, 0x30420002, 0x10400009,
39057 +       0x00000000, 0x8f626820, 0x30422000, 0x1040fff8, 0x00000000, 0x0e0001e3,
39058 +       0x00002021, 0x0a0005cc, 0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008,
39059 +       0x27bd0018, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe8, 0x3c1bc000,
39060 +       0xafbf0014, 0xafb00010, 0xaf60680c, 0x8f626804, 0x34420082, 0xaf626804,
39061 +       0x8f634000, 0x24020b50, 0x3c010800, 0xac221b64, 0x24020b78, 0x3c010800,
39062 +       0xac221b74, 0x34630002, 0xaf634000, 0x0e00060d, 0x00808021, 0x3c010800,
39063 +       0xa0221b78, 0x304200ff, 0x24030002, 0x14430005, 0x00000000, 0x3c020800,
39064 +       0x8c421b64, 0x0a000600, 0xac5000c0, 0x3c020800, 0x8c421b64, 0xac5000bc,
39065 +       0x8f624434, 0x8f634438, 0x8f644410, 0x3c010800, 0xac221b6c, 0x3c010800,
39066 +       0xac231b7c, 0x3c010800, 0xac241b68, 0x8fbf0014, 0x8fb00010, 0x03e00008,
39067 +       0x27bd0018, 0x3c040800, 0x8c870000, 0x3c03aa55, 0x3463aa55, 0x3c06c003,
39068 +       0xac830000, 0x8cc20000, 0x14430007, 0x24050002, 0x3c0355aa, 0x346355aa,
39069 +       0xac830000, 0x8cc20000, 0x50430001, 0x24050001, 0x3c020800, 0xac470000,
39070 +       0x03e00008, 0x00a01021, 0x27bdfff8, 0x18800009, 0x00002821, 0x8f63680c,
39071 +       0x8f62680c, 0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a, 0x1440fff9,
39072 +       0x00000000, 0x03e00008, 0x27bd0008, 0x8f634450, 0x3c020800, 0x8c421b6c,
39073 +       0x00031c02, 0x0043102b, 0x14400008, 0x3c038000, 0x3c040800, 0x8c841b7c,
39074 +       0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444,
39075 +       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008,
39076 +       0x3042ffff, 0x3082ffff, 0x2442e000, 0x2c422001, 0x14400003, 0x3c024000,
39077 +       0x0a000650, 0x2402ffff, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002,
39078 +       0x1440fffc, 0x00001021, 0x03e00008, 0x00000000, 0x8f624450, 0x3c030800,
39079 +       0x8c631b68, 0x0a000659, 0x3042ffff, 0x8f624450, 0x3042ffff, 0x0043102b,
39080 +       0x1440fffc, 0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00802821,
39081 +       0x3c040800, 0x24841b10, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
39082 +       0x0e000684, 0xafa00014, 0x0a000668, 0x00000000, 0x8fbf0018, 0x03e00008,
39083 +       0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x3c020800, 0x34423000,
39084 +       0x3c030800, 0x34633000, 0x3c040800, 0x348437ff, 0x3c010800, 0xac221b84,
39085 +       0x24020040, 0x3c010800, 0xac221b88, 0x3c010800, 0xac201b80, 0xac600000,
39086 +       0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
39087 +       0x00804821, 0x8faa0010, 0x3c020800, 0x8c421b80, 0x3c040800, 0x8c841b88,
39088 +       0x8fab0014, 0x24430001, 0x0044102b, 0x3c010800, 0xac231b80, 0x14400003,
39089 +       0x00004021, 0x3c010800, 0xac201b80, 0x3c020800, 0x8c421b80, 0x3c030800,
39090 +       0x8c631b84, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
39091 +       0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020800, 0x8c421b80,
39092 +       0x3c030800, 0x8c631b84, 0x8f64680c, 0x00021140, 0x00431021, 0xac440008,
39093 +       0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
39094 +       0x00000000, 0x00000000,
39095  };
39096  
39097  u32 tg3TsoFwRodata[] = {
39098 -       0x4d61696e, 0x43707542, 0x00000000, 0x00000000, 0x74637073, 0x6567496e,
39099 -       0x00000000, 0x53774576, 0x656e7430, 0x00000000, 0x00000000, 0x00000000,
39100 -       0x00000000
39101 +       0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541,
39102 +       0x00000000, 0x00000000, 0x00000000, 0x73746b6f, 0x66666c64,
39103 +       0x496e0000, 0x73746b6f, 0x66662a2a, 0x00000000, 0x53774576,
39104 +       0x656e7430, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
39105 +       0x66617461, 0x6c457272, 0x00000000, 0x00000000, 0x00000000
39106  };
39107  
39108  #if 0 /* All zeros, don't eat up space with it. */
39109 @@ -3785,63 +4178,274 @@
39110  };
39111  #endif
39112  
39113 +/* 5705 needs a special version of the TSO firmware.  */
39114 +#define TG3_TSO5_FW_RELEASE_MAJOR      0x1
39115 +#define TG3_TSO5_FW_RELASE_MINOR       0x1
39116 +#define TG3_TSO5_FW_RELEASE_FIX                0x0
39117 +#define TG3_TSO5_FW_START_ADDR         0x00010000
39118 +#define TG3_TSO5_FW_TEXT_ADDR          0x00010000
39119 +#define TG3_TSO5_FW_TEXT_LEN           0xeb0
39120 +#define TG3_TSO5_FW_RODATA_ADDR                0x00010eb0
39121 +#define TG3_TSO5_FW_RODATA_LEN         0x50
39122 +#define TG3_TSO5_FW_DATA_ADDR          0x00010f20
39123 +#define TG3_TSO5_FW_DATA_LEN           0x20
39124 +#define TG3_TSO5_FW_SBSS_ADDR          0x00010f40
39125 +#define TG3_TSO5_FW_SBSS_LEN           0x28
39126 +#define TG3_TSO5_FW_BSS_ADDR           0x00010f70
39127 +#define TG3_TSO5_FW_BSS_LEN            0x88
39128 +
39129 +static u32 tg3Tso5FwText[] = {
39130 +       0x0c004003, 0x00000000, 0x00010f30, 0x00000000, 0x10000003, 0x00000000,
39131 +       0x0000000d, 0x0000000d, 0x3c1d0001, 0x37bde000, 0x03a0f021, 0x3c100001,
39132 +       0x26100000, 0x0c004010, 0x00000000, 0x0000000d, 0x27bdffe0, 0x3c04fefe,
39133 +       0xafbf0018, 0x0c0042f0, 0x34840002, 0x0c00436c, 0x00000000, 0x3c030001,
39134 +       0x90630f54, 0x24020002, 0x3c040001, 0x24840ebc, 0x14620003, 0x24050001,
39135 +       0x3c040001, 0x24840eb0, 0x24060001, 0x00003821, 0xafa00010, 0x0c004380,
39136 +       0xafa00014, 0x0c00402c, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020,
39137 +       0x00000000, 0x00000000, 0x27bdffe0, 0xafbf001c, 0xafb20018, 0xafb10014,
39138 +       0x0c0042d3, 0xafb00010, 0x3c128000, 0x24110001, 0x8f706810, 0x32020400,
39139 +       0x10400007, 0x00000000, 0x8f641008, 0x00921024, 0x14400003, 0x00000000,
39140 +       0x0c004064, 0x00000000, 0x3c020001, 0x90420f76, 0x10510003, 0x32020200,
39141 +       0x1040fff1, 0x00000000, 0x0c0041b4, 0x00000000, 0x08004034, 0x00000000,
39142 +       0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
39143 +       0x27bdffe0, 0x3c040001, 0x24840ed0, 0x00002821, 0x00003021, 0x00003821,
39144 +       0xafbf0018, 0xafa00010, 0x0c004380, 0xafa00014, 0x0000d021, 0x24020130,
39145 +       0xaf625000, 0x3c010001, 0xa4200f70, 0x3c010001, 0xa0200f77, 0x8fbf0018,
39146 +       0x03e00008, 0x27bd0020, 0x00000000, 0x00000000, 0x3c030001, 0x24630f80,
39147 +       0x90620000, 0x27bdfff0, 0x14400003, 0x0080c021, 0x08004073, 0x00004821,
39148 +       0x3c022000, 0x03021024, 0x10400003, 0x24090002, 0x08004073, 0xa0600000,
39149 +       0x24090001, 0x00181040, 0x30431f80, 0x346f8008, 0x1520004b, 0x25eb0028,
39150 +       0x3c040001, 0x00832021, 0x8c848010, 0x3c050001, 0x24a50f9a, 0x00041402,
39151 +       0xa0a20000, 0x3c010001, 0xa0240f9b, 0x3c020001, 0x00431021, 0x94428014,
39152 +       0x3c010001, 0xa0220f9c, 0x3c0c0001, 0x01836021, 0x8d8c8018, 0x304200ff,
39153 +       0x24420008, 0x000220c3, 0x24020001, 0x3c010001, 0xa0220f80, 0x0124102b,
39154 +       0x1040000c, 0x00003821, 0x24a6000e, 0x01602821, 0x8ca20000, 0x8ca30004,
39155 +       0x24a50008, 0x24e70001, 0xacc20000, 0xacc30004, 0x00e4102b, 0x1440fff8,
39156 +       0x24c60008, 0x00003821, 0x3c080001, 0x25080f9b, 0x91060000, 0x3c020001,
39157 +       0x90420f9c, 0x2503000d, 0x00c32821, 0x00461023, 0x00021fc2, 0x00431021,
39158 +       0x00021043, 0x1840000c, 0x00002021, 0x91020001, 0x00461023, 0x00021fc2,
39159 +       0x00431021, 0x00021843, 0x94a20000, 0x24e70001, 0x00822021, 0x00e3102a,
39160 +       0x1440fffb, 0x24a50002, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
39161 +       0x00822021, 0x3c02ffff, 0x01821024, 0x3083ffff, 0x00431025, 0x3c010001,
39162 +       0x080040fa, 0xac220fa0, 0x3c050001, 0x24a50f9c, 0x90a20000, 0x3c0c0001,
39163 +       0x01836021, 0x8d8c8018, 0x000220c2, 0x1080000e, 0x00003821, 0x01603021,
39164 +       0x24a5000c, 0x8ca20000, 0x8ca30004, 0x24a50008, 0x24e70001, 0xacc20000,
39165 +       0xacc30004, 0x00e4102b, 0x1440fff8, 0x24c60008, 0x3c050001, 0x24a50f9c,
39166 +       0x90a20000, 0x30430007, 0x24020004, 0x10620011, 0x28620005, 0x10400005,
39167 +       0x24020002, 0x10620008, 0x000710c0, 0x080040fa, 0x00000000, 0x24020006,
39168 +       0x1062000e, 0x000710c0, 0x080040fa, 0x00000000, 0x00a21821, 0x9463000c,
39169 +       0x004b1021, 0x080040fa, 0xa4430000, 0x000710c0, 0x00a21821, 0x8c63000c,
39170 +       0x004b1021, 0x080040fa, 0xac430000, 0x00a21821, 0x8c63000c, 0x004b2021,
39171 +       0x00a21021, 0xac830000, 0x94420010, 0xa4820004, 0x95e70006, 0x3c020001,
39172 +       0x90420f9c, 0x3c030001, 0x90630f9a, 0x00e2c823, 0x3c020001, 0x90420f9b,
39173 +       0x24630028, 0x01e34021, 0x24420028, 0x15200012, 0x01e23021, 0x94c2000c,
39174 +       0x3c010001, 0xa4220f98, 0x94c20004, 0x94c30006, 0x3c010001, 0xa4200f96,
39175 +       0x3c010001, 0xa4200f92, 0x00021400, 0x00431025, 0x3c010001, 0xac220f8c,
39176 +       0x95020004, 0x3c010001, 0x08004124, 0xa4220f90, 0x3c020001, 0x94420f90,
39177 +       0x3c030001, 0x94630f92, 0x00431021, 0xa5020004, 0x3c020001, 0x94420f8c,
39178 +       0xa4c20004, 0x3c020001, 0x8c420f8c, 0xa4c20006, 0x3c040001, 0x94840f92,
39179 +       0x3c020001, 0x94420f90, 0x3c0a0001, 0x954a0f96, 0x00441821, 0x3063ffff,
39180 +       0x0062182a, 0x24020002, 0x1122000b, 0x00832023, 0x3c030001, 0x94630f98,
39181 +       0x30620009, 0x10400006, 0x3062fff6, 0xa4c2000c, 0x3c020001, 0x94420f98,
39182 +       0x30420009, 0x01425023, 0x24020001, 0x1122001b, 0x29220002, 0x50400005,
39183 +       0x24020002, 0x11200007, 0x31a2ffff, 0x08004197, 0x00000000, 0x1122001d,
39184 +       0x24020016, 0x08004197, 0x31a2ffff, 0x3c0e0001, 0x95ce0fa0, 0x10800005,
39185 +       0x01806821, 0x01c42021, 0x00041c02, 0x3082ffff, 0x00627021, 0x000e1027,
39186 +       0xa502000a, 0x3c030001, 0x90630f9b, 0x31a2ffff, 0x00e21021, 0x0800418d,
39187 +       0x00432023, 0x3c020001, 0x94420fa0, 0x00442021, 0x00041c02, 0x3082ffff,
39188 +       0x00622021, 0x00807021, 0x00041027, 0x08004185, 0xa502000a, 0x3c050001,
39189 +       0x24a50f9a, 0x90a30000, 0x14620002, 0x24e2fff2, 0xa5e20034, 0x90a20000,
39190 +       0x00e21023, 0xa5020002, 0x3c030001, 0x94630fa0, 0x3c020001, 0x94420f7a,
39191 +       0x30e5ffff, 0x00641821, 0x00451023, 0x00622023, 0x00041c02, 0x3082ffff,
39192 +       0x00622021, 0x00041027, 0xa502000a, 0x3c030001, 0x90630f9c, 0x24620001,
39193 +       0x14a20005, 0x00807021, 0x01631021, 0x90420000, 0x08004185, 0x00026200,
39194 +       0x24620002, 0x14a20003, 0x306200fe, 0x004b1021, 0x944c0000, 0x3c020001,
39195 +       0x94420fa2, 0x3183ffff, 0x3c040001, 0x90840f9b, 0x00431021, 0x00e21021,
39196 +       0x00442023, 0x008a2021, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
39197 +       0x00822021, 0x00806821, 0x00041027, 0xa4c20010, 0x31a2ffff, 0x000e1c00,
39198 +       0x00431025, 0x3c040001, 0x24840f92, 0xade20010, 0x94820000, 0x3c050001,
39199 +       0x94a50f96, 0x3c030001, 0x8c630f8c, 0x24420001, 0x00b92821, 0xa4820000,
39200 +       0x3322ffff, 0x00622021, 0x0083182b, 0x3c010001, 0xa4250f96, 0x10600003,
39201 +       0x24a2ffff, 0x3c010001, 0xa4220f96, 0x3c024000, 0x03021025, 0x3c010001,
39202 +       0xac240f8c, 0xaf621008, 0x03e00008, 0x27bd0010, 0x3c030001, 0x90630f76,
39203 +       0x27bdffe8, 0x24020001, 0xafbf0014, 0x10620026, 0xafb00010, 0x8f620cf4,
39204 +       0x2442ffff, 0x3042007f, 0x00021100, 0x8c434000, 0x3c010001, 0xac230f84,
39205 +       0x8c434008, 0x24444000, 0x8c5c4004, 0x30620040, 0x14400002, 0x24020088,
39206 +       0x24020008, 0x3c010001, 0xa4220f88, 0x30620004, 0x10400005, 0x24020001,
39207 +       0x3c010001, 0xa0220f77, 0x080041d5, 0x00031402, 0x3c010001, 0xa0200f77,
39208 +       0x00031402, 0x3c010001, 0xa4220f74, 0x9483000c, 0x24020001, 0x3c010001,
39209 +       0xa4200f70, 0x3c010001, 0xa0220f76, 0x3c010001, 0xa4230f82, 0x24020001,
39210 +       0x1342001e, 0x00000000, 0x13400005, 0x24020003, 0x13420067, 0x00000000,
39211 +       0x080042cf, 0x00000000, 0x3c020001, 0x94420f82, 0x241a0001, 0x3c010001,
39212 +       0xa4200f7e, 0x3c010001, 0xa4200f72, 0x304407ff, 0x00021bc2, 0x00031823,
39213 +       0x3063003e, 0x34630036, 0x00021242, 0x3042003c, 0x00621821, 0x3c010001,
39214 +       0xa4240f78, 0x00832021, 0x24630030, 0x3c010001, 0xa4240f7a, 0x3c010001,
39215 +       0xa4230f7c, 0x3c060001, 0x24c60f72, 0x94c50000, 0x94c30002, 0x3c040001,
39216 +       0x94840f7a, 0x00651021, 0x0044102a, 0x10400013, 0x3c108000, 0x00a31021,
39217 +       0xa4c20000, 0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f76, 0x8f641008,
39218 +       0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4,
39219 +       0x00501024, 0x104000b7, 0x00000000, 0x0800420f, 0x00000000, 0x3c030001,
39220 +       0x94630f70, 0x00851023, 0xa4c40000, 0x00621821, 0x3042ffff, 0x3c010001,
39221 +       0xa4230f70, 0xaf620ce8, 0x3c020001, 0x94420f88, 0x34420024, 0xaf620cec,
39222 +       0x94c30002, 0x3c020001, 0x94420f70, 0x14620012, 0x3c028000, 0x3c108000,
39223 +       0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f76, 0x8f641008, 0x00901024,
39224 +       0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024,
39225 +       0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003, 0xaf620cf4, 0x3c108000,
39226 +       0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000,
39227 +       0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003,
39228 +       0x3c070001, 0x24e70f70, 0x94e20000, 0x03821021, 0xaf620ce0, 0x3c020001,
39229 +       0x8c420f84, 0xaf620ce4, 0x3c050001, 0x94a50f74, 0x94e30000, 0x3c040001,
39230 +       0x94840f78, 0x3c020001, 0x94420f7e, 0x00a32823, 0x00822023, 0x30a6ffff,
39231 +       0x3083ffff, 0x00c3102b, 0x14400043, 0x00000000, 0x3c020001, 0x94420f7c,
39232 +       0x00021400, 0x00621025, 0xaf620ce8, 0x94e20000, 0x3c030001, 0x94630f74,
39233 +       0x00441021, 0xa4e20000, 0x3042ffff, 0x14430021, 0x3c020008, 0x3c020001,
39234 +       0x90420f77, 0x10400006, 0x3c03000c, 0x3c020001, 0x94420f88, 0x34630624,
39235 +       0x0800427c, 0x0000d021, 0x3c020001, 0x94420f88, 0x3c030008, 0x34630624,
39236 +       0x00431025, 0xaf620cec, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
39237 +       0xa0200f76, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
39238 +       0x00000000, 0x8f620cf4, 0x00501024, 0x10400015, 0x00000000, 0x08004283,
39239 +       0x00000000, 0x3c030001, 0x94630f88, 0x34420624, 0x3c108000, 0x00621825,
39240 +       0x3c028000, 0xaf630cec, 0xaf620cf4, 0x8f641008, 0x00901024, 0x14400003,
39241 +       0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7,
39242 +       0x00000000, 0x3c010001, 0x080042cf, 0xa4200f7e, 0x3c020001, 0x94420f7c,
39243 +       0x00021400, 0x00c21025, 0xaf620ce8, 0x3c020001, 0x90420f77, 0x10400009,
39244 +       0x3c03000c, 0x3c020001, 0x94420f88, 0x34630624, 0x0000d021, 0x00431025,
39245 +       0xaf620cec, 0x080042c1, 0x3c108000, 0x3c020001, 0x94420f88, 0x3c030008,
39246 +       0x34630604, 0x00431025, 0xaf620cec, 0x3c020001, 0x94420f7e, 0x00451021,
39247 +       0x3c010001, 0xa4220f7e, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
39248 +       0xa0200f76, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
39249 +       0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x8fbf0014,
39250 +       0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe0, 0x3c040001, 0x24840ee0,
39251 +       0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0c004380,
39252 +       0xafa00014, 0x0000d021, 0x24020130, 0xaf625000, 0x3c010001, 0xa4200f70,
39253 +       0x3c010001, 0xa0200f77, 0x8f636804, 0x3c020001, 0x3442e000, 0x00621824,
39254 +       0x3c020001, 0x14620003, 0x00000000, 0x080042eb, 0x00000000, 0x8fbf0018,
39255 +       0x03e00008, 0x27bd0020, 0x27bdffe8, 0x3c1bc000, 0xafbf0014, 0xafb00010,
39256 +       0xaf60680c, 0x8f626804, 0x34420082, 0xaf626804, 0x8f634000, 0x24020b50,
39257 +       0x3c010001, 0xac220f40, 0x24020b78, 0x3c010001, 0xac220f50, 0x34630002,
39258 +       0xaf634000, 0x0c00431d, 0x00808021, 0x3c010001, 0xa0220f54, 0x304200ff,
39259 +       0x24030002, 0x14430005, 0x00000000, 0x3c020001, 0x8c420f40, 0x08004310,
39260 +       0xac5000c0, 0x3c020001, 0x8c420f40, 0xac5000bc, 0x8f624434, 0x8f634438,
39261 +       0x8f644410, 0x3c010001, 0xac220f48, 0x3c010001, 0xac230f58, 0x3c010001,
39262 +       0xac240f44, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x03e00008,
39263 +       0x24020001, 0x27bdfff8, 0x18800009, 0x00002821, 0x8f63680c, 0x8f62680c,
39264 +       0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a, 0x1440fff9, 0x00000000,
39265 +       0x03e00008, 0x27bd0008, 0x8f634450, 0x3c020001, 0x8c420f48, 0x00031c02,
39266 +       0x0043102b, 0x14400008, 0x3c038000, 0x3c040001, 0x8c840f58, 0x8f624450,
39267 +       0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444,
39268 +       0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff,
39269 +       0x3082ffff, 0x2442e000, 0x2c422001, 0x14400003, 0x3c024000, 0x0800434f,
39270 +       0x2402ffff, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc,
39271 +       0x00001021, 0x03e00008, 0x00000000, 0x8f624450, 0x3c030001, 0x8c630f44,
39272 +       0x08004358, 0x3042ffff, 0x8f624450, 0x3042ffff, 0x0043102b, 0x1440fffc,
39273 +       0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00802821, 0x3c040001,
39274 +       0x24840ef0, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0c004380,
39275 +       0xafa00014, 0x08004367, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020,
39276 +       0x3c020001, 0x3442d600, 0x3c030001, 0x3463d600, 0x3c040001, 0x3484ddff,
39277 +       0x3c010001, 0xac220f60, 0x24020040, 0x3c010001, 0xac220f64, 0x3c010001,
39278 +       0xac200f5c, 0xac600000, 0x24630004, 0x0083102b, 0x5040fffd, 0xac600000,
39279 +       0x03e00008, 0x00000000, 0x00804821, 0x8faa0010, 0x3c020001, 0x8c420f5c,
39280 +       0x3c040001, 0x8c840f64, 0x8fab0014, 0x24430001, 0x0044102b, 0x3c010001,
39281 +       0xac230f5c, 0x14400003, 0x00004021, 0x3c010001, 0xac200f5c, 0x3c020001,
39282 +       0x8c420f5c, 0x3c030001, 0x8c630f60, 0x91240000, 0x00021140, 0x00431021,
39283 +       0x00481021, 0x25080001, 0xa0440000, 0x29020008, 0x1440fff4, 0x25290001,
39284 +       0x3c020001, 0x8c420f5c, 0x3c030001, 0x8c630f60, 0x8f64680c, 0x00021140,
39285 +       0x00431021, 0xac440008, 0xac45000c, 0xac460010, 0xac470014, 0xac4a0018,
39286 +       0x03e00008, 0xac4b001c, 0x00000000, 0x00000000,
39287 +};
39288 +
39289 +u32 tg3Tso5FwRodata[] = {
39290 +       0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
39291 +       0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x00000000, 0x00000000,
39292 +       0x73746b6f, 0x66666c64, 0x00000000, 0x00000000, 0x66617461, 0x6c457272,
39293 +       0x00000000, 0x00000000, 0x00000000
39294 +};
39295 +
39296 +u32 tg3Tso5FwData[] = {
39297 +       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x73746b6f, 
39298 +       0x66666c64, 0x5f76312e, 0x312e3000, 0x00000000
39299 +};
39300 +
39301  /* tp->lock is held. */
39302  static int tg3_load_tso_firmware(struct tg3 *tp)
39303  {
39304         struct fw_info info;
39305 +       unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
39306         int err, i;
39307  
39308 -       info.text_base = TG3_TSO_FW_TEXT_ADDR;
39309 -       info.text_len = TG3_TSO_FW_TEXT_LEN;
39310 -       info.text_data = &tg3TsoFwText[0];
39311 -       info.rodata_base = TG3_TSO_FW_RODATA_ADDR;
39312 -       info.rodata_len = TG3_TSO_FW_RODATA_LEN;
39313 -       info.rodata_data = &tg3TsoFwRodata[0];
39314 -       info.data_base = TG3_TSO_FW_DATA_ADDR;
39315 -       info.data_len = TG3_TSO_FW_DATA_LEN;
39316 -       info.data_data = NULL;
39317 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
39318 +               info.text_base = TG3_TSO5_FW_TEXT_ADDR;
39319 +               info.text_len = TG3_TSO5_FW_TEXT_LEN;
39320 +               info.text_data = &tg3Tso5FwText[0];
39321 +               info.rodata_base = TG3_TSO5_FW_RODATA_ADDR;
39322 +               info.rodata_len = TG3_TSO5_FW_RODATA_LEN;
39323 +               info.rodata_data = &tg3Tso5FwRodata[0];
39324 +               info.data_base = TG3_TSO5_FW_DATA_ADDR;
39325 +               info.data_len = TG3_TSO5_FW_DATA_LEN;
39326 +               info.data_data = &tg3Tso5FwData[0];
39327 +               cpu_base = RX_CPU_BASE;
39328 +               cpu_scratch_base = NIC_SRAM_MBUF_POOL_BASE5705;
39329 +               cpu_scratch_size = (info.text_len +
39330 +                                   info.rodata_len +
39331 +                                   info.data_len +
39332 +                                   TG3_TSO5_FW_SBSS_LEN +
39333 +                                   TG3_TSO5_FW_BSS_LEN);
39334 +       } else {
39335 +               info.text_base = TG3_TSO_FW_TEXT_ADDR;
39336 +               info.text_len = TG3_TSO_FW_TEXT_LEN;
39337 +               info.text_data = &tg3TsoFwText[0];
39338 +               info.rodata_base = TG3_TSO_FW_RODATA_ADDR;
39339 +               info.rodata_len = TG3_TSO_FW_RODATA_LEN;
39340 +               info.rodata_data = &tg3TsoFwRodata[0];
39341 +               info.data_base = TG3_TSO_FW_DATA_ADDR;
39342 +               info.data_len = TG3_TSO_FW_DATA_LEN;
39343 +               info.data_data = NULL;
39344 +               cpu_base = TX_CPU_BASE;
39345 +               cpu_scratch_base = TX_CPU_SCRATCH_BASE;
39346 +               cpu_scratch_size = TX_CPU_SCRATCH_SIZE;
39347 +       }
39348  
39349 -       err = tg3_load_firmware_cpu(tp, TX_CPU_BASE,
39350 -                                   TX_CPU_SCRATCH_BASE, TX_CPU_SCRATCH_SIZE,
39351 +       err = tg3_load_firmware_cpu(tp, cpu_base,
39352 +                                   cpu_scratch_base, cpu_scratch_size,
39353                                     &info);
39354         if (err)
39355                 return err;
39356  
39357 -       /* Now startup only the TX cpu. */
39358 -       tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
39359 -       tw32(TX_CPU_BASE + CPU_PC,    TG3_TSO_FW_TEXT_ADDR);
39360 +       /* Now startup the cpu. */
39361 +       tw32(cpu_base + CPU_STATE, 0xffffffff);
39362 +       tw32(cpu_base + CPU_PC,    info.text_base);
39363  
39364         /* Flush posted writes. */
39365 -       tr32(TX_CPU_BASE + CPU_PC);
39366 +       tr32(cpu_base + CPU_PC);
39367         for (i = 0; i < 5; i++) {
39368 -               if (tr32(TX_CPU_BASE + CPU_PC) == TG3_TSO_FW_TEXT_ADDR)
39369 +               if (tr32(cpu_base + CPU_PC) == info.text_base)
39370                         break;
39371 -               tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
39372 -               tw32(TX_CPU_BASE + CPU_MODE,  CPU_MODE_HALT);
39373 -               tw32(TX_CPU_BASE + CPU_PC,    TG3_TSO_FW_TEXT_ADDR);
39374 +               tw32(cpu_base + CPU_STATE, 0xffffffff);
39375 +               tw32(cpu_base + CPU_MODE,  CPU_MODE_HALT);
39376 +               tw32(cpu_base + CPU_PC,    info.text_base);
39377  
39378                 /* Flush posted writes. */
39379 -               tr32(TX_CPU_BASE + CPU_PC);
39380 +               tr32(cpu_base + CPU_PC);
39381  
39382                 udelay(1000);
39383         }
39384         if (i >= 5) {
39385                 printk(KERN_ERR PFX "tg3_load_tso_firmware fails for %s "
39386 -                      "to set TX CPU PC, is %08x should be %08x\n",
39387 -                      tp->dev->name, tr32(TX_CPU_BASE + CPU_PC),
39388 -                      TG3_TSO_FW_TEXT_ADDR);
39389 +                      "to set CPU PC, is %08x should be %08x\n",
39390 +                      tp->dev->name, tr32(cpu_base + CPU_PC),
39391 +                      info.text_base);
39392                 return -ENODEV;
39393         }
39394 -       tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
39395 -       tw32(TX_CPU_BASE + CPU_MODE,  0x00000000);
39396 +       tw32(cpu_base + CPU_STATE, 0xffffffff);
39397 +       tw32(cpu_base + CPU_MODE,  0x00000000);
39398  
39399         /* Flush posted writes. */
39400 -       tr32(TX_CPU_BASE + CPU_MODE);
39401 +       tr32(cpu_base + CPU_MODE);
39402  
39403         return 0;
39404  }
39405  
39406 -#endif /* TG3_DO_TSO != 0 */
39407 +#endif /* TG3_TSO_SUPPORT != 0 */
39408  
39409  /* tp->lock is held. */
39410  static void __tg3_set_mac_addr(struct tg3 *tp)
39411 @@ -3860,6 +4464,15 @@
39412                 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
39413         }
39414  
39415 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
39416 +           GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701 &&
39417 +           GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
39418 +               for (i = 0; i < 12; i++) {
39419 +                       tw32(MAC_EXTADDR_0_HIGH + (i * 8), addr_high);
39420 +                       tw32(MAC_EXTADDR_0_LOW + (i * 8), addr_low);
39421 +               }
39422 +       }
39423 +
39424         addr_high = (tp->dev->dev_addr[0] +
39425                      tp->dev->dev_addr[1] +
39426                      tp->dev->dev_addr[2] +
39427 @@ -3893,23 +4506,19 @@
39428                            u32 nic_addr)
39429  {
39430         tg3_write_mem(tp,
39431 -                     (bdinfo_addr +
39432 -                      TG3_BDINFO_HOST_ADDR +
39433 -                      TG3_64BIT_REG_HIGH),
39434 +                     (bdinfo_addr + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH),
39435                       ((u64) mapping >> 32));
39436         tg3_write_mem(tp,
39437 -                     (bdinfo_addr +
39438 -                      TG3_BDINFO_HOST_ADDR +
39439 -                      TG3_64BIT_REG_LOW),
39440 +                     (bdinfo_addr + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW),
39441                       ((u64) mapping & 0xffffffff));
39442         tg3_write_mem(tp,
39443 -                     (bdinfo_addr +
39444 -                      TG3_BDINFO_MAXLEN_FLAGS),
39445 +                     (bdinfo_addr + TG3_BDINFO_MAXLEN_FLAGS),
39446                        maxlen_flags);
39447 -       tg3_write_mem(tp,
39448 -                     (bdinfo_addr +
39449 -                      TG3_BDINFO_NIC_ADDR),
39450 -                     nic_addr);
39451 +
39452 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
39453 +               tg3_write_mem(tp,
39454 +                             (bdinfo_addr + TG3_BDINFO_NIC_ADDR),
39455 +                             nic_addr);
39456  }
39457  
39458  static void __tg3_set_rx_mode(struct net_device *);
39459 @@ -3917,8 +4526,8 @@
39460  /* tp->lock is held. */
39461  static int tg3_reset_hw(struct tg3 *tp)
39462  {
39463 -       u32 val;
39464 -       int i, err;
39465 +       u32 val, rdmac_mode;
39466 +       int i, err, limit;
39467  
39468         tg3_disable_ints(tp);
39469  
39470 @@ -3970,9 +4579,8 @@
39471          * B3 tigon3 silicon.  This bit has no effect on any
39472          * other revision.
39473          */
39474 -       val = tr32(TG3PCI_CLOCK_CTRL);
39475 -       val |= CLOCK_CTRL_DELAY_PCI_GRANT;
39476 -       tw32(TG3PCI_CLOCK_CTRL, val);
39477 +       tp->pci_clock_ctrl |= CLOCK_CTRL_DELAY_PCI_GRANT;
39478 +       tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
39479         tr32(TG3PCI_CLOCK_CTRL);
39480  
39481         if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0 &&
39482 @@ -3990,11 +4598,13 @@
39483         tg3_init_rings(tp);
39484  
39485         /* Clear statistics/status block in chip, and status block in ram. */
39486 -       for (i = NIC_SRAM_STATS_BLK;
39487 -            i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE;
39488 -            i += sizeof(u32)) {
39489 -               tg3_write_mem(tp, i, 0);
39490 -               udelay(40);
39491 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
39492 +               for (i = NIC_SRAM_STATS_BLK;
39493 +                    i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE;
39494 +                    i += sizeof(u32)) {
39495 +                       tg3_write_mem(tp, i, 0);
39496 +                       udelay(40);
39497 +               }
39498         }
39499         memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
39500  
39501 @@ -4025,13 +4635,31 @@
39502              (65 << GRC_MISC_CFG_PRESCALAR_SHIFT));
39503  
39504         /* Initialize MBUF/DESC pool. */
39505 -       tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
39506 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
39507 -               tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE64);
39508 -       else
39509 -               tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
39510 -       tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
39511 -       tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
39512 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
39513 +               tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
39514 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
39515 +                       tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE64);
39516 +               else
39517 +                       tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
39518 +               tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
39519 +               tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
39520 +       }
39521 +#if TG3_TSO_SUPPORT != 0
39522 +       else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
39523 +               int fw_len;
39524 +
39525 +               fw_len = (TG3_TSO5_FW_TEXT_LEN +
39526 +                         TG3_TSO5_FW_RODATA_LEN +
39527 +                         TG3_TSO5_FW_DATA_LEN +
39528 +                         TG3_TSO5_FW_SBSS_LEN +
39529 +                         TG3_TSO5_FW_BSS_LEN);
39530 +               fw_len = (fw_len + (0x80 - 1)) & ~(0x80 - 1);
39531 +               tw32(BUFMGR_MB_POOL_ADDR,
39532 +                    NIC_SRAM_MBUF_POOL_BASE5705 + fw_len);
39533 +               tw32(BUFMGR_MB_POOL_SIZE,
39534 +                    NIC_SRAM_MBUF_POOL_SIZE5705 - fw_len - 0xa00);
39535 +       }
39536 +#endif
39537  
39538         if (!(tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE)) {
39539                 tw32(BUFMGR_MB_RDMA_LOW_WATER,
39540 @@ -4078,6 +4706,9 @@
39541                 return -ENODEV;
39542         }
39543  
39544 +       /* Setup replenish threshold. */
39545 +       tw32(RCVBDI_STD_THRESH, tp->rx_pending / 8);
39546 +
39547         /* Initialize TG3_BDINFO's at:
39548          *  RCVDBDI_STD_BD:     standard eth size rx ring
39549          *  RCVDBDI_JUMBO_BD:   jumbo frame rx ring
39550 @@ -4099,35 +4730,50 @@
39551              ((u64) tp->rx_std_mapping >> 32));
39552         tw32(RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
39553              ((u64) tp->rx_std_mapping & 0xffffffff));
39554 -       tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
39555 -            RX_STD_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
39556         tw32(RCVDBDI_STD_BD + TG3_BDINFO_NIC_ADDR,
39557              NIC_SRAM_RX_BUFFER_DESC);
39558  
39559 -       tw32(RCVDBDI_MINI_BD + TG3_BDINFO_MAXLEN_FLAGS,
39560 -            BDINFO_FLAGS_DISABLED);
39561 -
39562 -       if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) {
39563 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH,
39564 -                    ((u64) tp->rx_jumbo_mapping >> 32));
39565 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
39566 -                    ((u64) tp->rx_jumbo_mapping & 0xffffffff));
39567 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
39568 -                    RX_JUMBO_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
39569 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_NIC_ADDR,
39570 -                    NIC_SRAM_RX_JUMBO_BUFFER_DESC);
39571 +       /* Don't even try to program the JUMBO/MINI buffer descriptor
39572 +        * configs on 5705.
39573 +        */
39574 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
39575 +               tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
39576 +                    RX_STD_MAX_SIZE_5705 << BDINFO_FLAGS_MAXLEN_SHIFT);
39577         } else {
39578 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
39579 +               tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
39580 +                    RX_STD_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
39581 +
39582 +               tw32(RCVDBDI_MINI_BD + TG3_BDINFO_MAXLEN_FLAGS,
39583                      BDINFO_FLAGS_DISABLED);
39584 -       }
39585  
39586 -       /* Setup replenish thresholds. */
39587 -       tw32(RCVBDI_STD_THRESH, tp->rx_pending / 8);
39588 -       tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8);
39589 +               /* Setup replenish threshold. */
39590 +               tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8);
39591  
39592 -       /* Clear out send RCB ring in SRAM. */
39593 -       for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
39594 -               tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED);
39595 +               if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) {
39596 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH,
39597 +                            ((u64) tp->rx_jumbo_mapping >> 32));
39598 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
39599 +                            ((u64) tp->rx_jumbo_mapping & 0xffffffff));
39600 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
39601 +                            RX_JUMBO_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
39602 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_NIC_ADDR,
39603 +                            NIC_SRAM_RX_JUMBO_BUFFER_DESC);
39604 +               } else {
39605 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
39606 +                            BDINFO_FLAGS_DISABLED);
39607 +               }
39608 +
39609 +       }
39610 +
39611 +       /* There is only one send ring on 5705, no need to explicitly
39612 +        * disable the others.
39613 +        */
39614 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
39615 +               /* Clear out send RCB ring in SRAM. */
39616 +               for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
39617 +                       tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
39618 +                                     BDINFO_FLAGS_DISABLED);
39619 +       }
39620  
39621         tp->tx_prod = 0;
39622         tp->tx_cons = 0;
39623 @@ -4149,9 +4795,15 @@
39624                                NIC_SRAM_TX_BUFFER_DESC);
39625         }
39626  
39627 -       for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK; i += TG3_BDINFO_SIZE) {
39628 -               tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
39629 -                             BDINFO_FLAGS_DISABLED);
39630 +       /* There is only one receive return ring on 5705, no need to explicitly
39631 +        * disable the others.
39632 +        */
39633 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
39634 +               for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK;
39635 +                    i += TG3_BDINFO_SIZE) {
39636 +                       tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
39637 +                                     BDINFO_FLAGS_DISABLED);
39638 +               }
39639         }
39640  
39641         tp->rx_rcb_ptr = 0;
39642 @@ -4161,7 +4813,7 @@
39643  
39644         tg3_set_bdinfo(tp, NIC_SRAM_RCV_RET_RCB,
39645                        tp->rx_rcb_mapping,
39646 -                      (TG3_RX_RCB_RING_SIZE <<
39647 +                      (TG3_RX_RCB_RING_SIZE(tp) <<
39648                         BDINFO_FLAGS_MAXLEN_SHIFT),
39649                        0);
39650  
39651 @@ -4198,8 +4850,36 @@
39652         tw32(MAC_RCV_RULE_CFG, RCV_RULE_CFG_DEFAULT_CLASS);
39653         tw32(RCVLPC_CONFIG, 0x0181);
39654  
39655 +       /* Calculate RDMAC_MODE setting early, we need it to determine
39656 +        * the RCVLPC_STATE_ENABLE mask.
39657 +        */
39658 +       rdmac_mode = (RDMAC_MODE_ENABLE | RDMAC_MODE_TGTABORT_ENAB |
39659 +                     RDMAC_MODE_MSTABORT_ENAB | RDMAC_MODE_PARITYERR_ENAB |
39660 +                     RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
39661 +                     RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
39662 +                     RDMAC_MODE_LNGREAD_ENAB);
39663 +       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
39664 +               rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
39665 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
39666 +               if (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) {
39667 +                       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
39668 +                               rdmac_mode |= RDMAC_MODE_FIFO_SIZE_128;
39669 +                       } else if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) &&
39670 +                                  !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
39671 +                               rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST;
39672 +                       }
39673 +               }
39674 +       }
39675 +
39676         /* Receive/send statistics. */
39677 -       tw32(RCVLPC_STATS_ENABLE, 0xffffff);
39678 +       if ((rdmac_mode & RDMAC_MODE_FIFO_SIZE_128) &&
39679 +           (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) {
39680 +               val = tr32(RCVLPC_STATS_ENABLE);
39681 +               val &= ~RCVLPC_STATSENAB_LNGBRST_RFIX;
39682 +               tw32(RCVLPC_STATS_ENABLE, val);
39683 +       } else {
39684 +               tw32(RCVLPC_STATS_ENABLE, 0xffffff);
39685 +       }
39686         tw32(RCVLPC_STATSCTRL, RCVLPC_STATSCTRL_ENABLE);
39687         tw32(SNDDATAI_STATSENAB, 0xffffff);
39688         tw32(SNDDATAI_STATSCTRL,
39689 @@ -4215,33 +4895,43 @@
39690         }
39691  
39692         tw32(HOSTCC_RXCOL_TICKS, 0);
39693 -       tw32(HOSTCC_RXMAX_FRAMES, 1);
39694 -       tw32(HOSTCC_RXCOAL_TICK_INT, 0);
39695 -       tw32(HOSTCC_RXCOAL_MAXF_INT, 1);
39696         tw32(HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS);
39697 +       tw32(HOSTCC_RXMAX_FRAMES, 1);
39698         tw32(HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES);
39699 -       tw32(HOSTCC_TXCOAL_TICK_INT, 0);
39700 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
39701 +               tw32(HOSTCC_RXCOAL_TICK_INT, 0);
39702 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
39703 +               tw32(HOSTCC_TXCOAL_TICK_INT, 0);
39704 +       tw32(HOSTCC_RXCOAL_MAXF_INT, 1);
39705         tw32(HOSTCC_TXCOAL_MAXF_INT, 0);
39706 -       tw32(HOSTCC_STAT_COAL_TICKS,
39707 -            DEFAULT_STAT_COAL_TICKS);
39708  
39709 -       /* Status/statistics block address. */
39710 -       tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
39711 -            ((u64) tp->stats_mapping >> 32));
39712 -       tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
39713 -            ((u64) tp->stats_mapping & 0xffffffff));
39714 +       /* set status block DMA address */
39715         tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
39716              ((u64) tp->status_mapping >> 32));
39717         tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
39718              ((u64) tp->status_mapping & 0xffffffff));
39719 -       tw32(HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK);
39720 -       tw32(HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK);
39721 +
39722 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
39723 +               /* Status/statistics block address.  See tg3_timer,
39724 +                * the tg3_periodic_fetch_stats call there, and
39725 +                * tg3_get_stats to see how this works for 5705 chips.
39726 +                */
39727 +               tw32(HOSTCC_STAT_COAL_TICKS,
39728 +                    DEFAULT_STAT_COAL_TICKS);
39729 +               tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
39730 +                    ((u64) tp->stats_mapping >> 32));
39731 +               tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
39732 +                    ((u64) tp->stats_mapping & 0xffffffff));
39733 +               tw32(HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK);
39734 +               tw32(HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK);
39735 +       }
39736  
39737         tw32(HOSTCC_MODE, HOSTCC_MODE_ENABLE | tp->coalesce_mode);
39738  
39739         tw32(RCVCC_MODE, RCVCC_MODE_ENABLE | RCVCC_MODE_ATTN_ENABLE);
39740         tw32(RCVLPC_MODE, RCVLPC_MODE_ENABLE);
39741 -       tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE);
39742 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
39743 +               tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE);
39744  
39745         tp->mac_mode = MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE |
39746                 MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE;
39747 @@ -4260,42 +4950,47 @@
39748         tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);
39749         tr32(MAILBOX_INTERRUPT_0);
39750  
39751 -       tw32(DMAC_MODE, DMAC_MODE_ENABLE);
39752 -       tr32(DMAC_MODE);
39753 -       udelay(40);
39754 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
39755 +               tw32(DMAC_MODE, DMAC_MODE_ENABLE);
39756 +               tr32(DMAC_MODE);
39757 +               udelay(40);
39758 +       }
39759  
39760 -       tw32(WDMAC_MODE, (WDMAC_MODE_ENABLE | WDMAC_MODE_TGTABORT_ENAB |
39761 -                         WDMAC_MODE_MSTABORT_ENAB | WDMAC_MODE_PARITYERR_ENAB |
39762 -                         WDMAC_MODE_ADDROFLOW_ENAB | WDMAC_MODE_FIFOOFLOW_ENAB |
39763 -                         WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
39764 -                         WDMAC_MODE_LNGREAD_ENAB));
39765 +       val = (WDMAC_MODE_ENABLE | WDMAC_MODE_TGTABORT_ENAB |
39766 +              WDMAC_MODE_MSTABORT_ENAB | WDMAC_MODE_PARITYERR_ENAB |
39767 +              WDMAC_MODE_ADDROFLOW_ENAB | WDMAC_MODE_FIFOOFLOW_ENAB |
39768 +              WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
39769 +              WDMAC_MODE_LNGREAD_ENAB);
39770 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
39771 +           (tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) != 0 &&
39772 +           !(tp->tg3_flags2 & TG3_FLG2_IS_5788))
39773 +               val |= WDMAC_MODE_RX_ACCEL;
39774 +       tw32(WDMAC_MODE, val);
39775         tr32(WDMAC_MODE);
39776         udelay(40);
39777  
39778 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 &&
39779 -           (tp->tg3_flags & TG3_FLAG_PCIX_MODE)) {
39780 +       if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
39781                 val = tr32(TG3PCI_X_CAPS);
39782 -               val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
39783 -               val |= (PCIX_CAPS_MAX_BURST_5704 << PCIX_CAPS_BURST_SHIFT);
39784 -               if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
39785 -                       val |= (tp->split_mode_max_reqs <<
39786 -                               PCIX_CAPS_SPLIT_SHIFT);
39787 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) {
39788 +                       val &= ~PCIX_CAPS_BURST_MASK;
39789 +                       val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
39790 +               } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
39791 +                       val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
39792 +                       val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
39793 +                       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
39794 +                               val |= (tp->split_mode_max_reqs <<
39795 +                                       PCIX_CAPS_SPLIT_SHIFT);
39796 +               }
39797                 tw32(TG3PCI_X_CAPS, val);
39798         }
39799  
39800 -       val = (RDMAC_MODE_ENABLE | RDMAC_MODE_TGTABORT_ENAB |
39801 -              RDMAC_MODE_MSTABORT_ENAB | RDMAC_MODE_PARITYERR_ENAB |
39802 -              RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
39803 -              RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
39804 -              RDMAC_MODE_LNGREAD_ENAB);
39805 -       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
39806 -               val |= RDMAC_MODE_SPLIT_ENABLE;
39807 -       tw32(RDMAC_MODE, val);
39808 +       tw32(RDMAC_MODE, rdmac_mode);
39809         tr32(RDMAC_MODE);
39810         udelay(40);
39811  
39812         tw32(RCVDCC_MODE, RCVDCC_MODE_ENABLE | RCVDCC_MODE_ATTN_ENABLE);
39813 -       tw32(MBFREE_MODE, MBFREE_MODE_ENABLE);
39814 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
39815 +               tw32(MBFREE_MODE, MBFREE_MODE_ENABLE);
39816         tw32(SNDDATAC_MODE, SNDDATAC_MODE_ENABLE);
39817         tw32(SNDBDC_MODE, SNDBDC_MODE_ENABLE | SNDBDC_MODE_ATTN_ENABLE);
39818         tw32(RCVBDI_MODE, RCVBDI_MODE_ENABLE | RCVBDI_MODE_RCB_ATTN_ENAB);
39819 @@ -4310,8 +5005,8 @@
39820                         return err;
39821         }
39822  
39823 -#if TG3_DO_TSO != 0
39824 -       if (tp->dev->features & NETIF_F_TSO) {
39825 +#if TG3_TSO_SUPPORT != 0
39826 +       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
39827                 err = tg3_load_tso_firmware(tp);
39828                 if (err)
39829                         return err;
39830 @@ -4342,9 +5037,11 @@
39831  
39832         tw32(MAC_LED_CTRL, 0);
39833         tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
39834 -       tw32(MAC_RX_MODE, RX_MODE_RESET);
39835 -       tr32(MAC_RX_MODE);
39836 -       udelay(10);
39837 +       if (tp->phy_id == PHY_ID_SERDES) {
39838 +               tw32(MAC_RX_MODE, RX_MODE_RESET);
39839 +               tr32(MAC_RX_MODE);
39840 +               udelay(10);
39841 +       }
39842         tw32(MAC_RX_MODE, tp->rx_mode);
39843         tr32(MAC_RX_MODE);
39844         udelay(10);
39845 @@ -4378,22 +5075,48 @@
39846         tw32(MAC_RCV_VALUE_0, 0xffffffff & RCV_RULE_DISABLE_MASK);
39847         tw32(MAC_RCV_RULE_1,  0x86000004 & RCV_RULE_DISABLE_MASK);
39848         tw32(MAC_RCV_VALUE_1, 0xffffffff & RCV_RULE_DISABLE_MASK);
39849 -#if 0
39850 -       tw32(MAC_RCV_RULE_2,  0); tw32(MAC_RCV_VALUE_2,  0);
39851 -       tw32(MAC_RCV_RULE_3,  0); tw32(MAC_RCV_VALUE_3,  0);
39852 -#endif
39853 -       tw32(MAC_RCV_RULE_4,  0); tw32(MAC_RCV_VALUE_4,  0);
39854 -       tw32(MAC_RCV_RULE_5,  0); tw32(MAC_RCV_VALUE_5,  0);
39855 -       tw32(MAC_RCV_RULE_6,  0); tw32(MAC_RCV_VALUE_6,  0);
39856 -       tw32(MAC_RCV_RULE_7,  0); tw32(MAC_RCV_VALUE_7,  0);
39857 -       tw32(MAC_RCV_RULE_8,  0); tw32(MAC_RCV_VALUE_8,  0);
39858 -       tw32(MAC_RCV_RULE_9,  0); tw32(MAC_RCV_VALUE_9,  0);
39859 -       tw32(MAC_RCV_RULE_10,  0); tw32(MAC_RCV_VALUE_10,  0);
39860 -       tw32(MAC_RCV_RULE_11,  0); tw32(MAC_RCV_VALUE_11,  0);
39861 -       tw32(MAC_RCV_RULE_12,  0); tw32(MAC_RCV_VALUE_12,  0);
39862 -       tw32(MAC_RCV_RULE_13,  0); tw32(MAC_RCV_VALUE_13,  0);
39863 -       tw32(MAC_RCV_RULE_14,  0); tw32(MAC_RCV_VALUE_14,  0);
39864 -       tw32(MAC_RCV_RULE_15,  0); tw32(MAC_RCV_VALUE_15,  0);
39865 +
39866 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
39867 +               limit = 8;
39868 +       else
39869 +               limit = 16;
39870 +       if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF)
39871 +               limit -= 4;
39872 +       switch (limit) {
39873 +       case 16:
39874 +               tw32(MAC_RCV_RULE_15,  0); tw32(MAC_RCV_VALUE_15,  0);
39875 +       case 15:
39876 +               tw32(MAC_RCV_RULE_14,  0); tw32(MAC_RCV_VALUE_14,  0);
39877 +       case 14:
39878 +               tw32(MAC_RCV_RULE_13,  0); tw32(MAC_RCV_VALUE_13,  0);
39879 +       case 13:
39880 +               tw32(MAC_RCV_RULE_12,  0); tw32(MAC_RCV_VALUE_12,  0);
39881 +       case 12:
39882 +               tw32(MAC_RCV_RULE_11,  0); tw32(MAC_RCV_VALUE_11,  0);
39883 +       case 11:
39884 +               tw32(MAC_RCV_RULE_10,  0); tw32(MAC_RCV_VALUE_10,  0);
39885 +       case 10:
39886 +               tw32(MAC_RCV_RULE_9,  0); tw32(MAC_RCV_VALUE_9,  0);
39887 +       case 9:
39888 +               tw32(MAC_RCV_RULE_8,  0); tw32(MAC_RCV_VALUE_8,  0);
39889 +       case 8:
39890 +               tw32(MAC_RCV_RULE_7,  0); tw32(MAC_RCV_VALUE_7,  0);
39891 +       case 7:
39892 +               tw32(MAC_RCV_RULE_6,  0); tw32(MAC_RCV_VALUE_6,  0);
39893 +       case 6:
39894 +               tw32(MAC_RCV_RULE_5,  0); tw32(MAC_RCV_VALUE_5,  0);
39895 +       case 5:
39896 +               tw32(MAC_RCV_RULE_4,  0); tw32(MAC_RCV_VALUE_4,  0);
39897 +       case 4:
39898 +               /* tw32(MAC_RCV_RULE_3,  0); tw32(MAC_RCV_VALUE_3,  0); */
39899 +       case 3:
39900 +               /* tw32(MAC_RCV_RULE_2,  0); tw32(MAC_RCV_VALUE_2,  0); */
39901 +       case 2:
39902 +       case 1:
39903 +
39904 +       default:
39905 +               break;
39906 +       };
39907  
39908         if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE)
39909                 tg3_enable_ints(tp);
39910 @@ -4423,6 +5146,50 @@
39911         return err;
39912  }
39913  
39914 +#define TG3_STAT_ADD32(PSTAT, REG) \
39915 +do {   u32 __val = tr32(REG); \
39916 +       (PSTAT)->low += __val; \
39917 +       if ((PSTAT)->low < __val) \
39918 +               (PSTAT)->high += 1; \
39919 +} while (0)
39920 +
39921 +static void tg3_periodic_fetch_stats(struct tg3 *tp)
39922 +{
39923 +       struct tg3_hw_stats *sp = tp->hw_stats;
39924 +
39925 +       if (!netif_carrier_ok(tp->dev))
39926 +               return;
39927 +
39928 +       TG3_STAT_ADD32(&sp->tx_octets, MAC_TX_STATS_OCTETS);
39929 +       TG3_STAT_ADD32(&sp->tx_collisions, MAC_TX_STATS_COLLISIONS);
39930 +       TG3_STAT_ADD32(&sp->tx_xon_sent, MAC_TX_STATS_XON_SENT);
39931 +       TG3_STAT_ADD32(&sp->tx_xoff_sent, MAC_TX_STATS_XOFF_SENT);
39932 +       TG3_STAT_ADD32(&sp->tx_mac_errors, MAC_TX_STATS_MAC_ERRORS);
39933 +       TG3_STAT_ADD32(&sp->tx_single_collisions, MAC_TX_STATS_SINGLE_COLLISIONS);
39934 +       TG3_STAT_ADD32(&sp->tx_mult_collisions, MAC_TX_STATS_MULT_COLLISIONS);
39935 +       TG3_STAT_ADD32(&sp->tx_deferred, MAC_TX_STATS_DEFERRED);
39936 +       TG3_STAT_ADD32(&sp->tx_excessive_collisions, MAC_TX_STATS_EXCESSIVE_COL);
39937 +       TG3_STAT_ADD32(&sp->tx_late_collisions, MAC_TX_STATS_LATE_COL);
39938 +       TG3_STAT_ADD32(&sp->tx_ucast_packets, MAC_TX_STATS_UCAST);
39939 +       TG3_STAT_ADD32(&sp->tx_mcast_packets, MAC_TX_STATS_MCAST);
39940 +       TG3_STAT_ADD32(&sp->tx_bcast_packets, MAC_TX_STATS_BCAST);
39941 +
39942 +       TG3_STAT_ADD32(&sp->rx_octets, MAC_RX_STATS_OCTETS);
39943 +       TG3_STAT_ADD32(&sp->rx_fragments, MAC_RX_STATS_FRAGMENTS);
39944 +       TG3_STAT_ADD32(&sp->rx_ucast_packets, MAC_RX_STATS_UCAST);
39945 +       TG3_STAT_ADD32(&sp->rx_mcast_packets, MAC_RX_STATS_MCAST);
39946 +       TG3_STAT_ADD32(&sp->rx_bcast_packets, MAC_RX_STATS_BCAST);
39947 +       TG3_STAT_ADD32(&sp->rx_fcs_errors, MAC_RX_STATS_FCS_ERRORS);
39948 +       TG3_STAT_ADD32(&sp->rx_align_errors, MAC_RX_STATS_ALIGN_ERRORS);
39949 +       TG3_STAT_ADD32(&sp->rx_xon_pause_rcvd, MAC_RX_STATS_XON_PAUSE_RECVD);
39950 +       TG3_STAT_ADD32(&sp->rx_xoff_pause_rcvd, MAC_RX_STATS_XOFF_PAUSE_RECVD);
39951 +       TG3_STAT_ADD32(&sp->rx_mac_ctrl_rcvd, MAC_RX_STATS_MAC_CTRL_RECVD);
39952 +       TG3_STAT_ADD32(&sp->rx_xoff_entered, MAC_RX_STATS_XOFF_ENTERED);
39953 +       TG3_STAT_ADD32(&sp->rx_frame_too_long_errors, MAC_RX_STATS_FRAME_TOO_LONG);
39954 +       TG3_STAT_ADD32(&sp->rx_jabbers, MAC_RX_STATS_JABBERS);
39955 +       TG3_STAT_ADD32(&sp->rx_undersize_packets, MAC_RX_STATS_UNDERSIZE);
39956 +}
39957 +
39958  static void tg3_timer(unsigned long __opaque)
39959  {
39960         struct tg3 *tp = (struct tg3 *) __opaque;
39961 @@ -4451,6 +5218,9 @@
39962                 return;
39963         }
39964  
39965 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
39966 +               tg3_periodic_fetch_stats(tp);
39967 +
39968         /* This part only runs once per second. */
39969         if (!--tp->timer_counter) {
39970                 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) {
39971 @@ -4908,7 +5678,9 @@
39972                 get_stat64(&hw_stats->rx_bcast_packets);
39973                 
39974         stats->tx_packets = old_stats->tx_packets +
39975 -               get_stat64(&hw_stats->COS_out_packets[0]);
39976 +               get_stat64(&hw_stats->tx_ucast_packets) +
39977 +               get_stat64(&hw_stats->tx_mcast_packets) +
39978 +               get_stat64(&hw_stats->tx_bcast_packets);
39979  
39980         stats->rx_bytes = old_stats->rx_bytes +
39981                 get_stat64(&hw_stats->rx_octets);
39982 @@ -5232,6 +6004,20 @@
39983         tp->msg_enable = value;
39984  }
39985    
39986 +#if TG3_TSO_SUPPORT != 0
39987 +static int tg3_set_tso(struct net_device *dev, u32 value)
39988 +{
39989 +       struct tg3 *tp = dev->priv;
39990 +
39991 +       if (!(tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) {
39992 +               if (value)
39993 +                       return -EINVAL;
39994 +               return 0;
39995 +       }
39996 +       return ethtool_op_set_tso(dev, value);
39997 +}
39998 +#endif
39999 +  
40000  static int tg3_nway_reset(struct net_device *dev)
40001  {
40002         struct tg3 *tp = dev->priv;
40003 @@ -5279,11 +6065,14 @@
40004         spin_lock(&tp->tx_lock);
40005    
40006         tp->rx_pending = ering->rx_pending;
40007 +
40008 +       if ((tp->tg3_flags2 & TG3_FLG2_MAX_RXPEND_64) &&
40009 +           tp->rx_pending > 64)
40010 +               tp->rx_pending = 64;
40011         tp->rx_jumbo_pending = ering->rx_jumbo_pending;
40012         tp->tx_pending = ering->tx_pending;
40013  
40014         tg3_halt(tp);
40015 -       tg3_init_rings(tp);
40016         tg3_init_hw(tp);
40017         netif_wake_queue(tp->dev);
40018         spin_unlock(&tp->tx_lock);
40019 @@ -5322,7 +6111,6 @@
40020         else
40021                 tp->tg3_flags &= ~TG3_FLAG_PAUSE_TX;
40022         tg3_halt(tp);
40023 -       tg3_init_rings(tp);
40024         tg3_init_hw(tp);
40025         spin_unlock(&tp->tx_lock);
40026         spin_unlock_irq(&tp->lock);
40027 @@ -5467,6 +6255,10 @@
40028         .set_tx_csum            = tg3_set_tx_csum,
40029         .get_sg                 = ethtool_op_get_sg,
40030         .set_sg                 = ethtool_op_set_sg,
40031 +#if TG3_TSO_SUPPORT != 0
40032 +       .get_tso                = ethtool_op_get_tso,
40033 +       .set_tso                = tg3_set_tso,
40034 +#endif
40035  };
40036  
40037  /* Chips other than 5700/5701 use the NVRAM for fetching info. */
40038 @@ -5669,6 +6461,7 @@
40039                 u32 nic_cfg;
40040  
40041                 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
40042 +               tp->nic_sram_data_cfg = nic_cfg;
40043  
40044                 eeprom_signature_found = 1;
40045  
40046 @@ -5702,8 +6495,10 @@
40047                         eeprom_led_mode = led_mode_auto;
40048                         break;
40049                 };
40050 -               if ((tp->pci_chip_rev_id == CHIPREV_ID_5703_A1 ||
40051 -                    tp->pci_chip_rev_id == CHIPREV_ID_5703_A2) &&
40052 +
40053 +               if (((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
40054 +                    (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
40055 +                    (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) &&
40056                     (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP))
40057                         tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
40058  
40059 @@ -5785,9 +6580,7 @@
40060         }
40061  
40062         /* Enable Ethernet@WireSpeed */
40063 -       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007);
40064 -       tg3_readphy(tp, MII_TG3_AUX_CTRL, &val);
40065 -       tg3_writephy(tp, MII_TG3_AUX_CTRL, (val | (1 << 15) | (1 << 4)));
40066 +       tg3_phy_set_wirespeed(tp);
40067  
40068         if (!err && ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401)) {
40069                 err = tg3_init_5401phy_dsp(tp);
40070 @@ -5927,7 +6720,7 @@
40071                 tp->tg3_flags2 |= TG3_FLG2_SUN_5704;
40072  #endif
40073  
40074 -       /* If we have an AMD 762 or Intel ICH/ICH0 chipset, write
40075 +       /* If we have an AMD 762 or Intel ICH/ICH0/ICH2 chipset, write
40076          * reordering to the mailbox registers done by the host
40077          * controller can cause major troubles.  We read back from
40078          * every mailbox register write to force the writes to be
40079 @@ -5937,6 +6730,10 @@
40080                             PCI_DEVICE_ID_INTEL_82801AA_8, NULL) ||
40081             pci_find_device(PCI_VENDOR_ID_INTEL,
40082                             PCI_DEVICE_ID_INTEL_82801AB_8, NULL) ||
40083 +           pci_find_device(PCI_VENDOR_ID_INTEL,
40084 +                           PCI_DEVICE_ID_INTEL_82801BA_11, NULL) ||
40085 +           pci_find_device(PCI_VENDOR_ID_INTEL,
40086 +                           PCI_DEVICE_ID_INTEL_82801BA_6, NULL) ||
40087             pci_find_device(PCI_VENDOR_ID_AMD,
40088                             PCI_DEVICE_ID_AMD_FE_GATE_700C, NULL))
40089                 tp->tg3_flags |= TG3_FLAG_MBOX_WRITE_REORDER;
40090 @@ -6085,7 +6882,15 @@
40091                 tp->tg3_flags |= TG3_FLAG_WOL_SPEED_100MB;
40092         }
40093  
40094 +       /* A few boards don't want Ethernet@WireSpeed phy feature */
40095 +       if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
40096 +           ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
40097 +            (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) &&
40098 +            (tp->pci_chip_rev_id != CHIPREV_ID_5705_A1)))
40099 +               tp->tg3_flags2 |= TG3_FLG2_NO_ETH_WIRE_SPEED;
40100 +
40101         /* Only 5701 and later support tagged irq status mode.
40102 +        * Also, 5788 chips cannot use tagged irq status.
40103          *
40104          * However, since we are using NAPI avoid tagged irq status
40105          * because the interrupt condition is more difficult to
40106 @@ -6142,7 +6947,8 @@
40107         /* Determine if TX descriptors will reside in
40108          * main memory or in the chip SRAM.
40109          */
40110 -       if (tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG)
40111 +       if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) != 0 ||
40112 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
40113                 tp->tg3_flags |= TG3_FLAG_HOST_TXDS;
40114  
40115         grc_misc_cfg = tr32(GRC_MISC_CFG);
40116 @@ -6154,8 +6960,18 @@
40117                 tp->split_mode_max_reqs = SPLIT_MODE_5704_MAX_REQ;
40118         }
40119  
40120 -       /* this one is limited to 10/100 only */
40121 -       if (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5702FE)
40122 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
40123 +           (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 ||
40124 +            grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M))
40125 +               tp->tg3_flags2 |= TG3_FLG2_IS_5788;
40126 +
40127 +       /* these are limited to 10/100 only */
40128 +       if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 &&
40129 +            (grc_misc_cfg == 0x8000 || grc_misc_cfg == 0x4000)) ||
40130 +           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
40131 +            tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM &&
40132 +            (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5901 ||
40133 +             tp->pdev->device == PCI_DEVICE_ID_TIGON3_5901_2)))
40134                 tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
40135  
40136         err = tg3_phy_probe(tp);
40137 @@ -6414,8 +7230,6 @@
40138                 goto out_nofree;
40139         }
40140  
40141 -       tw32(TG3PCI_CLOCK_CTRL, 0);
40142 -
40143         if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) == 0) {
40144                 tp->dma_rwctrl =
40145                         (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
40146 @@ -6423,7 +7237,9 @@
40147                         (0x7 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
40148                         (0x7 << DMA_RWCTRL_READ_WATER_SHIFT) |
40149                         (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT);
40150 -               /* XXX 5705 note: set MIN_DMA to zero here */
40151 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
40152 +                       tp->dma_rwctrl &= ~(DMA_RWCTRL_MIN_DMA
40153 +                                           << DMA_RWCTRL_MIN_DMA_SHIFT);
40154         } else {
40155                 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
40156                         tp->dma_rwctrl =
40157 @@ -6524,8 +7340,15 @@
40158                 tp->dma_rwctrl |= DMA_RWCTRL_USE_MEM_READ_MULT;
40159         }
40160  
40161 +       tp->dma_rwctrl |= DMA_RWCTRL_ASSERT_ALL_BE;
40162 +
40163         tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
40164  
40165 +#if 0
40166 +       /* Unneeded, already done by tg3_get_invariants.  */
40167 +       tg3_switch_clocks(tp);
40168 +#endif
40169 +
40170         ret = 0;
40171         if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
40172             GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701)
40173 @@ -6630,12 +7453,35 @@
40174         case PHY_ID_BCM5701:    return "5701";
40175         case PHY_ID_BCM5703:    return "5703";
40176         case PHY_ID_BCM5704:    return "5704";
40177 +       case PHY_ID_BCM5705:    return "5705";
40178         case PHY_ID_BCM8002:    return "8002";
40179         case PHY_ID_SERDES:     return "serdes";
40180         default:                return "unknown";
40181         };
40182  }
40183  
40184 +static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
40185 +{
40186 +       struct pci_dev *peer = NULL;
40187 +       unsigned int func;
40188 +
40189 +       for (func = 0; func < 7; func++) {
40190 +               unsigned int devfn = tp->pdev->devfn;
40191 +
40192 +               devfn &= ~7;
40193 +               devfn |= func;
40194 +
40195 +               if (devfn == tp->pdev->devfn)
40196 +                       continue;
40197 +               peer = pci_find_slot(tp->pdev->bus->number, devfn);
40198 +               if (peer)
40199 +                       break;
40200 +       }
40201 +       if (!peer || peer == tp->pdev)
40202 +               BUG();
40203 +       return peer;
40204 +}
40205 +
40206  static int __devinit tg3_init_one(struct pci_dev *pdev,
40207                                   const struct pci_device_id *ent)
40208  {
40209 @@ -6688,7 +7534,7 @@
40210                         goto err_out_free_res;
40211                 }
40212         } else {
40213 -               err = pci_set_dma_mask(pdev, (u64) 0xffffffff);
40214 +               err = pci_set_dma_mask(pdev, 0xffffffffULL);
40215                 if (err) {
40216                         printk(KERN_ERR PFX "No usable DMA configuration, "
40217                                "aborting.\n");
40218 @@ -6794,6 +7640,44 @@
40219                 goto err_out_iounmap;
40220         }
40221  
40222 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
40223 +               tp->bufmgr_config.mbuf_read_dma_low_water =
40224 +                       DEFAULT_MB_RDMA_LOW_WATER_5705;
40225 +               tp->bufmgr_config.mbuf_mac_rx_low_water =
40226 +                       DEFAULT_MB_MACRX_LOW_WATER_5705;
40227 +               tp->bufmgr_config.mbuf_high_water =
40228 +                       DEFAULT_MB_HIGH_WATER_5705;
40229 +       }
40230 +
40231 +#if TG3_TSO_SUPPORT != 0
40232 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
40233 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
40234 +           tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 ||
40235 +           (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0 ||
40236 +           (tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
40237 +               tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE;
40238 +       } else {
40239 +               tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE;
40240 +       }
40241 +
40242 +       /* TSO is off by default, user can enable using ethtool.  */
40243 +#if 0
40244 +       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)
40245 +               dev->features |= NETIF_F_TSO;
40246 +#endif
40247 +
40248 +#endif
40249 +
40250 +       if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A1 &&
40251 +           !(tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) &&
40252 +           !(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH)) {
40253 +               tp->tg3_flags2 |= TG3_FLG2_MAX_RXPEND_64;
40254 +               tp->rx_pending = 64;
40255 +       }
40256 +
40257 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
40258 +               tp->pdev_peer = tg3_find_5704_peer(tp);
40259 +
40260         err = tg3_get_device_address(tp);
40261         if (err) {
40262                 printk(KERN_ERR PFX "Could not obtain valid ethernet address, "
40263 @@ -6816,16 +7700,8 @@
40264         } else
40265                 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS;
40266  
40267 -#if TG3_DO_TSO != 0
40268 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
40269 -           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
40270 -            tp->pci_chip_rev_id <= CHIPREV_ID_5701_B2)) {
40271 -               /* Not TSO capable. */
40272 -               dev->features &= ~NETIF_F_TSO;
40273 -       } else {
40274 -               dev->features |= NETIF_F_TSO;
40275 -       }
40276 -#endif
40277 +       if (tp->tg3_flags2 & TG3_FLG2_IS_5788)
40278 +               dev->features &= ~NETIF_F_HIGHDMA;
40279  
40280         err = register_netdev(dev);
40281         if (err) {
40282 diff -Nru a/drivers/net/tg3.h b/drivers/net/tg3.h
40283 --- a/drivers/net/tg3.h Sat Aug  2 18:24:21 2003
40284 +++ b/drivers/net/tg3.h Sat Aug 23 21:07:46 2003
40285 @@ -24,6 +24,7 @@
40286  #define RX_COPY_THRESHOLD              256
40287  
40288  #define RX_STD_MAX_SIZE                        1536
40289 +#define RX_STD_MAX_SIZE_5705           512
40290  #define RX_JUMBO_MAX_SIZE              0xdeadbeef /* XXX */
40291  
40292  /* First 256 bytes are a mirror of PCI config space. */
40293 @@ -59,7 +60,7 @@
40294  #define  PCIX_CAPS_SPLIT_SHIFT          20
40295  #define  PCIX_CAPS_BURST_MASK           0x000c0000
40296  #define  PCIX_CAPS_BURST_SHIFT          18
40297 -#define  PCIX_CAPS_MAX_BURST_5704       2
40298 +#define  PCIX_CAPS_MAX_BURST_CPIOB      2
40299  #define TG3PCI_PM_CAP_PTR              0x00000041
40300  #define TG3PCI_X_COMMAND               0x00000042
40301  #define TG3PCI_X_STATUS                        0x00000044
40302 @@ -115,11 +116,14 @@
40303  #define  CHIPREV_ID_5704_A0             0x2000
40304  #define  CHIPREV_ID_5704_A1             0x2001
40305  #define  CHIPREV_ID_5704_A2             0x2002
40306 +#define  CHIPREV_ID_5705_A0             0x3000
40307 +#define  CHIPREV_ID_5705_A1             0x3001
40308  #define  GET_ASIC_REV(CHIP_REV_ID)     ((CHIP_REV_ID) >> 12)
40309  #define   ASIC_REV_5700                         0x07
40310  #define   ASIC_REV_5701                         0x00
40311  #define   ASIC_REV_5703                         0x01
40312  #define   ASIC_REV_5704                         0x02
40313 +#define   ASIC_REV_5705                         0x03
40314  #define  GET_CHIP_REV(CHIP_REV_ID)     ((CHIP_REV_ID) >> 8)
40315  #define   CHIPREV_5700_AX               0x70
40316  #define   CHIPREV_5700_BX               0x71
40317 @@ -180,6 +184,9 @@
40318  #define  CLOCK_CTRL_ALTCLK              0x00001000
40319  #define  CLOCK_CTRL_PWRDOWN_PLL133      0x00008000
40320  #define  CLOCK_CTRL_44MHZ_CORE          0x00040000
40321 +#define  CLOCK_CTRL_625_CORE            0x00100000
40322 +#define  CLOCK_CTRL_FORCE_CLKRUN        0x00200000
40323 +#define  CLOCK_CTRL_CLKRUN_OENABLE      0x00400000
40324  #define  CLOCK_CTRL_DELAY_PCI_GRANT     0x80000000
40325  #define TG3PCI_REG_BASE_ADDR           0x00000078
40326  #define TG3PCI_MEM_WIN_BASE_ADDR       0x0000007c
40327 @@ -457,17 +464,89 @@
40328  #define MAC_RCV_RULE_CFG               0x00000500
40329  #define  RCV_RULE_CFG_DEFAULT_CLASS    0x00000008
40330  #define MAC_LOW_WMARK_MAX_RX_FRAME     0x00000504
40331 -/* 0x504 --> 0x590 unused */
40332 +/* 0x508 --> 0x520 unused */
40333 +#define MAC_HASHREGU_0                 0x00000520
40334 +#define MAC_HASHREGU_1                 0x00000524
40335 +#define MAC_HASHREGU_2                 0x00000528
40336 +#define MAC_HASHREGU_3                 0x0000052c
40337 +#define MAC_EXTADDR_0_HIGH             0x00000530
40338 +#define MAC_EXTADDR_0_LOW              0x00000534
40339 +#define MAC_EXTADDR_1_HIGH             0x00000538
40340 +#define MAC_EXTADDR_1_LOW              0x0000053c
40341 +#define MAC_EXTADDR_2_HIGH             0x00000540
40342 +#define MAC_EXTADDR_2_LOW              0x00000544
40343 +#define MAC_EXTADDR_3_HIGH             0x00000548
40344 +#define MAC_EXTADDR_3_LOW              0x0000054c
40345 +#define MAC_EXTADDR_4_HIGH             0x00000550
40346 +#define MAC_EXTADDR_4_LOW              0x00000554
40347 +#define MAC_EXTADDR_5_HIGH             0x00000558
40348 +#define MAC_EXTADDR_5_LOW              0x0000055c
40349 +#define MAC_EXTADDR_6_HIGH             0x00000560
40350 +#define MAC_EXTADDR_6_LOW              0x00000564
40351 +#define MAC_EXTADDR_7_HIGH             0x00000568
40352 +#define MAC_EXTADDR_7_LOW              0x0000056c
40353 +#define MAC_EXTADDR_8_HIGH             0x00000570
40354 +#define MAC_EXTADDR_8_LOW              0x00000574
40355 +#define MAC_EXTADDR_9_HIGH             0x00000578
40356 +#define MAC_EXTADDR_9_LOW              0x0000057c
40357 +#define MAC_EXTADDR_10_HIGH            0x00000580
40358 +#define MAC_EXTADDR_10_LOW             0x00000584
40359 +#define MAC_EXTADDR_11_HIGH            0x00000588
40360 +#define MAC_EXTADDR_11_LOW             0x0000058c
40361  #define MAC_SERDES_CFG                 0x00000590
40362  #define MAC_SERDES_STAT                        0x00000594
40363  /* 0x598 --> 0x600 unused */
40364  #define MAC_TX_MAC_STATE_BASE          0x00000600 /* 16 bytes */
40365  #define MAC_RX_MAC_STATE_BASE          0x00000610 /* 20 bytes */
40366  /* 0x624 --> 0x800 unused */
40367 -#define MAC_RX_STATS_BASE              0x00000800 /* 26 32-bit words */
40368 -/* 0x868 --> 0x880 unused */
40369 -#define MAC_TX_STATS_BASE              0x00000880 /* 28 32-bit words */
40370 -/* 0x8f0 --> 0xc00 unused */
40371 +#define MAC_TX_STATS_OCTETS            0x00000800
40372 +#define MAC_TX_STATS_RESV1             0x00000804
40373 +#define MAC_TX_STATS_COLLISIONS                0x00000808
40374 +#define MAC_TX_STATS_XON_SENT          0x0000080c
40375 +#define MAC_TX_STATS_XOFF_SENT         0x00000810
40376 +#define MAC_TX_STATS_RESV2             0x00000814
40377 +#define MAC_TX_STATS_MAC_ERRORS                0x00000818
40378 +#define MAC_TX_STATS_SINGLE_COLLISIONS 0x0000081c
40379 +#define MAC_TX_STATS_MULT_COLLISIONS   0x00000820
40380 +#define MAC_TX_STATS_DEFERRED          0x00000824
40381 +#define MAC_TX_STATS_RESV3             0x00000828
40382 +#define MAC_TX_STATS_EXCESSIVE_COL     0x0000082c
40383 +#define MAC_TX_STATS_LATE_COL          0x00000830
40384 +#define MAC_TX_STATS_RESV4_1           0x00000834
40385 +#define MAC_TX_STATS_RESV4_2           0x00000838
40386 +#define MAC_TX_STATS_RESV4_3           0x0000083c
40387 +#define MAC_TX_STATS_RESV4_4           0x00000840
40388 +#define MAC_TX_STATS_RESV4_5           0x00000844
40389 +#define MAC_TX_STATS_RESV4_6           0x00000848
40390 +#define MAC_TX_STATS_RESV4_7           0x0000084c
40391 +#define MAC_TX_STATS_RESV4_8           0x00000850
40392 +#define MAC_TX_STATS_RESV4_9           0x00000854
40393 +#define MAC_TX_STATS_RESV4_10          0x00000858
40394 +#define MAC_TX_STATS_RESV4_11          0x0000085c
40395 +#define MAC_TX_STATS_RESV4_12          0x00000860
40396 +#define MAC_TX_STATS_RESV4_13          0x00000864
40397 +#define MAC_TX_STATS_RESV4_14          0x00000868
40398 +#define MAC_TX_STATS_UCAST             0x0000086c
40399 +#define MAC_TX_STATS_MCAST             0x00000870
40400 +#define MAC_TX_STATS_BCAST             0x00000874
40401 +#define MAC_TX_STATS_RESV5_1           0x00000878
40402 +#define MAC_TX_STATS_RESV5_2           0x0000087c
40403 +#define MAC_RX_STATS_OCTETS            0x00000880
40404 +#define MAC_RX_STATS_RESV1             0x00000884
40405 +#define MAC_RX_STATS_FRAGMENTS         0x00000888
40406 +#define MAC_RX_STATS_UCAST             0x0000088c
40407 +#define MAC_RX_STATS_MCAST             0x00000890
40408 +#define MAC_RX_STATS_BCAST             0x00000894
40409 +#define MAC_RX_STATS_FCS_ERRORS                0x00000898
40410 +#define MAC_RX_STATS_ALIGN_ERRORS      0x0000089c
40411 +#define MAC_RX_STATS_XON_PAUSE_RECVD   0x000008a0
40412 +#define MAC_RX_STATS_XOFF_PAUSE_RECVD  0x000008a4
40413 +#define MAC_RX_STATS_MAC_CTRL_RECVD    0x000008a8
40414 +#define MAC_RX_STATS_XOFF_ENTERED      0x000008ac
40415 +#define MAC_RX_STATS_FRAME_TOO_LONG    0x000008b0
40416 +#define MAC_RX_STATS_JABBERS           0x000008b4
40417 +#define MAC_RX_STATS_UNDERSIZE         0x000008b8
40418 +/* 0x8bc --> 0xc00 unused */
40419  
40420  /* Send data initiator control registers */
40421  #define SNDDATAI_MODE                  0x00000c00
40422 @@ -599,6 +678,7 @@
40423  #define  RCVLPC_STATSCTRL_ENABLE        0x00000001
40424  #define  RCVLPC_STATSCTRL_FASTUPD       0x00000002
40425  #define RCVLPC_STATS_ENABLE            0x00002018
40426 +#define  RCVLPC_STATSENAB_LNGBRST_RFIX  0x00400000
40427  #define RCVLPC_STATS_INCMASK           0x0000201c
40428  /* 0x2020 --> 0x2100 unused */
40429  #define RCVLPC_SELLST_BASE             0x00002100 /* 16 16-byte entries */
40430 @@ -812,13 +892,16 @@
40431  #define BUFMGR_MB_POOL_ADDR            0x00004408
40432  #define BUFMGR_MB_POOL_SIZE            0x0000440c
40433  #define BUFMGR_MB_RDMA_LOW_WATER       0x00004410
40434 -#define  DEFAULT_MB_RDMA_LOW_WATER      0x00000040
40435 +#define  DEFAULT_MB_RDMA_LOW_WATER      0x00000050
40436 +#define  DEFAULT_MB_RDMA_LOW_WATER_5705         0x00000000
40437  #define  DEFAULT_MB_RDMA_LOW_WATER_JUMBO 0x00000130
40438  #define BUFMGR_MB_MACRX_LOW_WATER      0x00004414
40439  #define  DEFAULT_MB_MACRX_LOW_WATER      0x00000020
40440 +#define  DEFAULT_MB_MACRX_LOW_WATER_5705  0x00000010
40441  #define  DEFAULT_MB_MACRX_LOW_WATER_JUMBO 0x00000098
40442  #define BUFMGR_MB_HIGH_WATER           0x00004418
40443  #define  DEFAULT_MB_HIGH_WATER          0x00000060
40444 +#define  DEFAULT_MB_HIGH_WATER_5705     0x00000060
40445  #define  DEFAULT_MB_HIGH_WATER_JUMBO    0x0000017c
40446  #define BUFMGR_RX_MB_ALLOC_REQ         0x0000441c
40447  #define  BUFMGR_MB_ALLOC_BIT            0x10000000
40448 @@ -854,6 +937,8 @@
40449  #define  RDMAC_MODE_LNGREAD_ENAB        0x00000200
40450  #define  RDMAC_MODE_SPLIT_ENABLE        0x00000800
40451  #define  RDMAC_MODE_SPLIT_RESET                 0x00001000
40452 +#define  RDMAC_MODE_FIFO_SIZE_128       0x00020000
40453 +#define  RDMAC_MODE_FIFO_LONG_BURST     0x00030000
40454  #define RDMAC_STATUS                   0x00004804
40455  #define  RDMAC_STATUS_TGTABORT          0x00000004
40456  #define  RDMAC_STATUS_MSTABORT          0x00000008
40457 @@ -877,6 +962,7 @@
40458  #define  WDMAC_MODE_FIFOURUN_ENAB       0x00000080
40459  #define  WDMAC_MODE_FIFOOREAD_ENAB      0x00000100
40460  #define  WDMAC_MODE_LNGREAD_ENAB        0x00000200
40461 +#define  WDMAC_MODE_RX_ACCEL            0x00000400
40462  #define WDMAC_STATUS                   0x00004c04
40463  #define  WDMAC_STATUS_TGTABORT          0x00000004
40464  #define  WDMAC_STATUS_MSTABORT          0x00000008
40465 @@ -1140,7 +1226,10 @@
40466  #define  GRC_MISC_CFG_BOARD_ID_5704    0x00000000
40467  #define  GRC_MISC_CFG_BOARD_ID_5704CIOBE 0x00004000
40468  #define  GRC_MISC_CFG_BOARD_ID_5704_A2 0x00008000
40469 +#define  GRC_MISC_CFG_BOARD_ID_5788    0x00010000
40470 +#define  GRC_MISC_CFG_BOARD_ID_5788M   0x00018000
40471  #define  GRC_MISC_CFG_BOARD_ID_AC91002A1 0x00018000
40472 +#define  GRC_MISC_CFG_KEEP_GPHY_POWER  0x04000000
40473  #define GRC_LOCAL_CTRL                 0x00006808
40474  #define  GRC_LCLCTRL_INT_ACTIVE                0x00000001
40475  #define  GRC_LCLCTRL_CLEARINT          0x00000002
40476 @@ -1275,6 +1364,7 @@
40477  #define  NIC_SRAM_DATA_CFG_WOL_ENABLE           0x00000040
40478  #define  NIC_SRAM_DATA_CFG_ASF_ENABLE           0x00000080
40479  #define  NIC_SRAM_DATA_CFG_EEPROM_WP            0x00000100
40480 +#define  NIC_SRAM_DATA_CFG_MINI_PCI             0x00001000
40481  #define  NIC_SRAM_DATA_CFG_FIBER_WOL            0x00004000
40482  
40483  #define NIC_SRAM_DATA_PHY_ID           0x00000b74
40484 @@ -1312,6 +1402,8 @@
40485  #define NIC_SRAM_MBUF_POOL_BASE                0x00008000
40486  #define  NIC_SRAM_MBUF_POOL_SIZE96      0x00018000
40487  #define  NIC_SRAM_MBUF_POOL_SIZE64      0x00010000
40488 +#define  NIC_SRAM_MBUF_POOL_BASE5705   0x00010000
40489 +#define  NIC_SRAM_MBUF_POOL_SIZE5705   0x0000e000
40490  
40491  /* Currently this is fixed. */
40492  #define PHY_ADDR               0x01
40493 @@ -1824,6 +1916,10 @@
40494         u32                             tg3_flags2;
40495  #define TG3_FLG2_RESTART_TIMER         0x00000001
40496  #define TG3_FLG2_SUN_5704              0x00000002
40497 +#define TG3_FLG2_NO_ETH_WIRE_SPEED     0x00000004
40498 +#define TG3_FLG2_IS_5788               0x00000008
40499 +#define TG3_FLG2_MAX_RXPEND_64         0x00000010
40500 +#define TG3_FLG2_TSO_CAPABLE           0x00000020
40501  
40502         u32                             split_mode_max_reqs;
40503  #define SPLIT_MODE_5704_MAX_REQ                3
40504 @@ -1868,6 +1964,7 @@
40505  #define PHY_ID_BCM5701                 0x60008110
40506  #define PHY_ID_BCM5703                 0x60008160
40507  #define PHY_ID_BCM5704                 0x60008190
40508 +#define PHY_ID_BCM5705                 0x600081a0
40509  #define PHY_ID_BCM8002                 0x60010140
40510  #define PHY_ID_SERDES                  0xfeedbee0
40511  #define PHY_ID_INVALID                 0xffffffff
40512 @@ -1880,6 +1977,9 @@
40513         enum phy_led_mode               led_mode;
40514  
40515         char                            board_part_number[24];
40516 +       u32                             nic_sram_data_cfg;
40517 +       u32                             pci_clock_ctrl;
40518 +       struct pci_dev                  *pdev_peer;
40519  
40520         /* This macro assumes the passed PHY ID is already masked
40521          * with PHY_ID_MASK.
40522 @@ -1888,6 +1988,7 @@
40523         ((X) == PHY_ID_BCM5400 || (X) == PHY_ID_BCM5401 || \
40524          (X) == PHY_ID_BCM5411 || (X) == PHY_ID_BCM5701 || \
40525          (X) == PHY_ID_BCM5703 || (X) == PHY_ID_BCM5704 || \
40526 +        (X) == PHY_ID_BCM5705 || \
40527          (X) == PHY_ID_BCM8002 || (X) == PHY_ID_SERDES)
40528  
40529         struct tg3_hw_stats             *hw_stats;
40530 diff -Nru a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
40531 --- a/drivers/net/tokenring/lanstreamer.c       Tue Aug 19 20:54:17 2003
40532 +++ b/drivers/net/tokenring/lanstreamer.c       Mon Sep  1 08:30:59 2003
40533 @@ -228,7 +228,6 @@
40534         int rc = 0;
40535         static int card_no=-1;
40536         u16 pcr;
40537 -       u8 cls = 0;
40538  
40539  #if STREAMER_DEBUG
40540         printk("lanstreamer::streamer_init_one, entry pdev %p\n",pdev);
40541 @@ -254,14 +253,16 @@
40542  #endif
40543  #endif
40544  
40545 -       if (pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
40546 +       rc = pci_set_dma_mask(pdev, 0xFFFFFFFFULL);
40547 +       if (rc) {
40548                 printk(KERN_ERR "%s: No suitable PCI mapping available.\n",
40549                                 dev->name);
40550                 rc = -ENODEV;
40551                 goto err_out;
40552         }
40553  
40554 -       if (pci_enable_device(pdev)) {
40555 +       rc = pci_enable_device(pdev);
40556 +       if (rc) {
40557                 printk(KERN_ERR "lanstreamer: unable to enable pci device\n");
40558                 rc=-EIO;
40559                 goto err_out;
40560 @@ -269,6 +270,12 @@
40561  
40562         pci_set_master(pdev);
40563  
40564 +       rc = pci_set_mwi(pdev);
40565 +       if (rc) {
40566 +               printk(KERN_ERR "lanstreamer: unable to enable MWI on pci device\n");
40567 +               goto err_out_disable;
40568 +       }
40569 +
40570         pio_start = pci_resource_start(pdev, 0);
40571         pio_end = pci_resource_end(pdev, 0);
40572         pio_flags = pci_resource_flags(pdev, 0);
40573 @@ -290,7 +297,7 @@
40574                 printk(KERN_ERR "lanstreamer: unable to get pci io addr %lx\n",
40575                         pio_start);
40576                 rc= -EBUSY;
40577 -               goto err_out;
40578 +               goto err_out_mwi;
40579         }
40580  
40581         if (!request_mem_region(mmio_start, mmio_len, "lanstreamer")) {
40582 @@ -341,26 +348,9 @@
40583  
40584         spin_lock_init(&streamer_priv->streamer_lock);
40585  
40586 -       pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cls);
40587 -       cls <<= 2;
40588 -       if (cls != SMP_CACHE_BYTES) {
40589 -               printk(KERN_INFO "  PCI cache line size set incorrectly "
40590 -                               "(%i bytes) by BIOS/FW, ", cls);
40591 -               if (cls > SMP_CACHE_BYTES)
40592 -                       printk("expecting %i\n", SMP_CACHE_BYTES);
40593 -               else {
40594 -                       printk("correcting to %i\n", SMP_CACHE_BYTES);
40595 -                       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
40596 -                                                       SMP_CACHE_BYTES >> 2);
40597 -               }
40598 -       }
40599 -
40600         pci_read_config_word (pdev, PCI_COMMAND, &pcr);
40601 -
40602 -       pcr |= (PCI_COMMAND_INVALIDATE | PCI_COMMAND_SERR);
40603 -
40604 +       pcr |= PCI_COMMAND_SERR;
40605         pci_write_config_word (pdev, PCI_COMMAND, pcr);
40606 -       pci_read_config_word (pdev, PCI_COMMAND, &pcr);
40607  
40608         printk("%s \n", version);
40609         printk("%s: %s. I/O at %hx, MMIO at %p, using irq %d\n",dev->name,
40610 @@ -383,8 +373,12 @@
40611         release_mem_region(mmio_start, mmio_len);
40612  err_out_free_pio:
40613         release_region(pio_start, pio_len);
40614 +err_out_mwi:
40615 +       pci_clear_mwi(pdev);
40616 +err_out_disable:
40617 +       pci_disable_device(pdev);
40618  err_out:
40619 -       kfree(dev);
40620 +       free_netdev(dev);
40621  #if STREAMER_DEBUG
40622         printk("lanstreamer: Exit error %x\n",rc);
40623  #endif
40624 @@ -430,9 +424,11 @@
40625  #endif
40626  
40627         unregister_netdev(dev);
40628 -       /* shouldn't we do iounmap here? */
40629 -       release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0));
40630 +       iounmap(streamer_priv->streamer_mmio);
40631         release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev,1));
40632 +       release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0));
40633 +       pci_clear_mwi(pdev);
40634 +       pci_disable_device(pdev);
40635         free_netdev(dev);
40636         pci_set_drvdata(pdev, NULL);
40637  }
40638 diff -Nru a/drivers/net/tulip/Kconfig b/drivers/net/tulip/Kconfig
40639 --- a/drivers/net/tulip/Kconfig Mon Aug 18 21:08:08 2003
40640 +++ b/drivers/net/tulip/Kconfig Mon Aug 25 05:54:02 2003
40641 @@ -129,7 +129,7 @@
40642  
40643  config PCMCIA_XIRTULIP
40644         tristate "Xircom Tulip-like CardBus support (old driver)"
40645 -       depends on NET_TULIP && CARDBUS
40646 +       depends on NET_TULIP && CARDBUS && BROKEN_ON_SMP
40647         ---help---
40648           This driver is for the Digital "Tulip" Ethernet CardBus adapters.
40649           It should work with most DEC 21*4*-based chips/ethercards, as well
40650 diff -Nru a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
40651 --- a/drivers/net/tulip/de2104x.c       Tue Aug 19 20:53:17 2003
40652 +++ b/drivers/net/tulip/de2104x.c       Mon Sep  1 08:05:06 2003
40653 @@ -1,6 +1,6 @@
40654  /* de2104x.c: A Linux PCI Ethernet driver for Intel/Digital 21040/1 chips. */
40655  /*
40656 -       Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
40657 +       Copyright 2001,2003 Jeff Garzik <jgarzik@pobox.com>
40658  
40659         Copyright 1994, 1995 Digital Equipment Corporation.         [de4x5.c]
40660         Written/copyright 1994-2001 by Donald Becker.               [tulip.c]
40661 @@ -28,8 +28,8 @@
40662   */
40663  
40664  #define DRV_NAME               "de2104x"
40665 -#define DRV_VERSION            "0.5.4"
40666 -#define DRV_RELDATE            "Jan 1, 2002"
40667 +#define DRV_VERSION            "0.6"
40668 +#define DRV_RELDATE            "Sep 1, 2003"
40669  
40670  #include <linux/config.h>
40671  #include <linux/module.h>
40672 @@ -1464,7 +1464,7 @@
40673         netif_wake_queue(dev);
40674  }
40675  
40676 -static int de_get_regs(struct de_private *de, u8 *buf)
40677 +static void __de_get_regs(struct de_private *de, u8 *buf)
40678  {
40679         int i;
40680         u32 *rbuf = (u32 *)buf;
40681 @@ -1475,11 +1475,9 @@
40682  
40683         /* handle self-clearing RxMissed counter, CSR8 */
40684         de_rx_missed(de, rbuf[8]);
40685 -
40686 -       return 0;
40687  }
40688  
40689 -static int de_ethtool_gset(struct de_private *de, struct ethtool_cmd *ecmd)
40690 +static int __de_get_settings(struct de_private *de, struct ethtool_cmd *ecmd)
40691  {
40692         ecmd->supported = de->media_supported;
40693         ecmd->transceiver = XCVR_INTERNAL;
40694 @@ -1516,7 +1514,7 @@
40695         return 0;
40696  }
40697  
40698 -static int de_ethtool_sset(struct de_private *de, struct ethtool_cmd *ecmd)
40699 +static int __de_set_settings(struct de_private *de, struct ethtool_cmd *ecmd)
40700  {
40701         u32 new_media;
40702         unsigned int media_lock;
40703 @@ -1584,169 +1582,121 @@
40704         return 0;
40705  }
40706  
40707 -static int de_ethtool_ioctl (struct de_private *de, void *useraddr)
40708 +static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info)
40709  {
40710 -       u32 ethcmd;
40711 +       struct de_private *de = dev->priv;
40712  
40713 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
40714 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
40715 +       strcpy (info->driver, DRV_NAME);
40716 +       strcpy (info->version, DRV_VERSION);
40717 +       strcpy (info->bus_info, pci_name(de->pdev));
40718 +       info->eedump_len = DE_EEPROM_SIZE;
40719 +}
40720  
40721 -       if (get_user(ethcmd, (u32 *)useraddr))
40722 -               return -EFAULT;
40723 -
40724 -       switch (ethcmd) {
40725 -
40726 -       case ETHTOOL_GDRVINFO: {
40727 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
40728 -               strcpy (info.driver, DRV_NAME);
40729 -               strcpy (info.version, DRV_VERSION);
40730 -               strcpy (info.bus_info, pci_name(de->pdev));
40731 -               info.eedump_len = DE_EEPROM_SIZE;
40732 -               info.regdump_len = DE_REGS_SIZE;
40733 -               if (copy_to_user (useraddr, &info, sizeof (info)))
40734 -                       return -EFAULT;
40735 -               return 0;
40736 -       }
40737 -
40738 -       /* get settings */
40739 -       case ETHTOOL_GSET: {
40740 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
40741 -               spin_lock_irq(&de->lock);
40742 -               de_ethtool_gset(de, &ecmd);
40743 -               spin_unlock_irq(&de->lock);
40744 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
40745 -                       return -EFAULT;
40746 -               return 0;
40747 -       }
40748 -       /* set settings */
40749 -       case ETHTOOL_SSET: {
40750 -               struct ethtool_cmd ecmd;
40751 -               int r;
40752 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
40753 -                       return -EFAULT;
40754 -               spin_lock_irq(&de->lock);
40755 -               r = de_ethtool_sset(de, &ecmd);
40756 -               spin_unlock_irq(&de->lock);
40757 -               return r;
40758 -       }
40759 +static int de_get_regs_len(struct net_device *dev)
40760 +{
40761 +       return DE_REGS_SIZE;
40762 +}
40763  
40764 -       /* restart autonegotiation */
40765 -       case ETHTOOL_NWAY_RST: {
40766 -               u32 status;
40767 +static int de_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
40768 +{
40769 +       struct de_private *de = dev->priv;
40770 +       int rc;
40771  
40772 -               if (de->media_type != DE_MEDIA_TP_AUTO)
40773 -                       return -EINVAL;
40774 -               if (netif_carrier_ok(de->dev))
40775 -                       de_link_down(de);
40776 +       spin_lock_irq(&de->lock);
40777 +       rc = __de_get_settings(de, ecmd);
40778 +       spin_unlock_irq(&de->lock);
40779  
40780 -               status = dr32(SIAStatus);
40781 -               dw32(SIAStatus, (status & ~NWayState) | NWayRestart);
40782 -               if (netif_msg_link(de))
40783 -                       printk(KERN_INFO "%s: link nway restart, status %x,%x\n",
40784 -                              de->dev->name, status, dr32(SIAStatus));
40785 -               return 0;
40786 -       }
40787 -
40788 -       /* get link status */
40789 -       case ETHTOOL_GLINK: {
40790 -               struct ethtool_value edata = {ETHTOOL_GLINK};
40791 -               edata.data = (netif_carrier_ok(de->dev)) ? 1 : 0;
40792 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
40793 -                       return -EFAULT;
40794 -               return 0;
40795 -       }
40796 -
40797 -       /* get message-level */
40798 -       case ETHTOOL_GMSGLVL: {
40799 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
40800 -               edata.data = de->msg_enable;
40801 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
40802 -                       return -EFAULT;
40803 -               return 0;
40804 -       }
40805 -       /* set message-level */
40806 -       case ETHTOOL_SMSGLVL: {
40807 -               struct ethtool_value edata;
40808 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
40809 -                       return -EFAULT;
40810 -               de->msg_enable = edata.data;
40811 -               return 0;
40812 -       }
40813 -
40814 -       /* get registers */
40815 -       case ETHTOOL_GREGS: {
40816 -               struct ethtool_regs regs;
40817 -               u8 regbuf[DE_REGS_SIZE];
40818 -               int r;
40819 +       return rc;
40820 +}
40821  
40822 -               if (copy_from_user(&regs, useraddr, sizeof(regs)))
40823 -                       return -EFAULT;
40824 -               
40825 -               if (regs.len > DE_REGS_SIZE) {
40826 -                       regs.len = DE_REGS_SIZE;
40827 -               }
40828 -               regs.version = (DE_REGS_VER << 2) | de->de21040;
40829 -               if (copy_to_user(useraddr, &regs, sizeof(regs)))
40830 -                       return -EFAULT;
40831 +static int de_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
40832 +{
40833 +       struct de_private *de = dev->priv;
40834 +       int rc;
40835  
40836 -               useraddr += offsetof(struct ethtool_regs, data);
40837 +       spin_lock_irq(&de->lock);
40838 +       rc = __de_set_settings(de, ecmd);
40839 +       spin_unlock_irq(&de->lock);
40840  
40841 -               spin_lock_irq(&de->lock);
40842 -               r = de_get_regs(de, regbuf);
40843 -               spin_unlock_irq(&de->lock);
40844 +       return rc;
40845 +}
40846  
40847 -               if (r)
40848 -                       return r;
40849 -               if (copy_to_user(useraddr, regbuf, regs.len))
40850 -                       return -EFAULT;
40851 -               return 0;
40852 -       }
40853 +static u32 de_get_msglevel(struct net_device *dev)
40854 +{
40855 +       struct de_private *de = dev->priv;
40856  
40857 -       /* get SROM dump */
40858 -       case ETHTOOL_GEEPROM: {
40859 -               struct ethtool_eeprom eeprom;
40860 +       return de->msg_enable;
40861 +}
40862  
40863 -               if (!de->ee_data)
40864 -                       break;
40865 -               if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
40866 -                       return -EFAULT;
40867 -               if ((eeprom.offset != 0) || (eeprom.magic != 0) ||
40868 -                   (eeprom.len != DE_EEPROM_SIZE))
40869 -                       return -EINVAL;
40870 +static void de_set_msglevel(struct net_device *dev, u32 msglvl)
40871 +{
40872 +       struct de_private *de = dev->priv;
40873  
40874 -               useraddr += offsetof(struct ethtool_regs, data);
40875 -               if (copy_to_user(useraddr, de->ee_data, DE_EEPROM_SIZE))
40876 -                       return -EFAULT;
40877 -       }
40878 +       de->msg_enable = msglvl;
40879 +}
40880  
40881 -       default:
40882 -               break;
40883 -       }
40884 +static int de_get_eeprom(struct net_device *dev,
40885 +                        struct ethtool_eeprom *eeprom, u8 *data)
40886 +{
40887 +       struct de_private *de = dev->priv;
40888  
40889 -       return -EOPNOTSUPP;
40890 -}
40891 +       if (!de->ee_data)
40892 +               return -EOPNOTSUPP;
40893 +       if ((eeprom->offset != 0) || (eeprom->magic != 0) ||
40894 +           (eeprom->len != DE_EEPROM_SIZE))
40895 +               return -EINVAL;
40896 +       memcpy(data, de->ee_data, eeprom->len);
40897  
40898 +       return 0;
40899 +}
40900  
40901 -static int de_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
40902 +static int de_nway_reset(struct net_device *dev)
40903  {
40904         struct de_private *de = dev->priv;
40905 -       int rc = 0;
40906 +       u32 status;
40907  
40908 -       if (!netif_running(dev))
40909 +       if (de->media_type != DE_MEDIA_TP_AUTO)
40910                 return -EINVAL;
40911 -               
40912 -       switch (cmd) {
40913 -       case SIOCETHTOOL:
40914 -               return de_ethtool_ioctl(de, (void *) rq->ifr_data);
40915 +       if (netif_carrier_ok(de->dev))
40916 +               de_link_down(de);
40917  
40918 -       default:
40919 -               rc = -EOPNOTSUPP;
40920 -               break;
40921 -       }
40922 +       status = dr32(SIAStatus);
40923 +       dw32(SIAStatus, (status & ~NWayState) | NWayRestart);
40924 +       if (netif_msg_link(de))
40925 +               printk(KERN_INFO "%s: link nway restart, status %x,%x\n",
40926 +                      de->dev->name, status, dr32(SIAStatus));
40927 +       return 0;
40928 +}
40929  
40930 -       return rc;
40931 +static void de_get_regs(struct net_device *dev, struct ethtool_regs *regs,
40932 +                       void *data)
40933 +{
40934 +       struct de_private *de = dev->priv;
40935 +
40936 +       if (regs->len > DE_REGS_SIZE)
40937 +               regs->len = DE_REGS_SIZE;
40938 +       regs->version = (DE_REGS_VER << 2) | de->de21040;
40939 +
40940 +       spin_lock_irq(&de->lock);
40941 +       __de_get_regs(de, data);
40942 +       spin_unlock_irq(&de->lock);
40943  }
40944  
40945 +static struct ethtool_ops de_ethtool_ops = {
40946 +       .get_link               = ethtool_op_get_link,
40947 +       .get_tx_csum            = ethtool_op_get_tx_csum,
40948 +       .get_sg                 = ethtool_op_get_sg,
40949 +       .get_drvinfo            = de_get_drvinfo,
40950 +       .get_regs_len           = de_get_regs_len,
40951 +       .get_settings           = de_get_settings,
40952 +       .set_settings           = de_set_settings,
40953 +       .get_msglevel           = de_get_msglevel,
40954 +       .set_msglevel           = de_set_msglevel,
40955 +       .get_eeprom             = de_get_eeprom,
40956 +       .nway_reset             = de_nway_reset,
40957 +       .get_regs               = de_get_regs,
40958 +};
40959 +
40960  static void __init de21040_get_mac_address (struct de_private *de)
40961  {
40962         unsigned i;
40963 @@ -2011,7 +1961,7 @@
40964         dev->set_multicast_list = de_set_rx_mode;
40965         dev->hard_start_xmit = de_start_xmit;
40966         dev->get_stats = de_get_stats;
40967 -       dev->do_ioctl = de_ioctl;
40968 +       dev->ethtool_ops = &de_ethtool_ops;
40969         dev->tx_timeout = de_tx_timeout;
40970         dev->watchdog_timeo = TX_TIMEOUT;
40971  
40972 diff -Nru a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
40973 --- a/drivers/net/tulip/dmfe.c  Tue Aug 19 20:53:17 2003
40974 +++ b/drivers/net/tulip/dmfe.c  Tue Aug 26 13:42:22 2003
40975 @@ -296,7 +296,7 @@
40976  static int dmfe_stop(struct DEVICE *);
40977  static struct net_device_stats * dmfe_get_stats(struct DEVICE *);
40978  static void dmfe_set_filter_mode(struct DEVICE *);
40979 -static int dmfe_do_ioctl(struct DEVICE *, struct ifreq *, int);
40980 +static struct ethtool_ops netdev_ethtool_ops;
40981  static u16 read_srom_word(long ,int);
40982  static irqreturn_t dmfe_interrupt(int , void *, struct pt_regs *);
40983  static void dmfe_descriptor_init(struct dmfe_board_info *, unsigned long);
40984 @@ -417,7 +417,7 @@
40985         dev->stop = &dmfe_stop;
40986         dev->get_stats = &dmfe_get_stats;
40987         dev->set_multicast_list = &dmfe_set_filter_mode;
40988 -       dev->do_ioctl = &dmfe_do_ioctl;
40989 +       dev->ethtool_ops = &netdev_ethtool_ops;
40990         spin_lock_init(&db->lock);
40991  
40992         pci_read_config_dword(pdev, 0x50, &pci_pmr);
40993 @@ -1000,55 +1000,23 @@
40994         spin_unlock_irqrestore(&db->lock, flags);
40995  }
40996  
40997 -
40998 -/*
40999 - *     Process the ethtool ioctl command
41000 - */
41001 -
41002 -static int dmfe_ethtool_ioctl(struct net_device *dev, void *useraddr)
41003 +static void netdev_get_drvinfo(struct net_device *dev,
41004 +                              struct ethtool_drvinfo *info)
41005  {
41006 -       struct dmfe_board_info *db = dev->priv;
41007 -       struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
41008 -       u32 ethcmd;
41009 -
41010 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
41011 -               return -EFAULT;
41012 -
41013 -        switch (ethcmd) {
41014 -        case ETHTOOL_GDRVINFO:
41015 -               strcpy(info.driver, DRV_NAME);
41016 -               strcpy(info.version, DRV_VERSION);
41017 -               if (db->pdev)
41018 -                       strcpy(info.bus_info, pci_name(db->pdev));
41019 -               else
41020 -                       sprintf(info.bus_info, "EISA 0x%lx %d",
41021 -                               dev->base_addr, dev->irq);
41022 -               if (copy_to_user(useraddr, &info, sizeof(info)))
41023 -                       return -EFAULT;
41024 -               return 0;
41025 -        }
41026 -
41027 -       return -EOPNOTSUPP;
41028 -}
41029 +       struct dmfe_board_info *np = dev->priv;
41030  
41031 -
41032 -/*
41033 - *     Process the upper socket ioctl command
41034 - */
41035 -
41036 -static int dmfe_do_ioctl(struct DEVICE *dev, struct ifreq *ifr, int cmd)
41037 -{
41038 -       int retval = -EOPNOTSUPP;
41039 -       DMFE_DBUG(0, "dmfe_do_ioctl()", 0);
41040 -
41041 -       switch(cmd) {
41042 -       case SIOCETHTOOL:
41043 -               return dmfe_ethtool_ioctl(dev, (void*)ifr->ifr_data);
41044 -       }
41045 -
41046 -       return retval;
41047 +       strcpy(info->driver, DRV_NAME);
41048 +       strcpy(info->version, DRV_VERSION);
41049 +       if (np->pdev)
41050 +               strcpy(info->bus_info, pci_name(np->pdev));
41051 +       else
41052 +               sprintf(info->bus_info, "EISA 0x%lx %d",
41053 +                       dev->base_addr, dev->irq);
41054  }
41055  
41056 +static struct ethtool_ops netdev_ethtool_ops = {
41057 +       .get_drvinfo            = netdev_get_drvinfo,
41058 +};
41059  
41060  /*
41061   *     A periodic timer routine
41062 diff -Nru a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
41063 --- a/drivers/net/tulip/winbond-840.c   Tue Aug 19 20:53:17 2003
41064 +++ b/drivers/net/tulip/winbond-840.c   Mon Sep  1 14:05:11 2003
41065 @@ -392,6 +392,7 @@
41066  static void set_rx_mode(struct net_device *dev);
41067  static struct net_device_stats *get_stats(struct net_device *dev);
41068  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
41069 +static struct ethtool_ops netdev_ethtool_ops;
41070  static int  netdev_close(struct net_device *dev);
41071  
41072  \f
41073 @@ -482,6 +483,7 @@
41074         dev->get_stats = &get_stats;
41075         dev->set_multicast_list = &set_rx_mode;
41076         dev->do_ioctl = &netdev_ioctl;
41077 +       dev->ethtool_ops = &netdev_ethtool_ops;
41078         dev->tx_timeout = &tx_timeout;
41079         dev->watchdog_timeo = TX_TIMEOUT;
41080  
41081 @@ -1452,88 +1454,79 @@
41082         spin_unlock_irq(&np->lock);
41083  }
41084  
41085 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
41086 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
41087  {
41088         struct netdev_private *np = dev->priv;
41089 -       u32 ethcmd;
41090 -               
41091 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
41092 -               return -EFAULT;
41093 -
41094 -        switch (ethcmd) {
41095 -        case ETHTOOL_GDRVINFO: {
41096 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
41097 -               strcpy(info.driver, DRV_NAME);
41098 -               strcpy(info.version, DRV_VERSION);
41099 -               strcpy(info.bus_info, pci_name(np->pci_dev));
41100 -               if (copy_to_user(useraddr, &info, sizeof(info)))
41101 -                       return -EFAULT;
41102 -               return 0;
41103 -       }
41104 -
41105 -       /* get settings */
41106 -       case ETHTOOL_GSET: {
41107 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
41108 -               spin_lock_irq(&np->lock);
41109 -               mii_ethtool_gset(&np->mii_if, &ecmd);
41110 -               spin_unlock_irq(&np->lock);
41111 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
41112 -                       return -EFAULT;
41113 -               return 0;
41114 -       }
41115 -       /* set settings */
41116 -       case ETHTOOL_SSET: {
41117 -               int r;
41118 -               struct ethtool_cmd ecmd;
41119 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
41120 -                       return -EFAULT;
41121 -               spin_lock_irq(&np->lock);
41122 -               r = mii_ethtool_sset(&np->mii_if, &ecmd);
41123 -               spin_unlock_irq(&np->lock);
41124 -               return r;
41125 -       }
41126 -       /* restart autonegotiation */
41127 -       case ETHTOOL_NWAY_RST: {
41128 -               return mii_nway_restart(&np->mii_if);
41129 -       }
41130 -       /* get link status */
41131 -       case ETHTOOL_GLINK: {
41132 -               struct ethtool_value edata = {ETHTOOL_GLINK};
41133 -               edata.data = mii_link_ok(&np->mii_if);
41134 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
41135 -                       return -EFAULT;
41136 -               return 0;
41137 -       }
41138 -
41139 -       /* get message-level */
41140 -       case ETHTOOL_GMSGLVL: {
41141 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
41142 -               edata.data = debug;
41143 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
41144 -                       return -EFAULT;
41145 -               return 0;
41146 -       }
41147 -       /* set message-level */
41148 -       case ETHTOOL_SMSGLVL: {
41149 -               struct ethtool_value edata;
41150 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
41151 -                       return -EFAULT;
41152 -               debug = edata.data;
41153 -               return 0;
41154 -       }
41155 -        }
41156 -       
41157 -       return -EOPNOTSUPP;
41158 +
41159 +       strcpy (info->driver, DRV_NAME);
41160 +       strcpy (info->version, DRV_VERSION);
41161 +       strcpy (info->bus_info, pci_name(np->pci_dev));
41162 +}
41163 +
41164 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
41165 +{
41166 +       struct netdev_private *np = dev->priv;
41167 +       int rc;
41168 +
41169 +       spin_lock_irq(&np->lock);
41170 +       rc = mii_ethtool_gset(&np->mii_if, cmd);
41171 +       spin_unlock_irq(&np->lock);
41172 +
41173 +       return rc;
41174  }
41175  
41176 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
41177 +{
41178 +       struct netdev_private *np = dev->priv;
41179 +       int rc;
41180 +
41181 +       spin_lock_irq(&np->lock);
41182 +       rc = mii_ethtool_sset(&np->mii_if, cmd);
41183 +       spin_unlock_irq(&np->lock);
41184 +
41185 +       return rc;
41186 +}
41187 +
41188 +static int netdev_nway_reset(struct net_device *dev)
41189 +{
41190 +       struct netdev_private *np = dev->priv;
41191 +       return mii_nway_restart(&np->mii_if);
41192 +}
41193 +
41194 +static u32 netdev_get_link(struct net_device *dev)
41195 +{
41196 +       struct netdev_private *np = dev->priv;
41197 +       return mii_link_ok(&np->mii_if);
41198 +}
41199 +
41200 +static u32 netdev_get_msglevel(struct net_device *dev)
41201 +{
41202 +       return debug;
41203 +}
41204 +
41205 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
41206 +{
41207 +       debug = value;
41208 +}
41209 +
41210 +static struct ethtool_ops netdev_ethtool_ops = {
41211 +       .get_drvinfo            = netdev_get_drvinfo,
41212 +       .get_settings           = netdev_get_settings,
41213 +       .set_settings           = netdev_set_settings,
41214 +       .nway_reset             = netdev_nway_reset,
41215 +       .get_link               = netdev_get_link,
41216 +       .get_msglevel           = netdev_get_msglevel,
41217 +       .set_msglevel           = netdev_set_msglevel,
41218 +       .get_sg                 = ethtool_op_get_sg,
41219 +       .get_tx_csum            = ethtool_op_get_tx_csum,
41220 +};
41221 +
41222  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
41223  {
41224         struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
41225         struct netdev_private *np = dev->priv;
41226  
41227         switch(cmd) {
41228 -       case SIOCETHTOOL:
41229 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
41230         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
41231                 data->phy_id = ((struct netdev_private *)dev->priv)->phys[0] & 0x1f;
41232                 /* Fall Through */
41233 diff -Nru a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
41234 --- a/drivers/net/tulip/xircom_cb.c     Tue Aug 19 20:53:17 2003
41235 +++ b/drivers/net/tulip/xircom_cb.c     Tue Aug 26 14:52:05 2003
41236 @@ -175,37 +175,19 @@
41237  }
41238  #endif
41239  
41240 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
41241 +static void netdev_get_drvinfo(struct net_device *dev,
41242 +                              struct ethtool_drvinfo *info)
41243  {
41244 -       u32 ethcmd;
41245 -               
41246 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
41247 -               return -EFAULT;
41248 -       
41249 -       switch (ethcmd) {
41250 -       case ETHTOOL_GDRVINFO: {
41251 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
41252 -               strncpy(info.driver, "xircom_cb", sizeof(info.driver)-1);
41253 -               if (copy_to_user(useraddr, &info, sizeof(info)))
41254 -                       return -EFAULT;
41255 -               return 0;
41256 -       }
41257 -       }
41258 -       
41259 -       return -EOPNOTSUPP;
41260 -}
41261 +       struct xircom_private *private = dev->priv;
41262  
41263 -static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
41264 -{
41265 -
41266 -       switch(cmd) {
41267 -       case SIOCETHTOOL:
41268 -              return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
41269 -       default:
41270 -               return -EOPNOTSUPP;
41271 -       }
41272 +       strcpy(info->driver, "xircom_cb");
41273 +       strcpy(info->bus_info, pci_name(private->pdev));
41274  }
41275  
41276 +static struct ethtool_ops netdev_ethtool_ops = {
41277 +       .get_drvinfo            = netdev_get_drvinfo,
41278 +};
41279 +
41280  /* xircom_probe is the code that gets called on device insertion.
41281     it sets up the hardware and registers the device to the networklayer.
41282     
41283 @@ -287,7 +269,7 @@
41284         dev->stop = &xircom_close;
41285         dev->get_stats = &xircom_get_stats;
41286         dev->priv = private;
41287 -       dev->do_ioctl = &private_ioctl;
41288 +       SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
41289         pci_set_drvdata(pdev, dev);
41290  
41291         
41292 diff -Nru a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
41293 --- a/drivers/net/via-rhine.c   Tue Aug 19 20:53:17 2003
41294 +++ b/drivers/net/via-rhine.c   Mon Sep  1 14:05:11 2003
41295 @@ -547,6 +547,7 @@
41296  static void via_rhine_set_rx_mode(struct net_device *dev);
41297  static struct net_device_stats *via_rhine_get_stats(struct net_device *dev);
41298  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
41299 +static struct ethtool_ops netdev_ethtool_ops;
41300  static int  via_rhine_close(struct net_device *dev);
41301  
41302  static inline u32 get_intr_status(struct net_device *dev)
41303 @@ -780,6 +781,7 @@
41304         dev->get_stats = via_rhine_get_stats;
41305         dev->set_multicast_list = via_rhine_set_rx_mode;
41306         dev->do_ioctl = netdev_ioctl;
41307 +       dev->ethtool_ops = &netdev_ethtool_ops;
41308         dev->tx_timeout = via_rhine_tx_timeout;
41309         dev->watchdog_timeo = TX_TIMEOUT;
41310         if (np->drv_flags & ReqTxAlign)
41311 @@ -1741,90 +1743,87 @@
41312         writeb(np->rx_thresh | rx_mode, ioaddr + RxConfig);
41313  }
41314  
41315 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
41316 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
41317  {
41318         struct netdev_private *np = dev->priv;
41319 -       u32 ethcmd;
41320  
41321 -       if (get_user(ethcmd, (u32 *)useraddr))
41322 -               return -EFAULT;
41323 +       strcpy (info->driver, DRV_NAME);
41324 +       strcpy (info->version, DRV_VERSION);
41325 +       strcpy (info->bus_info, pci_name(np->pdev));
41326 +}
41327  
41328 -       switch (ethcmd) {
41329 -       case ETHTOOL_GDRVINFO: {
41330 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
41331 -               strcpy (info.driver, DRV_NAME);
41332 -               strcpy (info.version, DRV_VERSION);
41333 -               strcpy (info.bus_info, pci_name(np->pdev));
41334 -               if (copy_to_user (useraddr, &info, sizeof (info)))
41335 -                       return -EFAULT;
41336 -               return 0;
41337 -       }
41338 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
41339 +{
41340 +       struct netdev_private *np = dev->priv;
41341 +       int rc;
41342  
41343 -       /* get settings */
41344 -       case ETHTOOL_GSET: {
41345 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
41346 -               if (!(np->drv_flags & CanHaveMII))
41347 -                       break;
41348 -               spin_lock_irq(&np->lock);
41349 -               mii_ethtool_gset(&np->mii_if, &ecmd);
41350 -               spin_unlock_irq(&np->lock);
41351 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
41352 -                       return -EFAULT;
41353 -               return 0;
41354 -       }
41355 -       /* set settings */
41356 -       case ETHTOOL_SSET: {
41357 -               int r;
41358 -               struct ethtool_cmd ecmd;
41359 -               if (!(np->drv_flags & CanHaveMII))
41360 -                       break;
41361 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
41362 -                       return -EFAULT;
41363 -               spin_lock_irq(&np->lock);
41364 -               r = mii_ethtool_sset(&np->mii_if, &ecmd);
41365 -               spin_unlock_irq(&np->lock);
41366 -               return r;
41367 -       }
41368 -       /* restart autonegotiation */
41369 -       case ETHTOOL_NWAY_RST: {
41370 -               if (!(np->drv_flags & CanHaveMII))
41371 -                       break;
41372 -               return mii_nway_restart(&np->mii_if);
41373 -       }
41374 -       /* get link status */
41375 -       case ETHTOOL_GLINK: {
41376 -               struct ethtool_value edata = {ETHTOOL_GLINK};
41377 -               if (!(np->drv_flags & CanHaveMII))
41378 -                       break;
41379 -               edata.data = mii_link_ok(&np->mii_if);
41380 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
41381 -                       return -EFAULT;
41382 -               return 0;
41383 -       }
41384 -
41385 -       /* get message-level */
41386 -       case ETHTOOL_GMSGLVL: {
41387 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
41388 -               edata.data = debug;
41389 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
41390 -                       return -EFAULT;
41391 -               return 0;
41392 -       }
41393 -       /* set message-level */
41394 -       case ETHTOOL_SMSGLVL: {
41395 -               struct ethtool_value edata;
41396 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
41397 -                       return -EFAULT;
41398 -               debug = edata.data;
41399 -               return 0;
41400 -       }
41401 -       default:
41402 -               break;
41403 -       }
41404 +       if (!(np->drv_flags & CanHaveMII))
41405 +               return -EINVAL;
41406 +
41407 +       spin_lock_irq(&np->lock);
41408 +       rc = mii_ethtool_gset(&np->mii_if, cmd);
41409 +       spin_unlock_irq(&np->lock);
41410 +
41411 +       return rc;
41412 +}
41413 +
41414 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
41415 +{
41416 +       struct netdev_private *np = dev->priv;
41417 +       int rc;
41418 +
41419 +       if (!(np->drv_flags & CanHaveMII))
41420 +               return -EINVAL;
41421 +
41422 +       spin_lock_irq(&np->lock);
41423 +       rc = mii_ethtool_sset(&np->mii_if, cmd);
41424 +       spin_unlock_irq(&np->lock);
41425  
41426 -       return -EOPNOTSUPP;
41427 +       return rc;
41428  }
41429  
41430 +static int netdev_nway_reset(struct net_device *dev)
41431 +{
41432 +       struct netdev_private *np = dev->priv;
41433 +
41434 +       if (!(np->drv_flags & CanHaveMII))
41435 +               return -EINVAL;
41436 +
41437 +       return mii_nway_restart(&np->mii_if);
41438 +}
41439 +
41440 +static u32 netdev_get_link(struct net_device *dev)
41441 +{
41442 +       struct netdev_private *np = dev->priv;
41443 +
41444 +       if (!(np->drv_flags & CanHaveMII))
41445 +               return 0;       /* -EINVAL */
41446 +
41447 +       return mii_link_ok(&np->mii_if);
41448 +}
41449 +
41450 +static u32 netdev_get_msglevel(struct net_device *dev)
41451 +{
41452 +       return debug;
41453 +}
41454 +
41455 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
41456 +{
41457 +       debug = value;
41458 +}
41459 +
41460 +static struct ethtool_ops netdev_ethtool_ops = {
41461 +       .get_drvinfo            = netdev_get_drvinfo,
41462 +       .get_settings           = netdev_get_settings,
41463 +       .set_settings           = netdev_set_settings,
41464 +       .nway_reset             = netdev_nway_reset,
41465 +       .get_link               = netdev_get_link,
41466 +       .get_msglevel           = netdev_get_msglevel,
41467 +       .set_msglevel           = netdev_set_msglevel,
41468 +       .get_sg                 = ethtool_op_get_sg,
41469 +       .get_tx_csum            = ethtool_op_get_tx_csum,
41470 +};
41471 +
41472  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
41473  {
41474         struct netdev_private *np = dev->priv;
41475 @@ -1834,14 +1833,9 @@
41476         if (!netif_running(dev))
41477                 return -EINVAL;
41478  
41479 -       if (cmd == SIOCETHTOOL)
41480 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
41481 -
41482 -       else {
41483 -               spin_lock_irq(&np->lock);
41484 -               rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL);
41485 -               spin_unlock_irq(&np->lock);
41486 -       }
41487 +       spin_lock_irq(&np->lock);
41488 +       rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL);
41489 +       spin_unlock_irq(&np->lock);
41490  
41491         return rc;
41492  }
41493 diff -Nru a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
41494 --- a/drivers/net/wan/Kconfig   Wed Aug 20 22:31:57 2003
41495 +++ b/drivers/net/wan/Kconfig   Tue Sep  2 08:24:53 2003
41496 @@ -35,7 +35,7 @@
41497  # The COSA/SRP driver has not been tested as non-modular yet.
41498  config COSA
41499         tristate "COSA/SRP sync serial boards support"
41500 -       depends on WAN && ISA && m
41501 +       depends on WAN && ISA && m && BROKEN
41502         ---help---
41503           This is a driver for COSA and SRP synchronous serial boards. These
41504           boards allow to connect synchronous serial devices (for example
41505 @@ -63,7 +63,7 @@
41506  # Not updated to 2.6.
41507  config COMX
41508         tristate "MultiGate (COMX) synchronous serial boards support"
41509 -       depends on WAN && (ISA || PCI) && OBSOLETE
41510 +       depends on WAN && (ISA || PCI) && BROKEN
41511         ---help---
41512           Say Y if you want to use any board from the MultiGate (COMX) family.
41513           These boards are synchronous serial adapters for the PC,
41514 @@ -465,7 +465,7 @@
41515  
41516  config SDLA
41517         tristate "SDLA (Sangoma S502/S508) support"
41518 -       depends on DLCI && ISA
41519 +       depends on DLCI && ISA && BROKEN_ON_SMP
41520         help
41521           Say Y here if you need a driver for the Sangoma S502A, S502E, and
41522           S508 Frame Relay Access Devices. These are multi-protocol cards, but
41523 @@ -498,7 +498,7 @@
41524  
41525  config VENDOR_SANGOMA
41526         tristate "Sangoma WANPIPE(tm) multiprotocol cards"
41527 -       depends on WAN_ROUTER_DRIVERS && WAN_ROUTER && (PCI || ISA)
41528 +       depends on WAN_ROUTER_DRIVERS && WAN_ROUTER && (PCI || ISA) && BROKEN
41529         ---help---
41530           WANPIPE from Sangoma Technologies Inc. (<http://www.sangoma.com/>)
41531           is a family of intelligent multiprotocol WAN adapters with data
41532 diff -Nru a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
41533 --- a/drivers/net/wan/cosa.c    Tue Aug 19 21:00:03 2003
41534 +++ b/drivers/net/wan/cosa.c    Fri Aug 29 22:32:28 2003
41535 @@ -632,7 +632,7 @@
41536  {
41537         sppp_detach(chan->pppdev.dev);
41538         unregister_netdev(chan->pppdev.dev);
41539 -       free_netdev(chan->ppp.dev);
41540 +       free_netdev(chan->pppdev.dev);
41541  }
41542  
41543  static int cosa_sppp_open(struct net_device *d)
41544 @@ -961,12 +961,12 @@
41545         unsigned long flags;
41546         int n;
41547  
41548 -       if ((n=minor(file->f_dentry->d_inode->i_rdev)>>CARD_MINOR_BITS)
41549 +       if ((n=iminor(file->f_dentry->d_inode)>>CARD_MINOR_BITS)
41550                 >= nr_cards)
41551                 return -ENODEV;
41552         cosa = cosa_cards+n;
41553  
41554 -       if ((n=minor(file->f_dentry->d_inode->i_rdev)
41555 +       if ((n=iminor(file->f_dentry->d_inode)
41556                 & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels)
41557                 return -ENODEV;
41558         chan = cosa->chan + n;
41559 @@ -1009,7 +1009,7 @@
41560  /* To be done ... */
41561  static int cosa_fasync(struct inode *inode, struct file *file, int on)
41562  {
41563 -        int port = MINOR(inode->i_rdev);
41564 +        int port = iminor(inode);
41565          int rv = fasync_helper(inode, file, on, &fasync[port]);
41566          return rv < 0 ? rv : 0;
41567  }
41568 diff -Nru a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c
41569 --- a/drivers/net/wan/cycx_drv.c        Tue Jul 15 10:01:29 2003
41570 +++ b/drivers/net/wan/cycx_drv.c        Sat Aug 23 20:42:31 2003
41571 @@ -70,12 +70,12 @@
41572  static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len);
41573  static void cycx_bootcfg(struct cycx_hw *hw);
41574  
41575 -static int reset_cyc2x(u32 addr);
41576 -static int detect_cyc2x(u32 addr);
41577 +static int reset_cyc2x(void *addr);
41578 +static int detect_cyc2x(void *addr);
41579  
41580  /* Miscellaneous functions */
41581  static void delay_cycx(int sec);
41582 -static int get_option_index(u32 *optlist, u32 optval);
41583 +static int get_option_index(long *optlist, long optval);
41584  static u16 checksum(u8 *buf, u32 len);
41585  
41586  #define wait_cyc(addr) cycx_exec(addr + CMD_OFFSET)
41587 @@ -92,14 +92,14 @@
41588   * These are arrays of configuration options used by verification routines.
41589   * The first element of each array is its size (i.e. number of options).
41590   */
41591 -static u32 cyc2x_dpmbase_options[] = {
41592 +static long cyc2x_dpmbase_options[] = {
41593         20,
41594         0xA0000, 0xA4000, 0xA8000, 0xAC000, 0xB0000, 0xB4000, 0xB8000,
41595         0xBC000, 0xC0000, 0xC4000, 0xC8000, 0xCC000, 0xD0000, 0xD4000,
41596         0xD8000, 0xDC000, 0xE0000, 0xE4000, 0xE8000, 0xEC000
41597  };
41598  
41599 -static u32 cycx_2x_irq_options[]  = { 7, 3, 5, 9, 10, 11, 12, 15 };
41600 +static long cycx_2x_irq_options[]  = { 7, 3, 5, 9, 10, 11, 12, 15 };
41601  
41602  /* Kernel Loadable Module Entry Points */
41603  /* Module 'insert' entry point.
41604 @@ -137,7 +137,7 @@
41605  EXPORT_SYMBOL(cycx_setup);
41606  int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len)
41607  {
41608 -       unsigned long dpmbase = hw->dpmbase;
41609 +       long dpmbase = (long)hw->dpmbase;
41610         int err;
41611  
41612         /* Verify IRQ configuration options */
41613 @@ -147,17 +147,17 @@
41614         }
41615  
41616         /* Setup adapter dual-port memory window and test memory */
41617 -       if (!hw->dpmbase) {
41618 +       if (!dpmbase) {
41619                 printk(KERN_ERR "%s: you must specify the dpm address!\n",
41620                                 modname);
41621                 return -EINVAL;
41622 -       } else if (!get_option_index(cyc2x_dpmbase_options, hw->dpmbase)) {
41623 +       } else if (!get_option_index(cyc2x_dpmbase_options, dpmbase)) {
41624                 printk(KERN_ERR "%s: memory address 0x%lX is invalid!\n",
41625                                 modname, dpmbase);
41626                 return -EINVAL;
41627         }
41628  
41629 -       hw->dpmbase = (u32)ioremap(dpmbase, CYCX_WINDOWSIZE);
41630 +       hw->dpmbase = ioremap(dpmbase, CYCX_WINDOWSIZE);
41631         hw->dpmsize = CYCX_WINDOWSIZE;
41632  
41633         if (!detect_cyc2x(hw->dpmbase)) {
41634 @@ -181,8 +181,7 @@
41635  EXPORT_SYMBOL(cycx_down);
41636  int cycx_down(struct cycx_hw *hw)
41637  {
41638 -       iounmap((u32 *)hw->dpmbase);
41639 -
41640 +       iounmap(hw->dpmbase);
41641         return 0;
41642  }
41643  
41644 @@ -204,7 +203,7 @@
41645   * o Set exec flag.
41646   * o Busy-wait until flag is reset. */
41647  EXPORT_SYMBOL(cycx_exec);
41648 -int cycx_exec(u32 addr)
41649 +int cycx_exec(void *addr)
41650  {
41651         u16 i = 0;
41652         /* wait till addr content is zeroed */
41653 @@ -250,7 +249,7 @@
41654  /* Load Aux Routines */
41655  /* Reset board hardware.
41656     return 1 if memory exists at addr and 0 if not. */
41657 -static int memory_exists(u32 addr)
41658 +static int memory_exists(void *addr)
41659  {
41660         int tries = 0;
41661  
41662 @@ -268,9 +267,9 @@
41663  }
41664  
41665  /* Load reset code. */
41666 -static void reset_load(u32 addr, u8 *buffer, u32 cnt)
41667 +static void reset_load(void *addr, u8 *buffer, u32 cnt)
41668  {
41669 -       u32 pt_code = addr + RESET_OFFSET;
41670 +       void *pt_code = addr + RESET_OFFSET;
41671         u16 i; /*, j; */
41672  
41673         for (i = 0 ; i < cnt ; i++) {
41674 @@ -282,7 +281,7 @@
41675  /* Load buffer using boot interface.
41676   * o copy data from buffer to Cyclom-X memory
41677   * o wait for reset code to copy it to right portion of memory */
41678 -static int buffer_load(u32 addr, u8 *buffer, u32 cnt)
41679 +static int buffer_load(void *addr, u8 *buffer, u32 cnt)
41680  {
41681         memcpy_toio(addr + DATA_OFFSET, buffer, cnt);
41682         writew(GEN_BOOT_DAT, addr + CMD_OFFSET);
41683 @@ -291,7 +290,7 @@
41684  }
41685  
41686  /* Set up entry point and kick start Cyclom-X CPU. */
41687 -static void cycx_start(u32 addr)
41688 +static void cycx_start(void *addr)
41689  {
41690         /* put in 0x30 offset the jump instruction to the code entry point */
41691         writeb(0xea, addr + 0x30);
41692 @@ -305,9 +304,9 @@
41693  }
41694  
41695  /* Load and boot reset code. */
41696 -static void cycx_reset_boot(u32 addr, u8 *code, u32 len)
41697 +static void cycx_reset_boot(void *addr, u8 *code, u32 len)
41698  {
41699 -       u32 pt_start = addr + START_OFFSET;
41700 +       void *pt_start = addr + START_OFFSET;
41701  
41702         writeb(0xea, pt_start++); /* jmp to f000:3f00 */
41703         writeb(0x00, pt_start++);
41704 @@ -322,9 +321,9 @@
41705  }
41706  
41707  /* Load data.bin file through boot (reset) interface. */
41708 -static int cycx_data_boot(u32 addr, u8 *code, u32 len)
41709 +static int cycx_data_boot(void *addr, u8 *code, u32 len)
41710  {
41711 -       u32 pt_boot_cmd = addr + CMD_OFFSET;
41712 +       void *pt_boot_cmd = addr + CMD_OFFSET;
41713         u32 i;
41714  
41715         /* boot buffer lenght */
41716 @@ -353,9 +352,9 @@
41717  
41718  
41719  /* Load code.bin file through boot (reset) interface. */
41720 -static int cycx_code_boot(u32 addr, u8 *code, u32 len)
41721 +static int cycx_code_boot(void *addr, u8 *code, u32 len)
41722  {
41723 -       u32 pt_boot_cmd = addr + CMD_OFFSET;
41724 +       void *pt_boot_cmd = addr + CMD_OFFSET;
41725         u32 i;
41726  
41727         /* boot buffer lenght */
41728 @@ -392,7 +391,7 @@
41729         u8 *reset_image,
41730            *data_image,
41731            *code_image;
41732 -       u32 pt_cycld = hw->dpmbase + 0x400;
41733 +       void *pt_cycld = hw->dpmbase + 0x400;
41734         u16 cksum;
41735  
41736         /* Announce */
41737 @@ -426,7 +425,7 @@
41738         if (cksum != cfm->checksum) {
41739                 printk(KERN_ERR "%s:%s: firmware corrupted!\n",
41740                                 modname, __FUNCTION__);
41741 -               printk(KERN_ERR " cdsize = 0x%x (expected 0x%lx)\n",
41742 +               printk(KERN_ERR " cdsize = 0x%lx (expected 0x%lx)\n",
41743                                 len - sizeof(struct cycx_firmware) - 1,
41744                                 cfm->info.codesize);
41745                 printk(KERN_ERR " chksum = 0x%x (expected 0x%x)\n",
41746 @@ -435,9 +434,7 @@
41747         }
41748  
41749         /* If everything is ok, set reset, data and code pointers */
41750 -
41751 -       img_hdr = (struct cycx_fw_header *)(((u8 *)cfm) +
41752 -                                           sizeof(struct cycx_firmware) - 1);
41753 +       img_hdr = (struct cycx_fw_header *)&cfm->image;
41754  #ifdef FIRMWARE_DEBUG
41755         printk(KERN_INFO "%s:%s: image sizes\n", __FUNCTION__, modname);
41756         printk(KERN_INFO " reset=%lu\n", img_hdr->reset_size);
41757 @@ -526,7 +523,7 @@
41758   *     Return 1 if detected o.k. or 0 if failed.
41759   *     Note:   This test is destructive! Adapter will be left in shutdown
41760   *             state after the test. */
41761 -static int detect_cyc2x(u32 addr)
41762 +static int detect_cyc2x(void *addr)
41763  {
41764         reset_cyc2x(addr);
41765  
41766 @@ -536,7 +533,7 @@
41767  /* Miscellaneous */
41768  /* Get option's index into the options list.
41769   *     Return option's index (1 .. N) or zero if option is invalid. */
41770 -static int get_option_index(u32 *optlist, u32 optval)
41771 +static int get_option_index(long *optlist, long optval)
41772  {
41773         int i = 1;
41774  
41775 @@ -548,7 +545,7 @@
41776  }
41777  
41778  /* Reset adapter's CPU. */
41779 -static int reset_cyc2x(u32 addr)
41780 +static int reset_cyc2x(void *addr)
41781  {
41782         writeb(0, addr + RST_ENABLE);
41783         delay_cycx(2);
41784 diff -Nru a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c
41785 --- a/drivers/net/wan/cycx_main.c       Tue May 20 07:19:38 2003
41786 +++ b/drivers/net/wan/cycx_main.c       Sat Aug 23 20:36:33 2003
41787 @@ -223,7 +223,7 @@
41788         /* Configure hardware, load firmware, etc. */
41789         memset(&card->hw, 0, sizeof(card->hw));
41790         card->hw.irq     = irq;
41791 -       card->hw.dpmbase = conf->maddr;
41792 +       card->hw.dpmbase = (void *)conf->maddr;
41793         card->hw.dpmsize = CYCX_WINDOWSIZE;
41794         card->hw.fwid    = CFID_X25_2X;
41795         card->lock       = SPIN_LOCK_UNLOCKED;
41796 @@ -236,7 +236,7 @@
41797         /* Initialize WAN device data space */
41798         wandev->irq       = irq;
41799         wandev->dma       = wandev->ioport = 0;
41800 -       wandev->maddr     = card->hw.dpmbase;
41801 +       wandev->maddr     = (unsigned long)card->hw.dpmbase;
41802         wandev->msize     = card->hw.dpmsize;
41803         wandev->hw_opt[2] = 0;
41804         wandev->hw_opt[3] = card->hw.fwid;
41805 diff -Nru a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
41806 --- a/drivers/net/wireless/airo.c       Tue Aug 19 20:13:55 2003
41807 +++ b/drivers/net/wireless/airo.c       Sun Aug 31 16:14:06 2003
41808 @@ -81,12 +81,12 @@
41809  #endif
41810  
41811  /* Support Cisco MIC feature */
41812 -/* As this feature requires the AES encryption algorithm, it is not included
41813 -   in the kernel tree. If you want to enable it, you need to download the
41814 -   aes.h, aestab.h and mic.h files from the CVS at
41815 -   http://sf.net/projects/airo-linux/ Put the files in the same directory
41816 -   as airo.c and compile normally */
41817 +#define MICSUPPORT
41818 +
41819 +#if defined(MICSUPPORT) && !defined(CONFIG_CRYPTO)
41820 +#warning MIC support requires Crypto API
41821  #undef MICSUPPORT
41822 +#endif
41823  
41824  /* Hack to do some power saving */
41825  #define POWER_ON_DOWN
41826 @@ -615,14 +615,14 @@
41827         u16 arlDelay;
41828         u16 _reserved4[1];
41829         /*---------- Aironet Extensions ----------*/
41830 -       u16 magicAction;
41831 +       u8 magicAction;
41832  #define MAGIC_ACTION_STSCHG 1
41833  #define MACIC_ACTION_RESUME 2
41834  #define MAGIC_IGNORE_MCAST (1<<8)
41835  #define MAGIC_IGNORE_BCAST (1<<9)
41836  #define MAGIC_SWITCH_TO_PSP (0<<10)
41837  #define MAGIC_STAY_IN_CAM (1<<10)
41838 -       u16 magicControl;
41839 +       u8 magicControl;
41840         u16 autoWake;
41841  } ConfigRid;
41842  
41843 @@ -843,6 +843,7 @@
41844  #define AIROGMICRID            11
41845  #define AIROGMICSTATS          12
41846  #define AIROGFLAGS             13
41847 +#define AIRORRID               15
41848  
41849  /* Leave gap of 40 commands after AIROGSTATSD32 for future */
41850  
41851 @@ -994,6 +995,8 @@
41852  static int micsetup(struct airo_info *ai);
41853  static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len);
41854  static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen);
41855 +
41856 +#include <linux/crypto.h>
41857  #endif
41858  
41859  struct airo_info {
41860 @@ -1063,9 +1066,12 @@
41861  #endif /* WIRELESS_SPY */
41862  #endif /* WIRELESS_EXT > 15 */
41863  #endif /* WIRELESS_EXT */
41864 +#ifdef MICSUPPORT
41865         /* MIC stuff */
41866 +       struct crypto_tfm       *tfm;
41867         mic_module              mod[2];
41868         mic_statistics          micstats;
41869 +#endif
41870  };
41871  
41872  static inline int bap_read(struct airo_info *ai, u16 *pu16Dst, int bytelen,
41873 @@ -1079,7 +1085,462 @@
41874                                 struct airo_info *apriv );
41875  
41876  #ifdef MICSUPPORT
41877 -#include "mic.h"
41878 +/***********************************************************************
41879 + *                              MIC ROUTINES                           *
41880 + ***********************************************************************
41881 + */
41882 +
41883 +static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq);
41884 +static void MoveWindow(miccntx *context, u32 micSeq);
41885 +void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *);
41886 +void emmh32_init(emmh32_context *context);
41887 +void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
41888 +void emmh32_final(emmh32_context *context, u8 digest[4]);
41889 +
41890 +/* micinit - Initialize mic seed */
41891 +
41892 +static void micinit(struct airo_info *ai)
41893 +{
41894 +       MICRid mic_rid;
41895 +
41896 +       clear_bit(JOB_MIC, &ai->flags);
41897 +       PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0);
41898 +       up(&ai->sem);
41899 +
41900 +       ai->micstats.enabled = (mic_rid.state & 0x00FF) ? 1 : 0;
41901 +
41902 +       if (ai->micstats.enabled) {
41903 +               /* Key must be valid and different */
41904 +               if (mic_rid.multicastValid && (!ai->mod[0].mCtx.valid ||
41905 +                   (memcmp (ai->mod[0].mCtx.key, mic_rid.multicast,
41906 +                            sizeof(ai->mod[0].mCtx.key)) != 0))) {
41907 +                       /* Age current mic Context */
41908 +                       memcpy(&ai->mod[1].mCtx,&ai->mod[0].mCtx,sizeof(miccntx));
41909 +                       /* Initialize new context */
41910 +                       memcpy(&ai->mod[0].mCtx.key,mic_rid.multicast,sizeof(mic_rid.multicast));
41911 +                       ai->mod[0].mCtx.window  = 33; //Window always points to the middle
41912 +                       ai->mod[0].mCtx.rx      = 0;  //Rx Sequence numbers
41913 +                       ai->mod[0].mCtx.tx      = 0;  //Tx sequence numbers
41914 +                       ai->mod[0].mCtx.valid   = 1;  //Key is now valid
41915 +  
41916 +                       /* Give key to mic seed */
41917 +                       emmh32_setseed(&ai->mod[0].mCtx.seed,mic_rid.multicast,sizeof(mic_rid.multicast), ai->tfm);
41918 +               }
41919 +
41920 +               /* Key must be valid and different */
41921 +               if (mic_rid.unicastValid && (!ai->mod[0].uCtx.valid || 
41922 +                   (memcmp(ai->mod[0].uCtx.key, mic_rid.unicast,
41923 +                           sizeof(ai->mod[0].uCtx.key)) != 0))) {
41924 +                       /* Age current mic Context */
41925 +                       memcpy(&ai->mod[1].uCtx,&ai->mod[0].uCtx,sizeof(miccntx));
41926 +                       /* Initialize new context */
41927 +                       memcpy(&ai->mod[0].uCtx.key,mic_rid.unicast,sizeof(mic_rid.unicast));
41928 +       
41929 +                       ai->mod[0].uCtx.window  = 33; //Window always points to the middle
41930 +                       ai->mod[0].uCtx.rx      = 0;  //Rx Sequence numbers
41931 +                       ai->mod[0].uCtx.tx      = 0;  //Tx sequence numbers
41932 +                       ai->mod[0].uCtx.valid   = 1;  //Key is now valid
41933 +       
41934 +                       //Give key to mic seed
41935 +                       emmh32_setseed(&ai->mod[0].uCtx.seed, mic_rid.unicast, sizeof(mic_rid.unicast), ai->tfm);
41936 +               }
41937 +       } else {
41938 +      /* So next time we have a valid key and mic is enabled, we will update
41939 +       * the sequence number if the key is the same as before.
41940 +       */
41941 +               ai->mod[0].uCtx.valid = 0;
41942 +               ai->mod[0].mCtx.valid = 0;
41943 +       }
41944 +}
41945 +
41946 +/* micsetup - Get ready for business */
41947 +
41948 +static int micsetup(struct airo_info *ai) {
41949 +       int i;
41950 +
41951 +       if (ai->tfm == NULL)
41952 +               ai->tfm = crypto_alloc_tfm("aes", 0);
41953 +
41954 +        if (ai->tfm == NULL) {
41955 +                printk(KERN_ERR "airo: failed to load transform for AES\n");
41956 +                return ERROR;
41957 +        }
41958 +
41959 +       for (i=0; i < NUM_MODULES; i++) {
41960 +               memset(&ai->mod[i].mCtx,0,sizeof(miccntx));
41961 +               memset(&ai->mod[i].uCtx,0,sizeof(miccntx));
41962 +       }
41963 +       return SUCCESS;
41964 +}
41965 +
41966 +char micsnap[]= {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02};
41967 +
41968 +/*===========================================================================
41969 + * Description: Mic a packet
41970 + *    
41971 + *      Inputs: etherHead * pointer to an 802.3 frame
41972 + *    
41973 + *     Returns: BOOLEAN if successful, otherwise false.
41974 + *             PacketTxLen will be updated with the mic'd packets size.
41975 + *
41976 + *    Caveats: It is assumed that the frame buffer will already
41977 + *             be big enough to hold the largets mic message possible.
41978 + *            (No memory allocation is done here).
41979 + *  
41980 + *    Author: sbraneky (10/15/01)
41981 + *    Merciless hacks by rwilcher (1/14/02)
41982 + */
41983 +
41984 +static int encapsulate(struct airo_info *ai ,etherHead *frame, MICBuffer *mic, int payLen)
41985 +{
41986 +       miccntx   *context;
41987 +
41988 +       // Determine correct context
41989 +       // If not adhoc, always use unicast key
41990 +
41991 +       if (test_bit(FLAG_ADHOC, &ai->flags) && (frame->da[0] & 0x1))
41992 +               context = &ai->mod[0].mCtx;
41993 +       else
41994 +               context = &ai->mod[0].uCtx;
41995 +  
41996 +       if (!context->valid)
41997 +               return ERROR;
41998 +
41999 +       mic->typelen = htons(payLen + 16); //Length of Mic'd packet
42000 +
42001 +       memcpy(&mic->u.snap, micsnap, sizeof(micsnap)); // Add Snap
42002 +
42003 +       // Add Tx sequence
42004 +       mic->seq = htonl(context->tx);
42005 +       context->tx += 2;
42006 +
42007 +       emmh32_init(&context->seed); // Mic the packet
42008 +       emmh32_update(&context->seed,frame->da,ETH_ALEN * 2); // DA,SA
42009 +       emmh32_update(&context->seed,(u8*)&mic->typelen,10); // Type/Length and Snap
42010 +       emmh32_update(&context->seed,(u8*)&mic->seq,sizeof(mic->seq)); //SEQ
42011 +       emmh32_update(&context->seed,frame->da + ETH_ALEN * 2,payLen); //payload
42012 +       emmh32_final(&context->seed, (u8*)&mic->mic);
42013 +
42014 +       /*    New Type/length ?????????? */
42015 +       mic->typelen = 0; //Let NIC know it could be an oversized packet
42016 +       return SUCCESS;
42017 +}
42018 +
42019 +typedef enum {
42020 +    NONE,
42021 +    NOMIC,
42022 +    NOMICPLUMMED,
42023 +    SEQUENCE,
42024 +    INCORRECTMIC,
42025 +} mic_error;
42026 +
42027 +/*===========================================================================
42028 + *  Description: Decapsulates a MIC'd packet and returns the 802.3 packet
42029 + *               (removes the MIC stuff) if packet is a valid packet.
42030 + *      
42031 + *       Inputs: etherHead  pointer to the 802.3 packet             
42032 + *     
42033 + *      Returns: BOOLEAN - TRUE if packet should be dropped otherwise FALSE
42034 + *     
42035 + *      Author: sbraneky (10/15/01)
42036 + *    Merciless hacks by rwilcher (1/14/02)
42037 + *---------------------------------------------------------------------------
42038 + */
42039 +
42040 +static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16 payLen)
42041 +{
42042 +       int      i;
42043 +       u32      micSEQ;
42044 +       miccntx  *context;
42045 +       u8       digest[4];
42046 +       mic_error micError = NONE;
42047 +
42048 +       // Check if the packet is a Mic'd packet
42049 +
42050 +       if (!ai->micstats.enabled) {
42051 +               //No Mic set or Mic OFF but we received a MIC'd packet.
42052 +               if (memcmp ((u8*)eth + 14, micsnap, sizeof(micsnap)) == 0) {
42053 +                       ai->micstats.rxMICPlummed++;
42054 +                       return ERROR;
42055 +               }
42056 +               return SUCCESS;
42057 +       }
42058 +
42059 +       if (ntohs(mic->typelen) == 0x888E)
42060 +               return SUCCESS;
42061 +
42062 +       if (memcmp (mic->u.snap, micsnap, sizeof(micsnap)) != 0) {
42063 +           // Mic enabled but packet isn't Mic'd
42064 +               ai->micstats.rxMICPlummed++;
42065 +               return ERROR;
42066 +       }
42067 +
42068 +       micSEQ = ntohl(mic->seq);            //store SEQ as CPU order
42069 +
42070 +       //At this point we a have a mic'd packet and mic is enabled
42071 +       //Now do the mic error checking.
42072 +
42073 +       //Receive seq must be odd
42074 +       if ( (micSEQ & 1) == 0 ) {
42075 +               ai->micstats.rxWrongSequence++;
42076 +               return ERROR;
42077 +       }
42078 +
42079 +       for (i = 0; i < NUM_MODULES; i++) {
42080 +               int mcast = eth->da[0] & 1;
42081 +               //Determine proper context 
42082 +               context = mcast ? &ai->mod[i].mCtx : &ai->mod[i].uCtx;
42083 +       
42084 +               //Make sure context is valid
42085 +               if (!context->valid) {
42086 +                       if (i == 0)
42087 +                               micError = NOMICPLUMMED;
42088 +                       continue;                
42089 +               }
42090 +               //DeMic it 
42091 +
42092 +               if (!mic->typelen)
42093 +                       mic->typelen = htons(payLen + sizeof(MICBuffer) - 2);
42094 +       
42095 +               emmh32_init(&context->seed);
42096 +               emmh32_update(&context->seed, eth->da, ETH_ALEN*2); 
42097 +               emmh32_update(&context->seed, (u8 *)&mic->typelen, sizeof(mic->typelen)+sizeof(mic->u.snap)); 
42098 +               emmh32_update(&context->seed, (u8 *)&mic->seq,sizeof(mic->seq));        
42099 +               emmh32_update(&context->seed, eth->da + ETH_ALEN*2,payLen);     
42100 +               //Calculate MIC
42101 +               emmh32_final(&context->seed, digest);
42102 +       
42103 +               if (memcmp(digest, &mic->mic, 4)) { //Make sure the mics match
42104 +                 //Invalid Mic
42105 +                       if (i == 0)
42106 +                               micError = INCORRECTMIC;
42107 +                       continue;
42108 +               }
42109 +
42110 +               //Check Sequence number if mics pass
42111 +               if (RxSeqValid(ai, context, mcast, micSEQ) == SUCCESS) {
42112 +                       ai->micstats.rxSuccess++;
42113 +                       return SUCCESS;
42114 +               }
42115 +               if (i == 0)
42116 +                       micError = SEQUENCE;
42117 +       }
42118 +
42119 +       // Update statistics
42120 +       switch (micError) {
42121 +               case NOMICPLUMMED: ai->micstats.rxMICPlummed++;   break;
42122 +               case SEQUENCE:    ai->micstats.rxWrongSequence++; break;
42123 +               case INCORRECTMIC: ai->micstats.rxIncorrectMIC++; break;
42124 +               case NONE:  break;
42125 +               case NOMIC: break;
42126 +       }
42127 +       return ERROR;
42128 +}
42129 +
42130 +/*===========================================================================
42131 + * Description:  Checks the Rx Seq number to make sure it is valid
42132 + *               and hasn't already been received
42133 + *   
42134 + *     Inputs: miccntx - mic context to check seq against
42135 + *             micSeq  - the Mic seq number
42136 + *   
42137 + *    Returns: TRUE if valid otherwise FALSE. 
42138 + *
42139 + *    Author: sbraneky (10/15/01)
42140 + *    Merciless hacks by rwilcher (1/14/02)
42141 + *---------------------------------------------------------------------------
42142 + */
42143 +
42144 +static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq)
42145 +{
42146 +       u32 seq,index;
42147 +
42148 +       //Allow for the ap being rebooted - if it is then use the next 
42149 +       //sequence number of the current sequence number - might go backwards
42150 +
42151 +       if (mcast) {
42152 +               if (test_bit(FLAG_UPDATE_MULTI, &ai->flags)) {
42153 +                       clear_bit (FLAG_UPDATE_MULTI, &ai->flags);
42154 +                       context->window = (micSeq > 33) ? micSeq : 33;
42155 +                       context->rx     = 0;        // Reset rx
42156 +               }
42157 +       } else if (test_bit(FLAG_UPDATE_UNI, &ai->flags)) {
42158 +               clear_bit (FLAG_UPDATE_UNI, &ai->flags);
42159 +               context->window = (micSeq > 33) ? micSeq : 33; // Move window
42160 +               context->rx     = 0;        // Reset rx
42161 +       }
42162 +
42163 +       //Make sequence number relative to START of window
42164 +       seq = micSeq - (context->window - 33);
42165 +
42166 +       //Too old of a SEQ number to check.
42167 +       if ((u32)seq < 0)
42168 +               return ERROR;
42169 +    
42170 +       if ( seq > 64 ) {
42171 +               //Window is infinite forward
42172 +               MoveWindow(context,micSeq);
42173 +               return SUCCESS;
42174 +       }
42175 +
42176 +       // We are in the window. Now check the context rx bit to see if it was already sent
42177 +       seq >>= 1;         //divide by 2 because we only have odd numbers
42178 +       index = 1 << seq;  //Get an index number
42179 +
42180 +       if (!(context->rx & index)) {
42181 +               //micSEQ falls inside the window.
42182 +               //Add seqence number to the list of received numbers.
42183 +               context->rx |= index;
42184 +
42185 +               MoveWindow(context,micSeq);
42186 +
42187 +               return SUCCESS;
42188 +       }
42189 +       return ERROR;
42190 +}
42191 +
42192 +static void MoveWindow(miccntx *context, u32 micSeq)
42193 +{
42194 +       u32 shift;
42195 +
42196 +       //Move window if seq greater than the middle of the window
42197 +       if (micSeq > context->window) {
42198 +               shift = (micSeq - context->window) >> 1;
42199 +    
42200 +                   //Shift out old
42201 +               if (shift < 32)
42202 +                       context->rx >>= shift;
42203 +               else
42204 +                       context->rx = 0;
42205 +
42206 +               context->window = micSeq;      //Move window
42207 +       }
42208 +}
42209 +
42210 +/*==============================================*/
42211 +/*========== EMMH ROUTINES  ====================*/
42212 +/*==============================================*/
42213 +
42214 +/* mic accumulate */
42215 +#define MIC_ACCUM(val) \
42216 +       context->accum += (u64)(val) * context->coeff[coeff_position++];
42217 +
42218 +static unsigned char aes_counter[16];
42219 +
42220 +/* expand the key to fill the MMH coefficient array */
42221 +void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *tfm)
42222 +{
42223 +  /* take the keying material, expand if necessary, truncate at 16-bytes */
42224 +  /* run through AES counter mode to generate context->coeff[] */
42225 +  
42226 +       int i,j;
42227 +       u32 counter;
42228 +       u8 *cipher;
42229 +       struct scatterlist sg[1];
42230 +
42231 +       crypto_cipher_setkey(tfm, pkey, 16);
42232 +       counter = 0;
42233 +       for (i = 0; i < (sizeof(context->coeff)/sizeof(context->coeff[0])); ) {
42234 +               aes_counter[15] = (u8)(counter >> 0);
42235 +               aes_counter[14] = (u8)(counter >> 8);
42236 +               aes_counter[13] = (u8)(counter >> 16);
42237 +               aes_counter[12] = (u8)(counter >> 24);
42238 +               counter++;
42239 +               sg[0].page = virt_to_page(aes_counter);
42240 +               sg[0].offset = ((long) aes_counter & ~PAGE_MASK);
42241 +               sg[0].length = 16;
42242 +               crypto_cipher_encrypt(tfm, sg, sg, 16);
42243 +               cipher = kmap(sg[0].page) + sg[0].offset;
42244 +               for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) {
42245 +                       context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
42246 +                       j += 4;
42247 +               }
42248 +       }
42249 +}
42250 +
42251 +/* prepare for calculation of a new mic */
42252 +void emmh32_init(emmh32_context *context)
42253 +{
42254 +       /* prepare for new mic calculation */
42255 +       context->accum = 0;
42256 +       context->position = 0;
42257 +}
42258 +
42259 +/* add some bytes to the mic calculation */
42260 +void emmh32_update(emmh32_context *context, u8 *pOctets, int len)
42261 +{
42262 +       int     coeff_position, byte_position;
42263 +  
42264 +       if (len == 0) return;
42265 +  
42266 +       coeff_position = context->position >> 2;
42267 +  
42268 +       /* deal with partial 32-bit word left over from last update */
42269 +       byte_position = context->position & 3;
42270 +       if (byte_position) {
42271 +               /* have a partial word in part to deal with */
42272 +               do {
42273 +                       if (len == 0) return;
42274 +                       context->part.d8[byte_position++] = *pOctets++;
42275 +                       context->position++;
42276 +                       len--;
42277 +               } while (byte_position < 4);
42278 +               MIC_ACCUM(htonl(context->part.d32));
42279 +       }
42280 +
42281 +       /* deal with full 32-bit words */
42282 +       while (len >= 4) {
42283 +               MIC_ACCUM(htonl(*(u32 *)pOctets));
42284 +               context->position += 4;
42285 +               pOctets += 4;
42286 +               len -= 4;
42287 +       }
42288 +
42289 +       /* deal with partial 32-bit word that will be left over from this update */
42290 +       byte_position = 0;
42291 +       while (len > 0) {
42292 +               context->part.d8[byte_position++] = *pOctets++;
42293 +               context->position++;
42294 +               len--;
42295 +       }
42296 +}
42297 +
42298 +/* mask used to zero empty bytes for final partial word */
42299 +static u32 mask32[4] = { 0x00000000L, 0xFF000000L, 0xFFFF0000L, 0xFFFFFF00L };
42300 +
42301 +/* calculate the mic */
42302 +void emmh32_final(emmh32_context *context, u8 digest[4])
42303 +{
42304 +       int     coeff_position, byte_position;
42305 +       u32     val;
42306 +  
42307 +       u64 sum, utmp;
42308 +       s64 stmp;
42309 +
42310 +       coeff_position = context->position >> 2;
42311 +  
42312 +       /* deal with partial 32-bit word left over from last update */
42313 +       byte_position = context->position & 3;
42314 +       if (byte_position) {
42315 +               /* have a partial word in part to deal with */
42316 +               val = htonl(context->part.d32);
42317 +               MIC_ACCUM(val & mask32[byte_position]); /* zero empty bytes */
42318 +       }
42319 +
42320 +       /* reduce the accumulated u64 to a 32-bit MIC */
42321 +       sum = context->accum;
42322 +       stmp = (sum  & 0xffffffffLL) - ((sum >> 32)  * 15);
42323 +       utmp = (stmp & 0xffffffffLL) - ((stmp >> 32) * 15);
42324 +       sum = utmp & 0xffffffffLL;
42325 +       if (utmp > 0x10000000fLL)
42326 +               sum -= 15;
42327 +
42328 +       val = (u32)sum;
42329 +       digest[0] = (val>>24) & 0xFF;
42330 +       digest[1] = (val>>16) & 0xFF;
42331 +       digest[2] = (val>>8) & 0xFF;
42332 +       digest[3] = val & 0xFF;
42333 +}
42334  #endif
42335  
42336  static int readBSSListRid(struct airo_info *ai, int first,
42337 @@ -1556,6 +2017,7 @@
42338         struct sockaddr *addr = p;
42339         Resp rsp;
42340  
42341 +       readConfigRid(ai, 1);
42342         memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len);
42343         ai->need_commit = 1;
42344         disable_MAC(ai, 1);
42345 @@ -1624,6 +2086,10 @@
42346                 /* PCMCIA frees this stuff, so only for PCI and ISA */
42347                 release_region( dev->base_addr, 64 );
42348          }
42349 +#ifdef MICSUPPORT
42350 +       if (ai->tfm)
42351 +               crypto_free_tfm(ai->tfm);
42352 +#endif
42353         del_airo_dev( dev );
42354         free_netdev( dev );
42355  }
42356 @@ -1725,6 +2191,9 @@
42357         ai->thr_pid = kernel_thread(airo_thread, dev, CLONE_FS | CLONE_FILES);
42358         if (ai->thr_pid < 0)
42359                 goto err_out_free;
42360 +#ifdef MICSUPPORT
42361 +       ai->tfm = NULL;
42362 +#endif
42363         rc = add_airo_dev( dev );
42364         if (rc)
42365                 goto err_out_thr;
42366 @@ -2125,146 +2594,149 @@
42367  
42368                         if (len > 2312) {
42369                                 printk( KERN_ERR "airo: Bad size %d\n", len );
42370 -                               len = 0;
42371 +                               goto badrx;
42372                         }
42373 -                       if (len) {
42374 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
42375 -                                       bap_read (apriv, (u16*)&fc, sizeof(fc), BAP0);
42376 -                                       fc = le16_to_cpu(fc);
42377 -                                       switch (fc & 0xc) {
42378 -                                               case 4:
42379 -                                                       if ((fc & 0xe0) == 0xc0)
42380 -                                                               hdrlen = 10;
42381 -                                                       else
42382 -                                                               hdrlen = 16;
42383 -                                                       break;
42384 -                                               case 8:
42385 -                                                       if ((fc&0x300)==0x300){
42386 -                                                               hdrlen = 30;
42387 -                                                               break;
42388 -                                                       }
42389 -                                               default:
42390 -                                                       hdrlen = 24;
42391 -                                       }
42392 -                               } else
42393 -                                       hdrlen = ETH_ALEN * 2;
42394 +                       if (len == 0)
42395 +                               goto badrx;
42396  
42397 -                               skb = dev_alloc_skb( len + hdrlen + 2 );
42398 -                               if ( !skb ) {
42399 -                                       apriv->stats.rx_dropped++;
42400 -                                       len = 0;
42401 -                               }
42402 -                       }
42403 -                       if (len) {
42404 -                               buffer = (u16*)skb_put (skb, len + hdrlen);
42405 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
42406 -                                       buffer[0] = fc;
42407 -                                       bap_read (apriv, buffer + 1, hdrlen - 2, BAP0);
42408 -                                       if (hdrlen == 24)
42409 -                                               bap_read (apriv, tmpbuf, 6, BAP0);
42410 -
42411 -                                       bap_read (apriv, &gap, sizeof(gap), BAP0);
42412 -                                       gap = le16_to_cpu(gap);
42413 -                                       if (gap) {
42414 -                                               if (gap <= 8)
42415 -                                                       bap_read (apriv, tmpbuf, gap, BAP0);
42416 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
42417 +                               bap_read (apriv, (u16*)&fc, sizeof(fc), BAP0);
42418 +                               fc = le16_to_cpu(fc);
42419 +                               switch (fc & 0xc) {
42420 +                                       case 4:
42421 +                                               if ((fc & 0xe0) == 0xc0)
42422 +                                                       hdrlen = 10;
42423                                                 else
42424 -                                                       printk(KERN_ERR "airo: gaplen too big. Problems will follow...\n");
42425 -                                       }
42426 -
42427 -
42428 -                                       bap_read (apriv, buffer + hdrlen/2, len, BAP0);
42429 -                               } else {
42430 -                                       MICBuffer micbuf;
42431 -                                       bap_read (apriv, buffer, ETH_ALEN*2, BAP0);
42432 -                                       if (apriv->micstats.enabled) {
42433 -                                               bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0);
42434 -                                               if (ntohs(micbuf.typelen) > 0x05DC)
42435 -                                                       bap_setup (apriv, fid, 0x44, BAP0);
42436 -                                               else {
42437 -                                                       len -= sizeof(micbuf);
42438 -                                                       if (len < 48)
42439 -                                                               len = 48;
42440 -                                                       skb_trim (skb, len + hdrlen);
42441 +                                                       hdrlen = 16;
42442 +                                               break;
42443 +                                       case 8:
42444 +                                               if ((fc&0x300)==0x300){
42445 +                                                       hdrlen = 30;
42446 +                                                       break;
42447                                                 }
42448 -                                       }
42449 -                                       bap_read(apriv,buffer+ETH_ALEN,len,BAP0);
42450 +                                       default:
42451 +                                               hdrlen = 24;
42452 +                               }
42453 +                       } else
42454 +                               hdrlen = ETH_ALEN * 2;
42455 +
42456 +                       skb = dev_alloc_skb( len + hdrlen + 2 );
42457 +                       if ( !skb ) {
42458 +                               apriv->stats.rx_dropped++;
42459 +                               goto badrx;
42460 +                       }
42461 +                       buffer = (u16*)skb_put (skb, len + hdrlen);
42462 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
42463 +                               buffer[0] = fc;
42464 +                               bap_read (apriv, buffer + 1, hdrlen - 2, BAP0);
42465 +                               if (hdrlen == 24)
42466 +                                       bap_read (apriv, tmpbuf, 6, BAP0);
42467 +
42468 +                               bap_read (apriv, &gap, sizeof(gap), BAP0);
42469 +                               gap = le16_to_cpu(gap);
42470 +                               if (gap) {
42471 +                                       if (gap <= 8)
42472 +                                               bap_read (apriv, tmpbuf, gap, BAP0);
42473 +                                       else
42474 +                                               printk(KERN_ERR "airo: gaplen too big. Problems will follow...\n");
42475 +                               }
42476 +                               bap_read (apriv, buffer + hdrlen/2, len, BAP0);
42477 +                       } else {
42478 +#ifdef MICSUPPORT
42479 +                               MICBuffer micbuf;
42480 +#endif
42481 +                               bap_read (apriv, buffer, ETH_ALEN*2, BAP0);
42482  #ifdef MICSUPPORT
42483 -                                       if (decapsulate(apriv,&micbuf,(etherHead*)buffer,len)) {
42484 -                                               dev_kfree_skb_irq (skb);
42485 -                                               len = 0;
42486 +                               if (apriv->micstats.enabled) {
42487 +                                       bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0);
42488 +                                       if (ntohs(micbuf.typelen) > 0x05DC)
42489 +                                               bap_setup (apriv, fid, 0x44, BAP0);
42490 +                                       else {
42491 +                                               if (len <= sizeof(micbuf))
42492 +                                                       goto badmic;
42493 +
42494 +                                               len -= sizeof(micbuf);
42495 +                                               skb_trim (skb, len + hdrlen);
42496                                         }
42497 +                               }
42498  #endif
42499 +                               bap_read(apriv,buffer+ETH_ALEN,len,BAP0);
42500 +#ifdef MICSUPPORT
42501 +                               if (decapsulate(apriv,&micbuf,(etherHead*)buffer,len)) {
42502 +badmic:
42503 +                                       dev_kfree_skb_irq (skb);
42504 +badrx:
42505 +                                       OUT4500( apriv, EVACK, EV_RX);
42506 +                                       goto exitrx;
42507                                 }
42508 +#endif
42509                         }
42510 -                       if (len) {
42511  #if WIRELESS_EXT > 15
42512  #ifdef IW_WIRELESS_SPY         /* defined in iw_handler.h */
42513 -                               if (apriv->spy_data.spy_number > 0) {
42514 -                                       char *sa;
42515 -                                       struct iw_quality wstats;
42516 -                                       /* Prepare spy data : addr + qual */
42517 -                                       if (!test_bit(FLAG_802_11, &apriv->flags)) {
42518 -                                               sa = (char*)buffer + 6;
42519 -                                               bap_setup (apriv, fid, 8, BAP0);
42520 -                                               bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
42521 -                                       } else
42522 -                                               sa = (char*)buffer + 10;
42523 -                                       wstats.qual = hdr.rssi[0];
42524 -                                       if (apriv->rssi)
42525 -                                               wstats.level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
42526 -                                       else
42527 -                                               wstats.level = (hdr.rssi[1] + 321) / 2;
42528 -                                       wstats.updated = 3;     
42529 -                                       /* Update spy records */
42530 -                                       wireless_spy_update(dev, sa, &wstats);
42531 -                               }
42532 +                       if (apriv->spy_data.spy_number > 0) {
42533 +                               char *sa;
42534 +                               struct iw_quality wstats;
42535 +                               /* Prepare spy data : addr + qual */
42536 +                               if (!test_bit(FLAG_802_11, &apriv->flags)) {
42537 +                                       sa = (char*)buffer + 6;
42538 +                                       bap_setup (apriv, fid, 8, BAP0);
42539 +                                       bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
42540 +                               } else
42541 +                                       sa = (char*)buffer + 10;
42542 +                               wstats.qual = hdr.rssi[0];
42543 +                               if (apriv->rssi)
42544 +                                       wstats.level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
42545 +                               else
42546 +                                       wstats.level = (hdr.rssi[1] + 321) / 2;
42547 +                               wstats.updated = 3;     
42548 +                               /* Update spy records */
42549 +                               wireless_spy_update(dev, sa, &wstats);
42550 +                       }
42551  #endif /* IW_WIRELESS_SPY */
42552  #else /* WIRELESS_EXT > 15 */
42553  #ifdef WIRELESS_SPY
42554 -                               if (apriv->spy_number > 0) {
42555 -                                       int i;
42556 -                                       char *sa;
42557 -
42558 -                                       sa = (char*)buffer + (test_bit(FLAG_802_11, &apriv->flags) ? 10 : 6);
42559 -
42560 -                                       for (i=0; i<apriv->spy_number; i++)
42561 -                                               if (!memcmp(sa,apriv->spy_address[i],ETH_ALEN))
42562 -                                               {
42563 -                                                       if (!test_bit(FLAG_802_11, &apriv->flags)) {
42564 -                                                               bap_setup (apriv, fid, 8, BAP0);
42565 -                                                               bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
42566 -                                                       }
42567 -                                                       apriv->spy_stat[i].qual = hdr.rssi[0];
42568 -                                                       if (apriv->rssi)
42569 -                                                               apriv->spy_stat[i].level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
42570 -                                                       else
42571 -                                                               apriv->spy_stat[i].level = (hdr.rssi[1] + 321) / 2;
42572 -                                                       apriv->spy_stat[i].noise = 0;
42573 -                                                       apriv->spy_stat[i].updated = 3;
42574 -                                                       break;
42575 +                       if (apriv->spy_number > 0) {
42576 +                               int i;
42577 +                               char *sa;
42578 +
42579 +                               sa = (char*)buffer + (test_bit(FLAG_802_11, &apriv->flags) ? 10 : 6);
42580 +
42581 +                               for (i=0; i<apriv->spy_number; i++)
42582 +                                       if (!memcmp(sa,apriv->spy_address[i],ETH_ALEN))
42583 +                                       {
42584 +                                               if (!test_bit(FLAG_802_11, &apriv->flags)) {
42585 +                                                       bap_setup (apriv, fid, 8, BAP0);
42586 +                                                       bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
42587                                                 }
42588 -                               }
42589 +                                               apriv->spy_stat[i].qual = hdr.rssi[0];
42590 +                                               if (apriv->rssi)
42591 +                                                       apriv->spy_stat[i].level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
42592 +                                               else
42593 +                                                       apriv->spy_stat[i].level = (hdr.rssi[1] + 321) / 2;
42594 +                                               apriv->spy_stat[i].noise = 0;
42595 +                                               apriv->spy_stat[i].updated = 3;
42596 +                                               break;
42597 +                                       }
42598 +                       }
42599  #endif /* WIRELESS_SPY  */
42600  #endif /* WIRELESS_EXT > 15 */
42601 -                               OUT4500( apriv, EVACK, EV_RX);
42602 +                       OUT4500( apriv, EVACK, EV_RX);
42603  
42604 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
42605 -                                       skb->mac.raw = skb->data;
42606 -                                       skb->pkt_type = PACKET_OTHERHOST;
42607 -                                       skb->dev = apriv->wifidev;
42608 -                                       skb->protocol = htons(ETH_P_802_2);
42609 -                               } else {
42610 -                                       skb->dev = dev;
42611 -                                       skb->protocol = eth_type_trans(skb,dev);
42612 -                               }
42613 -                               skb->dev->last_rx = jiffies;
42614 -                               skb->ip_summed = CHECKSUM_NONE;
42615 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
42616 +                               skb->mac.raw = skb->data;
42617 +                               skb->pkt_type = PACKET_OTHERHOST;
42618 +                               skb->dev = apriv->wifidev;
42619 +                               skb->protocol = htons(ETH_P_802_2);
42620 +                       } else {
42621 +                               skb->dev = dev;
42622 +                               skb->protocol = eth_type_trans(skb,dev);
42623 +                       }
42624 +                       skb->dev->last_rx = jiffies;
42625 +                       skb->ip_summed = CHECKSUM_NONE;
42626  
42627 -                               netif_rx( skb );
42628 -                       } else
42629 -                               OUT4500( apriv, EVACK, EV_RX);
42630 +                       netif_rx( skb );
42631                 }
42632 +exitrx:
42633  
42634                 /* Check to see if a packet has been transmitted */
42635                 if (  status & ( EV_TX|EV_TXEXC ) ) {
42636 @@ -2469,6 +2941,9 @@
42637                                 printk(KERN_WARNING "airo: unknown received signal level scale\n");
42638                 }
42639                 ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS;
42640 +               ai->config.authType = AUTH_OPEN;
42641 +               ai->config.modulation = MOD_CCK;
42642 +               ai->config._reserved1a[0] = 2; /* ??? */
42643  
42644  #ifdef MICSUPPORT
42645                 if ((cap_rid.len>=sizeof(cap_rid)) && (cap_rid.extSoftCap&1) &&
42646 @@ -2515,6 +2990,7 @@
42647                         memcpy(mySsid.ssids[i].ssid, ssids[i],
42648                                mySsid.ssids[i].len);
42649                 }
42650 +               mySsid.len = sizeof(mySsid);
42651         }
42652  
42653         status = writeConfigRid(ai, 1);
42654 @@ -3692,6 +4168,8 @@
42655                        offset < data->writelen ) offset++;
42656                 offset++;
42657         }
42658 +       if (i)
42659 +               SSID_rid.len = sizeof(SSID_rid);
42660         disable_MAC(ai, 1);
42661         writeSsidRid(ai, &SSID_rid);
42662         enable_MAC(ai, &rsp, 1);
42663 @@ -4156,7 +4634,7 @@
42664  
42665  static int __init airo_init_module( void )
42666  {
42667 -       int i, rc = 0, have_isa_dev = 0;
42668 +       int i, have_isa_dev = 0;
42669  
42670         airo_entry = create_proc_entry("aironet",
42671                                        S_IFDIR | airo_perm,
42672 @@ -4174,7 +4652,7 @@
42673  
42674  #ifdef CONFIG_PCI
42675         printk( KERN_INFO "airo:  Probing for PCI adapters\n" );
42676 -       rc = pci_module_init(&airo_driver);
42677 +       pci_module_init(&airo_driver);
42678         printk( KERN_INFO "airo:  Finished probing for PCI adapters\n" );
42679  #endif
42680  
42681 @@ -4197,8 +4675,11 @@
42682         }
42683         remove_proc_entry("aironet", proc_root_driver);
42684  
42685 -       if (is_pci)
42686 +       if (is_pci) {
42687 +#ifdef CONFIG_PCI
42688                 pci_unregister_driver(&airo_driver);
42689 +#endif
42690 +       }
42691  }
42692  
42693  #ifdef WIRELESS_EXT
42694 @@ -4260,6 +4741,7 @@
42695                         printk(KERN_DEBUG "%s: New channel value of %d is invalid!\n", dev->name, fwrq->m);
42696                         rc = -EINVAL;
42697                 } else {
42698 +                       readConfigRid(local, 1);
42699                         /* Yes ! We can set it !!! */
42700                         local->config.channelSet = (u16)(channel - 1);
42701                         local->need_commit = 1;
42702 @@ -4280,6 +4762,7 @@
42703         struct airo_info *local = dev->priv;
42704         StatusRid status_rid;           /* Card status info */
42705  
42706 +       readConfigRid(local, 1);
42707         if ((local->config.opmode & 0xFF) == MODE_STA_ESS)
42708                 status_rid.channel = local->config.channelSet;
42709         else
42710 @@ -4336,6 +4819,7 @@
42711                        sizeof(SSID_rid.ssids[index].ssid));
42712                 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length);
42713                 SSID_rid.ssids[index].len = dwrq->length - 1;
42714 +               SSID_rid.len = sizeof(SSID_rid);
42715         }
42716         /* Write it to the card */
42717         disable_MAC(local, 1);
42718 @@ -4445,6 +4929,7 @@
42719         if(dwrq->length > 16 + 1) {
42720                 return -E2BIG;
42721         }
42722 +       readConfigRid(local, 1);
42723         memset(local->config.nodeName, 0, sizeof(local->config.nodeName));
42724         memcpy(local->config.nodeName, extra, dwrq->length);
42725         local->need_commit = 1;
42726 @@ -4463,6 +4948,7 @@
42727  {
42728         struct airo_info *local = dev->priv;
42729  
42730 +       readConfigRid(local, 1);
42731         strncpy(extra, local->config.nodeName, 16);
42732         extra[16] = '\0';
42733         dwrq->length = strlen(extra) + 1;
42734 @@ -4519,6 +5005,7 @@
42735                 return -EINVAL;
42736         }
42737  
42738 +       readConfigRid(local, 1);
42739         /* Now, check if we want a fixed or auto value */
42740         if(vwrq->fixed == 0) {
42741                 /* Fill all the rates up to this max rate */
42742 @@ -4555,6 +5042,7 @@
42743  
42744         vwrq->value = status_rid.currentXmitRate * 500000;
42745         /* If more than one rate, set auto */
42746 +       readConfigRid(local, 1);
42747         vwrq->fixed = (local->config.rates[1] == 0);
42748  
42749         return 0;
42750 @@ -4577,6 +5065,7 @@
42751         if((rthr < 0) || (rthr > 2312)) {
42752                 return -EINVAL;
42753         }
42754 +       readConfigRid(local, 1);
42755         local->config.rtsThres = rthr;
42756         local->need_commit = 1;
42757  
42758 @@ -4594,6 +5083,7 @@
42759  {
42760         struct airo_info *local = dev->priv;
42761  
42762 +       readConfigRid(local, 1);
42763         vwrq->value = local->config.rtsThres;
42764         vwrq->disabled = (vwrq->value >= 2312);
42765         vwrq->fixed = 1;
42766 @@ -4619,6 +5109,7 @@
42767                 return -EINVAL;
42768         }
42769         fthr &= ~0x1;   /* Get an even value - is it really needed ??? */
42770 +       readConfigRid(local, 1);
42771         local->config.fragThresh = (u16)fthr;
42772         local->need_commit = 1;
42773  
42774 @@ -4636,6 +5127,7 @@
42775  {
42776         struct airo_info *local = dev->priv;
42777  
42778 +       readConfigRid(local, 1);
42779         vwrq->value = local->config.fragThresh;
42780         vwrq->disabled = (vwrq->value >= 2312);
42781         vwrq->fixed = 1;
42782 @@ -4655,6 +5147,7 @@
42783         struct airo_info *local = dev->priv;
42784         int commit = 1;
42785  
42786 +       readConfigRid(local, 1);
42787         if ((local->config.rmode & 0xff) >= RXMODE_RFMON)
42788                 commit = 2;
42789  
42790 @@ -4714,6 +5207,7 @@
42791  {
42792         struct airo_info *local = dev->priv;
42793  
42794 +       readConfigRid(local, 1);
42795         /* If not managed, assume it's ad-hoc */
42796         switch (local->config.opmode & 0xFF) {
42797                 case MODE_STA_ESS:
42798 @@ -4750,6 +5244,7 @@
42799         if(!(cap_rid.softCap & 2)) {
42800                 return -EOPNOTSUPP;
42801         } */
42802 +       readConfigRid(local, 1);
42803  
42804         /* Basic checking: do we have a key to set ?
42805          * Note : with the new API, it's impossible to get a NULL pointer.
42806 @@ -4836,6 +5331,7 @@
42807         if(!(cap_rid.softCap & 2)) {
42808                 return -EOPNOTSUPP;
42809         }
42810 +       readConfigRid(local, 1);
42811         /* Check encryption mode */
42812         switch(local->config.authType)  {
42813                 case AUTH_ENCRYPT:
42814 @@ -4892,6 +5388,7 @@
42815         clear_bit (FLAG_RADIO_OFF, &local->flags);
42816         for (i = 0; cap_rid.txPowerLevels[i] && (i < 8); i++)
42817                 if ((vwrq->value==cap_rid.txPowerLevels[i])) {
42818 +                       readConfigRid(local, 1);
42819                         local->config.txPower = vwrq->value;
42820                         local->need_commit = 1;
42821                         rc = -EINPROGRESS;      /* Call commit handler */
42822 @@ -4911,6 +5408,7 @@
42823  {
42824         struct airo_info *local = dev->priv;
42825  
42826 +       readConfigRid(local, 1);
42827         vwrq->value = local->config.txPower;
42828         vwrq->fixed = 1;        /* No power control */
42829         vwrq->disabled = test_bit(FLAG_RADIO_OFF, &local->flags);
42830 @@ -4934,6 +5432,7 @@
42831         if(vwrq->disabled) {
42832                 return -EINVAL;
42833         }
42834 +       readConfigRid(local, 1);
42835         if(vwrq->flags & IW_RETRY_LIMIT) {
42836                 if(vwrq->flags & IW_RETRY_MAX)
42837                         local->config.longRetryLimit = vwrq->value;
42838 @@ -4968,6 +5467,7 @@
42839  
42840         vwrq->disabled = 0;      /* Can't be disabled */
42841  
42842 +       readConfigRid(local, 1);
42843         /* Note : by default, display the min retry number */
42844         if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
42845                 vwrq->flags = IW_RETRY_LIFETIME;
42846 @@ -5106,6 +5606,7 @@
42847  {
42848         struct airo_info *local = dev->priv;
42849  
42850 +       readConfigRid(local, 1);
42851         if (vwrq->disabled) {
42852                 if ((local->config.rmode & 0xFF) >= RXMODE_RFMON) {
42853                         return -EINVAL;
42854 @@ -5162,6 +5663,7 @@
42855  {
42856         struct airo_info *local = dev->priv;
42857  
42858 +       readConfigRid(local, 1);
42859         int mode = local->config.powerSaveMode;
42860         if ((vwrq->disabled = (mode == POWERSAVE_CAM)))
42861                 return 0;
42862 @@ -5191,6 +5693,7 @@
42863  {
42864         struct airo_info *local = dev->priv;
42865  
42866 +       readConfigRid(local, 1);
42867         local->config.rssiThreshold = vwrq->disabled ? RSSI_DEFAULT : vwrq->value;
42868         local->need_commit = 1;
42869  
42870 @@ -5208,6 +5711,7 @@
42871  {
42872         struct airo_info *local = dev->priv;
42873  
42874 +       readConfigRid(local, 1);
42875         vwrq->value = local->config.rssiThreshold;
42876         vwrq->disabled = (vwrq->value == 0);
42877         vwrq->fixed = 1;
42878 @@ -6017,7 +6521,7 @@
42879  
42880                 /* Separate R/W functions bracket legality here
42881                  */
42882 -               if ( com.command <= AIROGMICSTATS )
42883 +               if ( com.command <= AIRORRID )
42884                         rc = readrids(dev,&com);
42885                 else if ( com.command >= AIROPCAP && com.command <= AIROPLEAPUSR )
42886                         rc = writerids(dev,&com);
42887 @@ -6107,6 +6611,7 @@
42888  static int readrids(struct net_device *dev, aironet_ioctl *comp) {
42889         unsigned short ridcode;
42890         unsigned char *iobuf;
42891 +       int len;
42892         struct airo_info *ai = dev->priv;
42893  
42894         if (test_bit(FLAG_FLASHING, &ai->flags))
42895 @@ -6134,11 +6639,14 @@
42896         case AIROGSTAT:     ridcode = RID_STATUS;       break;
42897         case AIROGSTATSD32: ridcode = RID_STATSDELTA;   break;
42898         case AIROGSTATSC32: ridcode = RID_STATS;        break;
42899 +#ifdef MICSUPPORT
42900         case AIROGMICSTATS:
42901                 if (copy_to_user(comp->data, &ai->micstats,
42902                                  min((int)comp->len,(int)sizeof(ai->micstats))))
42903                         return -EFAULT;
42904                 return 0;
42905 +#endif
42906 +       case AIRORRID:      ridcode = comp->len;        break;
42907         default:
42908                 return -EINVAL;
42909                 break;
42910 @@ -6152,9 +6660,12 @@
42911          * then return it to the user
42912          * 9/22/2000 Honor user given length
42913          */
42914 +       if (comp->command == AIRORRID)
42915 +               len = le16_to_cpu(*(unsigned short *)iobuf); /* Yuck! */
42916 +       else
42917 +               len = comp->len;
42918  
42919 -       if (copy_to_user(comp->data, iobuf,
42920 -                        min((int)comp->len, (int)RIDS_SIZE))) {
42921 +       if (copy_to_user(comp->data, iobuf, min(len, (int)RIDS_SIZE))) {
42922                 kfree (iobuf);
42923                 return -EFAULT;
42924         }
42925 @@ -6222,9 +6733,11 @@
42926  
42927                 PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDS_SIZE, 1);
42928  
42929 +#ifdef MICSUPPORT
42930                 enabled = ai->micstats.enabled;
42931                 memset(&ai->micstats,0,sizeof(ai->micstats));
42932                 ai->micstats.enabled = enabled;
42933 +#endif
42934  
42935                 if (copy_to_user(comp->data, iobuf,
42936                                  min((int)comp->len, (int)RIDS_SIZE))) {
42937 diff -Nru a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c
42938 --- a/drivers/net/wireless/airport.c    Tue Aug 19 20:53:17 2003
42939 +++ b/drivers/net/wireless/airport.c    Mon Aug 25 09:51:43 2003
42940 @@ -25,8 +25,6 @@
42941  #include <linux/if_arp.h>
42942  #include <linux/etherdevice.h>
42943  #include <linux/wireless.h>
42944 -#include <linux/adb.h>
42945 -#include <linux/pmu.h>
42946  
42947  #include <asm/io.h>
42948  #include <asm/system.h>
42949 @@ -48,96 +46,115 @@
42950         int ndev_registered;
42951  };
42952  
42953 -#ifdef CONFIG_PMAC_PBOOK
42954 -static int airport_sleep_notify(struct pmu_sleep_notifier *self, int when);
42955 -static struct pmu_sleep_notifier airport_sleep_notifier = {
42956 -       airport_sleep_notify, SLEEP_LEVEL_NET,
42957 -};
42958 -#endif
42959 +static int
42960 +airport_suspend(struct macio_dev *mdev, u32 state)
42961 +{
42962 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
42963 +       struct orinoco_private *priv = dev->priv;
42964 +       struct airport *card = priv->card;
42965 +       unsigned long flags;
42966 +       int err;
42967 +
42968 +       printk(KERN_DEBUG "%s: Airport entering sleep mode\n", dev->name);
42969 +
42970 +       err = orinoco_lock(priv, &flags);
42971 +       if (err) {
42972 +               printk(KERN_ERR "%s: hw_unavailable on PBOOK_SLEEP_NOW\n",
42973 +                      dev->name);
42974 +               return 0;
42975 +       }
42976 +
42977 +       err = __orinoco_down(dev);
42978 +       if (err)
42979 +               printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n",
42980 +                      dev->name, err);
42981  
42982 -/*
42983 - * Function prototypes
42984 - */
42985 +       netif_device_detach(dev);
42986  
42987 -static struct net_device *airport_attach(struct device_node *of_node);
42988 -static void airport_detach(struct net_device *dev);
42989 +       priv->hw_unavailable++;
42990  
42991 -static struct net_device *airport_dev;
42992 +       orinoco_unlock(priv, &flags);
42993 +
42994 +       disable_irq(dev->irq);
42995 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
42996 +
42997 +       return 0;
42998 +}
42999  
43000 -#ifdef CONFIG_PMAC_PBOOK
43001  static int
43002 -airport_sleep_notify(struct pmu_sleep_notifier *self, int when)
43003 +airport_resume(struct macio_dev *mdev)
43004  {
43005 -       struct net_device *dev = airport_dev;
43006 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
43007         struct orinoco_private *priv = dev->priv;
43008         struct airport *card = priv->card;
43009         unsigned long flags;
43010         int err;
43011 -       
43012 -       if (! airport_dev)
43013 -               return PBOOK_SLEEP_OK;
43014 -
43015 -       switch (when) {
43016 -       case PBOOK_SLEEP_NOW:
43017 -               printk(KERN_DEBUG "%s: Airport entering sleep mode\n", dev->name);
43018 -
43019 -               err = orinoco_lock(priv, &flags);
43020 -               if (err) {
43021 -                       printk(KERN_ERR "%s: hw_unavailable on PBOOK_SLEEP_NOW\n",
43022 -                              dev->name);
43023 -                       break;
43024 -               }
43025  
43026 -               err = __orinoco_down(dev);
43027 -               if (err)
43028 -                       printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n",
43029 -                              dev->name, err);
43030 +       printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
43031  
43032 -               netif_device_detach(dev);
43033 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1);
43034 +       mdelay(200);
43035  
43036 -               priv->hw_unavailable++;
43037 +       enable_irq(dev->irq);
43038  
43039 -               orinoco_unlock(priv, &flags);
43040 +       err = orinoco_reinit_firmware(dev);
43041 +       if (err) {
43042 +               printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n",
43043 +                      dev->name, err);
43044 +               return 0;
43045 +       }
43046  
43047 -               disable_irq(dev->irq);
43048 -               pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
43049 -               break;
43050 +       spin_lock_irqsave(&priv->lock, flags);
43051  
43052 -       case PBOOK_WAKE:
43053 -               printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
43054 -               pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1);
43055 -               mdelay(200);
43056 +       netif_device_attach(dev);
43057  
43058 -               enable_irq(dev->irq);
43059 +       priv->hw_unavailable--;
43060  
43061 -               err = orinoco_reinit_firmware(dev);
43062 -               if (err) {
43063 -                       printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n",
43064 +       if (priv->open && (! priv->hw_unavailable)) {
43065 +               err = __orinoco_up(dev);
43066 +               if (err)
43067 +                       printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
43068                                dev->name, err);
43069 -                       break;
43070 -               }
43071 +       }
43072  
43073 -               spin_lock_irqsave(&priv->lock, flags);
43074  
43075 -               netif_device_attach(dev);
43076 +       spin_unlock_irqrestore(&priv->lock, flags);
43077  
43078 -               priv->hw_unavailable--;
43079 +       return 0;
43080 +}
43081  
43082 -               if (priv->open && (! priv->hw_unavailable)) {
43083 -                       err = __orinoco_up(dev);
43084 -                       if (err)
43085 -                               printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
43086 -                                      dev->name, err);
43087 -               }
43088 +static int
43089 +airport_detach(struct macio_dev *mdev)
43090 +{
43091 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
43092 +       struct orinoco_private *priv = dev->priv;
43093 +       struct airport *card = priv->card;
43094  
43095 +       if (card->ndev_registered)
43096 +               unregister_netdev(dev);
43097 +       card->ndev_registered = 0;
43098  
43099 -               spin_unlock_irqrestore(&priv->lock, flags);
43100 +       if (card->irq_requested)
43101 +               free_irq(dev->irq, dev);
43102 +       card->irq_requested = 0;
43103  
43104 -               break;
43105 -       }
43106 -       return PBOOK_SLEEP_OK;
43107 +       if (card->vaddr)
43108 +               iounmap(card->vaddr);
43109 +       card->vaddr = 0;
43110 +
43111 +       dev->base_addr = 0;
43112 +
43113 +       release_OF_resource(card->node, 0);
43114 +
43115 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
43116 +       current->state = TASK_UNINTERRUPTIBLE;
43117 +       schedule_timeout(HZ);
43118 +
43119 +       dev_set_drvdata(&mdev->ofdev.dev, NULL);
43120 +       free_netdev(dev);
43121 +
43122 +       return 0;
43123  }
43124 -#endif /* CONFIG_PMAC_PBOOK */
43125  
43126  static int airport_hard_reset(struct orinoco_private *priv)
43127  {
43128 @@ -170,25 +187,26 @@
43129         return 0;
43130  }
43131  
43132 -static struct net_device *
43133 -airport_attach(struct device_node *of_node)
43134 +static int
43135 +airport_attach(struct macio_dev *mdev, const struct of_match *match)
43136  {
43137         struct orinoco_private *priv;
43138         struct net_device *dev;
43139         struct airport *card;
43140         unsigned long phys_addr;
43141 +       struct device_node *of_node = mdev->ofdev.node;
43142         hermes_t *hw;
43143  
43144         if (of_node->n_addrs < 1 || of_node->n_intrs < 1) {
43145                 printk(KERN_ERR "airport: wrong interrupt/addresses in OF tree\n");
43146 -               return NULL;
43147 +               return -ENODEV;
43148         }
43149  
43150         /* Allocate space for private device-specific data */
43151         dev = alloc_orinocodev(sizeof(*card), airport_hard_reset);
43152         if (! dev) {
43153                 printk(KERN_ERR "airport: can't allocate device datas\n");
43154 -               return NULL;
43155 +               return -ENODEV;
43156         }
43157         priv = dev->priv;
43158         card = priv->card;
43159 @@ -199,11 +217,14 @@
43160         if (! request_OF_resource(of_node, 0, " (airport)")) {
43161                 printk(KERN_ERR "airport: can't request IO resource !\n");
43162                 kfree(dev);
43163 -               return NULL;
43164 +               return -ENODEV;
43165         }
43166  
43167         dev->name[0] = '\0';    /* register_netdev will give us an ethX name */
43168         SET_MODULE_OWNER(dev);
43169 +       SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
43170 +
43171 +       dev_set_drvdata(&mdev->ofdev.dev, dev);
43172  
43173         /* Setup interrupts & base address */
43174         dev->irq = of_node->intrs[0].line;
43175 @@ -240,79 +261,50 @@
43176         }
43177         printk(KERN_DEBUG "airport: card registered for interface %s\n", dev->name);
43178         card->ndev_registered = 1;
43179 -
43180 -#ifdef CONFIG_PMAC_PBOOK
43181 -       pmu_register_sleep_notifier(&airport_sleep_notifier);
43182 -#endif
43183 -       return dev;
43184 -       
43185 +       return 0;
43186   failed:
43187 -       airport_detach(dev);
43188 -       return NULL;
43189 +       airport_detach(mdev);
43190 +       return -ENODEV;
43191  }                              /* airport_attach */
43192  
43193 -/*======================================================================
43194 -  This deletes a driver "instance".  
43195 -  ======================================================================*/
43196 -
43197 -static void
43198 -airport_detach(struct net_device *dev)
43199 -{
43200 -       struct orinoco_private *priv = dev->priv;
43201 -       struct airport *card = priv->card;
43202 -
43203 -#ifdef CONFIG_PMAC_PBOOK
43204 -       pmu_unregister_sleep_notifier(&airport_sleep_notifier);
43205 -#endif
43206 -       if (card->ndev_registered)
43207 -               unregister_netdev(dev);
43208 -       card->ndev_registered = 0;
43209 -
43210 -       if (card->irq_requested)
43211 -               free_irq(dev->irq, dev);
43212 -       card->irq_requested = 0;
43213 -
43214 -       if (card->vaddr)
43215 -               iounmap(card->vaddr);
43216 -       card->vaddr = 0;
43217 -
43218 -       dev->base_addr = 0;
43219 -
43220 -       release_OF_resource(card->node, 0);
43221 -
43222 -       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
43223 -       current->state = TASK_UNINTERRUPTIBLE;
43224 -       schedule_timeout(HZ);
43225 -
43226 -       free_netdev(dev);
43227 -}                              /* airport_detach */
43228  
43229  static char version[] __initdata = "airport.c 0.13e (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
43230  MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
43231  MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
43232  MODULE_LICENSE("Dual MPL/GPL");
43233  
43234 +static struct of_match airport_match[] = 
43235 +{
43236 +       {
43237 +       .name           = "radio",
43238 +       .type           = OF_ANY_MATCH,
43239 +       .compatible     = OF_ANY_MATCH
43240 +       },
43241 +       {},
43242 +};
43243 +
43244 +static struct macio_driver airport_driver = 
43245 +{
43246 +       .name           = "airport",
43247 +       .match_table    = airport_match,
43248 +       .probe          = airport_attach,
43249 +       .remove         = airport_detach,
43250 +       .suspend        = airport_suspend,
43251 +       .resume         = airport_resume,
43252 +};
43253 +
43254  static int __init
43255  init_airport(void)
43256  {
43257 -       struct device_node *airport_node;
43258 -
43259         printk(KERN_DEBUG "%s\n", version);
43260  
43261 -       /* Lookup card in device tree */
43262 -       airport_node = find_devices("radio");
43263 -       if (airport_node && !strcmp(airport_node->parent->name, "mac-io"))
43264 -               airport_dev = airport_attach(airport_node);
43265 -
43266 -       return airport_dev ? 0 : -ENODEV;
43267 +       return macio_register_driver(&airport_driver);
43268  }
43269  
43270  static void __exit
43271  exit_airport(void)
43272  {
43273 -       if (airport_dev)
43274 -               airport_detach(airport_dev);
43275 -       airport_dev = NULL;
43276 +       return macio_unregister_driver(&airport_driver);
43277  }
43278  
43279  module_init(init_airport);
43280 diff -Nru a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
43281 --- a/drivers/net/wireless/ray_cs.c     Thu Aug  7 09:17:57 2003
43282 +++ b/drivers/net/wireless/ray_cs.c     Tue Aug 26 14:55:20 2003
43283 @@ -105,6 +105,9 @@
43284  static struct net_device_stats *ray_get_stats(struct net_device *dev);
43285  static int ray_dev_init(struct net_device *dev);
43286  static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
43287 +
43288 +static struct ethtool_ops netdev_ethtool_ops;
43289 +
43290  static int ray_open(struct net_device *dev);
43291  static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev);
43292  static void set_multicast_list(struct net_device *dev);
43293 @@ -408,6 +411,7 @@
43294      dev->set_config = &ray_dev_config;
43295      dev->get_stats  = &ray_get_stats;
43296      dev->do_ioctl = &ray_dev_ioctl;
43297 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
43298  #if WIRELESS_EXT > 7   /* If wireless extension exist in the kernel */
43299      dev->get_wireless_stats = ray_get_wireless_stats;
43300  #endif
43301 @@ -1226,26 +1230,16 @@
43302  
43303  /*===========================================================================*/
43304  
43305 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
43306 +static void netdev_get_drvinfo(struct net_device *dev,
43307 +                              struct ethtool_drvinfo *info)
43308  {
43309 -       u32 ethcmd;
43310 -               
43311 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
43312 -               return -EFAULT;
43313 -       
43314 -       switch (ethcmd) {
43315 -       case ETHTOOL_GDRVINFO: {
43316 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
43317 -               strncpy(info.driver, "ray_cs", sizeof(info.driver)-1);
43318 -               if (copy_to_user(useraddr, &info, sizeof(info)))
43319 -                       return -EFAULT;
43320 -               return 0;
43321 -       }
43322 -       }
43323 -       
43324 -       return -EOPNOTSUPP;
43325 +       strcpy(info->driver, "ray_cs");
43326  }
43327  
43328 +static struct ethtool_ops netdev_ethtool_ops = {
43329 +       .get_drvinfo            = netdev_get_drvinfo,
43330 +};
43331 +
43332  /*====================================================================*/
43333  
43334  static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43335 @@ -1265,10 +1259,6 @@
43336      /* Validate the command */
43337      switch (cmd)
43338      {
43339 -    case SIOCETHTOOL:
43340 -      err = netdev_ethtool_ioctl(dev, (void *) ifr->ifr_data);
43341 -      break;
43342 -
43343  #if WIRELESS_EXT > 7
43344        /* --------------- WIRELESS EXTENSIONS --------------- */
43345        /* Get name */
43346 diff -Nru a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
43347 --- a/drivers/net/yellowfin.c   Tue Aug 19 20:53:17 2003
43348 +++ b/drivers/net/yellowfin.c   Sun Aug 31 06:34:16 2003
43349 @@ -873,8 +873,6 @@
43350         /* Calculate the next Tx descriptor entry. */
43351         entry = yp->cur_tx % TX_RING_SIZE;
43352  
43353 -       yp->tx_skbuff[entry] = skb;
43354 -
43355         if (gx_fix) {   /* Note: only works for paddable protocols e.g.  IP. */
43356                 int cacheline_end = ((unsigned long)skb->data + skb->len) % 32;
43357                 /* Fix GX chipset errata. */
43358 @@ -889,6 +887,8 @@
43359                         return 0;
43360                 }
43361         }
43362 +       yp->tx_skbuff[entry] = skb;
43363 +
43364  #ifdef NO_TXSTATS
43365         yp->tx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev, 
43366                 skb->data, len, PCI_DMA_TODEVICE));
43367 diff -Nru a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
43368 --- a/drivers/parport/parport_pc.c      Thu Jul 31 08:59:04 2003
43369 +++ b/drivers/parport/parport_pc.c      Sun Aug 31 16:14:16 2003
43370 @@ -93,7 +93,7 @@
43371         int dma;
43372  } superios[NR_SUPERIOS] __devinitdata = { {0,},};
43373  
43374 -static int user_specified __devinitdata = 0;
43375 +static int user_specified;
43376  #if defined(CONFIG_PARPORT_PC_SUPERIO) || \
43377         (defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
43378  static int verbose_probing;
43379 diff -Nru a/drivers/pci/pci.ids b/drivers/pci/pci.ids
43380 --- a/drivers/pci/pci.ids       Wed Aug  6 12:32:59 2003
43381 +++ b/drivers/pci/pci.ids       Thu Aug 28 00:24:56 2003
43382 @@ -3247,7 +3247,8 @@
43383                 1148 5061  SK-9861 V2.0 Gigabit Ethernet 1000Base-SX Adapter
43384                 1148 5071  SK-9871 V2.0 Gigabit Ethernet 1000Base-ZX Adapter
43385                 1148 9521  SK-9521 10/100/1000Base-T Adapter
43386 -       4400  Gigabit Ethernet
43387 +       4400 SK-9Dxx Gigabit Ethernet Adapter
43388 +       4500 SK-9Mxx Gigabit Ethernet Adapter
43389  1149  Win System Corporation
43390  114a  VMIC
43391         5579  VMIPCI-5579 (Reflective Memory Card)
43392 @@ -5313,9 +5314,12 @@
43393                 1166 1648  NetXtreme CIOB-E 1000Base-T
43394         164d  NetXtreme BCM5702FE Gigabit Ethernet
43395         1653  NetXtreme BCM5705 Gigabit Ethernet
43396 +       1654  NetXtreme BCM5705 Gigabit Ethernet
43397         165d  NetXtreme BCM5705M Gigabit Ethernet
43398 +       165e  NetXtreme BCM5705M Gigabit Ethernet
43399         1696  NetXtreme BCM5782 Gigabit Ethernet
43400                 14e4 000d  NetXtreme BCM5782 1000Base-T
43401 +       169c  NetXtreme BCM5788 Gigabit Ethernet
43402         16a6  NetXtreme BCM5702 Gigabit Ethernet
43403                 0e11 00bb  NC7760 Gigabit Server Adapter (PCI-X, 10/100/1000-T)
43404                 1028 0126  BCM5702 1000Base-T
43405 @@ -5337,6 +5341,8 @@
43406         16c7  NetXtreme BCM5703 Gigabit Ethernet
43407                 14e4 0009  NetXtreme BCM5703 1000Base-T
43408                 14e4 000a  NetXtreme BCM5703 1000Base-SX
43409 +       170d  NetXtreme BCM5901 Gigabit Ethernet
43410 +       170e  NetXtreme BCM5901 Gigabit Ethernet
43411         4210  BCM4210 iLine10 HomePNA 2.0
43412         4211  BCM4211 iLine10 HomePNA 2.0 + V.90 56k modem
43413         4212  BCM4212 v.90 56k modem
43414 @@ -5877,6 +5883,8 @@
43415         03e8  AC1000 Gigabit Ethernet
43416         03e9  AC1001 Gigabit Ethernet
43417         03ea  AC9100 Gigabit Ethernet
43418 +               173b 0001  AC1002
43419 +       03eb  AC1003 Gigabit Ethernet
43420  1743  Peppercon AG
43421         8139  ROL/F-100 Fast Ethernet Adapter with ROL
43422  174b  PC Partner Limited
43423 diff -Nru a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
43424 --- a/drivers/pcmcia/cistpl.c   Sun Jul  6 16:03:10 2003
43425 +++ b/drivers/pcmcia/cistpl.c   Wed Aug 27 13:25:31 2003
43426 @@ -293,15 +293,17 @@
43427  #endif
43428         ret = read_cis_mem(s, attr, addr, len, ptr);
43429  
43430 -    /* Copy data into the cache */
43431 -    cis = kmalloc(sizeof(struct cis_cache_entry) + len, GFP_KERNEL);
43432 -    if (cis) {
43433 -       cis->addr = addr;
43434 -       cis->len = len;
43435 -       cis->attr = attr;
43436 -       memcpy(cis->cache, ptr, len);
43437 -       list_add(&cis->node, &s->cis_cache);
43438 -    }
43439 +       if (ret == 0) {
43440 +               /* Copy data into the cache */
43441 +               cis = kmalloc(sizeof(struct cis_cache_entry) + len, GFP_KERNEL);
43442 +               if (cis) {
43443 +                       cis->addr = addr;
43444 +                       cis->len = len;
43445 +                       cis->attr = attr;
43446 +                       memcpy(cis->cache, ptr, len);
43447 +                       list_add(&cis->node, &s->cis_cache);
43448 +               }
43449 +       }
43450  }
43451  
43452  static void
43453 diff -Nru a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
43454 --- a/drivers/pcmcia/ds.c       Mon Jun 16 13:20:14 2003
43455 +++ b/drivers/pcmcia/ds.c       Tue Aug 26 09:25:41 2003
43456 @@ -495,7 +495,7 @@
43457  
43458  static int ds_open(struct inode *inode, struct file *file)
43459  {
43460 -    socket_t i = minor(inode->i_rdev);
43461 +    socket_t i = iminor(inode);
43462      struct pcmcia_bus_socket *s;
43463      user_info_t *user;
43464  
43465 @@ -529,7 +529,7 @@
43466  
43467  static int ds_release(struct inode *inode, struct file *file)
43468  {
43469 -    socket_t i = minor(inode->i_rdev);
43470 +    socket_t i = iminor(inode);
43471      struct pcmcia_bus_socket *s;
43472      user_info_t *user, **link;
43473  
43474 @@ -563,7 +563,7 @@
43475  static ssize_t ds_read(struct file *file, char *buf,
43476                        size_t count, loff_t *ppos)
43477  {
43478 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
43479 +    socket_t i = iminor(file->f_dentry->d_inode);
43480      struct pcmcia_bus_socket *s;
43481      user_info_t *user;
43482  
43483 @@ -594,7 +594,7 @@
43484  static ssize_t ds_write(struct file *file, const char *buf,
43485                         size_t count, loff_t *ppos)
43486  {
43487 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
43488 +    socket_t i = iminor(file->f_dentry->d_inode);
43489      struct pcmcia_bus_socket *s;
43490      user_info_t *user;
43491  
43492 @@ -629,7 +629,7 @@
43493  /* No kernel lock - fine */
43494  static u_int ds_poll(struct file *file, poll_table *wait)
43495  {
43496 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
43497 +    socket_t i = iminor(file->f_dentry->d_inode);
43498      struct pcmcia_bus_socket *s;
43499      user_info_t *user;
43500  
43501 @@ -653,7 +653,7 @@
43502  static int ds_ioctl(struct inode * inode, struct file * file,
43503                     u_int cmd, u_long arg)
43504  {
43505 -    socket_t i = minor(inode->i_rdev);
43506 +    socket_t i = iminor(inode);
43507      struct pcmcia_bus_socket *s;
43508      u_int size;
43509      int ret, err;
43510 diff -Nru a/drivers/pcmcia/ricoh.h b/drivers/pcmcia/ricoh.h
43511 --- a/drivers/pcmcia/ricoh.h    Mon Jul 14 07:42:47 2003
43512 +++ b/drivers/pcmcia/ricoh.h    Wed Aug 27 12:42:52 2003
43513 @@ -142,59 +142,61 @@
43514          config_writeb(socket, RL5C4XX_MISC_CONTROL, reg);
43515  }
43516  
43517 -static void ricoh_set_zv(struct pcmcia_socket *sock)
43518 +static void ricoh_set_zv(struct yenta_socket *socket)
43519  {
43520 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
43521          if(socket->dev->vendor == PCI_VENDOR_ID_RICOH)
43522          {
43523                  switch(socket->dev->device)
43524                  {
43525                          /* There may be more .. */
43526                 case  PCI_DEVICE_ID_RICOH_RL5C478:
43527 -                       sock->zoom_video = ricoh_zoom_video;
43528 +                       socket->socket.zoom_video = ricoh_zoom_video;
43529                         break;  
43530                  }
43531          }
43532  }
43533  
43534 -static int ricoh_init(struct pcmcia_socket *sock)
43535 +static void ricoh_save_state(struct yenta_socket *socket)
43536  {
43537 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
43538 -       yenta_init(sock);
43539 -       ricoh_set_zv(sock);
43540 +       rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
43541 +       rl_ctl(socket) = config_readw(socket, RL5C4XX_16BIT_CTL);
43542 +       rl_io(socket) = config_readw(socket, RL5C4XX_16BIT_IO_0);
43543 +       rl_mem(socket) = config_readw(socket, RL5C4XX_16BIT_MEM_0);
43544 +       rl_config(socket) = config_readw(socket, RL5C4XX_CONFIG);
43545 +}
43546  
43547 +static void ricoh_restore_state(struct yenta_socket *socket)
43548 +{
43549         config_writew(socket, RL5C4XX_MISC, rl_misc(socket));
43550         config_writew(socket, RL5C4XX_16BIT_CTL, rl_ctl(socket));
43551         config_writew(socket, RL5C4XX_16BIT_IO_0, rl_io(socket));
43552         config_writew(socket, RL5C4XX_16BIT_MEM_0, rl_mem(socket));
43553         config_writew(socket, RL5C4XX_CONFIG, rl_config(socket));
43554 -       
43555 -       return 0;
43556  }
43557  
43558  
43559  /*
43560 - * Magic Ricoh initialization code.. Save state at
43561 - * beginning, re-initialize it after suspend.
43562 + * Magic Ricoh initialization code..
43563   */
43564  static int ricoh_override(struct yenta_socket *socket)
43565  {
43566 -       rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
43567 -       rl_ctl(socket) = config_readw(socket, RL5C4XX_16BIT_CTL);
43568 -       rl_io(socket) = config_readw(socket, RL5C4XX_16BIT_IO_0);
43569 -       rl_mem(socket) = config_readw(socket, RL5C4XX_16BIT_MEM_0);
43570 -       rl_config(socket) = config_readw(socket, RL5C4XX_CONFIG);
43571 +       u16 config, ctl;
43572 +
43573 +       config = config_readw(socket, RL5C4XX_CONFIG);
43574  
43575         /* Set the default timings, don't trust the original values */
43576 -       rl_ctl(socket) = RL5C4XX_16CTL_IO_TIMING | RL5C4XX_16CTL_MEM_TIMING;
43577 +       ctl = RL5C4XX_16CTL_IO_TIMING | RL5C4XX_16CTL_MEM_TIMING;
43578  
43579         if(socket->dev->device < PCI_DEVICE_ID_RICOH_RL5C475) {
43580 -               rl_ctl(socket) |= RL5C46X_16CTL_LEVEL_1 | RL5C46X_16CTL_LEVEL_2;
43581 +               ctl |= RL5C46X_16CTL_LEVEL_1 | RL5C46X_16CTL_LEVEL_2;
43582         } else {
43583 -               rl_config(socket) |= RL5C4XX_CONFIG_PREFETCH;
43584 +               config |= RL5C4XX_CONFIG_PREFETCH;
43585         }
43586  
43587 -       socket->socket.ops->init = ricoh_init;
43588 +       config_writew(socket, RL5C4XX_16BIT_CTL, ctl);
43589 +       config_writew(socket, RL5C4XX_CONFIG, config);
43590 +
43591 +       ricoh_set_zv(socket);
43592  
43593         return 0;
43594  }
43595 diff -Nru a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
43596 --- a/drivers/pcmcia/sa1111_generic.c   Sun Jun 15 04:35:08 2003
43597 +++ b/drivers/pcmcia/sa1111_generic.c   Sun Aug 24 07:45:05 2003
43598 @@ -16,6 +16,7 @@
43599  
43600  #include <asm/hardware.h>
43601  #include <asm/hardware/sa1111.h>
43602 +#include <asm/io.h>
43603  #include <asm/irq.h>
43604  
43605  #include "sa1111_generic.h"
43606 @@ -118,16 +119,15 @@
43607         sa11xx_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
43608  }
43609  
43610 -static int pcmcia_probe(struct device *dev)
43611 +static int pcmcia_probe(struct sa1111_dev *dev)
43612  {
43613 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
43614         char *base;
43615  
43616 -       if (!request_mem_region(sadev->res.start, 512,
43617 -                               SA1111_DRIVER_NAME(sadev)))
43618 +       if (!request_mem_region(dev->res.start, 512,
43619 +                               SA1111_DRIVER_NAME(dev)))
43620                 return -EBUSY;
43621  
43622 -       base = sadev->mapbase;
43623 +       base = dev->mapbase;
43624  
43625         /*
43626          * Initialise the suspend state.
43627 @@ -136,61 +136,68 @@
43628         sa1111_writel(PCCR_S0_FLT | PCCR_S1_FLT, base + SA1111_PCCR);
43629  
43630  #ifdef CONFIG_SA1100_ADSBITSY
43631 -       pcmcia_adsbitsy_init(dev);
43632 +       pcmcia_adsbitsy_init(&dev->dev);
43633  #endif
43634  #ifdef CONFIG_SA1100_BADGE4
43635 -       pcmcia_badge4_init(dev);
43636 +       pcmcia_badge4_init(&dev->dev);
43637  #endif
43638  #ifdef CONFIG_SA1100_GRAPHICSMASTER
43639 -       pcmcia_graphicsmaster_init(dev);
43640 +       pcmcia_graphicsmaster_init(&dev->dev);
43641  #endif
43642  #ifdef CONFIG_SA1100_JORNADA720
43643 -       pcmcia_jornada720_init(dev);
43644 +       pcmcia_jornada720_init(&dev->dev);
43645  #endif
43646  #ifdef CONFIG_ASSABET_NEPONSET
43647 -       pcmcia_neponset_init(dev);
43648 +       pcmcia_neponset_init(&dev->dev);
43649  #endif
43650  #ifdef CONFIG_SA1100_PFS168
43651 -       pcmcia_pfs_init(dev);
43652 +       pcmcia_pfs_init(&dev->dev);
43653  #endif
43654  #ifdef CONFIG_SA1100_PT_SYSTEM3
43655 -       pcmcia_system3_init(dev);
43656 +       pcmcia_system3_init(&dev->dev);
43657  #endif
43658  #ifdef CONFIG_SA1100_XP860
43659 -       pcmcia_xp860_init(dev);
43660 +       pcmcia_xp860_init(&dev->dev);
43661  #endif
43662         return 0;
43663  }
43664  
43665 -static int __devexit pcmcia_remove(struct device *dev)
43666 +static int __devexit pcmcia_remove(struct sa1111_dev *dev)
43667  {
43668 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
43669 -
43670 -       sa11xx_drv_pcmcia_remove(dev);
43671 -       release_mem_region(sadev->res.start, 512);
43672 +       sa11xx_drv_pcmcia_remove(&dev->dev);
43673 +       release_mem_region(dev->res.start, 512);
43674         return 0;
43675  }
43676  
43677 +static int pcmcia_suspend(struct sa1111_dev *dev, u32 state)
43678 +{
43679 +       return pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
43680 +}
43681 +
43682 +static int pcmcia_resume(struct sa1111_dev *dev)
43683 +{
43684 +       return pcmcia_socket_dev_resume(&dev->dev, RESUME_RESTORE_STATE);
43685 +}
43686 +
43687  static struct sa1111_driver pcmcia_driver = {
43688         .drv = {
43689 -               .name           = "sa1111-pcmcia",
43690 -               .bus            = &sa1111_bus_type,
43691 -               .probe          = pcmcia_probe,
43692 -               .remove         = __devexit_p(pcmcia_remove),
43693 -               .suspend        = pcmcia_socket_dev_suspend,
43694 -               .resume         = pcmcia_socket_dev_resume,
43695 +               .name   = "sa1111-pcmcia",
43696         },
43697 -       .devid                  = SA1111_DEVID_PCMCIA,
43698 +       .devid          = SA1111_DEVID_PCMCIA,
43699 +       .probe          = pcmcia_probe,
43700 +       .remove         = __devexit_p(pcmcia_remove),
43701 +       .suspend        = pcmcia_suspend,
43702 +       .resume         = pcmcia_resume,
43703  };
43704  
43705  static int __init sa1111_drv_pcmcia_init(void)
43706  {
43707 -       return driver_register(&pcmcia_driver.drv);
43708 +       return sa1111_driver_register(&pcmcia_driver);
43709  }
43710  
43711  static void __exit sa1111_drv_pcmcia_exit(void)
43712  {
43713 -       driver_unregister(&pcmcia_driver.drv);
43714 +       sa1111_driver_unregister(&pcmcia_driver);
43715  }
43716  
43717  module_init(sa1111_drv_pcmcia_init);
43718 diff -Nru a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
43719 --- a/drivers/pcmcia/ti113x.h   Wed Aug  6 15:59:05 2003
43720 +++ b/drivers/pcmcia/ti113x.h   Wed Aug 27 12:58:54 2003
43721 @@ -136,16 +136,34 @@
43722  
43723  #ifdef CONFIG_CARDBUS
43724  
43725 -static int ti_intctl(struct yenta_socket *socket)
43726 +/*
43727 + * Texas Instruments CardBus controller overrides.
43728 + */
43729 +#define ti_sysctl(socket)      ((socket)->private[0])
43730 +#define ti_cardctl(socket)     ((socket)->private[1])
43731 +#define ti_devctl(socket)      ((socket)->private[2])
43732 +#define ti_diag(socket)                ((socket)->private[3])
43733 +#define ti_irqmux(socket)      ((socket)->private[4])
43734 +
43735 +/*
43736 + * These are the TI specific power management handlers.
43737 + */
43738 +static void ti_save_state(struct yenta_socket *socket)
43739  {
43740 -       u8 new, reg = exca_readb(socket, I365_INTCTL);
43741 +       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
43742 +       ti_irqmux(socket) = config_readl(socket, TI122X_IRQMUX);
43743 +       ti_cardctl(socket) = config_readb(socket, TI113X_CARD_CONTROL);
43744 +       ti_devctl(socket) = config_readb(socket, TI113X_DEVICE_CONTROL);
43745 +       ti_diag(socket) = config_readb(socket, TI1250_DIAGNOSTIC);
43746 +}
43747  
43748 -       new = reg & ~I365_INTR_ENA;
43749 -       if (socket->cb_irq)
43750 -               new |= I365_INTR_ENA;
43751 -       if (new != reg)
43752 -               exca_writeb(socket, I365_INTCTL, new);
43753 -       return 0;
43754 +static void ti_restore_state(struct yenta_socket *socket)
43755 +{
43756 +       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
43757 +       config_writel(socket, TI122X_IRQMUX, ti_irqmux(socket));
43758 +       config_writeb(socket, TI113X_CARD_CONTROL, ti_cardctl(socket));
43759 +       config_writeb(socket, TI113X_DEVICE_CONTROL, ti_devctl(socket));
43760 +       config_writeb(socket, TI1250_DIAGNOSTIC, ti_diag(socket));
43761  }
43762  
43763  /*
43764 @@ -185,8 +203,8 @@
43765  
43766         ti_zoom_video(sock, onoff);
43767  
43768 -       reg = config_readb(socket, 0x84);
43769 -       reg |= (1<<7);  /* ZV bus enable */
43770 +       reg = config_readb(socket, TI1250_MULTIMEDIA_CTL);
43771 +       reg |= TI1250_MMC_ZVOUTEN;      /* ZV bus enable */
43772  
43773         if(PCI_FUNC(socket->dev->devfn)==1)
43774                 shift = 1;
43775 @@ -204,12 +222,11 @@
43776                 reg &= ~(1<<shift);     /* Socket zoon video off */
43777         }
43778  
43779 -       config_writeb(socket, 0x84, reg);
43780 +       config_writeb(socket, TI1250_MULTIMEDIA_CTL, reg);
43781  }
43782  
43783 -static void ti_set_zv(struct pcmcia_socket *sock)
43784 +static void ti_set_zv(struct yenta_socket *socket)
43785  {
43786 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
43787         if(socket->dev->vendor == PCI_VENDOR_ID_TI)
43788         {
43789                 switch(socket->dev->device)
43790 @@ -218,24 +235,16 @@
43791                         case PCI_DEVICE_ID_TI_1220:
43792                         case PCI_DEVICE_ID_TI_1221:
43793                         case PCI_DEVICE_ID_TI_1225:
43794 -                               sock->zoom_video = ti_zoom_video;
43795 +                               socket->socket.zoom_video = ti_zoom_video;
43796                                 break;  
43797                         case PCI_DEVICE_ID_TI_1250:
43798                         case PCI_DEVICE_ID_TI_1251A:
43799                         case PCI_DEVICE_ID_TI_1251B:
43800                         case PCI_DEVICE_ID_TI_1450:
43801 -                               sock->zoom_video = ti1250_zoom_video;
43802 +                               socket->socket.zoom_video = ti1250_zoom_video;
43803                 }
43804         }
43805  }
43806 -static int ti_init(struct pcmcia_socket *sock)
43807 -{
43808 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
43809 -       yenta_init(sock);
43810 -       ti_set_zv(sock);
43811 -       ti_intctl(socket);
43812 -       return 0;
43813 -}
43814  
43815  
43816  /*
43817 @@ -250,6 +259,18 @@
43818   *   This makes us correctly get PCI CSC interrupt
43819   *   events.
43820   */
43821 +static int ti_init(struct yenta_socket *socket)
43822 +{
43823 +       u8 new, reg = exca_readb(socket, I365_INTCTL);
43824 +
43825 +       new = reg & ~I365_INTR_ENA;
43826 +       if (socket->cb_irq)
43827 +               new |= I365_INTR_ENA;
43828 +       if (new != reg)
43829 +               exca_writeb(socket, I365_INTCTL, new);
43830 +       return 0;
43831 +}
43832 +
43833  static int ti_override(struct yenta_socket *socket)
43834  {
43835         u8 new, reg = exca_readb(socket, I365_INTCTL);
43836 @@ -258,6 +279,8 @@
43837         if (new != reg)
43838                 exca_writeb(socket, I365_INTCTL, new);
43839  
43840 +       ti_set_zv(socket);
43841 +
43842  #if 0
43843         /*
43844          * If ISA interrupts don't work, then fall back to routing card
43845 @@ -285,83 +308,85 @@
43846         }
43847  #endif
43848  
43849 -       socket->socket.ops->init = ti_init;
43850 -       return 0;
43851 -}
43852 -
43853 -#define ti_sysctl(socket)      ((socket)->private[0])
43854 -#define ti_cardctl(socket)     ((socket)->private[1])
43855 -#define ti_devctl(socket)      ((socket)->private[2])
43856 -#define ti_diag(socket)                ((socket)->private[3])
43857 -#define ti_irqmux(socket)      ((socket)->private[4])
43858 -
43859 -
43860 -static int ti113x_init(struct pcmcia_socket *sock)
43861 -{
43862 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
43863 -       yenta_init(sock);
43864 -       ti_set_zv(sock);
43865 -
43866 -       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
43867 -       config_writeb(socket, TI113X_CARD_CONTROL, ti_cardctl(socket));
43868 -       config_writeb(socket, TI113X_DEVICE_CONTROL, ti_devctl(socket));
43869 -       ti_intctl(socket);
43870         return 0;
43871  }
43872  
43873  static int ti113x_override(struct yenta_socket *socket)
43874  {
43875 -       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
43876 -       ti_cardctl(socket) = config_readb(socket, TI113X_CARD_CONTROL);
43877 -       ti_devctl(socket) = config_readb(socket, TI113X_DEVICE_CONTROL);
43878 +       u8 cardctl;
43879  
43880 -       ti_cardctl(socket) &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC);
43881 +       cardctl = config_readb(socket, TI113X_CARD_CONTROL);
43882 +       cardctl &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC);
43883         if (socket->cb_irq)
43884 -               ti_cardctl(socket) |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ;
43885 -       ti_override(socket);
43886 -       socket->socket.ops->init = ti113x_init;
43887 -       return 0;
43888 +               cardctl |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ;
43889 +       config_writeb(socket, TI113X_CARD_CONTROL, cardctl);
43890 +
43891 +       return ti_override(socket);
43892  }
43893  
43894  
43895 -static int ti1250_init(struct pcmcia_socket *sock)
43896 +static int ti12xx_override(struct yenta_socket *socket)
43897  {
43898 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
43899 -       ti113x_init(sock);
43900 -       ti_irqmux(socket) = config_readl(socket, TI122X_IRQMUX);
43901 -#if 0
43902 -       ti_irqmux(socket) = (ti_irqmux(socket) & ~0x0f) | 0x02; /* route INTA */
43903 -       if (!(ti_sysctl(socket) & TI122X_SCR_INTRTIE))
43904 -               ti_irqmux(socket) |= 0x20; /* route INTB */
43905 -#endif
43906 -       
43907 -       config_writel(socket, TI122X_IRQMUX, ti_irqmux(socket));
43908 -               
43909 -       config_writeb(socket, TI1250_DIAGNOSTIC, ti_diag(socket));
43910 -       return 0;
43911 +       u32 val;
43912 +
43913 +       /* make sure that memory burst is active */
43914 +       val = config_readl(socket, TI113X_SYSTEM_CONTROL);
43915 +       if (!(val & TI122X_SCR_MRBURSTUP)) {
43916 +               printk(KERN_INFO "Yenta: Enabling burst memory read transactions\n");
43917 +               val |= TI122X_SCR_MRBURSTUP;
43918 +               config_writel(socket, TI113X_SYSTEM_CONTROL, val);
43919 +       }
43920 +
43921 +       /*
43922 +        * Yenta expects controllers to use CSCINT to route
43923 +        * CSC interrupts to PCI rather than INTVAL.
43924 +        */
43925 +       val = config_readb(socket, TI1250_DIAGNOSTIC);
43926 +       printk(KERN_INFO "Yenta: Using %s to route CSC interrupts to PCI\n",
43927 +               (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL");
43928 +       printk(KERN_INFO "Yenta: Routing CardBus interrupts to %s\n",
43929 +               (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA");
43930 +
43931 +       return ti_override(socket);
43932  }
43933  
43934 +
43935  static int ti1250_override(struct yenta_socket *socket)
43936  {
43937 -       ti_diag(socket) = config_readb(socket, TI1250_DIAGNOSTIC);
43938 +       u8 old, diag;
43939  
43940 -       ti_diag(socket) &= ~(TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ);
43941 +       old = config_readb(socket, TI1250_DIAGNOSTIC);
43942 +       diag = old & ~(TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ);
43943         if (socket->cb_irq)
43944 -               ti_diag(socket) |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ;
43945 -       ti113x_override(socket);
43946 -       socket->socket.ops->init = ti1250_init;
43947 -       return 0;
43948 -}
43949 +               diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ;
43950  
43951 +       if (diag != old) {
43952 +               printk(KERN_INFO "Yenta: adjusting diagnostic: %02x -> %02x\n",
43953 +                       old, diag);
43954 +               config_writeb(socket, TI1250_DIAGNOSTIC, diag);
43955 +       }
43956  
43957 -static int ti12xx_override(struct yenta_socket *socket)
43958 -{
43959 -       /* make sure that memory burst is active */
43960 -       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
43961 -       ti_sysctl(socket) |= TI122X_SCR_MRBURSTUP;
43962 -       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
43963 +#if 0
43964 +       /*
43965 +        * This is highly machine specific, and we should NOT touch
43966 +        * this register - we have no knowledge how the hardware
43967 +        * is actually wired.
43968 +        *
43969 +        * If we're going to do this, we should probably look into
43970 +        * using the subsystem IDs.
43971 +        *
43972 +        * On ThinkPad 380XD, this changes MFUNC0 from the ISA IRQ3
43973 +        * output (which it is) to IRQ2.  We also change MFUNC1
43974 +        * from ISA IRQ4 to IRQ6.
43975 +        */
43976 +       irqmux = config_readl(socket, TI122X_IRQMUX);
43977 +       irqmux = (irqmux & ~0x0f) | 0x02; /* route INTA */
43978 +       if (!(ti_sysctl(socket) & TI122X_SCR_INTRTIE))
43979 +               irqmux = (irqmux & ~0xf0) | 0x20; /* route INTB */
43980 +       config_writel(socket, TI122X_IRQMUX, irqmux);
43981 +#endif
43982  
43983 -       return ti113x_override(socket);
43984 +       return ti12xx_override(socket);
43985  }
43986  
43987  #endif /* CONFIG_CARDBUS */
43988 diff -Nru a/drivers/pcmcia/topic.h b/drivers/pcmcia/topic.h
43989 --- a/drivers/pcmcia/topic.h    Fri Oct 18 16:11:25 2002
43990 +++ b/drivers/pcmcia/topic.h    Wed Aug 27 13:19:32 2003
43991 @@ -31,20 +31,7 @@
43992  #ifndef _LINUX_TOPIC_H
43993  #define _LINUX_TOPIC_H
43994  
43995 -#ifndef PCI_VENDOR_ID_TOSHIBA
43996 -#define PCI_VENDOR_ID_TOSHIBA          0x1179
43997 -#endif
43998 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC95_A
43999 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_A        0x0603
44000 -#endif
44001 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC95_B
44002 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_B        0x060a
44003 -#endif
44004 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC97
44005 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC97  0x060f
44006 -#endif
44007 -
44008 -/* Register definitions for Toshiba ToPIC95 controllers */
44009 +/* Register definitions for Toshiba ToPIC95/97/100 controllers */
44010  
44011  #define TOPIC_SOCKET_CONTROL           0x0090  /* 32 bit */
44012  #define  TOPIC_SCR_IRQSEL              0x00000001
44013 @@ -92,5 +79,62 @@
44014  #define  TOPIC97_RCR_RI_DISABLE                0x00000004
44015  #define  TOPIC97_RCR_CAUDIO_OFF                0x00000002
44016  #define  TOPIC_RCR_CAUDIO_INVERT       0x00000001
44017 +
44018 +#define TOPIC97_MISC1                  0x00ad  /* 8bit */
44019 +#define  TOPIC97_MISC1_CLOCKRUN_ENABLE 0x80
44020 +#define  TOPIC97_MISC1_CLOCKRUN_MODE   0x40
44021 +#define  TOPIC97_MISC1_DETECT_REQ_ENA  0x10
44022 +#define  TOPIC97_MISC1_SCK_CLEAR_DIS   0x04
44023 +#define  TOPIC97_MISC1_R2_LOW_ENABLE   0x10
44024 +
44025 +#define TOPIC97_MISC2                  0x00ae  /* 8 bit */
44026 +#define  TOPIC97_MISC2_SPWRCLK_MASK    0x70
44027 +#define  TOPIC97_MISC2_SPWRMOD         0x08
44028 +#define  TOPIC97_MISC2_SPWR_ENABLE     0x04
44029 +#define  TOPIC97_MISC2_ZV_MODE         0x02
44030 +#define  TOPIC97_MISC2_ZV_ENABLE       0x01
44031 +
44032 +#define TOPIC97_ZOOM_VIDEO_CONTROL     0x009c  /* 8 bit */
44033 +#define  TOPIC97_ZV_CONTROL_ENABLE     0x01
44034 +
44035 +#define TOPIC97_AUDIO_VIDEO_SWITCH     0x003c  /* 8 bit */
44036 +#define  TOPIC97_AVS_AUDIO_CONTROL     0x02
44037 +#define  TOPIC97_AVS_VIDEO_CONTROL     0x01
44038 +
44039 +
44040 +static void topic97_zoom_video(struct pcmcia_socket *sock, int onoff)
44041 +{
44042 +       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
44043 +       u8 reg_zv, reg;
44044 +
44045 +       reg_zv = config_readb(socket, TOPIC97_ZOOM_VIDEO_CONTROL);
44046 +       if (onoff) {
44047 +               reg_zv |= TOPIC97_ZV_CONTROL_ENABLE;
44048 +               config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
44049 +
44050 +               reg = config_readb(socket, TOPIC97_MISC2);
44051 +               reg |= TOPIC97_MISC2_ZV_ENABLE;
44052 +               config_writeb(socket, TOPIC97_MISC2, reg);
44053 +
44054 +               /* not sure this is needed, doc is unclear */
44055 +#if 0
44056 +               reg = config_readb(socket, TOPIC97_AUDIO_VIDEO_SWITCH);
44057 +               reg |= TOPIC97_AVS_AUDIO_CONTROL | TOPIC97_AVS_VIDEO_CONTROL;
44058 +               config_writeb(socket, TOPIC97_AUDIO_VIDEO_SWITCH, reg);
44059 +#endif
44060 +       }
44061 +       else {
44062 +               reg_zv &= ~TOPIC97_ZV_CONTROL_ENABLE;
44063 +               config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
44064 +       }
44065 +
44066 +}
44067 +
44068 +static int topic97_override(struct yenta_socket *socket)
44069 +{
44070 +       /* ToPIC97/100 support ZV */
44071 +       socket->socket.zoom_video = topic97_zoom_video;
44072 +       return 0;
44073 +}
44074  
44075  #endif /* _LINUX_TOPIC_H */
44076 diff -Nru a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
44077 --- a/drivers/pcmcia/yenta_socket.c     Thu Aug 14 16:53:49 2003
44078 +++ b/drivers/pcmcia/yenta_socket.c     Wed Aug 27 13:19:32 2003
44079 @@ -443,73 +443,6 @@
44080         add_timer(&socket->poll_timer);
44081  }
44082  
44083 -/*
44084 - * Only probe "regular" interrupts, don't
44085 - * touch dangerous spots like the mouse irq,
44086 - * because there are mice that apparently
44087 - * get really confused if they get fondled
44088 - * too intimately.
44089 - *
44090 - * Default to 11, 10, 9, 7, 6, 5, 4, 3.
44091 - */
44092 -static u32 isa_interrupts = 0x0ef8;
44093 -
44094 -static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
44095 -{
44096 -       int i;
44097 -       unsigned long val;
44098 -       u16 bridge_ctrl;
44099 -       u32 mask;
44100 -
44101 -       /* Set up ISA irq routing to probe the ISA irqs.. */
44102 -       bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
44103 -       if (!(bridge_ctrl & CB_BRIDGE_INTR)) {
44104 -               bridge_ctrl |= CB_BRIDGE_INTR;
44105 -               config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
44106 -       }
44107 -
44108 -       /*
44109 -        * Probe for usable interrupts using the force
44110 -        * register to generate bogus card status events.
44111 -        */
44112 -       cb_writel(socket, CB_SOCKET_EVENT, -1);
44113 -       cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
44114 -       exca_writeb(socket, I365_CSCINT, 0);
44115 -       val = probe_irq_on() & isa_irq_mask;
44116 -       for (i = 1; i < 16; i++) {
44117 -               if (!((val >> i) & 1))
44118 -                       continue;
44119 -               exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4));
44120 -               cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
44121 -               udelay(100);
44122 -               cb_writel(socket, CB_SOCKET_EVENT, -1);
44123 -       }
44124 -       cb_writel(socket, CB_SOCKET_MASK, 0);
44125 -       exca_writeb(socket, I365_CSCINT, 0);
44126 -       
44127 -       mask = probe_irq_mask(val) & 0xffff;
44128 -
44129 -       bridge_ctrl &= ~CB_BRIDGE_INTR;
44130 -       config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
44131 -
44132 -       return mask;
44133 -}
44134 -
44135 -/*
44136 - * Set static data that doesn't need re-initializing..
44137 - */
44138 -static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
44139 -{
44140 -       socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
44141 -       socket->socket.map_size = 0x1000;
44142 -       socket->socket.pci_irq = socket->cb_irq;
44143 -       socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
44144 -       socket->socket.cb_dev = socket->dev;
44145 -
44146 -       printk("Yenta IRQ list %04x, PCI irq%d\n", socket->socket.irq_mask, socket->cb_irq);
44147 -}
44148 -
44149 -
44150  static void yenta_clear_maps(struct yenta_socket *socket)
44151  {
44152         int i;
44153 @@ -528,42 +461,13 @@
44154         }
44155  }
44156  
44157 -/*
44158 - * Initialize the standard cardbus registers
44159 - */
44160 -static void yenta_config_init(struct yenta_socket *socket)
44161 +/* Called at resume and initialization events */
44162 +static int yenta_sock_init(struct pcmcia_socket *sock)
44163  {
44164 +       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
44165         u16 bridge;
44166 -       struct pci_dev *dev = socket->dev;
44167 -
44168 -       pci_set_power_state(socket->dev, 0);
44169 -
44170 -       config_writel(socket, CB_LEGACY_MODE_BASE, 0);
44171 -       config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start);
44172 -       config_writew(socket, PCI_COMMAND,
44173 -                       PCI_COMMAND_IO |
44174 -                       PCI_COMMAND_MEMORY |
44175 -                       PCI_COMMAND_MASTER |
44176 -                       PCI_COMMAND_WAIT);
44177 -
44178 -       /* MAGIC NUMBERS! Fixme */
44179 -       config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
44180 -       config_writeb(socket, PCI_LATENCY_TIMER, 168);
44181 -       config_writel(socket, PCI_PRIMARY_BUS,
44182 -               (176 << 24) |                      /* sec. latency timer */
44183 -               (dev->subordinate->subordinate << 16) | /* subordinate bus */
44184 -               (dev->subordinate->secondary << 8) |  /* secondary bus */
44185 -               dev->subordinate->primary);                /* primary bus */
44186  
44187 -       /*
44188 -        * Set up the bridging state:
44189 -        *  - enable write posting.
44190 -        *  - memory window 0 prefetchable, window 1 non-prefetchable
44191 -        *  - PCI interrupts enabled if a PCI interrupt exists..
44192 -        */
44193 -       bridge = config_readw(socket, CB_BRIDGE_CONTROL);
44194 -       bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_INTR | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
44195 -       bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN;
44196 +       bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~CB_BRIDGE_INTR;
44197         if (!socket->cb_irq)
44198                 bridge |= CB_BRIDGE_INTR;
44199         config_writew(socket, CB_BRIDGE_CONTROL, bridge);
44200 @@ -573,41 +477,27 @@
44201  
44202         /* Redo card voltage interrogation */
44203         cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST);
44204 -}
44205  
44206 -/* Called at resume and initialization events */
44207 -static int yenta_init(struct pcmcia_socket *sock)
44208 -{
44209 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
44210 -       yenta_config_init(socket);
44211         yenta_clear_maps(socket);
44212  
44213 -       /* Re-enable interrupts */
44214 +       if (socket->type && socket->type->sock_init)
44215 +               socket->type->sock_init(socket);
44216 +
44217 +       /* Re-enable CSC interrupts */
44218         cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
44219 +
44220         return 0;
44221  }
44222  
44223 -static int yenta_suspend(struct pcmcia_socket *sock)
44224 +static int yenta_sock_suspend(struct pcmcia_socket *sock)
44225  {
44226         struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
44227  
44228         yenta_set_socket(sock, &dead_socket);
44229  
44230 -       /* Disable interrupts */
44231 +       /* Disable CSC interrupts */
44232         cb_writel(socket, CB_SOCKET_MASK, 0x0);
44233  
44234 -       /*
44235 -        * This does not work currently. The controller
44236 -        * loses too much information during D3 to come up
44237 -        * cleanly. We should probably fix yenta_init()
44238 -        * to update all the critical registers, notably
44239 -        * the IO and MEM bridging region data.. That is
44240 -        * something that pci_set_power_state() should
44241 -        * probably know about bridges anyway.
44242 -        *
44243 -       pci_set_power_state(socket->dev, 3);
44244 -        */
44245 -
44246         return 0;
44247  }
44248  
44249 @@ -758,8 +648,8 @@
44250  
44251  
44252  static struct pccard_operations yenta_socket_operations = {
44253 -       .init                   = yenta_init,
44254 -       .suspend                = yenta_suspend,
44255 +       .init                   = yenta_sock_init,
44256 +       .suspend                = yenta_sock_suspend,
44257         .get_status             = yenta_get_status,
44258         .get_socket             = yenta_get_socket,
44259         .set_socket             = yenta_set_socket,
44260 @@ -770,52 +660,165 @@
44261  
44262  #include "ti113x.h"
44263  #include "ricoh.h"
44264 +#include "topic.h"
44265 +
44266 +enum {
44267 +       CARDBUS_TYPE_DEFAULT = -1,
44268 +       CARDBUS_TYPE_TI,
44269 +       CARDBUS_TYPE_TI113X,
44270 +       CARDBUS_TYPE_TI12XX,
44271 +       CARDBUS_TYPE_TI1250,
44272 +       CARDBUS_TYPE_RICOH,
44273 +       CARDBUS_TYPE_TOPIC97
44274 +};
44275  
44276  /*
44277   * Different cardbus controllers have slightly different
44278   * initialization sequences etc details. List them here..
44279   */
44280 -#define PD(x,y) PCI_VENDOR_ID_##x, PCI_DEVICE_ID_##x##_##y
44281 -struct cardbus_override_struct {
44282 -       unsigned short vendor;
44283 -       unsigned short device;
44284 -       int (*override) (struct yenta_socket *socket);
44285 -} cardbus_override[] = {
44286 -       { PD(TI,1031),  &ti_override },
44287 -
44288 -       /* TBD: Check if these TI variants can use more
44289 -        * advanced overrides instead */
44290 -       { PD(TI,1210),  &ti_override },
44291 -       { PD(TI,1211),  &ti_override },
44292 -       { PD(TI,1251A), &ti_override },
44293 -       { PD(TI,1251B), &ti_override },
44294 -       { PD(TI,1420),  &ti_override },
44295 -       { PD(TI,1450),  &ti_override },
44296 -       { PD(TI,4410),  &ti_override },
44297 -       { PD(TI,4451),  &ti_override },
44298 -
44299 -       { PD(TI,1130),  &ti113x_override },
44300 -       { PD(TI,1131),  &ti113x_override },
44301 -
44302 -       { PD(TI,1220),  &ti12xx_override },
44303 -       { PD(TI,1221),  &ti12xx_override },
44304 -       { PD(TI,1225),  &ti12xx_override },
44305 -       { PD(TI,1520),  &ti12xx_override },
44306 -
44307 -       { PD(TI,1250),  &ti1250_override },
44308 -       { PD(TI,1410),  &ti1250_override },
44309 -
44310 -       { PD(RICOH,RL5C465), &ricoh_override },
44311 -       { PD(RICOH,RL5C466), &ricoh_override },
44312 -       { PD(RICOH,RL5C475), &ricoh_override },
44313 -       { PD(RICOH,RL5C476), &ricoh_override },
44314 -       { PD(RICOH,RL5C478), &ricoh_override },
44315 -
44316 -       { }, /* all zeroes */
44317 +struct cardbus_type cardbus_type[] = {
44318 +       [CARDBUS_TYPE_TI]       = {
44319 +               .override       = ti_override,
44320 +               .save_state     = ti_save_state,
44321 +               .restore_state  = ti_restore_state,
44322 +               .sock_init      = ti_init,
44323 +       },
44324 +       [CARDBUS_TYPE_TI113X]   = {
44325 +               .override       = ti113x_override,
44326 +               .save_state     = ti_save_state,
44327 +               .restore_state  = ti_restore_state,
44328 +               .sock_init      = ti_init,
44329 +       },
44330 +       [CARDBUS_TYPE_TI12XX]   = {
44331 +               .override       = ti12xx_override,
44332 +               .save_state     = ti_save_state,
44333 +               .restore_state  = ti_restore_state,
44334 +               .sock_init      = ti_init,
44335 +       },
44336 +       [CARDBUS_TYPE_TI1250]   = {
44337 +               .override       = ti1250_override,
44338 +               .save_state     = ti_save_state,
44339 +               .restore_state  = ti_restore_state,
44340 +               .sock_init      = ti_init,
44341 +       },
44342 +       [CARDBUS_TYPE_RICOH]    = {
44343 +               .override       = ricoh_override,
44344 +               .save_state     = ricoh_save_state,
44345 +               .restore_state  = ricoh_restore_state,
44346 +       },
44347 +       [CARDBUS_TYPE_TOPIC97]  = {
44348 +               .override       = topic97_override,
44349 +       },
44350  };
44351  
44352  
44353  /*
44354 + * Only probe "regular" interrupts, don't
44355 + * touch dangerous spots like the mouse irq,
44356 + * because there are mice that apparently
44357 + * get really confused if they get fondled
44358 + * too intimately.
44359 + *
44360 + * Default to 11, 10, 9, 7, 6, 5, 4, 3.
44361 + */
44362 +static u32 isa_interrupts = 0x0ef8;
44363 +
44364 +static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
44365 +{
44366 +       int i;
44367 +       unsigned long val;
44368 +       u16 bridge_ctrl;
44369 +       u32 mask;
44370 +
44371 +       /* Set up ISA irq routing to probe the ISA irqs.. */
44372 +       bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
44373 +       if (!(bridge_ctrl & CB_BRIDGE_INTR)) {
44374 +               bridge_ctrl |= CB_BRIDGE_INTR;
44375 +               config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
44376 +       }
44377 +
44378 +       /*
44379 +        * Probe for usable interrupts using the force
44380 +        * register to generate bogus card status events.
44381 +        */
44382 +       cb_writel(socket, CB_SOCKET_EVENT, -1);
44383 +       cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
44384 +       exca_writeb(socket, I365_CSCINT, 0);
44385 +       val = probe_irq_on() & isa_irq_mask;
44386 +       for (i = 1; i < 16; i++) {
44387 +               if (!((val >> i) & 1))
44388 +                       continue;
44389 +               exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4));
44390 +               cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
44391 +               udelay(100);
44392 +               cb_writel(socket, CB_SOCKET_EVENT, -1);
44393 +       }
44394 +       cb_writel(socket, CB_SOCKET_MASK, 0);
44395 +       exca_writeb(socket, I365_CSCINT, 0);
44396 +
44397 +       mask = probe_irq_mask(val) & 0xffff;
44398 +
44399 +       bridge_ctrl &= ~CB_BRIDGE_INTR;
44400 +       config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
44401 +
44402 +       return mask;
44403 +}
44404 +
44405 +/*
44406 + * Set static data that doesn't need re-initializing..
44407 + */
44408 +static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
44409 +{
44410 +       socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
44411 +       socket->socket.map_size = 0x1000;
44412 +       socket->socket.pci_irq = socket->cb_irq;
44413 +       socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
44414 +       socket->socket.cb_dev = socket->dev;
44415 +
44416 +       printk(KERN_INFO "Yenta: ISA IRQ list %04x, PCI irq%d\n",
44417 +              socket->socket.irq_mask, socket->cb_irq);
44418 +}
44419 +
44420 +/*
44421 + * Initialize the standard cardbus registers
44422 + */
44423 +static void yenta_config_init(struct yenta_socket *socket)
44424 +{
44425 +       u16 bridge;
44426 +       struct pci_dev *dev = socket->dev;
44427 +
44428 +       pci_set_power_state(socket->dev, 0);
44429 +
44430 +       config_writel(socket, CB_LEGACY_MODE_BASE, 0);
44431 +       config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start);
44432 +       config_writew(socket, PCI_COMMAND,
44433 +                       PCI_COMMAND_IO |
44434 +                       PCI_COMMAND_MEMORY |
44435 +                       PCI_COMMAND_MASTER |
44436 +                       PCI_COMMAND_WAIT);
44437 +
44438 +       /* MAGIC NUMBERS! Fixme */
44439 +       config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
44440 +       config_writeb(socket, PCI_LATENCY_TIMER, 168);
44441 +       config_writel(socket, PCI_PRIMARY_BUS,
44442 +               (176 << 24) |                      /* sec. latency timer */
44443 +               (dev->subordinate->subordinate << 16) | /* subordinate bus */
44444 +               (dev->subordinate->secondary << 8) |  /* secondary bus */
44445 +               dev->subordinate->primary);                /* primary bus */
44446 +
44447 +       /*
44448 +        * Set up the bridging state:
44449 +        *  - enable write posting.
44450 +        *  - memory window 0 prefetchable, window 1 non-prefetchable
44451 +        *  - PCI interrupts enabled if a PCI interrupt exists..
44452 +        */
44453 +       bridge = config_readw(socket, CB_BRIDGE_CONTROL);
44454 +       bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_INTR | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
44455 +       bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN | CB_BRIDGE_INTR;
44456 +       config_writew(socket, CB_BRIDGE_CONTROL, bridge);
44457 +}
44458 +
44459 +/*
44460   * Initialize a cardbus controller. Make sure we have a usable
44461   * interrupt, and that we can map the cardbus area. Fill in the
44462   * socket information structure..
44463 @@ -823,7 +826,6 @@
44464  static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_id *id)
44465  {
44466         struct yenta_socket *socket;
44467 -       struct cardbus_override_struct *d;
44468         int ret;
44469         
44470         socket = kmalloc(sizeof(struct yenta_socket), GFP_KERNEL);
44471 @@ -887,14 +889,13 @@
44472         socket->cb_irq = dev->irq;
44473  
44474         /* Do we have special options for the device? */
44475 -       d = cardbus_override;
44476 -       while (d->override) {
44477 -               if ((dev->vendor == d->vendor) && (dev->device == d->device)) {
44478 -                       ret = d->override(socket);
44479 -                       if (ret < 0)
44480 -                               goto unmap;
44481 -               }
44482 -               d++;
44483 +       if (id->driver_data != CARDBUS_TYPE_DEFAULT &&
44484 +           id->driver_data < ARRAY_SIZE(cardbus_type)) {
44485 +               socket->type = &cardbus_type[id->driver_data];
44486 +
44487 +               ret = socket->type->override(socket);
44488 +               if (ret < 0)
44489 +                       goto unmap;
44490         }
44491  
44492         /* We must finish initialization here */
44493 @@ -933,25 +934,97 @@
44494  
44495  static int yenta_dev_suspend (struct pci_dev *dev, u32 state)
44496  {
44497 -       return pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
44498 +       struct yenta_socket *socket = pci_get_drvdata(dev);
44499 +       int ret;
44500 +
44501 +       ret = pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
44502 +
44503 +       if (socket) {
44504 +               if (socket->type && socket->type->save_state)
44505 +                       socket->type->save_state(socket);
44506 +
44507 +               /* FIXME: pci_save_state needs to have a better interface */
44508 +               pci_save_state(dev, socket->saved_state);
44509 +               pci_read_config_dword(dev, 16*4, &socket->saved_state[16]);
44510 +               pci_read_config_dword(dev, 17*4, &socket->saved_state[17]);
44511 +               pci_set_power_state(dev, 3);
44512 +       }
44513 +
44514 +       return ret;
44515  }
44516  
44517  
44518  static int yenta_dev_resume (struct pci_dev *dev)
44519  {
44520 +       struct yenta_socket *socket = pci_get_drvdata(dev);
44521 +
44522 +       if (socket) {
44523 +               pci_set_power_state(dev, 0);
44524 +               /* FIXME: pci_restore_state needs to have a better interface */
44525 +               pci_restore_state(dev, socket->saved_state);
44526 +               pci_write_config_dword(dev, 16*4, socket->saved_state[16]);
44527 +               pci_write_config_dword(dev, 17*4, socket->saved_state[17]);
44528 +
44529 +               if (socket->type && socket->type->restore_state)
44530 +                       socket->type->restore_state(socket);
44531 +       }
44532 +
44533         return pcmcia_socket_dev_resume(&dev->dev, RESUME_RESTORE_STATE);
44534  }
44535  
44536  
44537 -static struct pci_device_id yenta_table [] = { {
44538 -       .class          = PCI_CLASS_BRIDGE_CARDBUS << 8,
44539 -       .class_mask     = ~0,
44540 -
44541 -       .vendor         = PCI_ANY_ID,
44542 -       .device         = PCI_ANY_ID,
44543 -       .subvendor      = PCI_ANY_ID,
44544 -       .subdevice      = PCI_ANY_ID,
44545 -}, { /* all zeroes */ }
44546 +#define CB_ID(vend,dev,type)                           \
44547 +       {                                               \
44548 +               .vendor         = vend,                 \
44549 +               .device         = dev,                  \
44550 +               .subvendor      = PCI_ANY_ID,           \
44551 +               .subdevice      = PCI_ANY_ID,           \
44552 +               .class          = PCI_CLASS_BRIDGE_CARDBUS << 8, \
44553 +               .class_mask     = ~0,                   \
44554 +               .driver_data    = CARDBUS_TYPE_##type,  \
44555 +       }
44556 +
44557 +static struct pci_device_id yenta_table [] = {
44558 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1031, TI),
44559 +
44560 +       /*
44561 +        * TBD: Check if these TI variants can use more
44562 +        * advanced overrides instead.  (I can't get the
44563 +        * data sheets for these devices. --rmk)
44564 +        */
44565 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI),
44566 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251B, TI),
44567 +
44568 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X),
44569 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1131, TI113X),
44570 +
44571 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, TI12XX),
44572 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1220, TI12XX),
44573 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1221, TI12XX),
44574 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1225, TI12XX),
44575 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251A, TI12XX),
44576 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420, TI12XX),
44577 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1450, TI12XX),
44578 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520, TI12XX),
44579 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4410, TI12XX),
44580 +//     CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4450, TI12XX),
44581 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4451, TI12XX),
44582 +
44583 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250),
44584 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250),
44585 +
44586 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH),
44587 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH),
44588 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH),
44589 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH),
44590 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH),
44591 +
44592 +       CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97),
44593 +       CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97),
44594 +
44595 +       /* match any cardbus bridge */
44596 +       CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT),
44597 +       { /* all zeroes */ }
44598  };
44599  MODULE_DEVICE_TABLE(pci, yenta_table);
44600  
44601 diff -Nru a/drivers/pcmcia/yenta_socket.h b/drivers/pcmcia/yenta_socket.h
44602 --- a/drivers/pcmcia/yenta_socket.h     Mon Jun 30 13:33:00 2003
44603 +++ b/drivers/pcmcia/yenta_socket.h     Wed Aug 27 12:42:53 2003
44604 @@ -95,6 +95,15 @@
44605   */
44606  #define CB_MEM_PAGE(map)       (0x40 + (map))
44607  
44608 +struct yenta_socket;
44609 +
44610 +struct cardbus_type {
44611 +       int     (*override)(struct yenta_socket *);
44612 +       void    (*save_state)(struct yenta_socket *);
44613 +       void    (*restore_state)(struct yenta_socket *);
44614 +       int     (*sock_init)(struct yenta_socket *);
44615 +};
44616 +
44617  struct yenta_socket {
44618         struct pci_dev *dev;
44619         int cb_irq, io_irq;
44620 @@ -102,9 +111,13 @@
44621         struct timer_list poll_timer;
44622  
44623         struct pcmcia_socket socket;
44624 +       struct cardbus_type *type;
44625  
44626         /* A few words of private data for special stuff of overrides... */
44627         unsigned int private[8];
44628 +
44629 +       /* PCI saved state */
44630 +       u32 saved_state[18];
44631  };
44632  
44633  
44634 diff -Nru a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c
44635 --- a/drivers/s390/char/tape_char.c     Mon May 26 12:20:47 2003
44636 +++ b/drivers/s390/char/tape_char.c     Tue Aug 26 09:25:41 2003
44637 @@ -238,14 +238,14 @@
44638         struct tape_device *device;
44639         int minor, rc;
44640  
44641 -       if (major(filp->f_dentry->d_inode->i_rdev) != tapechar_major)
44642 +       if (imajor(filp->f_dentry->d_inode) != tapechar_major)
44643                 return -ENODEV;
44644 -       minor = minor(filp->f_dentry->d_inode->i_rdev);
44645 +       minor = iminor(filp->f_dentry->d_inode);
44646         device = tape_get_device(minor / TAPE_MINORS_PER_DEV);
44647         if (IS_ERR(device)) {
44648                 return PTR_ERR(device);
44649         }
44650 -       DBF_EVENT(6, "TCHAR:open: %x\n", minor(inode->i_rdev));
44651 +       DBF_EVENT(6, "TCHAR:open: %x\n", iminor(inode));
44652         rc = tape_open(device);
44653         if (rc == 0) {
44654                 rc = tape_assign(device);
44655 @@ -269,7 +269,7 @@
44656         struct tape_device *device;
44657  
44658         device = (struct tape_device *) filp->private_data;
44659 -       DBF_EVENT(6, "TCHAR:release: %x\n", minor(inode->i_rdev));
44660 +       DBF_EVENT(6, "TCHAR:release: %x\n", iminor(inode));
44661  #if 0
44662         // FIXME: this is broken. Either MTWEOF/MTWEOF/MTBSR is done
44663         // EVERYTIME the user switches from write to something different
44664 @@ -281,7 +281,7 @@
44665         /*
44666          * If this is the rewinding tape minor then rewind.
44667          */
44668 -       if ((minor(inode->i_rdev) & 1) != 0)
44669 +       if ((iminor(inode) & 1) != 0)
44670                 tape_mtop(device, MTREW, 1);
44671         if (device->char_data.idal_buf != NULL) {
44672                 idal_buffer_free(device->char_data.idal_buf);
44673 diff -Nru a/drivers/s390/char/tubio.h b/drivers/s390/char/tubio.h
44674 --- a/drivers/s390/char/tubio.h Wed Jun 11 12:32:58 2003
44675 +++ b/drivers/s390/char/tubio.h Tue Aug 26 09:25:41 2003
44676 @@ -377,7 +377,7 @@
44677   */
44678  extern inline tub_t *INODE2TUB(struct inode *ip)
44679  {
44680 -       unsigned int minor = minor(ip->i_rdev);
44681 +       unsigned int minor = iminor(ip);
44682         tub_t *tubp = NULL;
44683         if (minor == 0 && current->tty) {
44684                 if (current->tty->driver == tty3270_driver)
44685 diff -Nru a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
44686 --- a/drivers/s390/net/cu3088.c Sun May 25 17:00:00 2003
44687 +++ b/drivers/s390/net/cu3088.c Tue Aug 19 09:22:46 2003
44688 @@ -64,7 +64,7 @@
44689  group_write(struct device_driver *drv, const char *buf, size_t count)
44690  {
44691         const char *start, *end;
44692 -       char bus_ids[2][BUS_ID_SIZE], *argv[2];
44693 +       char bus_ids[2][BUS_ID_SIZE+1], *argv[2];
44694         int i;
44695         int ret;
44696         struct ccwgroup_driver *cdrv;
44697 @@ -79,7 +79,7 @@
44698  
44699                 if (!(end = strchr(start, delim[i])))
44700                         return count;
44701 -               len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start);
44702 +               len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start)+1;
44703                 strlcpy (bus_ids[i], start, len);
44704                 argv[i] = bus_ids[i];
44705                 start = end + 1;
44706 diff -Nru a/drivers/s390/net/qeth.c b/drivers/s390/net/qeth.c
44707 --- a/drivers/s390/net/qeth.c   Thu Jul 17 10:27:34 2003
44708 +++ b/drivers/s390/net/qeth.c   Sun Aug 31 16:14:08 2003
44709 @@ -9765,19 +9765,19 @@
44710  };
44711  
44712  static struct file_operations qeth_procfile_fops = {
44713 -       ioctl:qeth_procfile_ioctl,
44714 -       read:qeth_procfile_read,
44715 -       open:qeth_procfile_open,
44716 -       release:qeth_procfile_release,
44717 +       .ioctl = qeth_procfile_ioctl,
44718 +       .read = qeth_procfile_read,
44719 +       .open = qeth_procfile_open,
44720 +       .release = qeth_procfile_release,
44721  };
44722  
44723  static struct proc_dir_entry *qeth_proc_file;
44724  
44725  static struct file_operations qeth_ipato_procfile_fops = {
44726 -       read:qeth_procfile_read,        /* same as above! */
44727 -       write:qeth_ipato_procfile_write,
44728 -       open:qeth_ipato_procfile_open,
44729 -       release:qeth_procfile_release   /* same as above! */
44730 +       .read = qeth_procfile_read,     /* same as above! */
44731 +       .write = qeth_ipato_procfile_write,
44732 +       .open = qeth_ipato_procfile_open,
44733 +       .release = qeth_procfile_release        /* same as above! */
44734  };
44735  
44736  static struct proc_dir_entry *qeth_ipato_proc_file;
44737 diff -Nru a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c
44738 --- a/drivers/sbus/char/bpp.c   Wed May  7 08:47:30 2003
44739 +++ b/drivers/sbus/char/bpp.c   Tue Aug 26 09:25:41 2003
44740 @@ -440,7 +440,7 @@
44741   */
44742  static int bpp_open(struct inode *inode, struct file *f)
44743  {
44744 -      unsigned minor = minor(inode->i_rdev);
44745 +      unsigned minor = iminor(inode);
44746        int ret;
44747  
44748        spin_lock(&bpp_open_lock);
44749 @@ -470,7 +470,7 @@
44750   */
44751  static int bpp_release(struct inode *inode, struct file *f)
44752  {
44753 -      unsigned minor = minor(inode->i_rdev);
44754 +      unsigned minor = iminor(inode);
44755  
44756        spin_lock(&bpp_open_lock);
44757        instances[minor].opened = 0;
44758 @@ -634,7 +634,7 @@
44759  static ssize_t bpp_read(struct file *f, char *c, size_t cnt, loff_t * ppos)
44760  {
44761        long rc;
44762 -      const unsigned minor = minor(f->f_dentry->d_inode->i_rdev);
44763 +      unsigned minor = iminor(f->f_dentry->d_inode);
44764        if (minor >= BPP_NO) return -ENODEV;
44765        if (!instances[minor].present) return -ENODEV;
44766  
44767 @@ -787,7 +787,7 @@
44768  static ssize_t bpp_write(struct file *f, const char *c, size_t cnt, loff_t * ppos)
44769  {
44770        long errno = 0;
44771 -      const unsigned minor = minor(f->f_dentry->d_inode->i_rdev);
44772 +      unsigned minor = iminor(f->f_dentry->d_inode);
44773        if (minor >= BPP_NO) return -ENODEV;
44774        if (!instances[minor].present) return -ENODEV;
44775  
44776 @@ -813,7 +813,7 @@
44777  {
44778        int errno = 0;
44779  
44780 -      unsigned minor = minor(inode->i_rdev);
44781 +      unsigned minor = iminor(inode);
44782        if (minor >= BPP_NO) return -ENODEV;
44783        if (!instances[minor].present) return -ENODEV;
44784  
44785 diff -Nru a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c
44786 --- a/drivers/sbus/char/cpwatchdog.c    Tue Apr 22 23:40:00 2003
44787 +++ b/drivers/sbus/char/cpwatchdog.c    Tue Aug 26 09:25:41 2003
44788 @@ -295,7 +295,7 @@
44789  
44790  static int wd_open(struct inode *inode, struct file *f)
44791  {
44792 -       switch(minor(inode->i_rdev))
44793 +       switch(iminor(inode))
44794         {
44795                 case WD0_MINOR:
44796                         f->private_data = &wd_dev.watchdog[WD0_ID];
44797 diff -Nru a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
44798 --- a/drivers/sbus/char/display7seg.c   Thu Jan 16 11:49:15 2003
44799 +++ b/drivers/sbus/char/display7seg.c   Tue Aug 26 09:25:41 2003
44800 @@ -91,7 +91,7 @@
44801  
44802  static int d7s_open(struct inode *inode, struct file *f)
44803  {
44804 -       if (D7S_MINOR != minor(inode->i_rdev))
44805 +       if (D7S_MINOR != iminor(inode))
44806                 return -ENODEV;
44807         atomic_inc(&d7s_users);
44808         return 0;
44809 @@ -121,7 +121,7 @@
44810         __u8 regs = readb(d7s_regs);
44811         __u8 ireg = 0;
44812  
44813 -       if (D7S_MINOR != minor(inode->i_rdev))
44814 +       if (D7S_MINOR != iminor(inode))
44815                 return -ENODEV;
44816  
44817         switch (cmd) {
44818 diff -Nru a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c
44819 --- a/drivers/sbus/char/rtc.c   Thu Jul 18 23:11:59 2002
44820 +++ b/drivers/sbus/char/rtc.c   Mon Sep  1 00:27:41 2003
44821 @@ -28,7 +28,7 @@
44822  static int rtc_busy = 0;
44823  
44824  /* Retrieve the current date and time from the real time clock. */
44825 -void get_rtc_time(struct rtc_time *t)
44826 +static void get_rtc_time(struct rtc_time *t)
44827  {
44828         unsigned long regs = mstk48t02_regs;
44829         u8 tmp;
44830 diff -Nru a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c
44831 --- a/drivers/sbus/char/vfc_dev.c       Wed May  7 08:47:30 2003
44832 +++ b/drivers/sbus/char/vfc_dev.c       Tue Aug 26 09:25:41 2003
44833 @@ -184,7 +184,7 @@
44834         struct vfc_dev *dev;
44835  
44836         spin_lock(&vfc_dev_lock);
44837 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
44838 +       dev = vfc_get_dev_ptr(iminor(inode));
44839         if (dev == NULL) {
44840                 spin_unlock(&vfc_dev_lock);
44841                 return -ENODEV;
44842 @@ -215,7 +215,7 @@
44843         struct vfc_dev *dev;
44844  
44845         spin_lock(&vfc_dev_lock);
44846 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
44847 +       dev = vfc_get_dev_ptr(iminor(inode));
44848         if (!dev || !dev->busy) {
44849                 spin_unlock(&vfc_dev_lock);
44850                 return -EINVAL;
44851 @@ -557,7 +557,7 @@
44852         unsigned int tmp;
44853         struct vfc_dev *dev;
44854  
44855 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
44856 +       dev = vfc_get_dev_ptr(iminor(inode));
44857         if(dev == NULL)
44858                 return -ENODEV;
44859         
44860 @@ -602,7 +602,7 @@
44861                 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCRDINFO)\n", dev->instance));
44862                 break;
44863         default:
44864 -               ret = vfc_debug(vfc_get_dev_ptr(MINOR(inode->i_rdev)),
44865 +               ret = vfc_debug(vfc_get_dev_ptr(iminor(inode)),
44866                                 cmd, arg);
44867                 break;
44868         };
44869 @@ -616,7 +616,7 @@
44870         unsigned int map_size, ret, map_offset;
44871         struct vfc_dev *dev;
44872         
44873 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
44874 +       dev = vfc_get_dev_ptr(iminor(inode));
44875         if(dev == NULL)
44876                 return -ENODEV;
44877  
44878 diff -Nru a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
44879 --- a/drivers/scsi/3w-xxxx.c    Sat Aug 16 11:46:50 2003
44880 +++ b/drivers/scsi/3w-xxxx.c    Tue Aug 26 09:25:41 2003
44881 @@ -628,7 +628,7 @@
44882         unsigned long *cpu_addr;
44883         TW_New_Ioctl *tw_ioctl;
44884         TW_Passthru *passthru;
44885 -       TW_Device_Extension *tw_dev = tw_device_extension_list[minor(inode->i_rdev)];
44886 +       TW_Device_Extension *tw_dev = tw_device_extension_list[iminor(inode)];
44887         int retval = -EFAULT;
44888  
44889         dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");
44890 @@ -786,7 +786,7 @@
44891  
44892         dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n");
44893  
44894 -       minor_number = minor(inode->i_rdev);
44895 +       minor_number = iminor(inode);
44896         if (minor_number >= tw_device_extension_count)
44897                 return -ENODEV;
44898  
44899 diff -Nru a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h
44900 --- a/drivers/scsi/3w-xxxx.h    Mon May 12 07:26:10 2003
44901 +++ b/drivers/scsi/3w-xxxx.h    Mon Sep  1 17:20:32 2003
44902 @@ -59,42 +59,37 @@
44903  
44904  /* AEN strings */
44905  static char *tw_aen_string[] = {
44906 -       "INFO: AEN queue empty",                       // 0x000
44907 -       "INFO: Soft reset occurred",                   // 0x001
44908 -       "ERROR: Unit degraded: Unit #",                // 0x002
44909 -       "ERROR: Controller error",                     // 0x003 
44910 -       "ERROR: Rebuild failed: Unit #",               // 0x004
44911 -       "INFO: Rebuild complete: Unit #",              // 0x005
44912 -       "ERROR: Incomplete unit detected: Unit #",     // 0x006
44913 -       "INFO: Initialization complete: Unit #",       // 0x007
44914 -       "WARNING: Unclean shutdown detected: Unit #",  // 0x008
44915 -       "WARNING: ATA port timeout: Port #",           // 0x009
44916 -       "ERROR: Drive error: Port #",                  // 0x00A
44917 -       "INFO: Rebuild started: Unit #",               // 0x00B 
44918 -       "INFO: Initialization started: Unit #",        // 0x00C
44919 -       "ERROR: Logical unit deleted: Unit #",         // 0x00D
44920 -       NULL,                                          // 0x00E unused
44921 -       "WARNING: SMART threshold exceeded: Port #",   // 0x00F
44922 -       NULL, NULL, NULL, NULL, NULL,
44923 -       NULL, NULL, NULL, NULL, NULL,
44924 -       NULL, NULL, NULL, NULL, NULL,
44925 -       NULL, NULL,                                    // 0x010-0x020 unused
44926 -       "WARNING: ATA UDMA downgrade: Port #",         // 0x021
44927 -       "WARNING: ATA UDMA upgrade: Port #",           // 0x022
44928 -       "WARNING: Sector repair occurred: Port #",     // 0x023
44929 -       "ERROR: SBUF integrity check failure",         // 0x024
44930 -       "ERROR: Lost cached write: Port #",            // 0x025
44931 -       "ERROR: Drive ECC error detected: Port #",     // 0x026
44932 -       "ERROR: DCB checksum error: Port #",           // 0x027
44933 -       "ERROR: DCB unsupported version: Port #",      // 0x028
44934 -       "INFO: Verify started: Unit #",                // 0x029
44935 -       "ERROR: Verify failed: Port #",                // 0x02A
44936 -       "INFO: Verify complete: Unit #",               // 0x02B
44937 -       "WARNING: Overwrote bad sector during rebuild: Port #",  //0x02C
44938 -       "ERROR: Encountered bad sector during rebuild: Port #",  //0x02D
44939 -       "ERROR: Replacement drive is too small: Port #",         //0x02E
44940 -       "WARNING: Verify error: Unit not previously initialized: Unit #", //0x02F
44941 -       "ERROR: Drive not supported: Port #"           // 0x030
44942 +       [0x000] = "INFO: AEN queue empty",
44943 +       [0x001] = "INFO: Soft reset occurred",
44944 +       [0x002] = "ERROR: Unit degraded: Unit #",
44945 +       [0x003] = "ERROR: Controller error",
44946 +       [0x004] = "ERROR: Rebuild failed: Unit #",
44947 +       [0x005] = "INFO: Rebuild complete: Unit #",
44948 +       [0x006] = "ERROR: Incomplete unit detected: Unit #",
44949 +       [0x007] = "INFO: Initialization complete: Unit #",
44950 +       [0x008] = "WARNING: Unclean shutdown detected: Unit #",
44951 +       [0x009] = "WARNING: ATA port timeout: Port #",
44952 +       [0x00A] = "ERROR: Drive error: Port #",
44953 +       [0x00B] = "INFO: Rebuild started: Unit #",
44954 +       [0x00C] = "INFO: Initialization started: Unit #",
44955 +       [0x00D] = "ERROR: Logical unit deleted: Unit #",
44956 +       [0x00F] = "WARNING: SMART threshold exceeded: Port #",
44957 +       [0x021] = "WARNING: ATA UDMA downgrade: Port #",
44958 +       [0x021] = "WARNING: ATA UDMA upgrade: Port #",
44959 +       [0x023] = "WARNING: Sector repair occurred: Port #",
44960 +       [0x024] = "ERROR: SBUF integrity check failure",
44961 +       [0x025] = "ERROR: Lost cached write: Port #",
44962 +       [0x026] = "ERROR: Drive ECC error detected: Port #",
44963 +       [0x027] = "ERROR: DCB checksum error: Port #",
44964 +       [0x028] = "ERROR: DCB unsupported version: Port #",
44965 +       [0x029] = "INFO: Verify started: Unit #",
44966 +       [0x02A] = "ERROR: Verify failed: Port #",
44967 +       [0x02B] = "INFO: Verify complete: Unit #",
44968 +       [0x02C] = "WARNING: Overwrote bad sector during rebuild: Port #",
44969 +       [0x02D] = "ERROR: Encountered bad sector during rebuild: Port #",
44970 +       [0x02E] = "ERROR: Replacement drive is too small: Port #",
44971 +       [0x02F] = "WARNING: Verify error: Unit not previously initialized: Unit #",
44972 +       [0x030] = "ERROR: Drive not supported: Port #",
44973  };
44974  
44975  /*
44976 diff -Nru a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
44977 --- a/drivers/scsi/Kconfig      Sun Jun 29 20:43:06 2003
44978 +++ b/drivers/scsi/Kconfig      Tue Aug 26 11:57:18 2003
44979 @@ -355,7 +355,7 @@
44980  # All the I2O code and drivers do not seem to be 64bit safe.
44981  config SCSI_DPT_I2O
44982         tristate "Adaptec I2O RAID support "
44983 -       depends on !X86_64 && SCSI
44984 +       depends on !X86_64 && SCSI && BROKEN
44985         help
44986           This driver supports all of Adaptec's I2O based RAID controllers as 
44987           well as the DPT SmartRaid V cards.  This is an Adaptec maintained
44988 @@ -398,7 +398,7 @@
44989  # does not use pci dma and seems to be onboard only for old machines
44990  config SCSI_AM53C974
44991         tristate "AM53/79C974 PCI SCSI support"
44992 -       depends on X86 && PCI && SCSI
44993 +       depends on X86 && PCI && SCSI && BROKEN
44994         ---help---
44995           This is support for the AM53/79C974 SCSI host adapters.  Please read
44996           <file:Documentation/scsi/AM53C974.txt> for details.  Also, the
44997 @@ -742,7 +742,7 @@
44998  
44999  config SCSI_INITIO
45000         tristate "Initio 9100U(W) support"
45001 -       depends on PCI && SCSI
45002 +       depends on PCI && SCSI && BROKEN
45003         help
45004           This is support for the Initio 91XXU(W) SCSI host adapter.  Please
45005           read the SCSI-HOWTO, available from
45006 @@ -1161,7 +1161,7 @@
45007  
45008  config SCSI_MCA_53C9X
45009         tristate "NCR MCA 53C9x SCSI support"
45010 -       depends on MCA && SCSI
45011 +       depends on MCA && SCSI && BROKEN_ON_SMP
45012         help
45013           Some MicroChannel machines, notably the NCR 35xx line, use a SCSI
45014           controller based on the NCR 53C94.  This driver will allow use of
45015 @@ -1189,7 +1189,7 @@
45016  
45017  config SCSI_PCI2000
45018         tristate "PCI2000 support"
45019 -       depends on PCI && SCSI
45020 +       depends on PCI && SCSI && BROKEN
45021         help
45022           This is support for the PCI2000I EIDE interface card which acts as a
45023           SCSI host adapter.  Please read the SCSI-HOWTO, available from
45024 @@ -1202,7 +1202,7 @@
45025  
45026  config SCSI_PCI2220I
45027         tristate "PCI2220i support"
45028 -       depends on PCI && SCSI
45029 +       depends on PCI && SCSI && BROKEN
45030         help
45031           This is support for the PCI2220i EIDE interface card which acts as a
45032           SCSI host adapter.  Please read the SCSI-HOWTO, available from
45033 @@ -1314,7 +1314,7 @@
45034  
45035  config SCSI_SEAGATE
45036         tristate "Seagate ST-02 and Future Domain TMC-8xx SCSI support"
45037 -       depends on X86 && ISA && SCSI
45038 +       depends on X86 && ISA && SCSI && BROKEN
45039         ---help---
45040           These are 8-bit SCSI controllers; the ST-01 is also supported by
45041           this driver.  It is explained in section 3.9 of the SCSI-HOWTO,
45042 @@ -1381,7 +1381,7 @@
45043  
45044  config SCSI_DC390T
45045         tristate "Tekram DC390(T) and Am53/79C974 SCSI support"
45046 -       depends on PCI && SCSI
45047 +       depends on PCI && SCSI && BROKEN
45048         ---help---
45049           This driver supports PCI SCSI host adapters based on the Am53C974A
45050           chip, e.g. Tekram DC390(T), DawiControl 2974 and some onboard
45051 diff -Nru a/drivers/scsi/a2091.h b/drivers/scsi/a2091.h
45052 --- a/drivers/scsi/a2091.h      Fri Dec 20 06:27:06 2002
45053 +++ b/drivers/scsi/a2091.h      Mon Sep  1 17:20:32 2003
45054 @@ -18,10 +18,6 @@
45055  int wd33c93_abort(Scsi_Cmnd *);
45056  int wd33c93_reset(Scsi_Cmnd *, unsigned int);
45057  
45058 -#ifndef NULL
45059 -#define NULL 0
45060 -#endif
45061 -
45062  #ifndef CMD_PER_LUN
45063  #define CMD_PER_LUN 2
45064  #endif
45065 diff -Nru a/drivers/scsi/a3000.h b/drivers/scsi/a3000.h
45066 --- a/drivers/scsi/a3000.h      Fri Dec 20 06:27:46 2002
45067 +++ b/drivers/scsi/a3000.h      Mon Sep  1 17:20:32 2003
45068 @@ -18,10 +18,6 @@
45069  int wd33c93_abort(Scsi_Cmnd *);
45070  int wd33c93_reset(Scsi_Cmnd *, unsigned int);
45071  
45072 -#ifndef NULL
45073 -#define NULL 0
45074 -#endif
45075 -
45076  #ifndef CMD_PER_LUN
45077  #define CMD_PER_LUN 2
45078  #endif
45079 diff -Nru a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
45080 --- a/drivers/scsi/aacraid/linit.c      Thu Jul 31 07:32:16 2003
45081 +++ b/drivers/scsi/aacraid/linit.c      Tue Aug 26 09:25:41 2003
45082 @@ -565,7 +565,7 @@
45083  
45084  static int aac_cfg_open(struct inode * inode, struct file * file )
45085  {
45086 -       unsigned minor_number = minor(inode->i_rdev);
45087 +       unsigned minor_number = iminor(inode);
45088         if(minor_number >= aac_count)
45089                 return -ENODEV;
45090         return 0;
45091 @@ -601,7 +601,7 @@
45092   
45093  static int aac_cfg_ioctl(struct inode * inode,  struct file * file, unsigned int cmd, unsigned long arg )
45094  {
45095 -       struct aac_dev *dev = aac_devices[minor(inode->i_rdev)];
45096 +       struct aac_dev *dev = aac_devices[iminor(inode)];
45097         return aac_do_ioctl(dev, cmd, (void *)arg);
45098  }
45099  
45100 diff -Nru a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
45101 --- a/drivers/scsi/advansys.c   Fri May  2 12:35:39 2003
45102 +++ b/drivers/scsi/advansys.c   Sun Aug 31 16:15:44 2003
45103 @@ -6199,7 +6199,9 @@
45104  
45105  static Scsi_Host_Template driver_template = {
45106      .proc_name                  = "advansys",
45107 +#ifdef CONFIG_PROC_FS
45108      .proc_info                  = advansys_proc_info,
45109 +#endif
45110      .name                       = "advansys",
45111      .detect                     = advansys_detect, 
45112      .release                    = advansys_release,
45113 diff -Nru a/drivers/scsi/aha1542.h b/drivers/scsi/aha1542.h
45114 --- a/drivers/scsi/aha1542.h    Mon Jul 14 07:50:01 2003
45115 +++ b/drivers/scsi/aha1542.h    Mon Sep  1 17:20:32 2003
45116 @@ -146,8 +146,4 @@
45117  #define AHA1542_SCATTER 16
45118  #define AHA1542_CMDLUN 1
45119  
45120 -#ifndef NULL
45121 -       #define NULL 0
45122 -#endif
45123 -
45124  #endif
45125 diff -Nru a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
45126 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c    Thu Jun 19 16:46:06 2003
45127 +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c    Sun Aug 31 16:14:08 2003
45128 @@ -72,10 +72,10 @@
45129  MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table);
45130  
45131  struct pci_driver aic79xx_pci_driver = {
45132 -       name:           "aic79xx",
45133 -       probe:          ahd_linux_pci_dev_probe,
45134 -       remove:         ahd_linux_pci_dev_remove,
45135 -       id_table:       ahd_linux_pci_id_table
45136 +       .name           = "aic79xx",
45137 +       .probe          = ahd_linux_pci_dev_probe,
45138 +       .remove         = ahd_linux_pci_dev_remove,
45139 +       .id_table       = ahd_linux_pci_id_table
45140  };
45141  
45142  static void
45143 diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
45144 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c    Wed May 14 15:00:40 2003
45145 +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c    Sun Aug 31 16:14:08 2003
45146 @@ -75,10 +75,10 @@
45147  MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table);
45148  
45149  struct pci_driver aic7xxx_pci_driver = {
45150 -       name:           "aic7xxx",
45151 -       probe:          ahc_linux_pci_dev_probe,
45152 -       remove:         ahc_linux_pci_dev_remove,
45153 -       id_table:       ahc_linux_pci_id_table
45154 +       .name           = "aic7xxx",
45155 +       .probe          = ahc_linux_pci_dev_probe,
45156 +       .remove         = ahc_linux_pci_dev_remove,
45157 +       .id_table       = ahc_linux_pci_id_table
45158  };
45159  
45160  static void
45161 diff -Nru a/drivers/scsi/amiga7xx.h b/drivers/scsi/amiga7xx.h
45162 --- a/drivers/scsi/amiga7xx.h   Fri Dec 20 06:28:14 2002
45163 +++ b/drivers/scsi/amiga7xx.h   Mon Sep  1 17:20:32 2003
45164 @@ -10,10 +10,6 @@
45165  int NCR53c7xx_reset(Scsi_Cmnd *, unsigned int);
45166  void NCR53c7x0_intr(int irq, void *dev_id, struct pt_regs * regs);
45167  
45168 -#ifndef NULL
45169 -#define NULL 0
45170 -#endif
45171 -
45172  #ifndef CMD_PER_LUN
45173  #define CMD_PER_LUN 3
45174  #endif
45175 diff -Nru a/drivers/scsi/atp870u.h b/drivers/scsi/atp870u.h
45176 --- a/drivers/scsi/atp870u.h    Sun Jun  8 12:18:41 2003
45177 +++ b/drivers/scsi/atp870u.h    Mon Sep  1 17:20:32 2003
45178 @@ -28,10 +28,6 @@
45179  #define ATP870U_SCATTER 128
45180  #define ATP870U_CMDLUN 1
45181  
45182 -#ifndef NULL
45183 -#define NULL 0
45184 -#endif
45185 -
45186  extern const char *atp870u_info(struct Scsi_Host *);
45187  
45188  #endif
45189 diff -Nru a/drivers/scsi/bvme6000.h b/drivers/scsi/bvme6000.h
45190 --- a/drivers/scsi/bvme6000.h   Fri Dec 20 06:31:43 2002
45191 +++ b/drivers/scsi/bvme6000.h   Mon Sep  1 17:20:32 2003
45192 @@ -11,10 +11,6 @@
45193  int NCR53c7xx_reset(Scsi_Cmnd *, unsigned int);
45194  void NCR53c7x0_intr(int irq, void *dev_id, struct pt_regs * regs);
45195  
45196 -#ifndef NULL
45197 -#define NULL 0
45198 -#endif
45199 -
45200  #ifndef CMD_PER_LUN
45201  #define CMD_PER_LUN 3
45202  #endif
45203 diff -Nru a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
45204 --- a/drivers/scsi/dpt_i2o.c    Fri May  2 12:45:47 2003
45205 +++ b/drivers/scsi/dpt_i2o.c    Tue Aug 26 09:25:41 2003
45206 @@ -1551,7 +1551,7 @@
45207  
45208         //TODO check for root access
45209         //
45210 -       minor = minor(inode->i_rdev);
45211 +       minor = iminor(inode);
45212         if (minor >= hba_count) {
45213                 return -ENXIO;
45214         }
45215 @@ -1582,7 +1582,7 @@
45216         int minor;
45217         adpt_hba* pHba;
45218  
45219 -       minor = minor(inode->i_rdev);
45220 +       minor = iminor(inode);
45221         if (minor >= hba_count) {
45222                 return -ENXIO;
45223         }
45224 @@ -1878,7 +1878,7 @@
45225         adpt_hba* pHba;
45226         ulong flags;
45227  
45228 -       minor = minor(inode->i_rdev);
45229 +       minor = iminor(inode);
45230         if (minor >= DPTI_MAX_HBA){
45231                 return -ENXIO;
45232         }
45233 diff -Nru a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h
45234 --- a/drivers/scsi/gdth.h       Mon May 12 07:26:12 2003
45235 +++ b/drivers/scsi/gdth.h       Mon Sep  1 17:20:32 2003
45236 @@ -16,9 +16,6 @@
45237  #include <linux/version.h>
45238  #include <linux/types.h>
45239  
45240 -#ifndef NULL
45241 -#define NULL 0
45242 -#endif
45243  #ifndef TRUE
45244  #define TRUE 1
45245  #endif
45246 diff -Nru a/drivers/scsi/gvp11.h b/drivers/scsi/gvp11.h
45247 --- a/drivers/scsi/gvp11.h      Fri Dec 20 06:35:20 2002
45248 +++ b/drivers/scsi/gvp11.h      Mon Sep  1 17:20:32 2003
45249 @@ -18,10 +18,6 @@
45250  int wd33c93_abort(Scsi_Cmnd *);
45251  int wd33c93_reset(Scsi_Cmnd *, unsigned int);
45252  
45253 -#ifndef NULL
45254 -#define NULL 0
45255 -#endif
45256 -
45257  #ifndef CMD_PER_LUN
45258  #define CMD_PER_LUN 2
45259  #endif
45260 diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
45261 --- a/drivers/scsi/hosts.c      Sat Aug 16 16:09:46 2003
45262 +++ b/drivers/scsi/hosts.c      Sun Aug 31 16:15:45 2003
45263 @@ -158,7 +158,13 @@
45264         scsi_proc_hostdir_rm(shost->hostt);
45265         scsi_destroy_command_freelist(shost);
45266  
45267 -       put_device(parent);
45268 +       /*
45269 +        * Some drivers (eg aha1542) do scsi_register()/scsi_unregister()
45270 +        * during probing without performing a scsi_set_device() in between.
45271 +        * In this case dev->parent is NULL.
45272 +        */
45273 +       if (parent)
45274 +               put_device(parent);
45275         kfree(shost);
45276  }
45277  
45278 diff -Nru a/drivers/scsi/hosts.h b/drivers/scsi/hosts.h
45279 --- a/drivers/scsi/hosts.h      Mon Jun 23 04:00:34 2003
45280 +++ b/drivers/scsi/hosts.h      Mon Sep  1 13:56:57 2003
45281 @@ -25,7 +25,6 @@
45282  #define _HOSTS_H
45283  
45284  #include <linux/config.h>
45285 -#include <linux/proc_fs.h>
45286  
45287  #include <scsi/scsi_host.h>
45288  
45289 diff -Nru a/drivers/scsi/i91uscsi.h b/drivers/scsi/i91uscsi.h
45290 --- a/drivers/scsi/i91uscsi.h   Sun Feb 16 16:20:08 2003
45291 +++ b/drivers/scsi/i91uscsi.h   Mon Sep  1 17:20:32 2003
45292 @@ -67,9 +67,6 @@
45293  #define UDWORD  unsigned long
45294  #define U32     u32
45295  
45296 -#ifndef NULL
45297 -#define NULL     0             /* zero          */
45298 -#endif
45299  #ifndef FAILURE
45300  #define FAILURE  (-1)
45301  #endif
45302 diff -Nru a/drivers/scsi/imm.h b/drivers/scsi/imm.h
45303 --- a/drivers/scsi/imm.h        Fri May  2 12:27:27 2003
45304 +++ b/drivers/scsi/imm.h        Mon Sep  1 17:20:32 2003
45305 @@ -96,17 +96,18 @@
45306  
45307  static char *IMM_MODE_STRING[] =
45308  {
45309 -    "Autodetect",
45310 -    "SPP",
45311 -    "PS/2",
45312 -    "EPP 8 bit",
45313 -    "EPP 16 bit",
45314 +       [IMM_AUTODETECT] = "Autodetect",
45315 +       [IMM_NIBBLE]     = "SPP",
45316 +       [IMM_PS2]        = "PS/2",
45317 +       [IMM_EPP_8]      = "EPP 8 bit",
45318 +       [IMM_EPP_16]     = "EPP 16 bit",
45319  #ifdef CONFIG_SCSI_IZIP_EPP16
45320 -    "EPP 16 bit",
45321 +       [IMM_EPP_16]     = "EPP 16 bit",
45322  #else
45323 -    "EPP 32 bit",
45324 +       [IMM_EPP_32]     = "EPP 32 bit",
45325  #endif
45326 -    "Unknown"};
45327 +       [IMM_UNKNOWN]    = "Unknown",
45328 +};
45329  
45330  /* This is a global option */
45331  int imm_sg = SG_ALL;           /* enable/disable scatter-gather. */
45332 diff -Nru a/drivers/scsi/ini9100u.h b/drivers/scsi/ini9100u.h
45333 --- a/drivers/scsi/ini9100u.h   Sun May  4 02:56:43 2003
45334 +++ b/drivers/scsi/ini9100u.h   Mon Sep  1 17:20:32 2003
45335 @@ -99,9 +99,6 @@
45336  #define UDWORD  unsigned long
45337  #define U32   u32
45338  
45339 -#ifndef NULL
45340 -#define NULL     0             /* zero          */
45341 -#endif
45342  #ifndef TRUE
45343  #define TRUE     (1)           /* boolean true  */
45344  #endif
45345 diff -Nru a/drivers/scsi/inia100.h b/drivers/scsi/inia100.h
45346 --- a/drivers/scsi/inia100.h    Sun May  4 02:56:43 2003
45347 +++ b/drivers/scsi/inia100.h    Mon Sep  1 17:20:32 2003
45348 @@ -88,9 +88,6 @@
45349  #define UDWORD  unsigned long
45350  #define U32     u32
45351  
45352 -#ifndef NULL
45353 -#define NULL     0             /* zero          */
45354 -#endif
45355  #ifndef FAILURE
45356  #define FAILURE  (-1)
45357  #endif
45358 diff -Nru a/drivers/scsi/mac_scsi.h b/drivers/scsi/mac_scsi.h
45359 --- a/drivers/scsi/mac_scsi.h   Mon May 12 07:26:13 2003
45360 +++ b/drivers/scsi/mac_scsi.h   Mon Sep  1 17:20:32 2003
45361 @@ -32,9 +32,6 @@
45362  #define MACSCSI_PUBLIC_RELEASE 2
45363  
45364  #ifndef ASM
45365 -#ifndef NULL
45366 -#define NULL 0
45367 -#endif
45368  
45369  #ifndef CMD_PER_LUN
45370  #define CMD_PER_LUN 2
45371 diff -Nru a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
45372 --- a/drivers/scsi/megaraid.c   Sat Aug 16 11:46:50 2003
45373 +++ b/drivers/scsi/megaraid.c   Mon Sep  1 13:56:57 2003
45374 @@ -36,6 +36,7 @@
45375  #include <asm/uaccess.h>
45376  #include <asm/io.h>
45377  #include <linux/delay.h>
45378 +#include <linux/proc_fs.h>
45379  #include <linux/reboot.h>
45380  #include <linux/module.h>
45381  #include <linux/list.h>
45382 diff -Nru a/drivers/scsi/mvme147.h b/drivers/scsi/mvme147.h
45383 --- a/drivers/scsi/mvme147.h    Fri Dec 20 06:38:40 2002
45384 +++ b/drivers/scsi/mvme147.h    Mon Sep  1 17:20:32 2003
45385 @@ -17,10 +17,6 @@
45386  int wd33c93_abort(Scsi_Cmnd *);
45387  int wd33c93_reset(Scsi_Cmnd *, unsigned int);
45388  
45389 -#ifndef NULL
45390 -#define NULL 0
45391 -#endif
45392 -
45393  #ifndef CMD_PER_LUN
45394  #define CMD_PER_LUN 2
45395  #endif
45396 diff -Nru a/drivers/scsi/mvme16x.h b/drivers/scsi/mvme16x.h
45397 --- a/drivers/scsi/mvme16x.h    Fri Dec 20 06:39:02 2002
45398 +++ b/drivers/scsi/mvme16x.h    Mon Sep  1 17:20:32 2003
45399 @@ -11,10 +11,6 @@
45400  int NCR53c7xx_reset(Scsi_Cmnd *, unsigned int);
45401  void NCR53c7x0_intr(int irq, void *dev_id, struct pt_regs * regs);
45402  
45403 -#ifndef NULL
45404 -#define NULL 0
45405 -#endif
45406 -
45407  #ifndef CMD_PER_LUN
45408  #define CMD_PER_LUN 3
45409  #endif
45410 diff -Nru a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
45411 --- a/drivers/scsi/nsp32.c      Tue Aug 19 12:35:44 2003
45412 +++ b/drivers/scsi/nsp32.c      Sun Aug 31 16:14:08 2003
45413 @@ -2809,13 +2809,13 @@
45414                 for (j = 0; j < NUMBER(data->lunt[0]); j++) {
45415                         int offset = i * NUMBER(data->lunt[0]) + j;
45416                         nsp32_lunt tmp = {
45417 -                               SCpnt:       NULL,
45418 -                               save_datp:   0,
45419 -                               msgin03:     FALSE,
45420 -                               sg_num:      0,
45421 -                               cur_entry:   0,
45422 -                               sglun:       &(data->sg_list[offset]),
45423 -                               sglun_paddr: data->sg_paddr + (offset * sizeof(nsp32_sglun)),
45424 +                               .SCpnt       = NULL,
45425 +                               .save_datp   = 0,
45426 +                               .msgin03     = FALSE,
45427 +                               .sg_num      = 0,
45428 +                               .cur_entry   = 0,
45429 +                               .sglun       = &(data->sg_list[offset]),
45430 +                               .sglun_paddr = data->sg_paddr + (offset * sizeof(nsp32_sglun)),
45431                         };
45432  
45433                         data->lunt[i][j] = tmp;
45434 diff -Nru a/drivers/scsi/osst.c b/drivers/scsi/osst.c
45435 --- a/drivers/scsi/osst.c       Fri May  2 12:38:35 2003
45436 +++ b/drivers/scsi/osst.c       Tue Aug 26 09:25:41 2003
45437 @@ -132,9 +132,9 @@
45438  #define OSST_TIMEOUT (200 * HZ)
45439  #define OSST_LONG_TIMEOUT (1800 * HZ)
45440  
45441 -#define TAPE_NR(x) (minor(x) & ~(-1 << ST_MODE_SHIFT))
45442 -#define TAPE_MODE(x) ((minor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
45443 -#define TAPE_REWIND(x) ((minor(x) & 0x80) == 0)
45444 +#define TAPE_NR(x) (iminor(x) & ~(-1 << ST_MODE_SHIFT))
45445 +#define TAPE_MODE(x) ((iminor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
45446 +#define TAPE_REWIND(x) ((iminor(x) & 0x80) == 0)
45447  #define TAPE_IS_RAW(x) (TAPE_MODE(x) & (ST_NBR_MODES >> 1))
45448  
45449  /* Internal ioctl to set both density (uppermost 8 bits) and blocksize (lower
45450 @@ -4215,8 +4215,8 @@
45451         ST_mode      * STm;
45452         ST_partstat  * STps;
45453         char         * name;
45454 -       int            dev  = TAPE_NR(inode->i_rdev);
45455 -       int            mode = TAPE_MODE(inode->i_rdev);
45456 +       int            dev  = TAPE_NR(inode);
45457 +       int            mode = TAPE_MODE(inode);
45458  
45459         write_lock(&os_scsi_tapes_lock);
45460         if (dev >= osst_max_dev || os_scsi_tapes == NULL ||
45461 @@ -4244,7 +4244,7 @@
45462         filp->private_data = STp;
45463         STp->in_use = 1;
45464         write_unlock(&os_scsi_tapes_lock);
45465 -       STp->rew_at_close = TAPE_REWIND(inode->i_rdev);
45466 +       STp->rew_at_close = TAPE_REWIND(inode);
45467  
45468         if( !scsi_block_when_processing_errors(STp->device) ) {
45469                 return -ENXIO;
45470 @@ -4264,7 +4264,7 @@
45471         flags = filp->f_flags;
45472         STp->write_prot = ((flags & O_ACCMODE) == O_RDONLY);
45473  
45474 -       STp->raw = TAPE_IS_RAW(inode->i_rdev);
45475 +       STp->raw = TAPE_IS_RAW(inode);
45476         if (STp->raw)
45477                 STp->header_ok = 0;
45478  
45479 diff -Nru a/drivers/scsi/pas16.h b/drivers/scsi/pas16.h
45480 --- a/drivers/scsi/pas16.h      Mon May 12 07:26:14 2003
45481 +++ b/drivers/scsi/pas16.h      Mon Sep  1 17:20:32 2003
45482 @@ -123,10 +123,6 @@
45483  static int pas16_host_reset(Scsi_Cmnd *);
45484  static int pas16_device_reset(Scsi_Cmnd *);
45485  
45486 -#ifndef NULL
45487 -#define NULL 0
45488 -#endif
45489 -
45490  #ifndef CMD_PER_LUN
45491  #define CMD_PER_LUN 2
45492  #endif
45493 diff -Nru a/drivers/scsi/pci2000.h b/drivers/scsi/pci2000.h
45494 --- a/drivers/scsi/pci2000.h    Sun May  4 02:56:44 2003
45495 +++ b/drivers/scsi/pci2000.h    Mon Sep  1 17:20:32 2003
45496 @@ -197,8 +197,4 @@
45497                                         struct block_device *bdev,
45498                                         sector_t capacity, int geom[]);
45499  
45500 -#ifndef NULL
45501 -       #define NULL 0
45502 -#endif
45503 -
45504  #endif
45505 diff -Nru a/drivers/scsi/pci2220i.h b/drivers/scsi/pci2220i.h
45506 --- a/drivers/scsi/pci2220i.h   Sun May  4 02:56:44 2003
45507 +++ b/drivers/scsi/pci2220i.h   Mon Sep  1 17:20:32 2003
45508 @@ -36,8 +36,4 @@
45509  int Pci2220i_BiosParam         (struct scsi_device *sdev,
45510                                         struct block_device *dev,
45511                                         sector_t capacity, int geom[]);
45512 -
45513 -#ifndef NULL
45514 -       #define NULL 0
45515 -#endif
45516  #endif
45517 diff -Nru a/drivers/scsi/psi240i.h b/drivers/scsi/psi240i.h
45518 --- a/drivers/scsi/psi240i.h    Sun May  4 02:56:45 2003
45519 +++ b/drivers/scsi/psi240i.h    Mon Sep  1 17:20:32 2003
45520 @@ -316,8 +316,4 @@
45521  int Psi240i_Reset                      (Scsi_Cmnd *SCpnt, unsigned int flags);
45522  int Psi240i_BiosParam          (struct scsi_device *sdev, struct block_device *bdev,
45523                                         sector_t capacity, int geom[]);
45524 -
45525 -#ifndef NULL
45526 -       #define NULL 0
45527 -#endif
45528  #endif
45529 diff -Nru a/drivers/scsi/qlogicfc.h b/drivers/scsi/qlogicfc.h
45530 --- a/drivers/scsi/qlogicfc.h   Sun May  4 02:56:45 2003
45531 +++ b/drivers/scsi/qlogicfc.h   Mon Sep  1 17:20:32 2003
45532 @@ -77,9 +77,4 @@
45533  int isp2x00_reset(Scsi_Cmnd *, unsigned int);
45534  int isp2x00_biosparam(struct scsi_device *, struct block_device *,
45535                 sector_t, int[]);
45536 -
45537 -#ifndef NULL
45538 -#define NULL (0)
45539 -#endif
45540 -
45541  #endif /* _QLOGICFC_H */
45542 diff -Nru a/drivers/scsi/qlogicisp.h b/drivers/scsi/qlogicisp.h
45543 --- a/drivers/scsi/qlogicisp.h  Sun May  4 02:56:45 2003
45544 +++ b/drivers/scsi/qlogicisp.h  Mon Sep  1 17:20:32 2003
45545 @@ -66,8 +66,4 @@
45546  int isp1020_reset(Scsi_Cmnd *, unsigned int);
45547  int isp1020_biosparam(struct scsi_device *, struct block_device *,
45548                 sector_t, int[]);
45549 -
45550 -#ifndef NULL
45551 -#define NULL (0)
45552 -#endif
45553  #endif /* _QLOGICISP_H */
45554 diff -Nru a/drivers/scsi/sg.c b/drivers/scsi/sg.c
45555 --- a/drivers/scsi/sg.c Sat Aug 16 11:46:50 2003
45556 +++ b/drivers/scsi/sg.c Tue Aug 26 09:25:41 2003
45557 @@ -238,7 +238,7 @@
45558  static int
45559  sg_open(struct inode *inode, struct file *filp)
45560  {
45561 -       int dev = minor(inode->i_rdev);
45562 +       int dev = iminor(inode);
45563         int flags = filp->f_flags;
45564         Sg_device *sdp;
45565         Sg_fd *sfp;
45566 diff -Nru a/drivers/scsi/sgiwd93.h b/drivers/scsi/sgiwd93.h
45567 --- a/drivers/scsi/sgiwd93.h    Sun May  4 02:56:46 2003
45568 +++ b/drivers/scsi/sgiwd93.h    Mon Sep  1 17:20:32 2003
45569 @@ -6,10 +6,6 @@
45570  #ifndef _SGIWD93_H
45571  #define _SGIWD93_H
45572  
45573 -#ifndef NULL
45574 -#define NULL        0
45575 -#endif
45576 -
45577  #ifndef CMD_PER_LUN
45578  #define CMD_PER_LUN 8
45579  #endif
45580 diff -Nru a/drivers/scsi/sr.c b/drivers/scsi/sr.c
45581 --- a/drivers/scsi/sr.c Thu Jul 31 08:28:30 2003
45582 +++ b/drivers/scsi/sr.c Mon Sep  1 06:28:41 2003
45583 @@ -695,6 +695,10 @@
45584         unsigned char *buffer;
45585         int rc, n;
45586         struct scsi_mode_data data;
45587 +       struct scsi_request *SRpnt;
45588 +       unsigned char cmd[MAX_COMMAND_SIZE];
45589 +       unsigned int the_result;
45590 +       int retries;
45591  
45592         static char *loadmech[] =
45593         {
45594 @@ -708,11 +712,46 @@
45595                 ""
45596         };
45597  
45598 +       /* allocate a request for the TEST_UNIT_READY */
45599 +       SRpnt = scsi_allocate_request(cd->device);
45600 +       if (!SRpnt) {
45601 +               printk(KERN_WARNING "(get_capabilities:) Request allocation "
45602 +                      "failure.\n");
45603 +               return;
45604 +       }
45605 +
45606 +       /* allocate transfer buffer */
45607         buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
45608         if (!buffer) {
45609                 printk(KERN_ERR "sr: out of memory.\n");
45610 +               scsi_release_request(SRpnt);
45611                 return;
45612         }
45613 +
45614 +       /* issue TEST_UNIT_READY until the initial startup UNIT_ATTENTION
45615 +        * conditions are gone, or a timeout happens
45616 +        */
45617 +       retries = 0;
45618 +       do {
45619 +               memset((void *)cmd, 0, MAX_COMMAND_SIZE);
45620 +               cmd[0] = TEST_UNIT_READY;
45621 +
45622 +               SRpnt->sr_cmd_len = 0;
45623 +               SRpnt->sr_sense_buffer[0] = 0;
45624 +               SRpnt->sr_sense_buffer[2] = 0;
45625 +               SRpnt->sr_data_direction = DMA_NONE;
45626 +
45627 +               scsi_wait_req (SRpnt, (void *) cmd, buffer,
45628 +                              0, SR_TIMEOUT, MAX_RETRIES);
45629 +
45630 +               the_result = SRpnt->sr_result;
45631 +               retries++;
45632 +       } while (retries < 5 && 
45633 +                (!scsi_status_is_good(the_result) ||
45634 +                 ((driver_byte(the_result) & DRIVER_SENSE) &&
45635 +                  SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION)));
45636 +
45637 +       /* ask for mode page 0x2a */
45638         rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
45639                              SR_TIMEOUT, 3, &data);
45640  
45641 @@ -722,6 +761,7 @@
45642                 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
45643                                          CDC_DVD | CDC_DVD_RAM |
45644                                          CDC_SELECT_DISC | CDC_SELECT_SPEED);
45645 +               scsi_release_request(SRpnt);
45646                 kfree(buffer);
45647                 printk("%s: scsi-1 drive\n", cd->cdi.name);
45648                 return;
45649 @@ -775,6 +815,7 @@
45650         /*else    I don't think it can close its tray
45651                 cd->cdi.mask |= CDC_CLOSE_TRAY; */
45652  
45653 +       scsi_release_request(SRpnt);
45654         kfree(buffer);
45655  }
45656  
45657 diff -Nru a/drivers/scsi/st.c b/drivers/scsi/st.c
45658 --- a/drivers/scsi/st.c Mon Aug 11 11:44:45 2003
45659 +++ b/drivers/scsi/st.c Tue Aug 26 12:05:16 2003
45660 @@ -140,8 +140,8 @@
45661  #define ST_TIMEOUT (900 * HZ)
45662  #define ST_LONG_TIMEOUT (14000 * HZ)
45663  
45664 -#define TAPE_NR(x) (minor(x) & ~(-1 << ST_MODE_SHIFT))
45665 -#define TAPE_MODE(x) ((minor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
45666 +#define TAPE_NR(x) (iminor(x) & ~(-1 << ST_MODE_SHIFT))
45667 +#define TAPE_MODE(x) ((iminor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
45668  
45669  /* Internal ioctl to set both density (uppermost 8 bits) and blocksize (lower
45670     24 bits) */
45671 @@ -786,7 +786,7 @@
45672         ST_partstat *STps;
45673         char *name = tape_name(STp);
45674         struct inode *inode = filp->f_dentry->d_inode;
45675 -       int mode = TAPE_MODE(inode->i_rdev);
45676 +       int mode = TAPE_MODE(inode);
45677  
45678         STp->ready = ST_READY;
45679  
45680 @@ -980,7 +980,7 @@
45681         int i, retval = (-EIO);
45682         Scsi_Tape *STp;
45683         ST_partstat *STps;
45684 -       int dev = TAPE_NR(inode->i_rdev);
45685 +       int dev = TAPE_NR(inode);
45686         char *name;
45687  
45688         write_lock(&st_dev_arr_lock);
45689 @@ -1004,7 +1004,7 @@
45690         }
45691         STp->in_use = 1;
45692         write_unlock(&st_dev_arr_lock);
45693 -       STp->rew_at_close = STp->autorew_dev = (minor(inode->i_rdev) & 0x80) == 0;
45694 +       STp->rew_at_close = STp->autorew_dev = (iminor(inode) & 0x80) == 0;
45695  
45696  
45697         if (!scsi_block_when_processing_errors(STp->device)) {
45698 diff -Nru a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h
45699 --- a/drivers/scsi/sun3_scsi.h  Mon May 12 07:26:15 2003
45700 +++ b/drivers/scsi/sun3_scsi.h  Mon Sep  1 17:20:32 2003
45701 @@ -36,11 +36,6 @@
45702  #ifndef SUN3_NCR5380_H
45703  #define SUN3_NCR5380_H
45704  
45705 -#ifndef NULL
45706 -#define NULL 0
45707 -#endif
45708 -
45709 -
45710  #define SUN3SCSI_PUBLIC_RELEASE 1
45711  
45712  /*
45713 diff -Nru a/drivers/scsi/t128.h b/drivers/scsi/t128.h
45714 --- a/drivers/scsi/t128.h       Mon May 12 07:26:16 2003
45715 +++ b/drivers/scsi/t128.h       Mon Sep  1 17:20:32 2003
45716 @@ -100,10 +100,6 @@
45717  static int t128_bus_reset(Scsi_Cmnd *);
45718  static int t128_device_reset(Scsi_Cmnd *);
45719  
45720 -#ifndef NULL
45721 -#define NULL 0
45722 -#endif
45723 -
45724  #ifndef CMD_PER_LUN
45725  #define CMD_PER_LUN 2
45726  #endif
45727 diff -Nru a/drivers/serial/Kconfig b/drivers/serial/Kconfig
45728 --- a/drivers/serial/Kconfig    Fri Aug  1 03:02:30 2003
45729 +++ b/drivers/serial/Kconfig    Sun Aug 24 08:17:18 2003
45730 @@ -430,12 +430,12 @@
45731  
45732  config SERIAL_CORE
45733         tristate
45734 -       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)
45735 -       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
45736 +       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)
45737 +       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
45738  
45739  config SERIAL_CORE_CONSOLE
45740         bool
45741 -       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
45742 +       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
45743         default y
45744  
45745  config SERIAL_68328
45746 @@ -472,6 +472,22 @@
45747         bool
45748         depends on SERIAL_68360_SMC || SERIAL_68360_SCC
45749         default y
45750 +
45751 +config SERIAL_PMACZILOG
45752 +       tristate "PowerMac z85c30 ESCC support"
45753 +       depends on PPC_OF
45754 +       help
45755 +         This driver supports the Zilog z85C30 serial ports found on
45756 +         PowerMac machines.
45757 +         Say Y or M if you want to be able to these serial ports.
45758 +
45759 +config SERIAL_PMACZILOG_CONSOLE
45760 +       bool "Console on PowerMac z85c30 serial port"
45761 +       depends on SERIAL_PMACZILOG=y
45762 +       help
45763 +         If you would like to be able to use the z85c30 serial port
45764 +         on your PowerMac as the console, you can do so by answering
45765 +         Y to this option.
45766  
45767  endmenu
45768  
45769 diff -Nru a/drivers/serial/Makefile b/drivers/serial/Makefile
45770 --- a/drivers/serial/Makefile   Tue Jul 15 03:23:50 2003
45771 +++ b/drivers/serial/Makefile   Sun Aug 24 08:17:18 2003
45772 @@ -31,3 +31,4 @@
45773  obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o
45774  obj-$(CONFIG_V850E_UART) += v850e_uart.o
45775  obj-$(CONFIG_SERIAL98) += serial98.o
45776 +obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
45777 diff -Nru a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
45778 --- /dev/null   Wed Dec 31 16:00:00 1969
45779 +++ b/drivers/serial/pmac_zilog.c       Sun Aug 24 08:05:53 2003
45780 @@ -0,0 +1,1626 @@
45781 +/*
45782 + * linux/drivers/serial/pmac_zilog.c
45783 + * 
45784 + * Driver for PowerMac Z85c30 based ESCC cell found in the
45785 + * "macio" ASICs of various PowerMac models
45786 + * 
45787 + * Copyright (C) 2003 Ben. Herrenschmidt (benh@kernel.crashing.org)
45788 + *
45789 + * Derived from drivers/macintosh/macserial.c by Paul Mackerras
45790 + * and drivers/serial/sunzilog.c by David S. Miller
45791 + *
45792 + * Hrm... actually, I ripped most of sunzilog (Thanks David !) and
45793 + * adapted special tweaks needed for us. I don't think it's worth
45794 + * merging back those though. The DMA code still has to get in
45795 + * and once done, I expect that driver to remain fairly stable in
45796 + * the long term, unless we change the driver model again...
45797 + *
45798 + * This program is free software; you can redistribute it and/or modify
45799 + * it under the terms of the GNU General Public License as published by
45800 + * the Free Software Foundation; either version 2 of the License, or
45801 + * (at your option) any later version.
45802 + *
45803 + * This program is distributed in the hope that it will be useful,
45804 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
45805 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45806 + * GNU General Public License for more details.
45807 + *
45808 + * You should have received a copy of the GNU General Public License
45809 + * along with this program; if not, write to the Free Software
45810 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
45811 + *
45812 + * TODO:   - Add DMA support
45813 + *         - Defer port shutdown to a few seconds after close
45814 + *         - maybe put something right into up->clk_divisor
45815 + */
45816 +
45817 +#undef DEBUG
45818 +
45819 +#include <linux/config.h>
45820 +#include <linux/module.h>
45821 +#include <linux/tty.h>
45822 +
45823 +#include <linux/tty_flip.h>
45824 +#include <linux/major.h>
45825 +#include <linux/string.h>
45826 +#include <linux/fcntl.h>
45827 +#include <linux/mm.h>
45828 +#include <linux/kernel.h>
45829 +#include <linux/delay.h>
45830 +#include <linux/init.h>
45831 +#include <linux/console.h>
45832 +#include <linux/slab.h>
45833 +#include <linux/adb.h>
45834 +#include <linux/pmu.h>
45835 +#include <asm/sections.h>
45836 +#include <asm/io.h>
45837 +#include <asm/irq.h>
45838 +#include <asm/prom.h>
45839 +#include <asm/bitops.h>
45840 +#include <asm/machdep.h>
45841 +#include <asm/pmac_feature.h>
45842 +#include <asm/kgdb.h>
45843 +#include <asm/dbdma.h>
45844 +#include <asm/macio.h>
45845 +
45846 +#include <linux/serial.h>
45847 +#include <linux/serial_core.h>
45848 +
45849 +#include "pmac_zilog.h"
45850 +
45851 +
45852 +/* Not yet implemented */
45853 +#undef HAS_DBDMA
45854 +
45855 +static char version[] __initdata = "pmac_zilog.c 0.5a (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
45856 +MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
45857 +MODULE_DESCRIPTION("Driver for the PowerMac serial ports.");
45858 +MODULE_LICENSE("GPL");
45859 +
45860 +#define PWRDBG(fmt, arg...)    printk(KERN_DEBUG fmt , ## arg)
45861 +
45862 +
45863 +/*
45864 + * For the sake of early serial console, we can do a pre-probe
45865 + * (optional) of the ports at rather early boot time.
45866 + */
45867 +static struct uart_pmac_port   pmz_ports[MAX_ZS_PORTS];
45868 +static int                     pmz_ports_count;
45869 +
45870 +
45871 +/* 
45872 + * Load all registers to reprogram the port
45873 + * This function must only be called when the TX is not busy.  The UART
45874 + * port lock must be held and local interrupts disabled.
45875 + */
45876 +static void pmz_load_zsregs(struct uart_pmac_port *up, u8 *regs)
45877 +{
45878 +       int i;
45879 +
45880 +       /* Let pending transmits finish.  */
45881 +       for (i = 0; i < 1000; i++) {
45882 +               unsigned char stat = read_zsreg(up, R1);
45883 +               if (stat & ALL_SNT)
45884 +                       break;
45885 +               udelay(100);
45886 +       }
45887 +
45888 +       ZS_CLEARERR(up);
45889 +       zssync(up);
45890 +       ZS_CLEARFIFO(up);
45891 +       zssync(up);
45892 +       ZS_CLEARERR(up);
45893 +
45894 +       /* Disable all interrupts.  */
45895 +       write_zsreg(up, R1,
45896 +                   regs[R1] & ~(RxINT_MASK | TxINT_ENAB | EXT_INT_ENAB));
45897 +
45898 +       /* Set parity, sync config, stop bits, and clock divisor.  */
45899 +       write_zsreg(up, R4, regs[R4]);
45900 +
45901 +       /* Set misc. TX/RX control bits.  */
45902 +       write_zsreg(up, R10, regs[R10]);
45903 +
45904 +       /* Set TX/RX controls sans the enable bits.  */
45905 +       write_zsreg(up, R3, regs[R3] & ~RxENABLE);
45906 +       write_zsreg(up, R5, regs[R5] & ~TxENABLE);
45907 +
45908 +       /* Synchronous mode config.  */
45909 +       write_zsreg(up, R6, regs[R6]);
45910 +       write_zsreg(up, R7, regs[R7]);
45911 +
45912 +       /* Disable baud generator.  */
45913 +       write_zsreg(up, R14, regs[R14] & ~BRENAB);
45914 +
45915 +       /* Clock mode control.  */
45916 +       write_zsreg(up, R11, regs[R11]);
45917 +
45918 +       /* Lower and upper byte of baud rate generator divisor.  */
45919 +       write_zsreg(up, R12, regs[R12]);
45920 +       write_zsreg(up, R13, regs[R13]);
45921 +       
45922 +       /* Now rewrite R14, with BRENAB (if set).  */
45923 +       write_zsreg(up, R14, regs[R14]);
45924 +
45925 +       /* External status interrupt control.  */
45926 +       write_zsreg(up, R15, regs[R15]);
45927 +
45928 +       /* Reset external status interrupts.  */
45929 +       write_zsreg(up, R0, RES_EXT_INT);
45930 +       write_zsreg(up, R0, RES_EXT_INT);
45931 +
45932 +       /* Rewrite R3/R5, this time without enables masked.  */
45933 +       write_zsreg(up, R3, regs[R3]);
45934 +       write_zsreg(up, R5, regs[R5]);
45935 +
45936 +       /* Rewrite R1, this time without IRQ enabled masked.  */
45937 +       write_zsreg(up, R1, regs[R1]);
45938 +
45939 +       /* Enable interrupts */
45940 +       write_zsreg(up, R9, regs[R9]);
45941 +}
45942 +
45943 +/* 
45944 + * We do like sunzilog to avoid disrupting pending Tx
45945 + * Reprogram the Zilog channel HW registers with the copies found in the
45946 + * software state struct.  If the transmitter is busy, we defer this update
45947 + * until the next TX complete interrupt.  Else, we do it right now.
45948 + *
45949 + * The UART port lock must be held and local interrupts disabled.
45950 + */
45951 +static void pmz_maybe_update_regs(struct uart_pmac_port *up)
45952 +{
45953 +#if 1
45954 +               if (!ZS_REGS_HELD(up)) {
45955 +               if (ZS_TX_ACTIVE(up)) {
45956 +                       up->flags |= PMACZILOG_FLAG_REGS_HELD;
45957 +               } else {
45958 +                       pr_debug("pmz: maybe_update_regs: updating\n");
45959 +                       pmz_load_zsregs(up, up->curregs);
45960 +               }
45961 +       }
45962 +#else
45963 +               pr_debug("pmz: maybe_update_regs: updating\n");
45964 +        pmz_load_zsregs(up, up->curregs);
45965 +#endif
45966 +}
45967 +
45968 +static void pmz_receive_chars(struct uart_pmac_port *up, struct pt_regs *regs)
45969 +{
45970 +       struct tty_struct *tty = up->port.info->tty;    /* XXX info==NULL? */
45971 +
45972 +       while (1) {
45973 +               unsigned char ch, r1;
45974 +
45975 +               if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
45976 +                       tty->flip.work.func((void *)tty);
45977 +                       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
45978 +                               /* XXX Ignores SysRq when we need it most. Fix. */
45979 +                               return; 
45980 +               }
45981 +
45982 +               r1 = read_zsreg(up, R1);
45983 +               if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) {
45984 +                       write_zsreg(up, R0, ERR_RES);
45985 +                       zssync(up);
45986 +               }
45987 +
45988 +               ch = read_zsreg(up, R0);
45989 +
45990 +               /* This funny hack depends upon BRK_ABRT not interfering
45991 +                * with the other bits we care about in R1.
45992 +                */
45993 +               if (ch & BRK_ABRT)
45994 +                       r1 |= BRK_ABRT;
45995 +
45996 +               ch = read_zsdata(up);
45997 +               ch &= up->parity_mask;
45998 +
45999 +               /* A real serial line, record the character and status.  */
46000 +               *tty->flip.char_buf_ptr = ch;
46001 +               *tty->flip.flag_buf_ptr = TTY_NORMAL;
46002 +               up->port.icount.rx++;
46003 +               if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) {
46004 +                       if (r1 & BRK_ABRT) {
46005 +                               r1 &= ~(PAR_ERR | CRC_ERR);
46006 +                               up->port.icount.brk++;
46007 +                               if (uart_handle_break(&up->port))
46008 +                                       goto next_char;
46009 +                       }
46010 +                       else if (r1 & PAR_ERR)
46011 +                               up->port.icount.parity++;
46012 +                       else if (r1 & CRC_ERR)
46013 +                               up->port.icount.frame++;
46014 +                       if (r1 & Rx_OVR)
46015 +                               up->port.icount.overrun++;
46016 +                       r1 &= up->port.read_status_mask;
46017 +                       if (r1 & BRK_ABRT)
46018 +                               *tty->flip.flag_buf_ptr = TTY_BREAK;
46019 +                       else if (r1 & PAR_ERR)
46020 +                               *tty->flip.flag_buf_ptr = TTY_PARITY;
46021 +                       else if (r1 & CRC_ERR)
46022 +                               *tty->flip.flag_buf_ptr = TTY_FRAME;
46023 +               }
46024 +               if (uart_handle_sysrq_char(&up->port, ch, regs))
46025 +                       goto next_char;
46026 +
46027 +               if (up->port.ignore_status_mask == 0xff ||
46028 +                   (r1 & up->port.ignore_status_mask) == 0) {
46029 +                       tty->flip.flag_buf_ptr++;
46030 +                       tty->flip.char_buf_ptr++;
46031 +                       tty->flip.count++;
46032 +               }
46033 +               if ((r1 & Rx_OVR) &&
46034 +                   tty->flip.count < TTY_FLIPBUF_SIZE) {
46035 +                       *tty->flip.flag_buf_ptr = TTY_OVERRUN;
46036 +                       tty->flip.flag_buf_ptr++;
46037 +                       tty->flip.char_buf_ptr++;
46038 +                       tty->flip.count++;
46039 +               }
46040 +       next_char:
46041 +               ch = read_zsreg(up, R0);
46042 +               if (!(ch & Rx_CH_AV))
46043 +                       break;
46044 +       }
46045 +
46046 +       tty_flip_buffer_push(tty);
46047 +}
46048 +
46049 +static void pmz_status_handle(struct uart_pmac_port *up, struct pt_regs *regs)
46050 +{
46051 +       unsigned char status;
46052 +
46053 +       status = read_zsreg(up, R0);
46054 +       write_zsreg(up, R0, RES_EXT_INT);
46055 +       zssync(up);
46056 +
46057 +       if (ZS_WANTS_MODEM_STATUS(up)) {
46058 +               if (status & SYNC_HUNT)
46059 +                       up->port.icount.dsr++;
46060 +
46061 +               /* The Zilog just gives us an interrupt when DCD/CTS/etc. change.
46062 +                * But it does not tell us which bit has changed, we have to keep
46063 +                * track of this ourselves.
46064 +                */
46065 +               if ((status & DCD) ^ up->prev_status)
46066 +                       uart_handle_dcd_change(&up->port,
46067 +                                              (status & DCD));
46068 +               if ((status & CTS) ^ up->prev_status)
46069 +                       uart_handle_cts_change(&up->port,
46070 +                                              (status & CTS));
46071 +
46072 +               wake_up_interruptible(&up->port.info->delta_msr_wait);
46073 +       }
46074 +
46075 +       up->prev_status = status;
46076 +}
46077 +
46078 +static void pmz_transmit_chars(struct uart_pmac_port *up)
46079 +{
46080 +       struct circ_buf *xmit;
46081 +
46082 +       if (ZS_IS_CONS(up)) {
46083 +               unsigned char status = read_zsreg(up, R0);
46084 +
46085 +               /* TX still busy?  Just wait for the next TX done interrupt.
46086 +                *
46087 +                * It can occur because of how we do serial console writes.  It would
46088 +                * be nice to transmit console writes just like we normally would for
46089 +                * a TTY line. (ie. buffered and TX interrupt driven).  That is not
46090 +                * easy because console writes cannot sleep.  One solution might be
46091 +                * to poll on enough port->xmit space becomming free.  -DaveM
46092 +                */
46093 +               if (!(status & Tx_BUF_EMP))
46094 +                       return;
46095 +       }
46096 +
46097 +       up->flags &= ~PMACZILOG_FLAG_TX_ACTIVE;
46098 +
46099 +       if (ZS_REGS_HELD(up)) {
46100 +               pmz_load_zsregs(up, up->curregs);
46101 +               up->flags &= ~PMACZILOG_FLAG_REGS_HELD;
46102 +       }
46103 +
46104 +       if (ZS_TX_STOPPED(up)) {
46105 +               up->flags &= ~PMACZILOG_FLAG_TX_STOPPED;
46106 +               goto ack_tx_int;
46107 +       }
46108 +
46109 +       if (up->port.x_char) {
46110 +               up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
46111 +               write_zsdata(up, up->port.x_char);
46112 +               zssync(up);
46113 +               up->port.icount.tx++;
46114 +               up->port.x_char = 0;
46115 +               return;
46116 +       }
46117 +
46118 +       if (up->port.info == NULL)
46119 +               goto ack_tx_int;
46120 +       xmit = &up->port.info->xmit;
46121 +       if (uart_circ_empty(xmit)) {
46122 +               uart_write_wakeup(&up->port);
46123 +               goto ack_tx_int;
46124 +       }
46125 +       if (uart_tx_stopped(&up->port))
46126 +               goto ack_tx_int;
46127 +
46128 +       up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
46129 +       write_zsdata(up, xmit->buf[xmit->tail]);
46130 +       zssync(up);
46131 +
46132 +       xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
46133 +       up->port.icount.tx++;
46134 +
46135 +       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
46136 +               uart_write_wakeup(&up->port);
46137 +
46138 +       return;
46139 +
46140 +ack_tx_int:
46141 +       write_zsreg(up, R0, RES_Tx_P);
46142 +       zssync(up);
46143 +}
46144 +
46145 +/* Hrm... we register that twice, fixme later.... */
46146 +static irqreturn_t pmz_interrupt(int irq, void *dev_id, struct pt_regs *regs)
46147 +{
46148 +       struct uart_pmac_port *up = dev_id;
46149 +       struct uart_pmac_port *up_a;
46150 +       struct uart_pmac_port *up_b;
46151 +       int rc = IRQ_NONE;
46152 +       u8 r3;
46153 +
46154 +       up_a = ZS_IS_CHANNEL_A(up) ? up : up->mate;
46155 +       up_b = up_a->mate;
46156 +       
46157 +               spin_lock(&up_a->port.lock);
46158 +       r3 = read_zsreg(up, R3);
46159 +       pr_debug("pmz_irq: %x\n", r3);
46160 +
46161 +               /* Channel A */
46162 +               if (r3 & (CHAEXT | CHATxIP | CHARxIP)) {
46163 +               write_zsreg(up_a, R0, RES_H_IUS);
46164 +               zssync(up_a);           
46165 +               pr_debug("pmz: irq channel A: %x\n", r3);
46166 +               if (r3 & CHARxIP)
46167 +                       pmz_receive_chars(up_a, regs);
46168 +                       if (r3 & CHAEXT)
46169 +                               pmz_status_handle(up_a, regs);
46170 +                       if (r3 & CHATxIP)
46171 +                               pmz_transmit_chars(up_a);
46172 +               rc = IRQ_HANDLED;
46173 +               }
46174 +               spin_unlock(&up_a->port.lock);
46175 +       
46176 +               spin_lock(&up_b->port.lock);
46177 +       if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) {
46178 +               write_zsreg(up_b, R0, RES_H_IUS);
46179 +               zssync(up_b);
46180 +               pr_debug("pmz: irq channel B: %x\n", r3);
46181 +                       if (r3 & CHBRxIP)
46182 +                               pmz_receive_chars(up_b, regs);
46183 +                       if (r3 & CHBEXT)
46184 +                               pmz_status_handle(up_b, regs);
46185 +                       if (r3 & CHBTxIP)
46186 +                               pmz_transmit_chars(up_b);
46187 +               rc = IRQ_HANDLED;
46188 +               }
46189 +               spin_unlock(&up_b->port.lock);
46190 +
46191 +
46192 +       return rc;
46193 +}
46194 +
46195 +/*
46196 + * Peek the status register, lock not held by caller
46197 + */
46198 +static inline u8 pmz_peek_status(struct uart_pmac_port *up)
46199 +{
46200 +       unsigned long flags;
46201 +       u8 status;
46202 +       
46203 +       spin_lock_irqsave(&up->port.lock, flags);
46204 +       status = read_zsreg(up, R0);
46205 +       spin_unlock_irqrestore(&up->port.lock, flags);
46206 +
46207 +       return status;
46208 +}
46209 +
46210 +/* 
46211 + * Check if transmitter is empty
46212 + * The port lock is not held.
46213 + */
46214 +static unsigned int pmz_tx_empty(struct uart_port *port)
46215 +{
46216 +       unsigned char status;
46217 +
46218 +       status = pmz_peek_status(to_pmz(port));
46219 +       if (status & Tx_BUF_EMP)
46220 +               return TIOCSER_TEMT;
46221 +       return 0;
46222 +}
46223 +
46224 +/* 
46225 + * Set Modem Control (RTS & DTR) bits
46226 + * The port lock is held and interrupts are disabled.
46227 + * Note: Shall we really filter out RTS on external ports or
46228 + * should that be dealt at higher level only ?
46229 + */
46230 +static void pmz_set_mctrl(struct uart_port *port, unsigned int mctrl)
46231 +{
46232 +       struct uart_pmac_port *up = to_pmz(port);
46233 +       unsigned char set_bits, clear_bits;
46234 +
46235 +        /* Do nothing for irda for now... */
46236 +       if (ZS_IS_IRDA(up))
46237 +               return;
46238 +
46239 +       set_bits = clear_bits = 0;
46240 +
46241 +       if (ZS_IS_INTMODEM(up)) {
46242 +               if (mctrl & TIOCM_RTS)
46243 +                       set_bits |= RTS;
46244 +               else
46245 +                       clear_bits |= RTS;
46246 +       }
46247 +       if (mctrl & TIOCM_DTR)
46248 +               set_bits |= DTR;
46249 +       else
46250 +               clear_bits |= DTR;
46251 +
46252 +       /* NOTE: Not subject to 'transmitter active' rule.  */ 
46253 +       up->curregs[R5] |= set_bits;
46254 +       up->curregs[R5] &= ~clear_bits;
46255 +       write_zsreg(up, R5, up->curregs[R5]);
46256 +       zssync(up);
46257 +}
46258 +
46259 +/* 
46260 + * Get Modem Control bits (only the input ones, the core will
46261 + * or that with a cached value of the control ones)
46262 + * The port lock is not held.
46263 + */
46264 +static unsigned int pmz_get_mctrl(struct uart_port *port)
46265 +{
46266 +       unsigned char status;
46267 +       unsigned int ret;
46268 +
46269 +       status = pmz_peek_status(to_pmz(port));
46270 +
46271 +       ret = 0;
46272 +       if (status & DCD)
46273 +               ret |= TIOCM_CAR;
46274 +       if (status & SYNC_HUNT)
46275 +               ret |= TIOCM_DSR;
46276 +       if (status & CTS)
46277 +               ret |= TIOCM_CTS;
46278 +
46279 +       return ret;
46280 +}
46281 +
46282 +/* 
46283 + * Stop TX side. Dealt like sunzilog at next Tx interrupt,
46284 + * though for DMA, we will have to do a bit more. What is
46285 + * the meaning of the tty_stop bit ? XXX
46286 + * The port lock is held and interrupts are disabled.
46287 + */
46288 +static void pmz_stop_tx(struct uart_port *port, unsigned int tty_stop)
46289 +{
46290 +       to_pmz(port)->flags |= PMACZILOG_FLAG_TX_STOPPED;
46291 +}
46292 +
46293 +/* 
46294 + * Kick the Tx side.
46295 + * The port lock is held and interrupts are disabled.
46296 + */
46297 +static void pmz_start_tx(struct uart_port *port, unsigned int tty_start)
46298 +{
46299 +       struct uart_pmac_port *up = to_pmz(port);
46300 +       unsigned char status;
46301 +
46302 +       pr_debug("pmz: start_tx()\n");
46303 +
46304 +       up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
46305 +       up->flags &= ~PMACZILOG_FLAG_TX_STOPPED;
46306 +
46307 +       status = read_zsreg(up, R0);
46308 +
46309 +       /* TX busy?  Just wait for the TX done interrupt.  */
46310 +       if (!(status & Tx_BUF_EMP))
46311 +               return;
46312 +
46313 +       /* Send the first character to jump-start the TX done
46314 +        * IRQ sending engine.
46315 +        */
46316 +       if (port->x_char) {
46317 +               write_zsdata(up, port->x_char);
46318 +               zssync(up);
46319 +               port->icount.tx++;
46320 +               port->x_char = 0;
46321 +       } else {
46322 +               struct circ_buf *xmit = &port->info->xmit;
46323 +
46324 +               write_zsdata(up, xmit->buf[xmit->tail]);
46325 +               zssync(up);
46326 +               xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
46327 +               port->icount.tx++;
46328 +
46329 +               if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
46330 +                       uart_write_wakeup(&up->port);
46331 +       }
46332 +       pr_debug("pmz: start_tx() done.\n");
46333 +}
46334 +
46335 +/* 
46336 + * Stop Rx side, basically disable emitting of
46337 + * Rx interrupts on the port
46338 + * The port lock is held.
46339 + */
46340 +static void pmz_stop_rx(struct uart_port *port)
46341 +{
46342 +       struct uart_pmac_port *up = to_pmz(port);
46343 +
46344 +       if (ZS_IS_CONS(up))
46345 +               return;
46346 +
46347 +       pr_debug("pmz: stop_rx()()\n");
46348 +
46349 +       /* Disable all RX interrupts.  */
46350 +       up->curregs[R1] &= ~RxINT_MASK;
46351 +       pmz_maybe_update_regs(up);
46352 +
46353 +       pr_debug("pmz: stop_rx() done.\n");
46354 +}
46355 +
46356 +/* 
46357 + * Enable modem status change interrupts
46358 + * The port lock is not held.
46359 + */
46360 +static void pmz_enable_ms(struct uart_port *port)
46361 +{
46362 +       struct uart_pmac_port *up = to_pmz(port);
46363 +       unsigned char new_reg;
46364 +       unsigned long flags;
46365 +
46366 +       spin_lock_irqsave(&port->lock, flags);
46367 +
46368 +       new_reg = up->curregs[R15] | (DCDIE | SYNCIE | CTSIE);
46369 +       if (new_reg != up->curregs[R15]) {
46370 +               up->curregs[R15] = new_reg;
46371 +
46372 +               /* NOTE: Not subject to 'transmitter active' rule.  */ 
46373 +               write_zsreg(up, R15, up->curregs[R15]);
46374 +       }
46375 +
46376 +       spin_unlock_irqrestore(&port->lock, flags);
46377 +}
46378 +
46379 +/* 
46380 + * Control break state emission
46381 + * The port lock is not held.
46382 + */
46383 +static void pmz_break_ctl(struct uart_port *port, int break_state)
46384 +{
46385 +       struct uart_pmac_port *up = to_pmz(port);
46386 +       unsigned char set_bits, clear_bits, new_reg;
46387 +       unsigned long flags;
46388 +
46389 +       set_bits = clear_bits = 0;
46390 +
46391 +       if (break_state)
46392 +               set_bits |= SND_BRK;
46393 +       else
46394 +               clear_bits |= SND_BRK;
46395 +
46396 +       spin_lock_irqsave(&port->lock, flags);
46397 +
46398 +       new_reg = (up->curregs[R5] | set_bits) & ~clear_bits;
46399 +       if (new_reg != up->curregs[R5]) {
46400 +               up->curregs[R5] = new_reg;
46401 +
46402 +               /* NOTE: Not subject to 'transmitter active' rule.  */ 
46403 +               write_zsreg(up, R5, up->curregs[R5]);
46404 +       }
46405 +
46406 +       spin_unlock_irqrestore(&port->lock, flags);
46407 +}
46408 +
46409 +/*
46410 + * Turn power on or off to the SCC and associated stuff
46411 + * (port drivers, modem, IR port, etc.)
46412 + * Returns the number of milliseconds we should wait before
46413 + * trying to use the port.
46414 + */
46415 +static int pmz_set_scc_power(struct uart_pmac_port *up, int state)
46416 +{
46417 +       int delay = 0;
46418 +
46419 +       if (state) {
46420 +               pmac_call_feature(
46421 +                       PMAC_FTR_SCC_ENABLE, up->node, up->port_type, 1);
46422 +               if (ZS_IS_INTMODEM(up)) {
46423 +                       pmac_call_feature(
46424 +                               PMAC_FTR_MODEM_ENABLE, up->node, 0, 1);
46425 +                       delay = 2500;   /* wait for 2.5s before using */
46426 +               } else if (ZS_IS_IRDA(up))
46427 +                       mdelay(50);     /* Do better here once the problems
46428 +                                        * with blocking have been ironed out
46429 +                                        */
46430 +       } else {
46431 +               /* TODO: Make that depend on a timer, don't power down
46432 +                * immediately
46433 +                */
46434 +               if (ZS_IS_INTMODEM(up)) {
46435 +                       pmac_call_feature(
46436 +                               PMAC_FTR_MODEM_ENABLE, up->node, 0, 0);
46437 +               }
46438 +               pmac_call_feature(
46439 +                       PMAC_FTR_SCC_ENABLE, up->node, up->port_type, 0);
46440 +       }
46441 +       return delay;
46442 +}
46443 +
46444 +/*
46445 + * FixZeroBug....Works around a bug in the SCC receving channel.
46446 + * Taken from Darwin code, 15 Sept. 2000  -DanM
46447 + *
46448 + * The following sequence prevents a problem that is seen with O'Hare ASICs
46449 + * (most versions -- also with some Heathrow and Hydra ASICs) where a zero
46450 + * at the input to the receiver becomes 'stuck' and locks up the receiver.
46451 + * This problem can occur as a result of a zero bit at the receiver input
46452 + * coincident with any of the following events:
46453 + *
46454 + *     The SCC is initialized (hardware or software).
46455 + *     A framing error is detected.
46456 + *     The clocking option changes from synchronous or X1 asynchronous
46457 + *             clocking to X16, X32, or X64 asynchronous clocking.
46458 + *     The decoding mode is changed among NRZ, NRZI, FM0, or FM1.
46459 + *
46460 + * This workaround attempts to recover from the lockup condition by placing
46461 + * the SCC in synchronous loopback mode with a fast clock before programming
46462 + * any of the asynchronous modes.
46463 + */
46464 +static void pmz_fix_zero_bug_scc(struct uart_pmac_port *up)
46465 +{
46466 +       write_zsreg(up, 9, ZS_IS_CHANNEL_A(up) ? CHRA : CHRB);
46467 +       zssync(up);
46468 +       udelay(10);
46469 +       write_zsreg(up, 9, (ZS_IS_CHANNEL_A(up) ? CHRA : CHRB) | NV);
46470 +       zssync(up);
46471 +
46472 +       write_zsreg(up, 4, (X1CLK | EXTSYNC));
46473 +
46474 +       /* I think this is wrong....but, I just copying code....
46475 +       */
46476 +       write_zsreg(up, 3, (8 & ~RxENABLE));
46477 +
46478 +       write_zsreg(up, 5, (8 & ~TxENABLE));
46479 +       write_zsreg(up, 9, NV); /* Didn't we already do this? */
46480 +       write_zsreg(up, 11, (RCBR | TCBR));
46481 +       write_zsreg(up, 12, 0);
46482 +       write_zsreg(up, 13, 0);
46483 +       write_zsreg(up, 14, (LOOPBAK | SSBR));
46484 +       write_zsreg(up, 14, (LOOPBAK | SSBR | BRENAB));
46485 +       write_zsreg(up, 3, (8 | RxENABLE));
46486 +       write_zsreg(up, 0, RES_EXT_INT);
46487 +       write_zsreg(up, 0, RES_EXT_INT);        /* to kill some time */
46488 +
46489 +       /* The channel should be OK now, but it is probably receiving
46490 +        * loopback garbage.
46491 +        * Switch to asynchronous mode, disable the receiver,
46492 +        * and discard everything in the receive buffer.
46493 +        */
46494 +       write_zsreg(up, 9, NV);
46495 +       write_zsreg(up, 4, PAR_ENAB);
46496 +       write_zsreg(up, 3, (8 & ~RxENABLE));
46497 +
46498 +       while (read_zsreg(up, 0) & Rx_CH_AV) {
46499 +               (void)read_zsreg(up, 8);
46500 +               write_zsreg(up, 0, RES_EXT_INT);
46501 +               write_zsreg(up, 0, ERR_RES);
46502 +       }
46503 +}
46504 +
46505 +/*
46506 + * Real startup routine, powers up the hardware and sets up
46507 + * the SCC. Returns a delay in ms where you need to wait before
46508 + * actually using the port, this is typically the internal modem
46509 + * powerup delay. This routine expect the lock to be taken.
46510 + */
46511 +static int __pmz_startup(struct uart_pmac_port *up)
46512 +{
46513 +       int pwr_delay = 0;
46514 +
46515 +       memset(&up->curregs, 0, sizeof(up->curregs));
46516 +
46517 +       /* Power up the SCC & underlying hardware (modem/irda) */
46518 +       pwr_delay = pmz_set_scc_power(up, 1);
46519 +
46520 +       /* Nice buggy HW ... */
46521 +       pmz_fix_zero_bug_scc(up);
46522 +
46523 +       /* Reset the chip */
46524 +       write_zsreg(up, 9, ZS_IS_CHANNEL_A(up) ? CHRA : CHRB);
46525 +       zssync(up);
46526 +       udelay(10);
46527 +       write_zsreg(up, 9, 0);
46528 +       zssync(up);
46529 +
46530 +       /* Clear the interrupt registers */
46531 +       write_zsreg(up, R1, 0);
46532 +       write_zsreg(up, R0, ERR_RES);
46533 +       write_zsreg(up, R0, ERR_RES);
46534 +       write_zsreg(up, R0, RES_H_IUS);
46535 +       write_zsreg(up, R0, RES_H_IUS);
46536 +
46537 +       /* Remember status for DCD/CTS changes */
46538 +       up->prev_status = read_zsreg(up, R0);
46539 +
46540 +       /* Enable receiver and transmitter.  */
46541 +       up->curregs[R3] |= RxENABLE;
46542 +       up->curregs[R5] |= TxENABLE | RTS | DTR;
46543 +
46544 +       /* Master interrupt enable */
46545 +       up->curregs[R9] |= NV | MIE;
46546 +
46547 +       up->curregs[R1] |= EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB;
46548 +       //      pmz_maybe_update_regs(up);
46549 +
46550 +       return pwr_delay;
46551 +}
46552 +
46553 +/*
46554 + * This is the "normal" startup routine, using the above one
46555 + * wrapped with the lock and doing a schedule delay
46556 + */
46557 +static int pmz_startup(struct uart_port *port)
46558 +{
46559 +       struct uart_pmac_port *up = to_pmz(port);
46560 +       unsigned long flags;
46561 +       int pwr_delay = 0;
46562 +
46563 +       pr_debug("pmz: startup()\n");
46564 +
46565 +       /* A console is never powered down */
46566 +       if (!ZS_IS_CONS(up)) {
46567 +               spin_lock_irqsave(&port->lock, flags);
46568 +               pwr_delay = __pmz_startup(up);
46569 +               spin_unlock_irqrestore(&port->lock, flags);
46570 +       }
46571 +       
46572 +       if (request_irq(up->port.irq, pmz_interrupt, SA_SHIRQ, "PowerMac Zilog", up)) {
46573 +               printk(KERN_ERR "Unable to register zs interrupt handler.\n");
46574 +               pmz_set_scc_power(up, 0);
46575 +               return -ENXIO;
46576 +       }
46577 +
46578 +       /* Right now, we deal with delay by blocking here, I'll be
46579 +        * smarter later on
46580 +        */
46581 +       if (pwr_delay != 0) {
46582 +               pr_debug("pmz: delaying %d ms\n", pwr_delay);
46583 +               set_current_state(TASK_UNINTERRUPTIBLE);
46584 +               schedule_timeout((pwr_delay * HZ)/1000);
46585 +       }
46586 +
46587 +       pr_debug("pmz: startup() done.\n");
46588 +
46589 +       return 0;
46590 +}
46591 +
46592 +static void pmz_shutdown(struct uart_port *port)
46593 +{
46594 +       struct uart_pmac_port *up = to_pmz(port);
46595 +       unsigned long flags;
46596 +
46597 +       pr_debug("pmz: shutdown()\n");
46598 +
46599 +       /* Release interrupt handler */
46600 +               free_irq(up->port.irq, up);
46601 +
46602 +       if (ZS_IS_CONS(up))
46603 +               return;
46604 +
46605 +       spin_lock_irqsave(&port->lock, flags);
46606 +
46607 +       /* Disable receiver and transmitter.  */
46608 +       up->curregs[R3] &= ~RxENABLE;
46609 +       up->curregs[R5] &= ~TxENABLE;
46610 +
46611 +       /* Disable all interrupts and BRK assertion.  */
46612 +       up->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK);
46613 +       up->curregs[R5] &= ~SND_BRK;
46614 +       pmz_maybe_update_regs(up);
46615 +
46616 +       /* Shut the chip down */
46617 +       pmz_set_scc_power(up, 0);
46618 +
46619 +       spin_unlock_irqrestore(&port->lock, flags);
46620 +
46621 +       pr_debug("pmz: shutdown() done.\n");
46622 +}
46623 +
46624 +/* Shared by TTY driver and serial console setup.  The port lock is held
46625 + * and local interrupts are disabled.
46626 + */
46627 +static void
46628 +pmz_convert_to_zs(struct uart_pmac_port *up, unsigned int cflag,
46629 +                      unsigned int iflag, int baud)
46630 +{
46631 +       int brg;
46632 +
46633 +       switch (baud) {
46634 +       case ZS_CLOCK/16:       /* 230400 */
46635 +               up->curregs[R4] = X16CLK;
46636 +               up->curregs[R11] = 0;
46637 +               break;
46638 +       case ZS_CLOCK/32:       /* 115200 */
46639 +               up->curregs[R4] = X32CLK;
46640 +               up->curregs[R11] = 0;
46641 +               break;
46642 +       default:
46643 +               up->curregs[R4] = X16CLK;
46644 +               up->curregs[R11] = TCBR | RCBR;
46645 +               brg = BPS_TO_BRG(baud, ZS_CLOCK / 16);
46646 +               up->curregs[R12] = (brg & 255);
46647 +               up->curregs[R13] = ((brg >> 8) & 255);
46648 +               up->curregs[R14] = BRENAB;
46649 +       }
46650 +
46651 +       /* Character size, stop bits, and parity. */
46652 +       up->curregs[3] &= ~RxN_MASK;
46653 +       up->curregs[5] &= ~TxN_MASK;
46654 +
46655 +       switch (cflag & CSIZE) {
46656 +       case CS5:
46657 +               up->curregs[3] |= Rx5;
46658 +               up->curregs[5] |= Tx5;
46659 +               up->parity_mask = 0x1f;
46660 +               break;
46661 +       case CS6:
46662 +               up->curregs[3] |= Rx6;
46663 +               up->curregs[5] |= Tx6;
46664 +               up->parity_mask = 0x3f;
46665 +               break;
46666 +       case CS7:
46667 +               up->curregs[3] |= Rx7;
46668 +               up->curregs[5] |= Tx7;
46669 +               up->parity_mask = 0x7f;
46670 +               break;
46671 +       case CS8:
46672 +       default:
46673 +               up->curregs[3] |= Rx8;
46674 +               up->curregs[5] |= Tx8;
46675 +               up->parity_mask = 0xff;
46676 +               break;
46677 +       };
46678 +       up->curregs[4] &= ~(SB_MASK);
46679 +       if (cflag & CSTOPB)
46680 +               up->curregs[4] |= SB2;
46681 +       else
46682 +               up->curregs[4] |= SB1;
46683 +       if (cflag & PARENB)
46684 +               up->curregs[4] |= PAR_ENAB;
46685 +       else
46686 +               up->curregs[4] &= ~PAR_ENAB;
46687 +       if (!(cflag & PARODD))
46688 +               up->curregs[4] |= PAR_EVEN;
46689 +       else
46690 +               up->curregs[4] &= ~PAR_EVEN;
46691 +
46692 +       up->port.read_status_mask = Rx_OVR;
46693 +       if (iflag & INPCK)
46694 +               up->port.read_status_mask |= CRC_ERR | PAR_ERR;
46695 +       if (iflag & (BRKINT | PARMRK))
46696 +               up->port.read_status_mask |= BRK_ABRT;
46697 +
46698 +       up->port.ignore_status_mask = 0;
46699 +       if (iflag & IGNPAR)
46700 +               up->port.ignore_status_mask |= CRC_ERR | PAR_ERR;
46701 +       if (iflag & IGNBRK) {
46702 +               up->port.ignore_status_mask |= BRK_ABRT;
46703 +               if (iflag & IGNPAR)
46704 +                       up->port.ignore_status_mask |= Rx_OVR;
46705 +       }
46706 +
46707 +       if ((cflag & CREAD) == 0)
46708 +               up->port.ignore_status_mask = 0xff;
46709 +}
46710 +
46711 +static void pmz_irda_rts_pulses(struct uart_pmac_port *up, int w)
46712 +{
46713 +       udelay(w);
46714 +       write_zsreg(up, 5, Tx8 | TxENABLE);
46715 +       zssync(up);
46716 +       udelay(2);
46717 +       write_zsreg(up, 5, Tx8 | TxENABLE | RTS);
46718 +       zssync(up);
46719 +       udelay(8);
46720 +       write_zsreg(up, 5, Tx8 | TxENABLE);
46721 +       zssync(up);
46722 +       udelay(4);
46723 +       write_zsreg(up, 5, Tx8 | TxENABLE | RTS);
46724 +       zssync(up);
46725 +}
46726 +
46727 +/*
46728 + * Set the irda codec on the imac to the specified baud rate.
46729 + */
46730 +static void pmz_irda_setup(struct uart_pmac_port *up, int cflags)
46731 +{
46732 +       int code, speed, t;
46733 +
46734 +       speed = cflags & CBAUD;
46735 +       if (speed < B2400 || speed > B115200)
46736 +               return;
46737 +       code = 0x4d + B115200 - speed;
46738 +
46739 +       /* disable serial interrupts and receive DMA */
46740 +       write_zsreg(up, 1, up->curregs[1] & ~0x9f);
46741 +
46742 +       /* wait for transmitter to drain */
46743 +       t = 10000;
46744 +       while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0
46745 +              || (read_zsreg(up, R1) & ALL_SNT) == 0) {
46746 +               if (--t <= 0) {
46747 +                       printk(KERN_ERR "transmitter didn't drain\n");
46748 +                       return;
46749 +               }
46750 +               udelay(10);
46751 +       }
46752 +       udelay(100);
46753 +
46754 +       /* set to 8 bits, no parity, 19200 baud, RTS on, DTR off */
46755 +       write_zsreg(up, R4, X16CLK | SB1);
46756 +       write_zsreg(up, R11, TCBR | RCBR);
46757 +       t = BPS_TO_BRG(19200, ZS_CLOCK/16);
46758 +       write_zsreg(up, R12, t);
46759 +       write_zsreg(up, R13, t >> 8);
46760 +       write_zsreg(up, R14, BRENAB);
46761 +       write_zsreg(up, R3, Rx8 | RxENABLE);
46762 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS);
46763 +       zssync(up);
46764 +
46765 +       /* set TxD low for ~104us and pulse RTS */
46766 +       udelay(1000);
46767 +       write_zsdata(up, 0xfe);
46768 +       pmz_irda_rts_pulses(up, 150);
46769 +       pmz_irda_rts_pulses(up, 180);
46770 +       pmz_irda_rts_pulses(up, 50);
46771 +       udelay(100);
46772 +
46773 +       /* assert DTR, wait 30ms, talk to the chip */
46774 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS | DTR);
46775 +       zssync(up);
46776 +       mdelay(30);
46777 +       while (read_zsreg(up, R0) & Rx_CH_AV)
46778 +               read_zsdata(up);
46779 +
46780 +       write_zsdata(up, 1);
46781 +       t = 1000;
46782 +       while ((read_zsreg(up, R0) & Rx_CH_AV) == 0) {
46783 +               if (--t <= 0) {
46784 +                       printk(KERN_ERR "irda_setup timed out on 1st byte\n");
46785 +                       goto out;
46786 +               }
46787 +               udelay(10);
46788 +       }
46789 +       t = read_zsdata(up);
46790 +       if (t != 4)
46791 +               printk(KERN_ERR "irda_setup 1st byte = %x\n", t);
46792 +
46793 +       write_zsdata(up, code);
46794 +       t = 1000;
46795 +       while ((read_zsreg(up, R0) & Rx_CH_AV) == 0) {
46796 +               if (--t <= 0) {
46797 +                       printk(KERN_ERR "irda_setup timed out on 2nd byte\n");
46798 +                       goto out;
46799 +               }
46800 +               udelay(10);
46801 +       }
46802 +       t = read_zsdata(up);
46803 +       if (t != code)
46804 +               printk(KERN_ERR "irda_setup 2nd byte = %x (%x)\n", t, code);
46805 +
46806 +       /* Drop DTR again and do some more RTS pulses */
46807 + out:
46808 +       udelay(100);
46809 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS);
46810 +       pmz_irda_rts_pulses(up, 80);
46811 +
46812 +       /* We should be right to go now.  We assume that load_zsregs
46813 +          will get called soon to load up the correct baud rate etc. */
46814 +       up->curregs[R5] = (up->curregs[R5] | RTS) & ~DTR;
46815 +}
46816 +
46817 +/* The port lock is not held.  */
46818 +static void
46819 +pmz_set_termios(struct uart_port *port, struct termios *termios,
46820 +                    struct termios *old)
46821 +{
46822 +       struct uart_pmac_port *up = to_pmz(port);
46823 +       unsigned long flags;
46824 +       int baud;
46825 +
46826 +       pr_debug("pmz: set_termios()\n");
46827 +
46828 +       baud = uart_get_baud_rate(port, termios, old, 1200, 230400);
46829 +
46830 +       spin_lock_irqsave(&up->port.lock, flags);
46831 +
46832 +       pmz_convert_to_zs(up, termios->c_cflag, termios->c_iflag, baud);
46833 +
46834 +       if (UART_ENABLE_MS(&up->port, termios->c_cflag))
46835 +               up->flags |= PMACZILOG_FLAG_MODEM_STATUS;
46836 +       else
46837 +               up->flags &= ~PMACZILOG_FLAG_MODEM_STATUS;
46838 +
46839 +       /* set the irda codec to the right rate */
46840 +       if (ZS_IS_IRDA(up))
46841 +               pmz_irda_setup(up, termios->c_cflag);
46842 +
46843 +       /* Load registers to the chip */
46844 +       pmz_maybe_update_regs(up);
46845 +
46846 +       spin_unlock_irqrestore(&up->port.lock, flags);
46847 +
46848 +       pr_debug("pmz: set_termios() done.\n");
46849 +}
46850 +
46851 +static const char *pmz_type(struct uart_port *port)
46852 +{
46853 +       return "PowerMac Zilog";
46854 +}
46855 +
46856 +/* We do not request/release mappings of the registers here, this
46857 + * happens at early serial probe time.
46858 + */
46859 +static void pmz_release_port(struct uart_port *port)
46860 +{
46861 +}
46862 +
46863 +static int pmz_request_port(struct uart_port *port)
46864 +{
46865 +       return 0;
46866 +}
46867 +
46868 +/* These do not need to do anything interesting either.  */
46869 +static void pmz_config_port(struct uart_port *port, int flags)
46870 +{
46871 +}
46872 +
46873 +/* We do not support letting the user mess with the divisor, IRQ, etc. */
46874 +static int pmz_verify_port(struct uart_port *port, struct serial_struct *ser)
46875 +{
46876 +       return -EINVAL;
46877 +}
46878 +
46879 +static struct uart_ops pmz_pops = {
46880 +       .tx_empty       =       pmz_tx_empty,
46881 +       .set_mctrl      =       pmz_set_mctrl,
46882 +       .get_mctrl      =       pmz_get_mctrl,
46883 +       .stop_tx        =       pmz_stop_tx,
46884 +       .start_tx       =       pmz_start_tx,
46885 +       .stop_rx        =       pmz_stop_rx,
46886 +       .enable_ms      =       pmz_enable_ms,
46887 +       .break_ctl      =       pmz_break_ctl,
46888 +       .startup        =       pmz_startup,
46889 +       .shutdown       =       pmz_shutdown,
46890 +       .set_termios    =       pmz_set_termios,
46891 +       .type           =       pmz_type,
46892 +       .release_port   =       pmz_release_port,
46893 +       .request_port   =       pmz_request_port,
46894 +       .config_port    =       pmz_config_port,
46895 +       .verify_port    =       pmz_verify_port,
46896 +};
46897 +
46898 +/*
46899 + * Setup one port structure after probing, HW is down at this point,
46900 + * Unlike sunzilog, we don't need to pre-init the spinlock as we don't
46901 + * register our console before uart_add_one_port() is called
46902 + */
46903 +static int __init pmz_setup_port(struct uart_pmac_port *up, int early)
46904 +{
46905 +       struct device_node *np = up->node;
46906 +       char *conn;
46907 +       struct slot_names_prop {
46908 +               int     count;
46909 +               char    name[1];
46910 +       } *slots;
46911 +       int len;
46912 +
46913 +       /*
46914 +        * Request & map chip registers
46915 +        */
46916 +       if (!early && request_OF_resource(np, 0, NULL) == NULL) {
46917 +               printk("pmac_zilog: failed to request resources for %s\n",
46918 +                       np->full_name);
46919 +               return -EBUSY;
46920 +       }
46921 +       up->port.mapbase = np->addrs[0].address;
46922 +       up->port.membase = ioremap(up->port.mapbase, 0x1000);
46923 +      
46924 +       up->control_reg = (volatile u8 *)up->port.membase;
46925 +       up->data_reg = up->control_reg + 0x10;
46926 +       
46927 +       /*
46928 +        * Request & map DBDMA registers
46929 +        */
46930 +#ifdef HAS_DBDMA
46931 +       if (np->n_addrs >= 3 && np->n_intrs >= 3)
46932 +               up->flags |= PMACZILOG_FLAG_HAS_DMA;
46933 +#endif 
46934 +       if (ZS_HAS_DMA(up)) {
46935 +               if (!early && request_OF_resource(np, np->n_addrs - 2, " (tx dma)") == NULL) {
46936 +                       printk(KERN_ERR "pmac_zilog: can't request TX DMA resource !\n");
46937 +                       up->flags &= ~PMACZILOG_FLAG_HAS_DMA;
46938 +                       goto no_dma;
46939 +               }
46940 +               if (!early && request_OF_resource(np, np->n_addrs - 1, " (rx dma)") == NULL) {
46941 +                       release_OF_resource(np, np->n_addrs - 2);
46942 +                       printk(KERN_ERR "pmac_zilog: can't request RX DMA resource !\n");
46943 +                       up->flags &= ~PMACZILOG_FLAG_HAS_DMA;
46944 +                       goto no_dma;
46945 +               }
46946 +               up->tx_dma_regs = (volatile struct dbdma_regs *)
46947 +                       ioremap(np->addrs[np->n_addrs - 2].address, 0x1000);
46948 +               up->rx_dma_regs = (volatile struct dbdma_regs *)
46949 +                       ioremap(np->addrs[np->n_addrs - 1].address, 0x1000);
46950 +               up->tx_dma_irq = np->intrs[1].line;
46951 +               up->rx_dma_irq = np->intrs[2].line;
46952 +       }
46953 +no_dma:
46954 +       if (!early)
46955 +               up->flags |= PMACZILOG_FLAG_RSRC_REQUESTED;
46956 +
46957 +       /*
46958 +        * Detect port type
46959 +        */
46960 +       if (device_is_compatible(np, "cobalt"))
46961 +               up->flags |= PMACZILOG_FLAG_IS_INTMODEM;
46962 +       conn = get_property(np, "AAPL,connector", &len);
46963 +       if (conn && (strcmp(conn, "infrared") == 0))
46964 +               up->flags |= PMACZILOG_FLAG_IS_IRDA;
46965 +       up->port_type = PMAC_SCC_ASYNC;
46966 +       /* 1999 Powerbook G3 has slot-names property instead */
46967 +       slots = (struct slot_names_prop *)get_property(np, "slot-names", &len);
46968 +       if (slots && slots->count > 0) {
46969 +               if (strcmp(slots->name, "IrDA") == 0)
46970 +                       up->flags |= PMACZILOG_FLAG_IS_IRDA;
46971 +               else if (strcmp(slots->name, "Modem") == 0)
46972 +                       up->flags |= PMACZILOG_FLAG_IS_INTMODEM;
46973 +       }
46974 +       if (ZS_IS_IRDA(up))
46975 +               up->port_type = PMAC_SCC_IRDA;
46976 +       if (ZS_IS_INTMODEM(up)) {
46977 +               struct device_node* i2c_modem = find_devices("i2c-modem");
46978 +               if (i2c_modem) {
46979 +                       char* mid = get_property(i2c_modem, "modem-id", NULL);
46980 +                       if (mid) switch(*mid) {
46981 +                       case 0x04 :
46982 +                       case 0x05 :
46983 +                       case 0x07 :
46984 +                       case 0x08 :
46985 +                       case 0x0b :
46986 +                       case 0x0c :
46987 +                               up->port_type = PMAC_SCC_I2S1;
46988 +                       }
46989 +                       printk(KERN_INFO "pmac_zilog: i2c-modem detected, id: %d\n",
46990 +                               mid ? (*mid) : 0);
46991 +               } else {
46992 +                       printk(KERN_INFO "pmac_zilog: serial modem detected\n");
46993 +               }
46994 +       }
46995 +
46996 +       /*
46997 +        * Init remaining bits of "port" structure
46998 +        */
46999 +       up->port.iotype = SERIAL_IO_MEM;
47000 +       up->port.irq = np->intrs[0].line;
47001 +       up->port.uartclk = ZS_CLOCK;
47002 +       up->port.fifosize = 1;
47003 +       up->port.ops = &pmz_pops;
47004 +       up->port.type = PORT_PMAC_ZILOG;
47005 +       up->port.flags = 0;
47006 +
47007 +       return 0;
47008 +}
47009 +
47010 +/*
47011 + * Get rid of a port on module removal
47012 + */
47013 +static void pmz_dispose_port(struct uart_pmac_port *up)
47014 +{
47015 +       struct device_node *np;
47016 +
47017 +       if (up->flags & PMACZILOG_FLAG_RSRC_REQUESTED) {
47018 +               release_OF_resource(up->node, 0);
47019 +               if (ZS_HAS_DMA(up)) {
47020 +                       release_OF_resource(up->node, up->node->n_addrs - 2);
47021 +                       release_OF_resource(up->node, up->node->n_addrs - 1);
47022 +               }
47023 +       }
47024 +       iounmap((void *)up->control_reg);
47025 +       np = up->node;
47026 +       up->node = NULL;
47027 +       of_node_put(np);
47028 +}
47029 +
47030 +/*
47031 + * Called upon match with an escc node in the devive-tree.
47032 + */
47033 +static int pmz_attach(struct macio_dev *mdev, const struct of_match *match)
47034 +{
47035 +       int i;
47036 +       
47037 +       /* Iterate the pmz_ports array to find a matching entry
47038 +        */
47039 +       for (i = 0; i < MAX_ZS_PORTS; i++)
47040 +               if (pmz_ports[i].node == mdev->ofdev.node) {
47041 +                       pmz_ports[i].dev = mdev;
47042 +                       dev_set_drvdata(&mdev->ofdev.dev, &pmz_ports[i]);
47043 +                       return 0;
47044 +               }
47045 +       return -ENODEV;
47046 +}
47047 +
47048 +/*
47049 + * That one should not be called, macio isn't really a hotswap device,
47050 + * we don't expect one of those serial ports to go away...
47051 + */
47052 +static int pmz_detach(struct macio_dev *mdev)
47053 +{
47054 +       struct uart_pmac_port   *port = dev_get_drvdata(&mdev->ofdev.dev);
47055 +       
47056 +       if (!port)
47057 +               return -ENODEV;
47058 +
47059 +       dev_set_drvdata(&mdev->ofdev.dev, NULL);
47060 +       port->dev = NULL;
47061 +       
47062 +       return 0;
47063 +}
47064 +
47065 +/*
47066 + * Probe all ports in the system and build the ports array, we register
47067 + * with the serial layer at this point, the macio-type probing is only
47068 + * used later to "attach" to the sysfs tree so we get power management
47069 + * events
47070 + */
47071 +static int __init pmz_probe(int early)
47072 +{
47073 +       struct device_node      *node_p, *node_a, *node_b, *np;
47074 +       int                     count = 0;
47075 +       int                     rc;
47076 +
47077 +       /*
47078 +        * Find all escc chips in the system
47079 +        */
47080 +       node_p = of_find_node_by_name(NULL, "escc");
47081 +       while (node_p) {
47082 +               /*
47083 +                * First get channel A/B node pointers
47084 +                * 
47085 +                * TODO: Add routines with proper locking to do that...
47086 +                */
47087 +               node_a = node_b = NULL;
47088 +               for (np = NULL; (np = of_get_next_child(node_p, np)) != NULL;) {
47089 +                       if (strncmp(np->name, "ch-a", 4) == 0)
47090 +                               node_a = of_node_get(np);
47091 +                       else if (strncmp(np->name, "ch-b", 4) == 0)
47092 +                               node_b = of_node_get(np);
47093 +               }
47094 +               if (!node_a || !node_b) {
47095 +                       of_node_put(node_a);
47096 +                       of_node_put(node_b);
47097 +                       printk(KERN_ERR "pmac_zilog: missing node %c for escc %s\n",
47098 +                               (!node_a) ? 'a' : 'b', node_p->full_name);
47099 +                       goto next;
47100 +               }
47101 +
47102 +               /*
47103 +                * Fill basic fields in the port structures
47104 +                */
47105 +               pmz_ports[count].mate           = &pmz_ports[count+1];
47106 +               pmz_ports[count+1].mate         = &pmz_ports[count];
47107 +               pmz_ports[count].flags          = PMACZILOG_FLAG_IS_CHANNEL_A;
47108 +               pmz_ports[count].node           = node_a;
47109 +               pmz_ports[count+1].node         = node_b;
47110 +               pmz_ports[count].port.line      = count;
47111 +               pmz_ports[count+1].port.line    = count+1;
47112 +
47113 +               /*
47114 +                * Setup the ports for real
47115 +                */
47116 +               rc = pmz_setup_port(&pmz_ports[count], early);
47117 +               if (rc == 0)
47118 +                       rc = pmz_setup_port(&pmz_ports[count+1], early);
47119 +               if (rc != 0) {
47120 +                       of_node_put(node_a);
47121 +                       of_node_put(node_b);
47122 +                       memset(&pmz_ports[count], 0, sizeof(struct uart_pmac_port));
47123 +                       memset(&pmz_ports[count+1], 0, sizeof(struct uart_pmac_port));
47124 +                       goto next;
47125 +               }
47126 +               count += 2;
47127 +next:
47128 +               node_p = of_find_node_by_name(node_p, "escc");
47129 +       }
47130 +       pmz_ports_count = count;
47131 +
47132 +       return 0;
47133 +}
47134 +
47135 +static struct uart_driver pmz_uart_reg = {
47136 +       .owner          =       THIS_MODULE,
47137 +       .driver_name    =       "ttyS",
47138 +       .devfs_name     =       "tts/",
47139 +       .dev_name       =       "ttyS",
47140 +       .major          =       TTY_MAJOR,
47141 +};
47142 +
47143 +#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
47144 +
47145 +static void pmz_console_write(struct console *con, const char *s, unsigned int count);
47146 +static int __init pmz_console_setup(struct console *co, char *options);
47147 +
47148 +static struct console pmz_console = {
47149 +       .name   =       "ttyS",
47150 +       .write  =       pmz_console_write,
47151 +       .device =       uart_console_device,
47152 +       .setup  =       pmz_console_setup,
47153 +       .flags  =       CON_PRINTBUFFER,
47154 +       .index  =       -1,
47155 +       .data   =       &pmz_uart_reg,
47156 +};
47157 +
47158 +#define PMACZILOG_CONSOLE      &pmz_console
47159 +#else /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
47160 +#define PMACZILOG_CONSOLE      (NULL)
47161 +#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
47162 +
47163 +/*
47164 + * Register the driver, console driver and ports with the serial
47165 + * core
47166 + */
47167 +static int __init pmz_register(void)
47168 +{
47169 +       int i, rc;
47170 +       
47171 +       pmz_uart_reg.nr = pmz_ports_count;
47172 +       pmz_uart_reg.cons = PMACZILOG_CONSOLE;
47173 +       pmz_uart_reg.minor = 64;
47174 +
47175 +       /*
47176 +        * Register this driver with the serial core
47177 +        */
47178 +       rc = uart_register_driver(&pmz_uart_reg);
47179 +       if (rc != 0)
47180 +               return rc;
47181 +
47182 +       /*
47183 +        * Register each port with the serial core
47184 +        */
47185 +       for (i = 0; i < pmz_ports_count; i++) {
47186 +               struct uart_pmac_port *uport = &pmz_ports[i];
47187 +               if (uport->node != NULL)
47188 +                       uart_add_one_port(&pmz_uart_reg, &uport->port);
47189 +       }
47190 +
47191 +       return 0;
47192 +}
47193 +
47194 +static struct of_match pmz_match[] = 
47195 +{
47196 +       {
47197 +       .name           = "ch-a",
47198 +       .type           = OF_ANY_MATCH,
47199 +       .compatible     = OF_ANY_MATCH
47200 +       },
47201 +       {
47202 +       .name           = "ch-b",
47203 +       .type           = OF_ANY_MATCH,
47204 +       .compatible     = OF_ANY_MATCH
47205 +       },
47206 +       {},
47207 +};
47208 +
47209 +static struct macio_driver pmz_driver = 
47210 +{
47211 +       .name           = "pmac_zilog",
47212 +       .match_table    = pmz_match,
47213 +       .probe          = pmz_attach,
47214 +       .remove         = pmz_detach,
47215 +//     .suspend        = pmz_suspend, *** NYI
47216 +//     .resume         = pmz_resume,  *** NYI
47217 +};
47218 +
47219 +static void pmz_fixup_resources(void)
47220 +{
47221 +       int i;
47222 +               for (i=0; i<pmz_ports_count; i++) {
47223 +                       struct uart_pmac_port *up = &pmz_ports[i];
47224 +
47225 +               if (up->node == NULL)
47226 +                       continue;
47227 +                       if (up->flags & PMACZILOG_FLAG_RSRC_REQUESTED)
47228 +                       continue;
47229 +               if (request_OF_resource(up->node, 0, NULL) == NULL)
47230 +                       printk(KERN_WARNING "%s: Failed to do late IO resource request, port still active\n",
47231 +                              up->node->name);
47232 +               up->flags |= PMACZILOG_FLAG_RSRC_REQUESTED;
47233 +               if (!ZS_HAS_DMA(up))
47234 +                       continue;
47235 +               if (request_OF_resource(up->node, up->node->n_addrs - 2, NULL) == NULL)
47236 +                       printk(KERN_WARNING "%s: Failed to do late DMA resource request, port still active\n",
47237 +                              up->node->name);
47238 +               if (request_OF_resource(up->node, up->node->n_addrs - 1, NULL) == NULL)
47239 +                       printk(KERN_WARNING "%s: Failed to do late DMA resource request, port still active\n",
47240 +                              up->node->name);
47241 +               }
47242 +
47243 +}
47244 +
47245 +static int __init init_pmz(void)
47246 +{
47247 +       printk(KERN_DEBUG "%s\n", version);
47248 +
47249 +       /*
47250 +        * If we had serial console, then we didn't request
47251 +        * resources yet. We fix that up now
47252 +        */
47253 +       if (pmz_ports_count > 0)
47254 +               pmz_fixup_resources();
47255 +
47256 +       /* 
47257 +        * First, we need to do a direct OF-based probe pass. We
47258 +        * do that because we want serial console up before the
47259 +        * macio stuffs calls us back, and since that makes it
47260 +        * easier to pass the proper number of channels to
47261 +        * uart_register_driver()
47262 +        */
47263 +       if (pmz_ports_count == 0)
47264 +               pmz_probe(0);
47265 +
47266 +       /*
47267 +        * Bail early if no port found
47268 +        */
47269 +       if (pmz_ports_count == 0)
47270 +               return -ENODEV;
47271 +
47272 +       /*
47273 +        * Now we register with the serial layer
47274 +        */
47275 +       pmz_register();
47276 +       
47277 +       /*
47278 +        * Then we register the macio driver itself
47279 +        */
47280 +       return macio_register_driver(&pmz_driver);
47281 +}
47282 +
47283 +static void __exit exit_pmz(void)
47284 +{
47285 +       int i;
47286 +
47287 +       /* Get rid of macio-driver (detach from macio) */
47288 +       macio_unregister_driver(&pmz_driver);
47289 +
47290 +       /* Unregister UART driver */
47291 +       uart_unregister_driver(&pmz_uart_reg);
47292 +
47293 +       for (i = 0; i < pmz_ports_count; i++) {
47294 +               struct uart_pmac_port *uport = &pmz_ports[i];
47295 +               if (uport->node != NULL) {
47296 +                       uart_remove_one_port(&pmz_uart_reg, &uport->port);
47297 +                       pmz_dispose_port(uport);
47298 +               }
47299 +       }
47300 +}
47301 +
47302 +#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
47303 +
47304 +/*
47305 + * Print a string to the serial port trying not to disturb
47306 + * any possible real use of the port...
47307 + */
47308 +static void pmz_console_write(struct console *con, const char *s, unsigned int count)
47309 +{
47310 +       struct uart_pmac_port *up = &pmz_ports[con->index];
47311 +       unsigned long flags;
47312 +       int i;
47313 +
47314 +       spin_lock_irqsave(&up->port.lock, flags);
47315 +
47316 +       /* Turn of interrupts and enable the transmitter. */
47317 +       write_zsreg(up, R1, up->curregs[1] & ~TxINT_ENAB);
47318 +       write_zsreg(up, R5, up->curregs[5] | TxENABLE | RTS | DTR);
47319 +
47320 +       for (i = 0; i < count; i++) {
47321 +               /* Wait for the transmit buffer to empty. */
47322 +               while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0)
47323 +                       udelay(5);
47324 +               write_zsdata(up, s[i]);
47325 +               if (s[i] == 10) {
47326 +                       while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0)
47327 +                               udelay(5);
47328 +                       write_zsdata(up, R13);
47329 +               }
47330 +       }
47331 +
47332 +       /* Restore the values in the registers. */
47333 +       write_zsreg(up, R1, up->curregs[1]);
47334 +       /* Don't disable the transmitter. */
47335 +
47336 +       spin_unlock_irqrestore(&up->port.lock, flags);
47337 +}
47338 +
47339 +/*
47340 + * Setup the serial console
47341 + */
47342 +static int __init pmz_console_setup(struct console *co, char *options)
47343 +{
47344 +       struct uart_port *port;
47345 +       int baud = 38400;
47346 +       int bits = 8;
47347 +       int parity = 'n';
47348 +       int flow = 'n';
47349 +       unsigned long pwr_delay;
47350 +
47351 +       /*
47352 +        * XServe's default to 57600 bps
47353 +        */
47354 +       if (machine_is_compatible("RackMac1,1")
47355 +        || machine_is_compatible("RackMac1,2"))
47356 +               baud = 57600;
47357 +
47358 +       /*
47359 +        * Check whether an invalid uart number has been specified, and
47360 +        * if so, search for the first available port that does have
47361 +        * console support.
47362 +        */
47363 +       if (co->index >= pmz_ports_count)
47364 +               co->index = 0;
47365 +       port = &pmz_ports[co->index].port;
47366 +
47367 +       /*
47368 +        * Mark port as beeing a console
47369 +        */
47370 +       port->flags |= PMACZILOG_FLAG_IS_CONS;
47371 +
47372 +       /*
47373 +        * Temporary fix for uart layer who didn't setup the spinlock yet
47374 +        */
47375 +       spin_lock_init(&port->lock);
47376 +
47377 +       /*
47378 +        * Enable the hardware
47379 +        */
47380 +       pwr_delay = __pmz_startup(&pmz_ports[co->index]);
47381 +       if (pwr_delay)
47382 +               mdelay(pwr_delay);
47383 +       
47384 +       if (options)
47385 +               uart_parse_options(options, &baud, &parity, &bits, &flow);
47386 +
47387 +       return uart_set_options(port, co, baud, parity, bits, flow);
47388 +}
47389 +
47390 +static int __init pmz_console_init(void)
47391 +{
47392 +       /* Probe ports */
47393 +       pmz_probe(1);
47394 +
47395 +       /* TODO: Autoprobe console based on OF */
47396 +       /* pmz_console.index = i; */
47397 +       register_console(&pmz_console);
47398 +
47399 +       return 0;
47400 +
47401 +}
47402 +console_initcall(pmz_console_init);
47403 +#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
47404 +
47405 +module_init(init_pmz);
47406 +module_exit(exit_pmz);
47407 diff -Nru a/drivers/serial/pmac_zilog.h b/drivers/serial/pmac_zilog.h
47408 --- /dev/null   Wed Dec 31 16:00:00 1969
47409 +++ b/drivers/serial/pmac_zilog.h       Sun Aug 24 08:05:54 2003
47410 @@ -0,0 +1,361 @@
47411 +#ifndef __PMAC_ZILOG_H__
47412 +#define __PMAC_ZILOG_H__
47413 +
47414 +/*
47415 + * At most 2 ESCCs with 2 ports each
47416 + */
47417 +#define MAX_ZS_PORTS   4
47418 +
47419 +/* 
47420 + * We wrap our port structure around the generic uart_port.
47421 + */
47422 +#define NUM_ZSREGS    16
47423 +
47424 +struct uart_pmac_port {
47425 +       struct uart_port                port;
47426 +       struct uart_pmac_port           *mate;
47427 +
47428 +       /* macio_dev for the escc holding this port (maybe be null on
47429 +        * early inited port)
47430 +        */
47431 +       struct macio_dev                *dev;
47432 +       /* device node to this port, this points to one of 2 childs
47433 +        * of "escc" node (ie. ch-a or ch-b)
47434 +        */
47435 +       struct device_node              *node;
47436 +
47437 +       /* Port type as obtained from device tree (IRDA, modem, ...) */
47438 +       int                             port_type;
47439 +       u8                              curregs[NUM_ZSREGS];
47440 +
47441 +       unsigned int                    flags;
47442 +#define PMACZILOG_FLAG_IS_CONS         0x00000001
47443 +#define PMACZILOG_FLAG_IS_KGDB         0x00000002
47444 +#define PMACZILOG_FLAG_MODEM_STATUS    0x00000004
47445 +#define PMACZILOG_FLAG_IS_CHANNEL_A    0x00000008
47446 +#define PMACZILOG_FLAG_REGS_HELD       0x00000010
47447 +#define PMACZILOG_FLAG_TX_STOPPED      0x00000020
47448 +#define PMACZILOG_FLAG_TX_ACTIVE       0x00000040
47449 +#define PMACZILOG_FLAG_ENABLED          0x00000080
47450 +#define PMACZILOG_FLAG_IS_IRDA         0x00000100
47451 +#define PMACZILOG_FLAG_IS_INTMODEM     0x00000200
47452 +#define PMACZILOG_FLAG_HAS_DMA         0x00000400
47453 +#define PMACZILOG_FLAG_RSRC_REQUESTED  0x00000800
47454 +
47455 +       unsigned char                   parity_mask;
47456 +       unsigned char                   prev_status;
47457 +
47458 +       volatile u8                     *control_reg;
47459 +       volatile u8                     *data_reg;
47460 +
47461 +       unsigned int                    tx_dma_irq;
47462 +       unsigned int                    rx_dma_irq;
47463 +       volatile struct dbdma_regs      *tx_dma_regs;
47464 +       volatile struct dbdma_regs      *rx_dma_regs;
47465 +};
47466 +
47467 +#define to_pmz(p) ((struct uart_pmac_port *)(p))
47468 +
47469 +/*
47470 + * Register acessors. Note that we don't need to enforce a recovery
47471 + * delay on PCI PowerMac hardware, it's dealt in HW by the MacIO chip,
47472 + * though if we try to use this driver on older machines, we might have
47473 + * to add it back
47474 + */
47475 +static inline u8 read_zsreg(struct uart_pmac_port *port, u8 reg)
47476 +{
47477 +       if (reg != 0)
47478 +               writeb(reg, port->control_reg);
47479 +       return readb(port->control_reg);
47480 +}
47481 +
47482 +static inline void write_zsreg(struct uart_pmac_port *port, u8 reg, u8 value)
47483 +{
47484 +       if (reg != 0)
47485 +               writeb(reg, port->control_reg);
47486 +       writeb(value, port->control_reg);
47487 +}
47488 +
47489 +static inline u8 read_zsdata(struct uart_pmac_port *port)
47490 +{
47491 +       return readb(port->data_reg);
47492 +}
47493 +
47494 +static inline void write_zsdata(struct uart_pmac_port *port, u8 data)
47495 +{
47496 +       writeb(data, port->data_reg);
47497 +}
47498 +
47499 +static inline void zssync(struct uart_pmac_port *port)
47500 +{
47501 +       (void)readb(port->control_reg);
47502 +}
47503 +
47504 +/* Conversion routines to/from brg time constants from/to bits
47505 + * per second.
47506 + */
47507 +#define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
47508 +#define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
47509 +
47510 +#define ZS_CLOCK         3686400       /* Z8530 RTxC input clock rate */
47511 +
47512 +/* The Zilog register set */
47513 +
47514 +#define        FLAG    0x7e
47515 +
47516 +/* Write Register 0 */
47517 +#define        R0      0               /* Register selects */
47518 +#define        R1      1
47519 +#define        R2      2
47520 +#define        R3      3
47521 +#define        R4      4
47522 +#define        R5      5
47523 +#define        R6      6
47524 +#define        R7      7
47525 +#define        R8      8
47526 +#define        R9      9
47527 +#define        R10     10
47528 +#define        R11     11
47529 +#define        R12     12
47530 +#define        R13     13
47531 +#define        R14     14
47532 +#define        R15     15
47533 +
47534 +#define        NULLCODE        0       /* Null Code */
47535 +#define        POINT_HIGH      0x8     /* Select upper half of registers */
47536 +#define        RES_EXT_INT     0x10    /* Reset Ext. Status Interrupts */
47537 +#define        SEND_ABORT      0x18    /* HDLC Abort */
47538 +#define        RES_RxINT_FC    0x20    /* Reset RxINT on First Character */
47539 +#define        RES_Tx_P        0x28    /* Reset TxINT Pending */
47540 +#define        ERR_RES         0x30    /* Error Reset */
47541 +#define        RES_H_IUS       0x38    /* Reset highest IUS */
47542 +
47543 +#define        RES_Rx_CRC      0x40    /* Reset Rx CRC Checker */
47544 +#define        RES_Tx_CRC      0x80    /* Reset Tx CRC Checker */
47545 +#define        RES_EOM_L       0xC0    /* Reset EOM latch */
47546 +
47547 +/* Write Register 1 */
47548 +
47549 +#define        EXT_INT_ENAB    0x1     /* Ext Int Enable */
47550 +#define        TxINT_ENAB      0x2     /* Tx Int Enable */
47551 +#define        PAR_SPEC        0x4     /* Parity is special condition */
47552 +
47553 +#define        RxINT_DISAB     0       /* Rx Int Disable */
47554 +#define        RxINT_FCERR     0x8     /* Rx Int on First Character Only or Error */
47555 +#define        INT_ALL_Rx      0x10    /* Int on all Rx Characters or error */
47556 +#define        INT_ERR_Rx      0x18    /* Int on error only */
47557 +#define RxINT_MASK     0x18
47558 +
47559 +#define        WT_RDY_RT       0x20    /* W/Req reflects recv if 1, xmit if 0 */
47560 +#define        WT_FN_RDYFN     0x40    /* W/Req pin is DMA request if 1, wait if 0 */
47561 +#define        WT_RDY_ENAB     0x80    /* Enable W/Req pin */
47562 +
47563 +/* Write Register #2 (Interrupt Vector) */
47564 +
47565 +/* Write Register 3 */
47566 +
47567 +#define        RxENABLE        0x1     /* Rx Enable */
47568 +#define        SYNC_L_INH      0x2     /* Sync Character Load Inhibit */
47569 +#define        ADD_SM          0x4     /* Address Search Mode (SDLC) */
47570 +#define        RxCRC_ENAB      0x8     /* Rx CRC Enable */
47571 +#define        ENT_HM          0x10    /* Enter Hunt Mode */
47572 +#define        AUTO_ENAB       0x20    /* Auto Enables */
47573 +#define        Rx5             0x0     /* Rx 5 Bits/Character */
47574 +#define        Rx7             0x40    /* Rx 7 Bits/Character */
47575 +#define        Rx6             0x80    /* Rx 6 Bits/Character */
47576 +#define        Rx8             0xc0    /* Rx 8 Bits/Character */
47577 +#define RxN_MASK       0xc0
47578 +
47579 +/* Write Register 4 */
47580 +
47581 +#define        PAR_ENAB        0x1     /* Parity Enable */
47582 +#define        PAR_EVEN        0x2     /* Parity Even/Odd* */
47583 +
47584 +#define        SYNC_ENAB       0       /* Sync Modes Enable */
47585 +#define        SB1             0x4     /* 1 stop bit/char */
47586 +#define        SB15            0x8     /* 1.5 stop bits/char */
47587 +#define        SB2             0xc     /* 2 stop bits/char */
47588 +#define SB_MASK                0xc
47589 +
47590 +#define        MONSYNC         0       /* 8 Bit Sync character */
47591 +#define        BISYNC          0x10    /* 16 bit sync character */
47592 +#define        SDLC            0x20    /* SDLC Mode (01111110 Sync Flag) */
47593 +#define        EXTSYNC         0x30    /* External Sync Mode */
47594 +
47595 +#define        X1CLK           0x0     /* x1 clock mode */
47596 +#define        X16CLK          0x40    /* x16 clock mode */
47597 +#define        X32CLK          0x80    /* x32 clock mode */
47598 +#define        X64CLK          0xC0    /* x64 clock mode */
47599 +#define XCLK_MASK      0xC0
47600 +
47601 +/* Write Register 5 */
47602 +
47603 +#define        TxCRC_ENAB      0x1     /* Tx CRC Enable */
47604 +#define        RTS             0x2     /* RTS */
47605 +#define        SDLC_CRC        0x4     /* SDLC/CRC-16 */
47606 +#define        TxENABLE        0x8     /* Tx Enable */
47607 +#define        SND_BRK         0x10    /* Send Break */
47608 +#define        Tx5             0x0     /* Tx 5 bits (or less)/character */
47609 +#define        Tx7             0x20    /* Tx 7 bits/character */
47610 +#define        Tx6             0x40    /* Tx 6 bits/character */
47611 +#define        Tx8             0x60    /* Tx 8 bits/character */
47612 +#define TxN_MASK       0x60
47613 +#define        DTR             0x80    /* DTR */
47614 +
47615 +/* Write Register 6 (Sync bits 0-7/SDLC Address Field) */
47616 +
47617 +/* Write Register 7 (Sync bits 8-15/SDLC 01111110) */
47618 +
47619 +/* Write Register 7' (Some enhanced feature control) */
47620 +#define        ENEXREAD        0x40    /* Enable read of some write registers */
47621 +
47622 +/* Write Register 8 (transmit buffer) */
47623 +
47624 +/* Write Register 9 (Master interrupt control) */
47625 +#define        VIS     1       /* Vector Includes Status */
47626 +#define        NV      2       /* No Vector */
47627 +#define        DLC     4       /* Disable Lower Chain */
47628 +#define        MIE     8       /* Master Interrupt Enable */
47629 +#define        STATHI  0x10    /* Status high */
47630 +#define        NORESET 0       /* No reset on write to R9 */
47631 +#define        CHRB    0x40    /* Reset channel B */
47632 +#define        CHRA    0x80    /* Reset channel A */
47633 +#define        FHWRES  0xc0    /* Force hardware reset */
47634 +
47635 +/* Write Register 10 (misc control bits) */
47636 +#define        BIT6    1       /* 6 bit/8bit sync */
47637 +#define        LOOPMODE 2      /* SDLC Loop mode */
47638 +#define        ABUNDER 4       /* Abort/flag on SDLC xmit underrun */
47639 +#define        MARKIDLE 8      /* Mark/flag on idle */
47640 +#define        GAOP    0x10    /* Go active on poll */
47641 +#define        NRZ     0       /* NRZ mode */
47642 +#define        NRZI    0x20    /* NRZI mode */
47643 +#define        FM1     0x40    /* FM1 (transition = 1) */
47644 +#define        FM0     0x60    /* FM0 (transition = 0) */
47645 +#define        CRCPS   0x80    /* CRC Preset I/O */
47646 +
47647 +/* Write Register 11 (Clock Mode control) */
47648 +#define        TRxCXT  0       /* TRxC = Xtal output */
47649 +#define        TRxCTC  1       /* TRxC = Transmit clock */
47650 +#define        TRxCBR  2       /* TRxC = BR Generator Output */
47651 +#define        TRxCDP  3       /* TRxC = DPLL output */
47652 +#define        TRxCOI  4       /* TRxC O/I */
47653 +#define        TCRTxCP 0       /* Transmit clock = RTxC pin */
47654 +#define        TCTRxCP 8       /* Transmit clock = TRxC pin */
47655 +#define        TCBR    0x10    /* Transmit clock = BR Generator output */
47656 +#define        TCDPLL  0x18    /* Transmit clock = DPLL output */
47657 +#define        RCRTxCP 0       /* Receive clock = RTxC pin */
47658 +#define        RCTRxCP 0x20    /* Receive clock = TRxC pin */
47659 +#define        RCBR    0x40    /* Receive clock = BR Generator output */
47660 +#define        RCDPLL  0x60    /* Receive clock = DPLL output */
47661 +#define        RTxCX   0x80    /* RTxC Xtal/No Xtal */
47662 +
47663 +/* Write Register 12 (lower byte of baud rate generator time constant) */
47664 +
47665 +/* Write Register 13 (upper byte of baud rate generator time constant) */
47666 +
47667 +/* Write Register 14 (Misc control bits) */
47668 +#define        BRENAB  1       /* Baud rate generator enable */
47669 +#define        BRSRC   2       /* Baud rate generator source */
47670 +#define        DTRREQ  4       /* DTR/Request function */
47671 +#define        AUTOECHO 8      /* Auto Echo */
47672 +#define        LOOPBAK 0x10    /* Local loopback */
47673 +#define        SEARCH  0x20    /* Enter search mode */
47674 +#define        RMC     0x40    /* Reset missing clock */
47675 +#define        DISDPLL 0x60    /* Disable DPLL */
47676 +#define        SSBR    0x80    /* Set DPLL source = BR generator */
47677 +#define        SSRTxC  0xa0    /* Set DPLL source = RTxC */
47678 +#define        SFMM    0xc0    /* Set FM mode */
47679 +#define        SNRZI   0xe0    /* Set NRZI mode */
47680 +
47681 +/* Write Register 15 (external/status interrupt control) */
47682 +#define        EN85C30 1       /* Enable some 85c30-enhanced registers */
47683 +#define        ZCIE    2       /* Zero count IE */
47684 +#define        ENSTFIFO 4      /* Enable status FIFO (SDLC) */
47685 +#define        DCDIE   8       /* DCD IE */
47686 +#define        SYNCIE  0x10    /* Sync/hunt IE */
47687 +#define        CTSIE   0x20    /* CTS IE */
47688 +#define        TxUIE   0x40    /* Tx Underrun/EOM IE */
47689 +#define        BRKIE   0x80    /* Break/Abort IE */
47690 +
47691 +
47692 +/* Read Register 0 */
47693 +#define        Rx_CH_AV        0x1     /* Rx Character Available */
47694 +#define        ZCOUNT          0x2     /* Zero count */
47695 +#define        Tx_BUF_EMP      0x4     /* Tx Buffer empty */
47696 +#define        DCD             0x8     /* DCD */
47697 +#define        SYNC_HUNT       0x10    /* Sync/hunt */
47698 +#define        CTS             0x20    /* CTS */
47699 +#define        TxEOM           0x40    /* Tx underrun */
47700 +#define        BRK_ABRT        0x80    /* Break/Abort */
47701 +
47702 +/* Read Register 1 */
47703 +#define        ALL_SNT         0x1     /* All sent */
47704 +/* Residue Data for 8 Rx bits/char programmed */
47705 +#define        RES3            0x8     /* 0/3 */
47706 +#define        RES4            0x4     /* 0/4 */
47707 +#define        RES5            0xc     /* 0/5 */
47708 +#define        RES6            0x2     /* 0/6 */
47709 +#define        RES7            0xa     /* 0/7 */
47710 +#define        RES8            0x6     /* 0/8 */
47711 +#define        RES18           0xe     /* 1/8 */
47712 +#define        RES28           0x0     /* 2/8 */
47713 +/* Special Rx Condition Interrupts */
47714 +#define        PAR_ERR         0x10    /* Parity error */
47715 +#define        Rx_OVR          0x20    /* Rx Overrun Error */
47716 +#define        CRC_ERR         0x40    /* CRC/Framing Error */
47717 +#define        END_FR          0x80    /* End of Frame (SDLC) */
47718 +
47719 +/* Read Register 2 (channel b only) - Interrupt vector */
47720 +#define        CHB_Tx_EMPTY    0x00
47721 +#define        CHB_EXT_STAT    0x02
47722 +#define        CHB_Rx_AVAIL    0x04
47723 +#define        CHB_SPECIAL     0x06
47724 +#define        CHA_Tx_EMPTY    0x08
47725 +#define        CHA_EXT_STAT    0x0a
47726 +#define        CHA_Rx_AVAIL    0x0c
47727 +#define        CHA_SPECIAL     0x0e
47728 +#define        STATUS_MASK     0x06
47729 +
47730 +/* Read Register 3 (interrupt pending register) ch a only */
47731 +#define        CHBEXT  0x1             /* Channel B Ext/Stat IP */
47732 +#define        CHBTxIP 0x2             /* Channel B Tx IP */
47733 +#define        CHBRxIP 0x4             /* Channel B Rx IP */
47734 +#define        CHAEXT  0x8             /* Channel A Ext/Stat IP */
47735 +#define        CHATxIP 0x10            /* Channel A Tx IP */
47736 +#define        CHARxIP 0x20            /* Channel A Rx IP */
47737 +
47738 +/* Read Register 8 (receive data register) */
47739 +
47740 +/* Read Register 10  (misc status bits) */
47741 +#define        ONLOOP  2               /* On loop */
47742 +#define        LOOPSEND 0x10           /* Loop sending */
47743 +#define        CLK2MIS 0x40            /* Two clocks missing */
47744 +#define        CLK1MIS 0x80            /* One clock missing */
47745 +
47746 +/* Read Register 12 (lower byte of baud rate generator constant) */
47747 +
47748 +/* Read Register 13 (upper byte of baud rate generator constant) */
47749 +
47750 +/* Read Register 15 (value of WR 15) */
47751 +
47752 +/* Misc macros */
47753 +#define ZS_CLEARERR(port)    (write_zsreg(port, 0, ERR_RES))
47754 +#define ZS_CLEARFIFO(port)   do { volatile unsigned char garbage; \
47755 +                                    garbage = read_zsdata(port); \
47756 +                                    garbage = read_zsdata(port); \
47757 +                                    garbage = read_zsdata(port); \
47758 +                               } while(0)
47759 +
47760 +#define ZS_IS_CONS(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_CONS)
47761 +#define ZS_IS_KGDB(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_KGDB)
47762 +#define ZS_IS_CHANNEL_A(UP)            ((UP)->flags & PMACZILOG_FLAG_IS_CHANNEL_A)
47763 +#define ZS_REGS_HELD(UP)               ((UP)->flags & PMACZILOG_FLAG_REGS_HELD)
47764 +#define ZS_TX_STOPPED(UP)              ((UP)->flags & PMACZILOG_FLAG_TX_STOPPED)
47765 +#define ZS_TX_ACTIVE(UP)               ((UP)->flags & PMACZILOG_FLAG_TX_ACTIVE)
47766 +#define ZS_WANTS_MODEM_STATUS(UP)      ((UP)->flags & PMACZILOG_FLAG_MODEM_STATUS)
47767 +#define ZS_IS_IRDA(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_IRDA)
47768 +#define ZS_IS_INTMODEM(UP)             ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM)
47769 +#define ZS_HAS_DMA(UP)                 ((UP)->flags & PMACZILOG_FLAG_HAS_DMA)
47770 +
47771 +#endif /* __PMAC_ZILOG_H__ */
47772 diff -Nru a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
47773 --- a/drivers/telephony/ixj.c   Sun Jul 27 12:29:47 2003
47774 +++ b/drivers/telephony/ixj.c   Tue Aug 26 09:25:41 2003
47775 @@ -278,8 +278,8 @@
47776  
47777  #include "ixj.h"
47778  
47779 -#define TYPE(dev) (minor(dev) >> 4)
47780 -#define NUM(dev) (minor(dev) & 0xf)
47781 +#define TYPE(inode) (iminor(inode) >> 4)
47782 +#define NUM(inode) (iminor(inode) & 0xf)
47783  
47784  static int ixjdebug;
47785  static int hertz = HZ;
47786 @@ -2273,7 +2273,7 @@
47787                 schedule_timeout(1);
47788         }
47789         if (ixjdebug & 0x0002)
47790 -               printk(KERN_INFO "Closing board %d\n", NUM(inode->i_rdev));
47791 +               printk(KERN_INFO "Closing board %d\n", NUM(inode));
47792  
47793         if (j->cardtype == QTI_PHONECARD)
47794                 ixj_set_port(j, PORT_SPEAKER);
47795 @@ -2858,7 +2858,7 @@
47796  static ssize_t ixj_read(struct file * file_p, char *buf, size_t length, loff_t * ppos)
47797  {
47798         unsigned long i = *ppos;
47799 -       IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
47800 +       IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode));
47801  
47802         DECLARE_WAITQUEUE(wait, current);
47803  
47804 @@ -2915,7 +2915,7 @@
47805  {
47806         int pre_retval;
47807         ssize_t read_retval = 0;
47808 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
47809 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
47810  
47811         pre_retval = ixj_PreRead(j, 0L);
47812         switch (pre_retval) {
47813 @@ -2994,7 +2994,7 @@
47814         int pre_retval;
47815         ssize_t write_retval = 0;
47816  
47817 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
47818 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
47819  
47820         pre_retval = ixj_PreWrite(j, 0L);
47821         switch (pre_retval) {
47822 @@ -4707,7 +4707,7 @@
47823  {
47824         unsigned int mask = 0;
47825  
47826 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
47827 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
47828  
47829         poll_wait(file_p, &(j->poll_q), wait);
47830         if (j->read_buffer_ready > 0)
47831 @@ -6208,10 +6208,10 @@
47832         IXJ_FILTER_RAW jfr;
47833  
47834         unsigned int raise, mant;
47835 -       unsigned int minor = minor(inode->i_rdev);
47836 -       int board = NUM(inode->i_rdev);
47837 +       unsigned int minor = iminor(inode);
47838 +       int board = NUM(inode);
47839  
47840 -       IXJ *j = get_ixj(NUM(inode->i_rdev));
47841 +       IXJ *j = get_ixj(NUM(inode));
47842  
47843         int retval = 0;
47844  
47845 @@ -6764,7 +6764,7 @@
47846  
47847  static int ixj_fasync(int fd, struct file *file_p, int mode)
47848  {
47849 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
47850 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
47851  
47852         return fasync_helper(fd, file_p, mode, &j->async_queue);
47853  }
47854 diff -Nru a/drivers/telephony/phonedev.c b/drivers/telephony/phonedev.c
47855 --- a/drivers/telephony/phonedev.c      Mon Jul 14 09:05:52 2003
47856 +++ b/drivers/telephony/phonedev.c      Tue Aug 26 09:25:41 2003
47857 @@ -46,7 +46,7 @@
47858  
47859  static int phone_open(struct inode *inode, struct file *file)
47860  {
47861 -       unsigned int minor = minor(inode->i_rdev);
47862 +       unsigned int minor = iminor(inode);
47863         int err = 0;
47864         struct phone_device *p;
47865         struct file_operations *old_fops, *new_fops = NULL;
47866 diff -Nru a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
47867 --- a/drivers/usb/class/audio.c Wed Jul 30 11:00:01 2003
47868 +++ b/drivers/usb/class/audio.c Tue Aug 26 09:25:41 2003
47869 @@ -1955,7 +1955,7 @@
47870  
47871  static int usb_audio_open_mixdev(struct inode *inode, struct file *file)
47872  {
47873 -       unsigned int minor = minor(inode->i_rdev);
47874 +       unsigned int minor = iminor(inode);
47875         struct list_head *devs, *mdevs;
47876         struct usb_mixerdev *ms;
47877         struct usb_audio_state *s;
47878 @@ -2633,7 +2633,7 @@
47879  
47880  static int usb_audio_open(struct inode *inode, struct file *file)
47881  {
47882 -       unsigned int minor = minor(inode->i_rdev);
47883 +       unsigned int minor = iminor(inode);
47884         DECLARE_WAITQUEUE(wait, current);
47885         struct list_head *devs, *adevs;
47886         struct usb_audiodev *as;
47887 diff -Nru a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c
47888 --- a/drivers/usb/class/bluetty.c       Wed Jul 30 05:49:21 2003
47889 +++ b/drivers/usb/class/bluetty.c       Wed Aug 27 04:45:14 2003
47890 @@ -1,8 +1,8 @@
47891  /*
47892   * bluetty.c   Version 0.13
47893   *
47894 - * Copyright (c) 2000, 2001 Greg Kroah-Hartman <greg@kroah.com>
47895 - * Copyright (c) 2000 Mark Douglas Corner      <mcorner@umich.edu>
47896 + * Copyright (C) 2000, 2001 Greg Kroah-Hartman <greg@kroah.com>
47897 + * Copyright (C) 2000 Mark Douglas Corner      <mcorner@umich.edu>
47898   *
47899   * USB Bluetooth TTY driver, based on the Bluetooth Spec version 1.0B
47900   * 
47901 diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
47902 --- a/drivers/usb/class/cdc-acm.c       Mon Aug 11 07:56:25 2003
47903 +++ b/drivers/usb/class/cdc-acm.c       Sat Aug 23 12:40:13 2003
47904 @@ -767,6 +767,7 @@
47905  
47906  static int __init acm_init(void)
47907  {
47908 +       int retval;
47909         acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
47910         if (!acm_tty_driver)
47911                 return -ENOMEM;
47912 @@ -783,15 +784,17 @@
47913         acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
47914         tty_set_operations(acm_tty_driver, &acm_ops);
47915  
47916 -       if (tty_register_driver(acm_tty_driver)) {
47917 +       retval = tty_register_driver(acm_tty_driver);
47918 +       if (retval) {
47919                 put_tty_driver(acm_tty_driver);
47920 -               return -1;
47921 +               return retval;
47922         }
47923  
47924 -       if (usb_register(&acm_driver) < 0) {
47925 +       retval = usb_register(&acm_driver);
47926 +       if (retval) {
47927                 tty_unregister_driver(acm_tty_driver);
47928                 put_tty_driver(acm_tty_driver);
47929 -               return -1;
47930 +               return retval;
47931         }
47932  
47933         info(DRIVER_VERSION ":" DRIVER_DESC);
47934 diff -Nru a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c
47935 --- a/drivers/usb/class/usb-midi.c      Tue Jul 29 04:28:54 2003
47936 +++ b/drivers/usb/class/usb-midi.c      Tue Sep  2 11:40:27 2003
47937 @@ -812,7 +812,7 @@
47938  
47939  static int usb_midi_open(struct inode *inode, struct file *file)
47940  {
47941 -       int minor = minor(inode->i_rdev);
47942 +       int minor = iminor(inode);
47943         DECLARE_WAITQUEUE(wait, current);
47944         struct list_head      *devs, *mdevs;
47945         struct usb_midi_state *s;
47946 @@ -2084,16 +2084,12 @@
47947  
47948  /* ------------------------------------------------------------------------- */
47949  
47950 -int __init usb_midi_init(void)
47951 +static int __init usb_midi_init(void)
47952  {
47953 -       if ( usb_register(&usb_midi_driver) < 0 )
47954 -               return -1;
47955 -
47956 -       return 0;
47957 -
47958 +       return usb_register(&usb_midi_driver);
47959  }
47960  
47961 -void __exit usb_midi_exit(void)
47962 +static void __exit usb_midi_exit(void)
47963  {
47964         usb_deregister(&usb_midi_driver);
47965  }
47966 diff -Nru a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
47967 --- a/drivers/usb/class/usblp.c Sun Aug 10 02:01:53 2003
47968 +++ b/drivers/usb/class/usblp.c Tue Sep  2 11:40:28 2003
47969 @@ -318,7 +318,7 @@
47970  
47971  static int usblp_open(struct inode *inode, struct file *file)
47972  {
47973 -       int minor = minor(inode->i_rdev);
47974 +       int minor = iminor(inode);
47975         struct usblp *usblp;
47976         struct usb_interface *intf;
47977         int retval;
47978 @@ -1150,10 +1150,13 @@
47979  
47980  static int __init usblp_init(void)
47981  {
47982 -       if (usb_register(&usblp_driver))
47983 -               return -1;
47984 +       int retval;
47985 +       retval = usb_register(&usblp_driver);
47986 +       if (retval)
47987 +               goto out;
47988         info(DRIVER_VERSION ": " DRIVER_DESC);
47989 -       return 0;
47990 +out:
47991 +       return retval;
47992  }
47993  
47994  static void __exit usblp_exit(void)
47995 diff -Nru a/drivers/usb/core/file.c b/drivers/usb/core/file.c
47996 --- a/drivers/usb/core/file.c   Wed Aug 13 06:35:23 2003
47997 +++ b/drivers/usb/core/file.c   Tue Sep  2 11:40:28 2003
47998 @@ -34,7 +34,7 @@
47999  
48000  static int usb_open(struct inode * inode, struct file * file)
48001  {
48002 -       int minor = minor(inode->i_rdev);
48003 +       int minor = iminor(inode);
48004         struct file_operations *c;
48005         int err = -ENODEV;
48006         struct file_operations *old_fops, *new_fops = NULL;
48007 @@ -129,7 +129,7 @@
48008         int retval = -EINVAL;
48009         int minor_base = class_driver->minor_base;
48010         int minor = 0;
48011 -       char name[DEVICE_ID_SIZE];
48012 +       char name[BUS_ID_SIZE];
48013         struct class_device *class_dev;
48014         char *temp;
48015  
48016 @@ -166,7 +166,7 @@
48017         intf->minor = minor;
48018  
48019         /* handle the devfs registration */
48020 -       snprintf(name, DEVICE_ID_SIZE, class_driver->name, minor - minor_base);
48021 +       snprintf(name, BUS_ID_SIZE, class_driver->name, minor - minor_base);
48022         devfs_mk_cdev(MKDEV(USB_MAJOR, minor), class_driver->mode, name);
48023  
48024         /* create a usb class device for this usb interface */
48025 @@ -211,7 +211,7 @@
48026                         struct usb_class_driver *class_driver)
48027  {
48028         int minor_base = class_driver->minor_base;
48029 -       char name[DEVICE_ID_SIZE];
48030 +       char name[BUS_ID_SIZE];
48031  
48032  #ifdef CONFIG_USB_DYNAMIC_MINORS
48033         minor_base = 0;
48034 @@ -226,7 +226,7 @@
48035         usb_minors[intf->minor] = NULL;
48036         spin_unlock (&minor_lock);
48037  
48038 -       snprintf(name, DEVICE_ID_SIZE, class_driver->name, intf->minor - minor_base);
48039 +       snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base);
48040         devfs_remove (name);
48041  
48042         if (intf->class_dev) {
48043 diff -Nru a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
48044 --- a/drivers/usb/core/hcd-pci.c        Tue Aug 12 09:19:01 2003
48045 +++ b/drivers/usb/core/hcd-pci.c        Fri Aug 29 11:14:52 2003
48046 @@ -139,6 +139,7 @@
48047                         return retval;
48048                 }
48049         }
48050 +       // hcd zeroed everything
48051         hcd->regs = base;
48052         hcd->region = region;
48053  
48054 @@ -165,6 +166,7 @@
48055                 dev_err (hcd->controller, "can't reset\n");
48056                 goto clean_3;
48057         }
48058 +       hcd->state = USB_STATE_HALT;
48059  
48060         pci_set_master (dev);
48061  #ifndef __sparc__
48062 @@ -230,7 +232,8 @@
48063                 BUG ();
48064  
48065         hub = hcd->self.root_hub;
48066 -       hcd->state = USB_STATE_QUIESCING;
48067 +       if (HCD_IS_RUNNING (hcd->state))
48068 +               hcd->state = USB_STATE_QUIESCING;
48069  
48070         dev_dbg (hcd->controller, "roothub graceful disconnect\n");
48071         usb_disconnect (&hub);
48072 @@ -287,8 +290,8 @@
48073                 pci_save_state (dev, hcd->pci_state);
48074  
48075                 /* driver may want to disable DMA etc */
48076 +               hcd->state = USB_STATE_QUIESCING;
48077                 retval = hcd->driver->suspend (hcd, state);
48078 -               hcd->state = USB_STATE_SUSPENDED;
48079         }
48080  
48081         pci_set_power_state (dev, state);
48082 diff -Nru a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
48083 --- a/drivers/usb/core/hcd.c    Tue Aug 12 09:07:44 2003
48084 +++ b/drivers/usb/core/hcd.c    Fri Aug 29 11:16:13 2003
48085 @@ -483,7 +483,7 @@
48086  {
48087         struct urb      *urb;
48088         struct usb_hcd  *hcd;
48089 -       int             length;
48090 +       int             length = 0;
48091         unsigned long   flags;
48092  
48093         urb = (struct urb *) ptr;
48094 @@ -499,7 +499,9 @@
48095                 return;
48096         }
48097  
48098 -       length = hcd->driver->hub_status_data (hcd, urb->transfer_buffer);
48099 +       if (!HCD_IS_SUSPENDED (hcd->state))
48100 +               length = hcd->driver->hub_status_data (
48101 +                                       hcd, urb->transfer_buffer);
48102  
48103         /* complete the status urb, or retrigger the timer */
48104         spin_lock (&hcd_data_lock);
48105 @@ -1097,6 +1099,8 @@
48106  static int hcd_get_frame_number (struct usb_device *udev)
48107  {
48108         struct usb_hcd  *hcd = (struct usb_hcd *)udev->bus->hcpriv;
48109 +       if (!HCD_IS_RUNNING (hcd->state))
48110 +               return -ESHUTDOWN;
48111         return hcd->driver->get_frame_number (hcd);
48112  }
48113  
48114 @@ -1193,6 +1197,12 @@
48115                 goto done;
48116         }
48117  
48118 +       /* running ~= hc unlink handshake works (irq, timer, etc)
48119 +        * halted ~= no unlink handshake is needed
48120 +        * suspended, resuming == should never happen
48121 +        */
48122 +       WARN_ON (!HCD_IS_RUNNING (hcd->state) && hcd->state != USB_STATE_HALT);
48123 +
48124         if (!urb->hcpriv) {
48125                 retval = -EINVAL;
48126                 goto done;
48127 @@ -1208,6 +1218,17 @@
48128                 goto done;
48129         }
48130  
48131 +       /* PCI IRQ setup can easily be broken so that USB controllers
48132 +        * never get completion IRQs ... maybe even the ones we need to
48133 +        * finish unlinking the initial failed usb_set_address().
48134 +        */
48135 +       if (!hcd->saw_irq) {
48136 +               dev_warn (hcd->controller, "Unlink after no-IRQ?  "
48137 +                       "Different ACPI or APIC settings may help."
48138 +                       "\n");
48139 +               hcd->saw_irq = 1;
48140 +       }
48141 +
48142         /* maybe set up to block until the urb's completion fires.  the
48143          * lower level hcd code is always async, locking on urb->status
48144          * updates; an intercepted completion unblocks us.
48145 @@ -1287,6 +1308,8 @@
48146         dev = udev->hcpriv;
48147         hcd = udev->bus->hcpriv;
48148  
48149 +       WARN_ON (!HCD_IS_RUNNING (hcd->state) && hcd->state != USB_STATE_HALT);
48150 +
48151         local_irq_disable ();
48152  
48153  rescan:
48154 @@ -1483,6 +1506,7 @@
48155         if (unlikely (hcd->state == USB_STATE_HALT))    /* irq sharing? */
48156                 return IRQ_NONE;
48157  
48158 +       hcd->saw_irq = 1;
48159         hcd->driver->irq (hcd, r);
48160         if (hcd->state != start && hcd->state == USB_STATE_HALT)
48161                 usb_hc_died (hcd);
48162 diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
48163 --- a/drivers/usb/core/hcd.h    Tue Aug 12 09:13:35 2003
48164 +++ b/drivers/usb/core/hcd.h    Fri Aug 29 11:06:37 2003
48165 @@ -73,6 +73,7 @@
48166          * hardware info/state
48167          */
48168         struct hc_driver        *driver;        /* hw-specific hooks */
48169 +       unsigned                saw_irq : 1;
48170         int                     irq;            /* irq allocated */
48171         void                    *regs;          /* device memory/io */
48172         struct device           *controller;    /* handle to hardware */
48173 @@ -89,13 +90,11 @@
48174  
48175         int                     state;
48176  #      define  __ACTIVE                0x01
48177 -#      define  __SLEEPY                0x02
48178  #      define  __SUSPEND               0x04
48179  #      define  __TRANSIENT             0x80
48180  
48181  #      define  USB_STATE_HALT          0
48182  #      define  USB_STATE_RUNNING       (__ACTIVE)
48183 -#      define  USB_STATE_READY         (__ACTIVE|__SLEEPY)
48184  #      define  USB_STATE_QUIESCING     (__SUSPEND|__TRANSIENT|__ACTIVE)
48185  #      define  USB_STATE_RESUMING      (__SUSPEND|__TRANSIENT)
48186  #      define  USB_STATE_SUSPENDED     (__SUSPEND)
48187 diff -Nru a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
48188 --- a/drivers/usb/core/inode.c  Thu Jul 10 06:17:51 2003
48189 +++ b/drivers/usb/core/inode.c  Wed Aug 27 04:45:14 2003
48190 @@ -4,7 +4,7 @@
48191   *     inode.c  --  Inode/Dentry functions for the USB device file system.
48192   *
48193   *     Copyright (C) 2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
48194 - *     Copyright (c) 2001,2002 Greg Kroah-Hartman (greg@kroah.com)
48195 + *     Copyright (C) 2001,2002 Greg Kroah-Hartman (greg@kroah.com)
48196   *
48197   *     This program is free software; you can redistribute it and/or modify
48198   *     it under the terms of the GNU General Public License as published by
48199 diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c
48200 --- a/drivers/usb/core/message.c        Thu Aug 14 09:14:33 2003
48201 +++ b/drivers/usb/core/message.c        Thu Aug 21 04:31:25 2003
48202 @@ -246,21 +246,22 @@
48203                 io->status = urb->status;
48204  
48205                 /* the previous urbs, and this one, completed already.
48206 -                * unlink the later ones so they won't rx/tx bad data,
48207 -                *
48208 -                * FIXME don't bother unlinking urbs that haven't yet been
48209 -                * submitted; those non-error cases shouldn't be syslogged
48210 +                * unlink pending urbs so they won't rx/tx bad data.
48211                  */
48212                 for (i = 0, found = 0; i < io->entries; i++) {
48213 +                       if (!io->urbs [i])
48214 +                               continue;
48215                         if (found) {
48216                                 status = usb_unlink_urb (io->urbs [i]);
48217 -                               if (status && status != -EINPROGRESS)
48218 -                                       err ("sg_complete, unlink --> %d",
48219 -                                                       status);
48220 +                               if (status != -EINPROGRESS && status != -EBUSY)
48221 +                                       dev_err (&io->dev->dev,
48222 +                                               "%s, unlink --> %d\n",
48223 +                                               __FUNCTION__, status);
48224                         } else if (urb == io->urbs [i])
48225                                 found = 1;
48226                 }
48227         }
48228 +       urb->dev = 0;
48229  
48230         /* on the last completion, signal usb_sg_wait() */
48231         io->bytes += urb->actual_length;
48232 @@ -356,7 +357,7 @@
48233                         goto nomem;
48234                 }
48235  
48236 -               io->urbs [i]->dev = dev;
48237 +               io->urbs [i]->dev = 0;
48238                 io->urbs [i]->pipe = pipe;
48239                 io->urbs [i]->interval = period;
48240                 io->urbs [i]->transfer_flags = urb_flags;
48241 @@ -448,6 +449,7 @@
48242         for (i = 0; i < io->entries && !io->status; i++) {
48243                 int     retval;
48244  
48245 +               io->urbs [i]->dev = io->dev;
48246                 retval = usb_submit_urb (io->urbs [i], SLAB_ATOMIC);
48247  
48248                 /* after we submit, let completions or cancelations fire;
48249 @@ -459,9 +461,9 @@
48250                 case -ENXIO:    // hc didn't queue this one
48251                 case -EAGAIN:
48252                 case -ENOMEM:
48253 +                       io->urbs [i]->dev = 0;
48254                         retval = 0;
48255                         i--;
48256 -                       // FIXME:  should it usb_sg_cancel() on INTERRUPT?
48257                         yield ();
48258                         break;
48259  
48260 @@ -477,8 +479,10 @@
48261  
48262                         /* fail any uncompleted urbs */
48263                 default:
48264 +                       io->urbs [i]->dev = 0;
48265                         io->urbs [i]->status = retval;
48266 -                       dbg ("usb_sg_msg, submit --> %d", retval);
48267 +                       dev_dbg (&io->dev->dev, "%s, submit --> %d\n",
48268 +                               __FUNCTION__, retval);
48269                         usb_sg_cancel (io);
48270                 }
48271                 spin_lock_irqsave (&io->lock, flags);
48272 @@ -521,9 +525,9 @@
48273                         if (!io->urbs [i]->dev)
48274                                 continue;
48275                         retval = usb_unlink_urb (io->urbs [i]);
48276 -                       if (retval && retval != -EINPROGRESS)
48277 -                               warn ("usb_sg_cancel, unlink --> %d", retval);
48278 -                       // FIXME don't warn on "not yet submitted" error
48279 +                       if (retval != -EINPROGRESS && retval != -EBUSY)
48280 +                               dev_warn (&io->dev->dev, "%s, unlink --> %d\n",
48281 +                                       __FUNCTION__, retval);
48282                 }
48283         }
48284         spin_unlock_irqrestore (&io->lock, flags);
48285 diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
48286 --- a/drivers/usb/core/usb.c    Mon Aug 11 16:09:09 2003
48287 +++ b/drivers/usb/core/usb.c    Wed Aug 27 10:04:01 2003
48288 @@ -991,8 +991,8 @@
48289   *
48290   * This call is synchronous, and may not be used in an interrupt context.
48291   *
48292 - * Only hub drivers (including virtual root hub drivers for host
48293 - * controllers) should ever call this.
48294 + * Only the hub driver should ever call this; root hub registration
48295 + * uses it only indirectly.
48296   */
48297  #define NEW_DEVICE_RETRYS      2
48298  #define SET_ADDRESS_RETRYS     2
48299 @@ -1417,11 +1417,46 @@
48300                         usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
48301  }
48302  
48303 +static int usb_device_suspend(struct device *dev, u32 state)
48304 +{
48305 +       struct usb_interface *intf;
48306 +       struct usb_driver *driver;
48307 +
48308 +       if ((dev->driver == &usb_generic_driver) || 
48309 +           (dev->driver_data == &usb_generic_driver_data))
48310 +               return 0;
48311 +
48312 +       intf = to_usb_interface(dev);
48313 +       driver = to_usb_driver(dev->driver);
48314 +
48315 +       if (driver && driver->suspend)
48316 +               return driver->suspend(intf, state);
48317 +       return 0;
48318 +}
48319 +
48320 +static int usb_device_resume(struct device *dev)
48321 +{
48322 +       struct usb_interface *intf;
48323 +       struct usb_driver *driver;
48324 +
48325 +       if ((dev->driver == &usb_generic_driver) || 
48326 +           (dev->driver_data == &usb_generic_driver_data))
48327 +               return 0;
48328 +
48329 +       intf = to_usb_interface(dev);
48330 +       driver = to_usb_driver(dev->driver);
48331 +
48332 +       if (driver && driver->resume)
48333 +               return driver->resume(intf);
48334 +       return 0;
48335 +}
48336  
48337  struct bus_type usb_bus_type = {
48338         .name =         "usb",
48339         .match =        usb_device_match,
48340         .hotplug =      usb_hotplug,
48341 +       .suspend =      usb_device_suspend,
48342 +       .resume =       usb_device_resume,
48343  };
48344  
48345  #ifndef MODULE
48346 @@ -1509,7 +1544,6 @@
48347  EXPORT_SYMBOL(usb_find_interface);
48348  EXPORT_SYMBOL(usb_ifnum_to_if);
48349  
48350 -EXPORT_SYMBOL(usb_new_device);
48351  EXPORT_SYMBOL(usb_reset_device);
48352  EXPORT_SYMBOL(usb_disconnect);
48353  
48354 diff -Nru a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
48355 --- a/drivers/usb/gadget/net2280.c      Thu Aug  7 04:00:21 2003
48356 +++ b/drivers/usb/gadget/net2280.c      Mon Sep  1 12:15:45 2003
48357 @@ -30,6 +30,7 @@
48358  
48359  /*
48360   * Copyright (C) 2003 David Brownell
48361 + * Copyright (C) 2003 NetChip Technologies
48362   *
48363   * This program is free software; you can redistribute it and/or modify
48364   * it under the terms of the GNU General Public License as published by
48365 @@ -49,6 +50,7 @@
48366  #define DEBUG  1
48367  // #define     VERBOSE         /* extra debug messages (success too) */
48368  
48369 +#include <linux/version.h>
48370  #include <linux/config.h>
48371  #include <linux/module.h>
48372  #include <linux/pci.h>
48373 @@ -76,7 +78,7 @@
48374  
48375  
48376  #define        DRIVER_DESC             "NetChip 2280 USB Peripheral Controller"
48377 -#define        DRIVER_VERSION          "May Day 2003"
48378 +#define        DRIVER_VERSION          "Bastille Day 2003"
48379  
48380  #define        DMA_ADDR_INVALID        (~(dma_addr_t)0)
48381  #define        EP_DONTUSE              13      /* nonzero */
48382 @@ -448,7 +450,7 @@
48383         struct net2280_ep       *ep;
48384  
48385         ep = container_of (_ep, struct net2280_ep, ep);
48386 -       if (!_ep || (!ep->desc && ep->num != 0))
48387 +       if (!_ep)
48388                 return 0;
48389  
48390         *dma = DMA_ADDR_INVALID;
48391 @@ -1344,11 +1346,12 @@
48392                 s = "(none)";
48393  
48394         /* Main Control Registers */
48395 -       t = snprintf (next, size, "%s " DRIVER_VERSION "\n"
48396 +       t = snprintf (next, size, "%s version " DRIVER_VERSION
48397 +                       ", chiprev %04x\n"
48398                         "devinit %03x fifoctl %08x gadget '%s'\n"
48399                         "pci irqenb0 %02x irqenb1 %08x "
48400                         "irqstat0 %04x irqstat1 %08x\n",
48401 -                       driver_name,
48402 +                       driver_name, dev->chiprev,
48403                         readl (&dev->regs->devinit),
48404                         readl (&dev->regs->fifoctl),
48405                         s,
48406 @@ -1393,16 +1396,33 @@
48407                         continue;
48408  
48409                 t1 = readl (&ep->regs->ep_cfg);
48410 +               t2 = readl (&ep->regs->ep_rsp) & 0xff;
48411                 t = snprintf (next, size,
48412 -                               "%s\tcfg %05x rsp %02x enb %02x ",
48413 -                               ep->ep.name, t1,
48414 -                               readl (&ep->regs->ep_rsp) & 0xff,
48415 +                               "%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
48416 +                                       "irqenb %02x\n",
48417 +                               ep->ep.name, t1, t2,
48418 +                               (t2 & (1 << CLEAR_NAK_OUT_PACKETS))
48419 +                                       ? "NAK " : "",
48420 +                               (t2 & (1 << CLEAR_EP_HIDE_STATUS_PHASE))
48421 +                                       ? "hide " : "",
48422 +                               (t2 & (1 << CLEAR_EP_FORCE_CRC_ERROR))
48423 +                                       ? "CRC " : "",
48424 +                               (t2 & (1 << CLEAR_INTERRUPT_MODE))
48425 +                                       ? "interrupt " : "",
48426 +                               (t2 & (1<<CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE))
48427 +                                       ? "status " : "",
48428 +                               (t2 & (1 << CLEAR_NAK_OUT_PACKETS_MODE))
48429 +                                       ? "NAKmode " : "",
48430 +                               (t2 & (1 << CLEAR_ENDPOINT_TOGGLE))
48431 +                                       ? "DATA1 " : "DATA0 ",
48432 +                               (t2 & (1 << CLEAR_ENDPOINT_HALT))
48433 +                                       ? "HALT " : "",
48434                                 readl (&ep->regs->ep_irqenb));
48435                 size -= t;
48436                 next += t;
48437  
48438                 t = snprintf (next, size,
48439 -                               "stat %08x avail %04x "
48440 +                               "\tstat %08x avail %04x "
48441                                 "(ep%d%s-%s)%s\n",
48442                                 readl (&ep->regs->ep_stat),
48443                                 readl (&ep->regs->ep_avail),
48444 @@ -1796,6 +1816,7 @@
48445                 dev->ep [i].irqs = 0;
48446  
48447         /* hook up the driver ... */
48448 +       driver->driver.bus = 0;
48449         dev->driver = driver;
48450         dev->gadget.dev.driver = &driver->driver;
48451         retval = driver->bind (&dev->gadget);
48452 @@ -1807,10 +1828,6 @@
48453                 return retval;
48454         }
48455  
48456 -       // FIXME
48457 -       // driver_register (&driver->driver);
48458 -       // device_register (&dev->gadget.dev);
48459 -
48460         device_create_file (&dev->pdev->dev, &dev_attr_function);
48461         device_create_file (&dev->pdev->dev, &dev_attr_queues);
48462  
48463 @@ -1877,10 +1894,6 @@
48464         device_remove_file (&dev->pdev->dev, &dev_attr_function);
48465         device_remove_file (&dev->pdev->dev, &dev_attr_queues);
48466  
48467 -       // FIXME
48468 -       // device_unregister()
48469 -       // driver_unregister (&driver->driver);
48470 -
48471         DEBUG (dev, "unregistered driver '%s'\n", driver->driver.name);
48472         return 0;
48473  }
48474 @@ -2049,9 +2062,9 @@
48475  
48476                 /* maybe advance queue to next request */
48477                 if (ep->num == 0) {
48478 -                       /* FIXME need mechanism (request flag?) so control OUT
48479 -                        * can decide to stall ep0 after that done() returns,
48480 -                        * from non-irq context
48481 +                       /* NOTE:  net2280 could let gadget driver start the
48482 +                        * status stage later. since not all controllers let
48483 +                        * them control that, the api doesn't (yet) allow it.
48484                          */
48485                         if (!ep->stopped)
48486                                 allow_status (ep);
48487 @@ -2174,6 +2187,8 @@
48488  
48489                 /* watch control traffic at the token level, and force
48490                  * synchronization before letting the status stage happen.
48491 +                * FIXME ignore tokens we'll NAK, until driver responds.
48492 +                * that'll mean a lot less irqs for some drivers.
48493                  */
48494                 ep->is_in = (u.r.bRequestType & USB_DIR_IN) != 0;
48495                 if (ep->is_in)
48496 @@ -2417,6 +2432,28 @@
48497                         if ((tmp & (1 << DMA_SCATTER_GATHER_ENABLE)) == 0
48498                                         || (tmp & (1 << DMA_ENABLE)) == 0)
48499                                 restart_dma (ep);
48500 +#ifdef USE_DMA_CHAINING
48501 +                       else if (ep->desc->bEndpointAddress & USB_DIR_IN) {
48502 +                               struct net2280_request  *req;
48503 +                               u32                     dmacount;
48504 +
48505 +                               /* the descriptor at the head of the chain
48506 +                                * may still have VALID_BIT clear; that's
48507 +                                * used to trigger changing DMA_FIFO_VALIDATE
48508 +                                * (affects automagic zlp writes).
48509 +                                */
48510 +                               req = list_entry (ep->queue.next,
48511 +                                               struct net2280_request, queue);
48512 +                               dmacount = req->td->dmacount;
48513 +                               dmacount &= __constant_cpu_to_le32 (
48514 +                                               (1 << VALID_BIT)
48515 +                                               | DMA_BYTE_COUNT_MASK);
48516 +                               if (dmacount && (dmacount & valid_bit) == 0) {
48517 +                                       stop_dma (ep->dma);
48518 +                                       restart_dma (ep);
48519 +                               }
48520 +                       }
48521 +#endif
48522                 }
48523                 ep->irqs++;
48524         }
48525 @@ -2458,6 +2495,13 @@
48526  
48527  /*-------------------------------------------------------------------------*/
48528  
48529 +static void gadget_release (struct device *_dev)
48530 +{
48531 +       struct net2280  *dev = dev_get_drvdata (_dev);
48532 +
48533 +       kfree (dev);
48534 +}
48535 +
48536  /* tear down the binding between this driver and the pci device */
48537  
48538  static void net2280_remove (struct pci_dev *pdev)
48539 @@ -2493,12 +2537,12 @@
48540                                 pci_resource_len (pdev, 0));
48541         if (dev->enabled)
48542                 pci_disable_device (pdev);
48543 +       device_unregister (&dev->gadget.dev);
48544         device_remove_file (&pdev->dev, &dev_attr_registers);
48545         pci_set_drvdata (pdev, 0);
48546  
48547 -       INFO (dev, "unbind from pci %s\n", pci_name(pdev));
48548 +       INFO (dev, "unbind\n");
48549  
48550 -       kfree (dev);
48551         the_controller = 0;
48552  }
48553  
48554 @@ -2518,7 +2562,7 @@
48555          * usb_gadget_driver_{register,unregister}() must change.
48556          */
48557         if (the_controller) {
48558 -               WARN (the_controller, "ignoring %s\n", pci_name(pdev));
48559 +               dev_warn (&pdev->dev, "ignoring\n");
48560                 return -EBUSY;
48561         }
48562  
48563 @@ -2534,9 +2578,11 @@
48564         dev->pdev = pdev;
48565         dev->gadget.ops = &net2280_ops;
48566  
48567 -       strcpy (dev->gadget.dev.bus_id, pci_name(pdev));
48568 +       /* the "gadget" abstracts/virtualizes the controller */
48569 +       strcpy (dev->gadget.dev.bus_id, "gadget");
48570         dev->gadget.dev.parent = &pdev->dev;
48571         dev->gadget.dev.dma_mask = pdev->dev.dma_mask;
48572 +       dev->gadget.dev.release = gadget_release;
48573         dev->gadget.name = driver_name;
48574  
48575         /* now all the pci goodies ... */
48576 @@ -2650,6 +2696,7 @@
48577         INFO (dev, "version: %s\n", bufp);
48578         the_controller = dev;
48579  
48580 +       device_register (&dev->gadget.dev);
48581         device_create_file (&pdev->dev, &dev_attr_registers);
48582  
48583         return 0;
48584 diff -Nru a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
48585 --- a/drivers/usb/gadget/net2280.h      Mon Jul 14 09:07:22 2003
48586 +++ b/drivers/usb/gadget/net2280.h      Wed Aug 27 10:30:35 2003
48587 @@ -389,6 +389,7 @@
48588         u32             ep_rsp;
48589  #define     SET_NAK_OUT_PACKETS                                 15
48590  #define     SET_EP_HIDE_STATUS_PHASE                            14
48591 +#define     SET_EP_FORCE_CRC_ERROR                              13
48592  #define     SET_INTERRUPT_MODE                                  12
48593  #define     SET_CONTROL_STATUS_PHASE_HANDSHAKE                  11
48594  #define     SET_NAK_OUT_PACKETS_MODE                            10
48595 @@ -396,6 +397,7 @@
48596  #define     SET_ENDPOINT_HALT                                   8
48597  #define     CLEAR_NAK_OUT_PACKETS                               7
48598  #define     CLEAR_EP_HIDE_STATUS_PHASE                          6
48599 +#define     CLEAR_EP_FORCE_CRC_ERROR                            5
48600  #define     CLEAR_INTERRUPT_MODE                                4
48601  #define     CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE                3
48602  #define     CLEAR_NAK_OUT_PACKETS_MODE                          2
48603 @@ -476,6 +478,9 @@
48604  #define REG_CHIPREV            0x03    /* in bcd */
48605  #define        REG_HS_NAK_RATE         0x0a    /* NAK per N uframes */
48606  
48607 +#define        CHIPREV_1       0x0100
48608 +#define        CHIPREV_1A      0x0110
48609 +
48610  #ifdef __KERNEL__
48611  
48612  /* ep a-f highspeed and fullspeed maxpacket, addresses
48613 @@ -529,24 +534,6 @@
48614         ep->stopped = 1;
48615  }
48616  
48617 -static inline void set_halt (struct net2280_ep *ep)
48618 -{
48619 -       /* ep0 and bulk/intr endpoints */
48620 -       writel (  (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
48621 -                   /* set NAK_OUT for erratum 0114 */
48622 -               | (1 << SET_NAK_OUT_PACKETS)
48623 -               | (1 << SET_ENDPOINT_HALT)
48624 -               , &ep->regs->ep_rsp);
48625 -}
48626 -
48627 -static inline void clear_halt (struct net2280_ep *ep)
48628 -{
48629 -       /* bulk/intr endpoints */
48630 -       writel (  (1 << CLEAR_ENDPOINT_HALT)
48631 -               | (1 << CLEAR_ENDPOINT_TOGGLE)
48632 -               , &ep->regs->ep_rsp);
48633 -}
48634 -
48635  /* count (<= 4) bytes in the next fifo write will be valid */
48636  static inline void set_fifo_bytecount (struct net2280_ep *ep, unsigned count)
48637  {
48638 @@ -588,6 +575,28 @@
48639         struct pci_pool                 *requests;
48640         // statistics...
48641  };
48642 +
48643 +static inline void set_halt (struct net2280_ep *ep)
48644 +{
48645 +       /* ep0 and bulk/intr endpoints */
48646 +       writel (  (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
48647 +                   /* set NAK_OUT for erratum 0114 */
48648 +               | ((ep->dev->chiprev == CHIPREV_1) << SET_NAK_OUT_PACKETS)
48649 +               | (1 << SET_ENDPOINT_HALT)
48650 +               , &ep->regs->ep_rsp);
48651 +}
48652 +
48653 +static inline void clear_halt (struct net2280_ep *ep)
48654 +{
48655 +       /* ep0 and bulk/intr endpoints */
48656 +       writel (  (1 << CLEAR_ENDPOINT_HALT)
48657 +               | (1 << CLEAR_ENDPOINT_TOGGLE)
48658 +                   /* unless the gadget driver left a short packet in the
48659 +                    * fifo, this reverses the erratum 0114 workaround.
48660 +                    */
48661 +               | ((ep->dev->chiprev == CHIPREV_1) << CLEAR_NAK_OUT_PACKETS)
48662 +               , &ep->regs->ep_rsp);
48663 +}
48664  
48665  #ifdef USE_RDK_LEDS
48666  
48667 diff -Nru a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
48668 --- a/drivers/usb/host/ehci-hcd.c       Thu Jul 31 07:25:14 2003
48669 +++ b/drivers/usb/host/ehci-hcd.c       Fri Aug 29 11:21:44 2003
48670 @@ -41,7 +41,6 @@
48671  #include <linux/usb.h>
48672  #include <linux/moduleparam.h>
48673  
48674 -#include <linux/version.h>
48675  #include "../core/hcd.h"
48676  
48677  #include <asm/byteorder.h>
48678 @@ -232,7 +231,6 @@
48679                 ehci->hcd.state = USB_STATE_HALT;
48680                 return;
48681         }
48682 -       ehci->hcd.state = USB_STATE_READY;
48683  }
48684  
48685  /*-------------------------------------------------------------------------*/
48686 @@ -482,7 +480,7 @@
48687         ehci->reboot_notifier.notifier_call = ehci_reboot;
48688         register_reboot_notifier (&ehci->reboot_notifier);
48689  
48690 -       ehci->hcd.state = USB_STATE_READY;
48691 +       ehci->hcd.state = USB_STATE_RUNNING;
48692         writel (FLAG_CF, &ehci->regs->configured_flag);
48693         readl (&ehci->regs->command);   /* unblock posted write */
48694  
48695 @@ -626,7 +624,7 @@
48696         /* resume HC and each port */
48697  // restore pci FLADJ value
48698         // khubd and drivers will set HC running, if needed;
48699 -       hcd->state = USB_STATE_READY;
48700 +       hcd->state = USB_STATE_RUNNING;
48701         // FIXME Philips/Intel/... etc don't really have a "READY"
48702         // state ... turn on CMD_RUN too
48703         for (i = 0; i < ports; i++) {
48704 @@ -979,21 +977,12 @@
48705  /* EHCI spec says PCI is required. */
48706  
48707  /* PCI driver selection metadata; PCI hotplugging uses this */
48708 -static struct pci_device_id pci_ids [] = { {
48709 -
48710 +static const struct pci_device_id pci_ids [] = { {
48711         /* handle any USB 2.0 EHCI controller */
48712 -
48713 -       .class =                ((PCI_CLASS_SERIAL_USB << 8) | 0x20),
48714 -       .class_mask =   ~0,
48715 +       PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0),
48716         .driver_data =  (unsigned long) &ehci_driver,
48717 -
48718 -       /* no matter who makes it */
48719 -       .vendor =       PCI_ANY_ID,
48720 -       .device =       PCI_ANY_ID,
48721 -       .subvendor =    PCI_ANY_ID,
48722 -       .subdevice =    PCI_ANY_ID,
48723 -
48724 -}, { /* end: all zeroes */ }
48725 +       },
48726 +       { /* end: all zeroes */ }
48727  };
48728  MODULE_DEVICE_TABLE (pci, pci_ids);
48729  
48730 diff -Nru a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
48731 --- a/drivers/usb/host/ohci-hcd.c       Thu Jul 31 13:51:23 2003
48732 +++ b/drivers/usb/host/ohci-hcd.c       Fri Aug 29 11:23:08 2003
48733 @@ -529,7 +529,7 @@
48734         /* connect the virtual root hub */
48735         bus = hcd_to_bus (&ohci->hcd);
48736         bus->root_hub = udev = usb_alloc_dev (NULL, bus);
48737 -       ohci->hcd.state = USB_STATE_READY;
48738 +       ohci->hcd.state = USB_STATE_RUNNING;
48739         if (!udev) {
48740                 disable (ohci);
48741                 ohci->hc_control &= ~OHCI_CTRL_HCFS;
48742 diff -Nru a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
48743 --- a/drivers/usb/host/ohci-pci.c       Thu Jul 31 14:36:49 2003
48744 +++ b/drivers/usb/host/ohci-pci.c       Fri Aug 29 11:24:51 2003
48745 @@ -30,6 +30,15 @@
48746  
48747  /*-------------------------------------------------------------------------*/
48748  
48749 +static int
48750 +ohci_pci_reset (struct usb_hcd *hcd)
48751 +{
48752 +       struct ohci_hcd *ohci = hcd_to_ohci (hcd);
48753 +
48754 +       ohci->regs = hcd->regs;
48755 +       return hc_reset (ohci);
48756 +}
48757 +
48758  static int __devinit
48759  ohci_pci_start (struct usb_hcd *hcd)
48760  {
48761 @@ -89,12 +98,6 @@
48762                 ohci_stop (hcd);
48763                 return ret;
48764         }
48765 -       ohci->regs = hcd->regs;
48766 -
48767 -       if (hc_reset (ohci) < 0) {
48768 -               ohci_stop (hcd);
48769 -               return -ENODEV;
48770 -       }
48771  
48772         if (hc_start (ohci) < 0) {
48773                 ohci_err (ohci, "can't start\n");
48774 @@ -264,7 +267,7 @@
48775                         if (ohci->ed_bulktail)
48776                                 ohci->hc_control |= OHCI_CTRL_BLE;
48777                 }
48778 -               hcd->state = USB_STATE_READY;
48779 +               hcd->state = USB_STATE_RUNNING;
48780                 writel (ohci->hc_control, &ohci->regs->control);
48781  
48782                 /* trigger a start-frame interrupt (why?) */
48783 @@ -315,6 +318,7 @@
48784         /*
48785          * basic lifecycle operations
48786          */
48787 +       .reset =                ohci_pci_reset,
48788         .start =                ohci_pci_start,
48789  #ifdef CONFIG_PM
48790         .suspend =              ohci_pci_suspend,
48791 @@ -351,18 +355,9 @@
48792  
48793  
48794  static const struct pci_device_id pci_ids [] = { {
48795 -
48796         /* handle any USB OHCI controller */
48797 -       .class =        (PCI_CLASS_SERIAL_USB << 8) | 0x10,
48798 -       .class_mask =   ~0,
48799 +       PCI_DEVICE_CLASS((PCI_CLASS_SERIAL_USB << 8) | 0x10, ~0),
48800         .driver_data =  (unsigned long) &ohci_pci_hc_driver,
48801 -
48802 -       /* no matter who makes it */
48803 -       .vendor =       PCI_ANY_ID,
48804 -       .device =       PCI_ANY_ID,
48805 -       .subvendor =    PCI_ANY_ID,
48806 -       .subdevice =    PCI_ANY_ID,
48807 -
48808         }, { /* end: all zeroes */ }
48809  };
48810  MODULE_DEVICE_TABLE (pci, pci_ids);
48811 diff -Nru a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
48812 --- a/drivers/usb/host/ohci-q.c Mon Jul 14 11:27:33 2003
48813 +++ b/drivers/usb/host/ohci-q.c Wed Aug 27 10:29:59 2003
48814 @@ -1013,10 +1013,22 @@
48815                 if (list_empty (&ed->td_list))
48816                         ed_deschedule (ohci, ed);
48817                 /* ... reenabling halted EDs only after fault cleanup */
48818 -               else if (!(ed->hwINFO & ED_DEQUEUE)) {
48819 +               else if ((ed->hwINFO & (ED_SKIP | ED_DEQUEUE)) == ED_SKIP) {
48820                         td = list_entry (ed->td_list.next, struct td, td_list);
48821 -                       if (!(td->hwINFO & TD_DONE))
48822 +                       if (!(td->hwINFO & TD_DONE)) {
48823                                 ed->hwINFO &= ~ED_SKIP;
48824 +                               /* ... hc may need waking-up */
48825 +                               switch (ed->type) {
48826 +                               case PIPE_CONTROL:
48827 +                                       writel (OHCI_CLF,
48828 +                                               &ohci->regs->cmdstatus);   
48829 +                                       break;
48830 +                               case PIPE_BULK:
48831 +                                       writel (OHCI_BLF,
48832 +                                               &ohci->regs->cmdstatus);   
48833 +                                       break;
48834 +                               }
48835 +                       }
48836                 }
48837  
48838                 td = td_next;
48839 diff -Nru a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
48840 --- a/drivers/usb/host/ohci-sa1111.c    Thu Jul 31 13:51:23 2003
48841 +++ b/drivers/usb/host/ohci-sa1111.c    Sun Aug 24 07:45:05 2003
48842 @@ -352,9 +352,8 @@
48843  
48844  /*-------------------------------------------------------------------------*/
48845  
48846 -static int ohci_hcd_sa1111_drv_probe(struct device *_dev)
48847 +static int ohci_hcd_sa1111_drv_probe(struct sa1111_dev *dev)
48848  {
48849 -       struct sa1111_dev *dev = SA1111_DEV(_dev);
48850         struct usb_hcd *hcd = NULL;
48851         int ret;
48852  
48853 @@ -364,43 +363,29 @@
48854         ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, &hcd, dev);
48855  
48856         if (ret == 0)
48857 -               dev->dev.driver_data = hcd;
48858 +               sa1111_set_drvdata(dev, hcd);
48859  
48860         return ret;
48861  }
48862  
48863 -static int ohci_hcd_sa1111_drv_remove(struct device *_dev)
48864 +static int ohci_hcd_sa1111_drv_remove(struct sa1111_dev *dev)
48865  {
48866 -       struct sa1111_dev *dev = SA1111_DEV(_dev);
48867 -       struct usb_hcd *hcd = dev->dev.driver_data;
48868 +       struct usb_hcd *hcd = sa1111_get_drvdata(dev);
48869  
48870         usb_hcd_sa1111_remove(hcd, dev);
48871  
48872 -       dev->dev.driver_data = NULL;
48873 +       sa1111_set_drvdata(dev, NULL);
48874  
48875         return 0;
48876  }
48877  
48878 -static int ohci_hcd_sa1111_drv_suspend(struct device *dev, u32 state, u32 level)
48879 -{
48880 -       return 0;
48881 -}
48882 -
48883 -static int ohci_hcd_sa1111_drv_resume(struct device *dev, u32 level)
48884 -{
48885 -       return 0;
48886 -}
48887 -
48888  static struct sa1111_driver ohci_hcd_sa1111_driver = {
48889         .drv = {
48890 -               .name           = "sa1111-ohci",
48891 -               .bus            = &sa1111_bus_type,
48892 -               .probe          = ohci_hcd_sa1111_drv_probe,
48893 -               .remove         = ohci_hcd_sa1111_drv_remove,
48894 -               .suspend        = ohci_hcd_sa1111_drv_suspend,
48895 -               .resume         = ohci_hcd_sa1111_drv_resume,
48896 +               .name   = "sa1111-ohci",
48897         },
48898 -       .devid                  = SA1111_DEVID_USB,
48899 +       .devid          = SA1111_DEVID_USB,
48900 +       .probe          = ohci_hcd_sa1111_drv_probe,
48901 +       .remove         = ohci_hcd_sa1111_drv_remove,
48902  };
48903  
48904  static int __init ohci_hcd_sa1111_init (void)
48905 @@ -409,12 +394,12 @@
48906         dbg ("block sizes: ed %d td %d",
48907                 sizeof (struct ed), sizeof (struct td));
48908  
48909 -       return driver_register(&ohci_hcd_sa1111_driver.drv);
48910 +       return sa1111_driver_register(&ohci_hcd_sa1111_driver);
48911  }
48912  
48913  static void __exit ohci_hcd_sa1111_cleanup (void)
48914  {
48915 -       driver_unregister(&ohci_hcd_sa1111_driver.drv);
48916 +       sa1111_driver_unregister(&ohci_hcd_sa1111_driver);
48917  }
48918  
48919  module_init (ohci_hcd_sa1111_init);
48920 diff -Nru a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
48921 --- a/drivers/usb/host/uhci-hcd.c       Wed Aug  6 04:52:20 2003
48922 +++ b/drivers/usb/host/uhci-hcd.c       Fri Aug 29 11:29:09 2003
48923 @@ -2099,7 +2099,7 @@
48924         uhci->state_end = jiffies + HZ;
48925         outw(USBCMD_RS | USBCMD_CF | USBCMD_MAXP, io_addr + USBCMD);
48926  
48927 -        uhci->hcd.state = USB_STATE_READY;
48928 +        uhci->hcd.state = USB_STATE_RUNNING;
48929  }
48930  
48931  /*
48932 @@ -2143,6 +2143,20 @@
48933  #endif
48934  }
48935  
48936 +static int uhci_reset(struct usb_hcd *hcd)
48937 +{
48938 +       struct uhci_hcd *uhci = hcd_to_uhci(hcd);
48939 +
48940 +       uhci->io_addr = (unsigned long) hcd->regs;
48941 +
48942 +       /* Maybe kick BIOS off this hardware.  Then reset, so we won't get
48943 +        * interrupts from any previous setup.
48944 +        */
48945 +       pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
48946 +       reset_hc(uhci);
48947 +       return 0;
48948 +}
48949 +
48950  /*
48951   * Allocate a frame list, and then setup the skeleton
48952   *
48953 @@ -2159,7 +2173,7 @@
48954   *  - The fourth queue is the bandwidth reclamation queue, which loops back
48955   *    to the high speed control queue.
48956   */
48957 -static int __devinit uhci_start(struct usb_hcd *hcd)
48958 +static int uhci_start(struct usb_hcd *hcd)
48959  {
48960         struct uhci_hcd *uhci = hcd_to_uhci(hcd);
48961         int retval = -EBUSY;
48962 @@ -2171,7 +2185,6 @@
48963         struct proc_dir_entry *ent;
48964  #endif
48965  
48966 -       uhci->io_addr = (unsigned long) hcd->regs;
48967         io_size = pci_resource_len(hcd->pdev, hcd->region);
48968  
48969  #ifdef CONFIG_PROC_FS
48970 @@ -2188,10 +2201,6 @@
48971         uhci->proc_entry = ent;
48972  #endif
48973  
48974 -       /* Reset here so we don't get any interrupts from an old setup */
48975 -       /*  or broken setup */
48976 -       reset_hc(uhci);
48977 -
48978         uhci->fsbr = 0;
48979         uhci->fsbrtimeout = 0;
48980  
48981 @@ -2343,9 +2352,6 @@
48982  
48983         init_stall_timer(hcd);
48984  
48985 -       /* disable legacy emulation */
48986 -       pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
48987 -
48988         udev->speed = USB_SPEED_FULL;
48989  
48990         if (usb_register_root_hub(udev, &hcd->pdev->dev) != 0) {
48991 @@ -2446,7 +2452,7 @@
48992                 reset_hc(uhci);
48993                 start_hc(uhci);
48994         }
48995 -       uhci->hcd.state = USB_STATE_READY;
48996 +       uhci->hcd.state = USB_STATE_RUNNING;
48997         return 0;
48998  }
48999  #endif
49000 @@ -2484,6 +2490,7 @@
49001         .flags =                HCD_USB11,
49002  
49003         /* Basic lifecycle operations */
49004 +       .reset =                uhci_reset,
49005         .start =                uhci_start,
49006  #ifdef CONFIG_PM
49007         .suspend =              uhci_suspend,
49008 @@ -2504,18 +2511,9 @@
49009  };
49010  
49011  static const struct pci_device_id uhci_pci_ids[] = { {
49012 -
49013         /* handle any USB UHCI controller */
49014 -       .class =                ((PCI_CLASS_SERIAL_USB << 8) | 0x00),
49015 -       .class_mask =   ~0,
49016 +       PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x00), ~0),
49017         .driver_data =  (unsigned long) &uhci_driver,
49018 -
49019 -       /* no matter who makes it */
49020 -       .vendor =       PCI_ANY_ID,
49021 -       .device =       PCI_ANY_ID,
49022 -       .subvendor =    PCI_ANY_ID,
49023 -       .subdevice =    PCI_ANY_ID,
49024 -
49025         }, { /* end: all zeroes */ }
49026  };
49027  
49028 diff -Nru a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
49029 --- a/drivers/usb/image/mdc800.c        Wed Jun 11 20:02:46 2003
49030 +++ b/drivers/usb/image/mdc800.c        Wed Aug 27 03:46:31 2003
49031 @@ -977,8 +977,9 @@
49032  #define try_free_mem(A)  if (A != 0) { kfree (A); A=0; }
49033  #define try_free_urb(A)  if (A != 0) { usb_free_urb (A); A=0; }
49034  
49035 -int __init usb_mdc800_init (void)
49036 +static int __init usb_mdc800_init (void)
49037  {
49038 +       int retval = -ENODEV;
49039         /* Allocate Memory */
49040         try (mdc800=kmalloc (sizeof (struct mdc800_data), GFP_KERNEL));
49041  
49042 @@ -1005,7 +1006,8 @@
49043         try (mdc800->write_urb=usb_alloc_urb (0, GFP_KERNEL));
49044  
49045         /* Register the driver */
49046 -       if (usb_register (&mdc800_usb_driver) < 0)
49047 +       retval = usb_register(&mdc800_usb_driver);
49048 +       if (retval)
49049                 goto cleanup_on_fail;
49050  
49051         info (DRIVER_VERSION ":" DRIVER_DESC);
49052 @@ -1031,11 +1033,11 @@
49053                 kfree (mdc800);
49054         }
49055         mdc800=0;
49056 -       return -1;
49057 +       return retval;
49058  }
49059  
49060  
49061 -void __exit usb_mdc800_cleanup (void)
49062 +static void __exit usb_mdc800_cleanup (void)
49063  {
49064         usb_deregister (&mdc800_usb_driver);
49065  
49066 diff -Nru a/drivers/usb/image/scanner.h b/drivers/usb/image/scanner.h
49067 --- a/drivers/usb/image/scanner.h       Tue Jul 15 02:37:52 2003
49068 +++ b/drivers/usb/image/scanner.h       Tue Aug 26 09:25:41 2003
49069 @@ -313,7 +313,7 @@
49070  #define IS_EP_BULK_OUT(ep) (IS_EP_BULK(ep) && ((ep)->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT)
49071  #define IS_EP_INTR(ep) ((ep)->bmAttributes == USB_ENDPOINT_XFER_INT ? 1 : 0)
49072  
49073 -#define USB_SCN_MINOR(X) minor((X)->i_rdev)
49074 +#define USB_SCN_MINOR(X) iminor(X)
49075  
49076  #ifdef DEBUG
49077  #define SCN_DEBUG(X) X
49078 diff -Nru a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
49079 --- a/drivers/usb/input/hid-core.c      Sat Jun 21 04:45:12 2003
49080 +++ b/drivers/usb/input/hid-core.c      Tue Aug 26 17:19:45 2003
49081 @@ -1328,6 +1328,7 @@
49082  #define USB_DEVICE_ID_ATEN_CS124U      0x2202
49083  #define USB_DEVICE_ID_ATEN_2PORTKVM    0x2204
49084  #define USB_DEVICE_ID_ATEN_4PORTKVM    0x2205
49085 +#define USB_DEVICE_ID_ATEN_4PORTKVMC   0x2208
49086  
49087  #define USB_VENDOR_ID_TOPMAX           0x0663
49088  #define USB_DEVICE_ID_TOPMAX_COBRAPAD  0x0103
49089 @@ -1386,6 +1387,7 @@
49090         { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
49091         { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
49092         { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
49093 +       { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
49094         { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_HIDDEV },
49095         { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_HIDDEV },
49096         { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
49097 @@ -1691,11 +1693,20 @@
49098  
49099  static int __init hid_init(void)
49100  {
49101 -       hiddev_init();
49102 -       usb_register(&hid_driver);
49103 +       int retval;
49104 +       retval = hiddev_init();
49105 +       if (retval)
49106 +               goto hiddev_init_fail;
49107 +       retval = usb_register(&hid_driver);
49108 +       if (retval)
49109 +               goto usb_register_fail;
49110         info(DRIVER_VERSION ":" DRIVER_DESC);
49111  
49112         return 0;
49113 +usb_register_fail:
49114 +       hiddev_exit();
49115 +hiddev_init_fail:
49116 +       return retval;
49117  }
49118  
49119  static void __exit hid_exit(void)
49120 diff -Nru a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
49121 --- a/drivers/usb/input/hiddev.c        Wed Jun 11 07:58:27 2003
49122 +++ b/drivers/usb/input/hiddev.c        Tue Sep  2 11:40:28 2003
49123 @@ -271,7 +271,7 @@
49124  static int hiddev_open(struct inode * inode, struct file * file) {
49125         struct hiddev_list *list;
49126  
49127 -       int i = minor(inode->i_rdev) - HIDDEV_MINOR_BASE;
49128 +       int i = iminor(inode) - HIDDEV_MINOR_BASE;
49129  
49130         if (i >= HIDDEV_MINORS || !hiddev_table[i])
49131                 return -ENODEV;
49132 @@ -795,8 +795,7 @@
49133  int __init hiddev_init(void)
49134  {
49135         devfs_mk_dir("usb/hid");
49136 -       usb_register(&hiddev_driver);
49137 -       return 0;
49138 +       return usb_register(&hiddev_driver);
49139  }
49140  
49141  void __exit hiddev_exit(void)
49142 diff -Nru a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
49143 --- a/drivers/usb/input/kbtab.c Thu Jun 12 07:28:01 2003
49144 +++ b/drivers/usb/input/kbtab.c Sat Aug 23 07:09:53 2003
49145 @@ -216,9 +216,13 @@
49146  
49147  static int __init kbtab_init(void)
49148  {
49149 -       usb_register(&kbtab_driver);
49150 +       int retval;
49151 +       retval = usb_register(&kbtab_driver);
49152 +       if (retval)
49153 +               goto out;
49154         info(DRIVER_VERSION ":" DRIVER_DESC);
49155 -       return 0;
49156 +out:
49157 +       return retval;
49158  }
49159  
49160  static void __exit kbtab_exit(void)
49161 diff -Nru a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
49162 --- a/drivers/usb/input/powermate.c     Thu Jun 12 07:28:01 2003
49163 +++ b/drivers/usb/input/powermate.c     Sat Aug 23 07:11:02 2003
49164 @@ -433,14 +433,12 @@
49165          .id_table =     powermate_devices,
49166  };
49167  
49168 -int powermate_init(void)
49169 +static int __init powermate_init(void)
49170  {
49171 -       if (usb_register(&powermate_driver) < 0)
49172 -               return -1;
49173 -       return 0;
49174 +       return usb_register(&powermate_driver);
49175  }
49176  
49177 -void powermate_cleanup(void)
49178 +static void __exit powermate_cleanup(void)
49179  {
49180         usb_deregister(&powermate_driver);
49181  }
49182 diff -Nru a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c
49183 --- a/drivers/usb/media/dabusb.c        Mon Aug 11 07:56:25 2003
49184 +++ b/drivers/usb/media/dabusb.c        Tue Sep  2 11:40:28 2003
49185 @@ -29,7 +29,6 @@
49186  
49187  #include <linux/module.h>
49188  #include <linux/socket.h>
49189 -#include <linux/miscdevice.h>
49190  #include <linux/list.h>
49191  #include <linux/vmalloc.h>
49192  #include <linux/slab.h>
49193 @@ -583,7 +582,7 @@
49194  
49195  static int dabusb_open (struct inode *inode, struct file *file)
49196  {
49197 -       int devnum = minor (inode->i_rdev);
49198 +       int devnum = iminor(inode);
49199         pdabusb_t s;
49200  
49201         if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB))
49202 @@ -819,6 +818,7 @@
49203  
49204  static int __init dabusb_init (void)
49205  {
49206 +       int retval;
49207         unsigned u;
49208  
49209         /* initialize struct */
49210 @@ -836,14 +836,16 @@
49211         }
49212  
49213         /* register misc device */
49214 -       if (usb_register(&dabusb_driver))
49215 -               return -1;
49216 +       retval = usb_register(&dabusb_driver);
49217 +       if (retval)
49218 +               goto out;
49219  
49220         dbg("dabusb_init: driver registered");
49221  
49222         info(DRIVER_VERSION ":" DRIVER_DESC);
49223  
49224 -       return 0;
49225 +out:
49226 +       return retval;
49227  }
49228  
49229  static void __exit dabusb_cleanup (void)
49230 diff -Nru a/drivers/usb/media/dsbr100.c b/drivers/usb/media/dsbr100.c
49231 --- a/drivers/usb/media/dsbr100.c       Thu May 29 13:20:21 2003
49232 +++ b/drivers/usb/media/dsbr100.c       Sat Aug 23 07:19:42 2003
49233 @@ -354,15 +354,23 @@
49234  
49235  static int __init dsbr100_init(void)
49236  {
49237 +       int retval;
49238         usb_dsbr100_radio.priv = NULL;
49239 -       usb_register(&usb_dsbr100_driver);
49240 -       if (video_register_device(&usb_dsbr100_radio, VFL_TYPE_RADIO,
49241 -               radio_nr)==-1) {        
49242 +       retval = usb_register(&usb_dsbr100_driver);
49243 +       if (retval)
49244 +               goto failed_usb_register;
49245 +       retval = video_register_device(&usb_dsbr100_radio, VFL_TYPE_RADIO,
49246 +                                      radio_nr);
49247 +       if (retval) {   
49248                 warn("Couldn't register video device");
49249 -               return -EINVAL;
49250 +               goto failed_video_register;
49251         }
49252         info(DRIVER_VERSION ":" DRIVER_DESC);
49253         return 0;
49254 +failed_video_register:
49255 +       usb_deregister(&usb_dsbr100_driver);
49256 +failed_usb_register:
49257 +       return retval;
49258  }
49259  
49260  static void __exit dsbr100_exit(void)
49261 diff -Nru a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
49262 --- a/drivers/usb/media/ov511.c Tue Aug 12 23:54:33 2003
49263 +++ b/drivers/usb/media/ov511.c Wed Aug 27 05:44:53 2003
49264 @@ -4592,7 +4592,7 @@
49265         return rc;
49266  }
49267  
49268 -static int
49269 +static ssize_t
49270  ov51x_v4l1_read(struct file *file, char *buf, size_t cnt, loff_t *ppos)
49271  {
49272         struct video_device *vdev = file->private_data;
49273 @@ -6115,13 +6115,16 @@
49274  static int __init
49275  usb_ov511_init(void)
49276  {
49277 +       int retval;
49278  
49279 -       if (usb_register(&ov511_driver) < 0)
49280 -               return -1;
49281 +       retval = usb_register(&ov511_driver);
49282 +       if (retval)
49283 +               goto out;
49284  
49285         info(DRIVER_VERSION " : " DRIVER_DESC);
49286  
49287 -       return 0;
49288 +out:
49289 +       return retval;
49290  }
49291  
49292  static void __exit
49293 diff -Nru a/drivers/usb/media/pwc-if.c b/drivers/usb/media/pwc-if.c
49294 --- a/drivers/usb/media/pwc-if.c        Sat Jul 26 18:54:19 2003
49295 +++ b/drivers/usb/media/pwc-if.c        Wed Aug 27 05:44:03 2003
49296 @@ -129,7 +129,7 @@
49297  
49298  static int pwc_video_open(struct inode *inode, struct file *file);
49299  static int pwc_video_close(struct inode *inode, struct file *file);
49300 -static int pwc_video_read(struct file *file, char *buf,
49301 +static ssize_t pwc_video_read(struct file *file, char *buf,
49302                           size_t count, loff_t *ppos);
49303  static unsigned int pwc_video_poll(struct file *file, poll_table *wait);
49304  static int  pwc_video_ioctl(struct inode *inode, struct file *file,
49305 @@ -1116,7 +1116,7 @@
49306                  device is tricky anyhow.
49307   */
49308  
49309 -static int pwc_video_read(struct file *file, char *buf,
49310 +static ssize_t pwc_video_read(struct file *file, char *buf,
49311                           size_t count, loff_t *ppos)
49312  {
49313         struct video_device *vdev = file->private_data;
49314 @@ -1124,7 +1124,7 @@
49315         int noblock = file->f_flags & O_NONBLOCK;
49316         DECLARE_WAITQUEUE(wait, current);
49317  
49318 -       Trace(TRACE_READ, "video_read(0x%p, %p, %d) called.\n", vdev, buf, count);
49319 +       Trace(TRACE_READ, "video_read(0x%p, %p, %Zd) called.\n", vdev, buf, count);
49320         if (vdev == NULL)
49321                 return -EFAULT;
49322         pdev = vdev->priv;
49323 diff -Nru a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c
49324 --- a/drivers/usb/media/se401.c Thu Aug 21 09:01:34 2003
49325 +++ b/drivers/usb/media/se401.c Wed Aug 27 05:45:24 2003
49326 @@ -30,16 +30,10 @@
49327  #include <linux/config.h>
49328  #include <linux/module.h>
49329  #include <linux/init.h>
49330 -#include <linux/fs.h>
49331  #include <linux/vmalloc.h>
49332  #include <linux/slab.h>
49333 -#include <linux/proc_fs.h>
49334  #include <linux/pagemap.h>
49335  #include <linux/usb.h>
49336 -#include <asm/io.h>
49337 -#include <asm/semaphore.h>
49338 -#include <linux/mm.h>
49339 -
49340  #include "se401.h"
49341  
49342  static int flickerless=0;
49343 @@ -126,131 +120,6 @@
49344  
49345  /****************************************************************************
49346   *
49347 - * /proc interface
49348 - *
49349 - ***************************************************************************/
49350 -
49351 -#warning please convert me from procfs to sysfs
49352 -#undef CONFIG_VIDEO_PROC_FS
49353 -
49354 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49355 -
49356 -static struct proc_dir_entry *se401_proc_entry = NULL;
49357 -extern struct proc_dir_entry *video_proc_entry;
49358 -
49359 -#define YES_NO(x) ((x) ? "yes" : "no")
49360 -
49361 -static int se401_read_proc(char *page, char **start, off_t off, int count,
49362 -                          int *eof, void *data)
49363 -{
49364 -       char *out = page;
49365 -       int i, len;
49366 -       struct usb_se401 *se401 = data;
49367 -       
49368 -       /* Stay under PAGE_SIZE or else bla bla bla.... */
49369 -
49370 -       out+=sprintf(out, "driver_version  : %s\n", version);
49371 -       out+=sprintf(out, "model           : %s\n", se401->camera_name);
49372 -       out+=sprintf(out, "in use          : %s\n", YES_NO (se401->user));
49373 -       out+=sprintf(out, "streaming       : %s\n", YES_NO (se401->streaming));
49374 -       out+=sprintf(out, "button state    : %s\n", YES_NO (se401->button));
49375 -       out+=sprintf(out, "button pressed  : %s\n", YES_NO (se401->buttonpressed));
49376 -       out+=sprintf(out, "num_frames      : %d\n", SE401_NUMFRAMES);
49377 -
49378 -       out+=sprintf(out, "Sizes           :");
49379 -       for (i=0; i<se401->sizes; i++) {
49380 -               out+=sprintf(out, " %dx%d", se401->width[i],
49381 -                   se401->height[i]);
49382 -       }
49383 -       out+=sprintf(out, "\n");
49384 -       
49385 -       out+=sprintf(out, "Frames total    : %d\n", se401->readcount);
49386 -       out+=sprintf(out, "Frames read     : %d\n", se401->framecount);
49387 -       out+=sprintf(out, "Packets dropped : %d\n", se401->dropped);
49388 -       out+=sprintf(out, "Decoding Errors : %d\n", se401->error);
49389 -
49390 -       len = out - page;
49391 -       len -= off;
49392 -       if (len < count) {
49393 -               *eof = 1;
49394 -               if (len <= 0)
49395 -                       return 0;
49396 -       } else
49397 -               len = count;
49398 -
49399 -       *start = page + off;
49400 -       
49401 -       return len;     
49402 -}
49403 -
49404 -static int se401_write_proc(struct file *file, const char *buffer, 
49405 -                           unsigned long count, void *data)
49406 -{
49407 -       return -EINVAL;
49408 -}
49409 -
49410 -static void create_proc_se401_cam (struct usb_se401 *se401)
49411 -{
49412 -       char name[7];
49413 -       struct proc_dir_entry *ent;
49414 -
49415 -       if (!se401_proc_entry || !se401)
49416 -               return;
49417 -
49418 -       sprintf (name, "video%d", se401->vdev.minor);
49419 -
49420 -       ent = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
49421 -                               se401_proc_entry);
49422 -
49423 -       if (!ent)
49424 -               return;
49425 -
49426 -       ent->data = se401;
49427 -       ent->read_proc = se401_read_proc;
49428 -       ent->write_proc = se401_write_proc;
49429 -       se401->proc_entry = ent;
49430 -}
49431 -
49432 -static void destroy_proc_se401_cam (struct usb_se401 *se401)
49433 -{
49434 -       /* One to much, just to be sure :) */
49435 -       char name[9];
49436 -
49437 -       if (!se401 || !se401->proc_entry)
49438 -               return;
49439 -       
49440 -       sprintf(name, "video%d", se401->vdev.minor);
49441 -       remove_proc_entry(name, se401_proc_entry);
49442 -       se401->proc_entry = NULL;
49443 -}
49444 -
49445 -static void proc_se401_create (void)
49446 -{
49447 -       if (video_proc_entry == NULL) {
49448 -               err("/proc/video/ doesn't exist");
49449 -               return;
49450 -       }
49451 -
49452 -       se401_proc_entry=create_proc_entry("se401", S_IFDIR, video_proc_entry);
49453 -
49454 -       if (se401_proc_entry)
49455 -               se401_proc_entry->owner = THIS_MODULE;
49456 -       else
49457 -               err("Unable to initialize /proc/video/se401");
49458 -}
49459 -
49460 -static void proc_se401_destroy(void)
49461 -{
49462 -       if (se401_proc_entry == NULL)
49463 -               return;
49464 -
49465 -       remove_proc_entry("se401", video_proc_entry);
49466 -}
49467 -#endif /* CONFIG_PROC_FS && CONFIG_VIDEO_PROC_FS */
49468 -
49469 -
49470 -/****************************************************************************
49471 - *
49472   * se401 register read/write functions
49473   *
49474   ***************************************************************************/
49475 @@ -1252,7 +1121,7 @@
49476         return video_usercopy(inode, file, cmd, arg, se401_do_ioctl);
49477  }
49478  
49479 -static int se401_read(struct file *file, char *buf,
49480 +static ssize_t se401_read(struct file *file, char *buf,
49481                      size_t count, loff_t *ppos)
49482  {
49483         int realcount=count, ret=0;
49484 @@ -1517,9 +1386,6 @@
49485                 err("video_register_device failed");
49486                 return -EIO;
49487         }
49488 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49489 -        create_proc_se401_cam(se401);
49490 -#endif
49491         info("registered new video device: video%d", se401->vdev.minor);
49492  
49493         usb_set_intfdata (intf, se401);
49494 @@ -1544,9 +1410,6 @@
49495                         wake_up_interruptible(&se401->wq);
49496                         se401->removed = 1;
49497                 }
49498 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49499 -               destroy_proc_se401_cam(se401);
49500 -#endif
49501         }
49502  }
49503  
49504 @@ -1568,29 +1431,19 @@
49505  
49506  static int __init usb_se401_init(void)
49507  {
49508 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49509 -       proc_se401_create();
49510 -#endif
49511 -
49512         info("SE401 usb camera driver version %s registering", version);
49513         if (flickerless)
49514                 if (flickerless!=50 && flickerless!=60) {
49515                         info("Invallid flickerless value, use 0, 50 or 60.");
49516                         return -1;
49517         }
49518 -       if (usb_register(&se401_driver) < 0)
49519 -               return -1;
49520 -       return 0;
49521 +       return usb_register(&se401_driver);
49522  }
49523  
49524  static void __exit usb_se401_exit(void)
49525  {
49526         usb_deregister(&se401_driver);
49527         info("SE401 driver deregistered");
49528 -
49529 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49530 -       proc_se401_destroy();
49531 -#endif
49532  }
49533  
49534  module_init(usb_se401_init);
49535 diff -Nru a/drivers/usb/media/se401.h b/drivers/usb/media/se401.h
49536 --- a/drivers/usb/media/se401.h Thu Sep  5 16:27:15 2002
49537 +++ b/drivers/usb/media/se401.h Wed Aug 27 10:22:35 2003
49538 @@ -224,9 +224,6 @@
49539  
49540         wait_queue_head_t wq;   /* Processes waiting */
49541  
49542 -       /* proc interface */
49543 -       struct proc_dir_entry *proc_entry;      /* /proc/se401/videoX */
49544 -
49545         int nullpackets;
49546  };
49547  
49548 diff -Nru a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c
49549 --- a/drivers/usb/media/stv680.c        Thu Aug 21 09:02:29 2003
49550 +++ b/drivers/usb/media/stv680.c        Wed Aug 27 05:46:09 2003
49551 @@ -61,14 +61,9 @@
49552  #include <linux/config.h>
49553  #include <linux/module.h>
49554  #include <linux/init.h>
49555 -#include <linux/fs.h>
49556  #include <linux/vmalloc.h>
49557  #include <linux/slab.h>
49558 -#include <linux/proc_fs.h>
49559  #include <linux/pagemap.h>
49560 -#include <linux/smp_lock.h>
49561 -#include <linux/sched.h>
49562 -#include <linux/signal.h>
49563  #include <linux/errno.h>
49564  #include <linux/videodev.h>
49565  #include <linux/usb.h>
49566 @@ -515,124 +510,57 @@
49567  
49568  /***************** last of pencam  routines  *******************/
49569  
49570 -/********************************************************************
49571 - * /proc interface
49572 - *******************************************************************/
49573 -
49574 -#warning please convert me from procfs to sysfs
49575 -#undef CONFIG_VIDEO_PROC_FS
49576 -
49577 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49578 -
49579 -static struct proc_dir_entry *stv680_proc_entry = NULL;
49580 -extern struct proc_dir_entry *video_proc_entry;
49581 -
49582 -#define YES_NO(x) ((x) ? "yes" : "no")
49583 -#define ON_OFF(x) ((x) ? "(auto) on" : "(auto) off")
49584 -
49585 -static int stv680_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data)
49586 -{
49587 -       char *out = page;
49588 -       int len;
49589 -       struct usb_stv *stv680 = data;
49590 -
49591 -       /* Stay under PAGE_SIZE or else bla bla bla.... */
49592 -
49593 -       out += sprintf (out, "driver_version  : %s\n", DRIVER_VERSION);
49594 -       out += sprintf (out, "model           : %s\n", stv680->camera_name);
49595 -       out += sprintf (out, "in use          : %s\n", YES_NO (stv680->user));
49596 -       out += sprintf (out, "streaming       : %s\n", YES_NO (stv680->streaming));
49597 -       out += sprintf (out, "num_frames      : %d\n", STV680_NUMFRAMES);
49598 -
49599 -       out += sprintf (out, "Current size    : %ix%i\n", stv680->vwidth, stv680->vheight);
49600 -       if (swapRGB_on == 0)
49601 -               out += sprintf (out, "swapRGB         : %s\n", ON_OFF (swapRGB));
49602 -       else if (swapRGB_on == 1)
49603 -               out += sprintf (out, "swapRGB         : (forced) on\n");
49604 -       else if (swapRGB_on == -1)
49605 -               out += sprintf (out, "swapRGB         : (forced) off\n");
49606 -
49607 -       out += sprintf (out, "Palette         : %i", stv680->palette);
49608 -
49609 -       out += sprintf (out, "\n");
49610 -
49611 -       out += sprintf (out, "Frames total    : %d\n", stv680->readcount);
49612 -       out += sprintf (out, "Frames read     : %d\n", stv680->framecount);
49613 -       out += sprintf (out, "Packets dropped : %d\n", stv680->dropped);
49614 -       out += sprintf (out, "Decoding Errors : %d\n", stv680->error);
49615 -
49616 -       len = out - page;
49617 -       len -= off;
49618 -       if (len < count) {
49619 -               *eof = 1;
49620 -               if (len <= 0)
49621 -                       return 0;
49622 -       } else
49623 -               len = count;
49624 -
49625 -       *start = page + off;
49626 -       return len;
49627 -}
49628 -
49629 -static int create_proc_stv680_cam (struct usb_stv *stv680)
49630 -{
49631 -       char name[9];
49632 -       struct proc_dir_entry *ent;
49633 -
49634 -       if (!stv680_proc_entry || !stv680)
49635 -               return -1;
49636 -
49637 -       sprintf (name, "video%d", stv680->vdev.minor);
49638 -
49639 -       ent = create_proc_entry (name, S_IFREG | S_IRUGO | S_IWUSR, stv680_proc_entry);
49640 -       if (!ent)
49641 -               return -1;
49642 -
49643 -       ent->data = stv680;
49644 -       ent->read_proc = stv680_read_proc;
49645 -       stv680->proc_entry = ent;
49646 -       return 0;
49647 +/****************************************************************************
49648 + *  sysfs
49649 + ***************************************************************************/
49650 +static inline struct usb_stv *cd_to_stv(struct class_device *cd)
49651 +{
49652 +       struct video_device *vdev = to_video_device(cd);
49653 +       return video_get_drvdata(vdev);
49654 +}
49655 +
49656 +#define stv680_file(name, variable, field)                             \
49657 +static ssize_t show_##name(struct class_device *class_dev, char *buf)  \
49658 +{                                                                      \
49659 +       struct video_device *vdev = to_video_device(class_dev);         \
49660 +       struct usb_stv *stv = video_get_drvdata(vdev);                  \
49661 +       return sprintf(buf, field, stv->variable);                      \
49662 +}                                                                      \
49663 +static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
49664 +
49665 +stv680_file(model, camera_name, "%s\n");
49666 +stv680_file(in_use, user, "%d\n");
49667 +stv680_file(streaming, streaming, "%d\n");
49668 +stv680_file(palette, palette, "%i\n");
49669 +stv680_file(frames_total, readcount, "%d\n");
49670 +stv680_file(frames_read, framecount, "%d\n");
49671 +stv680_file(packets_dropped, dropped, "%d\n");
49672 +stv680_file(decoding_errors, error, "%d\n");
49673 +
49674 +static void stv680_create_sysfs_files(struct video_device *vdev)
49675 +{
49676 +       video_device_create_file(vdev, &class_device_attr_model);
49677 +       video_device_create_file(vdev, &class_device_attr_in_use);
49678 +       video_device_create_file(vdev, &class_device_attr_streaming);
49679 +       video_device_create_file(vdev, &class_device_attr_palette);
49680 +       video_device_create_file(vdev, &class_device_attr_frames_total);
49681 +       video_device_create_file(vdev, &class_device_attr_frames_read);
49682 +       video_device_create_file(vdev, &class_device_attr_packets_dropped);
49683 +       video_device_create_file(vdev, &class_device_attr_decoding_errors);
49684 +}
49685 +
49686 +static void stv680_remove_sysfs_files(struct video_device *vdev)
49687 +{
49688 +       video_device_remove_file(vdev, &class_device_attr_model);
49689 +       video_device_remove_file(vdev, &class_device_attr_in_use);
49690 +       video_device_remove_file(vdev, &class_device_attr_streaming);
49691 +       video_device_remove_file(vdev, &class_device_attr_palette);
49692 +       video_device_remove_file(vdev, &class_device_attr_frames_total);
49693 +       video_device_remove_file(vdev, &class_device_attr_frames_read);
49694 +       video_device_remove_file(vdev, &class_device_attr_packets_dropped);
49695 +       video_device_remove_file(vdev, &class_device_attr_decoding_errors);
49696  }
49697  
49698 -static void destroy_proc_stv680_cam (struct usb_stv *stv680)
49699 -{
49700 -       /* One to much, just to be sure :) */
49701 -       char name[9];
49702 -
49703 -       if (!stv680 || !stv680->proc_entry)
49704 -               return;
49705 -
49706 -       sprintf (name, "video%d", stv680->vdev.minor);
49707 -       remove_proc_entry (name, stv680_proc_entry);
49708 -       stv680->proc_entry = NULL;
49709 -}
49710 -
49711 -static int proc_stv680_create (void)
49712 -{
49713 -       if (video_proc_entry == NULL) {
49714 -               PDEBUG (0, "STV(e): /proc/video/ doesn't exist!");
49715 -               return -1;
49716 -       }
49717 -       stv680_proc_entry = create_proc_entry ("stv680", S_IFDIR, video_proc_entry);
49718 -
49719 -       if (stv680_proc_entry) {
49720 -               stv680_proc_entry->owner = THIS_MODULE;
49721 -       } else {
49722 -               PDEBUG (0, "STV(e): Unable to initialize /proc/video/stv680");
49723 -               return -1;
49724 -       }
49725 -       return 0;
49726 -}
49727 -
49728 -static void proc_stv680_destroy (void)
49729 -{
49730 -       if (stv680_proc_entry == NULL)
49731 -               return;
49732 -
49733 -       remove_proc_entry ("stv680", video_proc_entry);
49734 -}
49735 -#endif                         /* CONFIG_PROC_FS && CONFIG_VIDEO_PROC_FS */
49736 -
49737  /********************************************************************
49738   * Camera control
49739   *******************************************************************/
49740 @@ -1123,7 +1051,7 @@
49741  static int stv_open (struct inode *inode, struct file *file)
49742  {
49743         struct video_device *dev = video_devdata(file);
49744 -       struct usb_stv *stv680 = (struct usb_stv *) dev;
49745 +       struct usb_stv *stv680 = video_get_drvdata(dev);
49746         int err = 0;
49747  
49748         /* we are called with the BKL held */
49749 @@ -1147,7 +1075,7 @@
49750  static int stv_close (struct inode *inode, struct file *file)
49751  {
49752         struct video_device *dev = file->private_data;
49753 -       struct usb_stv *stv680 = (struct usb_stv *) dev;
49754 +       struct usb_stv *stv680 = video_get_drvdata(dev);
49755         int i;
49756  
49757         for (i = 0; i < STV680_NUMFRAMES; i++)
49758 @@ -1174,7 +1102,7 @@
49759                             unsigned int cmd, void *arg)
49760  {
49761         struct video_device *vdev = file->private_data;
49762 -       struct usb_stv *stv680 = (struct usb_stv *) vdev;
49763 +       struct usb_stv *stv680 = video_get_drvdata(vdev);
49764  
49765         if (!stv680->udev)
49766                 return -EIO;
49767 @@ -1350,7 +1278,7 @@
49768  static int stv680_mmap (struct file *file, struct vm_area_struct *vma)
49769  {
49770         struct video_device *dev = file->private_data;
49771 -       struct usb_stv *stv680 = (struct usb_stv *) dev;
49772 +       struct usb_stv *stv680 = video_get_drvdata(dev);
49773         unsigned long start = vma->vm_start;
49774         unsigned long size  = vma->vm_end-vma->vm_start;
49775         unsigned long page, pos;
49776 @@ -1385,13 +1313,13 @@
49777         return 0;
49778  }
49779  
49780 -static int stv680_read (struct file *file, char *buf,
49781 +static ssize_t stv680_read (struct file *file, char *buf,
49782                         size_t count, loff_t *ppos)
49783  {
49784         struct video_device *dev = file->private_data;
49785         unsigned long int realcount = count;
49786         int ret = 0;
49787 -       struct usb_stv *stv680 = (struct usb_stv *) dev;
49788 +       struct usb_stv *stv680 = video_get_drvdata(dev);
49789         unsigned long int i;
49790  
49791         if (STV680_NUMFRAMES != 2) {
49792 @@ -1448,14 +1376,17 @@
49793         .type =         VID_TYPE_CAPTURE,
49794         .hardware =     VID_HARDWARE_SE401,
49795         .fops =         &stv680_fops,
49796 +       .release =      video_device_release,
49797 +       .minor =        -1,
49798  };
49799  
49800  static int stv680_probe (struct usb_interface *intf, const struct usb_device_id *id)
49801  {
49802         struct usb_device *dev = interface_to_usbdev(intf);
49803         struct usb_host_interface *interface;
49804 -       struct usb_stv *stv680;
49805 +       struct usb_stv *stv680 = NULL;
49806         char *camera_name = NULL;
49807 +       int retval = 0;
49808  
49809         /* We don't handle multi-config cameras */
49810         if (dev->descriptor.bNumConfigurations != 1) {
49811 @@ -1471,12 +1402,14 @@
49812         } else {
49813                 PDEBUG (0, "STV(e): Vendor/Product ID do not match STV0680 values.");
49814                 PDEBUG (0, "STV(e): Check that the STV0680 camera is connected to the computer.");
49815 -               return -ENODEV;
49816 +               retval = -ENODEV;
49817 +               goto error;
49818         }
49819         /* We found one */
49820         if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
49821                 PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct.");
49822 -               return -ENOMEM;
49823 +               retval = -ENOMEM;
49824 +               goto error;
49825         }
49826  
49827         memset (stv680, 0, sizeof (*stv680));
49828 @@ -1484,24 +1417,34 @@
49829         stv680->udev = dev;
49830         stv680->camera_name = camera_name;
49831  
49832 -       memcpy (&stv680->vdev, &stv680_template, sizeof (stv680_template));
49833 -       memcpy (stv680->vdev.name, stv680->camera_name, strlen (stv680->camera_name));
49834 +       stv680->vdev = video_device_alloc();
49835 +       if (!stv680->vdev) {
49836 +               retval = -ENOMEM;
49837 +               goto error;
49838 +       }
49839 +       memcpy(stv680->vdev, &stv680_template, sizeof(stv680_template));
49840 +       stv680->vdev->dev = &intf->dev;
49841 +       video_set_drvdata(stv680->vdev, stv680);
49842 +
49843 +       memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name));
49844         init_waitqueue_head (&stv680->wq);
49845         init_MUTEX (&stv680->lock);
49846         wmb ();
49847  
49848 -       if (video_register_device (&stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
49849 -               kfree (stv680);
49850 +       if (video_register_device (stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
49851                 PDEBUG (0, "STV(e): video_register_device failed");
49852 -               return -EIO;
49853 +               retval = -EIO;
49854 +               goto error;
49855         }
49856 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49857 -       create_proc_stv680_cam (stv680);
49858 -#endif
49859 -       PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev.minor);
49860 +       PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev->minor);
49861  
49862         usb_set_intfdata (intf, stv680);
49863 +       stv680_create_sysfs_files(stv680->vdev);
49864         return 0;
49865 +
49866 +error:
49867 +       kfree(stv680);
49868 +       return retval;
49869  }
49870  
49871  static inline void usb_stv680_remove_disconnected (struct usb_stv *stv680)
49872 @@ -1528,9 +1471,6 @@
49873                 }
49874         PDEBUG (0, "STV(i): %s disconnected", stv680->camera_name);
49875  
49876 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49877 -       destroy_proc_stv680_cam (stv680);
49878 -#endif
49879         /* Free the memory */
49880         kfree (stv680);
49881  }
49882 @@ -1543,7 +1483,11 @@
49883  
49884         if (stv680) {
49885                 /* We don't want people trying to open up the device */
49886 -               video_unregister_device (&stv680->vdev);
49887 +               if (stv680->vdev) {
49888 +                       stv680_remove_sysfs_files(stv680->vdev);
49889 +                       video_unregister_device(stv680->vdev);
49890 +                       stv680->vdev = NULL;
49891 +               }
49892                 if (!stv680->user) {
49893                         usb_stv680_remove_disconnected (stv680);
49894                 } else {
49895 @@ -1566,10 +1510,6 @@
49896  
49897  static int __init usb_stv680_init (void)
49898  {
49899 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49900 -       if (proc_stv680_create () < 0)
49901 -               return -1;
49902 -#endif
49903         if (usb_register (&stv680_driver) < 0) {
49904                 PDEBUG (0, "STV(e): Could not setup STV0680 driver");
49905                 return -1;
49906 @@ -1584,10 +1524,6 @@
49907  {
49908         usb_deregister (&stv680_driver);
49909         PDEBUG (0, "STV(i): driver deregistered");
49910 -
49911 -#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
49912 -       proc_stv680_destroy ();
49913 -#endif
49914  }
49915  
49916  module_init (usb_stv680_init);
49917 diff -Nru a/drivers/usb/media/stv680.h b/drivers/usb/media/stv680.h
49918 --- a/drivers/usb/media/stv680.h        Wed Dec 18 09:12:15 2002
49919 +++ b/drivers/usb/media/stv680.h        Fri Aug 22 08:40:08 2003
49920 @@ -89,7 +89,7 @@
49921  
49922  /* this is almost the video structure uvd_t, with extra parameters for stv */
49923  struct usb_stv {
49924 -       struct video_device vdev;
49925 +       struct video_device *vdev;
49926  
49927         struct usb_device *udev;
49928  
49929 @@ -142,7 +142,6 @@
49930  
49931         wait_queue_head_t wq;   /* Processes waiting */
49932  
49933 -       struct proc_dir_entry *proc_entry;      /* /proc/stv680/videoX */
49934         int nullpackets;
49935  };
49936  
49937 diff -Nru a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c
49938 --- a/drivers/usb/media/usbvideo.c      Thu Aug 21 09:00:15 2003
49939 +++ b/drivers/usb/media/usbvideo.c      Wed Aug 27 05:32:59 2003
49940 @@ -37,24 +37,9 @@
49941  static int video_nr = -1;
49942  MODULE_PARM(video_nr, "i");
49943  
49944 -#warning please convert me from procfs to sysfs
49945 -#define USES_PROC_FS 0
49946  /*
49947   * Local prototypes.
49948   */
49949 -#if USES_PROC_FS
49950 -static void usbvideo_procfs_level1_create(struct usbvideo *ut);
49951 -static void usbvideo_procfs_level1_destroy(struct usbvideo *ut);
49952 -static void usbvideo_procfs_level2_create(struct uvd *uvd);
49953 -static void usbvideo_procfs_level2_destroy(struct uvd *uvd);
49954 -static int usbvideo_default_procfs_read_proc(
49955 -       char *page, char **start, off_t off, int count,
49956 -       int *eof, void *data);
49957 -static int usbvideo_default_procfs_write_proc(
49958 -       struct file *file, const char *buffer, 
49959 -       unsigned long count, void *data);
49960 -#endif
49961 -
49962  static void usbvideo_Disconnect(struct usb_interface *intf);
49963  static void usbvideo_CameraRelease(struct uvd *uvd);
49964  
49965 @@ -813,24 +798,7 @@
49966                 cams->cb.startDataPump = usbvideo_StartDataPump;
49967         if (cams->cb.stopDataPump == NULL)
49968                 cams->cb.stopDataPump = usbvideo_StopDataPump;
49969 -#if USES_PROC_FS
49970 -       /*
49971 -        * If both /proc fs callbacks are NULL then we assume that the driver
49972 -        * does not need procfs services at all. Leave them NULL.
49973 -        */
49974 -       cams->uses_procfs = (cams->cb.procfs_read != NULL) || (cams->cb.procfs_write == NULL);
49975 -       if (cams->uses_procfs) {
49976 -               if (cams->cb.procfs_read == NULL)
49977 -                       cams->cb.procfs_read = usbvideo_default_procfs_read_proc;
49978 -               if (cams->cb.procfs_write == NULL)
49979 -                       cams->cb.procfs_write = usbvideo_default_procfs_write_proc;
49980 -       }
49981 -#else /* !USES_PROC_FS */
49982 -       /* Report a warning so that user knows why there is no /proc entries */
49983 -       if ((cams->cb.procfs_read != NULL) || (cams->cb.procfs_write == NULL)) {
49984 -               dbg("%s: /proc fs support requested but not configured!", __FUNCTION__);
49985 -       }
49986 -#endif
49987 +
49988         cams->num_cameras = num_cams;
49989         cams->cam = (struct uvd *) &cams[1];
49990         cams->md_module = md;
49991 @@ -871,13 +839,6 @@
49992         cams->usbdrv.disconnect = cams->cb.disconnect;
49993         cams->usbdrv.id_table = id_table;
49994  
49995 -#if USES_PROC_FS
49996 -       if (cams->uses_procfs) {
49997 -               dbg("%s: Creating /proc filesystem entries.", __FUNCTION__);
49998 -               usbvideo_procfs_level1_create(cams);
49999 -       }
50000 -#endif
50001 -
50002         /*
50003          * Update global handle to usbvideo. This is very important
50004          * because probe() can be called before usb_register() returns.
50005 @@ -920,13 +881,6 @@
50006                 return;
50007         }
50008  
50009 -#if USES_PROC_FS
50010 -       if (cams->uses_procfs) {
50011 -               dbg("%s: Deregistering filesystem entries.", __FUNCTION__);
50012 -               usbvideo_procfs_level1_destroy(cams);
50013 -       }
50014 -#endif
50015 -
50016         dbg("%s: Deregistering %s driver.", __FUNCTION__, cams->drvName);
50017         usb_deregister(&cams->usbdrv);
50018  
50019 @@ -1041,14 +995,6 @@
50020                 return;
50021         }
50022  
50023 -#if USES_PROC_FS
50024 -       assert(uvd->handle != NULL);
50025 -       if (uvd->handle->uses_procfs) {
50026 -               dbg("%s: Removing /proc/%s/ filesystem entries.", __FUNCTION__, uvd->handle->drvName);
50027 -               usbvideo_procfs_level2_destroy(uvd);
50028 -       }
50029 -#endif
50030 -
50031         RingQueue_Free(&uvd->dp);
50032         if (VALID_CALLBACK(uvd, userFree))
50033                 GET_CALLBACK(uvd, userFree)(uvd);
50034 @@ -1200,17 +1146,6 @@
50035              (uvd->handle != NULL) ? uvd->handle->drvName : "???",
50036              uvd->vdev.minor, tmp2, tmp1);
50037  
50038 -#if USES_PROC_FS
50039 -       assert(uvd->handle != NULL);
50040 -       if (uvd->handle->uses_procfs) {
50041 -               if (uvd->debug > 0) {
50042 -                       info("%s: Creating /proc/video/%s/ filesystem entries.",
50043 -                            __FUNCTION__, uvd->handle->drvName);
50044 -               }
50045 -               usbvideo_procfs_level2_create(uvd);
50046 -       }
50047 -#endif
50048 -
50049         usb_get_dev(uvd->dev);
50050         return 0;
50051  }
50052 @@ -1665,7 +1600,7 @@
50053                 return -EFAULT;
50054  
50055         if (uvd->debug >= 1)
50056 -               info("%s: %d. bytes, noblock=%d.", __FUNCTION__, count, noblock);
50057 +               info("%s: %Zd. bytes, noblock=%d.", __FUNCTION__, count, noblock);
50058  
50059         down(&uvd->lock);       
50060  
50061 @@ -1783,7 +1718,7 @@
50062         /* Update last read position */
50063         frame->seqRead_Index += count;
50064         if (uvd->debug >= 1) {
50065 -               err("%s: {copy} count used=%d, new seqRead_Index=%ld",
50066 +               err("%s: {copy} count used=%Zd, new seqRead_Index=%ld",
50067                         __FUNCTION__, count, frame->seqRead_Index);
50068         }
50069  
50070 @@ -2345,130 +2280,4 @@
50071         }
50072  }
50073  
50074 -/*
50075 - * /proc interface
50076 - *
50077 - * We will be creating directories and entries under /proc/video using
50078 - * external 'video_proc_entry' directory which is exported by videodev.o
50079 - * module. Within that directory we will create $driver/ directory to
50080 - * uniquely and uniformly refer to our specific $driver. Within that
50081 - * directory we will finally create an entry that is named after the
50082 - * video device node - video3, for example. The format of that file
50083 - * is determined by callbacks that the minidriver may provide. If no
50084 - * callbacks are provided (neither read nor write) then we don't create
50085 - * the entry.
50086 - *
50087 - * Here is a sample directory entry: /proc/video/ibmcam/video3
50088 - *
50089 - * The "file" video3 (in example above) is readable and writeable, in
50090 - * theory. If the minidriver provides callbacks to do reading and
50091 - * writing then both those procedures are supported. However if the
50092 - * driver leaves callbacks in default (NULL) state the default
50093 - * read and write handlers are used. The default read handler reports
50094 - * that the driver does not support /proc fs. The default write handler
50095 - * returns error code on any write attempt.
50096 - */
50097 -
50098 -#if USES_PROC_FS
50099 -
50100 -extern struct proc_dir_entry *video_proc_entry;
50101 -
50102 -static void usbvideo_procfs_level1_create(struct usbvideo *ut)
50103 -{
50104 -       if (ut == NULL) {
50105 -               err("%s: ut == NULL", __FUNCTION__);
50106 -               return;
50107 -       }
50108 -       if (video_proc_entry == NULL) {
50109 -               err("%s: /proc/video/ doesn't exist.", __FUNCTION__);
50110 -               return;
50111 -       }
50112 -       ut->procfs_dEntry = create_proc_entry(ut->drvName, S_IFDIR, video_proc_entry);
50113 -       if (ut->procfs_dEntry != NULL) {
50114 -               if (ut->md_module != NULL)
50115 -                       ut->procfs_dEntry->owner = ut->md_module;
50116 -       } else {
50117 -               err("%s: Unable to initialize /proc/video/%s", __FUNCTION__, ut->drvName);
50118 -       }
50119 -}
50120 -
50121 -static void usbvideo_procfs_level1_destroy(struct usbvideo *ut)
50122 -{
50123 -       if (ut == NULL) {
50124 -               err("%s: ut == NULL", __FUNCTION__);
50125 -               return;
50126 -       }
50127 -       if (ut->procfs_dEntry != NULL) {
50128 -               remove_proc_entry(ut->drvName, video_proc_entry);
50129 -               ut->procfs_dEntry = NULL;
50130 -       }
50131 -}
50132 -
50133 -static void usbvideo_procfs_level2_create(struct uvd *uvd)
50134 -{
50135 -       if (uvd == NULL) {
50136 -               err("%s: uvd == NULL", __FUNCTION__);
50137 -               return;
50138 -       }
50139 -       assert(uvd->handle != NULL);
50140 -       if (uvd->handle->procfs_dEntry == NULL) {
50141 -               err("%s: uvd->handle->procfs_dEntry == NULL", __FUNCTION__);
50142 -               return;
50143 -       }
50144 -
50145 -       sprintf(uvd->videoName, "video%d", uvd->vdev.minor);
50146 -       uvd->procfs_vEntry = create_proc_entry(
50147 -               uvd->videoName,
50148 -               S_IFREG | S_IRUGO | S_IWUSR,
50149 -               uvd->handle->procfs_dEntry);
50150 -       if (uvd->procfs_vEntry != NULL) {
50151 -               uvd->procfs_vEntry->data = uvd;
50152 -               uvd->procfs_vEntry->read_proc = uvd->handle->cb.procfs_read;
50153 -               uvd->procfs_vEntry->write_proc = uvd->handle->cb.procfs_write;
50154 -       } else {
50155 -               err("%s: Failed to create entry \"%s\"", __FUNCTION__, uvd->videoName);
50156 -       }
50157 -}
50158 -
50159 -static void usbvideo_procfs_level2_destroy(struct uvd *uvd)
50160 -{
50161 -       if (uvd == NULL) {
50162 -               err("%s: uvd == NULL", __FUNCTION__);
50163 -               return;
50164 -       }
50165 -       if (uvd->procfs_vEntry != NULL) {
50166 -               remove_proc_entry(uvd->videoName, uvd->procfs_vEntry);
50167 -               uvd->procfs_vEntry = NULL;
50168 -       }
50169 -}
50170 -
50171 -static int usbvideo_default_procfs_read_proc(
50172 -       char *page, char **start, off_t off, int count,
50173 -       int *eof, void *data)
50174 -{
50175 -       char *out = page;
50176 -       int len;
50177 -       
50178 -       /* Stay under PAGE_SIZE or else */
50179 -       out += sprintf(out, "This driver does not support /proc services.\n");
50180 -       len = out - page;
50181 -       len -= off;
50182 -       if (len < count) {
50183 -               *eof = 1;
50184 -               if (len <= 0)
50185 -                       return 0;
50186 -       } else
50187 -               len = count;
50188 -       *start = page + off;
50189 -       return len;     
50190 -}
50191 -
50192 -static int usbvideo_default_procfs_write_proc(
50193 -       struct file *file, const char *buffer, 
50194 -       unsigned long count, void *data)
50195 -{
50196 -       return -EINVAL;
50197 -}
50198 -
50199 -#endif /* USES_PROC_FS */
50200  MODULE_LICENSE("GPL");
50201 diff -Nru a/drivers/usb/media/usbvideo.h b/drivers/usb/media/usbvideo.h
50202 --- a/drivers/usb/media/usbvideo.h      Thu Oct 24 13:11:38 2002
50203 +++ b/drivers/usb/media/usbvideo.h      Wed Aug 27 10:14:38 2003
50204 @@ -17,14 +17,12 @@
50205  #define        usbvideo_h
50206  
50207  #include <linux/config.h>
50208 -#include <linux/proc_fs.h>
50209  #include <linux/videodev.h>
50210  #include <linux/usb.h>
50211  
50212  /* Most helpful debugging aid */
50213  #define assert(expr) ((void) ((expr) ? 0 : (err("assert failed at line %d",__LINE__))))
50214  
50215 -#define USES_PROC_FS   (defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS))
50216  #define USBVIDEO_REPORT_STATS  1       /* Set to 0 to block statistics on close */
50217  
50218  /* Bit flags (options) */
50219 @@ -244,7 +242,6 @@
50220         struct video_capability vcap;           /* Video capabilities */
50221         struct video_channel vchan;     /* May be used for tuner support */
50222         struct usbvideo_statistics stats;
50223 -       struct proc_dir_entry *procfs_vEntry;   /* /proc/video/MYDRIVER/video2 */
50224         char videoName[32];             /* Holds name like "video7" */
50225  };
50226  
50227 @@ -266,8 +263,6 @@
50228         int (*getFPS)(struct uvd *);
50229         int (*overlayHook)(struct uvd *, struct usbvideo_frame *);
50230         int (*getFrame)(struct uvd *, int);
50231 -       int (*procfs_read)(char *page,char **start,off_t off,int count,int *eof,void *data);
50232 -       int (*procfs_write)(struct file *file,const char *buffer,unsigned long count,void *data);
50233         int (*startDataPump)(struct uvd *uvd);
50234         void (*stopDataPump)(struct uvd *uvd);
50235         int (*setVideoMode)(struct uvd *uvd, struct video_window *vw);
50236 @@ -281,8 +276,6 @@
50237         struct usbvideo_cb cb;          /* Table of callbacks (virtual methods) */
50238         struct video_device vdt;        /* Video device template */
50239         struct uvd *cam;                        /* Array of camera structures */
50240 -       int uses_procfs;                /* Non-zero if we create /proc entries */
50241 -       struct proc_dir_entry *procfs_dEntry;   /* /proc/video/MYDRIVER */
50242         struct module *md_module;       /* Minidriver module */
50243  };
50244  
50245 diff -Nru a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c
50246 --- a/drivers/usb/media/vicam.c Thu Jun  5 15:57:38 2003
50247 +++ b/drivers/usb/media/vicam.c Sat Aug 23 07:15:33 2003
50248 @@ -1388,11 +1388,13 @@
50249  static int __init
50250  usb_vicam_init(void)
50251  {
50252 +       int retval;
50253         DBG(KERN_INFO "ViCam-based WebCam driver startup\n");
50254         vicam_create_proc_root();
50255 -       if (usb_register(&vicam_driver) != 0)
50256 +       retval = usb_register(&vicam_driver);
50257 +       if (retval)
50258                 printk(KERN_WARNING "usb_register failed!\n");
50259 -       return 0;
50260 +       return retval;
50261  }
50262  
50263  static void __exit
50264 diff -Nru a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
50265 --- a/drivers/usb/misc/auerswald.c      Wed Jul 30 06:14:48 2003
50266 +++ b/drivers/usb/misc/auerswald.c      Tue Aug 26 09:25:41 2003
50267 @@ -1380,7 +1380,7 @@
50268  /* Open a new character device */
50269  static int auerchar_open (struct inode *inode, struct file *file)
50270  {
50271 -       int dtindex = minor(inode->i_rdev);
50272 +       int dtindex = iminor(inode);
50273         pauerswald_t cp = NULL;
50274         pauerchar_t ccp = NULL;
50275         struct usb_interface *intf;
50276 diff -Nru a/drivers/usb/misc/brlvger.c b/drivers/usb/misc/brlvger.c
50277 --- a/drivers/usb/misc/brlvger.c        Tue Jul 29 04:28:54 2003
50278 +++ b/drivers/usb/misc/brlvger.c        Tue Sep  2 11:40:28 2003
50279 @@ -249,17 +249,20 @@
50280  static int
50281  __init brlvger_init (void)
50282  {
50283 +       int retval;
50284         printk(BANNER);
50285  
50286         if(stall_tries < 1 || write_repeats < 1)
50287           return -EINVAL;
50288  
50289 -       if (usb_register(&brlvger_driver)) {
50290 +       retval = usb_register(&brlvger_driver);
50291 +       if (retval) {
50292                 err("USB registration failed");
50293 -               return -ENOSYS;
50294 +               goto out;
50295         }
50296  
50297 -       return 0;
50298 +out:
50299 +       return retval;
50300  }
50301  
50302  static void
50303 @@ -432,7 +435,7 @@
50304  static int
50305  brlvger_open(struct inode *inode, struct file *file)
50306  {
50307 -       int devnum = minor (inode->i_rdev);
50308 +       int devnum = iminor(inode);
50309         struct usb_interface *intf = NULL;
50310         struct brlvger_priv *priv = NULL;
50311         int n, ret;
50312 diff -Nru a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
50313 --- a/drivers/usb/misc/rio500.c Tue Jun 17 08:12:48 2003
50314 +++ b/drivers/usb/misc/rio500.c Sat Aug 23 07:28:41 2003
50315 @@ -33,7 +33,6 @@
50316  #include <linux/signal.h>
50317  #include <linux/sched.h>
50318  #include <linux/errno.h>
50319 -#include <linux/miscdevice.h>
50320  #include <linux/random.h>
50321  #include <linux/poll.h>
50322  #include <linux/init.h>
50323 @@ -531,12 +530,15 @@
50324  
50325  static int __init usb_rio_init(void)
50326  {
50327 -       if (usb_register(&rio_driver) < 0)
50328 -               return -1;
50329 +       int retval;
50330 +       retval = usb_register(&rio_driver);
50331 +       if (retval)
50332 +               goto out;
50333  
50334         info(DRIVER_VERSION ":" DRIVER_DESC);
50335  
50336 -       return 0;
50337 +out:
50338 +       return retval;
50339  }
50340  
50341  
50342 diff -Nru a/drivers/usb/misc/tiglusb.c b/drivers/usb/misc/tiglusb.c
50343 --- a/drivers/usb/misc/tiglusb.c        Mon Aug 11 07:56:25 2003
50344 +++ b/drivers/usb/misc/tiglusb.c        Tue Sep  2 11:40:28 2003
50345 @@ -24,7 +24,6 @@
50346  
50347  #include <linux/module.h>
50348  #include <linux/socket.h>
50349 -#include <linux/miscdevice.h>
50350  #include <linux/slab.h>
50351  #include <linux/init.h>
50352  #include <asm/uaccess.h>
50353 @@ -93,7 +92,7 @@
50354  static int
50355  tiglusb_open (struct inode *inode, struct file *filp)
50356  {
50357 -       int devnum = minor (inode->i_rdev);
50358 +       int devnum = iminor(inode);
50359         ptiglusb_t s;
50360  
50361         if (devnum < TIUSB_MINOR || devnum >= (TIUSB_MINOR + MAXTIGL))
50362 diff -Nru a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
50363 --- a/drivers/usb/misc/usblcd.c Wed Jul 16 06:00:04 2003
50364 +++ b/drivers/usb/misc/usblcd.c Sat Aug 23 07:24:57 2003
50365 @@ -342,18 +342,21 @@
50366         .id_table =     id_table,
50367  };
50368  
50369 -int usb_lcd_init(void)
50370 +static int __init usb_lcd_init(void)
50371  {
50372 -       if (usb_register(&lcd_driver) < 0)
50373 -               return -1;
50374 +       int retval;
50375 +       retval = usb_register(&lcd_driver);
50376 +       if (retval)
50377 +               goto out;
50378  
50379         info("%s (C) Adams IT Services http://www.usblcd.de", DRIVER_VERSION);
50380         info("USBLCD support registered.");
50381 -       return 0;
50382 +out:
50383 +       return retval;
50384  }
50385  
50386  
50387 -void usb_lcd_cleanup(void)
50388 +static void __exit usb_lcd_cleanup(void)
50389  {
50390         struct lcd_usb_data *lcd = &lcd_instance;
50391  
50392 diff -Nru a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
50393 --- a/drivers/usb/misc/usbtest.c        Sat Aug 16 11:46:50 2003
50394 +++ b/drivers/usb/misc/usbtest.c        Thu Aug 21 08:34:01 2003
50395 @@ -435,7 +435,7 @@
50396                 return 0;
50397         }
50398  
50399 -       le32_to_cpus (&config->wTotalLength);
50400 +       le16_to_cpus (&config->wTotalLength);
50401         if (config->wTotalLength == len)                /* read it all */
50402                 return 1;
50403         return config->wTotalLength >= TBUF_SIZE;       /* max partial read */
50404 diff -Nru a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
50405 --- a/drivers/usb/misc/uss720.c Tue May 13 05:34:40 2003
50406 +++ b/drivers/usb/misc/uss720.c Sat Aug 23 07:26:14 2003
50407 @@ -653,11 +653,14 @@
50408  
50409  static int __init uss720_init(void)
50410  {
50411 -       if (usb_register(&uss720_driver) < 0)
50412 -               return -1;
50413 +       int retval;
50414 +       retval = usb_register(&uss720_driver);
50415 +       if (retval)
50416 +               goto out;
50417  
50418         info(DRIVER_VERSION ":" DRIVER_DESC);
50419 -       return 0;
50420 +out:
50421 +       return retval;
50422  }
50423  
50424  static void __exit uss720_cleanup(void)
50425 diff -Nru a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
50426 --- a/drivers/usb/net/Kconfig   Tue Jun 17 07:37:22 2003
50427 +++ b/drivers/usb/net/Kconfig   Sun Aug 24 11:31:24 2003
50428 @@ -7,7 +7,7 @@
50429  comment "Networking support is needed for USB Networking device support"
50430         depends on USB && !NET
50431  
50432 -config USB_AX8817X
50433 +config USB_AX8817X_STANDALONE
50434         tristate "USB ASIX AX8817X Ethernet device support (EXPERIMENTAL)"
50435         depends on USB && NET && EXPERIMENTAL
50436         ---help---
50437 @@ -121,15 +121,15 @@
50438           module, say M here and read <file:Documentation/modules.txt>.
50439  
50440  config USB_USBNET
50441 -       tristate "Host-to-Host Networking for Cables and Smart Devices"
50442 +       tristate "Multi-purpose USB Networking Framework"
50443         depends on USB && NET
50444         ---help---
50445           This driver supports several kinds of network links over USB,
50446           with "minidrivers" built around a common network driver core
50447 -         that supports deep queues for efficient transfers.
50448 -
50449 -         Typically, these links involves only two network hosts.  The
50450 -         host runs "usbnet", and the other end of the link might be:
50451 +         that supports deep queues for efficient transfers.  (This gives
50452 +         better performance with small packets and at high speeds).
50453 +         
50454 +         The USB host runs "usbnet", and the other end of the link might be:
50455  
50456           - Another USB host, when using USB "network" or "data transfer"
50457             cables.  These are often used to network laptops to PCs, like
50458 @@ -141,6 +141,9 @@
50459             others), and devices that interoperate using the standard
50460             CDC-Ethernet specification (including many cable modems).
50461  
50462 +         - Network adapter hardware (like those for 10/100 Ethernet) which
50463 +           uses this driver framework.
50464 +
50465           The link will appear with a name like "usb0", when the link is
50466           a two-node link, or "eth0" for most CDC-Ethernet devices.  Those
50467           two-node links are most easily managed with Ethernet Bridging
50468 @@ -265,4 +268,30 @@
50469           what other networking devices you have in use.  However, if the
50470           IEEE 802 "local assignment" bit is set in the address, a "usbX"
50471           name is used instead.
50472 +
50473 +comment "USB Network Adapters"
50474 +       depends on USB_USBNET
50475 +
50476 +config USB_AX8817X
50477 +       boolean "ASIX AX88172 Based USB 2.0 Ethernet Devices"
50478 +       depends on USB_USBNET && EXPERIMENTAL
50479 +       default y
50480 +       help
50481 +
50482 +         This option adds support for ASIX AX88172 based USB 2.0
50483 +         10/100 Ethernet devices.
50484 +
50485 +         This driver should work with at least the following devices:
50486 +           * ASIX AX88172
50487 +           * D-Link DUB-E100
50488 +           * Hawking UF200
50489 +           * Linksys USB200M
50490 +           * Netgear FA120
50491 +           * Intellinet
50492 +           * ST Lab USB Ethernet
50493 +           * TrendNet TU2-ET100
50494 +
50495 +         This driver creates an interface named "ethX", where X depends on
50496 +         what other networking devices you have in use.  
50497 +
50498  
50499 diff -Nru a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
50500 --- a/drivers/usb/net/Makefile  Mon Jun 16 14:19:37 2003
50501 +++ b/drivers/usb/net/Makefile  Fri Aug 29 01:06:26 2003
50502 @@ -2,7 +2,7 @@
50503  # Makefile for USB Network drivers
50504  #
50505  
50506 -obj-$(CONFIG_USB_AX8817X)      += ax8817x.o
50507 +obj-$(CONFIG_USB_AX8817X_STANDALONE)   += ax8817x.o
50508  obj-$(CONFIG_USB_CATC)         += catc.o
50509  obj-$(CONFIG_USB_KAWETH)       += kaweth.o
50510  obj-$(CONFIG_USB_PEGASUS)      += pegasus.o
50511 diff -Nru a/drivers/usb/net/Makefile.mii b/drivers/usb/net/Makefile.mii
50512 --- a/drivers/usb/net/Makefile.mii      Mon Jun 16 14:19:37 2003
50513 +++ b/drivers/usb/net/Makefile.mii      Sat Aug 23 04:56:14 2003
50514 @@ -4,3 +4,4 @@
50515  
50516  obj-$(CONFIG_USB_AX8817X)      += mii.o
50517  obj-$(CONFIG_USB_PEGASUS)      += mii.o
50518 +obj-$(CONFIG_USB_USBNET)       += mii.o
50519 diff -Nru a/drivers/usb/net/ax8817x.c b/drivers/usb/net/ax8817x.c
50520 --- a/drivers/usb/net/ax8817x.c Thu Aug  7 10:28:47 2003
50521 +++ b/drivers/usb/net/ax8817x.c Thu Aug 21 20:23:38 2003
50522 @@ -75,7 +75,6 @@
50523  #include <linux/mii.h>
50524  #include <linux/crc32.h>
50525  #include <asm/uaccess.h>
50526 -#include <linux/version.h>
50527  
50528  /* Version Information */
50529  #define DRIVER_VERSION "v2.0.2"
50530 diff -Nru a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
50531 --- a/drivers/usb/net/usbnet.c  Wed Aug 13 17:22:50 2003
50532 +++ b/drivers/usb/net/usbnet.c  Thu Aug 28 15:25:45 2003
50533 @@ -1,7 +1,9 @@
50534  /*
50535 - * USB Host-to-Host Links
50536 - * Copyright (C) 2000-2002 by David Brownell <dbrownell@users.sourceforge.net>
50537 + * USB Networking Links
50538 + * Copyright (C) 2000-2003 by David Brownell <dbrownell@users.sourceforge.net>
50539   * Copyright (C) 2002 Pavel Machek <pavel@ucw.cz>
50540 + * Copyright (C) 2003 David Hollis <dhollis@davehollis.com>
50541 + * Copyright (c) 2002-2003 TiVo Inc.
50542   *
50543   * This program is free software; you can redistribute it and/or modify
50544   * it under the terms of the GNU General Public License as published by
50545 @@ -19,63 +21,38 @@
50546   */
50547  
50548  /*
50549 - * This is used for "USB networking", connecting USB hosts as peers.
50550 - *
50551 - * It can be used with USB "network cables", for IP-over-USB communications;
50552 - * Ethernet speeds without the Ethernet.  USB devices (including some PDAs)
50553 - * can support such links directly, replacing device-specific protocols
50554 - * with Internet standard ones.
50555 - *
50556 - * The links can be bridged using the Ethernet bridging (net/bridge)
50557 - * support as appropriate.  Devices currently supported include:
50558 + * This is a generic "USB networking" framework that works with several
50559 + * kinds of full and high speed networking devices:
50560   *
50561 + *   + USB host-to-host "network cables", used for IP-over-USB links.
50562 + *     These are often used for Laplink style connectivity products.
50563   *     - AnchorChip 2720
50564   *     - Belkin, eTEK (interops with Win32 drivers)
50565 - *     - EPSON USB clients
50566   *     - GeneSys GL620USB-A
50567   *     - NetChip 1080 (interoperates with NetChip Win32 drivers)
50568   *     - Prolific PL-2301/2302 (replaces "plusb" driver)
50569 - *     - PXA-250 or SA-1100 Linux PDAs like iPaq, Yopy, and Zaurus
50570 + *
50571 + *   + Smart USB devices can support such links directly, using Internet
50572 + *     standard protocols instead of proprietary host-to-device links.
50573 + *     - Linux PDAs like iPaq, Yopy, and Zaurus
50574 + *     - The BLOB boot loader (for diskless booting)
50575 + *     - Linux "gadgets", perhaps using PXA-2xx or Net2280 controllers
50576 + *     - Devices using EPSON's sample USB firmware
50577 + *     - CDC-Ethernet class devices, such as many cable modems
50578 + *
50579 + *   + Adapters to networks such as Ethernet.
50580 + *     - AX8817X based USB 2.0 products
50581 + *
50582 + * Links to these devices can be bridged using Linux Ethernet bridging.
50583 + * With minor exceptions, these all use similar USB framing for network
50584 + * traffic, but need different protocols for control traffic.
50585   *
50586   * USB devices can implement their side of this protocol at the cost
50587   * of two bulk endpoints; it's not restricted to "cable" applications.
50588   * See the SA1110, Zaurus, or EPSON device/client support in this driver;
50589 - * slave/target drivers such as "usb-eth" (on most SA-1100 PDAs) are
50590 - * used inside USB slave/target devices.
50591 - *
50592 - * 
50593 - * Status:
50594 - *
50595 - * - AN2720 ... not widely available, but reportedly works well
50596 - *
50597 - * - Belkin/eTEK ... no known issues
50598 - *
50599 - * - Both GeneSys and PL-230x use interrupt transfers for driver-to-driver
50600 - *   handshaking; it'd be worth implementing those as "carrier detect".
50601 - *   Prefer generic hooks, not minidriver-specific hacks.
50602 - *
50603 - * - For Netchip, should use keventd to poll via control requests to detect
50604 - *   hardware level "carrier detect". 
50605 - *
50606 - * - PL-230x ... the initialization protocol doesn't seem to match chip data
50607 - *   sheets, sometimes it's not needed and sometimes it hangs.  Prolific has
50608 - *   not responded to repeated support/information requests.
50609 - *
50610 - * - SA-1100 PDAs ... the standard ARM Linux SA-1100 support works nicely,
50611 - *   as found in www.handhelds.org and other kernels.  The Sharp/Lineo
50612 - *   kernels use different drivers, which also talk to this code.
50613 - *
50614 - * Interop with more Win32 drivers may be a good thing.
50615 - *
50616 - * Seems like reporting "peer connected" (carrier present) events may end
50617 - * up going through the netlink event system, not hotplug ... so new links
50618 - * would likely be handled with a link monitoring thread in some daemon.
50619 - *
50620 - * There are reports that bridging gives lower-than-usual throughput.
50621 - *
50622 - * Need smarter hotplug policy scripts ... ones that know how to arrange
50623 - * bridging with "brctl", and can handle static and dynamic ("pump") setups.
50624 - * Use those eventual "peer connected" events, and zeroconf.
50625 + * slave/target drivers such as "usb-eth" (on most SA-1100 PDAs) or
50626 + * "g_ether" (in the Linux "gadget" framework) implement that behavior
50627 + * within devices.
50628   *
50629   *
50630   * CHANGELOG:
50631 @@ -126,6 +103,7 @@
50632   *             vs pxa25x, and CDC Ethernet.  Throttle down log floods on
50633   *             disconnect; other cleanups. (db)  Flush net1080 fifos
50634   *             after several sequential framing errors. (Johannes Erdfelt)
50635 + * 22-aug-2003 AX8817X support (Dave Hollis).
50636   *
50637   *-------------------------------------------------------------------------*/
50638  
50639 @@ -139,9 +117,11 @@
50640  #include <linux/random.h>
50641  #include <linux/ethtool.h>
50642  #include <linux/workqueue.h>
50643 +#include <linux/mii.h>
50644  #include <asm/uaccess.h>
50645  #include <asm/unaligned.h>
50646  
50647 +
50648  // #define     DEBUG                   // error path messages, extra info
50649  // #define     VERBOSE                 // more; success messages
50650  #define        REALLY_QUEUE
50651 @@ -157,7 +137,7 @@
50652  #include <linux/dma-mapping.h>
50653  
50654  
50655 -#define DRIVER_VERSION         "25-Apr-2003"
50656 +#define DRIVER_VERSION         "25-Aug-2003"
50657  
50658  /*-------------------------------------------------------------------------*/
50659  
50660 @@ -218,6 +198,8 @@
50661         int                     msg_level;
50662         unsigned long           data [5];
50663  
50664 +       struct mii_if_info      mii;
50665 +
50666         // various kinds of pending driver work
50667         struct sk_buff_head     rxq;
50668         struct sk_buff_head     txq;
50669 @@ -399,6 +381,275 @@
50670  
50671  #endif /* CONFIG_USB_AN2720 */
50672  
50673 +\f
50674 +#ifdef CONFIG_USB_AX8817X
50675 +#define NEED_MII
50676 +/* ASIX AX8817X based USB 2.0 Ethernet Devices */
50677 +
50678 +#define HAVE_HARDWARE
50679 +
50680 +#include <linux/crc32.h>
50681 +
50682 +#define AX_CMD_SET_SW_MII              0x06
50683 +#define AX_CMD_READ_MII_REG            0x07
50684 +#define AX_CMD_WRITE_MII_REG           0x08
50685 +#define AX_CMD_SET_HW_MII              0x0a
50686 +#define AX_CMD_WRITE_RX_CTL            0x10
50687 +#define AX_CMD_READ_IPG012             0x11
50688 +#define AX_CMD_WRITE_IPG0              0x12
50689 +#define AX_CMD_WRITE_IPG1              0x13
50690 +#define AX_CMD_WRITE_IPG2              0x14
50691 +#define AX_CMD_WRITE_MULTI_FILTER      0x16
50692 +#define AX_CMD_READ_NODE_ID            0x17
50693 +#define AX_CMD_READ_PHY_ID             0x19
50694 +#define AX_CMD_WRITE_MEDIUM_MODE       0x1b
50695 +#define AX_CMD_WRITE_GPIOS             0x1f
50696 +
50697 +#define AX_MCAST_FILTER_SIZE           8
50698 +#define AX_MAX_MCAST                   64
50699 +
50700 +static int ax8817x_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
50701 +                           u16 size, void *data)
50702 +{
50703 +       return usb_control_msg(
50704 +               dev->udev,
50705 +               usb_rcvctrlpipe(dev->udev, 0),
50706 +               cmd,
50707 +               USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
50708 +               value,
50709 +               index,
50710 +               data,
50711 +               size,
50712 +               CONTROL_TIMEOUT_JIFFIES);
50713 +}
50714 +
50715 +static int ax8817x_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
50716 +                            u16 size, void *data)
50717 +{
50718 +       return usb_control_msg(
50719 +               dev->udev,
50720 +               usb_sndctrlpipe(dev->udev, 0),
50721 +               cmd,
50722 +               USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
50723 +               value,
50724 +               index,
50725 +               data,
50726 +               size,
50727 +               CONTROL_TIMEOUT_JIFFIES);
50728 +}
50729 +
50730 +static void ax8817x_async_cmd_callback(struct urb *urb, struct pt_regs *regs)
50731 +{
50732 +       struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
50733 +       
50734 +       if (urb->status < 0)
50735 +               printk(KERN_DEBUG "ax8817x_async_cmd_callback() failed with %d",
50736 +                       urb->status);
50737 +       
50738 +       kfree(req);
50739 +       usb_free_urb(urb);
50740 +}
50741 +
50742 +static void ax8817x_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
50743 +                                   u16 size, void *data)
50744 +{
50745 +       struct usb_ctrlrequest *req;
50746 +       int status;
50747 +       struct urb *urb;
50748 +       
50749 +       if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) {
50750 +               devdbg(dev, "Error allocating URB in write_cmd_async!");
50751 +               return;
50752 +       }
50753 +       
50754 +       if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) {
50755 +               deverr(dev, "Failed to allocate memory for control request");
50756 +               usb_free_urb(urb);
50757 +               return;
50758 +       }
50759 +
50760 +       req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
50761 +       req->bRequest = cmd;
50762 +       req->wValue = cpu_to_le16(value);
50763 +       req->wIndex = cpu_to_le16(index); 
50764 +       req->wLength = cpu_to_le16(size);
50765 +
50766 +       usb_fill_control_urb(urb, dev->udev,
50767 +                            usb_sndctrlpipe(dev->udev, 0),
50768 +                            (void *)req, data, size,
50769 +                            ax8817x_async_cmd_callback, req);
50770 +
50771 +       if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0)
50772 +               deverr(dev, "Error submitting the control message: status=%d", status);
50773 +}
50774 +
50775 +static void ax8817x_set_multicast(struct net_device *net)
50776 +{
50777 +       struct usbnet *dev = (struct usbnet *) net->priv;
50778 +       u8 rx_ctl = 0x8c;
50779 +
50780 +       if (net->flags & IFF_PROMISC) {
50781 +               rx_ctl |= 0x01;
50782 +       } else if (net->flags & IFF_ALLMULTI
50783 +                  || net->mc_count > AX_MAX_MCAST) {
50784 +               rx_ctl |= 0x02;
50785 +       } else if (net->mc_count == 0) {
50786 +               /* just broadcast and directed */
50787 +       } else {
50788 +               struct dev_mc_list *mc_list = net->mc_list;
50789 +               u8 *multi_filter;
50790 +               u32 crc_bits;
50791 +               int i;
50792 +
50793 +               multi_filter = kmalloc(AX_MCAST_FILTER_SIZE, GFP_ATOMIC);
50794 +               if (multi_filter == NULL) {
50795 +                       /* Oops, couldn't allocate a buffer for setting the multicast
50796 +                          filter. Try all multi mode. */
50797 +                       rx_ctl |= 0x02;
50798 +               } else {
50799 +                       memset(multi_filter, 0, AX_MCAST_FILTER_SIZE);
50800 +
50801 +                       /* Build the multicast hash filter. */
50802 +                       for (i = 0; i < net->mc_count; i++) {
50803 +                               crc_bits =
50804 +                                   ether_crc(ETH_ALEN,
50805 +                                             mc_list->dmi_addr) >> 26;
50806 +                               multi_filter[crc_bits >> 3] |=
50807 +                                   1 << (crc_bits & 7);
50808 +                               mc_list = mc_list->next;
50809 +                       }
50810 +
50811 +                       ax8817x_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
50812 +                                          AX_MCAST_FILTER_SIZE, multi_filter);
50813 +
50814 +                       rx_ctl |= 0x10;
50815 +               }
50816 +       }
50817 +
50818 +       ax8817x_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
50819 +}
50820 +
50821 +static int ax8817x_mdio_read(struct net_device *netdev, int phy_id, int loc)
50822 +{
50823 +       struct usbnet *dev = netdev->priv;
50824 +       u16 res;
50825 +       u8 buf[4];
50826 +
50827 +       ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf);
50828 +       ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, (u16 *)&res);
50829 +       ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf);
50830 +
50831 +       return res & 0xffff;
50832 +}
50833 +
50834 +static void ax8817x_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
50835 +{
50836 +       struct usbnet *dev = netdev->priv;
50837 +       u16 res = val;
50838 +       u8 buf[4];
50839 +
50840 +       ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf);
50841 +       ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, (u16 *)&res);
50842 +       ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf);
50843 +}
50844 +
50845 +static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
50846 +{
50847 +       int ret;
50848 +       u8 buf[6];
50849 +       u16 *buf16 = (u16 *) buf;
50850 +       int i;
50851 +
50852 +       dev->in = usb_rcvbulkpipe(dev->udev, 3);
50853 +       dev->out = usb_sndbulkpipe(dev->udev, 2);
50854 +
50855 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf)) < 0) {
50856 +               dbg("send AX_CMD_WRITE_RX_CTL failed: %d", ret);
50857 +               return ret;
50858 +       }
50859 +
50860 +       /* Get the MAC address */
50861 +       memset(buf, 0, ETH_ALEN);
50862 +       if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, 6, buf)) < 0) {
50863 +               dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
50864 +               return ret;
50865 +       }
50866 +       memcpy(dev->net->dev_addr, buf, ETH_ALEN);
50867 +
50868 +       /* Get IPG values */
50869 +       if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_IPG012, 0, 0, 3, buf)) < 0) {
50870 +               dbg("Error reading IPG values: %d", ret);
50871 +               return ret;
50872 +       }
50873 +
50874 +       for(i = 0;i < 3;i++) {
50875 +               ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0 + i, 0, 0, 1, &buf[i]);
50876 +       }
50877 +
50878 +       /* Get the PHY id */
50879 +       if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) {
50880 +               dbg("error on read AX_CMD_READ_PHY_ID: %02x", ret);
50881 +               return ret;
50882 +       } else if (ret < 2) {
50883 +               /* this should always return 2 bytes */
50884 +               dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", ret);
50885 +               return -EIO;
50886 +       }
50887 +
50888 +       /* Initialize MII structure */
50889 +       dev->mii.dev = dev->net;
50890 +       dev->mii.mdio_read = ax8817x_mdio_read;
50891 +       dev->mii.mdio_write = ax8817x_mdio_write;
50892 +       dev->mii.phy_id_mask = 0x3f;
50893 +       dev->mii.reg_num_mask = 0x1f;
50894 +       dev->mii.phy_id = buf[1];
50895 +
50896 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf)) < 0) {
50897 +               dbg("Failed to go to software MII mode: %02x", ret);
50898 +               return ret;
50899 +       }
50900 +
50901 +       *buf16 = cpu_to_le16(BMCR_RESET);
50902 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG,
50903 +                                    dev->mii.phy_id, MII_BMCR, 2, buf16)) < 0) {
50904 +               dbg("Failed to write MII reg - MII_BMCR: %02x", ret);
50905 +               return ret;
50906 +       }
50907 +
50908 +       /* Advertise that we can do full-duplex pause */
50909 +       *buf16 = cpu_to_le16(ADVERTISE_ALL | ADVERTISE_CSMA | 0x0400);
50910 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG,
50911 +                                    dev->mii.phy_id, MII_ADVERTISE, 
50912 +                                    2, buf16)) < 0) {
50913 +               dbg("Failed to write MII_REG advertisement: %02x", ret);
50914 +               return ret;
50915 +       }
50916 +
50917 +       *buf16 = cpu_to_le16(BMCR_ANENABLE | BMCR_ANRESTART);
50918 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG,
50919 +                                    dev->mii.phy_id, MII_BMCR, 
50920 +                                    2, buf16)) < 0) {
50921 +               dbg("Failed to write MII reg autonegotiate: %02x", ret);
50922 +               return ret;
50923 +       }
50924 +
50925 +       if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf)) < 0) {
50926 +               dbg("Failed to set hardware MII: %02x", ret);
50927 +               return ret;
50928 +       }
50929 +
50930 +       dev->net->set_multicast_list = ax8817x_set_multicast;
50931 +
50932 +       return 0;
50933 +}
50934 +
50935 +static const struct driver_info ax8817x_info = {
50936 +       .description = "ASIX AX8817x USB 2.0 Ethernet",
50937 +       .bind = ax8817x_bind,
50938 +       .flags =  FLAG_ETHER,
50939 +};
50940 +#endif /* CONFIG_USB_AX8817X */
50941 +
50942  
50943  \f
50944  #ifdef CONFIG_USB_BELKIN
50945 @@ -470,7 +721,7 @@
50946         u8      bNumberPowerFilters;
50947  } __attribute__ ((packed));
50948  
50949 -struct cdc_info {
50950 +struct cdc_state {
50951         struct header_desc      *header;
50952         struct union_desc       *u;
50953         struct ether_desc       *ether;
50954 @@ -513,7 +764,7 @@
50955         u8                              *buf = intf->altsetting->extra;
50956         int                             len = intf->altsetting->extralen;
50957         struct usb_interface_descriptor *d;
50958 -       struct cdc_info                 *info = (void *) &dev->data;
50959 +       struct cdc_state                *info = (void *) &dev->data;
50960         int                             status;
50961  
50962         if (sizeof dev->data < sizeof *info)
50963 @@ -522,12 +773,15 @@
50964         /* expect strict spec conformance for the descriptors, but
50965          * cope with firmware which stores them in the wrong place
50966          */
50967 -       if (len == 0 && dev->udev->config->extralen) {
50968 -               /* Motorola SB4100 (and maybe others) put
50969 -                * CDC descriptors here
50970 +       if (len == 0 && dev->udev->actconfig->extralen) {
50971 +               /* Motorola SB4100 (and others: Brad Hards says it's
50972 +                * from a Broadcom design) put CDC descriptors here
50973                  */
50974 -               buf = dev->udev->config->extra;
50975 -               len = dev->udev->config->extralen;
50976 +               buf = dev->udev->actconfig->extra;
50977 +               len = dev->udev->actconfig->extralen;
50978 +               if (len)
50979 +                       dev_dbg (&intf->dev,
50980 +                               "CDC descriptors on config\n");
50981         }
50982  
50983         memset (info, 0, sizeof *info);
50984 @@ -542,48 +796,92 @@
50985                  */
50986                 switch (buf [2]) {
50987                 case 0x00:              /* Header, mostly useless */
50988 -                       if (info->header)
50989 +                       if (info->header) {
50990 +                               dev_dbg (&intf->dev, "extra CDC header\n");
50991                                 goto bad_desc;
50992 +                       }
50993                         info->header = (void *) buf;
50994 -                       if (info->header->bLength != sizeof *info->header)
50995 +                       if (info->header->bLength != sizeof *info->header) {
50996 +                               dev_dbg (&intf->dev, "CDC header len %u\n",
50997 +                                       info->header->bLength);
50998                                 goto bad_desc;
50999 +                       }
51000                         break;
51001                 case 0x06:              /* Union (groups interfaces) */
51002 -                       if (info->u)
51003 +                       if (info->u) {
51004 +                               dev_dbg (&intf->dev, "extra CDC union\n");
51005                                 goto bad_desc;
51006 +                       }
51007                         info->u = (void *) buf;
51008 -                       if (info->u->bLength != sizeof *info->u)
51009 -                               goto bad_desc;
51010 -                       d = &intf->altsetting->desc;
51011 -                       if (info->u->bMasterInterface0 != d->bInterfaceNumber)
51012 +                       if (info->u->bLength != sizeof *info->u) {
51013 +                               dev_dbg (&intf->dev, "CDC union len %u\n",
51014 +                                       info->u->bLength);
51015                                 goto bad_desc;
51016 -                       info->data = dev->udev->actconfig->interface[0];
51017 -                       if (intf != (info->data + info->u->bMasterInterface0))
51018 +                       }
51019 +
51020 +                       /* we need a master/control interface (what we're
51021 +                        * probed with) and a slave/data interface; union
51022 +                        * descriptors sort this all out.
51023 +                        */
51024 +                       info->control = usb_ifnum_to_if(dev->udev,
51025 +                                               info->u->bMasterInterface0);
51026 +                       info->data = usb_ifnum_to_if(dev->udev,
51027 +                                               info->u->bSlaveInterface0);
51028 +                       if (!info->control || !info->data) {
51029 +                               dev_dbg (&intf->dev,
51030 +                                       "master #%u/%p slave #%u/%p\n",
51031 +                                       info->u->bMasterInterface0
51032 +                                       info->control,
51033 +                                       info->u->bSlaveInterface0,
51034 +                                       info->data);
51035                                 goto bad_desc;
51036 +                       }
51037 +                       if (info->control != intf) {
51038 +                               dev_dbg (&intf->dev, "bogus CDC Union\n");
51039 +                               /* Ambit USB Cable Modem (and maybe others)
51040 +                                * interchanges master and slave interface.
51041 +                                */
51042 +                               if (info->data == intf) {
51043 +                                       info->data = info->control;
51044 +                                       info->control = intf;
51045 +                               } else
51046 +                                       goto bad_desc;
51047 +                       }
51048  
51049                         /* a data interface altsetting does the real i/o */
51050 -                       info->data += info->u->bSlaveInterface0;
51051                         d = &info->data->altsetting->desc;
51052 -                       if (info->u->bSlaveInterface0 != d->bInterfaceNumber
51053 -                                   || d->bInterfaceClass != USB_CLASS_CDC_DATA)
51054 +                       if (d->bInterfaceClass != USB_CLASS_CDC_DATA) {
51055 +                               dev_dbg (&intf->dev, "slave class %u\n",
51056 +                                       d->bInterfaceClass);
51057                                 goto bad_desc;
51058 +                       }
51059                         if (usb_interface_claimed (info->data))
51060                                 return -EBUSY;
51061                         break;
51062                 case 0x0F:              /* Ethernet Networking */
51063 -                       if (info->ether)
51064 +                       if (info->ether) {
51065 +                               dev_dbg (&intf->dev, "extra CDC ether\n");
51066                                 goto bad_desc;
51067 +                       }
51068                         info->ether = (void *) buf;
51069 -                       if (info->ether->bLength != sizeof *info->ether)
51070 +                       if (info->ether->bLength != sizeof *info->ether) {
51071 +                               dev_dbg (&intf->dev, "CDC ether len %u\n",
51072 +                                       info->u->bLength);
51073                                 goto bad_desc;
51074 +                       }
51075                         break;
51076                 }
51077  next_desc:
51078                 len -= buf [0]; /* bLength */
51079                 buf += buf [0];
51080         }
51081 -       if (!info->header || !info ->u || !info->ether)
51082 +       if (!info->header || !info ->u || !info->ether) {
51083 +               dev_dbg (&intf->dev, "missing cdc %s%s%sdescriptor\n",
51084 +                       info->header ? "" : "header ",
51085 +                       info->u ? "" : "union ",
51086 +                       info->ether ? "" : "ether ");
51087                 goto bad_desc;
51088 +       }
51089  
51090  #ifdef CONFIG_USB_ZAURUS
51091         /* Zaurus ethernet addresses aren't unique ... */
51092 @@ -624,7 +922,7 @@
51093  
51094  static void cdc_unbind (struct usbnet *dev, struct usb_interface *intf)
51095  {
51096 -       struct cdc_info                 *info = (void *) &dev->data;
51097 +       struct cdc_state                *info = (void *) &dev->data;
51098  
51099         /* disconnect master --> disconnect slave */
51100         if (intf == info->control && info->data) {
51101 @@ -2091,16 +2389,23 @@
51102         }
51103  
51104         netif_start_queue (net);
51105 -       if (dev->msg_level >= 2)
51106 +       if (dev->msg_level >= 2) {
51107 +               char    *framing;
51108 +
51109 +               if (dev->driver_info->flags & FLAG_FRAMING_NC)
51110 +                       framing = "NetChip";
51111 +               else if (dev->driver_info->flags & FLAG_FRAMING_GL)
51112 +                       framing = "GeneSys";
51113 +               else if (dev->driver_info->flags & FLAG_FRAMING_Z)
51114 +                       framing = "Zaurus";
51115 +               else
51116 +                       framing = "simple";
51117 +
51118                 devinfo (dev, "open: enable queueing "
51119                                 "(rx %d, tx %d) mtu %d %s framing",
51120                         RX_QLEN (dev), TX_QLEN (dev), dev->net->mtu,
51121 -                       (info->flags & (FLAG_FRAMING_NC | FLAG_FRAMING_GL))
51122 -                           ? ((info->flags & FLAG_FRAMING_NC)
51123 -                               ? "NetChip"
51124 -                               : "GeneSys")
51125 -                           : "raw"
51126 -                       );
51127 +                       framing);
51128 +       }
51129  
51130         // delay posting reads until we're fully open
51131         tasklet_schedule (&dev->bh);
51132 @@ -2173,12 +2478,20 @@
51133  
51134  static int usbnet_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
51135  {
51136 -       switch (cmd) {
51137 -       case SIOCETHTOOL:
51138 +       if (cmd == SIOCETHTOOL)
51139                 return usbnet_ethtool_ioctl (net, (void __user *)rq->ifr_data);
51140 -       default:
51141 -               return -EOPNOTSUPP;
51142 +
51143 +#ifdef NEED_MII
51144 +       {
51145 +       struct usbnet *dev = (struct usbnet *)net->priv;
51146 +
51147 +       if (dev->mii.mdio_read != NULL && dev->mii.mdio_write != NULL)
51148 +               return generic_mii_ioctl(&dev->mii,
51149 +                               (struct mii_ioctl_data *) &rq->ifr_data,
51150 +                               cmd, NULL);
51151         }
51152 +#endif
51153 +       return -EOPNOTSUPP;
51154  }
51155  
51156  /*-------------------------------------------------------------------------*/
51157 @@ -2342,7 +2655,7 @@
51158                 if (!((skb->len + sizeof *trailer) & 0x01))
51159                         *skb_put (skb, 1) = PAD_BYTE;
51160                 trailer = (struct nc_trailer *) skb_put (skb, sizeof *trailer);
51161 -       } 
51162 +       }
51163  #endif /* CONFIG_USB_NET1080 */
51164  
51165         usb_fill_bulk_urb (urb, dev->udev, dev->out,
51166 @@ -2670,6 +2983,30 @@
51167  },
51168  #endif
51169  
51170 +#ifdef CONFIG_USB_AX8817X
51171 +{
51172 +       // Linksys USB200M
51173 +       USB_DEVICE (0x077b, 0x2226),
51174 +       .driver_info =  (unsigned long) &ax8817x_info,
51175 +}, {
51176 +       // Netgear FA120
51177 +       USB_DEVICE (0x0846, 0x1040),
51178 +       .driver_info =  (unsigned long) &ax8817x_info,
51179 +}, {
51180 +       // DLink DUB-E100
51181 +       USB_DEVICE (0x2001, 0x1a00),
51182 +       .driver_info =  (unsigned long) &ax8817x_info,
51183 +}, {
51184 +       // Intellinet, ST Lab USB Ethernet
51185 +       USB_DEVICE (0x0b95, 0x1720),
51186 +       .driver_info =  (unsigned long) &ax8817x_info,
51187 +}, {
51188 +       // Hawking UF200, TrendNet TU2-ET100
51189 +       USB_DEVICE (0x07b8, 0x420a),
51190 +       .driver_info =  (unsigned long) &ax8817x_info,
51191 +}, 
51192 +#endif
51193 +
51194  #ifdef CONFIG_USB_EPSON2888
51195  {
51196         USB_DEVICE (0x0525, 0x2888),    // EPSON USB client
51197 @@ -2834,18 +3171,19 @@
51198  
51199  static int __init usbnet_init (void)
51200  {
51201 -       // compiler should optimize this out
51202 -       if (sizeof (((struct sk_buff *)0)->cb) < sizeof (struct skb_data))
51203 -               BUG ();
51204 +       // compiler should optimize these out
51205 +       BUG_ON (sizeof (((struct sk_buff *)0)->cb)
51206 +                       < sizeof (struct skb_data));
51207 +#ifdef CONFIG_USB_CDCETHER
51208 +       BUG_ON ((sizeof (((struct usbnet *)0)->data)
51209 +                       < sizeof (struct cdc_state)));
51210 +#endif
51211  
51212         get_random_bytes (node_id, sizeof node_id);
51213         node_id [0] &= 0xfe;    // clear multicast bit
51214         node_id [0] |= 0x02;    // set local assignment bit (IEEE802)
51215  
51216 -       if (usb_register (&usbnet_driver) < 0)
51217 -               return -1;
51218 -
51219 -       return 0;
51220 +       return usb_register(&usbnet_driver);
51221  }
51222  module_init (usbnet_init);
51223  
51224 diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
51225 --- a/drivers/usb/serial/belkin_sa.c    Wed Aug 13 03:06:57 2003
51226 +++ b/drivers/usb/serial/belkin_sa.c    Fri Aug 22 13:52:01 2003
51227 @@ -602,10 +602,19 @@
51228  
51229  static int __init belkin_sa_init (void)
51230  {
51231 -       usb_serial_register (&belkin_device);
51232 -       usb_register (&belkin_driver);
51233 +       int retval;
51234 +       retval = usb_serial_register(&belkin_device);
51235 +       if (retval)
51236 +               goto failed_usb_serial_register;
51237 +       retval = usb_register(&belkin_driver);
51238 +       if (retval)
51239 +               goto failed_usb_register;
51240         info(DRIVER_DESC " " DRIVER_VERSION);
51241         return 0;
51242 +failed_usb_register:
51243 +       usb_serial_deregister(&belkin_device);
51244 +failed_usb_serial_register:
51245 +       return retval;
51246  }
51247  
51248  
51249 diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
51250 --- a/drivers/usb/serial/cyberjack.c    Wed Aug 13 03:06:57 2003
51251 +++ b/drivers/usb/serial/cyberjack.c    Mon Aug 25 03:18:48 2003
51252 @@ -101,10 +101,11 @@
51253  };
51254  
51255  struct cyberjack_private {
51256 -       short   rdtodo;         /* Bytes still to read */
51257 +       spinlock_t      lock;           /* Lock for SMP */
51258 +       short           rdtodo;         /* Bytes still to read */
51259         unsigned char   wrbuf[5*64];    /* Buffer for collecting data to write */
51260 -       short   wrfilled;       /* Overall data size we already got */
51261 -       short   wrsent;         /* Data akready sent */
51262 +       short           wrfilled;       /* Overall data size we already got */
51263 +       short           wrsent;         /* Data akready sent */
51264  };
51265  
51266  /* do some startup allocations not currently performed by usb_serial_probe() */
51267 @@ -120,6 +121,7 @@
51268                 return -ENOMEM;
51269  
51270         /* set initial values */
51271 +       spin_lock_init(&priv->lock);
51272         priv->rdtodo = 0;
51273         priv->wrfilled = 0;
51274         priv->wrsent = 0;
51275 @@ -146,6 +148,7 @@
51276  static int  cyberjack_open (struct usb_serial_port *port, struct file *filp)
51277  {
51278         struct cyberjack_private *priv;
51279 +       unsigned long flags;
51280         int result = 0;
51281  
51282         if (port_paranoia_check (port, __FUNCTION__))
51283 @@ -160,9 +163,11 @@
51284         port->tty->low_latency = 1;
51285  
51286         priv = usb_get_serial_port_data(port);
51287 +       spin_lock_irqsave(&priv->lock, flags);
51288         priv->rdtodo = 0;
51289         priv->wrfilled = 0;
51290         priv->wrsent = 0;
51291 +       spin_unlock_irqrestore(&priv->lock, flags);
51292  
51293         /* shutdown any bulk reads that might be going on */
51294         usb_unlink_urb (port->write_urb);
51295 @@ -194,6 +199,7 @@
51296  {
51297         struct usb_serial *serial = port->serial;
51298         struct cyberjack_private *priv = usb_get_serial_port_data(port);
51299 +       unsigned long flags;
51300         int result;
51301         int wrexpected;
51302  
51303 @@ -210,15 +216,19 @@
51304                 return (0);
51305         }
51306  
51307 +       spin_lock_irqsave(&priv->lock, flags);
51308 +
51309         if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ) {
51310                 /* To much data  for buffer. Reset buffer. */
51311                 priv->wrfilled=0;
51312 +               spin_unlock_irqrestore(&priv->lock, flags);
51313                 return (0);
51314         }
51315  
51316         /* Copy data */
51317         if (from_user) {
51318                 if (copy_from_user(priv->wrbuf+priv->wrfilled, buf, count)) {
51319 +                       spin_unlock_irqrestore(&priv->lock, flags);
51320                         return -EFAULT;
51321                 }
51322         } else {
51323 @@ -261,6 +271,7 @@
51324                         /* Throw away data. No better idea what to do with it. */
51325                         priv->wrfilled=0;
51326                         priv->wrsent=0;
51327 +                       spin_unlock_irqrestore(&priv->lock, flags);
51328                         return 0;
51329                 }
51330  
51331 @@ -275,6 +286,8 @@
51332                 }
51333         }
51334  
51335 +       spin_unlock_irqrestore(&priv->lock, flags);
51336 +
51337         return (count);
51338  } 
51339  
51340 @@ -282,8 +295,10 @@
51341  {
51342         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
51343         struct cyberjack_private *priv = usb_get_serial_port_data(port);
51344 +       unsigned long flags;
51345         struct usb_serial *serial;
51346         unsigned char *data = urb->transfer_buffer;
51347 +       int result;
51348  
51349         if (port_paranoia_check (port, __FUNCTION__))
51350                 return;
51351 @@ -302,21 +317,20 @@
51352  
51353         /* React only to interrupts signaling a bulk_in transfer */
51354         if( (urb->actual_length==4) && (data[0]==0x01) ) {
51355 -               short old_rdtodo = priv->rdtodo;
51356 +               short old_rdtodo;
51357                 int result;
51358  
51359                 /* This is a announcement of coming bulk_ins. */
51360                 unsigned short size = ((unsigned short)data[3]<<8)+data[2]+3;
51361  
51362 -               if( (size>259) || (size==0) ) {
51363 -                       dbg( "Bad announced bulk_in data length: %d", size );
51364 -                       /* Dunno what is most reliable to do here. */
51365 -                       /* return; */
51366 -               }
51367 +               spin_lock_irqsave(&priv->lock, flags);
51368 +
51369 +               old_rdtodo = priv->rdtodo;
51370  
51371                 if( (old_rdtodo+size)<(old_rdtodo) ) {
51372                         dbg( "To many bulk_in urbs to do." );
51373 -                       return;
51374 +                       spin_unlock_irqrestore(&priv->lock, flags);
51375 +                       goto resubmit;
51376                 }
51377  
51378                 /* "+=" is probably more fault tollerant than "=" */
51379 @@ -324,23 +338,34 @@
51380  
51381                 dbg("%s - rdtodo: %d", __FUNCTION__, priv->rdtodo);
51382  
51383 +               spin_unlock_irqrestore(&priv->lock, flags);
51384 +
51385                 if( !old_rdtodo ) {
51386                         port->read_urb->dev = port->serial->dev;
51387 -                       result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
51388 +                       result = usb_submit_urb(port->read_urb, GFP_KERNEL);
51389                         if( result )
51390                                 err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
51391                         dbg("%s - usb_submit_urb(read urb)", __FUNCTION__);
51392                 }
51393         }
51394 +
51395 +resubmit:
51396 +       port->interrupt_in_urb->dev = port->serial->dev;
51397 +       result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
51398 +       if (result)
51399 +               err(" usb_submit_urb(read int) failed");
51400 +       dbg("%s - usb_submit_urb(int urb)", __FUNCTION__);
51401  }
51402  
51403  static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
51404  {
51405         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
51406         struct cyberjack_private *priv = usb_get_serial_port_data(port);
51407 +       unsigned long flags;
51408         struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
51409         struct tty_struct *tty;
51410         unsigned char *data = urb->transfer_buffer;
51411 +       short todo;
51412         int i;
51413         int result;
51414  
51415 @@ -372,18 +397,22 @@
51416                 tty_flip_buffer_push(tty);
51417         }
51418  
51419 +       spin_lock_irqsave(&priv->lock, flags);
51420 +
51421         /* Reduce urbs to do by one. */
51422         priv->rdtodo-=urb->actual_length;
51423         /* Just to be sure */
51424 -       if ( priv->rdtodo<0 )
51425 -               priv->rdtodo = 0;
51426 +       if ( priv->rdtodo<0 ) priv->rdtodo = 0;
51427 +       todo = priv->rdtodo;
51428  
51429 -       dbg("%s - rdtodo: %d", __FUNCTION__, priv->rdtodo);
51430 +       spin_unlock_irqrestore(&priv->lock, flags);
51431 +
51432 +       dbg("%s - rdtodo: %d", __FUNCTION__, todo);
51433  
51434         /* Continue to read if we have still urbs to do. */
51435 -       if( priv->rdtodo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) {
51436 +       if( todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) {
51437                 port->read_urb->dev = port->serial->dev;
51438 -               result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
51439 +               result = usb_submit_urb(port->read_urb, GFP_KERNEL);
51440                 if (result)
51441                         err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
51442                 dbg("%s - usb_submit_urb(read urb)", __FUNCTION__);
51443 @@ -394,6 +423,7 @@
51444  {
51445         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
51446         struct cyberjack_private *priv = usb_get_serial_port_data(port);
51447 +       unsigned long flags;
51448         struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
51449  
51450         dbg("%s - port %d", __FUNCTION__, port->number);
51451 @@ -408,12 +438,15 @@
51452                 return;
51453         }
51454  
51455 +       spin_lock_irqsave(&priv->lock, flags);
51456 +
51457         /* only do something if we have more data to send */
51458         if( priv->wrfilled ) {
51459                 int length, blksize, result;
51460  
51461                 if (port->write_urb->status == -EINPROGRESS) {
51462                         dbg("%s - already writing", __FUNCTION__);
51463 +                       spin_unlock_irqrestore(&priv->lock, flags);
51464                         return;
51465                 }
51466  
51467 @@ -459,18 +492,28 @@
51468         }
51469  
51470  exit:
51471 +       spin_unlock_irqrestore(&priv->lock, flags);
51472         schedule_work(&port->work);
51473  }
51474  
51475  static int __init cyberjack_init (void)
51476  {
51477 -       usb_serial_register (&cyberjack_device);
51478 -       usb_register (&cyberjack_driver);
51479 +       int retval;
51480 +       retval  = usb_serial_register(&cyberjack_device);
51481 +       if (retval)
51482 +               goto failed_usb_serial_register;
51483 +       retval = usb_register(&cyberjack_driver);
51484 +       if (retval) 
51485 +               goto failed_usb_register;
51486  
51487         info(DRIVER_VERSION " " DRIVER_AUTHOR);
51488         info(DRIVER_DESC);
51489  
51490         return 0;
51491 +failed_usb_register:
51492 +       usb_serial_deregister(&cyberjack_device);
51493 +failed_usb_serial_register:
51494 +       return retval;
51495  }
51496  
51497  static void __exit cyberjack_exit (void)
51498 diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
51499 --- a/drivers/usb/serial/digi_acceleport.c      Wed Aug 13 03:06:57 2003
51500 +++ b/drivers/usb/serial/digi_acceleport.c      Tue Sep  2 11:40:28 2003
51501 @@ -218,7 +218,7 @@
51502  *    interrupt time.
51503  *  - digi_write_bulk_callback() and digi_read_bulk_callback() are
51504  *    called directly from interrupts.  Hence spin_lock_irqsave()
51505 -*    and spin_lock_irqrestore() are used in the rest of the code
51506 +*    and spin_unlock_irqrestore() are used in the rest of the code
51507  *    for any locks they acquire.
51508  *  - digi_write_bulk_callback() gets the port lock before waking up
51509  *    processes sleeping on the port write_wait.  It also schedules
51510 @@ -571,7 +571,7 @@
51511  *
51512  *  Do spin_unlock_irqrestore and interruptible_sleep_on_timeout
51513  *  so that wake ups are not lost if they occur between the unlock
51514 -*  and the sleep.  In other words, spin_lock_irqrestore and
51515 +*  and the sleep.  In other words, spin_unlock_irqrestore and
51516  *  interruptible_sleep_on_timeout are "atomic" with respect to
51517  *  wake ups.  This is used to implement condition variables.
51518  */
51519 @@ -2045,11 +2045,24 @@
51520  
51521  static int __init digi_init (void)
51522  {
51523 -       usb_serial_register (&digi_acceleport_2_device);
51524 -       usb_serial_register (&digi_acceleport_4_device);
51525 -       usb_register (&digi_driver);
51526 +       int retval;
51527 +       retval = usb_serial_register(&digi_acceleport_2_device);
51528 +       if (retval)
51529 +               goto failed_acceleport_2_device;
51530 +       retval = usb_serial_register(&digi_acceleport_4_device);
51531 +       if (retval) 
51532 +               goto failed_acceleport_4_device;
51533 +       retval = usb_register(&digi_driver);
51534 +       if (retval)
51535 +               goto failed_usb_register;
51536         info(DRIVER_VERSION ":" DRIVER_DESC);
51537         return 0;
51538 +failed_usb_register:
51539 +       usb_serial_deregister(&digi_acceleport_4_device);
51540 +failed_acceleport_4_device:
51541 +       usb_serial_deregister(&digi_acceleport_2_device);
51542 +failed_acceleport_2_device:
51543 +       return retval;
51544  }
51545  
51546  
51547 diff -Nru a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
51548 --- a/drivers/usb/serial/empeg.c        Mon Aug 11 07:56:25 2003
51549 +++ b/drivers/usb/serial/empeg.c        Fri Aug 22 13:52:01 2003
51550 @@ -558,7 +558,7 @@
51551  static int __init empeg_init (void)
51552  {
51553         struct urb *urb;
51554 -       int i;
51555 +       int i, retval;
51556  
51557         /* create our write urb pool and transfer buffers */ 
51558         spin_lock_init (&write_urb_pool_lock);
51559 @@ -570,7 +570,6 @@
51560                         continue;
51561                 }
51562  
51563 -               urb->transfer_buffer = NULL;
51564                 urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
51565                 if (!urb->transfer_buffer) {
51566                         err("%s - out of memory for urb buffers.", 
51567 @@ -579,12 +578,27 @@
51568                 }
51569         }
51570  
51571 -       usb_serial_register (&empeg_device);
51572 -       usb_register (&empeg_driver);
51573 +       retval = usb_serial_register(&empeg_device);
51574 +       if (retval)
51575 +               goto failed_usb_serial_register;
51576 +       retval = usb_register(&empeg_driver);
51577 +       if (retval)
51578 +               goto failed_usb_register;
51579  
51580         info(DRIVER_VERSION ":" DRIVER_DESC);
51581  
51582         return 0;
51583 +failed_usb_register:
51584 +       usb_serial_deregister(&empeg_device);
51585 +failed_usb_serial_register:
51586 +       for (i = 0; i < NUM_URBS; ++i) {
51587 +               if (write_urb_pool[i]) {
51588 +                       if (write_urb_pool[i]->transfer_buffer)
51589 +                               kfree(write_urb_pool[i]->transfer_buffer);
51590 +                       usb_free_urb(write_urb_pool[i]);
51591 +               }
51592 +       }
51593 +       return retval;
51594  }
51595  
51596  
51597 @@ -593,7 +607,7 @@
51598         int i;
51599         unsigned long flags;
51600  
51601 -       usb_register (&empeg_driver);
51602 +       usb_deregister(&empeg_driver);
51603         usb_serial_deregister (&empeg_device);
51604  
51605         spin_lock_irqsave (&write_urb_pool_lock, flags);
51606 diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
51607 --- a/drivers/usb/serial/ftdi_sio.c     Wed Aug 13 03:06:57 2003
51608 +++ b/drivers/usb/serial/ftdi_sio.c     Tue Aug 19 05:26:50 2003
51609 @@ -17,6 +17,11 @@
51610   * See http://ftdi-usb-sio.sourceforge.net for upto date testing info
51611   *     and extra documentation
51612   *
51613 + * (19/Aug/2003) Ian Abbott
51614 + *      Freed urb's transfer buffer in write bulk callback.
51615 + *      Omitted some paranoid checks in write bulk callback that don't matter.
51616 + *      Scheduled work in write bulk callback regardless of port's open count.
51617 + *
51618   * (05/Aug/2003) Ian Abbott
51619   *      Added VID/PID for ID TECH IDT1221U USB to RS-232 adapter.
51620   *      VID/PID provided by Steve Briggs.
51621 @@ -1391,31 +1396,21 @@
51622  static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
51623  {
51624         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
51625 -       struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
51626  
51627 -       dbg("%s", __FUNCTION__);
51628 +       /* free up the transfer buffer, as usb_free_urb() does not do this */
51629 +       kfree (urb->transfer_buffer);
51630  
51631         if (port_paranoia_check (port, __FUNCTION__))
51632                 return;
51633         
51634 +       dbg("%s - port %d", __FUNCTION__, port->number);
51635 +       
51636         if (urb->status) {
51637                 dbg("nonzero write bulk status received: %d", urb->status);
51638                 return;
51639         }
51640  
51641 -       if (!serial) {
51642 -               dbg("%s - bad serial pointer, exiting", __FUNCTION__);
51643 -               return;
51644 -       }
51645 -
51646 -       /* Have to check for validity of queueing up the tasks */
51647 -       dbg("%s - port->open_count = %d", __FUNCTION__, port->open_count);
51648 -
51649 -       if (port->open_count > 0){
51650 -               schedule_work(&port->work);
51651 -       } 
51652 -
51653 -       return;
51654 +       schedule_work(&port->work);
51655  } /* ftdi_write_bulk_callback */
51656  
51657  
51658 @@ -1999,17 +1994,42 @@
51659  
51660  static int __init ftdi_init (void)
51661  {
51662 +       int retval;
51663  
51664         dbg("%s", __FUNCTION__);
51665 -       usb_serial_register (&ftdi_SIO_device);
51666 -       usb_serial_register (&ftdi_8U232AM_device);
51667 -       usb_serial_register (&ftdi_FT232BM_device);
51668 -       usb_serial_register (&ftdi_USB_UIRT_device);
51669 -       usb_serial_register (&ftdi_HE_TIRA1_device);
51670 -       usb_register (&ftdi_driver);
51671 +       retval = usb_serial_register(&ftdi_SIO_device);
51672 +       if (retval)
51673 +               goto failed_SIO_register;
51674 +       retval = usb_serial_register(&ftdi_8U232AM_device);
51675 +       if (retval)
51676 +               goto failed_8U232AM_register;
51677 +       retval = usb_serial_register(&ftdi_FT232BM_device);
51678 +       if (retval)
51679 +               goto failed_FT232BM_register;
51680 +       retval = usb_serial_register(&ftdi_USB_UIRT_device);
51681 +       if (retval)
51682 +               goto failed_USB_UIRT_register;
51683 +       retval = usb_serial_register(&ftdi_HE_TIRA1_device);
51684 +       if (retval)
51685 +               goto failed_HE_TIRA1_register;
51686 +       retval = usb_register(&ftdi_driver);
51687 +       if (retval) 
51688 +               goto failed_usb_register;
51689  
51690         info(DRIVER_VERSION ":" DRIVER_DESC);
51691         return 0;
51692 +failed_usb_register:
51693 +       usb_serial_deregister(&ftdi_HE_TIRA1_device);
51694 +failed_HE_TIRA1_register:
51695 +       usb_serial_deregister(&ftdi_USB_UIRT_device);
51696 +failed_USB_UIRT_register:
51697 +       usb_serial_deregister(&ftdi_FT232BM_device);
51698 +failed_FT232BM_register:
51699 +       usb_serial_deregister(&ftdi_8U232AM_device);
51700 +failed_8U232AM_register:
51701 +       usb_serial_deregister(&ftdi_SIO_device);
51702 +failed_SIO_register:
51703 +       return retval;
51704  }
51705  
51706  
51707 diff -Nru a/drivers/usb/serial/io_16654.h b/drivers/usb/serial/io_16654.h
51708 --- a/drivers/usb/serial/io_16654.h     Mon Feb  4 23:38:25 2002
51709 +++ b/drivers/usb/serial/io_16654.h     Sat Aug 23 12:56:34 2003
51710 @@ -2,7 +2,7 @@
51711   *
51712   *     16654.H         Definitions for 16C654 UART used on EdgePorts
51713   *
51714 - *     Copyright (c) 1998 Inside Out Networks, Inc.
51715 + *     Copyright (C) 1998 Inside Out Networks, Inc.
51716   *     This program is free software; you can redistribute it and/or modify
51717   *     it under the terms of the GNU General Public License as published by
51718   *     the Free Software Foundation; either version 2 of the License, or
51719 @@ -142,14 +142,14 @@
51720  #define LSR_FIFO_ERR           0x80    // Rx Fifo contains at least 1 erred char
51721  
51722  
51723 -#define MSR_DELTA_CTS          0x01    // CTS changed from last read
51724 -#define MSR_DELTA_DSR          0x02    // DSR changed from last read
51725 -#define MSR_DELTA_RI           0x04    // RI  changed from 0 -> 1
51726 -#define MSR_DELTA_CD           0x08    // CD  changed from last read
51727 -#define MSR_CTS                        0x10    // Current state of CTS
51728 -#define MSR_DSR                        0x20    // Current state of DSR
51729 -#define MSR_RI                 0x40    // Current state of RI
51730 -#define MSR_CD                 0x80    // Current state of CD
51731 +#define EDGEPORT_MSR_DELTA_CTS 0x01    // CTS changed from last read
51732 +#define EDGEPORT_MSR_DELTA_DSR 0x02    // DSR changed from last read
51733 +#define EDGEPORT_MSR_DELTA_RI  0x04    // RI  changed from 0 -> 1
51734 +#define EDGEPORT_MSR_DELTA_CD  0x08    // CD  changed from last read
51735 +#define EDGEPORT_MSR_CTS       0x10    // Current state of CTS
51736 +#define EDGEPORT_MSR_DSR       0x20    // Current state of DSR
51737 +#define EDGEPORT_MSR_RI                0x40    // Current state of RI
51738 +#define EDGEPORT_MSR_CD                0x80    // Current state of CD
51739  
51740  
51741  
51742 diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
51743 --- a/drivers/usb/serial/io_edgeport.c  Wed Aug 13 03:06:57 2003
51744 +++ b/drivers/usb/serial/io_edgeport.c  Sat Aug 23 12:56:50 2003
51745 @@ -1,8 +1,8 @@
51746  /*
51747   * Edgeport USB Serial Converter driver
51748   *
51749 - * Copyright(c) 2000 Inside Out Networks, All rights reserved.
51750 - * Copyright(c) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
51751 + * Copyright (C) 2000 Inside Out Networks, All rights reserved.
51752 + * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
51753   *
51754   *     This program is free software; you can redistribute it and/or modify
51755   *     it under the terms of the GNU General Public License as published by
51756 @@ -1806,10 +1806,10 @@
51757         mcr = edge_port->shadowMCR;
51758         result = ((mcr & MCR_DTR)       ? TIOCM_DTR: 0)   /* 0x002 */
51759                   | ((mcr & MCR_RTS)    ? TIOCM_RTS: 0)   /* 0x004 */
51760 -                 | ((msr & MSR_CTS)    ? TIOCM_CTS: 0)   /* 0x020 */
51761 -                 | ((msr & MSR_CD)     ? TIOCM_CAR: 0)   /* 0x040 */
51762 -                 | ((msr & MSR_RI)     ? TIOCM_RI:  0)   /* 0x080 */
51763 -                 | ((msr & MSR_DSR)    ? TIOCM_DSR: 0);  /* 0x100 */
51764 +                 | ((msr & EDGEPORT_MSR_CTS)   ? TIOCM_CTS: 0)   /* 0x020 */
51765 +                 | ((msr & EDGEPORT_MSR_CD)    ? TIOCM_CAR: 0)   /* 0x040 */
51766 +                 | ((msr & EDGEPORT_MSR_RI)    ? TIOCM_RI:  0)   /* 0x080 */
51767 +                 | ((msr & EDGEPORT_MSR_DSR)   ? TIOCM_DSR: 0);  /* 0x100 */
51768  
51769  
51770         dbg("%s -- %x", __FUNCTION__, result);
51771 @@ -2221,20 +2221,20 @@
51772  
51773         dbg("%s %02x", __FUNCTION__, newMsr);
51774  
51775 -       if (newMsr & (MSR_DELTA_CTS | MSR_DELTA_DSR | MSR_DELTA_RI | MSR_DELTA_CD)) {
51776 +       if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
51777                 icount = &edge_port->icount;
51778  
51779                 /* update input line counters */
51780 -               if (newMsr & MSR_DELTA_CTS) {
51781 +               if (newMsr & EDGEPORT_MSR_DELTA_CTS) {
51782                         icount->cts++;
51783                 }
51784 -               if (newMsr & MSR_DELTA_DSR) {
51785 +               if (newMsr & EDGEPORT_MSR_DELTA_DSR) {
51786                         icount->dsr++;
51787                 }
51788 -               if (newMsr & MSR_DELTA_CD) {
51789 +               if (newMsr & EDGEPORT_MSR_DELTA_CD) {
51790                         icount->dcd++;
51791                 }
51792 -               if (newMsr & MSR_DELTA_RI) {
51793 +               if (newMsr & EDGEPORT_MSR_DELTA_RI) {
51794                         icount->rng++;
51795                 }
51796                 wake_up_interruptible(&edge_port->delta_msr_wait);
51797 @@ -3051,15 +3051,36 @@
51798   * edgeport_init
51799   *     This is called by the module subsystem, or on startup to initialize us
51800   ****************************************************************************/
51801 -int __init edgeport_init(void)
51802 +static int __init edgeport_init(void)
51803  {
51804 -       usb_serial_register (&edgeport_1port_device);
51805 -       usb_serial_register (&edgeport_2port_device);
51806 -       usb_serial_register (&edgeport_4port_device);
51807 -       usb_serial_register (&edgeport_8port_device);
51808 -       usb_register (&io_driver);
51809 +       int retval;
51810 +       retval = usb_serial_register(&edgeport_1port_device);
51811 +       if (retval) 
51812 +               goto failed_1port_device_register;
51813 +       retval = usb_serial_register(&edgeport_2port_device);
51814 +       if (retval)
51815 +               goto failed_2port_device_register;
51816 +       retval = usb_serial_register(&edgeport_4port_device);
51817 +       if (retval)
51818 +               goto failed_4port_device_register;
51819 +       retval = usb_serial_register(&edgeport_8port_device);
51820 +       if (retval)
51821 +               goto failed_8port_device_register;
51822 +       retval = usb_register(&io_driver);
51823 +       if (retval) 
51824 +               goto failed_usb_register;
51825         info(DRIVER_DESC " " DRIVER_VERSION);
51826         return 0;
51827 +failed_usb_register:
51828 +       usb_serial_deregister(&edgeport_8port_device);
51829 +failed_8port_device_register:
51830 +       usb_serial_deregister(&edgeport_4port_device);
51831 +failed_4port_device_register:
51832 +       usb_serial_deregister(&edgeport_2port_device);
51833 +failed_2port_device_register:
51834 +       usb_serial_deregister(&edgeport_1port_device);
51835 +failed_1port_device_register:
51836 +       return retval;
51837  }
51838  
51839  
51840 @@ -3068,7 +3089,7 @@
51841   * edgeport_exit
51842   *     Called when the driver is about to be unloaded.
51843   ****************************************************************************/
51844 -void __exit edgeport_exit (void)
51845 +static void __exit edgeport_exit (void)
51846  {
51847         usb_deregister (&io_driver);
51848         usb_serial_deregister (&edgeport_1port_device);
51849 diff -Nru a/drivers/usb/serial/io_edgeport.h b/drivers/usb/serial/io_edgeport.h
51850 --- a/drivers/usb/serial/io_edgeport.h  Mon Feb 11 13:54:53 2002
51851 +++ b/drivers/usb/serial/io_edgeport.h  Wed Aug 27 04:45:14 2003
51852 @@ -2,7 +2,7 @@
51853   *
51854   *     io_edgeport.h   Edgeport Linux Interface definitions
51855   *
51856 - *     Copyright (c) 2000 Inside Out Networks, Inc.
51857 + *     Copyright (C) 2000 Inside Out Networks, Inc.
51858   *
51859   *     This program is free software; you can redistribute it and/or modify
51860   *     it under the terms of the GNU General Public License as published by
51861 diff -Nru a/drivers/usb/serial/io_fw_boot.h b/drivers/usb/serial/io_fw_boot.h
51862 --- a/drivers/usb/serial/io_fw_boot.h   Mon Feb 11 13:54:53 2002
51863 +++ b/drivers/usb/serial/io_fw_boot.h   Wed Aug 27 04:45:13 2003
51864 @@ -1,7 +1,7 @@
51865  //**************************************************************
51866  //* Edgeport/4 Binary Image
51867  //* Generated by HEX2C v1.06
51868 -//* Copyright(c) 1998 Inside Out Networks, All rights reserved.
51869 +//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
51870  //*    This program is free software; you can redistribute it and/or modify
51871  //*    it under the terms of the GNU General Public License as published by
51872  //*    the Free Software Foundation; either version 2 of the License, or
51873 diff -Nru a/drivers/usb/serial/io_fw_boot2.h b/drivers/usb/serial/io_fw_boot2.h
51874 --- a/drivers/usb/serial/io_fw_boot2.h  Mon Feb 11 13:54:53 2002
51875 +++ b/drivers/usb/serial/io_fw_boot2.h  Wed Aug 27 04:45:14 2003
51876 @@ -1,7 +1,7 @@
51877  //**************************************************************
51878  //* Edgeport/4 Binary Image
51879  //* Generated by HEX2C v1.06
51880 -//* Copyright(c) 1998 Inside Out Networks, All rights reserved.
51881 +//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
51882  //*    This program is free software; you can redistribute it and/or modify
51883  //*    it under the terms of the GNU General Public License as published by
51884  //*    the Free Software Foundation; either version 2 of the License, or
51885 diff -Nru a/drivers/usb/serial/io_fw_down.h b/drivers/usb/serial/io_fw_down.h
51886 --- a/drivers/usb/serial/io_fw_down.h   Mon Feb 11 13:54:53 2002
51887 +++ b/drivers/usb/serial/io_fw_down.h   Wed Aug 27 04:45:14 2003
51888 @@ -1,7 +1,7 @@
51889  //**************************************************************
51890  //* Edgeport/4 Binary Image
51891  //* Generated by HEX2C v1.06
51892 -//* Copyright(c) 1998 Inside Out Networks, All rights reserved.
51893 +//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
51894  //*    This program is free software; you can redistribute it and/or modify
51895  //*    it under the terms of the GNU General Public License as published by
51896  //*    the Free Software Foundation; either version 2 of the License, or
51897 diff -Nru a/drivers/usb/serial/io_fw_down2.h b/drivers/usb/serial/io_fw_down2.h
51898 --- a/drivers/usb/serial/io_fw_down2.h  Mon Feb 11 13:54:53 2002
51899 +++ b/drivers/usb/serial/io_fw_down2.h  Wed Aug 27 04:45:14 2003
51900 @@ -1,7 +1,7 @@
51901  //**************************************************************
51902  //* Edgeport/4 Binary Image
51903  //* Generated by HEX2C v1.06
51904 -//* Copyright(c) 1998 Inside Out Networks, All rights reserved.
51905 +//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
51906  //*    This program is free software; you can redistribute it and/or modify
51907  //*    it under the terms of the GNU General Public License as published by
51908  //*    the Free Software Foundation; either version 2 of the License, or
51909 diff -Nru a/drivers/usb/serial/io_fw_down3.h b/drivers/usb/serial/io_fw_down3.h
51910 --- a/drivers/usb/serial/io_fw_down3.h  Fri Jul 26 11:59:43 2002
51911 +++ b/drivers/usb/serial/io_fw_down3.h  Wed Aug 27 04:45:13 2003
51912 @@ -1,7 +1,7 @@
51913  //**************************************************************
51914  //* Edgeport Binary Image (for TI based products)
51915  //* Generated by TIBin2C v1.00
51916 -//* Copyright(c) 2001 Inside Out Networks, All rights reserved.
51917 +//* Copyright (C) 2001 Inside Out Networks, All rights reserved.
51918  //**************************************************************
51919  
51920  
51921 diff -Nru a/drivers/usb/serial/io_ionsp.h b/drivers/usb/serial/io_ionsp.h
51922 --- a/drivers/usb/serial/io_ionsp.h     Thu Mar 13 10:36:02 2003
51923 +++ b/drivers/usb/serial/io_ionsp.h     Wed Aug 27 04:45:13 2003
51924 @@ -2,7 +2,7 @@
51925   *
51926   *     IONSP.H         Definitions for I/O Networks Serial Protocol
51927   *
51928 - *     Copyright (c) 1997-1998 Inside Out Networks, Inc.
51929 + *     Copyright (C) 1997-1998 Inside Out Networks, Inc.
51930   *
51931   *     This program is free software; you can redistribute it and/or modify
51932   *     it under the terms of the GNU General Public License as published by
51933 diff -Nru a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
51934 --- a/drivers/usb/serial/io_ti.c        Wed Aug 13 03:06:57 2003
51935 +++ b/drivers/usb/serial/io_ti.c        Sat Aug 23 12:57:20 2003
51936 @@ -1,8 +1,8 @@
51937  /*
51938   * Edgeport USB Serial Converter driver
51939   *
51940 - * Copyright(c) 2000-2002 Inside Out Networks, All rights reserved.
51941 - * Copyright(c) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
51942 + * Copyright (C) 2000-2002 Inside Out Networks, All rights reserved.
51943 + * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
51944   *
51945   *     This program is free software; you can redistribute it and/or modify
51946   *     it under the terms of the GNU General Public License as published by
51947 @@ -127,6 +127,7 @@
51948  
51949  static struct usb_device_id edgeport_2port_id_table [] = {
51950         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) },
51951 +       { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) },
51952         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) },
51953         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421) },
51954         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421_BOOT) },
51955 @@ -145,6 +146,7 @@
51956  static struct usb_device_id id_table_combined [] = {
51957         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_1) },
51958         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2) },
51959 +       { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2C) },
51960         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_2I) },
51961         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421) },
51962         { USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_421_BOOT) },
51963 @@ -1575,17 +1577,17 @@
51964  
51965         dbg ("%s - %02x", __FUNCTION__, msr);
51966  
51967 -       if (msr & (MSR_DELTA_CTS | MSR_DELTA_DSR | MSR_DELTA_RI | MSR_DELTA_CD)) {
51968 +       if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
51969                 icount = &edge_port->icount;
51970  
51971                 /* update input line counters */
51972 -               if (msr & MSR_DELTA_CTS)
51973 +               if (msr & EDGEPORT_MSR_DELTA_CTS)
51974                         icount->cts++;
51975 -               if (msr & MSR_DELTA_DSR)
51976 +               if (msr & EDGEPORT_MSR_DELTA_DSR)
51977                         icount->dsr++;
51978 -               if (msr & MSR_DELTA_CD)
51979 +               if (msr & EDGEPORT_MSR_DELTA_CD)
51980                         icount->dcd++;
51981 -               if (msr & MSR_DELTA_RI)
51982 +               if (msr & EDGEPORT_MSR_DELTA_RI)
51983                         icount->rng++;
51984                 wake_up_interruptible (&edge_port->delta_msr_wait);
51985         }
51986 @@ -2447,10 +2449,10 @@
51987         mcr = edge_port->shadow_mcr;
51988         result = ((mcr & MCR_DTR)       ? TIOCM_DTR: 0)   /* 0x002 */
51989                   | ((mcr & MCR_RTS)    ? TIOCM_RTS: 0)   /* 0x004 */
51990 -                 | ((msr & MSR_CTS)    ? TIOCM_CTS: 0)   /* 0x020 */
51991 -                 | ((msr & MSR_CD)     ? TIOCM_CAR: 0)   /* 0x040 */
51992 -                 | ((msr & MSR_RI)     ? TIOCM_RI:  0)   /* 0x080 */
51993 -                 | ((msr & MSR_DSR)    ? TIOCM_DSR: 0);  /* 0x100 */
51994 +                 | ((msr & EDGEPORT_MSR_CTS)   ? TIOCM_CTS: 0)   /* 0x020 */
51995 +                 | ((msr & EDGEPORT_MSR_CD)    ? TIOCM_CAR: 0)   /* 0x040 */
51996 +                 | ((msr & EDGEPORT_MSR_RI)    ? TIOCM_RI:  0)   /* 0x080 */
51997 +                 | ((msr & EDGEPORT_MSR_DSR)   ? TIOCM_DSR: 0);  /* 0x100 */
51998  
51999  
52000         dbg("%s -- %x", __FUNCTION__, result);
52001 @@ -2679,11 +2681,24 @@
52002  
52003  static int __init edgeport_init(void)
52004  {
52005 -       usb_serial_register (&edgeport_1port_device);
52006 -       usb_serial_register (&edgeport_2port_device);
52007 -       usb_register (&io_driver);
52008 +       int retval;
52009 +       retval = usb_serial_register(&edgeport_1port_device);
52010 +       if (retval)
52011 +               goto failed_1port_device_register;
52012 +       retval = usb_serial_register(&edgeport_2port_device);
52013 +       if (retval)
52014 +               goto failed_2port_device_register;
52015 +       retval = usb_register(&io_driver);
52016 +       if (retval) 
52017 +               goto failed_usb_register;
52018         info(DRIVER_DESC " " DRIVER_VERSION);
52019         return 0;
52020 +failed_usb_register:
52021 +       usb_serial_deregister(&edgeport_2port_device);
52022 +failed_2port_device_register:
52023 +       usb_serial_deregister(&edgeport_1port_device);
52024 +failed_1port_device_register:
52025 +       return retval;
52026  }
52027  
52028  static void __exit edgeport_exit (void)
52029 diff -Nru a/drivers/usb/serial/io_ti.h b/drivers/usb/serial/io_ti.h
52030 --- a/drivers/usb/serial/io_ti.h        Fri Jul 26 11:59:44 2002
52031 +++ b/drivers/usb/serial/io_ti.h        Wed Aug 27 04:45:13 2003
52032 @@ -1,6 +1,6 @@
52033  /*****************************************************************************  
52034   *
52035 - *     Copyright (c) 1997-2002 Inside Out Networks, Inc.
52036 + *     Copyright (C) 1997-2002 Inside Out Networks, Inc.
52037   *
52038   *     This program is free software; you can redistribute it and/or modify
52039   *     it under the terms of the GNU General Public License as published by
52040 diff -Nru a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
52041 --- a/drivers/usb/serial/io_usbvend.h   Fri Jul 26 11:59:43 2002
52042 +++ b/drivers/usb/serial/io_usbvend.h   Wed Aug 27 04:45:13 2003
52043 @@ -7,7 +7,7 @@
52044   *
52045   ************************************************************************
52046   *
52047 - *     Copyright (c) 1998 Inside Out Networks, Inc.
52048 + *     Copyright (C) 1998 Inside Out Networks, Inc.
52049   *     This program is free software; you can redistribute it and/or modify
52050   *     it under the terms of the GNU General Public License as published by
52051   *     the Free Software Foundation; either version 2 of the License, or
52052 @@ -118,6 +118,7 @@
52053  #define ION_DEVICE_ID_TI_EDGEPORT_1            0x0215  /* Edgeport/1 RS232 */
52054  #define ION_DEVICE_ID_TI_EDGEPORT_42           0x0217  /* Edgeport/42 4 hub 2 RS232 */
52055  #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 */
52056 +#define ION_DEVICE_ID_TI_EDGEPORT_2C           0x021B  /* Edgeport/2c RS232 */
52057  
52058  #define ION_DEVICE_ID_TI_EDGEPORT_421_BOOT     0x0240  /* Edgeport/421 in boot mode */
52059  #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) */
52060 diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
52061 --- a/drivers/usb/serial/ipaq.c Mon Aug 11 07:56:25 2003
52062 +++ b/drivers/usb/serial/ipaq.c Fri Aug 22 13:52:01 2003
52063 @@ -570,16 +570,25 @@
52064  
52065  static int __init ipaq_init(void)
52066  {
52067 +       int retval;
52068         spin_lock_init(&write_list_lock);
52069 -       usb_serial_register(&ipaq_device);
52070 +       retval = usb_serial_register(&ipaq_device);
52071 +       if (retval) 
52072 +               goto failed_usb_serial_register;
52073         info(DRIVER_DESC " " DRIVER_VERSION);
52074         if (vendor) {
52075                 ipaq_id_table[0].idVendor = vendor;
52076                 ipaq_id_table[0].idProduct = product;
52077         }
52078 -       usb_register(&ipaq_driver);
52079 -
52080 +       retval = usb_register(&ipaq_driver);
52081 +       if (retval)
52082 +               goto failed_usb_register;
52083 +                 
52084         return 0;
52085 +failed_usb_register:
52086 +       usb_serial_deregister(&ipaq_device);
52087 +failed_usb_serial_register:
52088 +       return retval;
52089  }
52090  
52091  
52092 diff -Nru a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
52093 --- a/drivers/usb/serial/ir-usb.c       Thu May 29 14:13:24 2003
52094 +++ b/drivers/usb/serial/ir-usb.c       Fri Aug 22 13:52:01 2003
52095 @@ -609,10 +609,19 @@
52096  
52097  static int __init ir_init (void)
52098  {
52099 -       usb_serial_register (&ir_device);
52100 -       usb_register (&ir_driver);
52101 +       int retval;
52102 +       retval = usb_serial_register(&ir_device);
52103 +       if (retval)
52104 +               goto failed_usb_serial_register;
52105 +       retval = usb_register(&ir_driver);
52106 +       if (retval) 
52107 +               goto failed_usb_register;
52108         info(DRIVER_DESC " " DRIVER_VERSION);
52109         return 0;
52110 +failed_usb_register:
52111 +       usb_serial_deregister(&ir_device);
52112 +failed_usb_serial_register:
52113 +       return retval;
52114  }
52115  
52116  
52117 diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
52118 --- a/drivers/usb/serial/keyspan.c      Wed Aug 13 03:06:57 2003
52119 +++ b/drivers/usb/serial/keyspan.c      Fri Aug 22 13:52:01 2003
52120 @@ -197,15 +197,36 @@
52121  /* Functions used by new usb-serial code. */
52122  static int __init keyspan_init (void)
52123  {
52124 -       usb_serial_register (&keyspan_pre_device);
52125 -       usb_serial_register (&keyspan_1port_device);
52126 -       usb_serial_register (&keyspan_2port_device);
52127 -       usb_serial_register (&keyspan_4port_device);
52128 -       usb_register (&keyspan_driver);
52129 +       int retval;
52130 +       retval = usb_serial_register(&keyspan_pre_device);
52131 +       if (retval)
52132 +               goto failed_pre_device_register;
52133 +       retval = usb_serial_register(&keyspan_1port_device);
52134 +       if (retval)
52135 +               goto failed_1port_device_register;
52136 +       retval = usb_serial_register(&keyspan_2port_device);
52137 +       if (retval)
52138 +               goto failed_2port_device_register;
52139 +       retval = usb_serial_register(&keyspan_4port_device);
52140 +       if (retval)
52141 +               goto failed_4port_device_register;
52142 +       retval = usb_register(&keyspan_driver);
52143 +       if (retval) 
52144 +               goto failed_usb_register;
52145  
52146         info(DRIVER_VERSION ":" DRIVER_DESC);
52147  
52148         return 0;
52149 +failed_usb_register:
52150 +       usb_serial_deregister(&keyspan_4port_device);
52151 +failed_4port_device_register:
52152 +       usb_serial_deregister(&keyspan_2port_device);
52153 +failed_2port_device_register:
52154 +       usb_serial_deregister(&keyspan_1port_device);
52155 +failed_1port_device_register:
52156 +       usb_serial_deregister(&keyspan_pre_device);
52157 +failed_pre_device_register:
52158 +       return retval;
52159  }
52160  
52161  static void __exit keyspan_exit (void)
52162 diff -Nru a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
52163 --- a/drivers/usb/serial/keyspan_pda.c  Wed Aug 13 03:06:57 2003
52164 +++ b/drivers/usb/serial/keyspan_pda.c  Wed Aug 27 04:45:14 2003
52165 @@ -1,9 +1,9 @@
52166  /*
52167   * USB Keyspan PDA / Xircom / Entregra Converter driver
52168   *
52169 - * Copyright (c) 1999 - 2001 Greg Kroah-Hartman        <greg@kroah.com>
52170 - * Copyright (c) 1999, 2000 Brian Warner       <warner@lothar.com>
52171 - * Copyright (c) 2000 Al Borchers              <borchers@steinerpoint.com>
52172 + * Copyright (C) 1999 - 2001 Greg Kroah-Hartman        <greg@kroah.com>
52173 + * Copyright (C) 1999, 2000 Brian Warner       <warner@lothar.com>
52174 + * Copyright (C) 2000 Al Borchers              <borchers@steinerpoint.com>
52175   *
52176   *     This program is free software; you can redistribute it and/or modify
52177   *     it under the terms of the GNU General Public License as published by
52178 @@ -876,16 +876,39 @@
52179  
52180  static int __init keyspan_pda_init (void)
52181  {
52182 -       usb_serial_register (&keyspan_pda_device);
52183 +       int retval;
52184 +       retval = usb_serial_register(&keyspan_pda_device);
52185 +       if (retval)
52186 +               goto failed_pda_register;
52187  #ifdef KEYSPAN
52188 -       usb_serial_register (&keyspan_pda_fake_device);
52189 +       retval = usb_serial_register(&keyspan_pda_fake_device);
52190 +       if (retval)
52191 +               goto failed_pda_fake_register;
52192  #endif
52193  #ifdef XIRCOM
52194 -       usb_serial_register (&xircom_pgs_fake_device);
52195 -#endif
52196 -       usb_register (&keyspan_pda_driver);
52197 +       retval = usb_serial_register(&xircom_pgs_fake_device);
52198 +       if (retval)
52199 +               goto failed_xircom_register;
52200 +#endif
52201 +       retval = usb_register(&keyspan_pda_driver);
52202 +       if (retval)
52203 +               goto failed_usb_register;
52204         info(DRIVER_DESC " " DRIVER_VERSION);
52205         return 0;
52206 +failed_usb_register:   
52207 +#ifdef XIRCOM
52208 +       usb_serial_deregister(&xircom_pgs_fake_device);
52209 +failed_xircom_register:
52210 +#endif /* XIRCOM */
52211 +#ifdef KEYSPAN
52212 +       usb_serial_deregister(&keyspan_pda_fake_device);
52213 +#endif
52214 +#ifdef KEYSPAN
52215 +failed_pda_fake_register:
52216 +#endif
52217 +       usb_serial_deregister(&keyspan_pda_device);
52218 +failed_pda_register:
52219 +       return retval;
52220  }
52221  
52222  
52223 diff -Nru a/drivers/usb/serial/keyspan_pda_fw.h b/drivers/usb/serial/keyspan_pda_fw.h
52224 --- a/drivers/usb/serial/keyspan_pda_fw.h       Mon Feb  4 23:40:21 2002
52225 +++ b/drivers/usb/serial/keyspan_pda_fw.h       Wed Aug 27 04:45:14 2003
52226 @@ -1,7 +1,7 @@
52227  /*
52228   * USB Keyspan PDA Firmware
52229   *
52230 - * Copyright (c) 1999, 2000 Brian Warner       <warner@lothar.com>
52231 + * Copyright (C) 1999, 2000 Brian Warner       <warner@lothar.com>
52232   *
52233   *     This program is free software; you can redistribute it and/or modify
52234   *     it under the terms of the GNU General Public License as published by
52235 diff -Nru a/drivers/usb/serial/keyspan_usa26msg.h b/drivers/usb/serial/keyspan_usa26msg.h
52236 --- a/drivers/usb/serial/keyspan_usa26msg.h     Thu Mar 13 10:36:02 2003
52237 +++ b/drivers/usb/serial/keyspan_usa26msg.h     Wed Aug 27 04:45:13 2003
52238 @@ -1,7 +1,7 @@
52239  /*
52240         usa26msg.h
52241  
52242 -       Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52243 +       Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52244         This file is available under a BSD-style copyright
52245  
52246         Keyspan USB Async Firmware to run on Anchor EZ-USB
52247 @@ -15,7 +15,7 @@
52248         disclaimer.  The following copyright notice must appear immediately at
52249         the beginning of all source files:
52250  
52251 -               Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52252 +               Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52253  
52254                 This file is available under a BSD-style copyright
52255  
52256 diff -Nru a/drivers/usb/serial/keyspan_usa28msg.h b/drivers/usb/serial/keyspan_usa28msg.h
52257 --- a/drivers/usb/serial/keyspan_usa28msg.h     Thu Mar 13 10:36:02 2003
52258 +++ b/drivers/usb/serial/keyspan_usa28msg.h     Wed Aug 27 04:45:14 2003
52259 @@ -1,7 +1,7 @@
52260  /*
52261         usa28msg.h
52262  
52263 -       Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52264 +       Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52265         This file is available under a BSD-style copyright
52266  
52267         Keyspan USB Async Firmware to run on Anchor EZ-USB
52268 @@ -15,7 +15,7 @@
52269         disclaimer.  The following copyright notice must appear immediately at
52270         the beginning of all source files:
52271  
52272 -               Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52273 +               Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52274  
52275                 This file is available under a BSD-style copyright
52276  
52277 diff -Nru a/drivers/usb/serial/keyspan_usa49msg.h b/drivers/usb/serial/keyspan_usa49msg.h
52278 --- a/drivers/usb/serial/keyspan_usa49msg.h     Thu Mar 13 10:36:02 2003
52279 +++ b/drivers/usb/serial/keyspan_usa49msg.h     Wed Aug 27 04:45:14 2003
52280 @@ -1,7 +1,7 @@
52281  /*
52282         usa49msg.h
52283  
52284 -       Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52285 +       Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52286         This file is available under a BSD-style copyright
52287  
52288         Keyspan USB Async Firmware to run on Anchor EZ-USB
52289 @@ -15,7 +15,7 @@
52290         disclaimer.  The following copyright notice must appear immediately at
52291         the beginning of all source files:
52292  
52293 -               Copyright (c) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52294 +               Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
52295  
52296                 This file is available under a BSD-style copyright
52297  
52298 diff -Nru a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
52299 --- a/drivers/usb/serial/kl5kusb105.c   Wed Aug 13 03:06:57 2003
52300 +++ b/drivers/usb/serial/kl5kusb105.c   Fri Aug 22 13:52:01 2003
52301 @@ -1037,11 +1037,20 @@
52302  
52303  static int __init klsi_105_init (void)
52304  {
52305 -       usb_serial_register (&kl5kusb105d_device);
52306 -       usb_register (&kl5kusb105d_driver);
52307 +       int retval;
52308 +       retval = usb_serial_register(&kl5kusb105d_device);
52309 +       if (retval)
52310 +               goto failed_usb_serial_register;
52311 +       retval = usb_register(&kl5kusb105d_driver);
52312 +       if (retval)
52313 +               goto failed_usb_register;
52314  
52315         info(DRIVER_DESC " " DRIVER_VERSION);
52316         return 0;
52317 +failed_usb_register:
52318 +       usb_serial_deregister(&kl5kusb105d_device);
52319 +failed_usb_serial_register:
52320 +       return retval;
52321  }
52322  
52323  
52324 diff -Nru a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
52325 --- a/drivers/usb/serial/kobil_sct.c    Wed Aug 13 03:06:57 2003
52326 +++ b/drivers/usb/serial/kobil_sct.c    Fri Aug 22 13:52:01 2003
52327 @@ -743,13 +743,22 @@
52328  
52329  static int __init kobil_init (void)
52330  {
52331 -       usb_serial_register (&kobil_device);
52332 -       usb_register (&kobil_driver);
52333 +       int retval;
52334 +       retval = usb_serial_register(&kobil_device);
52335 +       if (retval)
52336 +               goto failed_usb_serial_register;
52337 +       retval = usb_register(&kobil_driver);
52338 +       if (retval) 
52339 +               goto failed_usb_register;
52340  
52341         info(DRIVER_VERSION " " DRIVER_AUTHOR);
52342         info(DRIVER_DESC);
52343  
52344         return 0;
52345 +failed_usb_register:
52346 +       usb_serial_deregister(&kobil_device);
52347 +failed_usb_serial_register:
52348 +       return retval;
52349  }
52350  
52351  
52352 diff -Nru a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
52353 --- a/drivers/usb/serial/mct_u232.c     Wed Aug 13 03:06:57 2003
52354 +++ b/drivers/usb/serial/mct_u232.c     Fri Aug 22 13:52:01 2003
52355 @@ -850,10 +850,19 @@
52356  
52357  static int __init mct_u232_init (void)
52358  {
52359 -       usb_serial_register (&mct_u232_device);
52360 -       usb_register (&mct_u232_driver);
52361 +       int retval;
52362 +       retval = usb_serial_register(&mct_u232_device);
52363 +       if (retval)
52364 +               goto failed_usb_serial_register;
52365 +       retval = usb_register(&mct_u232_driver);
52366 +       if (retval)
52367 +               goto failed_usb_register;
52368         info(DRIVER_DESC " " DRIVER_VERSION);
52369         return 0;
52370 +failed_usb_register:
52371 +       usb_serial_deregister(&mct_u232_device);
52372 +failed_usb_serial_register:
52373 +       return retval;
52374  }
52375  
52376  
52377 diff -Nru a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
52378 --- a/drivers/usb/serial/omninet.c      Wed Aug 13 03:06:57 2003
52379 +++ b/drivers/usb/serial/omninet.c      Fri Aug 22 13:52:01 2003
52380 @@ -375,10 +375,19 @@
52381  
52382  static int __init omninet_init (void)
52383  {
52384 -       usb_serial_register (&zyxel_omninet_device);
52385 -       usb_register (&omninet_driver);
52386 +       int retval;
52387 +       retval = usb_serial_register(&zyxel_omninet_device);
52388 +       if (retval)
52389 +               goto failed_usb_serial_register;
52390 +       retval = usb_register(&omninet_driver);
52391 +       if (retval)
52392 +               goto failed_usb_register;
52393         info(DRIVER_VERSION ":" DRIVER_DESC);
52394         return 0;
52395 +failed_usb_register:
52396 +       usb_serial_deregister(&zyxel_omninet_device);
52397 +failed_usb_serial_register:
52398 +       return retval;
52399  }
52400  
52401  
52402 diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
52403 --- a/drivers/usb/serial/pl2303.c       Wed Aug 13 03:06:57 2003
52404 +++ b/drivers/usb/serial/pl2303.c       Fri Aug 22 13:52:01 2003
52405 @@ -768,10 +768,19 @@
52406  
52407  static int __init pl2303_init (void)
52408  {
52409 -       usb_serial_register (&pl2303_device);
52410 -       usb_register (&pl2303_driver);
52411 +       int retval;
52412 +       retval = usb_serial_register(&pl2303_device);
52413 +       if (retval)
52414 +               goto failed_usb_serial_register;
52415 +       retval = usb_register(&pl2303_driver);
52416 +       if (retval)
52417 +               goto failed_usb_register;
52418         info(DRIVER_DESC " " DRIVER_VERSION);
52419         return 0;
52420 +failed_usb_register:
52421 +       usb_serial_deregister(&pl2303_device);
52422 +failed_usb_serial_register:
52423 +       return retval;
52424  }
52425  
52426  
52427 diff -Nru a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
52428 --- a/drivers/usb/serial/safe_serial.c  Thu May 29 14:53:27 2003
52429 +++ b/drivers/usb/serial/safe_serial.c  Wed Aug 27 04:45:14 2003
52430 @@ -1,8 +1,8 @@
52431  /*
52432   * Safe Encapsulated USB Serial Driver
52433   *
52434 - *      Copyright (c) 2001 Lineo
52435 - *      Copyright (c) 2001 Hewlett-Packard
52436 + *      Copyright (C) 2001 Lineo
52437 + *      Copyright (C) 2001 Hewlett-Packard
52438   *
52439   *     This program is free software; you can redistribute it and/or modify
52440   *     it under the terms of the GNU General Public License as published by
52441 @@ -422,7 +422,7 @@
52442  
52443  static int __init safe_init (void)
52444  {
52445 -       int i;
52446 +       int i, retval;
52447  
52448         info (DRIVER_VERSION " " DRIVER_AUTHOR);
52449         info (DRIVER_DESC);
52450 @@ -441,10 +441,18 @@
52451                 }
52452         }
52453  
52454 -       usb_serial_register (&safe_device);
52455 -       usb_register (&safe_driver);
52456 +       retval = usb_serial_register(&safe_device);
52457 +       if (retval)
52458 +               goto failed_usb_serial_register;
52459 +       retval = usb_register(&safe_driver);
52460 +       if (retval)
52461 +               goto failed_usb_register;
52462  
52463         return 0;
52464 +failed_usb_register:
52465 +       usb_serial_deregister(&safe_device);
52466 +failed_usb_serial_register:
52467 +       return retval;
52468  }
52469  
52470  static void __exit safe_exit (void)
52471 diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
52472 --- a/drivers/usb/serial/usb-serial.c   Thu Aug 14 15:51:23 2003
52473 +++ b/drivers/usb/serial/usb-serial.c   Fri Aug 29 06:39:11 2003
52474 @@ -2,8 +2,8 @@
52475   * USB Serial Converter driver
52476   *
52477   * Copyright (C) 1999 - 2003 Greg Kroah-Hartman (greg@kroah.com)
52478 - * Copyright (c) 2000 Peter Berger (pberger@brimson.com)
52479 - * Copyright (c) 2000 Al Borchers (borchers@steinerpoint.com)
52480 + * Copyright (C) 2000 Peter Berger (pberger@brimson.com)
52481 + * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com)
52482   *
52483   *     This program is free software; you can redistribute it and/or
52484   *     modify it under the terms of the GNU General Public License version
52485 @@ -871,7 +871,8 @@
52486  
52487         /* the ports are cleaned up and released in port_release() */
52488         for (i = 0; i < serial->num_ports; ++i)
52489 -               device_unregister(&serial->port[i]->dev);
52490 +               if (serial->port[i]->dev.parent != NULL)
52491 +                       device_unregister(&serial->port[i]->dev);
52492  
52493         /* If this is a "fake" port, we have to clean it up here, as it will
52494          * not get cleaned up in port_release() as it was never registered with
52495 diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
52496 --- a/drivers/usb/serial/visor.c        Wed Aug 13 03:06:57 2003
52497 +++ b/drivers/usb/serial/visor.c        Thu Aug 28 06:49:27 2003
52498 @@ -225,11 +225,16 @@
52499                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
52500         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_S360_ID),
52501                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
52502 -       { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID) },
52503 +       { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID),
52504 +               .driver_info = (kernel_ulong_t)&palm_os_4_probe },
52505         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NX60_ID),
52506                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
52507         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NZ90V_ID),
52508                 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
52509 +       { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), 
52510 +               .driver_info = (kernel_ulong_t)&palm_os_4_probe },
52511 +       { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), 
52512 +               .driver_info = (kernel_ulong_t)&palm_os_4_probe },
52513         { },                                    /* optional parameter entry */
52514         { }                                     /* Terminating entry */
52515  };
52516 @@ -258,6 +263,8 @@
52517         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_4_1_ID) },
52518         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NX60_ID) },
52519         { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_NZ90V_ID) },
52520 +       { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID) },
52521 +       { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID) },
52522         { },                                    /* optional parameter entry */
52523         { }                                     /* Terminating entry */
52524  };
52525 @@ -649,7 +656,7 @@
52526  
52527         transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL);
52528         if (!transfer_buffer) {
52529 -               dev_err(dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__,
52530 +               dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__,
52531                         sizeof(*connection_info));
52532                 return -ENOMEM;
52533         }
52534 @@ -735,7 +742,7 @@
52535  
52536         transfer_buffer =  kmalloc (sizeof (*connection_info), GFP_KERNEL);
52537         if (!transfer_buffer) {
52538 -               dev_err(dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__,
52539 +               dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __FUNCTION__,
52540                         sizeof(*connection_info));
52541                 return -ENOMEM;
52542         }
52543 @@ -956,7 +963,7 @@
52544  
52545  static int __init visor_init (void)
52546  {
52547 -       int i;
52548 +       int i, retval;
52549         /* Only if parameters were passed to us */
52550         if ((vendor>0) && (product>0)) {
52551                 struct usb_device_id usb_dev_temp[]=
52552 @@ -983,12 +990,24 @@
52553                 info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
52554                         vendor, product);
52555         }
52556 -       usb_serial_register (&handspring_device);
52557 -       usb_serial_register (&clie_3_5_device);
52558 -       usb_register (&visor_driver);
52559 +       retval = usb_serial_register(&handspring_device);
52560 +       if (retval)
52561 +               goto failed_handspring_register;
52562 +       retval = usb_serial_register(&clie_3_5_device);
52563 +       if (retval)
52564 +               goto failed_clie_3_5_register;
52565 +       retval = usb_register(&visor_driver);
52566 +       if (retval) 
52567 +               goto failed_usb_register;
52568         info(DRIVER_DESC " " DRIVER_VERSION);
52569  
52570         return 0;
52571 +failed_usb_register:
52572 +       usb_serial_deregister(&clie_3_5_device);
52573 +failed_clie_3_5_register:
52574 +       usb_serial_deregister(&handspring_device);
52575 +failed_handspring_register:
52576 +       return retval;
52577  }
52578  
52579  
52580 diff -Nru a/drivers/usb/serial/visor.h b/drivers/usb/serial/visor.h
52581 --- a/drivers/usb/serial/visor.h        Wed May  7 04:49:36 2003
52582 +++ b/drivers/usb/serial/visor.h        Thu Aug 28 06:49:27 2003
52583 @@ -41,6 +41,12 @@
52584  #define SONY_CLIE_NX60_ID              0x00DA
52585  #define SONY_CLIE_NZ90V_ID             0x00E9
52586  
52587 +#define SAMSUNG_VENDOR_ID              0x04E8
52588 +#define SAMSUNG_SCH_I330_ID            0x8001
52589 +
52590 +#define GARMIN_VENDOR_ID               0x091E
52591 +#define GARMIN_IQUE_3600_ID            0x0004
52592 +
52593  /****************************************************************************
52594   * Handspring Visor Vendor specific request codes (bRequest values)
52595   * A big thank you to Handspring for providing the following information.
52596 diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
52597 --- a/drivers/usb/serial/whiteheat.c    Wed Aug 13 03:06:57 2003
52598 +++ b/drivers/usb/serial/whiteheat.c    Fri Aug 22 13:52:01 2003
52599 @@ -1486,11 +1486,24 @@
52600   *****************************************************************************/
52601  static int __init whiteheat_init (void)
52602  {
52603 -       usb_serial_register (&whiteheat_fake_device);
52604 -       usb_serial_register (&whiteheat_device);
52605 -       usb_register (&whiteheat_driver);
52606 +       int retval;
52607 +       retval = usb_serial_register(&whiteheat_fake_device);
52608 +       if (retval)
52609 +               goto failed_fake_register;
52610 +       retval = usb_serial_register(&whiteheat_device);
52611 +       if (retval)
52612 +               goto failed_device_register;
52613 +       retval = usb_register(&whiteheat_driver);
52614 +       if (retval)
52615 +               goto failed_usb_register;
52616         info(DRIVER_DESC " " DRIVER_VERSION);
52617         return 0;
52618 +failed_usb_register:
52619 +       usb_serial_deregister(&whiteheat_device);
52620 +failed_device_register:
52621 +       usb_serial_deregister(&whiteheat_fake_device);
52622 +failed_fake_register:
52623 +       return retval;
52624  }
52625  
52626  
52627 diff -Nru a/drivers/usb/serial/xircom_pgs_fw.h b/drivers/usb/serial/xircom_pgs_fw.h
52628 --- a/drivers/usb/serial/xircom_pgs_fw.h        Mon Feb  4 23:49:26 2002
52629 +++ b/drivers/usb/serial/xircom_pgs_fw.h        Wed Aug 27 04:45:14 2003
52630 @@ -1,8 +1,8 @@
52631  /*
52632   * USB Xircom PGS Firmware
52633   *
52634 - * Copyright (c) 1999, 2000 Brian Warner        <warner@lothar.com>
52635 - * Copyright (c) 2001 Cristian M. Craciunescu  <cristi@dnt.ro>
52636 + * Copyright (C) 1999, 2000 Brian Warner        <warner@lothar.com>
52637 + * Copyright (C) 2001 Cristian M. Craciunescu  <cristi@dnt.ro>
52638   *
52639   *      This program is free software; you can redistribute it and/or modify
52640   *      it under the terms of the GNU General Public License as published by
52641 diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
52642 --- a/drivers/usb/storage/isd200.c      Sun Jul 13 18:02:23 2003
52643 +++ b/drivers/usb/storage/isd200.c      Tue Sep  2 10:47:41 2003
52644 @@ -272,8 +272,9 @@
52645  
52646  struct isd200_info {
52647         struct inquiry_data InquiryData;
52648 -       struct hd_driveid drive;
52649 +       struct hd_driveid *id;
52650         struct isd200_config ConfigData;
52651 +       unsigned char *RegsBuf;
52652         unsigned char ATARegs[8];
52653         unsigned char DeviceHead;
52654         unsigned char DeviceFlags;
52655 @@ -473,7 +474,7 @@
52656                 ata.generic.RegisterSelect = REG_COMMAND;
52657                 ata.write.CommandByte = WIN_IDENTIFY;
52658                 srb->sc_data_direction = SCSI_DATA_READ;
52659 -               srb->request_buffer = (void *)&info->drive;
52660 +               srb->request_buffer = (void *) info->id;
52661                 srb->request_bufflen = sizeof(struct hd_driveid);
52662                 break;
52663  
52664 @@ -513,11 +514,12 @@
52665         US_DEBUGP("Entering isd200_IssueATAReadRegs\n");
52666  
52667         transferStatus = isd200_action( us, ACTION_READ_STATUS,
52668 -                                   info->ATARegs, sizeof(info->ATARegs) );
52669 +                                   info->RegsBuf, sizeof(info->ATARegs) );
52670         if (transferStatus != ISD200_TRANSPORT_GOOD) {
52671                 US_DEBUGP("   Error reading ATA registers\n");
52672                 retStatus = ISD200_ERROR;
52673         } else {
52674 +               memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs));
52675                 US_DEBUGP("   Got ATA Register[IDE_ERROR_OFFSET] = 0x%x\n", 
52676                           info->ATARegs[IDE_ERROR_OFFSET]);
52677         }
52678 @@ -835,9 +837,9 @@
52679                            int detect )
52680  {
52681         int status = ISD200_GOOD;
52682 -       unsigned char *regs = us->iobuf;
52683         unsigned long endTime;
52684         struct isd200_info *info = (struct isd200_info *)us->extra;
52685 +       unsigned char *regs = info->RegsBuf;
52686         int recheckAsMaster = FALSE;
52687  
52688         if ( detect )
52689 @@ -984,6 +986,7 @@
52690  {
52691         struct isd200_info *info = (struct isd200_info *)us->extra;
52692         int retStatus = ISD200_GOOD;
52693 +       struct hd_driveid *id = info->id;
52694  
52695         US_DEBUGP("Entering isd200_get_inquiry_data\n");
52696  
52697 @@ -1000,7 +1003,7 @@
52698                         /* this must be an ATA device */
52699                         /* perform an ATA Command Identify */
52700                         transferStatus = isd200_action( us, ACTION_IDENTIFY,
52701 -                                                       &info->drive, 
52702 +                                                       id, 
52703                                                         sizeof(struct hd_driveid) );
52704                         if (transferStatus != ISD200_TRANSPORT_GOOD) {
52705                                 /* Error issuing ATA Command Identify */
52706 @@ -1010,35 +1013,35 @@
52707                                 /* ATA Command Identify successful */
52708                                 int i;
52709                                 __u16 *src, *dest;
52710 -                               ide_fix_driveid(&info->drive);
52711 +                               ide_fix_driveid(id);
52712  
52713                                 US_DEBUGP("   Identify Data Structure:\n");
52714 -                               US_DEBUGP("      config = 0x%x\n", info->drive.config);
52715 -                               US_DEBUGP("      cyls = 0x%x\n", info->drive.cyls);
52716 -                               US_DEBUGP("      heads = 0x%x\n", info->drive.heads);
52717 -                               US_DEBUGP("      track_bytes = 0x%x\n", info->drive.track_bytes);
52718 -                               US_DEBUGP("      sector_bytes = 0x%x\n", info->drive.sector_bytes);
52719 -                               US_DEBUGP("      sectors = 0x%x\n", info->drive.sectors);
52720 -                               US_DEBUGP("      serial_no[0] = 0x%x\n", info->drive.serial_no[0]);
52721 -                               US_DEBUGP("      buf_type = 0x%x\n", info->drive.buf_type);
52722 -                               US_DEBUGP("      buf_size = 0x%x\n", info->drive.buf_size);
52723 -                               US_DEBUGP("      ecc_bytes = 0x%x\n", info->drive.ecc_bytes);
52724 -                               US_DEBUGP("      fw_rev[0] = 0x%x\n", info->drive.fw_rev[0]);
52725 -                               US_DEBUGP("      model[0] = 0x%x\n", info->drive.model[0]);
52726 -                               US_DEBUGP("      max_multsect = 0x%x\n", info->drive.max_multsect);
52727 -                               US_DEBUGP("      dword_io = 0x%x\n", info->drive.dword_io);
52728 -                               US_DEBUGP("      capability = 0x%x\n", info->drive.capability);
52729 -                               US_DEBUGP("      tPIO = 0x%x\n", info->drive.tPIO);
52730 -                               US_DEBUGP("      tDMA = 0x%x\n", info->drive.tDMA);
52731 -                               US_DEBUGP("      field_valid = 0x%x\n", info->drive.field_valid);
52732 -                               US_DEBUGP("      cur_cyls = 0x%x\n", info->drive.cur_cyls);
52733 -                               US_DEBUGP("      cur_heads = 0x%x\n", info->drive.cur_heads);
52734 -                               US_DEBUGP("      cur_sectors = 0x%x\n", info->drive.cur_sectors);
52735 -                               US_DEBUGP("      cur_capacity = 0x%x\n", (info->drive.cur_capacity1 << 16) + info->drive.cur_capacity0 );
52736 -                               US_DEBUGP("      multsect = 0x%x\n", info->drive.multsect);
52737 -                               US_DEBUGP("      lba_capacity = 0x%x\n", info->drive.lba_capacity);
52738 -                               US_DEBUGP("      command_set_1 = 0x%x\n", info->drive.command_set_1);
52739 -                               US_DEBUGP("      command_set_2 = 0x%x\n", info->drive.command_set_2);
52740 +                               US_DEBUGP("      config = 0x%x\n", id->config);
52741 +                               US_DEBUGP("      cyls = 0x%x\n", id->cyls);
52742 +                               US_DEBUGP("      heads = 0x%x\n", id->heads);
52743 +                               US_DEBUGP("      track_bytes = 0x%x\n", id->track_bytes);
52744 +                               US_DEBUGP("      sector_bytes = 0x%x\n", id->sector_bytes);
52745 +                               US_DEBUGP("      sectors = 0x%x\n", id->sectors);
52746 +                               US_DEBUGP("      serial_no[0] = 0x%x\n", id->serial_no[0]);
52747 +                               US_DEBUGP("      buf_type = 0x%x\n", id->buf_type);
52748 +                               US_DEBUGP("      buf_size = 0x%x\n", id->buf_size);
52749 +                               US_DEBUGP("      ecc_bytes = 0x%x\n", id->ecc_bytes);
52750 +                               US_DEBUGP("      fw_rev[0] = 0x%x\n", id->fw_rev[0]);
52751 +                               US_DEBUGP("      model[0] = 0x%x\n", id->model[0]);
52752 +                               US_DEBUGP("      max_multsect = 0x%x\n", id->max_multsect);
52753 +                               US_DEBUGP("      dword_io = 0x%x\n", id->dword_io);
52754 +                               US_DEBUGP("      capability = 0x%x\n", id->capability);
52755 +                               US_DEBUGP("      tPIO = 0x%x\n", id->tPIO);
52756 +                               US_DEBUGP("      tDMA = 0x%x\n", id->tDMA);
52757 +                               US_DEBUGP("      field_valid = 0x%x\n", id->field_valid);
52758 +                               US_DEBUGP("      cur_cyls = 0x%x\n", id->cur_cyls);
52759 +                               US_DEBUGP("      cur_heads = 0x%x\n", id->cur_heads);
52760 +                               US_DEBUGP("      cur_sectors = 0x%x\n", id->cur_sectors);
52761 +                               US_DEBUGP("      cur_capacity = 0x%x\n", (id->cur_capacity1 << 16) + id->cur_capacity0 );
52762 +                               US_DEBUGP("      multsect = 0x%x\n", id->multsect);
52763 +                               US_DEBUGP("      lba_capacity = 0x%x\n", id->lba_capacity);
52764 +                               US_DEBUGP("      command_set_1 = 0x%x\n", id->command_set_1);
52765 +                               US_DEBUGP("      command_set_2 = 0x%x\n", id->command_set_2);
52766  
52767                                 memset(&info->InquiryData, 0, sizeof(info->InquiryData));
52768  
52769 @@ -1054,30 +1057,30 @@
52770                                 /* The length must be at least 36 (5 + 31) */
52771                                 info->InquiryData.AdditionalLength = 0x1F;
52772  
52773 -                               if (info->drive.command_set_1 & COMMANDSET_MEDIA_STATUS) {
52774 +                               if (id->command_set_1 & COMMANDSET_MEDIA_STATUS) {
52775                                         /* set the removable bit */
52776                                         info->InquiryData.DeviceTypeModifier = DEVICE_REMOVABLE;
52777                                         info->DeviceFlags |= DF_REMOVABLE_MEDIA;
52778                                 }
52779  
52780                                 /* Fill in vendor identification fields */
52781 -                               src = (__u16*)info->drive.model;
52782 +                               src = (__u16*)id->model;
52783                                 dest = (__u16*)info->InquiryData.VendorId;
52784                                 for (i=0;i<4;i++)
52785                                         dest[i] = be16_to_cpu(src[i]);
52786  
52787 -                               src = (__u16*)(info->drive.model+8);
52788 +                               src = (__u16*)(id->model+8);
52789                                 dest = (__u16*)info->InquiryData.ProductId;
52790                                 for (i=0;i<8;i++)
52791                                         dest[i] = be16_to_cpu(src[i]);
52792  
52793 -                               src = (__u16*)info->drive.fw_rev;
52794 +                               src = (__u16*)id->fw_rev;
52795                                 dest = (__u16*)info->InquiryData.ProductRevisionLevel;
52796                                 for (i=0;i<2;i++)
52797                                         dest[i] = be16_to_cpu(src[i]);
52798  
52799                                 /* determine if it supports Media Status Notification */
52800 -                               if (info->drive.command_set_2 & COMMANDSET_MEDIA_STATUS) {
52801 +                               if (id->command_set_2 & COMMANDSET_MEDIA_STATUS) {
52802                                         US_DEBUGP("   Device supports Media Status Notification\n");
52803  
52804                                         /* Indicate that it is enabled, even though it is not
52805 @@ -1101,11 +1104,9 @@
52806                         US_DEBUGP("Protocol changed to: %s\n", us->protocol_name);
52807             
52808                         /* Free driver structure */         
52809 -                       if (us->extra != NULL) {
52810 -                               kfree(us->extra);
52811 -                               us->extra = NULL;
52812 -                               us->extra_destructor = NULL;
52813 -                       }
52814 +                       us->extra_destructor(info);
52815 +                       us->extra = NULL;
52816 +                       us->extra_destructor = NULL;
52817                 }
52818         }
52819  
52820 @@ -1182,6 +1183,7 @@
52821                        union ata_cdb * ataCdb)
52822  {
52823         struct isd200_info *info = (struct isd200_info *)us->extra;
52824 +       struct hd_driveid *id = info->id;
52825         int sendToTransport = TRUE;
52826         unsigned char sectnum, head;
52827         unsigned short cylinder;
52828 @@ -1254,12 +1256,12 @@
52829  
52830                 US_DEBUGP("   ATA OUT - SCSIOP_READ_CAPACITY\n");
52831  
52832 -               if (info->drive.capability & CAPABILITY_LBA ) {
52833 -                       capacity = info->drive.lba_capacity - 1;
52834 +               if (id->capability & CAPABILITY_LBA ) {
52835 +                       capacity = id->lba_capacity - 1;
52836                 } else {
52837 -                       capacity = (info->drive.heads *
52838 -                                   info->drive.cyls *
52839 -                                   info->drive.sectors) - 1;
52840 +                       capacity = (id->heads *
52841 +                                   id->cyls *
52842 +                                   id->sectors) - 1;
52843                 }
52844                 readCapacityData.LogicalBlockAddress = cpu_to_be32(capacity);
52845                 readCapacityData.BytesPerBlock = cpu_to_be32(0x200);
52846 @@ -1280,16 +1282,16 @@
52847                 lba = cpu_to_be32(lba);
52848                 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8];
52849  
52850 -               if (info->drive.capability & CAPABILITY_LBA) {
52851 +               if (id->capability & CAPABILITY_LBA) {
52852                         sectnum = (unsigned char)(lba);
52853                         cylinder = (unsigned short)(lba>>8);
52854                         head = ATA_ADDRESS_DEVHEAD_LBA_MODE | (unsigned char)(lba>>24 & 0x0F);
52855                 } else {
52856 -                       sectnum = (unsigned char)((lba % info->drive.sectors) + 1);
52857 -                       cylinder = (unsigned short)(lba / (info->drive.sectors *
52858 -                                                          info->drive.heads));
52859 -                       head = (unsigned char)((lba / info->drive.sectors) %
52860 -                                              info->drive.heads);
52861 +                       sectnum = (unsigned char)((lba % id->sectors) + 1);
52862 +                       cylinder = (unsigned short)(lba / (id->sectors *
52863 +                                                          id->heads));
52864 +                       head = (unsigned char)((lba / id->sectors) %
52865 +                                              id->heads);
52866                 }
52867                 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
52868                 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
52869 @@ -1313,14 +1315,14 @@
52870                 lba = cpu_to_be32(lba);
52871                 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8];
52872  
52873 -               if (info->drive.capability & CAPABILITY_LBA) {
52874 +               if (id->capability & CAPABILITY_LBA) {
52875                         sectnum = (unsigned char)(lba);
52876                         cylinder = (unsigned short)(lba>>8);
52877                         head = ATA_ADDRESS_DEVHEAD_LBA_MODE | (unsigned char)(lba>>24 & 0x0F);
52878                 } else {
52879 -                       sectnum = (unsigned char)((lba % info->drive.sectors) + 1);
52880 -                       cylinder = (unsigned short)(lba / (info->drive.sectors * info->drive.heads));
52881 -                       head = (unsigned char)((lba / info->drive.sectors) % info->drive.heads);
52882 +                       sectnum = (unsigned char)((lba % id->sectors) + 1);
52883 +                       cylinder = (unsigned short)(lba / (id->sectors * id->heads));
52884 +                       head = (unsigned char)((lba / id->sectors) % id->heads);
52885                 }
52886                 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
52887                 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
52888 @@ -1398,6 +1400,21 @@
52889  
52890  
52891  /**************************************************************************
52892 + * isd200_free_info
52893 + *
52894 + * Frees the driver structure.
52895 + */
52896 +void isd200_free_info_ptrs(void *info_)
52897 +{
52898 +       struct isd200_info *info = (struct isd200_info *) info_;
52899 +
52900 +       if (info) {
52901 +               kfree(info->id);
52902 +               kfree(info->RegsBuf);
52903 +       }
52904 +}
52905 +
52906 +/**************************************************************************
52907   * isd200_init_info
52908   *                                                                      
52909   * Allocates (if necessary) and initializes the driver structure.
52910 @@ -1408,18 +1425,31 @@
52911  int isd200_init_info(struct us_data *us)
52912  {
52913         int retStatus = ISD200_GOOD;
52914 +       struct isd200_info *info;
52915  
52916 -       if (!us->extra) {
52917 -               us->extra = (void *) kmalloc(sizeof(struct isd200_info), GFP_KERNEL);
52918 -               if (!us->extra) {
52919 -                       US_DEBUGP("ERROR - kmalloc failure\n");
52920 +       info = (struct isd200_info *)
52921 +                       kmalloc(sizeof(struct isd200_info), GFP_KERNEL);
52922 +       if (!info)
52923 +               retStatus = ISD200_ERROR;
52924 +       else {
52925 +               memset(info, 0, sizeof(struct isd200_info));
52926 +               info->id = (struct hd_driveid *)
52927 +                               kmalloc(sizeof(struct hd_driveid), GFP_KERNEL);
52928 +               info->RegsBuf = (unsigned char *)
52929 +                               kmalloc(sizeof(info->ATARegs), GFP_KERNEL);
52930 +               if (!info->id || !info->RegsBuf) {
52931 +                       isd200_free_info_ptrs(info);
52932 +                       kfree(info);
52933                         retStatus = ISD200_ERROR;
52934 -               }
52935 +               } else
52936 +                       memset(info->id, 0, sizeof(struct hd_driveid));
52937         }
52938  
52939         if (retStatus == ISD200_GOOD) {
52940 -               memset(us->extra, 0, sizeof(struct isd200_info));
52941 -       }
52942 +               us->extra = info;
52943 +               us->extra_destructor = isd200_free_info_ptrs;
52944 +       } else
52945 +               US_DEBUGP("ERROR - kmalloc failure\n");
52946  
52947         return(retStatus);
52948  }
52949 diff -Nru a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
52950 --- a/drivers/usb/storage/sddr09.c      Sat Aug 16 11:46:50 2003
52951 +++ b/drivers/usb/storage/sddr09.c      Thu Aug 21 20:31:46 2003
52952 @@ -34,6 +34,7 @@
52953  #include "debug.h"
52954  #include "sddr09.h"
52955  
52956 +#include <linux/version.h>
52957  #include <linux/sched.h>
52958  #include <linux/errno.h>
52959  #include <linux/slab.h>
52960 diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
52961 --- a/drivers/usb/storage/transport.c   Sat Jun 28 13:31:18 2003
52962 +++ b/drivers/usb/storage/transport.c   Tue Aug 19 14:34:50 2003
52963 @@ -942,11 +942,11 @@
52964         memcpy(bcb->CDB, srb->cmnd, bcb->Length);
52965  
52966         /* send it to out endpoint */
52967 -       US_DEBUGP("Bulk command S 0x%x T 0x%x Trg %d LUN %d L %d F %d CL %d\n",
52968 +       US_DEBUGP("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
52969                         le32_to_cpu(bcb->Signature), bcb->Tag,
52970 +                       le32_to_cpu(bcb->DataTransferLength), bcb->Flags,
52971                         (bcb->Lun >> 4), (bcb->Lun & 0x0F), 
52972 -                       le32_to_cpu(bcb->DataTransferLength),
52973 -                       bcb->Flags, bcb->Length);
52974 +                       bcb->Length);
52975         result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
52976                                 bcb, US_BULK_CB_WRAP_LEN, NULL);
52977         US_DEBUGP("Bulk command transfer result=%d\n", result);
52978 @@ -999,7 +999,7 @@
52979                 return USB_STOR_TRANSPORT_ERROR;
52980  
52981         /* check bulk status */
52982 -       US_DEBUGP("Bulk status Sig 0x%x T 0x%x R %d Stat 0x%x\n",
52983 +       US_DEBUGP("Bulk Status S 0x%x T 0x%x R %d Stat 0x%x\n",
52984                         le32_to_cpu(bcs->Signature), bcs->Tag, 
52985                         bcs->Residue, bcs->Status);
52986         if ((bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN) &&
52987 diff -Nru a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
52988 --- a/drivers/usb/storage/unusual_devs.h        Wed Aug  6 10:59:43 2003
52989 +++ b/drivers/usb/storage/unusual_devs.h        Wed Aug 27 03:03:51 2003
52990 @@ -264,7 +264,7 @@
52991  UNUSUAL_DEV(  0x054c, 0x002e, 0x0106, 0x0310, 
52992                 "Sony",
52993                 "Handycam",
52994 -               US_SC_SCSI, US_PR_CB, NULL,
52995 +               US_SC_SCSI, US_PR_DEVICE, NULL,
52996                 US_FL_SINGLE_LUN | US_FL_MODE_XLATE),
52997  
52998  UNUSUAL_DEV(  0x054c, 0x0032, 0x0000, 0x9999,
52999 diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
53000 --- a/drivers/usb/storage/usb.c Fri Aug 15 10:14:26 2003
53001 +++ b/drivers/usb/storage/usb.c Sat Aug 23 02:37:39 2003
53002 @@ -1006,20 +1006,23 @@
53003   * Initialization and registration
53004   ***********************************************************************/
53005  
53006 -int __init usb_stor_init(void)
53007 +static int __init usb_stor_init(void)
53008  {
53009 +       int retval;
53010         printk(KERN_INFO "Initializing USB Mass Storage driver...\n");
53011  
53012 -       /* register the driver, return -1 if error */
53013 -       if (usb_register(&usb_storage_driver) < 0)
53014 -               return -1;
53015 +       /* register the driver, return usb_register return code if error */
53016 +       retval = usb_register(&usb_storage_driver);
53017 +       if (retval)
53018 +               goto out;
53019  
53020         /* we're all set */
53021         printk(KERN_INFO "USB Mass Storage support registered.\n");
53022 -       return 0;
53023 +out:
53024 +       return retval;
53025  }
53026  
53027 -void __exit usb_stor_exit(void)
53028 +static void __exit usb_stor_exit(void)
53029  {
53030         US_DEBUGP("usb_stor_exit() called\n");
53031  
53032 diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
53033 --- a/drivers/usb/storage/usb.h Thu Jul 17 15:58:30 2003
53034 +++ b/drivers/usb/storage/usb.h Thu Aug 21 20:31:58 2003
53035 @@ -48,7 +48,6 @@
53036  #include <linux/blkdev.h>
53037  #include <linux/smp_lock.h>
53038  #include <linux/completion.h>
53039 -#include <linux/version.h>
53040  #include "scsi.h"
53041  #include "hosts.h"
53042  
53043 diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
53044 --- a/drivers/usb/usb-skeleton.c        Wed Aug  6 02:20:34 2003
53045 +++ b/drivers/usb/usb-skeleton.c        Tue Sep  2 11:40:27 2003
53046 @@ -1,7 +1,7 @@
53047  /*
53048   * USB Skeleton driver - 1.1
53049   *
53050 - * Copyright (c) 2001-2003 Greg Kroah-Hartman (greg@kroah.com)
53051 + * Copyright (C) 2001-2003 Greg Kroah-Hartman (greg@kroah.com)
53052   *
53053   *     This program is free software; you can redistribute it and/or
53054   *     modify it under the terms of the GNU General Public License as
53055 @@ -229,7 +229,7 @@
53056  
53057         dbg("%s", __FUNCTION__);
53058  
53059 -       subminor = minor (inode->i_rdev);
53060 +       subminor = iminor(inode);
53061  
53062         /* prevent disconnects */
53063         down (&disconnect_sem);
53064 @@ -295,7 +295,7 @@
53065         if (atomic_read (&dev->write_busy))
53066                 wait_for_completion (&dev->write_finished);
53067  
53068 -       dev->open = 0;
53069 +       --dev->open;
53070  
53071         if (!dev->present) {
53072                 /* the device was unplugged before the file was released */
53073 @@ -677,10 +677,10 @@
53074  
53075         /* register this driver with the USB subsystem */
53076         result = usb_register(&skel_driver);
53077 -       if (result < 0) {
53078 +       if (result) {
53079                 err("usb_register failed. Error number %d",
53080                     result);
53081 -               return -1;
53082 +               return result;
53083         }
53084  
53085         info(DRIVER_DESC " " DRIVER_VERSION);
53086 diff -Nru a/drivers/video/68328fb.c b/drivers/video/68328fb.c
53087 --- a/drivers/video/68328fb.c   Fri Dec  6 12:36:20 2002
53088 +++ b/drivers/video/68328fb.c   Sun Aug 31 16:14:08 2003
53089 @@ -401,12 +401,12 @@
53090                                                ((1<<(width))-1)) : 0))
53091  
53092  static struct fb_ops mc68328_fb_ops = {
53093 -       .owner:         THIS_MODULE,
53094 -       .fb_setcolreg:  mc68328fb_setcolreg,
53095 -       .fb_fillrect:   cfbfillrect,
53096 -       .fb_copyarea:   cfbcopyarea,
53097 -       .fb_imageblit:  cfbimgblt,
53098 -       .fb_cursor:     softcursor,
53099 +       .owner          = THIS_MODULE,
53100 +       .fb_setcolreg   = mc68328fb_setcolreg,
53101 +       .fb_fillrect    = cfbfillrect,
53102 +       .fb_copyarea    = cfbcopyarea,
53103 +       .fb_imageblit   = cfbimgblt,
53104 +       .fb_cursor      = softcursor,
53105  };
53106  
53107  
53108 diff -Nru a/drivers/video/Kconfig b/drivers/video/Kconfig
53109 --- a/drivers/video/Kconfig     Wed Jun  4 22:54:29 2003
53110 +++ b/drivers/video/Kconfig     Sun Aug 24 06:05:48 2003
53111 @@ -40,7 +40,7 @@
53112  
53113  config FB_CIRRUS
53114         tristate "Cirrus Logic support"
53115 -       depends on FB && (AMIGA || PCI)
53116 +       depends on FB && (AMIGA || PCI) && BROKEN
53117         ---help---
53118           This enables support for Cirrus Logic GD542x/543x based boards on
53119           Amiga: SD64, Piccolo, Picasso II/II+, Picasso IV, or EGS Spectrum.
53120 @@ -55,7 +55,7 @@
53121  
53122  config FB_PM2
53123         tristate "Permedia2 support"
53124 -       depends on FB && (AMIGA || PCI)
53125 +       depends on FB && (AMIGA || PCI) && BROKEN
53126         help
53127           This is the frame buffer device driver for the Permedia2 AGP frame
53128           buffer card from ASK, aka `Graphic Blaster Exxtreme'.  There is a
53129 @@ -802,7 +802,7 @@
53130  
53131  config FB_PM3
53132         tristate "Permedia3 support"
53133 -       depends on FB && PCI
53134 +       depends on FB && PCI && BROKEN
53135         help
53136           This is the frame buffer device driver for the 3DLabs Permedia3
53137           chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 &
53138 diff -Nru a/drivers/video/Makefile b/drivers/video/Makefile
53139 --- a/drivers/video/Makefile    Sun May 25 08:40:39 2003
53140 +++ b/drivers/video/Makefile    Sun Aug 24 08:05:27 2003
53141 @@ -24,8 +24,8 @@
53142  obj-$(CONFIG_FB_RADEON)                  += radeonfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
53143  obj-$(CONFIG_FB_NEOMAGIC)         += neofb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
53144  obj-$(CONFIG_FB_IGA)              += igafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
53145 -obj-$(CONFIG_FB_CONTROL)          += controlfb.o
53146 -obj-$(CONFIG_FB_PLATINUM)         += platinumfb.o
53147 +obj-$(CONFIG_FB_CONTROL)          += controlfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
53148 +obj-$(CONFIG_FB_PLATINUM)         += platinumfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
53149  obj-$(CONFIG_FB_VALKYRIE)         += valkyriefb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
53150  obj-$(CONFIG_FB_CT65550)          += chipsfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
53151  obj-$(CONFIG_FB_ANAKIN)           += anakinfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
53152 diff -Nru a/drivers/video/controlfb.c b/drivers/video/controlfb.c
53153 --- a/drivers/video/controlfb.c Thu Apr 24 03:30:41 2003
53154 +++ b/drivers/video/controlfb.c Sun Aug 24 06:15:21 2003
53155 @@ -475,7 +475,7 @@
53156  
53157         /* Apply default var */
53158         var.activate = FB_ACTIVATE_NOW;
53159 -       rc = fb_set_var(&var, &p->info);
53160 +       rc = fb_set_var(&p->info, &var);
53161         if (rc && (vmode != VMODE_640_480_60 || cmode != CMODE_8))
53162                 goto try_again;
53163  
53164 diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
53165 --- a/drivers/video/fbmem.c     Wed Jul 23 07:45:30 2003
53166 +++ b/drivers/video/fbmem.c     Tue Aug 26 09:25:41 2003
53167 @@ -768,7 +768,7 @@
53168  {
53169         unsigned long p = *ppos;
53170         struct inode *inode = file->f_dentry->d_inode;
53171 -       int fbidx = minor(inode->i_rdev);
53172 +       int fbidx = iminor(inode);
53173         struct fb_info *info = registered_fb[fbidx];
53174  
53175         if (!info || ! info->screen_base)
53176 @@ -802,7 +802,7 @@
53177  {
53178         unsigned long p = *ppos;
53179         struct inode *inode = file->f_dentry->d_inode;
53180 -       int fbidx = minor(inode->i_rdev);
53181 +       int fbidx = iminor(inode);
53182         struct fb_info *info = registered_fb[fbidx];
53183         int err;
53184  
53185 @@ -964,7 +964,7 @@
53186  fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
53187          unsigned long arg)
53188  {
53189 -       int fbidx = minor(inode->i_rdev);
53190 +       int fbidx = iminor(inode);
53191         struct fb_info *info = registered_fb[fbidx];
53192         struct fb_ops *fb = info->fbops;
53193         struct fb_var_screeninfo var;
53194 @@ -1050,7 +1050,7 @@
53195  static int 
53196  fb_mmap(struct file *file, struct vm_area_struct * vma)
53197  {
53198 -       int fbidx = minor(file->f_dentry->d_inode->i_rdev);
53199 +       int fbidx = iminor(file->f_dentry->d_inode);
53200         struct fb_info *info = registered_fb[fbidx];
53201         struct fb_ops *fb = info->fbops;
53202         unsigned long off;
53203 @@ -1149,7 +1149,7 @@
53204  static int
53205  fb_open(struct inode *inode, struct file *file)
53206  {
53207 -       int fbidx = minor(inode->i_rdev);
53208 +       int fbidx = iminor(inode);
53209         struct fb_info *info;
53210         int res = 0;
53211  
53212 @@ -1174,7 +1174,7 @@
53213  static int 
53214  fb_release(struct inode *inode, struct file *file)
53215  {
53216 -       int fbidx = minor(inode->i_rdev);
53217 +       int fbidx = iminor(inode);
53218         struct fb_info *info;
53219  
53220         lock_kernel();
53221 diff -Nru a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
53222 --- a/drivers/video/platinumfb.c        Thu Apr 24 03:30:41 2003
53223 +++ b/drivers/video/platinumfb.c        Sun Aug 24 07:51:47 2003
53224 @@ -35,6 +35,7 @@
53225  #include <asm/io.h>
53226  #include <asm/prom.h>
53227  #include <asm/pgtable.h>
53228 +#include <asm/of_device.h>
53229  
53230  #include "macmodes.h"
53231  #include "platinumfb.h"
53232 @@ -87,7 +88,6 @@
53233   * internal functions
53234   */
53235  
53236 -static void platinum_of_init(struct device_node *dp);
53237  static inline int platinum_vram_reqd(int video_mode, int color_mode);
53238  static int read_platinum_sense(struct fb_info_platinum *info);
53239  static void set_platinum_clock(struct fb_info_platinum *info);
53240 @@ -323,7 +323,7 @@
53241  /*
53242   * Set misc info vars for this driver
53243   */
53244 -static void __init platinum_init_info(struct fb_info *info, struct fb_info_platinum *p)
53245 +static void __devinit platinum_init_info(struct fb_info *info, struct fb_info_platinum *p)
53246  {
53247         /* Fill fb_info */
53248         info->par = &p->par;
53249 @@ -349,7 +349,7 @@
53250  }
53251  
53252  
53253 -static int __init init_platinum(struct fb_info_platinum *p)
53254 +static int __devinit platinum_init_fb(struct fb_info_platinum *p)
53255  {
53256         struct fb_var_screeninfo var;
53257         int sense, rc;
53258 @@ -399,126 +399,21 @@
53259         /* Apply default var */
53260         p->info.var = var;
53261         var.activate = FB_ACTIVATE_NOW;
53262 -       rc = fb_set_var(&var, &p->info);
53263 +       rc = fb_set_var(&p->info, &var);
53264         if (rc && (default_vmode != VMODE_640_480_60 || default_cmode != CMODE_8))
53265                 goto try_again;
53266  
53267         /* Register with fbdev layer */
53268 -       if (register_framebuffer(&p->info) < 0)
53269 -               return 0;
53270 +       rc = register_framebuffer(&p->info);
53271 +       if (rc < 0)
53272 +               return rc;
53273  
53274         printk(KERN_INFO "fb%d: platinum frame buffer device\n",
53275                p->info.node);
53276  
53277 -       return 1;
53278 -}
53279 -
53280 -int __init platinum_init(void)
53281 -{
53282 -       struct device_node *dp;
53283 -
53284 -       dp = find_devices("platinum");
53285 -       if (dp != 0)
53286 -               platinum_of_init(dp);
53287         return 0;
53288  }
53289  
53290 -#ifdef __powerpc__
53291 -#define invalidate_cache(addr) \
53292 -       asm volatile("eieio; dcbf 0,%1" \
53293 -       : "=m" (*(addr)) : "r" (addr) : "memory");
53294 -#else
53295 -#define invalidate_cache(addr)
53296 -#endif
53297 -
53298 -static void __init platinum_of_init(struct device_node *dp)
53299 -{
53300 -       struct fb_info_platinum *info;
53301 -       unsigned long           addr, size;
53302 -       volatile __u8           *fbuffer;
53303 -       int                     i, bank0, bank1, bank2, bank3;
53304 -
53305 -       if(dp->n_addrs != 2) {
53306 -               printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs);
53307 -               return;
53308 -       }
53309 -
53310 -       info = kmalloc(sizeof(*info), GFP_ATOMIC);
53311 -       if (info == 0)
53312 -               return;
53313 -       memset(info, 0, sizeof(*info));
53314 -
53315 -       /* Map in frame buffer and registers */
53316 -       for (i = 0; i < dp->n_addrs; ++i) {
53317 -               addr = dp->addrs[i].address;
53318 -               size = dp->addrs[i].size;
53319 -               /* Let's assume we can request either all or nothing */
53320 -               if (!request_mem_region(addr, size, "platinumfb")) {
53321 -                       kfree(info);
53322 -                       return;
53323 -               }
53324 -               if (size >= 0x400000) {
53325 -                       /* frame buffer - map only 4MB */
53326 -                       info->frame_buffer_phys = addr;
53327 -                       info->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU);
53328 -                       info->base_frame_buffer = info->frame_buffer;
53329 -               } else {
53330 -                       /* registers */
53331 -                       info->platinum_regs_phys = addr;
53332 -                       info->platinum_regs = ioremap(addr, size);
53333 -               }
53334 -       }
53335 -
53336 -       info->cmap_regs_phys = 0xf301b000;      /* XXX not in prom? */
53337 -       request_mem_region(info->cmap_regs_phys, 0x1000, "platinumfb cmap");
53338 -       info->cmap_regs = ioremap(info->cmap_regs_phys, 0x1000);
53339 -
53340 -       /* Grok total video ram */
53341 -       out_be32(&info->platinum_regs->reg[16].r, (unsigned)info->frame_buffer_phys);
53342 -       out_be32(&info->platinum_regs->reg[20].r, 0x1011);      /* select max vram */
53343 -       out_be32(&info->platinum_regs->reg[24].r, 0);   /* switch in vram */
53344 -
53345 -       fbuffer = info->base_frame_buffer;
53346 -       fbuffer[0x100000] = 0x34;
53347 -       fbuffer[0x100008] = 0x0;
53348 -       invalidate_cache(&fbuffer[0x100000]);
53349 -       fbuffer[0x200000] = 0x56;
53350 -       fbuffer[0x200008] = 0x0;
53351 -       invalidate_cache(&fbuffer[0x200000]);
53352 -       fbuffer[0x300000] = 0x78;
53353 -       fbuffer[0x300008] = 0x0;
53354 -       invalidate_cache(&fbuffer[0x300000]);
53355 -       bank0 = 1; /* builtin 1MB vram, always there */
53356 -       bank1 = fbuffer[0x100000] == 0x34;
53357 -       bank2 = fbuffer[0x200000] == 0x56;
53358 -       bank3 = fbuffer[0x300000] == 0x78;
53359 -       info->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
53360 -       printk(KERN_INFO "Total VRAM = %dMB %d%d%d%d\n", (int) (info->total_vram / 1024 / 1024), bank3, bank2, bank1, bank0);
53361 -
53362 -       /*
53363 -        * Try to determine whether we have an old or a new DACula.
53364 -        */
53365 -       out_8(&info->cmap_regs->addr, 0x40);
53366 -       info->dactype = in_8(&info->cmap_regs->d2);
53367 -       switch (info->dactype) {
53368 -       case 0x3c:
53369 -               info->clktype = 1;
53370 -               break;
53371 -       case 0x84:
53372 -               info->clktype = 0;
53373 -               break;
53374 -       default:
53375 -               info->clktype = 0;
53376 -               printk(KERN_INFO "Unknown DACula type: %x\n", info->dactype);
53377 -               break;
53378 -       }
53379 -
53380 -       if (!init_platinum(info)) {
53381 -               kfree(info);
53382 -               return;
53383 -       }
53384 -}
53385 -
53386  /*
53387   * Get the monitor sense value.
53388   * Note that this can be called before calibrate_delay,
53389 @@ -630,4 +525,169 @@
53390         return 0;
53391  }
53392  
53393 +#ifdef __powerpc__
53394 +#define invalidate_cache(addr) \
53395 +       asm volatile("eieio; dcbf 0,%1" \
53396 +       : "=m" (*(addr)) : "r" (addr) : "memory");
53397 +#else
53398 +#define invalidate_cache(addr)
53399 +#endif
53400 +
53401 +static int __devinit platinumfb_probe(struct of_device* odev, const struct of_match *match)
53402 +{
53403 +       struct device_node      *dp = odev->node;
53404 +       struct fb_info_platinum *info;
53405 +       unsigned long           addr, size;
53406 +       volatile __u8           *fbuffer;
53407 +       int                     i, bank0, bank1, bank2, bank3, rc;
53408 +
53409 +       if (dp->n_addrs != 2) {
53410 +               printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs);
53411 +               return -ENXIO;
53412 +       }
53413 +
53414 +       info = kmalloc(sizeof(*info), GFP_ATOMIC);
53415 +       if (info == 0)
53416 +               return -ENOMEM;
53417 +       memset(info, 0, sizeof(*info));
53418 +
53419 +       /* Map in frame buffer and registers */
53420 +       for (i = 0; i < dp->n_addrs; ++i) {
53421 +               addr = dp->addrs[i].address;
53422 +               size = dp->addrs[i].size;
53423 +               /* Let's assume we can request either all or nothing */
53424 +               if (!request_mem_region(addr, size, "platinumfb")) {
53425 +                       kfree(info);
53426 +                       return -ENXIO;
53427 +               }
53428 +               if (size >= 0x400000) {
53429 +                       /* frame buffer - map only 4MB */
53430 +                       info->frame_buffer_phys = addr;
53431 +                       info->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU);
53432 +                       info->base_frame_buffer = info->frame_buffer;
53433 +               } else {
53434 +                       /* registers */
53435 +                       info->platinum_regs_phys = addr;
53436 +                       info->platinum_regs = ioremap(addr, size);
53437 +               }
53438 +       }
53439 +
53440 +       info->cmap_regs_phys = 0xf301b000;      /* XXX not in prom? */
53441 +       request_mem_region(info->cmap_regs_phys, 0x1000, "platinumfb cmap");
53442 +       info->cmap_regs = ioremap(info->cmap_regs_phys, 0x1000);
53443 +
53444 +       /* Grok total video ram */
53445 +       out_be32(&info->platinum_regs->reg[16].r, (unsigned)info->frame_buffer_phys);
53446 +       out_be32(&info->platinum_regs->reg[20].r, 0x1011);      /* select max vram */
53447 +       out_be32(&info->platinum_regs->reg[24].r, 0);   /* switch in vram */
53448 +
53449 +       fbuffer = info->base_frame_buffer;
53450 +       fbuffer[0x100000] = 0x34;
53451 +       fbuffer[0x100008] = 0x0;
53452 +       invalidate_cache(&fbuffer[0x100000]);
53453 +       fbuffer[0x200000] = 0x56;
53454 +       fbuffer[0x200008] = 0x0;
53455 +       invalidate_cache(&fbuffer[0x200000]);
53456 +       fbuffer[0x300000] = 0x78;
53457 +       fbuffer[0x300008] = 0x0;
53458 +       invalidate_cache(&fbuffer[0x300000]);
53459 +       bank0 = 1; /* builtin 1MB vram, always there */
53460 +       bank1 = fbuffer[0x100000] == 0x34;
53461 +       bank2 = fbuffer[0x200000] == 0x56;
53462 +       bank3 = fbuffer[0x300000] == 0x78;
53463 +       info->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
53464 +       printk(KERN_INFO "Total VRAM = %dMB %d%d%d%d\n", (int) (info->total_vram / 1024 / 1024), bank3, bank2, bank1, bank0);
53465 +
53466 +       /*
53467 +        * Try to determine whether we have an old or a new DACula.
53468 +        */
53469 +       out_8(&info->cmap_regs->addr, 0x40);
53470 +       info->dactype = in_8(&info->cmap_regs->d2);
53471 +       switch (info->dactype) {
53472 +       case 0x3c:
53473 +               info->clktype = 1;
53474 +               break;
53475 +       case 0x84:
53476 +               info->clktype = 0;
53477 +               break;
53478 +       default:
53479 +               info->clktype = 0;
53480 +               printk(KERN_INFO "Unknown DACula type: %x\n", info->dactype);
53481 +               break;
53482 +       }
53483 +       dev_set_drvdata(&odev->dev, info);
53484 +       
53485 +       rc = platinum_init_fb(info);
53486 +       if (rc != 0) {
53487 +               dev_set_drvdata(&odev->dev, NULL);
53488 +               kfree(info);
53489 +       }
53490 +
53491 +       return rc;
53492 +}
53493 +
53494 +static int __devexit platinumfb_remove(struct of_device* odev)
53495 +{
53496 +       struct fb_info_platinum *pinfo = dev_get_drvdata(&odev->dev);
53497 +       struct device_node *dp = odev->node;
53498 +       unsigned long addr, size;
53499 +       int i;
53500 +       
53501 +       if (!pinfo)
53502 +               return 0;
53503 +
53504 +        unregister_framebuffer (&pinfo->info);
53505 +       
53506 +       /* Unmap frame buffer and registers */
53507 +       for (i = 0; i < dp->n_addrs; ++i) {
53508 +               addr = dp->addrs[i].address;
53509 +               size = dp->addrs[i].size;
53510 +               release_mem_region(addr, size);
53511 +       }
53512 +       iounmap((void *)pinfo->frame_buffer);
53513 +       iounmap((void *)pinfo->platinum_regs);
53514 +       release_mem_region(pinfo->cmap_regs_phys, 0x1000);
53515 +       iounmap((void *)pinfo->cmap_regs);
53516 +
53517 +       kfree(pinfo);
53518 +
53519 +       return 0;
53520 +}
53521 +
53522 +static struct of_match platinumfb_match[] = 
53523 +{
53524 +       {
53525 +       .name           = "platinum",
53526 +       .type           = OF_ANY_MATCH,
53527 +       .compatible     = OF_ANY_MATCH,
53528 +       },
53529 +       {},
53530 +};
53531 +
53532 +static struct of_platform_driver platinum_driver = 
53533 +{
53534 +       .name           = "platinumfb",
53535 +       .match_table    = platinumfb_match,
53536 +       .probe          = platinumfb_probe,
53537 +       .remove         = platinumfb_remove,
53538 +};
53539 +
53540 +int __init platinum_init(void)
53541 +{
53542 +       of_register_driver(&platinum_driver);
53543 +
53544 +       return 0;
53545 +}
53546 +
53547 +void __exit platinum_exit(void)
53548 +{
53549 +       of_unregister_driver(&platinum_driver); 
53550 +}
53551 +
53552  MODULE_LICENSE("GPL");
53553 +MODULE_DESCRIPTION("framebuffer driver for Apple Platinum video");
53554 +
53555 +#ifdef MODULE
53556 +module_init(platinum_init);
53557 +module_exit(platinum_exit);
53558 +#endif
53559 diff -Nru a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
53560 --- a/drivers/video/riva/fbdev.c        Thu Jul 31 08:58:45 2003
53561 +++ b/drivers/video/riva/fbdev.c        Sun Aug 31 16:14:08 2003
53562 @@ -297,34 +297,34 @@
53563  #endif
53564  
53565  static struct fb_fix_screeninfo rivafb_fix = {
53566 -       id:             "nVidia",
53567 -       type:           FB_TYPE_PACKED_PIXELS,
53568 -       xpanstep:       1,
53569 -       ypanstep:       1,
53570 +       .id             = "nVidia",
53571 +       .type           = FB_TYPE_PACKED_PIXELS,
53572 +       .xpanstep       = 1,
53573 +       .ypanstep       = 1,
53574  };
53575  
53576  static struct fb_var_screeninfo rivafb_default_var = {
53577 -       xres:           640,
53578 -       yres:           480,
53579 -       xres_virtual:   640,
53580 -       yres_virtual:   480,
53581 -       bits_per_pixel: 8,
53582 -       red:            {0, 8, 0},
53583 -       green:          {0, 8, 0},
53584 -       blue:           {0, 8, 0},
53585 -       transp:         {0, 0, 0},
53586 -       activate:       FB_ACTIVATE_NOW,
53587 -       height:         -1,
53588 -       width:          -1,
53589 -       accel_flags:    FB_ACCELF_TEXT,
53590 -       pixclock:       39721,
53591 -       left_margin:    40,
53592 -       right_margin:   24,
53593 -       upper_margin:   32,
53594 -       lower_margin:   11,
53595 -       hsync_len:      96,
53596 -       vsync_len:      2,
53597 -       vmode:          FB_VMODE_NONINTERLACED
53598 +       .xres           = 640,
53599 +       .yres           = 480,
53600 +       .xres_virtual   = 640,
53601 +       .yres_virtual   = 480,
53602 +       .bits_per_pixel = 8,
53603 +       .red            = {0, 8, 0},
53604 +       .green          = {0, 8, 0},
53605 +       .blue           = {0, 8, 0},
53606 +       .transp         = {0, 0, 0},
53607 +       .activate       = FB_ACTIVATE_NOW,
53608 +       .height         = -1,
53609 +       .width          = -1,
53610 +       .accel_flags    = FB_ACCELF_TEXT,
53611 +       .pixclock       = 39721,
53612 +       .left_margin    = 40,
53613 +       .right_margin   = 24,
53614 +       .upper_margin   = 32,
53615 +       .lower_margin   = 11,
53616 +       .hsync_len      = 96,
53617 +       .vsync_len      = 2,
53618 +       .vmode          = FB_VMODE_NONINTERLACED
53619  };
53620  
53621  /* from GGI */
53622 @@ -1977,10 +1977,10 @@
53623  #endif /* !MODULE */
53624  
53625  static struct pci_driver rivafb_driver = {
53626 -       name:           "rivafb",
53627 -       id_table:       rivafb_pci_tbl,
53628 -       probe:          rivafb_probe,
53629 -       remove:         __exit_p(rivafb_remove),
53630 +       .name           = "rivafb",
53631 +       .id_table       = rivafb_pci_tbl,
53632 +       .probe          = rivafb_probe,
53633 +       .remove         = __exit_p(rivafb_remove),
53634  };
53635  
53636  
53637 diff -Nru a/drivers/video/stifb.c b/drivers/video/stifb.c
53638 --- a/drivers/video/stifb.c     Sat May 31 23:26:17 2003
53639 +++ b/drivers/video/stifb.c     Tue Aug 26 09:25:41 2003
53640 @@ -890,7 +890,7 @@
53641  {
53642         unsigned long p = *ppos;
53643         struct inode *inode = file->f_dentry->d_inode;
53644 -       int fbidx = minor(inode->i_rdev);
53645 +       int fbidx = iminor(inode);
53646         struct fb_info *info = registered_fb[fbidx];
53647         char tmpbuf[TMPBUFLEN];
53648  
53649 @@ -922,7 +922,7 @@
53650  stifb_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
53651  {
53652         struct inode *inode = file->f_dentry->d_inode;
53653 -       int fbidx = minor(inode->i_rdev);
53654 +       int fbidx = iminor(inode);
53655         struct fb_info *info = registered_fb[fbidx];
53656         unsigned long p = *ppos;
53657         size_t c;
53658 diff -Nru a/fs/affs/file.c b/fs/affs/file.c
53659 --- a/fs/affs/file.c    Sat Dec 14 09:42:09 2002
53660 +++ b/fs/affs/file.c    Sun Aug 31 16:14:08 2003
53661 @@ -793,8 +793,8 @@
53662  
53663  struct address_space_operations affs_aops_ofs = {
53664         .readpage = affs_readpage_ofs,
53665 -       //writepage: affs_writepage_ofs,
53666 -       //sync_page: affs_sync_page_ofs,
53667 +       //.writepage = affs_writepage_ofs,
53668 +       //.sync_page = affs_sync_page_ofs,
53669         .prepare_write = affs_prepare_write_ofs,
53670         .commit_write = affs_commit_write_ofs
53671  };
53672 diff -Nru a/fs/afs/callback.c b/fs/afs/callback.c
53673 --- a/fs/afs/callback.c Tue Oct  8 01:00:44 2002
53674 +++ b/fs/afs/callback.c Tue Aug 26 09:37:39 2003
53675 @@ -146,7 +146,7 @@
53676                         spin_unlock(&vnode->lock);
53677  
53678                         if (valid) {
53679 -                               invalidate_inode_pages(inode->i_mapping);
53680 +                               invalidate_remote_inode(inode);
53681                                 afs_put_server(server);
53682                         }
53683                         iput(inode);
53684 diff -Nru a/fs/afs/dir.c b/fs/afs/dir.c
53685 --- a/fs/afs/dir.c      Thu Jul  3 06:36:44 2003
53686 +++ b/fs/afs/dir.c      Tue Aug 26 09:37:39 2003
53687 @@ -569,7 +569,7 @@
53688                         spin_lock(&AFS_FS_I(inode)->lock);
53689                         AFS_FS_I(inode)->flags |= AFS_VNODE_DELETED;
53690                         spin_unlock(&AFS_FS_I(inode)->lock);
53691 -                       invalidate_inode_pages(inode->i_mapping);
53692 +                       invalidate_remote_inode(inode);
53693                         goto out_bad;
53694                 }
53695  
53696 diff -Nru a/fs/bad_inode.c b/fs/bad_inode.c
53697 --- a/fs/bad_inode.c    Tue Dec  3 11:20:54 2002
53698 +++ b/fs/bad_inode.c    Sun Aug 31 16:14:21 2003
53699 @@ -4,6 +4,8 @@
53700   *  Copyright (C) 1997, Stephen Tweedie
53701   *
53702   *  Provide stub functions for unreadable inodes
53703 + *
53704 + *  Fabian Frederick : August 2003 - All file operations assigned to EIO
53705   */
53706  
53707  #include <linux/fs.h>
53708 @@ -31,8 +33,10 @@
53709  static struct file_operations bad_file_ops =
53710  {
53711         .llseek         = EIO_ERROR,
53712 +       .aio_read       = EIO_ERROR,
53713         .read           = EIO_ERROR,
53714         .write          = EIO_ERROR,
53715 +       .aio_write      = EIO_ERROR,
53716         .readdir        = EIO_ERROR,
53717         .poll           = EIO_ERROR,
53718         .ioctl          = EIO_ERROR,
53719 @@ -41,8 +45,14 @@
53720         .flush          = EIO_ERROR,
53721         .release        = EIO_ERROR,
53722         .fsync          = EIO_ERROR,
53723 +       .aio_fsync      = EIO_ERROR,
53724         .fasync         = EIO_ERROR,
53725         .lock           = EIO_ERROR,
53726 +       .readv          = EIO_ERROR,
53727 +       .writev         = EIO_ERROR,
53728 +       .sendfile       = EIO_ERROR,
53729 +       .sendpage       = EIO_ERROR,
53730 +       .get_unmapped_area = EIO_ERROR,
53731  };
53732  
53733  struct inode_operations bad_inode_ops =
53734 @@ -61,6 +71,11 @@
53735         .truncate       = EIO_ERROR,
53736         .permission     = EIO_ERROR,
53737         .getattr        = EIO_ERROR,
53738 +       .setattr        = EIO_ERROR,
53739 +       .setxattr       = EIO_ERROR,
53740 +       .getxattr       = EIO_ERROR,
53741 +       .listxattr      = EIO_ERROR,
53742 +       .removexattr    = EIO_ERROR,
53743  };
53744  
53745  
53746 diff -Nru a/fs/bio.c b/fs/bio.c
53747 --- a/fs/bio.c  Fri May  2 11:30:24 2003
53748 +++ b/fs/bio.c  Thu Aug 21 07:58:40 2003
53749 @@ -793,10 +793,6 @@
53750                                         mempool_free_slab, bp->slab);
53751                 if (!bp->pool)
53752                         panic("biovec: can't init mempool\n");
53753 -
53754 -               printk("biovec pool[%d]: %3d bvecs: %3d entries (%d bytes)\n",
53755 -                                               i, bp->nr_vecs, pool_entries,
53756 -                                               size);
53757         }
53758  }
53759  
53760 @@ -809,8 +805,6 @@
53761         bio_pool = mempool_create(BIO_POOL_SIZE, mempool_alloc_slab, mempool_free_slab, bio_slab);
53762         if (!bio_pool)
53763                 panic("bio: can't create mempool\n");
53764 -
53765 -       printk("BIO: pool of %d setup, %ZuKb (%Zd bytes/bio)\n", BIO_POOL_SIZE, BIO_POOL_SIZE * sizeof(struct bio) >> 10, sizeof(struct bio));
53766  
53767         biovec_init_pools();
53768  
53769 diff -Nru a/fs/block_dev.c b/fs/block_dev.c
53770 --- a/fs/block_dev.c    Wed Aug 20 22:31:51 2003
53771 +++ b/fs/block_dev.c    Tue Aug 26 12:06:15 2003
53772 @@ -197,40 +197,36 @@
53773   * pseudo-fs
53774   */
53775  
53776 -static struct super_block *bd_get_sb(struct file_system_type *fs_type,
53777 -       int flags, const char *dev_name, void *data)
53778 -{
53779 -       return get_sb_pseudo(fs_type, "bdev:", NULL, 0x62646576);
53780 -}
53781 +static spinlock_t bdev_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
53782 +static kmem_cache_t * bdev_cachep;
53783  
53784 -static struct file_system_type bd_type = {
53785 -       .name           = "bdev",
53786 -       .get_sb         = bd_get_sb,
53787 -       .kill_sb        = kill_anon_super,
53788 +struct bdev_inode {
53789 +       struct block_device bdev;
53790 +       struct inode vfs_inode;
53791  };
53792  
53793 -static struct vfsmount *bd_mnt;
53794 -struct super_block *blockdev_superblock;
53795 -
53796 -/*
53797 - * bdev cache handling - shamelessly stolen from inode.c
53798 - * We use smaller hashtable, though.
53799 - */
53800 +static inline struct bdev_inode *BDEV_I(struct inode *inode)
53801 +{
53802 +       return container_of(inode, struct bdev_inode, vfs_inode);
53803 +}
53804  
53805 -#define HASH_BITS      6
53806 -#define HASH_SIZE      (1UL << HASH_BITS)
53807 -#define HASH_MASK      (HASH_SIZE-1)
53808 -static struct list_head bdev_hashtable[HASH_SIZE];
53809 -static spinlock_t bdev_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
53810 -static kmem_cache_t * bdev_cachep;
53811 +static struct inode *bdev_alloc_inode(struct super_block *sb)
53812 +{
53813 +       struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, SLAB_KERNEL);
53814 +       if (!ei)
53815 +               return NULL;
53816 +       return &ei->vfs_inode;
53817 +}
53818  
53819 -#define alloc_bdev() \
53820 -        ((struct block_device *) kmem_cache_alloc(bdev_cachep, SLAB_KERNEL))
53821 -#define destroy_bdev(bdev) kmem_cache_free(bdev_cachep, (bdev))
53822 +static void bdev_destroy_inode(struct inode *inode)
53823 +{
53824 +       kmem_cache_free(bdev_cachep, BDEV_I(inode));
53825 +}
53826  
53827  static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
53828  {
53829 -       struct block_device * bdev = (struct block_device *) foo;
53830 +       struct bdev_inode *ei = (struct bdev_inode *) foo;
53831 +       struct block_device *bdev = &ei->bdev;
53832  
53833         if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
53834             SLAB_CTOR_CONSTRUCTOR)
53835 @@ -238,25 +234,62 @@
53836                 memset(bdev, 0, sizeof(*bdev));
53837                 sema_init(&bdev->bd_sem, 1);
53838                 INIT_LIST_HEAD(&bdev->bd_inodes);
53839 +               INIT_LIST_HEAD(&bdev->bd_list);
53840 +               inode_init_once(&ei->vfs_inode);
53841         }
53842  }
53843  
53844 -void __init bdev_cache_init(void)
53845 +static inline void __bd_forget(struct inode *inode)
53846 +{
53847 +       list_del_init(&inode->i_devices);
53848 +       inode->i_bdev = NULL;
53849 +       inode->i_mapping = &inode->i_data;
53850 +}
53851 +
53852 +static void bdev_clear_inode(struct inode *inode)
53853 +{
53854 +       struct block_device *bdev = &BDEV_I(inode)->bdev;
53855 +       struct list_head *p;
53856 +       spin_lock(&bdev_lock);
53857 +       while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
53858 +               __bd_forget(list_entry(p, struct inode, i_devices));
53859 +       }
53860 +       list_del_init(&bdev->bd_list);
53861 +       spin_unlock(&bdev_lock);
53862 +}
53863 +
53864 +static struct super_operations bdev_sops = {
53865 +       .statfs = simple_statfs,
53866 +       .alloc_inode = bdev_alloc_inode,
53867 +       .destroy_inode = bdev_destroy_inode,
53868 +       .drop_inode = generic_delete_inode,
53869 +       .clear_inode = bdev_clear_inode,
53870 +};
53871 +
53872 +static struct super_block *bd_get_sb(struct file_system_type *fs_type,
53873 +       int flags, const char *dev_name, void *data)
53874  {
53875 -       int i, err;
53876 -       struct list_head *head = bdev_hashtable;
53877 +       return get_sb_pseudo(fs_type, "bdev:", &bdev_sops, 0x62646576);
53878 +}
53879 +
53880 +static struct file_system_type bd_type = {
53881 +       .name           = "bdev",
53882 +       .get_sb         = bd_get_sb,
53883 +       .kill_sb        = kill_anon_super,
53884 +};
53885  
53886 -       i = HASH_SIZE;
53887 -       do {
53888 -               INIT_LIST_HEAD(head);
53889 -               head++;
53890 -               i--;
53891 -       } while (i);
53892 +static struct vfsmount *bd_mnt;
53893 +struct super_block *blockdev_superblock;
53894  
53895 +void __init bdev_cache_init(void)
53896 +{
53897 +       int err;
53898         bdev_cachep = kmem_cache_create("bdev_cache",
53899 -                                        sizeof(struct block_device),
53900 -                                        0, SLAB_HWCACHE_ALIGN, init_once,
53901 -                                        NULL);
53902 +                                       sizeof(struct bdev_inode),
53903 +                                       0,
53904 +                                       SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
53905 +                                       init_once,
53906 +                                       NULL);
53907         if (!bdev_cachep)
53908                 panic("Cannot create bdev_cache SLAB cache");
53909         err = register_filesystem(&bd_type);
53910 @@ -272,123 +305,83 @@
53911  /*
53912   * Most likely _very_ bad one - but then it's hardly critical for small
53913   * /dev and can be fixed when somebody will need really large one.
53914 + * Keep in mind that it will be fed through icache hash function too.
53915   */
53916  static inline unsigned long hash(dev_t dev)
53917  {
53918 -       unsigned long tmp = dev;
53919 -       tmp = tmp + (tmp >> HASH_BITS) + (tmp >> HASH_BITS*2);
53920 -       return tmp & HASH_MASK;
53921 +       return MAJOR(dev)+MINOR(dev);
53922  }
53923  
53924 -static struct block_device *bdfind(dev_t dev, struct list_head *head)
53925 +static int bdev_test(struct inode *inode, void *data)
53926  {
53927 -       struct list_head *p;
53928 -       struct block_device *bdev;
53929 -       list_for_each(p, head) {
53930 -               bdev = list_entry(p, struct block_device, bd_hash);
53931 -               if (bdev->bd_dev != dev)
53932 -                       continue;
53933 -               atomic_inc(&bdev->bd_count);
53934 -               return bdev;
53935 -       }
53936 -       return NULL;
53937 +       return BDEV_I(inode)->bdev.bd_dev == *(dev_t *)data;
53938  }
53939  
53940 +static int bdev_set(struct inode *inode, void *data)
53941 +{
53942 +       BDEV_I(inode)->bdev.bd_dev = *(dev_t *)data;
53943 +       return 0;
53944 +}
53945 +
53946 +static LIST_HEAD(all_bdevs);
53947 +
53948  struct block_device *bdget(dev_t dev)
53949  {
53950 -       struct list_head * head = bdev_hashtable + hash(dev);
53951 -       struct block_device *bdev, *new_bdev;
53952 -       spin_lock(&bdev_lock);
53953 -       bdev = bdfind(dev, head);
53954 -       spin_unlock(&bdev_lock);
53955 -       if (bdev)
53956 -               return bdev;
53957 -       new_bdev = alloc_bdev();
53958 -       if (new_bdev) {
53959 -               struct inode *inode = new_inode(bd_mnt->mnt_sb);
53960 -               if (inode) {
53961 -                       kdev_t kdev = to_kdev_t(dev);
53962 -
53963 -                       atomic_set(&new_bdev->bd_count,1);
53964 -                       new_bdev->bd_dev = dev;
53965 -                       new_bdev->bd_contains = NULL;
53966 -                       new_bdev->bd_inode = inode;
53967 -                       new_bdev->bd_block_size = (1 << inode->i_blkbits);
53968 -                       new_bdev->bd_part_count = 0;
53969 -                       new_bdev->bd_invalidated = 0;
53970 -                       inode->i_mode = S_IFBLK;
53971 -                       inode->i_rdev = kdev;
53972 -                       inode->i_bdev = new_bdev;
53973 -                       inode->i_data.a_ops = &def_blk_aops;
53974 -                       mapping_set_gfp_mask(&inode->i_data, GFP_USER);
53975 -                       inode->i_data.backing_dev_info = &default_backing_dev_info;
53976 -                       spin_lock(&bdev_lock);
53977 -                       bdev = bdfind(dev, head);
53978 -                       if (!bdev) {
53979 -                               list_add(&new_bdev->bd_hash, head);
53980 -                               spin_unlock(&bdev_lock);
53981 -                               return new_bdev;
53982 -                       }
53983 -                       spin_unlock(&bdev_lock);
53984 -                       iput(new_bdev->bd_inode);
53985 -               }
53986 -               destroy_bdev(new_bdev);
53987 +       struct block_device *bdev;
53988 +       struct inode *inode;
53989 +
53990 +       inode = iget5_locked(bd_mnt->mnt_sb, hash(dev),
53991 +                       bdev_test, bdev_set, &dev);
53992 +
53993 +       if (!inode)
53994 +               return NULL;
53995 +
53996 +       bdev = &BDEV_I(inode)->bdev;
53997 +
53998 +       if (inode->i_state & I_NEW) {
53999 +               bdev->bd_contains = NULL;
54000 +               bdev->bd_inode = inode;
54001 +               bdev->bd_block_size = (1 << inode->i_blkbits);
54002 +               bdev->bd_part_count = 0;
54003 +               bdev->bd_invalidated = 0;
54004 +               inode->i_mode = S_IFBLK;
54005 +               inode->i_rdev = to_kdev_t(dev);
54006 +               inode->i_bdev = bdev;
54007 +               inode->i_data.a_ops = &def_blk_aops;
54008 +               mapping_set_gfp_mask(&inode->i_data, GFP_USER);
54009 +               inode->i_data.backing_dev_info = &default_backing_dev_info;
54010 +               spin_lock(&bdev_lock);
54011 +               list_add(&bdev->bd_list, &all_bdevs);
54012 +               spin_unlock(&bdev_lock);
54013 +               unlock_new_inode(inode);
54014         }
54015         return bdev;
54016  }
54017  
54018  long nr_blockdev_pages(void)
54019  {
54020 +       struct list_head *p;
54021         long ret = 0;
54022 -       int i;
54023 -
54024         spin_lock(&bdev_lock);
54025 -       for (i = 0; i < ARRAY_SIZE(bdev_hashtable); i++) {
54026 -               struct list_head *head = &bdev_hashtable[i];
54027 -               struct list_head *lh;
54028 -
54029 -               if (head == NULL)
54030 -                       continue;
54031 -               list_for_each(lh, head) {
54032 -                       struct block_device *bdev;
54033 -
54034 -                       bdev = list_entry(lh, struct block_device, bd_hash);
54035 -                       ret += bdev->bd_inode->i_mapping->nrpages;
54036 -               }
54037 +       list_for_each(p, &all_bdevs) {
54038 +               struct block_device *bdev;
54039 +               bdev = list_entry(p, struct block_device, bd_list);
54040 +               ret += bdev->bd_inode->i_mapping->nrpages;
54041         }
54042         spin_unlock(&bdev_lock);
54043         return ret;
54044  }
54045  
54046 -static inline void __bd_forget(struct inode *inode)
54047 -{
54048 -       list_del_init(&inode->i_devices);
54049 -       inode->i_bdev = NULL;
54050 -       inode->i_mapping = &inode->i_data;
54051 -}
54052 -
54053  void bdput(struct block_device *bdev)
54054  {
54055 -       if (atomic_dec_and_lock(&bdev->bd_count, &bdev_lock)) {
54056 -               struct list_head *p;
54057 -               if (bdev->bd_openers)
54058 -                       BUG();
54059 -               list_del(&bdev->bd_hash);
54060 -               while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
54061 -                       __bd_forget(list_entry(p, struct inode, i_devices));
54062 -               }
54063 -               spin_unlock(&bdev_lock);
54064 -               iput(bdev->bd_inode);
54065 -               destroy_bdev(bdev);
54066 -       }
54067 +       iput(bdev->bd_inode);
54068  }
54069   
54070  int bd_acquire(struct inode *inode)
54071  {
54072         struct block_device *bdev;
54073         spin_lock(&bdev_lock);
54074 -       if (inode->i_bdev) {
54075 -               atomic_inc(&inode->i_bdev->bd_count);
54076 +       if (inode->i_bdev && igrab(inode->i_bdev->bd_inode)) {
54077                 spin_unlock(&bdev_lock);
54078                 return 0;
54079         }
54080 @@ -397,12 +390,11 @@
54081         if (!bdev)
54082                 return -ENOMEM;
54083         spin_lock(&bdev_lock);
54084 -       if (!inode->i_bdev) {
54085 -               inode->i_bdev = bdev;
54086 -               inode->i_mapping = bdev->bd_inode->i_mapping;
54087 -               list_add(&inode->i_devices, &bdev->bd_inodes);
54088 -       } else if (inode->i_bdev != bdev)
54089 -               BUG();
54090 +       if (inode->i_bdev)
54091 +               __bd_forget(inode);
54092 +       inode->i_bdev = bdev;
54093 +       inode->i_mapping = bdev->bd_inode->i_mapping;
54094 +       list_add(&inode->i_devices, &bdev->bd_inodes);
54095         spin_unlock(&bdev_lock);
54096         return 0;
54097  }
54098 @@ -548,7 +540,6 @@
54099                                 if (ret)
54100                                         goto out_first;
54101                         }
54102 -                       bdev->bd_offset = 0;
54103                         if (!bdev->bd_openers) {
54104                                 bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
54105                                 bdi = blk_get_backing_dev_info(bdev);
54106 @@ -580,7 +571,8 @@
54107                                 ret = -ENXIO;
54108                                 goto out_first;
54109                         }
54110 -                       bdev->bd_offset = p->start_sect;
54111 +                       kobject_get(&p->kobj);
54112 +                       bdev->bd_part = p;
54113                         bd_set_size(bdev, (loff_t) p->nr_sects << 9);
54114                         up(&whole->bd_sem);
54115                 }
54116 @@ -701,6 +693,10 @@
54117                 put_disk(disk);
54118                 module_put(owner);
54119  
54120 +               if (bdev->bd_contains != bdev) {
54121 +                       kobject_put(&bdev->bd_part->kobj);
54122 +                       bdev->bd_part = NULL;
54123 +               }
54124                 bdev->bd_disk = NULL;
54125                 bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
54126                 if (bdev != bdev->bd_contains) {
54127 diff -Nru a/fs/cifs/CHANGES b/fs/cifs/CHANGES
54128 --- a/fs/cifs/CHANGES   Thu Aug 21 16:44:46 2003
54129 +++ b/fs/cifs/CHANGES   Tue Sep  2 11:34:09 2003
54130 @@ -1,3 +1,14 @@
54131 +Version 0.91
54132 +------------
54133 +Fix oops in reopen_files when invalid dentry. drop dentry on server rename 
54134 +and on revalidate errors. Fix cases where pid is now tgid.  Fix return code
54135 +on create hard link when server does not support them. 
54136 +
54137 +Version 0.90
54138 +------------
54139 +Fix scheduling while atomic error in getting inode info on newly created file. 
54140 +Fix truncate of existing files opened with O_CREAT but not O_TRUNC set.
54141 +
54142  Version 0.89
54143  ------------
54144  Fix oops on write to dead tcp session. Remove error log write for case when file open
54145 diff -Nru a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54146 --- a/fs/cifs/cifsfs.c  Sun Aug 10 22:50:41 2003
54147 +++ b/fs/cifs/cifsfs.c  Tue Aug 26 09:37:39 2003
54148 @@ -598,10 +598,12 @@
54149                                 netfid = oplock_item->netfid;
54150                                 DeleteOplockQEntry(oplock_item);
54151                                 write_unlock(&GlobalMid_Lock);
54152 -                               rc = filemap_fdatawrite(inode->i_mapping);
54153 -                               if(rc)
54154 -                                       CIFS_I(inode)->write_behind_rc 
54155 -                                               = rc;
54156 +                               if (S_ISREG(inode->i_mode))
54157 +                                       rc = filemap_fdatawrite(inode->i_mapping);
54158 +                               else
54159 +                                       rc = 0;
54160 +                               if (rc)
54161 +                                       CIFS_I(inode)->write_behind_rc = rc;
54162                                 cFYI(1,("Oplock flush inode %p rc %d",inode,rc));
54163                                 rc = CIFSSMBLock(0, pTcon, netfid,
54164                                         0 /* len */ , 0 /* offset */, 0, 
54165 diff -Nru a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
54166 --- a/fs/cifs/cifssmb.c Thu Aug 21 15:06:59 2003
54167 +++ b/fs/cifs/cifssmb.c Fri Aug 29 01:50:52 2003
54168 @@ -1,7 +1,7 @@
54169  /*
54170   *   fs/cifs/cifssmb.c
54171   *
54172 - *   Copyright (c) International Business Machines  Corp., 2002
54173 + *   Copyright (C) International Business Machines  Corp., 2002,2003
54174   *   Author(s): Steve French (sfrench@us.ibm.com)
54175   *
54176   *   Contains the routines for constructing the SMB PDUs themselves
54177 @@ -656,7 +656,7 @@
54178         pSMB->AndXCommand = 0xFF;       /* none */
54179         pSMB->Fid = smb_file_id; /* netfid stays le */
54180  
54181 -       pSMB->Locks[0].Pid = cpu_to_le16(current->pid);
54182 +       pSMB->Locks[0].Pid = cpu_to_le16(current->tgid);
54183         pSMB->Locks[0].Length = cpu_to_le64(len);
54184         pSMB->Locks[0].Offset = cpu_to_le64(offset);
54185         pSMB->ByteCount = sizeof (LOCKING_ANDX_RANGE);
54186 diff -Nru a/fs/cifs/dir.c b/fs/cifs/dir.c
54187 --- a/fs/cifs/dir.c     Thu Aug 21 15:06:59 2003
54188 +++ b/fs/cifs/dir.c     Fri Aug 29 01:50:52 2003
54189 @@ -3,7 +3,7 @@
54190   *
54191   *   vfs operations that deal with dentries
54192   * 
54193 - *   Copyright (c) International Business Machines  Corp., 2002
54194 + *   Copyright (C) International Business Machines  Corp., 2002,2003
54195   *   Author(s): Steve French (sfrench@us.ibm.com)
54196   *
54197   *   This library is free software; you can redistribute it and/or modify
54198 @@ -134,6 +134,7 @@
54199         struct inode *newinode = NULL;
54200         struct cifsFileInfo * pCifsFile = NULL;
54201         struct cifsInodeInfo * pCifsInode;
54202 +       int disposition = FILE_OVERWRITE_IF;
54203  
54204         xid = GetXid();
54205  
54206 @@ -151,6 +152,16 @@
54207                         desiredAccess = GENERIC_WRITE;
54208                 else if ((nd->intent.open.flags & O_ACCMODE) == O_RDWR)
54209                         desiredAccess = GENERIC_ALL;
54210 +
54211 +               if((nd->intent.open.flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
54212 +                       disposition = FILE_CREATE;
54213 +               else if((nd->intent.open.flags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC))
54214 +                       disposition = FILE_OVERWRITE_IF;
54215 +               else if((nd->intent.open.flags & O_CREAT) == O_CREAT)
54216 +                       disposition = FILE_OPEN_IF;
54217 +               else {
54218 +                       cFYI(1,("Create flag not set in create function"));
54219 +               }
54220         }
54221  
54222         /* BB add processing to set equivalent of mode - e.g. via CreateX with ACLs */
54223 @@ -158,7 +169,7 @@
54224                 oplock = REQ_OPLOCK;
54225  
54226         buf = kmalloc(sizeof(FILE_ALL_INFO),GFP_KERNEL);
54227 -       rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OVERWRITE_IF,
54228 +       rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
54229                          desiredAccess, CREATE_NOT_DIR,
54230                          &fileHandle, &oplock, buf, cifs_sb->local_nls);
54231         if (rc) {
54232 @@ -205,7 +216,7 @@
54233                                 memset((char *)pCifsFile, 0,
54234                                        sizeof (struct cifsFileInfo));
54235                                 pCifsFile->netfid = fileHandle;
54236 -                               pCifsFile->pid = current->pid;
54237 +                               pCifsFile->pid = current->tgid;
54238                                 pCifsFile->pInode = newinode;
54239                                 /* pCifsFile->pfile = file; */ /* put in at open time */
54240                                 write_lock(&GlobalSMBSeslock);
54241 @@ -297,6 +308,9 @@
54242              (" parent inode = 0x%p name is: %s and dentry = 0x%p",
54243               parent_dir_inode, direntry->d_name.name, direntry));
54244  
54245 +       if(nd) {  /* BB removeme */
54246 +               cFYI(1,("In lookup nd flags 0x%x open intent flags 0x%x",nd->flags,nd->intent.open.flags));
54247 +       } /* BB removeme BB */
54248         /* BB Add check of incoming data - e.g. frame not longer than maximum SMB - let server check the namelen BB */
54249  
54250         /* check whether path exists */
54251 diff -Nru a/fs/cifs/file.c b/fs/cifs/file.c
54252 --- a/fs/cifs/file.c    Thu Aug 21 15:13:09 2003
54253 +++ b/fs/cifs/file.c    Fri Aug 29 00:58:20 2003
54254 @@ -3,7 +3,7 @@
54255   *
54256   *   vfs operations that deal with files
54257   * 
54258 - *   Copyright (c) International Business Machines  Corp., 2002
54259 + *   Copyright (C) International Business Machines  Corp., 2002,2003
54260   *   Author(s): Steve French (sfrench@us.ibm.com)
54261   *
54262   *   This library is free software; you can redistribute it and/or modify
54263 @@ -144,6 +144,10 @@
54264                         list_add(&pCifsFile->tlist,&pTcon->openFileList);
54265                         pCifsInode = CIFS_I(file->f_dentry->d_inode);
54266                         if(pCifsInode) {
54267 +                               list_add(&pCifsFile->flist,&pCifsInode->openFileList);
54268 +                               write_unlock(&GlobalSMBSeslock);
54269 +                               write_unlock(&file->f_owner.lock);
54270 +
54271                                 if (pTcon->ses->capabilities & CAP_UNIX)
54272                                         rc = cifs_get_inode_info_unix(&file->f_dentry->d_inode,
54273                                                 full_path, inode->i_sb);
54274 @@ -151,16 +155,16 @@
54275                                         rc = cifs_get_inode_info(&file->f_dentry->d_inode,
54276                                                 full_path, buf, inode->i_sb);
54277  
54278 -                               list_add(&pCifsFile->flist,&pCifsInode->openFileList);
54279                                 if(oplock == OPLOCK_EXCLUSIVE) {
54280                                         pCifsInode->clientCanCacheAll = TRUE;
54281                                         pCifsInode->clientCanCacheRead = TRUE;
54282                                         cFYI(1,("Exclusive Oplock granted on inode %p",file->f_dentry->d_inode));
54283                                 } else if(oplock == OPLOCK_READ)
54284                                         pCifsInode->clientCanCacheRead = TRUE;
54285 +                       } else {
54286 +                               write_unlock(&GlobalSMBSeslock);
54287 +                               write_unlock(&file->f_owner.lock);
54288                         }
54289 -                       write_unlock(&GlobalSMBSeslock);
54290 -                       write_unlock(&file->f_owner.lock);
54291                         if(file->f_flags & O_CREAT) {           
54292                                 /* time to set mode which we can not set earlier due
54293                                  to problems creating new read-only files */
54294 @@ -221,16 +225,21 @@
54295                         if(file) {                
54296                                 file->private_data = NULL;
54297                                 read_unlock(&GlobalSMBSeslock);
54298 -                               rc = cifs_open(file->f_dentry->d_inode,file);
54299 -                               read_lock(&GlobalSMBSeslock);
54300 -                               if(rc) {
54301 -                                       cFYI(1,("reconnecting file %s failed with %d",
54302 -                                               file->f_dentry->d_name.name,rc));
54303 +                               if(file->f_dentry == 0) {
54304 +                                       cFYI(1,("Null dentry for file %p",file));
54305 +                                       read_lock(&GlobalSMBSeslock);
54306                                 } else {
54307 -                                       cFYI(1,("reconnection of %s succeeded",
54308 -                                               file->f_dentry->d_name.name));
54309 -                               }
54310 -                       } 
54311 +                                       rc = cifs_open(file->f_dentry->d_inode,file);
54312 +                                       read_lock(&GlobalSMBSeslock);
54313 +                                       if(rc) {
54314 +                                               cFYI(1,("reconnecting file %s failed with %d",
54315 +                                                       file->f_dentry->d_name.name,rc));
54316 +                                       } else {
54317 +                                               cFYI(1,("reconnection of %s succeeded",
54318 +                                                       file->f_dentry->d_name.name));
54319 +                                       }
54320 +                               } 
54321 +                       }
54322                 }
54323         }
54324         read_unlock(&GlobalSMBSeslock);
54325 diff -Nru a/fs/cifs/inode.c b/fs/cifs/inode.c
54326 --- a/fs/cifs/inode.c   Fri Aug 15 04:18:47 2003
54327 +++ b/fs/cifs/inode.c   Mon Sep  1 03:41:02 2003
54328 @@ -1,7 +1,7 @@
54329  /*
54330   *   fs/cifs/inode.c
54331   *
54332 - *   Copyright (c) International Business Machines  Corp., 2002
54333 + *   Copyright (C) International Business Machines  Corp., 2002,2003
54334   *   Author(s): Steve French (sfrench@us.ibm.com)
54335   *
54336   *   This library is free software; you can redistribute it and/or modify
54337 @@ -345,6 +345,8 @@
54338  
54339         if (!rc) {
54340                 direntry->d_inode->i_nlink--;
54341 +       } else if (rc == -ENOENT) {
54342 +               d_drop(direntry);
54343         } else if (rc == -ETXTBSY) {
54344                 int oplock = FALSE;
54345                 __u16 netfid;
54346 @@ -585,12 +587,24 @@
54347                 }            
54348         }
54349  
54350 -       if (cifs_sb->tcon->ses->capabilities & CAP_UNIX)
54351 -               cifs_get_inode_info_unix(&direntry->d_inode, full_path,
54352 +       if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) {
54353 +               rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path,
54354                                          direntry->d_sb);
54355 -       else
54356 -               cifs_get_inode_info(&direntry->d_inode, full_path, NULL,
54357 +               if(rc) {
54358 +                       cFYI(1,("error on getting revalidate info %d",rc));
54359 +/*                     if(rc != -ENOENT)
54360 +                               rc = 0; */ /* BB should we cache info on certain errors? */
54361 +               }
54362 +       } else {
54363 +               rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL,
54364                                     direntry->d_sb);
54365 +               if(rc) {
54366 +                       cFYI(1,("error on getting revalidate info %d",rc));
54367 +/*                     if(rc != -ENOENT)
54368 +                               rc = 0; */  /* BB should we cache info on certain errors? */
54369 +               }
54370 +       }
54371 +       /* should we remap certain errors, access denied?, to zero */
54372  
54373         /* BB if not oplocked, invalidate inode pages if mtime has changed */
54374  
54375 diff -Nru a/fs/cifs/link.c b/fs/cifs/link.c
54376 --- a/fs/cifs/link.c    Mon Jul 21 22:32:20 2003
54377 +++ b/fs/cifs/link.c    Tue Sep  2 11:34:10 2003
54378 @@ -1,7 +1,7 @@
54379  /*
54380   *   fs/cifs/link.c
54381   *
54382 - *   Copyright (c) International Business Machines  Corp., 2002
54383 + *   Copyright (C) International Business Machines  Corp., 2002,2003
54384   *   Author(s): Steve French (sfrench@us.ibm.com)
54385   *
54386   *   This library is free software; you can redistribute it and/or modify
54387 @@ -51,9 +51,12 @@
54388         if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX)
54389                 rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName,
54390                                             cifs_sb_target->local_nls);
54391 -       else
54392 +       else {
54393                 rc = CIFSCreateHardLink(xid, pTcon, fromName, toName,
54394                                         cifs_sb_target->local_nls);
54395 +               if(rc == -EIO)
54396 +                       rc = -EOPNOTSUPP;  
54397 +       }
54398  
54399  /* if (!rc)     */
54400         {
54401 diff -Nru a/fs/cifs/misc.c b/fs/cifs/misc.c
54402 --- a/fs/cifs/misc.c    Wed Aug  6 12:45:33 2003
54403 +++ b/fs/cifs/misc.c    Fri Aug 29 01:50:52 2003
54404 @@ -1,7 +1,7 @@
54405  /*
54406   *   fs/cifs/misc.c
54407   *
54408 - *   Copyright (c) International Business Machines  Corp., 2002
54409 + *   Copyright (c) International Business Machines  Corp., 2002,2003
54410   *   Author(s): Steve French (sfrench@us.ibm.com)
54411   *
54412   *   This library is free software; you can redistribute it and/or modify
54413 @@ -213,7 +213,7 @@
54414         buffer->Command = smb_command;
54415         buffer->Flags = 0x00;   /* case sensitive */
54416         buffer->Flags2 = SMBFLG2_KNOWS_LONG_NAMES;
54417 -       tmp = cpu_to_le32(current->pid);
54418 +       tmp = cpu_to_le32(current->tgid);
54419         buffer->Pid = tmp & 0xFFFF;
54420         tmp >>= 16;
54421         buffer->PidHigh = tmp & 0xFFFF;
54422 diff -Nru a/fs/coda/inode.c b/fs/coda/inode.c
54423 --- a/fs/coda/inode.c   Fri Jun 20 13:16:06 2003
54424 +++ b/fs/coda/inode.c   Tue Aug 26 09:25:41 2003
54425 @@ -115,7 +115,7 @@
54426                 inode = file->f_dentry->d_inode;
54427         
54428         if(!inode || !S_ISCHR(inode->i_mode) ||
54429 -          major(inode->i_rdev) != CODA_PSDEV_MAJOR) {
54430 +          imajor(inode) != CODA_PSDEV_MAJOR) {
54431                 if(file)
54432                         fput(file);
54433  
54434 @@ -123,7 +123,7 @@
54435                 return -1;
54436         }
54437  
54438 -       idx = minor(inode->i_rdev);
54439 +       idx = iminor(inode);
54440         fput(file);
54441  
54442         if(idx < 0 || idx >= MAX_CODADEVS) {
54443 diff -Nru a/fs/coda/psdev.c b/fs/coda/psdev.c
54444 --- a/fs/coda/psdev.c   Wed May  7 08:47:30 2003
54445 +++ b/fs/coda/psdev.c   Tue Aug 26 09:25:41 2003
54446 @@ -279,7 +279,7 @@
54447         int idx;
54448  
54449         lock_kernel();
54450 -       idx = minor(inode->i_rdev);
54451 +       idx = iminor(inode);
54452         if(idx >= MAX_CODADEVS) {
54453                 unlock_kernel();
54454                 return -ENODEV;
54455 diff -Nru a/fs/compat.c b/fs/compat.c
54456 --- a/fs/compat.c       Sun Jul 13 14:26:23 2003
54457 +++ b/fs/compat.c       Sun Aug 31 16:14:44 2003
54458 @@ -227,7 +227,8 @@
54459  #define IOCTL_HASHSIZE 256
54460  struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
54461  
54462 -extern struct ioctl_trans ioctl_start[], ioctl_end[]; 
54463 +extern struct ioctl_trans ioctl_start[];
54464 +extern int ioctl_table_size;
54465  
54466  static inline unsigned long ioctl32_hash(unsigned long cmd)
54467  {
54468 @@ -255,7 +256,7 @@
54469  {
54470         int i;
54471  
54472 -       for (i = 0; &ioctl_start[i] < &ioctl_end[0]; i++) {
54473 +       for (i = 0; i < ioctl_table_size; i++) {
54474                 if (ioctl_start[i].next != 0) { 
54475                         printk("ioctl translation %d bad\n",i); 
54476                         return -1;
54477 @@ -318,8 +319,7 @@
54478  
54479  static inline int builtin_ioctl(struct ioctl_trans *t)
54480  { 
54481 -       return t >= (struct ioctl_trans *)ioctl_start &&
54482 -              t < (struct ioctl_trans *)ioctl_end; 
54483 +       return t >= ioctl_start && t < (ioctl_start + ioctl_table_size);
54484  } 
54485  
54486  /* Problem: 
54487 diff -Nru a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54488 --- a/fs/compat_ioctl.c Thu Jul  3 15:19:48 2003
54489 +++ b/fs/compat_ioctl.c Tue Aug 26 09:25:40 2003
54490 @@ -1573,7 +1573,7 @@
54491                 return -EINVAL;
54492                         
54493         tty = (struct tty_struct *)file->private_data;
54494 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
54495 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
54496                 return -EINVAL;
54497                                                         
54498         if (tty->driver->ioctl != vt_ioctl)
54499 diff -Nru a/fs/dnotify.c b/fs/dnotify.c
54500 --- a/fs/dnotify.c      Wed Apr  2 22:51:32 2003
54501 +++ b/fs/dnotify.c      Sun Aug 31 16:14:42 2003
54502 @@ -20,8 +20,6 @@
54503  #include <linux/spinlock.h>
54504  #include <linux/slab.h>
54505  
54506 -extern void send_sigio(struct fown_struct *fown, int fd, int band);
54507 -
54508  int dir_notify_enable = 1;
54509  
54510  static rwlock_t dn_lock = RW_LOCK_UNLOCKED;
54511 @@ -94,7 +92,7 @@
54512                 prev = &odn->dn_next;
54513         }
54514  
54515 -       error = f_setown(filp, current->pid, 1);
54516 +       error = f_setown(filp, current->tgid, 1);
54517         if (error)
54518                 goto out_free;
54519  
54520 diff -Nru a/fs/ext2/namei.c b/fs/ext2/namei.c
54521 --- a/fs/ext2/namei.c   Sun Jun 29 23:49:04 2003
54522 +++ b/fs/ext2/namei.c   Sun Aug 31 16:14:21 2003
54523 @@ -143,7 +143,7 @@
54524         int err = PTR_ERR(inode);
54525         if (!IS_ERR(inode)) {
54526                 init_special_inode(inode, inode->i_mode, rdev);
54527 -#ifdef CONFIG_EXT2_FS_EXT_ATTR
54528 +#ifdef CONFIG_EXT2_FS_XATTR
54529                 inode->i_op = &ext2_special_inode_operations;
54530  #endif
54531                 mark_inode_dirty(inode);
54532 diff -Nru a/fs/ext3/namei.c b/fs/ext3/namei.c
54533 --- a/fs/ext3/namei.c   Wed Aug 20 22:32:02 2003
54534 +++ b/fs/ext3/namei.c   Sun Aug 31 16:14:18 2003
54535 @@ -1306,7 +1306,7 @@
54536  
54537         /* The 0th block becomes the root, move the dirents out */
54538         fde = &root->dotdot;
54539 -       de = (struct ext3_dir_entry_2 *)((char *)fde + fde->rec_len);
54540 +       de = (struct ext3_dir_entry_2 *)((char *)fde + le16_to_cpu(fde->rec_len));
54541         len = ((char *) root) + blocksize - (char *) de;
54542         memcpy (data1, de, len);
54543         de = (struct ext3_dir_entry_2 *) data1;
54544 diff -Nru a/fs/ext3/xattr.c b/fs/ext3/xattr.c
54545 --- a/fs/ext3/xattr.c   Thu Jul 17 22:30:42 2003
54546 +++ b/fs/ext3/xattr.c   Sun Aug 31 16:15:47 2003
54547 @@ -873,17 +873,22 @@
54548                const void *value, size_t value_len, int flags)
54549  {
54550         handle_t *handle;
54551 -       int error, error2;
54552 +       int error;
54553  
54554         handle = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS);
54555 -       if (IS_ERR(handle))
54556 +       if (IS_ERR(handle)) {
54557                 error = PTR_ERR(handle);
54558 -       else
54559 +       } else {
54560 +               int error2;
54561 +
54562                 error = ext3_xattr_set_handle(handle, inode, name_index, name,
54563                                               value, value_len, flags);
54564 -       error2 = ext3_journal_stop(handle);
54565 +               error2 = ext3_journal_stop(handle);
54566 +               if (error == 0)
54567 +                       error = error2;
54568 +       }
54569  
54570 -       return error ? error : error2;
54571 +       return error;
54572  }
54573  
54574  /*
54575 diff -Nru a/fs/fcntl.c b/fs/fcntl.c
54576 --- a/fs/fcntl.c        Thu Jun  5 23:36:40 2003
54577 +++ b/fs/fcntl.c        Sun Aug 31 16:14:42 2003
54578 @@ -6,6 +6,7 @@
54579  
54580  #include <linux/init.h>
54581  #include <linux/mm.h>
54582 +#include <linux/fs.h>
54583  #include <linux/file.h>
54584  #include <linux/dnotify.h>
54585  #include <linux/smp_lock.h>
54586 @@ -17,9 +18,6 @@
54587  #include <asm/poll.h>
54588  #include <asm/siginfo.h>
54589  #include <asm/uaccess.h>
54590 -
54591 -extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
54592 -extern int fcntl_getlease(struct file *filp);
54593  
54594  void set_close_on_exec(unsigned int fd, int flag)
54595  {
54596 diff -Nru a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
54597 --- a/fs/freevxfs/vxfs_inode.c  Sun Nov 17 11:53:57 2002
54598 +++ b/fs/freevxfs/vxfs_inode.c  Sun Aug 31 16:14:27 2003
54599 @@ -171,7 +171,7 @@
54600         return NULL;
54601  
54602  fail:
54603 -       printk(KERN_WARNING "vxfs: unable to read inode %ld\n", ino);
54604 +       printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino);
54605         vxfs_put_page(pp);
54606         return NULL;
54607  }
54608 diff -Nru a/fs/hpfs/namei.c b/fs/hpfs/namei.c
54609 --- a/fs/hpfs/namei.c   Sun Jun 29 23:49:25 2003
54610 +++ b/fs/hpfs/namei.c   Tue Aug 26 09:37:39 2003
54611 @@ -375,6 +375,7 @@
54612                 spin_lock(&dentry->d_lock);
54613                 if (atomic_read(&dentry->d_count) > 1 ||
54614                     permission(inode, MAY_WRITE, NULL) ||
54615 +                   !S_ISREG(inode->i_mode) ||
54616                     get_write_access(inode)) {
54617                         spin_unlock(&dentry->d_lock);
54618                         d_rehash(dentry);
54619 diff -Nru a/fs/intermezzo/presto.c b/fs/intermezzo/presto.c
54620 --- a/fs/intermezzo/presto.c    Fri Dec 13 17:27:19 2002
54621 +++ b/fs/intermezzo/presto.c    Tue Aug 26 09:33:56 2003
54622 @@ -66,8 +66,8 @@
54623          cache = presto_get_cache(inode);
54624          CDEBUG(D_PSDEV, "\n");
54625          if ( !cache ) {
54626 -                CERROR("PRESTO: BAD: cannot find cache for dev %d, ino %ld\n",
54627 -                       inode->i_sb->s_dev, inode->i_ino);
54628 +                CERROR("PRESTO: BAD: cannot find cache for dev %s, ino %ld\n",
54629 +                       inode->i_sb->s_id, inode->i_ino);
54630                  EXIT;
54631                  return -1;
54632          }
54633 diff -Nru a/fs/intermezzo/vfs.c b/fs/intermezzo/vfs.c
54634 --- a/fs/intermezzo/vfs.c       Thu Aug  7 10:29:14 2003
54635 +++ b/fs/intermezzo/vfs.c       Tue Aug 26 09:33:56 2003
54636 @@ -743,7 +743,7 @@
54637                  goto exit_lock;
54638  
54639          error = -EXDEV;
54640 -        if (dir->d_inode->i_sb->s_dev != inode->i_sb->s_dev)
54641 +        if (dir->d_inode->i_sb != inode->i_sb)
54642                  goto exit_lock;
54643  
54644          /*
54645 @@ -1800,7 +1800,7 @@
54646          if (error)
54647                  return error;
54648  
54649 -        if (new_dir->i_sb->s_dev != old_dir->i_sb->s_dev)
54650 +        if (new_dir->i_sb != old_dir->i_sb)
54651                  return -EXDEV;
54652  
54653          if (!new_dentry->d_inode)
54654 @@ -1881,7 +1881,7 @@
54655          if (error)
54656                  return error;
54657  
54658 -        if (new_dir->i_sb->s_dev != old_dir->i_sb->s_dev)
54659 +        if (new_dir->i_sb != old_dir->i_sb)
54660                  return -EXDEV;
54661  
54662          if (!new_dentry->d_inode)
54663 diff -Nru a/fs/jbd/journal.c b/fs/jbd/journal.c
54664 --- a/fs/jbd/journal.c  Sat Aug 16 11:46:50 2003
54665 +++ b/fs/jbd/journal.c  Sun Aug 31 16:14:25 2003
54666 @@ -1890,7 +1890,6 @@
54667  {
54668         int ret;
54669  
54670 -       printk(KERN_INFO "Journalled Block Device driver loaded\n");
54671         ret = journal_init_caches();
54672         if (ret != 0)
54673                 journal_destroy_caches();
54674 diff -Nru a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
54675 --- a/fs/jffs/inode-v23.c       Thu Aug 14 18:17:32 2003
54676 +++ b/fs/jffs/inode-v23.c       Sun Aug 31 16:13:59 2003
54677 @@ -1080,9 +1080,11 @@
54678         struct jffs_control *c;
54679         struct inode *inode;
54680         int result = 0;
54681 -       kdev_t dev = to_kdev_t(rdev);
54682 +       u16 data;
54683         int err;
54684  
54685 +       data = (MAJOR(rdev) << 8) | MINOR(rdev);
54686 +
54687         D1(printk("***jffs_mknod()\n"));
54688  
54689         lock_kernel();
54690 @@ -1114,7 +1116,7 @@
54691         raw_inode.mtime = raw_inode.atime;
54692         raw_inode.ctime = raw_inode.atime;
54693         raw_inode.offset = 0;
54694 -       raw_inode.dsize = sizeof(kdev_t);
54695 +       raw_inode.dsize = 2;
54696         raw_inode.rsize = 0;
54697         raw_inode.nsize = dentry->d_name.len;
54698         raw_inode.nlink = 1;
54699 @@ -1124,7 +1126,7 @@
54700  
54701         /* Write the new node to the flash.  */
54702         if ((err = jffs_write_node(c, node, &raw_inode, dentry->d_name.name,
54703 -                                  (unsigned char *)&dev, 0, NULL)) < 0) {
54704 +                                  (unsigned char *)&data, 0, NULL)) < 0) {
54705                 D(printk("jffs_mknod(): jffs_write_node() failed.\n"));
54706                 result = err;
54707                 goto jffs_mknod_err;
54708 @@ -1530,7 +1532,7 @@
54709         return err;
54710  } /* jffs_file_write()  */
54711  
54712 -static ssize_t
54713 +static int
54714  jffs_prepare_write(struct file *filp, struct page *page,
54715                    unsigned from, unsigned to)
54716  {
54717 @@ -1543,7 +1545,7 @@
54718         return 0;
54719  } /* jffs_prepare_write() */
54720  
54721 -static ssize_t
54722 +static int
54723  jffs_commit_write(struct file *filp, struct page *page,
54724                   unsigned from, unsigned to)
54725  {
54726 @@ -1732,9 +1734,10 @@
54727                 /* If the node is a device of some sort, then the number of
54728                    the device should be read from the flash memory and then
54729                    added to the inode's i_rdev member.  */
54730 -               kdev_t rdev;
54731 -               jffs_read_data(f, (char *)&rdev, 0, sizeof(kdev_t));
54732 -               init_special_inode(inode, inode->i_mode, kdev_t_to_nr(rdev));
54733 +               u16 val;
54734 +               jffs_read_data(f, (char *)val, 0, 2);
54735 +               init_special_inode(inode, inode->i_mode,
54736 +                       MKDEV((val >> 8) & 255, val & 255));
54737         }
54738  
54739         D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
54740 diff -Nru a/fs/jffs2/file.c b/fs/jffs2/file.c
54741 --- a/fs/jffs2/file.c   Wed May 28 08:01:06 2003
54742 +++ b/fs/jffs2/file.c   Tue Aug 26 09:25:41 2003
54743 @@ -103,8 +103,8 @@
54744            it out again with the appropriate data attached */
54745         if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
54746                 /* For these, we don't actually need to read the old node */
54747 -               dev =  (major(dentry->d_inode->i_rdev) << 8) | 
54748 -                       minor(dentry->d_inode->i_rdev);
54749 +               dev =  (imajor(dentry->d_inode) << 8) | 
54750 +                       iminor(dentry->d_inode);
54751                 mdata = (char *)&dev;
54752                 mdatalen = sizeof(dev);
54753                 D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen));
54754 diff -Nru a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
54755 --- a/fs/jffs2/os-linux.h       Mon Jun 23 06:03:50 2003
54756 +++ b/fs/jffs2/os-linux.h       Tue Aug 26 09:25:41 2003
54757 @@ -44,8 +44,8 @@
54758  #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
54759  
54760  #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,1)
54761 -#define JFFS2_F_I_RDEV_MIN(f) (minor(OFNI_EDONI_2SFFJ(f)->i_rdev))
54762 -#define JFFS2_F_I_RDEV_MAJ(f) (major(OFNI_EDONI_2SFFJ(f)->i_rdev))
54763 +#define JFFS2_F_I_RDEV_MIN(f) (iminor(OFNI_EDONI_2SFFJ(f)))
54764 +#define JFFS2_F_I_RDEV_MAJ(f) (imajor(OFNI_EDONI_2SFFJ(f)))
54765  #else
54766  #define JFFS2_F_I_RDEV_MIN(f) (MINOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
54767  #define JFFS2_F_I_RDEV_MAJ(f) (MAJOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
54768 diff -Nru a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
54769 --- a/fs/jffs2/wbuf.c   Wed May 28 08:01:07 2003
54770 +++ b/fs/jffs2/wbuf.c   Sun Aug 31 16:14:08 2003
54771 @@ -37,8 +37,8 @@
54772  #define NAND_JFFS2_OOB16_FSDALEN       8
54773  
54774  struct nand_oobinfo jffs2_oobinfo = {
54775 -       useecc: 1,
54776 -       eccpos: {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1, JFFS2_OOB_ECCPOS2, JFFS2_OOB_ECCPOS3, JFFS2_OOB_ECCPOS4, JFFS2_OOB_ECCPOS5}
54777 +       .useecc = 1,
54778 +       .eccpos = {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1, JFFS2_OOB_ECCPOS2, JFFS2_OOB_ECCPOS3, JFFS2_OOB_ECCPOS4, JFFS2_OOB_ECCPOS5}
54779  };
54780  
54781  static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c)
54782 diff -Nru a/fs/nfs/inode.c b/fs/nfs/inode.c
54783 --- a/fs/nfs/inode.c    Fri Jul 11 10:32:02 2003
54784 +++ b/fs/nfs/inode.c    Tue Aug 26 09:37:39 2003
54785 @@ -620,7 +620,7 @@
54786         NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);
54787         NFS_ATTRTIMEO_UPDATE(inode) = jiffies;
54788  
54789 -       invalidate_inode_pages(inode->i_mapping);
54790 +       invalidate_remote_inode(inode);
54791  
54792         memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
54793         NFS_CACHEINV(inode);
54794 @@ -823,14 +823,15 @@
54795                 goto out;
54796         }
54797  
54798 -       if (!S_ISREG(inode->i_mode))
54799 +       if (!S_ISREG(inode->i_mode)) {
54800                 attr->ia_valid &= ~ATTR_SIZE;
54801 -
54802 -       filemap_fdatawrite(inode->i_mapping);
54803 -       error = nfs_wb_all(inode);
54804 -       filemap_fdatawait(inode->i_mapping);
54805 -       if (error)
54806 -               goto out;
54807 +       } else {
54808 +               filemap_fdatawrite(inode->i_mapping);
54809 +               error = nfs_wb_all(inode);
54810 +               filemap_fdatawait(inode->i_mapping);
54811 +               if (error)
54812 +                       goto out;
54813 +       }
54814  
54815         error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr);
54816         if (error)
54817 @@ -1205,7 +1206,7 @@
54818         if (invalid) {
54819                 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
54820                 nfsi->attrtimeo_timestamp = jiffies;
54821 -               invalidate_inode_pages(inode->i_mapping);
54822 +               invalidate_remote_inode(inode);
54823                 memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
54824         } else if (time_after(jiffies, nfsi->attrtimeo_timestamp+nfsi->attrtimeo)) {
54825                 if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode))
54826 diff -Nru a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54827 --- a/fs/nfsd/nfs4proc.c        Thu Jun 26 21:26:02 2003
54828 +++ b/fs/nfsd/nfs4proc.c        Sun Aug 31 16:14:23 2003
54829 @@ -106,7 +106,8 @@
54830  nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
54831  {
54832         int status;
54833 -       dprintk("NFSD: nfsd4_open filename %.*s\n",open->op_fname.len, open->op_fname.data);
54834 +       dprintk("NFSD: nfsd4_open filename %.*s\n",
54835 +               (int)open->op_fname.len, open->op_fname.data);
54836  
54837         /* This check required by spec. */
54838         if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
54839 diff -Nru a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
54840 --- a/fs/nfsd/nfs4state.c       Thu Jul 31 16:53:11 2003
54841 +++ b/fs/nfsd/nfs4state.c       Sun Aug 31 16:14:23 2003
54842 @@ -688,7 +688,7 @@
54843  #define OPENSTATEID_HASH_MASK              (OPENSTATEID_HASH_SIZE - 1)
54844  
54845  #define file_hashval(x) \
54846 -        ((unsigned int)((x)->dev + (x)->ino + (x)->generation) & FILE_HASH_MASK)
54847 +        hash_ptr(x, FILE_HASH_BITS)
54848  #define openstateid_hashval(owner_id, file_id)  \
54849          (((owner_id) + (file_id)) & OPENSTATEID_HASH_MASK)
54850  
54851 @@ -697,13 +697,13 @@
54852  
54853  /* OPEN Share state helper functions */
54854  static inline struct nfs4_file *
54855 -alloc_init_file(unsigned int hashval, nfs4_ino_desc_t *ino) {
54856 +alloc_init_file(unsigned int hashval, struct inode *ino) {
54857         struct nfs4_file *fp;
54858         if ((fp = kmalloc(sizeof(struct nfs4_file),GFP_KERNEL))) {
54859                 INIT_LIST_HEAD(&fp->fi_hash);
54860                 INIT_LIST_HEAD(&fp->fi_perfile);
54861                 list_add(&fp->fi_hash, &file_hashtbl[hashval]);
54862 -               memcpy(&fp->fi_ino, ino, sizeof(nfs4_ino_desc_t));
54863 +               fp->fi_inode = igrab(ino);
54864                 fp->fi_id = current_fileid++;
54865                 alloc_file++;
54866                 return fp;
54867 @@ -841,11 +841,12 @@
54868  {
54869         free_file++;
54870         list_del_init(&fp->fi_hash);
54871 +       iput(fp->fi_inode);
54872         kfree(fp);
54873  }      
54874  
54875  void
54876 -release_open_state(struct nfs4_stateid *stp)
54877 +release_open_state(struct nfs4_stateid *stp, struct nfsd4_close *cl)
54878  {
54879         struct nfs4_stateowner *sop = stp->st_stateowner;
54880         struct nfs4_file *fp = stp->st_file;
54881 @@ -860,6 +861,7 @@
54882          */
54883         if (sop->so_confirmed && list_empty(&sop->so_peropenstate)) {
54884                 release_stateowner(sop);
54885 +               cl->cl_stateowner = NULL;
54886         }
54887         /* unused nfs4_file's are releseed. XXX slab cache? */
54888         if (list_empty(&fp->fi_perfile)) {
54889 @@ -911,13 +913,13 @@
54890  
54891  /* search file_hashtbl[] for file */
54892  static int
54893 -find_file(unsigned int hashval, nfs4_ino_desc_t *ino, struct nfs4_file **fp) {
54894 +find_file(unsigned int hashval, struct inode *ino, struct nfs4_file **fp) {
54895         struct list_head *pos, *next;
54896         struct nfs4_file *local = NULL;
54897  
54898         list_for_each_safe(pos, next, &file_hashtbl[hashval]) {
54899                 local = list_entry(pos, struct nfs4_file, fi_hash);
54900 -               if(!memcmp(&local->fi_ino, ino, sizeof(nfs4_ino_desc_t))) {
54901 +               if (local->fi_inode == ino) {
54902                         *fp = local;
54903                         return(1);
54904                 }
54905 @@ -934,24 +936,10 @@
54906         return 1;
54907  }
54908  
54909 -static inline void
54910 -nfs4_init_ino(nfs4_ino_desc_t *ino, struct svc_fh *fhp)
54911 -{
54912 -       struct inode *inode;
54913 -       if (!fhp->fh_dentry)
54914 -               BUG();
54915 -       inode = fhp->fh_dentry->d_inode;
54916 -       if (!inode)
54917 -               BUG();
54918 -       ino->dev = inode->i_sb->s_dev;
54919 -       ino->ino = inode->i_ino;
54920 -       ino->generation = inode->i_generation;
54921 -}
54922 -
54923  int
54924  nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
54925  {
54926 -       nfs4_ino_desc_t ino;
54927 +       struct inode *ino = current_fh->fh_dentry->d_inode;
54928         unsigned int fi_hashval;
54929         struct nfs4_file *fp;
54930         struct nfs4_stateid *stp;
54931 @@ -959,9 +947,8 @@
54932  
54933         dprintk("NFSD: nfs4_share_conflict\n");
54934  
54935 -       nfs4_init_ino(&ino, current_fh);
54936 -       fi_hashval = file_hashval(&ino);
54937 -       if (find_file(fi_hashval, &ino, &fp)) {
54938 +       fi_hashval = file_hashval(ino);
54939 +       if (find_file(fi_hashval, ino, &fp)) {
54940         /* Search for conflicting share reservations */
54941                 list_for_each_safe(pos, next, &fp->fi_perfile) {
54942                         stp = list_entry(pos, struct nfs4_stateid, st_perfile);
54943 @@ -1084,7 +1071,7 @@
54944         struct iattr iattr;
54945         struct nfs4_stateowner *sop = open->op_stateowner;
54946         struct nfs4_file *fp;
54947 -       nfs4_ino_desc_t ino;
54948 +       struct inode *ino;
54949         unsigned int fi_hashval;
54950         struct list_head *pos, *next;
54951         struct nfs4_stateid *stq, *stp = NULL;
54952 @@ -1094,11 +1081,11 @@
54953         if (!sop)
54954                 goto out;
54955  
54956 -       nfs4_init_ino(&ino, current_fh);
54957 +       ino = current_fh->fh_dentry->d_inode;
54958  
54959         down(&client_sema); /*XXX need finer grained locking */
54960 -       fi_hashval = file_hashval(&ino);
54961 -       if (find_file(fi_hashval, &ino, &fp)) {
54962 +       fi_hashval = file_hashval(ino);
54963 +       if (find_file(fi_hashval, ino, &fp)) {
54964                 /* Search for conflicting share reservations */
54965                 status = nfserr_share_denied;
54966                 list_for_each_safe(pos, next, &fp->fi_perfile) {
54967 @@ -1113,7 +1100,7 @@
54968         } else {
54969         /* No nfs4_file found; allocate and init a new one */
54970                 status = nfserr_resource;
54971 -               if ((fp = alloc_init_file(fi_hashval, &ino)) == NULL)
54972 +               if ((fp = alloc_init_file(fi_hashval, ino)) == NULL)
54973                         goto out;
54974         }
54975  
54976 @@ -1172,6 +1159,9 @@
54977         open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE;
54978         status = nfs_ok;
54979  out:
54980 +       if (fp && list_empty(&fp->fi_perfile))
54981 +               release_file(fp);
54982 +
54983         /*
54984         * To finish the open response, we just need to set the rflags.
54985         */
54986 @@ -1494,7 +1484,7 @@
54987         struct nfs4_stateid *stp;
54988  
54989         dprintk("NFSD: nfsd4_open_confirm on file %.*s\n",
54990 -                       current_fh->fh_dentry->d_name.len,
54991 +                       (int)current_fh->fh_dentry->d_name.len,
54992                         current_fh->fh_dentry->d_name.name);
54993         oc->oc_stateowner = NULL;
54994         down(&client_sema); /* XXX need finer grained locking */
54995 @@ -1528,7 +1518,7 @@
54996         struct nfs4_stateid *stp;
54997  
54998         dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n", 
54999 -                       current_fh->fh_dentry->d_name.len, 
55000 +                       (int)current_fh->fh_dentry->d_name.len,
55001                         current_fh->fh_dentry->d_name.name);
55002  
55003         down(&client_sema); /* XXX need finer grained locking */
55004 @@ -1567,7 +1557,7 @@
55005         struct nfs4_stateid *stp;
55006  
55007         dprintk("NFSD: nfsd4_close on file %.*s\n", 
55008 -                       current_fh->fh_dentry->d_name.len, 
55009 +                       (int)current_fh->fh_dentry->d_name.len,
55010                         current_fh->fh_dentry->d_name.name);
55011  
55012         down(&client_sema); /* XXX need finer grained locking */
55013 @@ -1584,7 +1574,7 @@
55014         memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t));
55015  
55016         /* release_open_state() calls nfsd_close() if needed */
55017 -       release_open_state(stp);
55018 +       release_open_state(stp,close);
55019  out:
55020         up(&client_sema);
55021         return status;
55022 diff -Nru a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
55023 --- a/fs/nfsd/nfs4xdr.c Sun Aug  3 21:42:17 2003
55024 +++ b/fs/nfsd/nfs4xdr.c Sat Aug 23 15:07:47 2003
55025 @@ -1631,6 +1631,8 @@
55026                 WRITEMEM(&close->cl_stateid.si_opaque, sizeof(stateid_opaque_t));
55027                 ADJUST_ARGS();
55028         }
55029 +       if ((close->cl_stateowner) && (close->cl_stateowner->so_confirmed))
55030 +               close->cl_stateowner->so_seqid++;
55031  }
55032  
55033  
55034 @@ -1767,6 +1769,8 @@
55035         default:
55036                 BUG();
55037         }
55038 +
55039 +       ENCODE_SEQID_OP_TAIL(open->op_stateowner);
55040  }
55041  
55042  static int
55043 diff -Nru a/fs/open.c b/fs/open.c
55044 --- a/fs/open.c Mon Aug 18 22:38:39 2003
55045 +++ b/fs/open.c Sun Aug 31 16:14:00 2003
55046 @@ -945,20 +945,12 @@
55047   */
55048  int filp_close(struct file *filp, fl_owner_t id)
55049  {
55050 -       struct address_space *mapping = filp->f_dentry->d_inode->i_mapping;
55051 -       int retval = 0, err;
55052 +       int retval;
55053  
55054         /* Report and clear outstanding errors */
55055 -       err = filp->f_error;
55056 -       if (err) {
55057 +       retval = filp->f_error;
55058 +       if (retval)
55059                 filp->f_error = 0;
55060 -               retval = err;
55061 -       }
55062 -
55063 -       if (test_and_clear_bit(AS_ENOSPC, &mapping->flags))
55064 -               retval = -ENOSPC;
55065 -       if (test_and_clear_bit(AS_EIO, &mapping->flags))
55066 -               retval = -EIO;
55067  
55068         if (!file_count(filp)) {
55069                 printk(KERN_ERR "VFS: Close: file count is 0\n");
55070 @@ -966,7 +958,7 @@
55071         }
55072  
55073         if (filp->f_op && filp->f_op->flush) {
55074 -               err = filp->f_op->flush(filp);
55075 +               int err = filp->f_op->flush(filp);
55076                 if (!retval)
55077                         retval = err;
55078         }
55079 diff -Nru a/fs/partitions/check.c b/fs/partitions/check.c
55080 --- a/fs/partitions/check.c     Tue Aug 12 06:46:16 2003
55081 +++ b/fs/partitions/check.c     Tue Aug 26 12:06:15 2003
55082 @@ -267,7 +267,14 @@
55083  
55084  extern struct subsystem block_subsys;
55085  
55086 +static void part_release(struct kobject *kobj)
55087 +{
55088 +       struct hd_struct * p = container_of(kobj,struct hd_struct,kobj);
55089 +       kfree(p);
55090 +}
55091 +
55092  struct kobj_type ktype_part = {
55093 +       .release        = part_release,
55094         .default_attrs  = default_attrs,
55095         .sysfs_ops      = &part_sysfs_ops,
55096  };
55097 @@ -279,13 +286,12 @@
55098                 return;
55099         if (!p->nr_sects)
55100                 return;
55101 +       disk->part[part-1] = NULL;
55102         p->start_sect = 0;
55103         p->nr_sects = 0;
55104         p->reads = p->writes = p->read_sectors = p->write_sectors = 0;
55105         devfs_remove("%s/part%d", disk->devfs_name, part);
55106         kobject_unregister(&p->kobj);
55107 -       disk->part[part-1] = NULL;
55108 -       kfree(p);
55109  }
55110  
55111  void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
55112 @@ -300,7 +306,6 @@
55113         p->start_sect = start;
55114         p->nr_sects = len;
55115         p->partno = part;
55116 -       disk->part[part-1] = p;
55117  
55118         devfs_mk_bdev(MKDEV(disk->major, disk->first_minor + part),
55119                         S_IFBLK|S_IRUSR|S_IWUSR,
55120 @@ -310,6 +315,7 @@
55121         p->kobj.parent = &disk->kobj;
55122         p->kobj.ktype = &ktype_part;
55123         kobject_register(&p->kobj);
55124 +       disk->part[part-1] = p;
55125  }
55126  
55127  static void disk_sysfs_symlinks(struct gendisk *disk)
55128 diff -Nru a/fs/proc/base.c b/fs/proc/base.c
55129 --- a/fs/proc/base.c    Thu Jul 10 22:23:45 2003
55130 +++ b/fs/proc/base.c    Sun Aug 31 16:13:56 2003
55131 @@ -864,19 +864,34 @@
55132   *     Exceptional case: normally we are not allowed to unhash a busy
55133   * directory. In this case, however, we can do it - no aliasing problems
55134   * due to the way we treat inodes.
55135 + *
55136 + * Rewrite the inode's ownerships here because the owning task may have
55137 + * performed a setuid(), etc.
55138   */
55139 -static int pid_revalidate(struct dentry * dentry, struct nameidata *nd)
55140 +static int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
55141  {
55142 -       if (pid_alive(proc_task(dentry->d_inode)))
55143 +       struct inode *inode = dentry->d_inode;
55144 +       struct task_struct *task = proc_task(inode);
55145 +       if (pid_alive(task)) {
55146 +               if (proc_type(inode) == PROC_PID_INO || task_dumpable(task)) {
55147 +                       inode->i_uid = task->euid;
55148 +                       inode->i_gid = task->egid;
55149 +               } else {
55150 +                       inode->i_uid = 0;
55151 +                       inode->i_gid = 0;
55152 +               }
55153 +               security_task_to_inode(task, inode);
55154                 return 1;
55155 +       }
55156         d_drop(dentry);
55157         return 0;
55158  }
55159  
55160 -static int pid_fd_revalidate(struct dentry * dentry, struct nameidata *nd)
55161 +static int pid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
55162  {
55163 -       struct task_struct *task = proc_task(dentry->d_inode);
55164 -       int fd = proc_type(dentry->d_inode) - PROC_PID_FD_DIR;
55165 +       struct inode *inode = dentry->d_inode;
55166 +       struct task_struct *task = proc_task(inode);
55167 +       int fd = proc_type(inode) - PROC_PID_FD_DIR;
55168         struct files_struct *files;
55169  
55170         task_lock(task);
55171 @@ -889,6 +904,14 @@
55172                 if (fcheck_files(files, fd)) {
55173                         spin_unlock(&files->file_lock);
55174                         put_files_struct(files);
55175 +                       if (task_dumpable(task)) {
55176 +                               inode->i_uid = task->euid;
55177 +                               inode->i_gid = task->egid;
55178 +                       } else {
55179 +                               inode->i_uid = 0;
55180 +                               inode->i_gid = 0;
55181 +                       }
55182 +                       security_task_to_inode(task, inode);
55183                         return 1;
55184                 }
55185                 spin_unlock(&files->file_lock);
55186 diff -Nru a/fs/proc/kcore.c b/fs/proc/kcore.c
55187 --- a/fs/proc/kcore.c   Fri Jun 20 13:16:05 2003
55188 +++ b/fs/proc/kcore.c   Sun Aug 31 16:14:22 2003
55189 @@ -1,5 +1,5 @@
55190  /*
55191 - *     fs/proc/kcore.c kernel ELF/AOUT core dumper
55192 + *     fs/proc/kcore.c kernel ELF core dumper
55193   *
55194   *     Modelled on fs/exec.c:aout_core_dump()
55195   *     Jeremy Fitzhardinge <jeremy@sw.oz.au>
55196 @@ -34,71 +34,6 @@
55197         .open           = open_kcore,
55198  };
55199  
55200 -#ifdef CONFIG_KCORE_AOUT
55201 -static ssize_t read_kcore(struct file *file, char *buf, size_t count, loff_t *ppos)
55202 -{
55203 -       unsigned long long p = *ppos, memsize;
55204 -       ssize_t read;
55205 -       ssize_t count1;
55206 -       char * pnt;
55207 -       struct user dump;
55208 -#if defined (__i386__) || defined (__mc68000__) || defined(__x86_64__)
55209 -#      define FIRST_MAPPED     PAGE_SIZE       /* we don't have page 0 mapped on x86.. */
55210 -#else
55211 -#      define FIRST_MAPPED     0
55212 -#endif
55213 -
55214 -       memset(&dump, 0, sizeof(struct user));
55215 -       dump.magic = CMAGIC;
55216 -       dump.u_dsize = (virt_to_phys(high_memory) >> PAGE_SHIFT);
55217 -#if defined (__i386__) || defined(__x86_64__)
55218 -       dump.start_code = PAGE_OFFSET;
55219 -#endif
55220 -#ifdef __alpha__
55221 -       dump.start_data = PAGE_OFFSET;
55222 -#endif
55223 -
55224 -       memsize = virt_to_phys(high_memory);
55225 -       if (p >= memsize)
55226 -               return 0;
55227 -       if (count > memsize - p)
55228 -               count = memsize - p;
55229 -       read = 0;
55230 -
55231 -       if (p < sizeof(struct user) && count > 0) {
55232 -               count1 = count;
55233 -               if (p + count1 > sizeof(struct user))
55234 -                       count1 = sizeof(struct user)-p;
55235 -               pnt = (char *) &dump + p;
55236 -               if (copy_to_user(buf,(void *) pnt, count1))
55237 -                       return -EFAULT;
55238 -               buf += count1;
55239 -               p += count1;
55240 -               count -= count1;
55241 -               read += count1;
55242 -       }
55243 -
55244 -       if (count > 0 && p < PAGE_SIZE + FIRST_MAPPED) {
55245 -               count1 = PAGE_SIZE + FIRST_MAPPED - p;
55246 -               if (count1 > count)
55247 -                       count1 = count;
55248 -               if (clear_user(buf, count1))
55249 -                       return -EFAULT;
55250 -               buf += count1;
55251 -               p += count1;
55252 -               count -= count1;
55253 -               read += count1;
55254 -       }
55255 -       if (count > 0) {
55256 -               if (copy_to_user(buf, (void *) (PAGE_OFFSET+p-PAGE_SIZE), count))
55257 -                       return -EFAULT;
55258 -               read += count;
55259 -       }
55260 -       *ppos += read;
55261 -       return read;
55262 -}
55263 -#else /* CONFIG_KCORE_AOUT */
55264 -
55265  #ifndef kc_vaddr_to_offset
55266  #define        kc_vaddr_to_offset(v) ((v) - PAGE_OFFSET)
55267  #endif
55268 @@ -480,4 +415,3 @@
55269  
55270         return acc;
55271  }
55272 -#endif /* CONFIG_KCORE_AOUT */
55273 diff -Nru a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55274 --- a/fs/proc/task_mmu.c        Thu Jun 19 16:57:39 2003
55275 +++ b/fs/proc/task_mmu.c        Sat Aug 23 05:08:00 2003
55276 @@ -90,14 +90,14 @@
55277                 ino = inode->i_ino;
55278         }
55279  
55280 -       seq_printf(m, "%0*lx-%0*lx %c%c%c%c %0*lx %02x:%02x %lu %n",
55281 -                       (int) (2*sizeof(void*)), map->vm_start,
55282 -                       (int) (2*sizeof(void*)), map->vm_end,
55283 +       seq_printf(m, "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n",
55284 +                       map->vm_start,
55285 +                       map->vm_end,
55286                         flags & VM_READ ? 'r' : '-',
55287                         flags & VM_WRITE ? 'w' : '-',
55288                         flags & VM_EXEC ? 'x' : '-',
55289                         flags & VM_MAYSHARE ? 's' : 'p',
55290 -                       (int) (2*sizeof(void*)), map->vm_pgoff << PAGE_SHIFT,
55291 +                       map->vm_pgoff << PAGE_SHIFT,
55292                         MAJOR(dev), MINOR(dev), ino, &len);
55293  
55294         if (map->vm_file) {
55295 diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
55296 --- a/fs/reiserfs/inode.c       Mon Aug 18 22:42:17 2003
55297 +++ b/fs/reiserfs/inode.c       Sun Aug 31 16:14:17 2003
55298 @@ -2048,8 +2048,8 @@
55299          last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1) ;
55300         /* no file contents in this page */
55301         if (page->index >= end_index + 1 || !last_offset) {
55302 -           error = 0 ;
55303 -           goto done ;
55304 +           unlock_page(page);
55305 +           return 0;
55306         }
55307         kaddr = kmap_atomic(page, KM_USER0);
55308         memset(kaddr + last_offset, 0, PAGE_CACHE_SIZE-last_offset) ;
55309 diff -Nru a/fs/smbfs/inode.c b/fs/smbfs/inode.c
55310 --- a/fs/smbfs/inode.c  Wed Jun 25 16:30:54 2003
55311 +++ b/fs/smbfs/inode.c  Tue Aug 26 09:37:39 2003
55312 @@ -212,7 +212,7 @@
55313                         (long) last_sz, (long) inode->i_size);
55314  
55315                 if (!S_ISDIR(inode->i_mode))
55316 -                       invalidate_inode_pages(inode->i_mapping);
55317 +                       invalidate_remote_inode(inode);
55318         }
55319  }
55320  
55321 @@ -276,7 +276,7 @@
55322                          * But we do want to invalidate the caches ...
55323                          */
55324                         if (!S_ISDIR(inode->i_mode))
55325 -                               invalidate_inode_pages(inode->i_mapping);
55326 +                               invalidate_remote_inode(inode);
55327                         else
55328                                 smb_invalid_dir_cache(inode);
55329                         error = -EIO;
55330 diff -Nru a/fs/vfat/namei.c b/fs/vfat/namei.c
55331 --- a/fs/vfat/namei.c   Sat Aug  2 15:10:30 2003
55332 +++ b/fs/vfat/namei.c   Mon Sep  1 08:45:36 2003
55333 @@ -200,20 +200,6 @@
55334         return 1;
55335  }
55336  
55337 -/* MS-DOS "device special files" */
55338 -
55339 -static const unsigned char *reserved3_names[] = {
55340 -       "con     ", "prn     ", "nul     ", "aux     ", NULL
55341 -};
55342 -
55343 -static const unsigned char *reserved4_names[] = {
55344 -       "com1    ", "com2    ", "com3    ", "com4    ", "com5    ",
55345 -       "com6    ", "com7    ", "com8    ", "com9    ",
55346 -       "lpt1    ", "lpt2    ", "lpt3    ", "lpt4    ", "lpt5    ",
55347 -       "lpt6    ", "lpt7    ", "lpt8    ", "lpt9    ",
55348 -       NULL };
55349 -
55350 -
55351  /* Characters that are undesirable in an MS-DOS file name */
55352  
55353  static wchar_t bad_chars[] = {
55354 @@ -255,38 +241,31 @@
55355         return 0;
55356  }
55357  
55358 -/* Checks the validity of a long MS-DOS filename */
55359 -/* Returns negative number on error, 0 for a normal
55360 - * return, and 1 for . or .. */
55361 -
55362 -static int vfat_valid_longname(const unsigned char *name, int len, int xlate)
55363 +static int vfat_valid_longname(const unsigned char *name, unsigned int len)
55364  {
55365 -       const unsigned char **reserved, *walk;
55366 -       int baselen;
55367 -
55368         if (len && name[len-1] == ' ')
55369 -               return -EINVAL;
55370 +               return 0;
55371         if (len >= 256)
55372 -               return -EINVAL;
55373 -       if (len < 3)
55374                 return 0;
55375  
55376 -       for (walk = name; *walk != 0 && *walk != '.'; walk++)
55377 -               ;
55378 -       baselen = walk - name;
55379 -
55380 -       if (baselen == 3) {
55381 -               for (reserved = reserved3_names; *reserved; reserved++) {
55382 -                       if (!strnicmp(name,*reserved,baselen))
55383 -                               return -EINVAL;
55384 -               }
55385 -       } else if (baselen == 4) {
55386 -               for (reserved = reserved4_names; *reserved; reserved++) {
55387 -                       if (!strnicmp(name,*reserved,baselen))
55388 -                               return -EINVAL;
55389 +       /* MS-DOS "device special files" */
55390 +       if (len == 3 || (len > 3 && name[3] == '.')) {  /* basename == 3 */
55391 +               if (!strnicmp(name, "aux", 3) ||
55392 +                   !strnicmp(name, "con", 3) ||
55393 +                   !strnicmp(name, "nul", 3) ||
55394 +                   !strnicmp(name, "prn", 3))
55395 +                       return 0;
55396 +       }
55397 +       if (len == 4 || (len > 4 && name[4] == '.')) {  /* basename == 4 */
55398 +               /* "com1", "com2", ... */
55399 +               if ('1' <= name[3] && name[3] <= '9') {
55400 +                       if (!strnicmp(name, "com", 3) ||
55401 +                           !strnicmp(name, "lpt", 3))
55402 +                               return 0;
55403                 }
55404         }
55405 -       return 0;
55406 +
55407 +       return 1;
55408  }
55409  
55410  static int vfat_find_form(struct inode *dir, unsigned char *name)
55411 @@ -684,9 +663,8 @@
55412         loff_t offset;
55413  
55414         *slots = 0;
55415 -       res = vfat_valid_longname(name, len, opts->unicode_xlate);
55416 -       if (res < 0)
55417 -               return res;
55418 +       if (!vfat_valid_longname(name, len))
55419 +               return -EINVAL;
55420  
55421         if(!(page = __get_free_page(GFP_KERNEL)))
55422                 return -ENOMEM;
55423 diff -Nru a/include/asm-arm/apm.h b/include/asm-arm/apm.h
55424 --- /dev/null   Wed Dec 31 16:00:00 1969
55425 +++ b/include/asm-arm/apm.h     Thu Aug  7 11:38:41 2003
55426 @@ -0,0 +1,56 @@
55427 +/* -*- linux-c -*-
55428 + *
55429 + * (C) 2003 zecke@handhelds.org
55430 + *
55431 + * GPL version 2
55432 + *
55433 + * based on arch/arm/kernel/apm.c
55434 + * factor out the information needed by architectures to provide
55435 + * apm status
55436 + *
55437 + *
55438 + */
55439 +#ifndef ARM_ASM_SA1100_APM_H
55440 +#define ARM_ASM_SA1100_APM_H
55441 +
55442 +#include <linux/config.h>
55443 +
55444 +#ifdef CONFIG_APM
55445 +
55446 +
55447 +#define APM_AC_OFFLINE 0
55448 +#define APM_AC_ONLINE 1
55449 +#define APM_AC_BACKUP 2
55450 +#define APM_AC_UNKNOWN 0xFF
55451 +
55452 +#define APM_BATTERY_STATUS_HIGH 0
55453 +#define APM_BATTERY_STATUS_LOW  1
55454 +#define APM_BATTERY_STATUS_CRITICAL 2
55455 +#define APM_BATTERY_STATUS_CHARGING 3
55456 +#define APM_BATTERY_STATUS_UNKNOWN 0xFF
55457 +
55458 +#define APM_BATTERY_LIFE_UNKNOWN 0xFFFF
55459 +#define APM_BATTERY_LIFE_MINUTES 0x8000
55460 +#define APM_BATTERY_LIFE_VALUE_MASK 0x7FFF
55461 +
55462 +/*
55463 + * This structure gets filled in by the machine specific 'get_power_status'
55464 + * implementation.  Any fields which are not set default to a safe value.
55465 + */
55466 +struct apm_power_info {
55467 +       unsigned char   ac_line_status;
55468 +       unsigned char   battery_status;
55469 +       unsigned char   battery_flag;
55470 +       unsigned char   battery_life;
55471 +       int             time;
55472 +       int             units;
55473 +};
55474 +
55475 +/*
55476 + * This allows machines to provide their own "apm get power status" function.
55477 + */
55478 +extern void (*apm_get_power_status)(struct apm_power_info *);
55479 +#endif
55480 +
55481 +
55482 +#endif
55483 diff -Nru a/include/asm-arm/arch-ebsa285/time.h b/include/asm-arm/arch-ebsa285/time.h
55484 --- a/include/asm-arm/arch-ebsa285/time.h       Tue May 13 08:20:50 2003
55485 +++ b/include/asm-arm/arch-ebsa285/time.h       Sun Aug 24 07:55:20 2003
55486 @@ -181,12 +181,13 @@
55487  }
55488  
55489  
55490 +static unsigned long timer1_latch;
55491  
55492  static unsigned long timer1_gettimeoffset (void)
55493  {
55494 -       unsigned long value = LATCH - *CSR_TIMER1_VALUE;
55495 +       unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
55496  
55497 -       return ((tick_nsec / 1000) * value) / LATCH;
55498 +       return ((tick_nsec / 1000) * value) / timer1_latch;
55499  }
55500  
55501  static irqreturn_t
55502 @@ -260,8 +261,10 @@
55503             machine_is_personal_server()) {
55504                 gettimeoffset = timer1_gettimeoffset;
55505  
55506 +               timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
55507 +
55508                 *CSR_TIMER1_CLR  = 0;
55509 -               *CSR_TIMER1_LOAD = LATCH;
55510 +               *CSR_TIMER1_LOAD = timer1_latch;
55511                 *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
55512  
55513                 timer_irq.handler = timer1_interrupt;
55514 diff -Nru a/include/asm-arm/arch-ebsa285/timex.h b/include/asm-arm/arch-ebsa285/timex.h
55515 --- a/include/asm-arm/arch-ebsa285/timex.h      Tue Feb  5 09:39:51 2002
55516 +++ b/include/asm-arm/arch-ebsa285/timex.h      Sun Aug 24 07:55:20 2003
55517 @@ -11,8 +11,8 @@
55518   */
55519  
55520  /*
55521 - * On EBSA285 boards, the clock runs at 50MHz and is
55522 - * divided by a 4-bit prescaler.  Other boards use an
55523 - * ISA derived timer, and this is unused.
55524 + * We assume a constant here; this satisfies the maths in linux/timex.h
55525 + * and linux/time.h.  CLOCK_TICK_RATE is actually system dependent, but
55526 + * this must be a constant.
55527   */
55528 -#define CLOCK_TICK_RATE                (mem_fclk_21285 / 16)
55529 +#define CLOCK_TICK_RATE                (50000000/16)
55530 diff -Nru a/include/asm-arm/arch-iop3xx/iop310.h b/include/asm-arm/arch-iop3xx/iop310.h
55531 --- a/include/asm-arm/arch-iop3xx/iop310.h      Mon Apr 21 15:43:42 2003
55532 +++ b/include/asm-arm/arch-iop3xx/iop310.h      Wed Aug 13 16:46:20 2003
55533 @@ -12,6 +12,14 @@
55534  #define _IOP310_HW_H_
55535  
55536  /*
55537 + * This is needed for mixed drivers that need to work on all
55538 + * IOP3xx variants but behave slightly differently on each.
55539 + */
55540 +#ifndef __ASSEMBLY__
55541 +#define iop_is_310() ((processor_id & 0xffffe3f0) == 0x69052000)
55542 +#endif
55543 +
55544 +/*
55545   * IOP310 I/O and Mem space regions for PCI autoconfiguration
55546   */
55547  #define IOP310_PCISEC_LOWER_IO         0x90010000
55548 diff -Nru a/include/asm-arm/arch-iop3xx/iop321.h b/include/asm-arm/arch-iop3xx/iop321.h
55549 --- a/include/asm-arm/arch-iop3xx/iop321.h      Fri May 30 07:09:39 2003
55550 +++ b/include/asm-arm/arch-iop3xx/iop321.h      Wed Aug 13 16:46:20 2003
55551 @@ -15,6 +15,10 @@
55552  #define _IOP321_HW_H_
55553  
55554  
55555 +/*
55556 + * This is needed for mixed drivers that need to work on all
55557 + * IOP3xx variants but behave slightly differently on each.
55558 + */
55559  #ifndef __ASSEMBLY__
55560  #define iop_is_321() ((processor_id & 0xfffff7e0) == 0x69052420)
55561  #endif
55562 diff -Nru a/include/asm-arm/arch-iop3xx/memory.h b/include/asm-arm/arch-iop3xx/memory.h
55563 --- a/include/asm-arm/arch-iop3xx/memory.h      Tue Apr 15 08:12:47 2003
55564 +++ b/include/asm-arm/arch-iop3xx/memory.h      Wed Aug 13 16:46:20 2003
55565 @@ -66,4 +66,6 @@
55566  extern void *mu_mem;
55567  #endif
55568  
55569 +#define PFN_TO_NID(addr)       (0)
55570 +
55571  #endif
55572 diff -Nru a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
55573 --- a/include/asm-arm/arch-pxa/pxa-regs.h       Mon Apr 21 15:43:42 2003
55574 +++ b/include/asm-arm/arch-pxa/pxa-regs.h       Mon Jun 30 04:20:34 2003
55575 @@ -836,7 +836,7 @@
55576  
55577  #define GPIO1_RST              1       /* reset */
55578  #define GPIO6_MMCCLK           6       /* MMC Clock */
55579 -#define GPIO8_48MHz            7       /* 48 MHz clock output */
55580 +#define GPIO7_48MHz            7       /* 48 MHz clock output */
55581  #define GPIO8_MMCCS0           8       /* MMC Chip Select 0 */
55582  #define GPIO9_MMCCS1           9       /* MMC Chip Select 1 */
55583  #define GPIO10_RTCCLK          10      /* real time clock (1 Hz) */
55584 @@ -939,7 +939,7 @@
55585  
55586  #define GPIO1_RTS_MD           ( 1 | GPIO_ALT_FN_1_IN)
55587  #define GPIO6_MMCCLK_MD                ( 6 | GPIO_ALT_FN_1_OUT)
55588 -#define GPIO8_48MHz_MD         ( 8 | GPIO_ALT_FN_1_OUT)
55589 +#define GPIO7_48MHz_MD         ( 7 | GPIO_ALT_FN_1_OUT)
55590  #define GPIO8_MMCCS0_MD                ( 8 | GPIO_ALT_FN_1_OUT)
55591  #define GPIO9_MMCCS1_MD                ( 9 | GPIO_ALT_FN_1_OUT)
55592  #define GPIO10_RTCCLK_MD       (10 | GPIO_ALT_FN_1_OUT)
55593 diff -Nru a/include/asm-arm/arch-sa1100/simpad.h b/include/asm-arm/arch-sa1100/simpad.h
55594 --- a/include/asm-arm/arch-sa1100/simpad.h      Mon Feb 24 10:29:41 2003
55595 +++ b/include/asm-arm/arch-sa1100/simpad.h      Thu Aug  7 11:49:10 2003
55596 @@ -5,17 +5,13 @@
55597   *
55598   * This file contains the hardware specific definitions for SIMpad
55599   *
55600 - * 2001/05/14 Juergen Messerer <juergen.messerer@siemens.ch>
55601 + * 2001/05/14 Juergen Messerer <juergen.messerer@freesurf.ch>
55602   */
55603  
55604 -#ifndef SIMPAD_H
55605 -#define SIMPAD_H
55606 +#ifndef __ASM_ARCH_SIMPAD_H
55607 +#define __ASM_ARCH_SIMPAD_H
55608  
55609  
55610 -#ifndef __ASM_ARCH_HARDWARE_H
55611 -#error "include <asm/hardware.h> instead"
55612 -#endif
55613 -
55614  #define GPIO_UART1_RTS GPIO_GPIO14
55615  #define GPIO_UART1_DTR GPIO_GPIO7
55616  #define GPIO_UART1_CTS GPIO_GPIO8
55617 @@ -28,7 +24,8 @@
55618  #define GPIO_UART3_DCD GPIO_GPIO18
55619  #define GPIO_UART3_DSR GPIO_GPIO17
55620  
55621 -#define GPIO_UCB1300_IRQ       GPIO_GPIO (22)  /* UCB GPIO and touchscreen */
55622 +#define GPIO_POWER_BUTTON      GPIO_GPIO0
55623 +#define GPIO_UCB1300_IRQ       GPIO_GPIO22     /* UCB GPIO and touchscreen */
55624  
55625  #define IRQ_UART1_CTS  IRQ_GPIO15
55626  #define IRQ_UART1_DCD  GPIO_GPIO23
55627 @@ -37,21 +34,26 @@
55628  #define IRQ_UART3_DCD  GPIO_GPIO18
55629  #define IRQ_UART3_DSR  GPIO_GPIO17
55630  
55631 -#define IRQ_GPIO_UCB1300_IRQ IRQ_GPIO22 
55632 +#define IRQ_GPIO_UCB1300_IRQ IRQ_GPIO22
55633 +#define IRQ_GPIO_POWER_BUTTON IRQ_GPIO0
55634  
55635  
55636  /*---  PCMCIA  ---*/
55637  #define GPIO_CF_CD              GPIO_GPIO24
55638 -#define GPIO_CF_IRQ             GPIO_GPIO1          
55639 +#define GPIO_CF_IRQ             GPIO_GPIO1
55640  #define IRQ_GPIO_CF_IRQ         IRQ_GPIO1
55641 -#define IRQ_GPIO_CF_CD          IRQ_GPIO24      
55642 +#define IRQ_GPIO_CF_CD          IRQ_GPIO24
55643 +
55644 +/*--- SmartCard ---*/
55645 +#define GPIO_SMART_CARD                GPIO_GPIO10
55646 +#define IRQ_GPIO_SMARD_CARD    IRQ_GPIO10
55647  
55648 -// CS3 Latch is write only, a shadow is necessary 
55649 +// CS3 Latch is write only, a shadow is necessary
55650  
55651 -#define CS3BUSTYPE unsigned volatile long           
55652 +#define CS3BUSTYPE unsigned volatile long
55653  #define CS3_BASE        0xf1000000
55654  
55655 -#define VCC_5V_EN       0x0001 // For 5V PCMCIA 
55656 +#define VCC_5V_EN       0x0001 // For 5V PCMCIA
55657  #define VCC_3V_EN       0x0002 // FOR 3.3V PCMCIA
55658  #define EN1             0x0004 // This is only for EPROM's
55659  #define EN0             0x0008 // Both should be enable for 3.3V or 5V
55660 @@ -63,15 +65,43 @@
55661  #define IRDA_SD         0x0200 // Shutdown for powersave
55662  #define RS232_ON        0x0400
55663  #define SD_MEDIAQ       0x0800 // Shutdown for powersave
55664 -#define LED2_ON         0x1000 
55665 +#define LED2_ON         0x1000
55666  #define IRDA_MODE       0x2000 // Fast/Slow IrDA mode
55667  #define ENABLE_5V       0x4000 // Enable 5V circuit
55668  #define RESET_SIMCARD   0x8000
55669  
55670  #define RS232_ENABLE    0x0440
55671 -#define PCMCIAMASK      0x402f   
55672 +#define PCMCIAMASK      0x402f
55673 +
55674 +
55675 +struct simpad_battery {
55676 +       unsigned char ac_status;        /* line connected yes/no */
55677 +       unsigned char status;           /* battery loading yes/no */
55678 +       unsigned char percentage;       /* percentage loaded */
55679 +       unsigned short life;            /* life till empty */
55680 +};
55681 +
55682 +/* These should match the apm_bios.h definitions */
55683 +#define SIMPAD_AC_STATUS_AC_OFFLINE      0x00
55684 +#define SIMPAD_AC_STATUS_AC_ONLINE       0x01
55685 +#define SIMPAD_AC_STATUS_AC_BACKUP       0x02   /* What does this mean? */
55686 +#define SIMPAD_AC_STATUS_AC_UNKNOWN      0xff
55687 +
55688 +/* These bitfields are rarely "or'd" together */
55689 +#define SIMPAD_BATT_STATUS_HIGH          0x01
55690 +#define SIMPAD_BATT_STATUS_LOW           0x02
55691 +#define SIMPAD_BATT_STATUS_CRITICAL      0x04
55692 +#define SIMPAD_BATT_STATUS_CHARGING      0x08
55693 +#define SIMPAD_BATT_STATUS_CHARGE_MAIN   0x10
55694 +#define SIMPAD_BATT_STATUS_DEAD          0x20   /* Battery will not charge */
55695 +#define SIMPAD_BATT_NOT_INSTALLED        0x20   /* For expansion pack batteries */
55696 +#define SIMPAD_BATT_STATUS_FULL          0x40   /* Battery fully charged (and connected to AC) */
55697 +#define SIMPAD_BATT_STATUS_NOBATT        0x80
55698 +#define SIMPAD_BATT_STATUS_UNKNOWN       0xff
55699 +
55700 +extern int simpad_get_battery(struct simpad_battery* );
55701  
55702 -#endif // SIMPAD_H
55703 +#endif // __ASM_ARCH_SIMPAD_H
55704  
55705  
55706  
55707 diff -Nru a/include/asm-arm/checksum.h b/include/asm-arm/checksum.h
55708 --- a/include/asm-arm/checksum.h        Tue Oct 15 10:15:06 2002
55709 +++ b/include/asm-arm/checksum.h        Mon Jun 23 03:41:42 2003
55710 @@ -105,7 +105,7 @@
55711         adcs    %0, %0, %5                                      \n\
55712         adc     %0, %0, #0"
55713         : "=&r"(sum)
55714 -       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len) << 16), "Ir" (proto << 8)
55715 +       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto))
55716         : "cc");
55717         return sum;
55718  }      
55719 @@ -127,7 +127,7 @@
55720         addcs   %0, %0, #0x10000                                \n\
55721         mvn     %0, %0"
55722         : "=&r"(sum)
55723 -       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (proto << 8)
55724 +       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto))
55725         : "cc");
55726         return sum >> 16;
55727  }
55728 diff -Nru a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
55729 --- a/include/asm-arm/dma-mapping.h     Wed Jun  4 08:09:55 2003
55730 +++ b/include/asm-arm/dma-mapping.h     Wed Aug 13 16:46:20 2003
55731 @@ -129,6 +129,28 @@
55732  }
55733  
55734  /**
55735 + * dma_map_page - map a portion of a page for streaming DMA
55736 + * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
55737 + * @page: page that buffer resides in
55738 + * @offset: offset into page for start of buffer
55739 + * @size: size of buffer to map
55740 + * @dir: DMA transfer direction
55741 + *
55742 + * Ensure that any data held in the cache is appropriately discarded
55743 + * or written back.
55744 + *
55745 + * The device owns this memory once this call has completed.  The CPU
55746 + * can regain ownership by calling dma_unmap_page() or dma_sync_single().
55747 + */
55748 +static inline dma_addr_t
55749 +dma_map_page(struct device *dev, struct page *page,
55750 +            unsigned long offset, size_t size,
55751 +            enum dma_data_direction dir)
55752 +{
55753 +       return dma_map_single(dev, page_address(page) + offset, size, (int)dir);
55754 +}
55755 +
55756 +/**
55757   * dma_unmap_single - unmap a single buffer previously mapped
55758   * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
55759   * @handle: DMA address of buffer
55760 @@ -152,21 +174,26 @@
55761         /* nothing to do */
55762  }
55763  
55764 -#if 0
55765 -static inline dma_addr_t
55766 -dma_map_page(struct device *dev, struct page *page, unsigned long off,
55767 -            size_t size, enum dma_data_direction dir)
55768 -{
55769 -       /* fixme */
55770 -}
55771 -
55772 +/**
55773 + * dma_unmap_page - unmap a buffer previously mapped through dma_map_page()
55774 + * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
55775 + * @handle: DMA address of buffer
55776 + * @size: size of buffer to map
55777 + * @dir: DMA transfer direction
55778 + *
55779 + * Unmap a single streaming mode DMA translation.  The handle and size
55780 + * must match what was provided in the previous dma_map_single() call.
55781 + * All other usages are undefined.
55782 + *
55783 + * After this call, reads by the CPU to the buffer are guaranteed to see
55784 + * whatever the device wrote there.
55785 + */
55786  static inline void
55787  dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size,
55788                enum dma_data_direction dir)
55789  {
55790 -       /* fixme */
55791 +       dma_unmap_single(dev, handle, size, (int)dir);
55792  }
55793 -#endif
55794  
55795  /**
55796   * dma_map_sg - map a set of SG buffers for streaming mode DMA
55797 diff -Nru a/include/asm-arm/hardware/amba.h b/include/asm-arm/hardware/amba.h
55798 --- a/include/asm-arm/hardware/amba.h   Wed Jun 18 15:23:24 2003
55799 +++ b/include/asm-arm/hardware/amba.h   Sun Aug 24 07:16:13 2003
55800 @@ -28,8 +28,8 @@
55801         int                     (*probe)(struct amba_device *, void *);
55802         int                     (*remove)(struct amba_device *);
55803         void                    (*shutdown)(struct amba_device *);
55804 -       int                     (*suspend)(struct amba_device *, u32, u32);
55805 -       int                     (*resume)(struct amba_device *, u32);
55806 +       int                     (*suspend)(struct amba_device *, u32);
55807 +       int                     (*resume)(struct amba_device *);
55808         struct amba_id          *id_table;
55809  };
55810  
55811 diff -Nru a/include/asm-arm/hardware/sa1111.h b/include/asm-arm/hardware/sa1111.h
55812 --- a/include/asm-arm/hardware/sa1111.h Tue Aug  5 12:36:08 2003
55813 +++ b/include/asm-arm/hardware/sa1111.h Sun Aug 24 07:45:05 2003
55814 @@ -542,9 +542,16 @@
55815  
55816  #define SA1111_DEV(_d) container_of((_d), struct sa1111_dev, dev)
55817  
55818 +#define sa1111_get_drvdata(d)  dev_get_drvdata(&(d)->dev)
55819 +#define sa1111_set_drvdata(d,p)        dev_get_drvdata(&(d)->dev, p)
55820 +
55821  struct sa1111_driver {
55822         struct device_driver    drv;
55823         unsigned int            devid;
55824 +       int (*probe)(struct sa1111_dev *);
55825 +       int (*remove)(struct sa1111_dev *);
55826 +       int (*suspend)(struct sa1111_dev *, u32);
55827 +       int (*resume)(struct sa1111_dev *);
55828  };
55829  
55830  #define SA1111_DRV(_d) container_of((_d), struct sa1111_driver, drv)
55831 @@ -572,5 +579,8 @@
55832  int sa1111_get_audio_rate(struct sa1111_dev *sadev);
55833  
55834  int sa1111_check_dma_bug(dma_addr_t addr);
55835 +
55836 +int sa1111_driver_register(struct sa1111_driver *);
55837 +void sa1111_driver_unregister(struct sa1111_driver *);
55838  
55839  #endif  /* _ASM_ARCH_SA1111 */
55840 diff -Nru a/include/asm-arm/pci.h b/include/asm-arm/pci.h
55841 --- a/include/asm-arm/pci.h     Mon Jun  9 09:25:33 2003
55842 +++ b/include/asm-arm/pci.h     Wed Aug 13 16:46:20 2003
55843 @@ -96,6 +96,19 @@
55844         return dma_unmap_sg(hwdev ? &hwdev->dev : NULL, sg, nents, dir);
55845  }
55846  
55847 +static inline dma_addr_t
55848 +pci_map_page(struct pci_dev *hwdev, struct page *page, unsigned long offset,
55849 +               size_t size, int dir)
55850 +{
55851 +       return  pci_map_single(hwdev, page_address(page) + offset, size, dir);
55852 +}
55853 +
55854 +static inline void
55855 +pci_unmap_page(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
55856 +{
55857 +       return pci_unmap_single(hwdev, handle, size, dir);
55858 +}
55859 +
55860  static inline void
55861  pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
55862  {
55863 diff -Nru a/include/asm-arm/proc-armo/processor.h b/include/asm-arm/proc-armo/processor.h
55864 --- a/include/asm-arm/proc-armo/processor.h     Wed May 29 08:06:36 2002
55865 +++ b/include/asm-arm/proc-armo/processor.h     Sun Aug 31 16:14:08 2003
55866 @@ -43,7 +43,7 @@
55867         uaccess_t       *uaccess;               /* User access functions*/
55868  
55869  #define EXTRA_THREAD_STRUCT_INIT               \
55870 -       uaccess:        &uaccess_kernel,
55871 +       .uaccess        = &uaccess_kernel,
55872  
55873  #define start_thread(regs,pc,sp)                                       \
55874  ({                                                                     \
55875 diff -Nru a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
55876 --- a/include/asm-arm/unistd.h  Tue Jan 14 15:28:43 2003
55877 +++ b/include/asm-arm/unistd.h  Tue Jul  8 09:40:32 2003
55878 @@ -303,7 +303,7 @@
55879         "swi    0\n\t"                                  \
55880         "pop    {r7}"
55881  #else
55882 -#define __syscall(name) "swi\t" __sys1(__NR_##name) "\n\t"
55883 +#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
55884  #endif
55885  #endif
55886  
55887 @@ -318,24 +318,28 @@
55888  
55889  #define _syscall0(type,name)                                           \
55890  type name(void) {                                                      \
55891 -  register long __res __asm__("r0");                                   \
55892 +  register long __res_r0 __asm__("r0");                                        \
55893 +  long __res;                                                          \
55894    __asm__ __volatile__ (                                               \
55895    __syscall(name)                                                      \
55896 -       :"=r" (__res)                                                   \
55897 +       : "=r" (__res_r0)                                               \
55898         :                                                               \
55899         : "lr");                                                        \
55900 +  __res = __res_r0;                                                    \
55901    __syscall_return(type,__res);                                                \
55902  }
55903  
55904  #define _syscall1(type,name,type1,arg1)                                \
55905  type name(type1 arg1) {                                                \
55906    register long __r0 __asm__("r0") = (long)arg1;                       \
55907 -  register long __res __asm__("r0");                                   \
55908 +  register long __res_r0 __asm__("r0");                                        \
55909 +  long __res;                                                          \
55910    __asm__ __volatile__ (                                               \
55911    __syscall(name)                                                      \
55912 -       : "=r" (__res)                                                  \
55913 +       : "=r" (__res_r0)                                               \
55914         : "r" (__r0)                                                    \
55915         : "lr");                                                        \
55916 +  __res = __res_r0;                                                    \
55917    __syscall_return(type,__res);                                                \
55918  }
55919  
55920 @@ -343,12 +347,14 @@
55921  type name(type1 arg1,type2 arg2) {                                     \
55922    register long __r0 __asm__("r0") = (long)arg1;                       \
55923    register long __r1 __asm__("r1") = (long)arg2;                       \
55924 -  register long __res __asm__("r0");                                   \
55925 +  register long __res_r0 __asm__("r0");                                        \
55926 +  long __res;                                                          \
55927    __asm__ __volatile__ (                                               \
55928    __syscall(name)                                                      \
55929 -       : "=r" (__res)                                                  \
55930 +       : "=r" (__res_r0)                                               \
55931         : "r" (__r0),"r" (__r1)                                         \
55932         : "lr");                                                        \
55933 +  __res = __res_r0;                                                    \
55934    __syscall_return(type,__res);                                                \
55935  }
55936  
55937 @@ -358,12 +364,14 @@
55938    register long __r0 __asm__("r0") = (long)arg1;                       \
55939    register long __r1 __asm__("r1") = (long)arg2;                       \
55940    register long __r2 __asm__("r2") = (long)arg3;                       \
55941 -  register long __res __asm__("r0");                                   \
55942 +  register long __res_r0 __asm__("r0");                                        \
55943 +  long __res;                                                          \
55944    __asm__ __volatile__ (                                               \
55945    __syscall(name)                                                      \
55946 -       : "=r" (__res)                                                  \
55947 +       : "=r" (__res_r0)                                               \
55948         : "r" (__r0),"r" (__r1),"r" (__r2)                              \
55949         : "lr");                                                        \
55950 +  __res = __res_r0;                                                    \
55951    __syscall_return(type,__res);                                                \
55952  }
55953  
55954 @@ -374,12 +382,14 @@
55955    register long __r1 __asm__("r1") = (long)arg2;                       \
55956    register long __r2 __asm__("r2") = (long)arg3;                       \
55957    register long __r3 __asm__("r3") = (long)arg4;                       \
55958 -  register long __res __asm__("r0");                                   \
55959 +  register long __res_r0 __asm__("r0");                                        \
55960 +  long __res;                                                          \
55961    __asm__ __volatile__ (                                               \
55962    __syscall(name)                                                      \
55963 -       : "=r" (__res)                                                  \
55964 +       : "=r" (__res_r0)                                               \
55965         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3)                   \
55966         : "lr");                                                        \
55967 +  __res = __res_r0;                                                    \
55968    __syscall_return(type,__res);                                                \
55969  }
55970    
55971 @@ -391,12 +401,14 @@
55972    register long __r2 __asm__("r2") = (long)arg3;                       \
55973    register long __r3 __asm__("r3") = (long)arg4;                       \
55974    register long __r4 __asm__("r4") = (long)arg5;                       \
55975 -  register long __res __asm__("r0");                                   \
55976 +  register long __res_r0 __asm__("r0");                                        \
55977 +  long __res;                                                          \
55978    __asm__ __volatile__ (                                               \
55979    __syscall(name)                                                      \
55980 -       : "=r" (__res)                                                  \
55981 +       : "=r" (__res_r0)                                               \
55982         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4)        \
55983         : "lr");                                                        \
55984 +  __res = __res_r0;                                                    \
55985    __syscall_return(type,__res);                                                \
55986  }
55987  
55988 @@ -408,12 +420,14 @@
55989    register long __r3 __asm__("r3") = (long)arg4;                       \
55990    register long __r4 __asm__("r4") = (long)arg5;                       \
55991    register long __r5 __asm__("r5") = (long)arg6;                       \
55992 -  register long __res __asm__("r0");                                   \
55993 +  register long __res_r0 __asm__("r0");                                        \
55994 +  long __res;                                                          \
55995    __asm__ __volatile__ (                                               \
55996    __syscall(name)                                                      \
55997 -       : "=r" (__res)                                                  \
55998 +       : "=r" (__res_r0)                                               \
55999         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5)            \
56000         : "lr");                                                        \
56001 +  __res = __res_r0;                                                    \
56002    __syscall_return(type,__res);                                                \
56003  }
56004  
56005 diff -Nru a/include/asm-arm/xor.h b/include/asm-arm/xor.h
56006 --- a/include/asm-arm/xor.h     Mon Feb  4 23:41:12 2002
56007 +++ b/include/asm-arm/xor.h     Sun Aug 31 16:14:08 2003
56008 @@ -125,11 +125,11 @@
56009  }
56010  
56011  static struct xor_block_template xor_block_arm4regs = {
56012 -       name:   "arm4regs",
56013 -       do_2:   xor_arm4regs_2,
56014 -       do_3:   xor_arm4regs_3,
56015 -       do_4:   xor_arm4regs_4,
56016 -       do_5:   xor_arm4regs_5,
56017 +       .name   = "arm4regs",
56018 +       .do_2   = xor_arm4regs_2,
56019 +       .do_3   = xor_arm4regs_3,
56020 +       .do_4   = xor_arm4regs_4,
56021 +       .do_5   = xor_arm4regs_5,
56022  };
56023  
56024  #undef XOR_TRY_TEMPLATES
56025 diff -Nru a/include/asm-arm26/processor.h b/include/asm-arm26/processor.h
56026 --- a/include/asm-arm26/processor.h     Thu Jun 26 03:24:47 2003
56027 +++ b/include/asm-arm26/processor.h     Sun Aug 31 16:14:08 2003
56028 @@ -51,7 +51,7 @@
56029          uaccess_t       *uaccess;         /* User access functions*/
56030  
56031  #define EXTRA_THREAD_STRUCT_INIT                \
56032 -        uaccess:        &uaccess_kernel,
56033 +        .uaccess        = &uaccess_kernel,
56034  
56035  // FIXME?!!
56036  
56037 diff -Nru a/include/asm-arm26/xor.h b/include/asm-arm26/xor.h
56038 --- a/include/asm-arm26/xor.h   Wed Jun  4 04:14:11 2003
56039 +++ b/include/asm-arm26/xor.h   Sun Aug 31 16:14:08 2003
56040 @@ -125,11 +125,11 @@
56041  }
56042  
56043  static struct xor_block_template xor_block_arm4regs = {
56044 -       name:   "arm4regs",
56045 -       do_2:   xor_arm4regs_2,
56046 -       do_3:   xor_arm4regs_3,
56047 -       do_4:   xor_arm4regs_4,
56048 -       do_5:   xor_arm4regs_5,
56049 +       .name   = "arm4regs",
56050 +       .do_2   = xor_arm4regs_2,
56051 +       .do_3   = xor_arm4regs_3,
56052 +       .do_4   = xor_arm4regs_4,
56053 +       .do_5   = xor_arm4regs_5,
56054  };
56055  
56056  #undef XOR_TRY_TEMPLATES
56057 diff -Nru a/include/asm-h8300/aki3068net/ne.h b/include/asm-h8300/aki3068net/ne.h
56058 --- a/include/asm-h8300/aki3068net/ne.h Sat Jul 19 05:41:33 2003
56059 +++ /dev/null   Wed Dec 31 16:00:00 1969
56060 @@ -1,28 +0,0 @@
56061 -/* AE-3068 (aka. aki3068net) RTL8019AS Config */
56062 -
56063 -#ifndef __H8300_AKI3068NET_NE__
56064 -#define __H8300_AKI3068NET_NE__
56065 -
56066 -#define NE2000_ADDR            0x200000
56067 -#define NE2000_IRQ              5
56068 -#define NE2000_IRQ_VECTOR      (12 + NE2000_IRQ)
56069 -#define        NE2000_BYTE             volatile unsigned short
56070 -
56071 -#define IER                     0xfee015
56072 -#define ISR                    0xfee016
56073 -#define IRQ_MASK               (1 << NE2000_IRQ)
56074 -
56075 -#define WCRL                    0xfee023
56076 -#define MAR0A                   0xffff20
56077 -#define ETCR0A                  0xffff24
56078 -#define DTCR0A                  0xffff27
56079 -#define MAR0B                   0xffff28
56080 -#define DTCR0B                  0xffff2f
56081 -
56082 -#define H8300_INIT_NE()                  \
56083 -do {                                     \
56084 -       wordlength = 1;                  \
56085 -        outb_p(0x48, ioaddr + EN0_DCFG); \
56086 -} while(0)
56087 -
56088 -#endif
56089 diff -Nru a/include/asm-h8300/aki3068net/timer_rate.h b/include/asm-h8300/aki3068net/timer_rate.h
56090 --- a/include/asm-h8300/aki3068net/timer_rate.h Sat Jul 19 09:19:25 2003
56091 +++ /dev/null   Wed Dec 31 16:00:00 1969
56092 @@ -1,9 +0,0 @@
56093 -#ifndef __H8300_AKI3068NET_TIMER_RATE__
56094 -#define __H8300_AKI3068NET_TIMER_RATE__
56095 -
56096 -#include <linux/config.h>
56097 -
56098 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
56099 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
56100 -
56101 -#endif
56102 diff -Nru a/include/asm-h8300/edosk2674/timer_rate.h b/include/asm-h8300/edosk2674/timer_rate.h
56103 --- a/include/asm-h8300/edosk2674/timer_rate.h  Sat Jul 19 09:18:09 2003
56104 +++ /dev/null   Wed Dec 31 16:00:00 1969
56105 @@ -1,4 +0,0 @@
56106 -#include <linux/config.h>
56107 -
56108 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
56109 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
56110 diff -Nru a/include/asm-h8300/h8300_smsc.h b/include/asm-h8300/h8300_smsc.h
56111 --- /dev/null   Wed Dec 31 16:00:00 1969
56112 +++ b/include/asm-h8300/h8300_smsc.h    Sun Aug 31 14:01:50 2003
56113 @@ -0,0 +1,20 @@
56114 +/****************************************************************************/
56115 +
56116 +/*
56117 + *     h8300_smsc.h -- SMSC in H8/300H and H8S Evalution Board.
56118 + *      
56119 + *     (C) Copyright 2003, Yoshinori Sato <ysato@users.sourceforge.jp>
56120 + */
56121 +
56122 +/****************************************************************************/
56123 +#ifndef        h8300smsc_h
56124 +#define        h8300smsc_h
56125 +/****************************************************************************/
56126 +
56127 +/* Such a description is OK ? */
56128 +#define H8300_SMSC_DEFINE
56129 +#include <asm/machine-depend.h>
56130 +#undef  H8300_SMSC_DEFINE
56131 +
56132 +/****************************************************************************/
56133 +#endif /* h8300smsc_h */
56134 diff -Nru a/include/asm-h8300/h8max/machine-depend.h b/include/asm-h8300/h8max/machine-depend.h
56135 --- a/include/asm-h8300/h8max/machine-depend.h  Thu Aug 21 22:56:17 2003
56136 +++ b/include/asm-h8300/h8max/machine-depend.h  Wed Aug 27 07:02:04 2003
56137 @@ -101,67 +101,3 @@
56138  }
56139  
56140  #endif
56141 -
56142 -/* H8MAX IDE I/F Config */
56143 -#ifdef H8300_IDE_DEFINE
56144 -
56145 -#define H8300_IDE_BASE 0x200000
56146 -#define H8300_IDE_CTRL 0x60000c
56147 -#define H8300_IDE_IRQ  5
56148 -#define H8300_IDE_REG_OFFSET 2
56149 -
56150 -#undef outb
56151 -#undef inb
56152 -#undef outb_p
56153 -#undef inb_p
56154 -#undef outsw
56155 -#undef insw
56156 -
56157 -#define outb(d,a) h8max_outb(d,(unsigned short *)a)
56158 -#define inb(a) h8max_inb((unsigned char *)a)
56159 -#define outb_p(d,a) h8max_outb(d,(unsigned short *)a)
56160 -#define inb_p(a) h8max_inb((unsigned char *)a)
56161 -#define outsw(addr,buf,len) h8max_outsw(addr,buf,len);
56162 -#define insw(addr,buf,len) h8max_insw(addr,buf,len);
56163 -
56164 -static inline void h8max_outb(unsigned short d,unsigned short *a)
56165 -{
56166 -       *a = d;
56167 -}
56168 -
56169 -static inline unsigned char h8max_inb(unsigned char *a)
56170 -{
56171 -       return *(a+1);
56172 -}
56173 -
56174 -static inline void h8max_outsw(void *addr, void *buf, int len)
56175 -{
56176 -       unsigned volatile short *ap = (unsigned volatile short *)addr;
56177 -       unsigned short *bp = (unsigned short *)buf;
56178 -       unsigned short d;
56179 -       while(len--) {
56180 -               d = *bp++;
56181 -               *ap = (d >> 8) | (d << 8);
56182 -       }
56183 -}
56184 -
56185 -static inline void h8max_insw(void *addr, void *buf, int len)
56186 -{
56187 -       unsigned volatile short *ap = (unsigned volatile short *)addr;
56188 -       unsigned short *bp = (unsigned short *)buf;
56189 -       unsigned short d;
56190 -       while(len--) {
56191 -               d = *ap;
56192 -               *bp++ = (d >> 8) | (d << 8);
56193 -       }
56194 -}
56195 -
56196 -static inline void target_ide_fix_driveid(struct hd_driveid *id)
56197 -{
56198 -       int c;
56199 -       unsigned short *p = (unsigned short *)id;
56200 -       for (c = 0; c < SECTOR_WORDS; c++, p++)
56201 -               *p = (*p >> 8) | (*p << 8);
56202 -}
56203 -
56204 -#endif
56205 diff -Nru a/include/asm-h8300/h8max/ne.h b/include/asm-h8300/h8max/ne.h
56206 --- a/include/asm-h8300/h8max/ne.h      Sat Jul 19 05:41:33 2003
56207 +++ /dev/null   Wed Dec 31 16:00:00 1969
56208 @@ -1,97 +0,0 @@
56209 -/* H8MAX RTL8019AS Config */
56210 -
56211 -#ifndef __H8300_H8MAX_NE__
56212 -#define __H8300_H8MAX_NE__
56213 -
56214 -#define NE2000_ADDR            0x800600
56215 -#define NE2000_IRQ              4
56216 -#define NE2000_IRQ_VECTOR      (12 + NE2000_IRQ)
56217 -#define        NE2000_BYTE             volatile unsigned short
56218 -
56219 -#define IER                     0xfee015
56220 -#define ISR                    0xfee016
56221 -#define IRQ_MASK               (1 << NE2000_IRQ)
56222 -/* sorry quick hack */
56223 -#if defined(outb)
56224 -# undef outb
56225 -#endif
56226 -#define outb(d,a)               h8max_outb((d),(a) - NE2000_ADDR)
56227 -#if defined(inb)
56228 -# undef inb
56229 -#endif
56230 -#define inb(a)                  h8max_inb((a) - NE2000_ADDR)
56231 -#if defined(outb_p)
56232 -# undef outb_p
56233 -#endif
56234 -#define outb_p(d,a)             h8max_outb((d),(a) - NE2000_ADDR)
56235 -#if defined(inb_p)
56236 -# undef inb_p
56237 -#endif
56238 -#define inb_p(a)                h8max_inb((a) - NE2000_ADDR)
56239 -#if defined(outsw)
56240 -# undef outsw
56241 -#endif
56242 -#define outsw(a,p,l)            h8max_outsw((a) - NE2000_ADDR,(unsigned short *)p,l)
56243 -#if defined(insw)
56244 -# undef insw
56245 -#endif
56246 -#define insw(a,p,l)             h8max_insw((a) - NE2000_ADDR,(unsigned short *)p,l)
56247 -#if defined(outsb)
56248 -# undef outsb
56249 -#endif
56250 -#define outsb(a,p,l)            h8max_outsb((a) - NE2000_ADDR,(unsigned char *)p,l)
56251 -#if defined(insb)
56252 -# undef insb
56253 -#endif
56254 -#define insb(a,p,l)             h8max_insb((a) - NE2000_ADDR,(unsigned char *)p,l)
56255 -
56256 -#define H8300_INIT_NE()                  \
56257 -do {                                     \
56258 -       wordlength = 2;                  \
56259 -       h8max_outb(0x49, ioaddr + EN0_DCFG); \
56260 -       SA_prom[14] = SA_prom[15] = 0x57;\
56261 -} while(0)
56262 -
56263 -static inline void h8max_outb(unsigned char d,unsigned char a)
56264 -{
56265 -       *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
56266 -}
56267 -
56268 -static inline unsigned char h8max_inb(unsigned char a)
56269 -{
56270 -       return *(unsigned char *)(NE2000_ADDR + (a << 1) +1);
56271 -}
56272 -
56273 -static inline void h8max_outsw(unsigned char a,unsigned short *p,unsigned long l)
56274 -{
56275 -       unsigned short d;
56276 -       for (; l != 0; --l, p++) {
56277 -               d = (((*p) >> 8) & 0xff) | ((*p) << 8);
56278 -               *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
56279 -       }
56280 -}
56281 -
56282 -static inline void h8max_insw(unsigned char a,unsigned short *p,unsigned long l)
56283 -{
56284 -       unsigned short d;
56285 -       for (; l != 0; --l, p++) {
56286 -               d = *(unsigned short *)(NE2000_ADDR + (a << 1));
56287 -               *p = (d << 8)|((d >> 8) & 0xff);
56288 -       }
56289 -}
56290 -
56291 -static inline void h8max_outsb(unsigned char a,unsigned char *p,unsigned long l)
56292 -{
56293 -       for (; l != 0; --l, p++) {
56294 -               *(unsigned short *)(NE2000_ADDR + (a << 1)) = *p;
56295 -       }
56296 -}
56297 -
56298 -static inline void h8max_insb(unsigned char a,unsigned char *p,unsigned long l)
56299 -{
56300 -       for (; l != 0; --l, p++) {
56301 -               *p = *((unsigned char *)(NE2000_ADDR + (a << 1))+1);
56302 -       }
56303 -}
56304 -
56305 -#endif
56306 diff -Nru a/include/asm-h8300/h8max/timer_rate.h b/include/asm-h8300/h8max/timer_rate.h
56307 --- a/include/asm-h8300/h8max/timer_rate.h      Sat Jul 19 09:19:25 2003
56308 +++ /dev/null   Wed Dec 31 16:00:00 1969
56309 @@ -1,10 +0,0 @@
56310 -#ifndef __H8300_H8MAX_TIMER_RATE__
56311 -#define __H8300_H8MAX_TIMER_RATE__
56312 -
56313 -#include <linux/config.h>
56314 -
56315 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
56316 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
56317 -
56318 -#endif
56319 -
56320 diff -Nru a/include/asm-h8300/ide.h b/include/asm-h8300/ide.h
56321 --- a/include/asm-h8300/ide.h   Thu Aug 21 08:55:15 2003
56322 +++ b/include/asm-h8300/ide.h   Wed Aug 27 07:12:57 2003
56323 @@ -16,145 +16,26 @@
56324  #ifdef __KERNEL__
56325  /****************************************************************************/
56326  
56327 -#include <linux/config.h>
56328 -#include <linux/interrupt.h>
56329 +void h8300_ide_print_resource(char *name, hw_regs_t *hw);
56330 +static inline int ide_default_irq(unsigned long base) { return 0; };
56331 +static inline ide_ioreg_t ide_default_io_base(int index) { return 0; };
56332  
56333 -#include <asm/setup.h>
56334 -#include <asm/io.h>
56335 -#include <asm/irq.h>
56336 -
56337 -/*
56338 - *     Some coldfire specifics.
56339 - */
56340 -
56341 -/*
56342 - *     Save some space, only have 1 interface.
56343 - */
56344 -#define MAX_HWIFS      1
56345 -
56346 -/*
56347 - *     Fix up things that may not have been provided.
56348 - */
56349 -
56350 -#undef SUPPORT_SLOW_DATA_PORTS
56351 -#define SUPPORT_SLOW_DATA_PORTS 0
56352 -
56353 -#undef SUPPORT_VLB_SYNC
56354 -#define SUPPORT_VLB_SYNC 0
56355 -
56356 -/* this definition is used only on startup .. */
56357 -#undef HD_DATA
56358 -#define HD_DATA NULL
56359 -
56360 -#define        DBGIDE(fmt,a...)
56361 -// #define     DBGIDE(fmt,a...) printk(fmt, ##a)
56362 -#define IDE_INLINE __inline__
56363 -// #define IDE_INLINE
56364 -
56365 -#define ide__sti()     __sti()
56366 -
56367 -/****************************************************************************/
56368 -
56369 -typedef union {
56370 -       unsigned all                    : 8;    /* all of the bits together */
56371 -       struct {
56372 -               unsigned bit7           : 1;    /* always 1 */
56373 -               unsigned lba            : 1;    /* using LBA instead of CHS */
56374 -               unsigned bit5           : 1;    /* always 1 */
56375 -               unsigned unit           : 1;    /* drive select number, 0 or 1 */
56376 -               unsigned head           : 4;    /* always zeros here */
56377 -       } b;
56378 -} select_t;
56379 -
56380 -/*
56381 - *     Our list of ports/irq's for different boards.
56382 - */
56383 -
56384 -/* machine depend header include */
56385 -#define H8300_IDE_DEFINE
56386 -#include <asm/machine-depend.h>
56387 -#undef  H8300_IDE_DEFINE
56388 -
56389 -/****************************************************************************/
56390 -
56391 -static IDE_INLINE int ide_default_irq(ide_ioreg_t base)
56392 +static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
56393 +        unsigned long ctrl_port, int *irq)
56394  {
56395 -       return H8300_IDE_IRQ+12;
56396  }
56397  
56398 -static IDE_INLINE ide_ioreg_t ide_default_io_base(int index)
56399 -{
56400 -       return (ide_ioreg_t)H8300_IDE_BASE;
56401 -}
56402  
56403 -/*
56404 - * Set up a hw structure for a specified data port, control port and IRQ.
56405 - * This should follow whatever the default interface uses.
56406 - */
56407 -static IDE_INLINE void ide_init_hwif_ports(
56408 -       hw_regs_t *hw,
56409 -       ide_ioreg_t data_port,
56410 -       ide_ioreg_t ctrl_port,
56411 -       int *irq)
56412 +static inline void ide_init_default_hwifs(void)
56413  {
56414 -       ide_ioreg_t reg = data_port;
56415 -       int i;
56416 -
56417 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
56418 -               hw->io_ports[i] = reg;
56419 -               reg += H8300_IDE_REG_OFFSET;
56420 -       }
56421 -       if (ctrl_port) {
56422 -               hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
56423 -       } else {
56424 -               hw->io_ports[IDE_CONTROL_OFFSET] = (ide_ioreg_t)H8300_IDE_CTRL;
56425 -       }
56426  }
56427  
56428 +#define MAX_HWIFS      1
56429  
56430 -/*
56431 - * This registers the standard ports for this architecture with the IDE
56432 - * driver.
56433 - */
56434 -static IDE_INLINE void ide_init_default_hwifs(void)
56435 -{
56436 -       hw_regs_t hw;
56437 -       ide_ioreg_t base;
56438 -       int index;
56439 -
56440 -       for (index = 0; index < MAX_HWIFS; index++) {
56441 -               base = ide_default_io_base(index);
56442 -               if (!base)
56443 -                       continue;
56444 -               memset(&hw, 0, sizeof(hw));
56445 -               ide_init_hwif_ports(&hw, base, 0, NULL);
56446 -               hw.irq = ide_default_irq(base);
56447 -               ide_register_hw(&hw, NULL);
56448 -       }
56449 -}
56450 -
56451 -#define ide_request_irq(irq,hand,flg,dev,id)   request_irq((irq),(hand),(flg),(dev),(id))
56452 -#define ide_free_irq(irq,dev_id)               free_irq((irq), (dev_id))
56453 -#define ide_check_region(from,extent)          (0)
56454 -#define ide_request_region(from,extent,name)   do {} while(0)
56455 -#define ide_release_region(from,extent)                do {} while(0)
56456 -
56457 -/*
56458 - * The following are not needed for the non-m68k ports
56459 - */
56460 -#define ide_ack_intr(hwif)             (1)
56461 -#define ide_fix_driveid(id)            target_ide_fix_driveid(id)
56462 -#define ide_release_lock(lock)         do {} while (0)
56463 -#define ide_get_lock(lock, hdlr, data) do {} while (0)
56464 -
56465 -static IDE_INLINE void ide_print_resource(char *name,hw_regs_t *hw)
56466 -{
56467 -       printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
56468 -               (unsigned int)hw->io_ports[IDE_DATA_OFFSET],
56469 -               (unsigned int)hw->io_ports[IDE_DATA_OFFSET]+(8*H8300_IDE_REG_OFFSET)-1,
56470 -               (unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
56471 -               hw->irq);
56472 -}
56473 +#define __ide_mm_insw(port,addr,count)  do { } while(0)
56474 +#define __ide_mm_insl(port,addr,count)  do { } while(0)
56475 +#define __ide_mm_outsw(port,addr,count) do { } while(0)
56476 +#define __ide_mm_outsl(port,addr,count) do { } while(0)
56477  
56478  /****************************************************************************/
56479  #endif /* __KERNEL__ */
56480 diff -Nru a/include/asm-h8300/irq.h b/include/asm-h8300/irq.h
56481 --- a/include/asm-h8300/irq.h   Sun Jul 13 23:17:52 2003
56482 +++ b/include/asm-h8300/irq.h   Wed Aug 27 07:02:04 2003
56483 @@ -3,11 +3,35 @@
56484  
56485  #include <asm/ptrace.h>
56486  
56487 -#if defined(CONFIG_CPU_H8300H)
56488 +#if defined(__H8300H__)
56489  #define NR_IRQS 64
56490 +#define EXT_IRQ0 12
56491 +#define EXT_IRQ1 13
56492 +#define EXT_IRQ2 14
56493 +#define EXT_IRQ3 15
56494 +#define EXT_IRQ4 16
56495 +#define EXT_IRQ5 17
56496 +#define EXT_IRQ6 18
56497 +#define EXT_IRQ7 19
56498  #endif
56499  #if defined(CONFIG_CPU_H8S)
56500  #define NR_IRQS 128
56501 +#define EXT_IRQ0 16
56502 +#define EXT_IRQ1 17
56503 +#define EXT_IRQ2 18
56504 +#define EXT_IRQ3 19
56505 +#define EXT_IRQ4 20
56506 +#define EXT_IRQ5 21
56507 +#define EXT_IRQ6 22
56508 +#define EXT_IRQ7 23
56509 +#define EXT_IRQ8 24
56510 +#define EXT_IRQ9 25
56511 +#define EXT_IRQ10 26
56512 +#define EXT_IRQ11 27
56513 +#define EXT_IRQ12 28
56514 +#define EXT_IRQ13 29
56515 +#define EXT_IRQ14 30
56516 +#define EXT_IRQ15 31
56517  #endif
56518  
56519  static __inline__ int irq_canonicalize(int irq)
56520 diff -Nru a/include/asm-h8300/machine-depend.h b/include/asm-h8300/machine-depend.h
56521 --- a/include/asm-h8300/machine-depend.h        Thu Aug 21 22:56:18 2003
56522 +++ /dev/null   Wed Dec 31 16:00:00 1969
56523 @@ -1,70 +0,0 @@
56524 -/* EDOSK2674 board depend header */
56525 -
56526 -/* TIMER rate define */
56527 -#ifdef H8300_TIMER_DEFINE
56528 -#define H8300_TIMER_COUNT_DATA 33000*10/8192
56529 -#define H8300_TIMER_FREQ 33000*1000/8192
56530 -#endif
56531 -
56532 -/* EDOSK-2674R SMSC Network Controler Target Depend impliments */
56533 -#ifdef H8300_SMSC_DEFINE
56534 -
56535 -#define SMSC_BASE 0xf80000
56536 -#define SMSC_IRQ 16
56537 -
56538 -/* sorry quick hack */
56539 -#if defined(outw)
56540 -# undef outw
56541 -#endif
56542 -#define outw(d,a) edosk2674_smsc_outw(d,(volatile unsigned short *)(a))
56543 -#if defined(inw)
56544 -# undef inw
56545 -#endif
56546 -#define inw(a) edosk2674_smsc_inw((volatile unsigned short *)(a))
56547 -#if defined(outsw)
56548 -# undef outsw
56549 -#endif
56550 -#define outsw(a,p,l) edosk2674_smsc_outsw((volatile unsigned short *)(a),p,l)
56551 -#if defined(insw)
56552 -# undef insw
56553 -#endif
56554 -#define insw(a,p,l) edosk2674_smsc_insw((volatile unsigned short *)(a),p,l)
56555 -
56556 -static inline void edosk2674_smsc_outw(
56557 -       unsigned short d,
56558 -       volatile unsigned short *a
56559 -       )
56560 -{
56561 -       *a = (d >> 8) | (d << 8);
56562 -}
56563 -
56564 -static inline unsigned short edosk2674_smsc_inw(
56565 -       volatile unsigned short *a
56566 -       )
56567 -{
56568 -       unsigned short d;
56569 -       d = *a;
56570 -       return (d >> 8) | (d << 8);
56571 -}
56572 -
56573 -static inline void edosk2674_smsc_outsw(
56574 -       volatile unsigned short *a,
56575 -       unsigned short *p,
56576 -       unsigned long l
56577 -       )
56578 -{
56579 -       for (; l != 0; --l, p++)
56580 -               *a = *p;
56581 -}
56582 -
56583 -static inline void edosk2674_smsc_insw(
56584 -       volatile unsigned short *a,
56585 -       unsigned short *p,
56586 -       unsigned long l
56587 -       )
56588 -{
56589 -       for (; l != 0; --l, p++)
56590 -               *p = *a;
56591 -}
56592 -
56593 -#endif
56594 diff -Nru a/include/asm-h8300/pci.h b/include/asm-h8300/pci.h
56595 --- a/include/asm-h8300/pci.h   Mon Jun  9 09:25:52 2003
56596 +++ b/include/asm-h8300/pci.h   Wed Aug 27 07:02:04 2003
56597 @@ -19,4 +19,6 @@
56598         /* We don't do dynamic PCI IRQ allocation */
56599  }
56600  
56601 +#define PCI_DMA_BUS_IS_PHYS    (1)
56602 +
56603  #endif /* _ASM_H8300_PCI_H */
56604 diff -Nru a/include/asm-i386/apic.h b/include/asm-i386/apic.h
56605 --- a/include/asm-i386/apic.h   Sun Jun 15 11:00:08 2003
56606 +++ b/include/asm-i386/apic.h   Fri Aug 29 03:51:17 2003
56607 @@ -64,6 +64,8 @@
56608         apic_write_around(APIC_EOI, 0);
56609  }
56610  
56611 +extern void (*wait_timer_tick)(void);
56612 +
56613  extern int get_maxlvt(void);
56614  extern void clear_local_APIC(void);
56615  extern void connect_bsp_APIC (void);
56616 diff -Nru a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h
56617 --- a/include/asm-i386/bugs.h   Sun Apr 20 12:24:22 2003
56618 +++ b/include/asm-i386/bugs.h   Sun Aug 31 16:14:48 2003
56619 @@ -193,11 +193,6 @@
56620             && (boot_cpu_data.x86_mask < 6 || boot_cpu_data.x86_mask == 11))
56621                 panic("Kernel compiled for PMMX+, assumes a local APIC without the read-before-write bug!");
56622  #endif
56623 -
56624 -#ifdef CONFIG_X86_SSE2
56625 -       if (!cpu_has_sse2)
56626 -               panic("Kernel compiled for SSE2, CPU doesn't have it.");
56627 -#endif
56628  }
56629  
56630  extern void alternative_instructions(void);
56631 diff -Nru a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h
56632 --- /dev/null   Wed Dec 31 16:00:00 1969
56633 +++ b/include/asm-i386/hpet.h   Sun Aug 31 16:15:40 2003
56634 @@ -0,0 +1,116 @@
56635 +
56636 +#ifndef _I386_HPET_H
56637 +#define _I386_HPET_H
56638 +
56639 +#ifdef CONFIG_HPET_TIMER
56640 +
56641 +#include <linux/errno.h>
56642 +#include <linux/module.h>
56643 +#include <linux/sched.h>
56644 +#include <linux/kernel.h>
56645 +#include <linux/param.h>
56646 +#include <linux/string.h>
56647 +#include <linux/mm.h>
56648 +#include <linux/interrupt.h>
56649 +#include <linux/time.h>
56650 +#include <linux/delay.h>
56651 +#include <linux/init.h>
56652 +#include <linux/smp.h>
56653 +
56654 +#include <asm/io.h>
56655 +#include <asm/smp.h>
56656 +#include <asm/irq.h>
56657 +#include <asm/msr.h>
56658 +#include <asm/delay.h>
56659 +#include <asm/mpspec.h>
56660 +#include <asm/uaccess.h>
56661 +#include <asm/processor.h>
56662 +
56663 +#include <linux/timex.h>
56664 +#include <linux/config.h>
56665 +
56666 +#include <asm/fixmap.h>
56667 +
56668 +/*
56669 + * Documentation on HPET can be found at:
56670 + *      http://www.intel.com/ial/home/sp/pcmmspec.htm
56671 + *      ftp://download.intel.com/ial/home/sp/mmts098.pdf
56672 + */
56673 +
56674 +#define HPET_MMAP_SIZE 1024
56675 +
56676 +#define HPET_ID                0x000
56677 +#define HPET_PERIOD    0x004
56678 +#define HPET_CFG       0x010
56679 +#define HPET_STATUS    0x020
56680 +#define HPET_COUNTER   0x0f0
56681 +#define HPET_T0_CFG    0x100
56682 +#define HPET_T0_CMP    0x108
56683 +#define HPET_T0_ROUTE  0x110
56684 +#define HPET_T1_CFG    0x120
56685 +#define HPET_T1_CMP    0x128
56686 +#define HPET_T1_ROUTE  0x130
56687 +#define HPET_T2_CFG    0x140
56688 +#define HPET_T2_CMP    0x148
56689 +#define HPET_T2_ROUTE  0x150
56690 +
56691 +#define HPET_ID_VENDOR 0xffff0000
56692 +#define HPET_ID_LEGSUP 0x00008000
56693 +#define HPET_ID_NUMBER 0x00001f00
56694 +#define HPET_ID_REV    0x000000ff
56695 +
56696 +#define HPET_ID_VENDOR_SHIFT   16
56697 +#define HPET_ID_VENDOR_8086    0x8086
56698 +
56699 +#define HPET_CFG_ENABLE        0x001
56700 +#define HPET_CFG_LEGACY        0x002
56701 +
56702 +#define HPET_TN_ENABLE         0x004
56703 +#define HPET_TN_PERIODIC       0x008
56704 +#define HPET_TN_PERIODIC_CAP   0x010
56705 +#define HPET_TN_SETVAL         0x040
56706 +#define HPET_TN_32BIT          0x100
56707 +
56708 +/* Use our own asm for 64 bit multiply/divide */
56709 +#define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in)                   \
56710 +               __asm__ __volatile__("mull %2"                          \
56711 +                               :"=a" (eax_out), "=d" (edx_out)         \
56712 +                               :"r" (reg_in), "0" (eax_in))
56713 +
56714 +#define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in)            \
56715 +               __asm__ __volatile__("divl %2"                          \
56716 +                               :"=a" (eax_out), "=d" (edx_out)         \
56717 +                               :"r" (reg_in), "0" (eax_in), "1" (edx_in))
56718 +
56719 +#define KERNEL_TICK_USEC       (1000000UL/HZ)  /* tick value in microsec */
56720 +/* Max HPET Period is 10^8 femto sec as in HPET spec */
56721 +#define HPET_MAX_PERIOD (100000000UL)
56722 +/*
56723 + * Min HPET period is 10^5 femto sec just for safety. If it is less than this,
56724 + * then 32 bit HPET counter wrapsaround in less than 0.5 sec.
56725 + */
56726 +#define HPET_MIN_PERIOD (100000UL)
56727 +
56728 +extern unsigned long hpet_period;      /* fsecs / HPET clock */
56729 +extern unsigned long hpet_tick;        /* hpet clks count per tick */
56730 +extern unsigned long hpet_address;     /* hpet memory map physical address */
56731 +
56732 +extern int hpet_rtc_timer_init(void);
56733 +extern int hpet_enable(void);
56734 +extern int is_hpet_enabled(void);
56735 +extern int is_hpet_capable(void);
56736 +extern int hpet_readl(unsigned long a);
56737 +extern void hpet_writel(unsigned long d, unsigned long a);
56738 +
56739 +#ifdef CONFIG_RTC
56740 +#define CONFIG_HPET_EMULATE_RTC        1
56741 +extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
56742 +extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
56743 +extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec);
56744 +extern int hpet_set_periodic_freq(unsigned long freq);
56745 +extern int hpet_rtc_dropped_irq(void);
56746 +extern int hpet_rtc_timer_init(void);
56747 +extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
56748 +#endif /* CONFIG_RTC */
56749 +#endif /* CONFIG_HPET_TIMER */
56750 +#endif /* _I386_HPET_H */
56751 diff -Nru a/include/asm-i386/i387.h b/include/asm-i386/i387.h
56752 --- a/include/asm-i386/i387.h   Fri May  9 14:22:55 2003
56753 +++ b/include/asm-i386/i387.h   Tue Sep  2 00:37:21 2003
56754 @@ -26,7 +26,9 @@
56755  extern void kernel_fpu_begin(void);
56756  #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
56757  
56758 -
56759 +/*
56760 + * These must be called with preempt disabled
56761 + */
56762  static inline void __save_init_fpu( struct task_struct *tsk )
56763  {
56764         if ( cpu_has_fxsr ) {
56765 @@ -39,19 +41,12 @@
56766         tsk->thread_info->status &= ~TS_USEDFPU;
56767  }
56768  
56769 -static inline void save_init_fpu( struct task_struct *tsk )
56770 -{
56771 -       __save_init_fpu(tsk);
56772 -       stts();
56773 -}
56774 -
56775 -
56776 -#define unlazy_fpu( tsk ) do { \
56777 +#define __unlazy_fpu( tsk ) do { \
56778         if ((tsk)->thread_info->status & TS_USEDFPU) \
56779                 save_init_fpu( tsk ); \
56780  } while (0)
56781  
56782 -#define clear_fpu( tsk )                                       \
56783 +#define __clear_fpu( tsk )                                     \
56784  do {                                                           \
56785         if ((tsk)->thread_info->status & TS_USEDFPU) {          \
56786                 asm volatile("fwait");                          \
56787 @@ -60,6 +55,30 @@
56788         }                                                       \
56789  } while (0)
56790  
56791 +
56792 +/*
56793 + * These disable preemption on their own and are safe
56794 + */
56795 +static inline void save_init_fpu( struct task_struct *tsk )
56796 +{
56797 +       preempt_disable();
56798 +       __save_init_fpu(tsk);
56799 +       stts();
56800 +       preempt_enable();
56801 +}
56802 +
56803 +#define unlazy_fpu( tsk ) do { \
56804 +       preempt_disable();      \
56805 +       __unlazy_fpu(tsk);      \
56806 +       preempt_enable();       \
56807 +} while (0)
56808 +
56809 +#define clear_fpu( tsk ) do {  \
56810 +       preempt_disable();      \
56811 +       __clear_fpu( tsk );     \
56812 +       preempt_enable();       \
56813 +} while (0)
56814 +                                       \
56815  /*
56816   * FPU state interaction...
56817   */
56818 diff -Nru a/include/asm-i386/processor.h b/include/asm-i386/processor.h
56819 --- a/include/asm-i386/processor.h      Wed Aug 20 11:14:51 2003
56820 +++ b/include/asm-i386/processor.h      Sun Aug 31 16:13:54 2003
56821 @@ -578,6 +578,8 @@
56822  #define ARCH_HAS_PREFETCH
56823  extern inline void prefetch(const void *x)
56824  {
56825 +       if (cpu_data[0].x86_vendor == X86_VENDOR_AMD)
56826 +               return;         /* Some athlons fault if the address is bad */
56827         alternative_input(ASM_NOP4,
56828                           "prefetchnta (%1)",
56829                           X86_FEATURE_XMM,
56830 diff -Nru a/include/asm-i386/smp.h b/include/asm-i386/smp.h
56831 --- a/include/asm-i386/smp.h    Mon Aug 18 19:46:23 2003
56832 +++ b/include/asm-i386/smp.h    Sun Aug 31 16:14:42 2003
56833 @@ -32,7 +32,6 @@
56834   */
56835   
56836  extern void smp_alloc_memory(void);
56837 -extern physid_mask_t phys_cpu_present_map;
56838  extern int pic_mode;
56839  extern int smp_num_siblings;
56840  extern int cpu_sibling_map[];
56841 diff -Nru a/include/asm-i386/timer.h b/include/asm-i386/timer.h
56842 --- a/include/asm-i386/timer.h  Wed Jul  2 21:21:34 2003
56843 +++ b/include/asm-i386/timer.h  Sun Aug 31 16:15:21 2003
56844 @@ -38,4 +38,8 @@
56845  extern struct timer_opts timer_cyclone;
56846  #endif
56847  
56848 +#ifdef CONFIG_HPET_TIMER
56849 +extern struct timer_opts timer_hpet;
56850 +#endif
56851 +
56852  #endif
56853 diff -Nru a/include/asm-ia64/hw_irq.h b/include/asm-ia64/hw_irq.h
56854 --- a/include/asm-ia64/hw_irq.h Tue Jul 29 08:53:10 2003
56855 +++ b/include/asm-ia64/hw_irq.h Tue Aug 26 15:09:18 2003
56856 @@ -39,9 +39,9 @@
56857   * Vectors 0x10-0x1f are used for low priority interrupts, e.g. CMCI.
56858   */
56859  #define IA64_CPEP_VECTOR               0x1c    /* corrected platform error polling vector */
56860 -#define IA64_CMCP_VECTOR               0x1d    /* correctable machine-check polling vector */
56861 +#define IA64_CMCP_VECTOR               0x1d    /* corrected machine-check polling vector */
56862  #define IA64_CPE_VECTOR                        0x1e    /* corrected platform error interrupt vector */
56863 -#define IA64_CMC_VECTOR                        0x1f    /* correctable machine-check interrupt vector */
56864 +#define IA64_CMC_VECTOR                        0x1f    /* corrected machine-check interrupt vector */
56865  /*
56866   * Vectors 0x20-0x2f are reserved for legacy ISA IRQs.
56867   */
56868 diff -Nru a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
56869 --- a/include/asm-ia64/pci.h    Tue Jun 24 14:16:56 2003
56870 +++ b/include/asm-ia64/pci.h    Mon Aug 25 14:45:43 2003
56871 @@ -74,7 +74,7 @@
56872  #define pci_dac_dma_supported(pci_dev, mask)           (1)
56873  #define pci_dac_page_to_dma(dev,pg,off,dir)            ((dma_addr_t) page_to_bus(pg) + (off))
56874  #define pci_dac_dma_to_page(dev,dma_addr)              (virt_to_page(bus_to_virt(dma_addr)))
56875 -#define pci_dac_dma_to_offset(dev,dma_addr)            ((dma_addr) & ~PAGE_MASK)
56876 +#define pci_dac_dma_to_offset(dev,dma_addr)            offset_in_page(dma_addr)
56877  #define pci_dac_dma_sync_single(dev,dma_addr,len,dir)  do { mb(); } while (0)
56878  
56879  #define sg_dma_len(sg)         ((sg)->dma_length)
56880 diff -Nru a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
56881 --- a/include/asm-ia64/unistd.h Tue Aug 19 23:13:40 2003
56882 +++ b/include/asm-ia64/unistd.h Mon Aug 25 14:47:33 2003
56883 @@ -248,6 +248,7 @@
56884  #define __NR_sys_clock_nanosleep       1256
56885  #define __NR_sys_fstatfs64             1257
56886  #define __NR_sys_statfs64              1258
56887 +#define __NR_fadvises64_64             1259
56888  
56889  #ifdef __KERNEL__
56890  
56891 diff -Nru a/include/asm-m68k/local.h b/include/asm-m68k/local.h
56892 --- /dev/null   Wed Dec 31 16:00:00 1969
56893 +++ b/include/asm-m68k/local.h  Sun Jul 27 17:23:16 2003
56894 @@ -0,0 +1,6 @@
56895 +#ifndef _ASM_M68K_LOCAL_H
56896 +#define _ASM_M68K_LOCAL_H
56897 +
56898 +#include <asm-generic/local.h>
56899 +
56900 +#endif /* _ASM_M68K_LOCAL_H */
56901 diff -Nru a/include/asm-m68k/sections.h b/include/asm-m68k/sections.h
56902 --- /dev/null   Wed Dec 31 16:00:00 1969
56903 +++ b/include/asm-m68k/sections.h       Sun Jul 27 17:23:16 2003
56904 @@ -0,0 +1,6 @@
56905 +#ifndef _ASM_M68K_SECTIONS_H
56906 +#define _ASM_M68K_SECTIONS_H
56907 +
56908 +#include <asm-generic/sections.h>
56909 +
56910 +#endif /* _ASM_M68K_SECTIONS_H */
56911 diff -Nru a/include/asm-m68k/system.h b/include/asm-m68k/system.h
56912 --- a/include/asm-m68k/system.h Wed Feb 26 10:53:19 2003
56913 +++ b/include/asm-m68k/system.h Tue Aug 12 05:48:28 2003
56914 @@ -36,9 +36,12 @@
56915  #define switch_to(prev,next,last) do { \
56916    register void *_prev __asm__ ("a0") = (prev); \
56917    register void *_next __asm__ ("a1") = (next); \
56918 +  register void *_last __asm__ ("d1"); \
56919    __asm__ __volatile__("jbsr resume" \
56920 -                      : : "a" (_prev), "a" (_next) \
56921 -                      : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1"); \
56922 +                      : "=a" (_prev), "=a" (_next), "=d" (_last) \
56923 +                      : "0" (_prev), "1" (_next) \
56924 +                      : "d0", "d2", "d3", "d4", "d5"); \
56925 +  (last) = _last; \
56926  } while (0)
56927  
56928  
56929 diff -Nru a/include/asm-m68knommu/irq.h b/include/asm-m68knommu/irq.h
56930 --- a/include/asm-m68knommu/irq.h       Fri Nov  1 08:37:46 2002
56931 +++ b/include/asm-m68knommu/irq.h       Sat Aug 23 06:08:54 2003
56932 @@ -2,6 +2,7 @@
56933  #define _M68K_IRQ_H_
56934  
56935  #include <linux/config.h>
56936 +#include <linux/interrupt.h>
56937  #include <asm/ptrace.h>
56938  
56939  #ifdef CONFIG_COLDFIRE
56940 @@ -62,7 +63,7 @@
56941  extern void (*mach_disable_irq)(unsigned int);
56942  
56943  extern int sys_request_irq(unsigned int, 
56944 -       void (*)(int, void *, struct pt_regs *), 
56945 +       irqreturn_t (*)(int, void *, struct pt_regs *), 
56946         unsigned long, const char *, void *);
56947  extern void sys_free_irq(unsigned int, void *);
56948  
56949 @@ -91,7 +92,7 @@
56950   * interrupt source (if it supports chaining).
56951   */
56952  typedef struct irq_node {
56953 -       void            (*handler)(int, void *, struct pt_regs *);
56954 +       irqreturn_t     (*handler)(int, void *, struct pt_regs *);
56955         unsigned long   flags;
56956         void            *dev_id;
56957         const char      *devname;
56958 @@ -102,7 +103,7 @@
56959   * This structure has only 4 elements for speed reasons
56960   */
56961  typedef struct irq_handler {
56962 -       void            (*handler)(int, void *, struct pt_regs *);
56963 +       irqreturn_t     (*handler)(int, void *, struct pt_regs *);
56964         unsigned long   flags;
56965         void            *dev_id;
56966         const char      *devname;
56967 diff -Nru a/include/asm-m68knommu/local.h b/include/asm-m68knommu/local.h
56968 --- /dev/null   Wed Dec 31 16:00:00 1969
56969 +++ b/include/asm-m68knommu/local.h     Sat Aug 23 06:08:54 2003
56970 @@ -0,0 +1,6 @@
56971 +#ifndef __M68KNOMMU_LOCAL_H
56972 +#define __M68KNOMMU_LOCAL_H
56973 +
56974 +#include <asm-generic/local.h>
56975 +
56976 +#endif /* __M68KNOMMU_LOCAL_H */
56977 diff -Nru a/include/asm-m68knommu/sections.h b/include/asm-m68knommu/sections.h
56978 --- /dev/null   Wed Dec 31 16:00:00 1969
56979 +++ b/include/asm-m68knommu/sections.h  Sat Aug 23 06:08:54 2003
56980 @@ -0,0 +1,7 @@
56981 +#ifndef _M68KNOMMU_SECTIONS_H
56982 +#define _M68KNOMMU_SECTIONS_H
56983 +
56984 +/* nothing to see, move along */
56985 +#include <asm-generic/sections.h>
56986 +
56987 +#endif
56988 diff -Nru a/include/asm-ppc/cpm_8260.h b/include/asm-ppc/cpm_8260.h
56989 --- a/include/asm-ppc/cpm_8260.h        Sun Sep 15 21:52:03 2002
56990 +++ b/include/asm-ppc/cpm_8260.h        Thu Aug 21 15:26:43 2003
56991 @@ -195,7 +195,7 @@
56992  
56993  /* SMC uart mode register (Internal memory map).
56994  */
56995 -#define        SMCMR_REN       ((ushort)0x0001)
56996 +#define SMCMR_REN      ((ushort)0x0001)
56997  #define SMCMR_TEN      ((ushort)0x0002)
56998  #define SMCMR_DM       ((ushort)0x000c)
56999  #define SMCMR_SM_GCI   ((ushort)0x0000)
57000 @@ -212,10 +212,12 @@
57001  
57002  /* SMC Event and Mask register.
57003  */
57004 -#define        SMCM_TXE        ((unsigned char)0x10)
57005 -#define        SMCM_BSY        ((unsigned char)0x04)
57006 -#define        SMCM_TX         ((unsigned char)0x02)
57007 -#define        SMCM_RX         ((unsigned char)0x01)
57008 +#define SMCM_BRKE       ((unsigned char)0x40)   /* When in UART Mode */
57009 +#define SMCM_BRK        ((unsigned char)0x10)   /* When in UART Mode */
57010 +#define SMCM_TXE       ((unsigned char)0x10)
57011 +#define SMCM_BSY       ((unsigned char)0x04)
57012 +#define SMCM_TX                ((unsigned char)0x02)
57013 +#define SMCM_RX                ((unsigned char)0x01)
57014  
57015  /* Baud rate generators.
57016  */
57017 @@ -314,10 +316,10 @@
57018  
57019  /* SCC Event and Mask register.
57020  */
57021 -#define        SCCM_TXE        ((unsigned char)0x10)
57022 -#define        SCCM_BSY        ((unsigned char)0x04)
57023 -#define        SCCM_TX         ((unsigned char)0x02)
57024 -#define        SCCM_RX         ((unsigned char)0x01)
57025 +#define SCCM_TXE       ((unsigned char)0x10)
57026 +#define SCCM_BSY       ((unsigned char)0x04)
57027 +#define SCCM_TX                ((unsigned char)0x02)
57028 +#define SCCM_RX                ((unsigned char)0x01)
57029  
57030  typedef struct scc_param {
57031         ushort  scc_rbase;      /* Rx Buffer descriptor base address */
57032 diff -Nru a/include/asm-ppc/macio.h b/include/asm-ppc/macio.h
57033 --- a/include/asm-ppc/macio.h   Sat Aug  9 09:39:19 2003
57034 +++ b/include/asm-ppc/macio.h   Sun Aug 24 04:06:49 2003
57035 @@ -42,6 +42,9 @@
57036  #define        to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev)
57037  #define        of_to_macio_device(d) container_of(d, struct macio_dev, ofdev)
57038  
57039 +extern struct macio_dev *macio_dev_get(struct macio_dev *dev);
57040 +extern void macio_dev_put(struct macio_dev *dev);
57041 +
57042  /*
57043   * A driver for a mac-io chip based device
57044   */
57045 @@ -54,8 +57,8 @@
57046         int     (*probe)(struct macio_dev* dev, const struct of_match *match);
57047         int     (*remove)(struct macio_dev* dev);
57048  
57049 -       int     (*suspend)(struct macio_dev* dev, u32 state, u32 level);
57050 -       int     (*resume)(struct macio_dev* dev, u32 level);
57051 +       int     (*suspend)(struct macio_dev* dev, u32 state);
57052 +       int     (*resume)(struct macio_dev* dev);
57053         int     (*shutdown)(struct macio_dev* dev);
57054  
57055         struct device_driver    driver;
57056 diff -Nru a/include/asm-ppc/of_device.h b/include/asm-ppc/of_device.h
57057 --- a/include/asm-ppc/of_device.h       Sat Aug  9 09:40:04 2003
57058 +++ b/include/asm-ppc/of_device.h       Sun Aug 24 04:06:49 2003
57059 @@ -39,6 +39,9 @@
57060  extern const struct of_match *of_match_device(
57061         const struct of_match *matches, const struct of_device *dev);
57062  
57063 +extern struct of_device *of_dev_get(struct of_device *dev);
57064 +extern void of_dev_put(struct of_device *dev);
57065 +
57066  /*
57067   * An of_platform_driver driver is attached to a basic of_device on
57068   * the "platform bus" (of_platform_bus_type)
57069 @@ -52,8 +55,8 @@
57070         int     (*probe)(struct of_device* dev, const struct of_match *match);
57071         int     (*remove)(struct of_device* dev);
57072  
57073 -       int     (*suspend)(struct of_device* dev, u32 state, u32 level);
57074 -       int     (*resume)(struct of_device* dev, u32 level);
57075 +       int     (*suspend)(struct of_device* dev, u32 state);
57076 +       int     (*resume)(struct of_device* dev);
57077         int     (*shutdown)(struct of_device* dev);
57078  
57079         struct device_driver    driver;
57080 @@ -65,6 +68,7 @@
57081  extern int of_device_register(struct of_device *ofdev);
57082  extern void of_device_unregister(struct of_device *ofdev);
57083  extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id);
57084 +extern void of_release_dev(struct device *dev);
57085  
57086  #endif /* __OF_DEVICE_H__ */
57087  
57088 diff -Nru a/include/asm-ppc/processor.h b/include/asm-ppc/processor.h
57089 --- a/include/asm-ppc/processor.h       Wed Jul 16 20:41:10 2003
57090 +++ b/include/asm-ppc/processor.h       Fri Aug 22 05:26:16 2003
57091 @@ -654,6 +654,7 @@
57092   */
57093  #define EISA_bus 0
57094  #define MCA_bus 0
57095 +#define MCA_bus__is_a_macro
57096  
57097  /* Lazy FPU handling on uni-processor */
57098  extern struct task_struct *last_task_used_math;
57099 diff -Nru a/include/asm-ppc/prom.h b/include/asm-ppc/prom.h
57100 --- a/include/asm-ppc/prom.h    Sat Jan  4 03:31:26 2003
57101 +++ b/include/asm-ppc/prom.h    Sun Aug 24 03:57:52 2003
57102 @@ -62,18 +62,35 @@
57103  struct prom_args;
57104  typedef void (*prom_entry)(struct prom_args *);
57105  
57106 -/* Prototypes */
57107 -extern void abort(void);
57108 -extern unsigned long prom_init(int, int, prom_entry);
57109 -extern void prom_print(const char *msg);
57110 -extern void relocate_nodes(void);
57111 -extern void finish_device_tree(void);
57112 +/* OBSOLETE: Old style node lookup */
57113  extern struct device_node *find_devices(const char *name);
57114  extern struct device_node *find_type_devices(const char *type);
57115  extern struct device_node *find_path_device(const char *path);
57116  extern struct device_node *find_compatible_devices(const char *type,
57117                                                    const char *compat);
57118  extern struct device_node *find_all_nodes(void);
57119 +
57120 +/* New style node lookup */
57121 +extern struct device_node *of_find_node_by_name(struct device_node *from,
57122 +       const char *name);
57123 +extern struct device_node *of_find_node_by_type(struct device_node *from,
57124 +       const char *type);
57125 +extern struct device_node *of_find_compatible_node(struct device_node *from,
57126 +       const char *type, const char *compat);
57127 +extern struct device_node *of_find_node_by_path(const char *path);
57128 +extern struct device_node *of_find_all_nodes(struct device_node *prev);
57129 +extern struct device_node *of_get_parent(const struct device_node *node);
57130 +extern struct device_node *of_get_next_child(const struct device_node *node,
57131 +                                            struct device_node *prev);
57132 +extern struct device_node *of_node_get(struct device_node *node);
57133 +extern void of_node_put(struct device_node *node);
57134 +
57135 +/* Other Prototypes */
57136 +extern void abort(void);
57137 +extern unsigned long prom_init(int, int, prom_entry);
57138 +extern void prom_print(const char *msg);
57139 +extern void relocate_nodes(void);
57140 +extern void finish_device_tree(void);
57141  extern int device_is_compatible(struct device_node *device, const char *);
57142  extern int machine_is_compatible(const char *compat);
57143  extern unsigned char *get_property(struct device_node *node, const char *name,
57144 diff -Nru a/include/asm-ppc/unistd.h b/include/asm-ppc/unistd.h
57145 --- a/include/asm-ppc/unistd.h  Tue Jul 15 04:47:19 2003
57146 +++ b/include/asm-ppc/unistd.h  Fri Aug 22 19:15:18 2003
57147 @@ -258,8 +258,9 @@
57148  #define __NR_utimes            251
57149  #define __NR_statfs64          252
57150  #define __NR_fstatfs64         253
57151 +#define __NR_fadvise64_64      254
57152  
57153 -#define __NR_syscalls          254
57154 +#define __NR_syscalls          255
57155  
57156  #define __NR(n)        #n
57157  
57158 diff -Nru a/include/asm-sparc/pci.h b/include/asm-sparc/pci.h
57159 --- a/include/asm-sparc/pci.h   Mon Jun  9 09:27:29 2003
57160 +++ b/include/asm-sparc/pci.h   Thu Aug 28 01:15:54 2003
57161 @@ -78,6 +78,14 @@
57162  #define pci_unmap_len_set(PTR, LEN_NAME, VAL)          \
57163         (((PTR)->LEN_NAME) = (VAL))
57164  
57165 +/*
57166 + * Same as above, only with pages instead of mapped addresses.
57167 + */
57168 +extern dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
57169 +                       unsigned long offset, size_t size, int direction);
57170 +extern void pci_unmap_page(struct pci_dev *hwdev,
57171 +                       dma_addr_t dma_address, size_t size, int direction);
57172 +
57173  /* Map a set of buffers described by scatterlist in streaming
57174   * mode for DMA.  This is the scather-gather version of the
57175   * above pci_map_single interface.  Here the scatter gather list
57176 diff -Nru a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
57177 --- a/include/asm-sparc/smp.h   Mon Aug 18 19:46:23 2003
57178 +++ b/include/asm-sparc/smp.h   Thu Aug 28 00:18:36 2003
57179 @@ -8,11 +8,13 @@
57180  
57181  #include <linux/config.h>
57182  #include <linux/threads.h>
57183 -#include <linux/cpumask.h>
57184  #include <asm/head.h>
57185  #include <asm/btfixup.h>
57186  
57187  #ifndef __ASSEMBLY__
57188 +
57189 +#include <linux/cpumask.h>
57190 +
57191  /* PROM provided per-processor information we need
57192   * to start them all up.
57193   */
57194 diff -Nru a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
57195 --- a/include/asm-sparc/unistd.h        Sat Aug 16 14:13:18 2003
57196 +++ b/include/asm-sparc/unistd.h        Wed Aug 27 23:52:25 2003
57197 @@ -282,10 +282,11 @@
57198  #define __NR_timer_gettime     263
57199  #define __NR_timer_getoverrun  264
57200  #define __NR_timer_delete      265
57201 -/* WARNING: You MAY NOT add syscall numbers larger than 265, since
57202 +#define __NR_timer_create      266
57203 +/* WARNING: You MAY NOT add syscall numbers larger than 266, since
57204   *          all of the syscall tables in the Sparc kernel are
57205 - *          sized to have 266 entries (starting at zero).  Therefore
57206 - *          find a free slot in the 0-265 range.
57207 + *          sized to have 267 entries (starting at zero).  Therefore
57208 + *          find a free slot in the 0-266 range.
57209   */
57210  
57211  #define _syscall0(type,name) \
57212 diff -Nru a/include/asm-sparc64/siginfo.h b/include/asm-sparc64/siginfo.h
57213 --- a/include/asm-sparc64/siginfo.h     Sun Jan  5 23:08:44 2003
57214 +++ b/include/asm-sparc64/siginfo.h     Thu Aug 28 01:31:51 2003
57215 @@ -83,7 +83,7 @@
57216  #ifdef __KERNEL__
57217  
57218  typedef struct sigevent32 {
57219 -       sigval_t sigev_value;
57220 +       sigval_t32 sigev_value;
57221         int sigev_signo;
57222         int sigev_notify;
57223         union {
57224 diff -Nru a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
57225 --- a/include/asm-sparc64/unistd.h      Sat Aug 16 14:13:18 2003
57226 +++ b/include/asm-sparc64/unistd.h      Wed Aug 27 23:52:25 2003
57227 @@ -284,10 +284,11 @@
57228  #define __NR_timer_gettime     263
57229  #define __NR_timer_getoverrun  264
57230  #define __NR_timer_delete      265
57231 -/* WARNING: You MAY NOT add syscall numbers larger than 265, since
57232 +#define __NR_timer_create      266
57233 +/* WARNING: You MAY NOT add syscall numbers larger than 266, since
57234   *          all of the syscall tables in the Sparc kernel are
57235 - *          sized to have 266 entries (starting at zero).  Therefore
57236 - *          find a free slot in the 0-265 range.
57237 + *          sized to have 267 entries (starting at zero).  Therefore
57238 + *          find a free slot in the 0-266 range.
57239   */
57240  
57241  #define _syscall0(type,name) \
57242 diff -Nru a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h
57243 --- a/include/asm-x86_64/bitops.h       Mon Aug 18 19:46:23 2003
57244 +++ b/include/asm-x86_64/bitops.h       Sat Aug 23 04:08:11 2003
57245 @@ -466,7 +466,7 @@
57246  
57247         __asm__("bsfl %1,%0\n\t"
57248                 "cmovzl %2,%0" 
57249 -               : "=r" (r) : "g" (x), "r" (32));
57250 +               : "=r" (r) : "g" (x), "r" (-1));
57251         return r+1;
57252  }
57253  
57254 diff -Nru a/include/asm-x86_64/ia32.h b/include/asm-x86_64/ia32.h
57255 --- a/include/asm-x86_64/ia32.h Fri May 23 03:22:07 2003
57256 +++ b/include/asm-x86_64/ia32.h Sun Aug 31 16:13:59 2003
57257 @@ -160,7 +160,6 @@
57258         char                    f_fpack[6];
57259  };
57260  
57261 -#define IA32_PAGE_OFFSET 0xffffe000
57262  #define IA32_STACK_TOP IA32_PAGE_OFFSET
57263  
57264  #ifdef __KERNEL__
57265 diff -Nru a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h
57266 --- a/include/asm-x86_64/mpspec.h       Mon Aug 18 19:46:23 2003
57267 +++ b/include/asm-x86_64/mpspec.h       Sat Aug 23 05:13:33 2003
57268 @@ -169,7 +169,6 @@
57269  extern cpumask_t mp_bus_to_cpumask [MAX_MP_BUSSES];
57270  
57271  extern unsigned int boot_cpu_physical_apicid;
57272 -extern cpumask_t phys_cpu_present_map;
57273  extern int smp_found_config;
57274  extern void find_smp_config (void);
57275  extern void get_smp_config (void);
57276 @@ -197,6 +196,50 @@
57277  extern void mp_config_ioapic_for_sci(int irq);
57278  
57279  extern int using_apic_timer;
57280 +
57281 +#define PHYSID_ARRAY_SIZE      BITS_TO_LONGS(MAX_APICS)
57282 +
57283 +struct physid_mask
57284 +{
57285 +       unsigned long mask[PHYSID_ARRAY_SIZE];
57286 +};
57287 +
57288 +typedef struct physid_mask physid_mask_t;
57289 +
57290 +#define physid_set(physid, map)                        set_bit(physid, (map).mask)
57291 +#define physid_clear(physid, map)              clear_bit(physid, (map).mask)
57292 +#define physid_isset(physid, map)              test_bit(physid, (map).mask)
57293 +#define physid_test_and_set(physid, map)       test_and_set_bit(physid, (map).mask)
57294 +
57295 +#define physids_and(dst, src1, src2)           bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
57296 +#define physids_or(dst, src1, src2)            bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
57297 +#define physids_clear(map)                     bitmap_clear((map).mask, MAX_APICS)
57298 +#define physids_complement(map)                        bitmap_complement((map).mask, MAX_APICS)
57299 +#define physids_empty(map)                     bitmap_empty((map).mask, MAX_APICS)
57300 +#define physids_equal(map1, map2)              bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
57301 +#define physids_weight(map)                    bitmap_weight((map).mask, MAX_APICS)
57302 +#define physids_shift_right(d, s, n)           bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
57303 +#define physids_shift_left(d, s, n)            bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
57304 +#define physids_coerce(map)                    ((map).mask[0])
57305 +
57306 +#define physids_promote(physids)                                               \
57307 +       ({                                                                      \
57308 +               physid_mask_t __physid_mask = PHYSID_MASK_NONE;                 \
57309 +               __physid_mask.mask[0] = physids;                                \
57310 +               __physid_mask;                                                  \
57311 +       })
57312 +
57313 +#define physid_mask_of_physid(physid)                                          \
57314 +       ({                                                                      \
57315 +               physid_mask_t __physid_mask = PHYSID_MASK_NONE;                 \
57316 +               physid_set(physid, __physid_mask);                              \
57317 +               __physid_mask;                                                  \
57318 +       })
57319 +
57320 +#define PHYSID_MASK_ALL                { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
57321 +#define PHYSID_MASK_NONE       { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
57322 +
57323 +extern physid_mask_t phys_cpu_present_map;
57324  
57325  #endif
57326  
57327 diff -Nru a/include/asm-x86_64/percpu.h b/include/asm-x86_64/percpu.h
57328 --- a/include/asm-x86_64/percpu.h       Fri Aug  8 13:06:56 2003
57329 +++ b/include/asm-x86_64/percpu.h       Sat Aug 23 05:29:54 2003
57330 @@ -31,6 +31,9 @@
57331                         memcpy((pcpudst)+__per_cpu_offset(__i), \
57332                                (src), (size));                  \
57333  } while (0)
57334 +
57335 +extern void setup_per_cpu_areas(void);
57336 +
57337  #else /* ! SMP */
57338  
57339  #define DEFINE_PER_CPU(type, name) \
57340 @@ -45,7 +48,5 @@
57341  
57342  #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
57343  #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
57344 -
57345 -extern void setup_per_cpu_areas(void);
57346  
57347  #endif /* _ASM_X8664_PERCPU_H_ */
57348 diff -Nru a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
57349 --- a/include/asm-x86_64/processor.h    Wed Aug 20 11:16:28 2003
57350 +++ b/include/asm-x86_64/processor.h    Sun Aug 31 16:13:59 2003
57351 @@ -18,6 +18,7 @@
57352  #include <asm/current.h>
57353  #include <asm/system.h>
57354  #include <asm/mmsegment.h>
57355 +#include <linux/personality.h>
57356  
57357  #define TF_MASK                0x00000100
57358  #define IF_MASK                0x00000200
57359 @@ -172,7 +173,8 @@
57360  /* This decides where the kernel will search for a free chunk of vm
57361   * space during mmap's.
57362   */
57363 -#define TASK_UNMAPPED_32 0xa0000000
57364 +#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
57365 +#define TASK_UNMAPPED_32 (IA32_PAGE_OFFSET / 3)
57366  #define TASK_UNMAPPED_64 PAGE_ALIGN(TASK_SIZE/3) 
57367  #define TASK_UNMAPPED_BASE     \
57368         (test_thread_flag(TIF_IA32) ? TASK_UNMAPPED_32 : TASK_UNMAPPED_64)  
57369 @@ -225,7 +227,6 @@
57370          * 8 bytes, for an extra "long" of ~0UL
57371          */
57372         unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
57373 -       u32 __cacheline_filler[4];      /* size is 0x100 */
57374  } __attribute__((packed)) ____cacheline_aligned;
57375  
57376  struct thread_struct {
57377 diff -Nru a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
57378 --- a/include/asm-x86_64/smp.h  Mon Aug 18 19:46:23 2003
57379 +++ b/include/asm-x86_64/smp.h  Sat Aug 23 05:14:50 2003
57380 @@ -36,7 +36,6 @@
57381   */
57382   
57383  extern void smp_alloc_memory(void);
57384 -extern cpumask_t phys_cpu_present_map;
57385  extern cpumask_t cpu_online_map;
57386  extern volatile unsigned long smp_invalidate_needed;
57387  extern int pic_mode;
57388 diff -Nru a/include/asm-x86_64/suspend.h b/include/asm-x86_64/suspend.h
57389 --- a/include/asm-x86_64/suspend.h      Sat Jun  7 00:54:11 2003
57390 +++ b/include/asm-x86_64/suspend.h      Sat Aug 23 05:22:09 2003
57391 @@ -44,7 +44,7 @@
57392                         :"r" ((thread)->debugreg##register))
57393  
57394  extern void fix_processor_context(void);
57395 -extern void do_magic(int resume);
57396 +extern int do_magic(int resume);
57397  
57398  #ifdef CONFIG_ACPI_SLEEP
57399  extern unsigned long saved_eip;
57400 diff -Nru a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
57401 --- a/include/asm-x86_64/topology.h     Mon Aug 18 19:46:23 2003
57402 +++ b/include/asm-x86_64/topology.h     Sat Aug 23 04:00:02 2003
57403 @@ -10,21 +10,18 @@
57404  /* Map the K8 CPU local memory controllers to a simple 1:1 CPU:NODE topology */
57405  
57406  extern int fake_node;
57407 -extern cpumask_t cpu_online_map;
57408 +extern unsigned long cpu_online_map;
57409  
57410  #define cpu_to_node(cpu)               (fake_node ? 0 : (cpu))
57411  #define memblk_to_node(memblk)         (fake_node ? 0 : (memblk))
57412  #define parent_node(node)              (node)
57413  #define node_to_first_cpu(node)        (fake_node ? 0 : (node))
57414 -#define node_to_cpu_mask(node) (fake_node ? cpu_online_map : cpumask_of_cpu(node))
57415 +#define node_to_cpu_mask(node) (fake_node ? cpu_online_map : (1UL << (node)))
57416  #define node_to_memblk(node)           (node)
57417  
57418 -static inline cpumask_t pcibus_to_cpumask(int bus)
57419 +static inline unsigned long pcibus_to_cpumask(int bus)
57420  {
57421 -       cpumask_t ret;
57422 -
57423 -       cpus_and(ret, mp_bus_to_cpumask[bus], cpu_online_map);
57424 -       return ret;
57425 +       return mp_bus_to_cpumask[bus] & cpu_online_map; 
57426  }
57427  
57428  #define NODE_BALANCE_RATE 30   /* CHECKME */ 
57429 diff -Nru a/include/linux/blkdev.h b/include/linux/blkdev.h
57430 --- a/include/linux/blkdev.h    Thu Aug 14 18:16:17 2003
57431 +++ b/include/linux/blkdev.h    Mon Sep  1 04:03:21 2003
57432 @@ -243,6 +243,7 @@
57433  
57434  struct bio_vec;
57435  typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *);
57436 +typedef void (activity_fn) (void *data, int rw);
57437  
57438  enum blk_queue_state {
57439         Queue_down,
57440 @@ -283,6 +284,7 @@
57441         prep_rq_fn              *prep_rq_fn;
57442         unplug_fn               *unplug_fn;
57443         merge_bvec_fn           *merge_bvec_fn;
57444 +       activity_fn             *activity_fn;
57445  
57446         /*
57447          * Auto-unplugging state
57448 @@ -300,6 +302,8 @@
57449          */
57450         void                    *queuedata;
57451  
57452 +       void                    *activity_data;
57453 +
57454         /*
57455          * queue needs bounce pages for pages above this limit
57456          */
57457 @@ -504,6 +508,7 @@
57458  extern void blk_stop_queue(request_queue_t *q);
57459  extern void __blk_stop_queue(request_queue_t *q);
57460  extern void blk_run_queue(request_queue_t *q);
57461 +extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *);
57462  
57463  static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
57464  {
57465 diff -Nru a/include/linux/cyclomx.h b/include/linux/cyclomx.h
57466 --- a/include/linux/cyclomx.h   Tue May 20 07:19:38 2003
57467 +++ b/include/linux/cyclomx.h   Sat Aug 23 20:38:19 2003
57468 @@ -52,7 +52,7 @@
57469         char in_isr;                    /* interrupt-in-service flag */
57470         char buff_int_mode_unbusy;      /* flag for carrying out dev_tint */
57471         wait_queue_head_t wait_stats;  /* to wait for the STATS indication */
57472 -       u32 mbox;                       /* -> mailbox */
57473 +       void *mbox;                     /* -> mailbox */
57474         void (*isr)(struct cycx_device* card);  /* interrupt service routine */
57475         int (*exec)(struct cycx_device* card, void* u_cmd, void* u_data);
57476         union {
57477 diff -Nru a/include/linux/cycx_cfm.h b/include/linux/cycx_cfm.h
57478 --- a/include/linux/cycx_cfm.h  Thu May 15 19:24:05 2003
57479 +++ b/include/linux/cycx_cfm.h  Sat Aug 23 19:57:15 2003
57480 @@ -90,7 +90,7 @@
57481         unsigned short      reserved[6];
57482         char                descr[CFM_DESCR_LEN];
57483         struct cycx_fw_info info;
57484 -       unsigned char       image[1];
57485 +       unsigned char       image[0];
57486  };
57487  
57488  struct cycx_fw_header {
57489 diff -Nru a/include/linux/cycx_drv.h b/include/linux/cycx_drv.h
57490 --- a/include/linux/cycx_drv.h  Thu May 15 19:33:21 2003
57491 +++ b/include/linux/cycx_drv.h  Sat Aug 23 20:11:44 2003
57492 @@ -48,7 +48,7 @@
57493  struct cycx_hw {
57494         u32 fwid;
57495         int irq;
57496 -       u32 dpmbase;
57497 +       void *dpmbase;
57498         u32 dpmsize;
57499         u32 reserved[5];
57500  };
57501 @@ -58,7 +58,7 @@
57502  extern int cycx_down(struct cycx_hw *hw);
57503  extern int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
57504  extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
57505 -extern int cycx_exec(u32 addr);
57506 +extern int cycx_exec(void *addr);
57507  
57508  extern void cycx_inten(struct cycx_hw *hw);
57509  extern void cycx_intr(struct cycx_hw *hw);
57510 diff -Nru a/include/linux/ethtool.h b/include/linux/ethtool.h
57511 --- a/include/linux/ethtool.h   Thu Aug  7 13:16:01 2003
57512 +++ b/include/linux/ethtool.h   Mon Sep  1 17:25:54 2003
57513 @@ -255,8 +255,11 @@
57514  /* Some generic methods drivers may use in their ethtool_ops */
57515  u32 ethtool_op_get_link(struct net_device *dev);
57516  u32 ethtool_op_get_tx_csum(struct net_device *dev);
57517 +int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
57518  u32 ethtool_op_get_sg(struct net_device *dev);
57519  int ethtool_op_set_sg(struct net_device *dev, u32 data);
57520 +u32 ethtool_op_get_tso(struct net_device *dev);
57521 +int ethtool_op_set_tso(struct net_device *dev, u32 data);
57522  
57523  /**
57524   * &ethtool_ops - Alter and report network device settings
57525 @@ -284,6 +287,8 @@
57526   * set_tx_csum: Turn transmit checksums on or off
57527   * get_sg: Report whether scatter-gather is enabled
57528   * set_sg: Turn scatter-gather on or off
57529 + * get_tso: Report whether TCP segmentation offload is enabled
57530 + * set_tso: Turn TCP segmentation offload on or off
57531   * self_test: Run specified self-tests
57532   * get_strings: Return a set of strings that describe the requested objects 
57533   * phys_id: Identify the device
57534 @@ -337,6 +342,8 @@
57535         int     (*set_tx_csum)(struct net_device *, u32);
57536         u32     (*get_sg)(struct net_device *);
57537         int     (*set_sg)(struct net_device *, u32);
57538 +       u32     (*get_tso)(struct net_device *);
57539 +       int     (*set_tso)(struct net_device *, u32);
57540         int     (*self_test_count)(struct net_device *);
57541         void    (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
57542         void    (*get_strings)(struct net_device *, u32 stringset, u8 *);
57543 diff -Nru a/include/linux/fs.h b/include/linux/fs.h
57544 --- a/include/linux/fs.h        Fri Jul 11 10:32:02 2003
57545 +++ b/include/linux/fs.h        Sun Aug 31 16:14:42 2003
57546 @@ -336,10 +336,8 @@
57547  };
57548  
57549  struct block_device {
57550 -       struct list_head        bd_hash;
57551 -       atomic_t                bd_count;
57552 -       struct inode *          bd_inode;
57553         dev_t                   bd_dev;  /* not a kdev_t - it's a search key */
57554 +       struct inode *          bd_inode;       /* will die */
57555         int                     bd_openers;
57556         struct semaphore        bd_sem; /* open/close mutex */
57557         struct list_head        bd_inodes;
57558 @@ -347,10 +345,11 @@
57559         int                     bd_holders;
57560         struct block_device *   bd_contains;
57561         unsigned                bd_block_size;
57562 -       sector_t                bd_offset;
57563 +       struct hd_struct *      bd_part;
57564         unsigned                bd_part_count;
57565         int                     bd_invalidated;
57566         struct gendisk *        bd_disk;
57567 +       struct list_head        bd_list;
57568  };
57569  
57570  /*
57571 @@ -468,6 +467,16 @@
57572  #endif
57573  }
57574  
57575 +static inline unsigned iminor(struct inode *inode)
57576 +{
57577 +       return minor(inode->i_rdev);
57578 +}
57579 +
57580 +static inline unsigned imajor(struct inode *inode)
57581 +{
57582 +       return major(inode->i_rdev);
57583 +}
57584 +
57585  struct fown_struct {
57586         rwlock_t lock;          /* protects pid, uid, euid fields */
57587         int pid;                /* pid or -pgrp where SIGIO should be sent */
57588 @@ -600,6 +609,10 @@
57589  extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 __user *);
57590  #endif
57591  
57592 +extern void send_sigio(struct fown_struct *fown, int fd, int band);
57593 +extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
57594 +extern int fcntl_getlease(struct file *filp);
57595 +
57596  /* fs/locks.c */
57597  extern void locks_init_lock(struct file_lock *);
57598  extern void locks_copy_lock(struct file_lock *, struct file_lock *);
57599 @@ -1176,6 +1189,12 @@
57600  unsigned long invalidate_mapping_pages(struct address_space *mapping,
57601                                         pgoff_t start, pgoff_t end);
57602  unsigned long invalidate_inode_pages(struct address_space *mapping);
57603 +static inline void invalidate_remote_inode(struct inode *inode)
57604 +{
57605 +       if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
57606 +           S_ISLNK(inode->i_mode))
57607 +               invalidate_inode_pages(inode->i_mapping);
57608 +}
57609  extern void invalidate_inode_pages2(struct address_space *mapping);
57610  extern void write_inode_now(struct inode *, int);
57611  extern int filemap_fdatawrite(struct address_space *);
57612 diff -Nru a/include/linux/genhd.h b/include/linux/genhd.h
57613 --- a/include/linux/genhd.h     Thu Jun  5 23:32:48 2003
57614 +++ b/include/linux/genhd.h     Sun Aug 31 16:14:27 2003
57615 @@ -197,7 +197,7 @@
57616  
57617  static inline sector_t get_start_sect(struct block_device *bdev)
57618  {
57619 -       return bdev->bd_offset;
57620 +       return bdev->bd_contains == bdev ? 0 : bdev->bd_part->start_sect;
57621  }
57622  static inline sector_t get_capacity(struct gendisk *disk)
57623  {
57624 diff -Nru a/include/linux/ide.h b/include/linux/ide.h
57625 --- a/include/linux/ide.h       Wed Aug 20 09:01:03 2003
57626 +++ b/include/linux/ide.h       Tue Sep  2 07:18:29 2003
57627 @@ -22,6 +22,7 @@
57628  #include <asm/system.h>
57629  #include <asm/hdreg.h>
57630  #include <asm/io.h>
57631 +#include <asm/semaphore.h>
57632  
57633  #define DEBUG_PM
57634  
57635 @@ -774,6 +775,7 @@
57636         int             crc_count;      /* crc counter to reduce drive speed */
57637         struct list_head list;
57638         struct device   gendev;
57639 +       struct semaphore gendev_rel_sem;        /* to deal with device release() */
57640         struct gendisk *disk;
57641  } ide_drive_t;
57642  
57643 @@ -1040,10 +1042,13 @@
57644         unsigned        auto_poll  : 1; /* supports nop auto-poll */
57645  
57646         struct device   gendev;
57647 +       struct semaphore gendev_rel_sem; /* To deal with device release() */
57648  
57649         void            *hwif_data;     /* extra hwif data */
57650  
57651         unsigned dma;
57652 +
57653 +       void (*led_act)(void *data, int rw);
57654  } ide_hwif_t;
57655  
57656  /*
57657 @@ -1242,21 +1247,6 @@
57658  
57659  extern int generic_ide_ioctl(struct block_device *, unsigned, unsigned long);
57660  
57661 -/*
57662 - * IDE modules.
57663 - */
57664 -#define IDE_CHIPSET_MODULE             0       /* not supported yet */
57665 -#define IDE_PROBE_MODULE               1
57666 -
57667 -typedef int    (ide_module_init_proc)(void);
57668 -
57669 -typedef struct ide_module_s {
57670 -       int                             type;
57671 -       ide_module_init_proc            *init;
57672 -       void                            *info;
57673 -       struct ide_module_s             *next;
57674 -} ide_module_t;
57675 -
57676  typedef struct ide_devices_s {
57677         char                    name[4];                /* hdX */
57678         unsigned                attached        : 1;    /* native */
57679 @@ -1274,8 +1264,7 @@
57680   */
57681  #ifndef _IDE_C
57682  extern ide_hwif_t      ide_hwifs[];            /* master data repository */
57683 -extern ide_module_t    *ide_chipsets;
57684 -extern ide_module_t    *ide_probe;
57685 +extern int (*ide_probe)(void);
57686  
57687  extern ide_devices_t   *idedisk;
57688  extern ide_devices_t   *idecd;
57689 @@ -1772,8 +1761,6 @@
57690  extern void ide_hwif_release_regions(ide_hwif_t* hwif);
57691  extern void ide_unregister (unsigned int index);
57692  
57693 -extern int export_ide_init_queue(ide_drive_t *);
57694 -extern u8 export_probe_for_drive(ide_drive_t *);
57695  extern int probe_hwif_init(ide_hwif_t *);
57696  
57697  static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
57698 @@ -1793,6 +1780,24 @@
57699  extern char *ide_xfer_verbose(u8 xfer_rate);
57700  extern void ide_toggle_bounce(ide_drive_t *drive, int on);
57701  extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
57702 +
57703 +typedef struct ide_pio_timings_s {
57704 +       int     setup_time;     /* Address setup (ns) minimum */
57705 +       int     active_time;    /* Active pulse (ns) minimum */
57706 +       int     cycle_time;     /* Cycle time (ns) minimum = (setup + active + recovery) */
57707 +} ide_pio_timings_t;
57708 +
57709 +typedef struct ide_pio_data_s {
57710 +       u8 pio_mode;
57711 +       u8 use_iordy;
57712 +       u8 overridden;
57713 +       u8 blacklisted;
57714 +       unsigned int cycle_time;
57715 +} ide_pio_data_t;
57716 +
57717 +extern u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d);
57718 +extern const ide_pio_timings_t ide_pio_timings[6];
57719 +
57720  
57721  extern spinlock_t ide_lock;
57722  extern struct semaphore ide_cfg_sem;
57723 diff -Nru a/include/linux/ipv6_route.h b/include/linux/ipv6_route.h
57724 --- a/include/linux/ipv6_route.h        Wed Jul 23 02:57:57 2003
57725 +++ b/include/linux/ipv6_route.h        Sat Aug 30 21:26:12 2003
57726 @@ -24,6 +24,7 @@
57727  #define RTF_CACHE      0x01000000      /* cache entry                  */
57728  #define RTF_FLOW       0x02000000      /* flow significant route       */
57729  #define RTF_POLICY     0x04000000      /* policy route                 */
57730 +#define RTF_NDISC      0x08000000      /* ndisc route                  */
57731  
57732  #define RTF_LOCAL      0x80000000
57733  
57734 diff -Nru a/include/linux/kdev_t.h b/include/linux/kdev_t.h
57735 --- a/include/linux/kdev_t.h    Fri Aug  1 02:22:20 2003
57736 +++ b/include/linux/kdev_t.h    Tue Aug 26 09:25:39 2003
57737 @@ -90,22 +90,7 @@
57738         return dev.value;
57739  }
57740  
57741 -static inline kdev_t val_to_kdev(unsigned int val)
57742 -{
57743 -       kdev_t dev;
57744 -       dev.value = val;
57745 -       return dev;
57746 -}
57747 -
57748 -#define HASHDEV(dev)   (kdev_val(dev))
57749  #define NODEV          (mk_kdev(0,0))
57750 -
57751 -static inline int kdev_same(kdev_t dev1, kdev_t dev2)
57752 -{
57753 -       return dev1.value == dev2.value;
57754 -}
57755 -
57756 -#define kdev_none(d1)  (!kdev_val(d1))
57757  
57758  /* Mask off the high bits for now.. */
57759  #define minor(dev)     ((dev).value & 0xff)
57760 diff -Nru a/include/linux/mmzone.h b/include/linux/mmzone.h
57761 --- a/include/linux/mmzone.h    Fri Aug  1 03:02:10 2003
57762 +++ b/include/linux/mmzone.h    Sun Aug 31 16:14:47 2003
57763 @@ -89,17 +89,24 @@
57764  
57765         ZONE_PADDING(_pad2_)
57766  
57767 -       /*
57768 -        * measure of scanning intensity for this zone. It is calculated
57769 -        * as exponentially decaying average of the scanning priority
57770 -        * required to free enough pages in this zone
57771 -        * (zone_adj_pressure()).
57772 +       /*
57773 +        * prev_priority holds the scanning priority for this zone.  It is
57774 +        * defined as the scanning priority at which we achieved our reclaim
57775 +        * target at the previous try_to_free_pages() or balance_pgdat()
57776 +        * invokation.
57777          *
57778 -        *     0                    --- low pressure
57779 +        * We use prev_priority as a measure of how much stress page reclaim is
57780 +        * under - it drives the swappiness decision: whether to unmap mapped
57781 +        * pages.
57782          *
57783 -        *     (DEF_PRIORITY << 10) --- high pressure
57784 +        * temp_priority is used to remember the scanning priority at which
57785 +        * this zone was successfully refilled to free_pages == pages_high.
57786 +        *
57787 +        * Access to both these fields is quite racy even on uniprocessor.  But
57788 +        * it is expected to average out OK.
57789          */
57790 -       int pressure;
57791 +       int temp_priority;
57792 +       int prev_priority;
57793  
57794         /*
57795          * free areas of different sizes
57796 diff -Nru a/include/linux/net.h b/include/linux/net.h
57797 --- a/include/linux/net.h       Mon May 12 14:35:19 2003
57798 +++ b/include/linux/net.h       Tue Sep  2 04:38:09 2003
57799 @@ -20,6 +20,7 @@
57800  
57801  #include <linux/config.h>
57802  #include <linux/wait.h>
57803 +#include <linux/stringify.h>
57804  
57805  struct poll_table_struct;
57806  struct inode;
57807 @@ -243,6 +244,8 @@
57808  };
57809  #endif
57810  
57811 +#define MODULE_ALIAS_NETPROTO(proto) \
57812 +       MODULE_ALIAS("net-pf-" __stringify(proto))
57813  
57814  #endif /* __KERNEL__ */
57815  #endif /* _LINUX_NET_H */
57816 diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
57817 --- a/include/linux/netdevice.h Tue Aug 19 21:01:19 2003
57818 +++ b/include/linux/netdevice.h Mon Sep  1 12:14:20 2003
57819 @@ -168,9 +168,9 @@
57820         unsigned fastroute_deferred_out;
57821         unsigned fastroute_latency_reduction;
57822         unsigned cpu_collision;
57823 -} ____cacheline_aligned;
57824 +};
57825  
57826 -extern struct netif_rx_stats netdev_rx_stat[];
57827 +DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat);
57828  
57829  
57830  /*
57831 @@ -830,6 +830,38 @@
57832         smp_mb__before_clear_bit();
57833         clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
57834         local_irq_restore(flags);
57835 +}
57836 +
57837 +static inline void netif_poll_disable(struct net_device *dev)
57838 +{
57839 +       while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
57840 +               /* No hurry. */
57841 +               current->state = TASK_INTERRUPTIBLE;
57842 +               schedule_timeout(1);
57843 +       }
57844 +}
57845 +
57846 +static inline void netif_poll_enable(struct net_device *dev)
57847 +{
57848 +       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
57849 +}
57850 +
57851 +/* same as netif_rx_complete, except that local_irq_save(flags)
57852 + * has already been issued
57853 + */
57854 +static inline void __netif_rx_complete(struct net_device *dev)
57855 +{
57856 +       if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
57857 +       list_del(&dev->poll_list);
57858 +       smp_mb__before_clear_bit();
57859 +       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
57860 +}
57861 +
57862 +static inline void netif_tx_disable(struct net_device *dev)
57863 +{
57864 +       spin_lock_bh(&dev->xmit_lock);
57865 +       netif_stop_queue(dev);
57866 +       spin_unlock_bh(&dev->xmit_lock);
57867  }
57868  
57869  /* These functions live elsewhere (drivers/net/net_init.c, but related) */
57870 diff -Nru a/include/linux/netfilter_bridge/ebt_802_3.h b/include/linux/netfilter_bridge/ebt_802_3.h
57871 --- /dev/null   Wed Dec 31 16:00:00 1969
57872 +++ b/include/linux/netfilter_bridge/ebt_802_3.h        Sat Aug 30 20:40:29 2003
57873 @@ -0,0 +1,60 @@
57874 +#ifndef __LINUX_BRIDGE_EBT_802_3_H
57875 +#define __LINUX_BRIDGE_EBT_802_3_H
57876 +
57877 +#define EBT_802_3_SAP 0x01
57878 +#define EBT_802_3_TYPE 0x02
57879 +
57880 +#define EBT_802_3_MATCH "802_3"
57881 +
57882 +/*
57883 + * If frame has DSAP/SSAP value 0xaa you must check the SNAP type
57884 + * to discover what kind of packet we're carrying. 
57885 + */
57886 +#define CHECK_TYPE 0xaa
57887 +
57888 +/*
57889 + * Control field may be one or two bytes.  If the first byte has
57890 + * the value 0x03 then the entire length is one byte, otherwise it is two.
57891 + * One byte controls are used in Unnumbered Information frames.
57892 + * Two byte controls are used in Numbered Information frames.
57893 + */
57894 +#define IS_UI 0x03
57895 +
57896 +#define EBT_802_3_MASK (EBT_802_3_SAP | EBT_802_3_TYPE | EBT_802_3)
57897 +
57898 +/* ui has one byte ctrl, ni has two */
57899 +struct hdr_ui {
57900 +       uint8_t dsap;
57901 +       uint8_t ssap;
57902 +       uint8_t ctrl;
57903 +       uint8_t orig[3];
57904 +       uint16_t type;
57905 +};
57906 +
57907 +struct hdr_ni {
57908 +       uint8_t dsap;
57909 +       uint8_t ssap;
57910 +       uint16_t ctrl;
57911 +       uint8_t  orig[3];
57912 +       uint16_t type;
57913 +};
57914 +
57915 +struct ebt_802_3_hdr {
57916 +       uint8_t  daddr[6];
57917 +       uint8_t  saddr[6];
57918 +       uint16_t len;
57919 +       union {
57920 +               struct hdr_ui ui;
57921 +               struct hdr_ni ni;
57922 +       } llc;
57923 +};
57924 +
57925 +struct ebt_802_3_info 
57926 +{
57927 +       uint8_t  sap;
57928 +       uint16_t type;
57929 +       uint8_t  bitmask;
57930 +       uint8_t  invflags;
57931 +};
57932 +
57933 +#endif
57934 diff -Nru a/include/linux/netfilter_bridge/ebt_arpreply.h b/include/linux/netfilter_bridge/ebt_arpreply.h
57935 --- /dev/null   Wed Dec 31 16:00:00 1969
57936 +++ b/include/linux/netfilter_bridge/ebt_arpreply.h     Sun Aug 24 04:31:45 2003
57937 @@ -0,0 +1,11 @@
57938 +#ifndef __LINUX_BRIDGE_EBT_ARPREPLY_H
57939 +#define __LINUX_BRIDGE_EBT_ARPREPLY_H
57940 +
57941 +struct ebt_arpreply_info
57942 +{
57943 +       unsigned char mac[ETH_ALEN];
57944 +       int target;
57945 +};
57946 +#define EBT_ARPREPLY_TARGET "arpreply"
57947 +
57948 +#endif
57949 diff -Nru a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
57950 --- a/include/linux/netfilter_bridge.h  Sun Apr 27 18:39:57 2003
57951 +++ b/include/linux/netfilter_bridge.h  Mon Sep  1 01:44:26 2003
57952 @@ -6,7 +6,7 @@
57953  
57954  #include <linux/config.h>
57955  #include <linux/netfilter.h>
57956 -#if defined(__KERNEL__) && defined(CONFIG_NETFILTER)
57957 +#if defined(__KERNEL__) && defined(CONFIG_BRIDGE_NETFILTER)
57958  #include <asm/atomic.h>
57959  #endif
57960  
57961 @@ -27,11 +27,6 @@
57962  
57963  #ifdef __KERNEL__
57964  
57965 -#define BRNF_PKT_TYPE                  0x01
57966 -#define BRNF_BRIDGED_DNAT              0x02
57967 -#define BRNF_DONT_TAKE_PARENT          0x04
57968 -#define BRNF_BRIDGED                   0x08
57969 -
57970  enum nf_br_hook_priorities {
57971         NF_BR_PRI_FIRST = INT_MIN,
57972         NF_BR_PRI_NAT_DST_BRIDGED = -300,
57973 @@ -43,7 +38,13 @@
57974         NF_BR_PRI_LAST = INT_MAX,
57975  };
57976  
57977 -#ifdef CONFIG_NETFILTER
57978 +#ifdef CONFIG_BRIDGE_NETFILTER
57979 +
57980 +#define BRNF_PKT_TYPE                  0x01
57981 +#define BRNF_BRIDGED_DNAT              0x02
57982 +#define BRNF_DONT_TAKE_PARENT          0x04
57983 +#define BRNF_BRIDGED                   0x08
57984 +
57985  static inline
57986  struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
57987  {
57988 @@ -63,7 +64,7 @@
57989                 __u32 ipv4;
57990         } daddr;
57991  };
57992 -#endif /* CONFIG_NETFILTER */
57993 +#endif /* CONFIG_BRIDGE_NETFILTER */
57994  
57995  #endif /* __KERNEL__ */
57996  #endif
57997 diff -Nru a/include/linux/netfilter_ipv4/ipt_CLASSIFY.h b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h
57998 --- /dev/null   Wed Dec 31 16:00:00 1969
57999 +++ b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h       Sun Aug 24 17:25:17 2003
58000 @@ -0,0 +1,8 @@
58001 +#ifndef _IPT_CLASSIFY_H
58002 +#define _IPT_CLASSIFY_H
58003 +
58004 +struct ipt_classify_target_info {
58005 +       u_int32_t priority;
58006 +};
58007 +
58008 +#endif /*_IPT_CLASSIFY_H */
58009 diff -Nru a/include/linux/netfilter_ipv4/ipt_SAME.h b/include/linux/netfilter_ipv4/ipt_SAME.h
58010 --- /dev/null   Wed Dec 31 16:00:00 1969
58011 +++ b/include/linux/netfilter_ipv4/ipt_SAME.h   Sun Aug 24 17:25:18 2003
58012 @@ -0,0 +1,19 @@
58013 +#ifndef _IPT_SAME_H
58014 +#define _IPT_SAME_H
58015 +
58016 +#define IPT_SAME_MAX_RANGE     10
58017 +
58018 +#define IPT_SAME_NODST         0x01
58019 +
58020 +struct ipt_same_info
58021 +{
58022 +       unsigned char info;
58023 +       u_int32_t rangesize;
58024 +       u_int32_t ipnum;
58025 +       u_int32_t *iparray;
58026 +
58027 +       /* hangs off end. */
58028 +       struct ip_nat_range range[IPT_SAME_MAX_RANGE];
58029 +};
58030 +
58031 +#endif /*_IPT_SAME_H*/
58032 diff -Nru a/include/linux/netfilter_ipv4/ipt_iprange.h b/include/linux/netfilter_ipv4/ipt_iprange.h
58033 --- /dev/null   Wed Dec 31 16:00:00 1969
58034 +++ b/include/linux/netfilter_ipv4/ipt_iprange.h        Sun Aug 24 17:25:18 2003
58035 @@ -0,0 +1,23 @@
58036 +#ifndef _IPT_IPRANGE_H
58037 +#define _IPT_IPRANGE_H
58038 +
58039 +#define IPRANGE_SRC            0x01    /* Match source IP address */
58040 +#define IPRANGE_DST            0x02    /* Match destination IP address */
58041 +#define IPRANGE_SRC_INV                0x10    /* Negate the condition */
58042 +#define IPRANGE_DST_INV                0x20    /* Negate the condition */
58043 +
58044 +struct ipt_iprange {
58045 +       /* Inclusive: network order. */
58046 +       u_int32_t min_ip, max_ip;
58047 +};
58048 +
58049 +struct ipt_iprange_info
58050 +{
58051 +       struct ipt_iprange src;
58052 +       struct ipt_iprange dst;
58053 +
58054 +       /* Flags from above */
58055 +       u_int8_t flags;
58056 +};
58057 +
58058 +#endif /* _IPT_IPRANGE_H */
58059 diff -Nru a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
58060 --- a/include/linux/nfsd/nfsfh.h        Mon Feb 17 13:50:11 2003
58061 +++ b/include/linux/nfsd/nfsfh.h        Tue Aug 26 09:25:41 2003
58062 @@ -294,8 +294,8 @@
58063                 /* how much do we care for accuracy with MinixFS? */
58064                 fhp->fh_post_blocks     = (inode->i_size+511) >> 9;
58065         }
58066 -       fhp->fh_post_rdev[0]    = htonl((u32)major(inode->i_rdev));
58067 -       fhp->fh_post_rdev[1]    = htonl((u32)minor(inode->i_rdev));
58068 +       fhp->fh_post_rdev[0]    = htonl((u32)imajor(inode));
58069 +       fhp->fh_post_rdev[1]    = htonl((u32)iminor(inode));
58070         fhp->fh_post_atime      = inode->i_atime;
58071         fhp->fh_post_mtime      = inode->i_mtime;
58072         fhp->fh_post_ctime      = inode->i_ctime;
58073 diff -Nru a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
58074 --- a/include/linux/nfsd/state.h        Thu Jun 26 21:26:02 2003
58075 +++ b/include/linux/nfsd/state.h        Sat Aug 23 15:07:31 2003
58076 @@ -113,21 +113,15 @@
58077         int                     so_confirmed; /* successful OPEN_CONFIRM? */
58078  };
58079  
58080 -typedef struct {
58081 -       u32                     dev; /* super_block->s_dev */
58082 -       unsigned long           ino;
58083 -       u32                     generation;
58084 -} nfs4_ino_desc_t;
58085 -
58086  /*
58087  *  nfs4_file: a file opened by some number of (open) nfs4_stateowners.
58088  *    o fi_perfile list is used to search for conflicting 
58089  *      share_acces, share_deny on the file.
58090  */
58091  struct nfs4_file {
58092 -       struct list_head        fi_hash;    /* hash by nfs4_ino_desc_t fields */
58093 +       struct list_head        fi_hash;    /* hash by "struct inode *" */
58094         struct list_head        fi_perfile; /* list: nfs4_stateid */
58095 -       nfs4_ino_desc_t         fi_ino;
58096 +       struct inode            *fi_inode;
58097         u32                     fi_id;      /* used with stateowner->so_id 
58098                                              * for openstateid_hashtbl hash */
58099  };
58100 diff -Nru a/include/linux/pci_ids.h b/include/linux/pci_ids.h
58101 --- a/include/linux/pci_ids.h   Wed Aug 20 14:33:08 2003
58102 +++ b/include/linux/pci_ids.h   Mon Sep  1 15:53:57 2003
58103 @@ -798,6 +798,7 @@
58104  #define PCI_DEVICE_ID_APPLE_UNI_N_FW2  0x0030
58105  #define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2        0x0032
58106  #define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034
58107 +#define PCI_DEVICE_ID_APPLE_KAUAI_ATA  0x003b
58108  #define PCI_DEVICE_ID_APPLE_KEYLARGO_I 0x003e
58109  #define PCI_DEVICE_ID_APPLE_TIGON3     0x1645
58110  
58111 @@ -877,6 +878,7 @@
58112  
58113  #define PCI_DEVICE_ID_SII_680          0x0680
58114  #define PCI_DEVICE_ID_SII_3112         0x3112
58115 +#define PCI_DEVICE_ID_SII_1210SA       0x0240
58116  
58117  #define PCI_VENDOR_ID_VISION           0x1098
58118  #define PCI_DEVICE_ID_VISION_QD8500    0x0001
58119 @@ -1115,7 +1117,9 @@
58120  #define PCI_DEVICE_ID_TTI_HPT374       0x0008
58121  
58122  #define PCI_VENDOR_ID_VIA              0x1106
58123 -#define PCI_DEVICE_ID_VIA_P4X600       0x0198
58124 +#define PCI_DEVICE_ID_VIA_8763_0       0x0198
58125 +#define PCI_DEVICE_ID_VIA_8380_0       0x0204
58126 +#define PCI_DEVICE_ID_VIA_PX8X0_0      0x0259
58127  #define PCI_DEVICE_ID_VIA_8363_0       0x0305 
58128  #define PCI_DEVICE_ID_VIA_8371_0       0x0391
58129  #define PCI_DEVICE_ID_VIA_8501_0       0x0501
58130 @@ -1130,10 +1134,10 @@
58131  #define PCI_DEVICE_ID_VIA_82C597_0     0x0597
58132  #define PCI_DEVICE_ID_VIA_82C598_0     0x0598
58133  #define PCI_DEVICE_ID_VIA_8601_0       0x0601
58134 -#define PCI_DEVICE_ID_VIA_82C694X_0    0x0605
58135 +#define PCI_DEVICE_ID_VIA_8605_0       0x0605
58136  #define PCI_DEVICE_ID_VIA_82C680       0x0680
58137  #define PCI_DEVICE_ID_VIA_82C686       0x0686
58138 -#define PCI_DEVICE_ID_VIA_82C691       0x0691
58139 +#define PCI_DEVICE_ID_VIA_82C691_0     0x0691
58140  #define PCI_DEVICE_ID_VIA_82C693       0x0693
58141  #define PCI_DEVICE_ID_VIA_82C693_1     0x0698
58142  #define PCI_DEVICE_ID_VIA_82C926       0x0926
58143 @@ -1156,19 +1160,21 @@
58144  #define PCI_DEVICE_ID_VIA_8622         0x3102 
58145  #define PCI_DEVICE_ID_VIA_8233C_0      0x3109
58146  #define PCI_DEVICE_ID_VIA_8361         0x3112
58147 -#define PCI_DEVICE_ID_VIA_KM266                0x3116
58148 -#define PCI_DEVICE_ID_VIA_CLE266       0x3123
58149 +#define PCI_DEVICE_ID_VIA_XM266                0x3116
58150 +#define PCI_DEVICE_ID_VIA_862X_0       0x3123
58151  #define PCI_DEVICE_ID_VIA_8753_0       0x3128
58152  #define PCI_DEVICE_ID_VIA_8233A                0x3147
58153 -#define PCI_DEVICE_ID_VIA_8752         0x3148
58154 +#define PCI_DEVICE_ID_VIA_8703_51_0    0x3148
58155  #define PCI_DEVICE_ID_VIA_8237_SATA    0x3149
58156 -#define PCI_DEVICE_ID_VIA_KN266                0x3156
58157 -#define PCI_DEVICE_ID_VIA_8754         0x3168
58158 +#define PCI_DEVICE_ID_VIA_XN266                0x3156
58159 +#define PCI_DEVICE_ID_VIA_8754C_0      0x3168
58160  #define PCI_DEVICE_ID_VIA_8235         0x3177
58161  #define PCI_DEVICE_ID_VIA_P4N333       0x3178
58162 -#define PCI_DEVICE_ID_VIA_K8T400M_0    0x3188
58163 +#define PCI_DEVICE_ID_VIA_8385_0       0x3188
58164  #define PCI_DEVICE_ID_VIA_8377_0       0x3189
58165 -#define PCI_DEVICE_ID_VIA_KM400                0x3205
58166 +#define PCI_DEVICE_ID_VIA_8378_0       0x3205
58167 +#define PCI_DEVICE_ID_VIA_8783_0       0x3208
58168 +#define PCI_DEVICE_ID_VIA_PT880                0x3258
58169  #define PCI_DEVICE_ID_VIA_P4M400       0x3209
58170  #define PCI_DEVICE_ID_VIA_8237         0x3227
58171  #define PCI_DEVICE_ID_VIA_86C100A      0x6100
58172 @@ -1183,7 +1189,12 @@
58173  #define PCI_DEVICE_ID_VIA_8505_1       0x8605
58174  #define PCI_DEVICE_ID_VIA_8633_1       0xB091
58175  #define PCI_DEVICE_ID_VIA_8367_1       0xB099
58176 -#define PCI_DEVICE_ID_VIA_8653_1       0xB101
58177 +#define PCI_DEVICE_ID_VIA_P4X266_1     0xB101
58178 +#define PCI_DEVICE_ID_VIA_8615_1       0xB103
58179 +#define PCI_DEVICE_ID_VIA_8361_1       0xB112
58180 +#define PCI_DEVICE_ID_VIA_8235_1       0xB168
58181 +#define PCI_DEVICE_ID_VIA_838X_1       0xB188
58182 +#define PCI_DEVICE_ID_VIA_83_87XX_1    0xB198
58183  
58184  #define PCI_VENDOR_ID_SIEMENS           0x110A
58185  #define PCI_DEVICE_ID_SIEMENS_DSCC4     0x2102
58186 @@ -1274,6 +1285,9 @@
58187  #define PCI_DEVICE_ID_SYSKONNECT_FP    0x4000
58188  #define PCI_DEVICE_ID_SYSKONNECT_TR    0x4200
58189  #define PCI_DEVICE_ID_SYSKONNECT_GE    0x4300
58190 +#define PCI_DEVICE_ID_SYSKONNECT_YU    0x4320
58191 +#define PCI_DEVICE_ID_SYSKONNECT_9DXX  0x4400
58192 +#define PCI_DEVICE_ID_SYSKONNECT_9MXX  0x4500
58193  
58194  #define PCI_VENDOR_ID_VMIC             0x114a
58195  #define PCI_DEVICE_ID_VMIC_VME         0x7587
58196 @@ -1332,7 +1346,10 @@
58197  #define PCI_VENDOR_ID_TOSHIBA          0x1179
58198  #define PCI_DEVICE_ID_TOSHIBA_601      0x0601
58199  #define PCI_DEVICE_ID_TOSHIBA_TOPIC95  0x060a
58200 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_A 0x0603
58201 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_B 0x060a
58202  #define PCI_DEVICE_ID_TOSHIBA_TOPIC97  0x060f
58203 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617
58204  
58205  #define PCI_VENDOR_ID_TOSHIBA_2                0x102f
58206  #define PCI_DEVICE_ID_TOSHIBA_TX3927   0x000a
58207 @@ -1758,11 +1775,19 @@
58208  #define PCI_DEVICE_ID_TIGON3_5703      0x1647
58209  #define PCI_DEVICE_ID_TIGON3_5704      0x1648
58210  #define PCI_DEVICE_ID_TIGON3_5702FE    0x164d
58211 +#define PCI_DEVICE_ID_TIGON3_5705      0x1653
58212 +#define PCI_DEVICE_ID_TIGON3_5705_2    0x1654
58213 +#define PCI_DEVICE_ID_TIGON3_5705M     0x165d
58214 +#define PCI_DEVICE_ID_TIGON3_5705M_2   0x165e
58215 +#define PCI_DEVICE_ID_TIGON3_5782      0x1696
58216 +#define PCI_DEVICE_ID_TIGON3_5788      0x169c
58217  #define PCI_DEVICE_ID_TIGON3_5702X     0x16a6
58218  #define PCI_DEVICE_ID_TIGON3_5703X     0x16a7
58219  #define PCI_DEVICE_ID_TIGON3_5704S     0x16a8
58220  #define PCI_DEVICE_ID_TIGON3_5702A3    0x16c6
58221  #define PCI_DEVICE_ID_TIGON3_5703A3    0x16c7
58222 +#define PCI_DEVICE_ID_TIGON3_5901      0x170d
58223 +#define PCI_DEVICE_ID_TIGON3_5901_2    0x170e
58224  #define PCI_DEVICE_ID_BCM4401          0x4401
58225  
58226  #define PCI_VENDOR_ID_SYBA             0x1592
58227 @@ -1790,6 +1815,7 @@
58228  #define PCI_DEVICE_ID_ALTIMA_AC1000    0x03e8
58229  #define PCI_DEVICE_ID_ALTIMA_AC1001    0x03e9
58230  #define PCI_DEVICE_ID_ALTIMA_AC9100    0x03ea
58231 +#define PCI_DEVICE_ID_ALTIMA_AC1003    0x03eb
58232  
58233  #define PCI_VENDOR_ID_SYMPHONY         0x1c1c
58234  #define PCI_DEVICE_ID_SYMPHONY_101     0x0001
58235 diff -Nru a/include/linux/personality.h b/include/linux/personality.h
58236 --- a/include/linux/personality.h       Sun Dec 29 15:44:39 2002
58237 +++ b/include/linux/personality.h       Sun Aug 31 16:13:59 2003
58238 @@ -34,6 +34,7 @@
58239         SHORT_INODE =           0x1000000,
58240         WHOLE_SECONDS =         0x2000000,
58241         STICKY_TIMEOUTS =       0x4000000,
58242 +       ADDR_LIMIT_3GB =        0x8000000,
58243  };
58244  
58245  /*
58246 @@ -56,6 +57,7 @@
58247         PER_SUNOS =             0x0006 | STICKY_TIMEOUTS,
58248         PER_XENIX =             0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
58249         PER_LINUX32 =           0x0008,
58250 +       PER_LINUX32_3GB =       0x0008 | ADDR_LIMIT_3GB,
58251         PER_IRIX32 =            0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
58252         PER_IRIXN32 =           0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
58253         PER_IRIX64 =            0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
58254 diff -Nru a/include/linux/pmu.h b/include/linux/pmu.h
58255 --- a/include/linux/pmu.h       Sun Feb  2 13:51:33 2003
58256 +++ b/include/linux/pmu.h       Mon Aug 25 10:06:34 2003
58257 @@ -33,6 +33,7 @@
58258  #define PMU_CPU_SPEED          0x7d    /* control CPU speed on some models */
58259  #define PMU_SLEEP              0x7f    /* put CPU to sleep */
58260  #define PMU_POWER_EVENTS       0x8f    /* Send power-event commands to PMU */
58261 +#define PMU_I2C_CMD            0x9a    /* I2C operations */
58262  #define PMU_RESET              0xd0    /* reset CPU */
58263  #define PMU_GET_BRIGHTBUTTON   0xd9    /* report brightness up/down pos */
58264  #define PMU_GET_COVER          0xdc    /* report cover open/closed */
58265 @@ -69,6 +70,20 @@
58266   * or via PMU_INT_ENVIRONMENT on core99 */
58267  #define PMU_ENV_LID_CLOSED     0x01    /* The lid is closed */
58268  
58269 +/* I2C related definitions */
58270 +#define PMU_I2C_MODE_SIMPLE    0
58271 +#define PMU_I2C_MODE_STDSUB    1
58272 +#define PMU_I2C_MODE_COMBINED  2
58273 +
58274 +#define PMU_I2C_BUS_STATUS     0
58275 +#define PMU_I2C_BUS_SYSCLK     1
58276 +#define PMU_I2C_BUS_POWER      2
58277 +
58278 +#define PMU_I2C_STATUS_OK      0
58279 +#define PMU_I2C_STATUS_DATAREAD        1
58280 +#define PMU_I2C_STATUS_BUSY    0xfe
58281 +
58282 +
58283  /* Kind of PMU (model) */
58284  enum {
58285         PMU_UNKNOWN,
58286 @@ -127,6 +142,8 @@
58287                 void (*done)(struct adb_request *), int nbytes, ...);
58288  
58289  extern void pmu_poll(void);
58290 +extern void pmu_poll_adb(void); /* For use by xmon */
58291 +extern void pmu_wait_complete(struct adb_request *req);
58292  
58293  /* For use before switching interrupts off for a long time;
58294   * warning: not stackable
58295 @@ -138,9 +155,16 @@
58296  
58297  extern void pmu_restart(void);
58298  extern void pmu_shutdown(void);
58299 +extern void pmu_unlock(void);
58300  
58301  extern int pmu_present(void);
58302  extern int pmu_get_model(void);
58303 +
58304 +extern int pmu_i2c_combined_read(int bus, int addr, int subaddr,  u8* data, int len);
58305 +extern int pmu_i2c_stdsub_write(int bus, int addr, int subaddr,  u8* data, int len);
58306 +extern int pmu_i2c_simple_read(int bus, int addr,  u8* data, int len);
58307 +extern int pmu_i2c_simple_write(int bus, int addr,  u8* data, int len);
58308 +
58309  
58310  #ifdef CONFIG_PMAC_PBOOK
58311  /*
58312 diff -Nru a/include/linux/proc_fs.h b/include/linux/proc_fs.h
58313 --- a/include/linux/proc_fs.h   Thu Jul 10 22:22:53 2003
58314 +++ b/include/linux/proc_fs.h   Sun Aug 31 16:14:22 2003
58315 @@ -182,12 +182,6 @@
58316         remove_proc_entry(name,proc_net);
58317  }
58318  
58319 -/*
58320 - * fs/proc/kcore.c
58321 - */
58322 -extern void kclist_add(struct kcore_list *, void *, size_t);
58323 -extern struct kcore_list *kclist_del(void *);
58324 -
58325  #else
58326  
58327  #define proc_root_driver NULL
58328 @@ -223,6 +217,9 @@
58329  
58330  extern struct proc_dir_entry proc_root;
58331  
58332 +#endif /* CONFIG_PROC_FS */
58333 +
58334 +#if !defined(CONFIG_PROC_FS)
58335  static inline void kclist_add(struct kcore_list *new, void *addr, size_t size)
58336  {
58337  }
58338 @@ -230,8 +227,10 @@
58339  {
58340         return NULL;
58341  }
58342 -
58343 -#endif /* CONFIG_PROC_FS */
58344 +#else
58345 +extern void kclist_add(struct kcore_list *, void *, size_t);
58346 +extern struct kcore_list *kclist_del(void *);
58347 +#endif
58348  
58349  struct proc_inode {
58350         struct task_struct *task;
58351 diff -Nru a/include/linux/sched.h b/include/linux/sched.h
58352 --- a/include/linux/sched.h     Wed Aug 20 22:32:07 2003
58353 +++ b/include/linux/sched.h     Sun Aug 31 16:14:26 2003
58354 @@ -391,6 +391,7 @@
58355         struct timer_list real_timer;
58356         struct list_head posix_timers; /* POSIX.1b Interval Timers */
58357         unsigned long utime, stime, cutime, cstime;
58358 +       unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; /* context switch counts */
58359         u64 start_time;
58360  /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
58361         unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
58362 diff -Nru a/include/linux/serial_core.h b/include/linux/serial_core.h
58363 --- a/include/linux/serial_core.h       Wed Jul 16 01:49:46 2003
58364 +++ b/include/linux/serial_core.h       Sun Aug 24 08:17:18 2003
58365 @@ -67,6 +67,9 @@
58366  #define PORT_PC9861    45
58367  #define PORT_PC9801_101        46
58368  
58369 +/* Macintosh Zilog type numbers */
58370 +#define PORT_MAC_ZILOG 50      /* m68k : not yet implemented */
58371 +#define PORT_PMAC_ZILOG        51
58372  
58373  #ifdef __KERNEL__
58374  
58375 diff -Nru a/include/linux/skbuff.h b/include/linux/skbuff.h
58376 --- a/include/linux/skbuff.h    Thu Aug  7 14:30:45 2003
58377 +++ b/include/linux/skbuff.h    Mon Sep  1 01:44:26 2003
58378 @@ -98,7 +98,7 @@
58379         struct nf_conntrack *master;
58380  };
58381  
58382 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
58383 +#ifdef CONFIG_BRIDGE_NETFILTER
58384  struct nf_bridge_info {
58385         atomic_t use;
58386         struct net_device *physindev;
58387 @@ -244,7 +244,7 @@
58388  #ifdef CONFIG_NETFILTER_DEBUG
58389          unsigned int           nf_debug;
58390  #endif
58391 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
58392 +#ifdef CONFIG_BRIDGE_NETFILTER
58393         struct nf_bridge_info   *nf_bridge;
58394  #endif
58395  #endif /* CONFIG_NETFILTER */
58396 @@ -1195,7 +1195,7 @@
58397                 atomic_inc(&nfct->master->use);
58398  }
58399  
58400 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
58401 +#ifdef CONFIG_BRIDGE_NETFILTER
58402  static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge)
58403  {
58404         if (nf_bridge && atomic_dec_and_test(&nf_bridge->use))
58405 diff -Nru a/include/linux/sonypi.h b/include/linux/sonypi.h
58406 --- a/include/linux/sonypi.h    Tue Feb 18 03:32:56 2003
58407 +++ b/include/linux/sonypi.h    Fri Aug  1 05:36:45 2003
58408 @@ -94,6 +94,8 @@
58409  #define SONYPI_EVENT_MEMORYSTICK_INSERT                54
58410  #define SONYPI_EVENT_MEMORYSTICK_EJECT         55
58411  #define SONYPI_EVENT_ANYBUTTON_RELEASED                56
58412 +#define SONYPI_EVENT_BATTERY_INSERT            57
58413 +#define SONYPI_EVENT_BATTERY_REMOVE            58
58414  
58415  /* get/set brightness */
58416  #define SONYPI_IOCGBRT         _IOR('v', 0, __u8)
58417 diff -Nru a/include/linux/tpqic02.h b/include/linux/tpqic02.h
58418 --- a/include/linux/tpqic02.h   Mon May 12 20:10:40 2003
58419 +++ b/include/linux/tpqic02.h   Tue Aug 26 09:25:40 2003
58420 @@ -587,10 +587,10 @@
58421   *  |___________________ Reserved for diagnostics during debugging.
58422   */
58423  
58424 -#define        TP_REWCLOSE(d)  ((minor(d)&0x01) == 1)                  /* rewind bit */
58425 +#define        TP_REWCLOSE(d)  ((d)&1)                 /* rewind bit */
58426                            /* rewind is only done if data has been transferred */
58427 -#define        TP_DENS(dev)    ((minor(dev) >> 1) & 0x07)            /* tape density */
58428 -#define TP_UNIT(dev)   ((minor(dev) >> 4) & 0x07)             /* unit number */
58429 +#define        TP_DENS(d)      (((d) >> 1) & 0x07)           /* tape density */
58430 +#define TP_UNIT(d)     (((d) >> 4) & 0x07)            /* unit number */
58431  
58432  /* print excessive diagnostics */
58433  #define TP_DIAGS(dev)  (QIC02_TAPE_DEBUG & TPQD_DIAGS)
58434 diff -Nru a/include/linux/tty.h b/include/linux/tty.h
58435 --- a/include/linux/tty.h       Thu Jul 17 22:30:53 2003
58436 +++ b/include/linux/tty.h       Tue Aug 26 09:25:40 2003
58437 @@ -367,7 +367,7 @@
58438  extern int macserial_init(void);
58439  extern int a2232board_init(void);
58440  
58441 -extern int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
58442 +extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
58443                               const char *routine);
58444  extern char *tty_name(struct tty_struct *tty, char *buf);
58445  extern void tty_wait_until_sent(struct tty_struct * tty, long timeout);
58446 diff -Nru a/include/linux/usb.h b/include/linux/usb.h
58447 --- a/include/linux/usb.h       Wed Aug 13 06:35:23 2003
58448 +++ b/include/linux/usb.h       Wed Aug 27 10:04:01 2003
58449 @@ -410,6 +410,8 @@
58450   *     the "usbfs" filesystem.  This lets devices provide ways to
58451   *     expose information to user space regardless of where they
58452   *     do (or don't) show up otherwise in the filesystem.
58453 + * @suspend: Called when the device is going to be suspended by the system.
58454 + * @resume: Called when the device is being resumed by the system.
58455   * @id_table: USB drivers use ID table to support hotplugging.
58456   *     Export this with MODULE_DEVICE_TABLE(usb,...).  This must be set
58457   *     or your driver's probe function will never get called.
58458 @@ -444,6 +446,9 @@
58459         void (*disconnect) (struct usb_interface *intf);
58460  
58461         int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf);
58462 +
58463 +       int (*suspend) (struct usb_interface *intf, u32 state);
58464 +       int (*resume) (struct usb_interface *intf);
58465  
58466         const struct usb_device_id *id_table;
58467  
58468 diff -Nru a/include/linux/usb_gadget.h b/include/linux/usb_gadget.h
58469 --- a/include/linux/usb_gadget.h        Thu Jul 31 04:09:33 2003
58470 +++ b/include/linux/usb_gadget.h        Sat Aug 23 02:56:23 2003
58471 @@ -313,8 +313,8 @@
58472   * arranges to poll once per interval, and the gadget driver usually will
58473   * have queued some data to transfer at that time.
58474   *
58475 - * Returns zero, or a negative error code.  Endpoints that are not enabled,
58476 - * or which are enabled but halted, report errors; errors will also be
58477 + * Returns zero, or a negative error code.  Endpoints that are not enabled
58478 + * report errors; errors will also be
58479   * reported when the usb peripheral is disconnected.
58480   */
58481  static inline int
58482 @@ -352,6 +352,11 @@
58483   * clears this feature; drivers may need to empty the endpoint's request
58484   * queue first, to make sure no inappropriate transfers happen.
58485   *
58486 + * Note that while an endpoint CLEAR_FEATURE will be invisible to the
58487 + * gadget driver, a SET_INTERFACE will not be.  To reset endpoints for the
58488 + * current altsetting, see usb_ep_clear_halt().  When switching altsettings,
58489 + * it's simplest to use usb_ep_enable() or usb_ep_disable() for the endpoints.
58490 + *
58491   * Returns zero, or a negative error code.  On success, this call sets
58492   * underlying hardware state that blocks data transfers.
58493   */
58494 @@ -365,12 +370,14 @@
58495   * usb_ep_clear_halt - clears endpoint halt, and resets toggle
58496   * @ep:the bulk or interrupt endpoint being reset
58497   *
58498 - * use this when responding to the standard usb "set interface" request,
58499 + * Use this when responding to the standard usb "set interface" request,
58500   * for endpoints that aren't reconfigured, after clearing any other state
58501   * in the endpoint's i/o queue.
58502   *
58503 - * returns zero, or a negative error code.  on success, this call clears
58504 + * Returns zero, or a negative error code.  On success, this call clears
58505   * the underlying hardware state reflecting endpoint halt and data toggle.
58506 + * Note that some hardware can't support this request (like pxa2xx_udc),
58507 + * and accordingly can't correctly implement interface altsettings.
58508   */
58509  static inline int
58510  usb_ep_clear_halt (struct usb_ep *ep)
58511 @@ -562,7 +569,8 @@
58512   *     queues a response to ep0, or returns negative to stall.
58513   * @disconnect: Invoked after all transfers have been stopped,
58514   *     when the host is disconnected.  May be called in_interrupt; this
58515 - *     may not sleep.
58516 + *     may not sleep.  Some devices can't detect disconnect, so this might
58517 + *     not be called except as part of controller shutdown.
58518   * @unbind: Invoked when the driver is unbound from a gadget,
58519   *     usually from rmmod (after a disconnect is reported).
58520   *     Called in a context that permits sleeping.
58521 @@ -603,7 +611,9 @@
58522   * not provide those callbacks.  However, some may need to change modes
58523   * when the host is not longer directing those activities.  For example,
58524   * local controls (buttons, dials, etc) may need to be re-enabled since
58525 - * the (remote) host can't do that any longer. 
58526 + * the (remote) host can't do that any longer; or an error state might
58527 + * be cleared, to make the device behave identically whether or not
58528 + * power is maintained.
58529   */
58530  struct usb_gadget_driver {
58531         char                    *function;
58532 diff -Nru a/include/linux/videodev.h b/include/linux/videodev.h
58533 --- a/include/linux/videodev.h  Wed Aug  6 02:51:26 2003
58534 +++ b/include/linux/videodev.h  Fri Aug 22 08:51:55 2003
58535 @@ -63,6 +63,12 @@
58536  {
58537         class_device_create_file(&vfd->class_dev, attr);
58538  }
58539 +static inline void
58540 +video_device_remove_file(struct video_device *vfd,
58541 +                        struct class_device_attribute *attr)
58542 +{
58543 +       class_device_remove_file(&vfd->class_dev, attr);
58544 +}
58545  
58546  /* helper functions to alloc / release struct video_device, the
58547     later can be used for video_device->release() */
58548 diff -Nru a/include/linux/wait.h b/include/linux/wait.h
58549 --- a/include/linux/wait.h      Sun May 18 17:00:00 2003
58550 +++ b/include/linux/wait.h      Sun Aug 31 16:14:00 2003
58551 @@ -220,22 +220,6 @@
58552         __remove_wait_queue(q,  wait);
58553  }
58554  
58555 -#define add_wait_queue_cond(q, wait, cond) \
58556 -       ({                                                      \
58557 -               unsigned long flags;                            \
58558 -               int _raced = 0;                                 \
58559 -               spin_lock_irqsave(&(q)->lock, flags);   \
58560 -               (wait)->flags = 0;                              \
58561 -               __add_wait_queue((q), (wait));                  \
58562 -               rmb();                                          \
58563 -               if (!(cond)) {                                  \
58564 -                       _raced = 1;                             \
58565 -                       __remove_wait_queue((q), (wait));       \
58566 -               }                                               \
58567 -               spin_lock_irqrestore(&(q)->lock, flags);        \
58568 -               _raced;                                         \
58569 -       })
58570 -
58571  /*
58572   * These are the old interfaces to sleep waiting for an event.
58573   * They are racy.  DO NOT use them, use the wait_event* interfaces above.  
58574 diff -Nru a/include/net/ax25.h b/include/net/ax25.h
58575 --- a/include/net/ax25.h        Thu Aug 21 11:59:08 2003
58576 +++ b/include/net/ax25.h        Sun Aug 24 04:34:01 2003
58577 @@ -314,7 +314,7 @@
58578  /* ax25_route.c */
58579  extern void ax25_rt_device_down(struct net_device *);
58580  extern int  ax25_rt_ioctl(unsigned int, void *);
58581 -extern int  ax25_rt_get_info(char *, char **, off_t, int);
58582 +extern struct file_operations ax25_route_fops;
58583  extern int  ax25_rt_autobind(ax25_cb *, ax25_address *);
58584  extern ax25_route *ax25_rt_find_route(ax25_route *, ax25_address *,
58585         struct net_device *);
58586 @@ -373,7 +373,7 @@
58587  extern int  ax25_uid_policy;
58588  extern ax25_address *ax25_findbyuid(uid_t);
58589  extern int  ax25_uid_ioctl(int, struct sockaddr_ax25 *);
58590 -extern int  ax25_uid_get_info(char *, char **, off_t, int);
58591 +extern struct file_operations ax25_uid_fops;
58592  extern void ax25_uid_free(void);
58593  
58594  /* sysctl_net_ax25.c */
58595 diff -Nru a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
58596 --- a/include/net/ip6_tunnel.h  Mon Jun  9 07:56:44 2003
58597 +++ b/include/net/ip6_tunnel.h  Mon Sep  1 01:55:01 2003
58598 @@ -25,6 +25,8 @@
58599         int recursion;          /* depth of hard_start_xmit recursion */
58600         struct ip6_tnl_parm parms;      /* tunnel configuration paramters */
58601         struct flowi fl;        /* flowi template for xmit */
58602 +       struct dst_entry *dst_cache;    /* cached dst */
58603 +       u32 dst_cookie;
58604  };
58605  
58606  /* Tunnel encapsulation limit destination sub-option */
58607 diff -Nru a/include/net/ipv6.h b/include/net/ipv6.h
58608 --- a/include/net/ipv6.h        Mon Aug 18 03:14:19 2003
58609 +++ b/include/net/ipv6.h        Mon Sep  1 07:33:05 2003
58610 @@ -193,7 +193,7 @@
58611         struct in6_addr         dst;
58612         struct ipv6_txoptions   *opt;
58613         atomic_t                users;
58614 -       u32                     linger;
58615 +       unsigned long           linger;
58616         u8                      share;
58617         u32                     owner;
58618         unsigned long           lastuse;
58619 diff -Nru a/include/net/irda/vlsi_ir.h b/include/net/irda/vlsi_ir.h
58620 --- a/include/net/irda/vlsi_ir.h        Tue Jun 10 16:16:15 2003
58621 +++ b/include/net/irda/vlsi_ir.h        Sun Aug 24 04:45:26 2003
58622 @@ -3,7 +3,7 @@
58623   *
58624   *     vlsi_ir.h:      VLSI82C147 PCI IrDA controller driver for Linux
58625   *
58626 - *     Version:        0.4a
58627 + *     Version:        0.5
58628   *
58629   *     Copyright (c) 2001-2003 Martin Diehl
58630   *
58631 @@ -27,18 +27,71 @@
58632  #ifndef IRDA_VLSI_FIR_H
58633  #define IRDA_VLSI_FIR_H
58634  
58635 -/*
58636 - * #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,xx)
58637 - *
58638 - * missing pci-dma api call to give streaming dma buffer back to hw
58639 - * patch floating on lkml - probably present in 2.5.26 or later
58640 - * otherwise defining it as noop is ok, since the vlsi-ir is only
58641 - * used on two oldish x86-based notebooks which are cache-coherent
58642 +/* ================================================================
58643 + * compatibility stuff
58644   */
58645 -#define pci_dma_prep_single(dev, addr, size, direction)        /* nothing */
58646 -/*
58647 - * #endif
58648 +
58649 +/* definitions not present in pci_ids.h */
58650 +
58651 +#ifndef PCI_CLASS_WIRELESS_IRDA
58652 +#define PCI_CLASS_WIRELESS_IRDA                0x0d00
58653 +#endif
58654 +
58655 +#ifndef PCI_CLASS_SUBCLASS_MASK
58656 +#define PCI_CLASS_SUBCLASS_MASK                0xffff
58657 +#endif
58658 +
58659 +/* missing pci-dma api call to give streaming dma buffer back to hw
58660 + * patch was floating on lkml around 2.5.2x and might be present later.
58661 + * Defining it this way is ok, since the vlsi-ir is only
58662 + * used on two oldish x86-based notebooks which are cache-coherent
58663 + * (and flush_write_buffers also handles PPro errata and C3 OOstore)
58664   */
58665 +#ifdef CONFIG_X86
58666 +#include <asm-i386/io.h>
58667 +#define pci_dma_prep_single(dev, addr, size, direction)        flush_write_buffers()
58668 +#else
58669 +#error missing pci dma api call
58670 +#endif
58671 +
58672 +/* in recent 2.5 interrupt handlers have non-void return value */
58673 +#ifndef IRQ_RETVAL
58674 +typedef void irqreturn_t;
58675 +#define IRQ_NONE
58676 +#define IRQ_HANDLED
58677 +#define IRQ_RETVAL(x)
58678 +#endif
58679 +
58680 +/* some stuff need to check kernelversion. Not all 2.5 stuff was present
58681 + * in early 2.5.x - the test is merely to separate 2.4 from 2.5
58682 + */
58683 +#include <linux/version.h>
58684 +
58685 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
58686 +
58687 +/* PDE() introduced in 2.5.4 */
58688 +#ifdef CONFIG_PROC_FS
58689 +#define PDE(inode) ((inode)->u.generic_ip)
58690 +#endif
58691 +
58692 +/* irda crc16 calculation exported in 2.5.42 */
58693 +#define irda_calc_crc16(fcs,buf,len)   (GOOD_FCS)
58694 +
58695 +/* we use this for unified pci device name access */
58696 +#define PCIDEV_NAME(pdev)      ((pdev)->name)
58697 +
58698 +#else /* 2.5 or later */
58699 +
58700 +/* recent 2.5/2.6 stores pci device names at varying places ;-) */
58701 +#ifdef CONFIG_PCI_NAMES
58702 +/* human readable name */
58703 +#define PCIDEV_NAME(pdev)      ((pdev)->pretty_name)
58704 +#else
58705 +/* whatever we get from the associated struct device - bus:slot:dev.fn id */
58706 +#define PCIDEV_NAME(pdev)      (pci_name(pdev))
58707 +#endif
58708 +
58709 +#endif
58710  
58711  /* ================================================================ */
58712  
58713 @@ -138,7 +191,7 @@
58714   *     - IRMISC_UARTSEL configured
58715   *     - IRCFG_MASTER must be cleared
58716   *     - IRCFG_SIR must be set
58717 - *     - IRENABLE_IREN must be asserted 0->1 (and hence IRENABLE_SIR_ON)
58718 + *     - IRENABLE_PHYANDCLOCK must be asserted 0->1 (and hence IRENABLE_SIR_ON)
58719   */
58720  
58721  enum vlsi_pci_irmisc {
58722 @@ -298,7 +351,7 @@
58723  /* notes:
58724   *     - not more than one SIR/MIR/FIR bit must be set at any time
58725   *     - SIR, MIR, FIR and CRC16 select the configuration which will
58726 - *       be applied on next 0->1 transition of IRENABLE_IREN (see below).
58727 + *       be applied on next 0->1 transition of IRENABLE_PHYANDCLOCK (see below).
58728   *     - besides allowing the PCI interface to execute busmaster cycles
58729   *       and therefore the ring SM to operate, the MSTR bit has side-effects:
58730   *       when MSTR is cleared, the RINGPTR's get reset and the legacy UART mode
58731 @@ -349,7 +402,7 @@
58732   */
58733  
58734  enum vlsi_pio_irenable {
58735 -       IRENABLE_IREN           = 0x8000,  /* enable IR phy and gate the mode config (rw) */
58736 +       IRENABLE_PHYANDCLOCK    = 0x8000,  /* enable IR phy and gate the mode config (rw) */
58737         IRENABLE_CFGER          = 0x4000,  /* mode configuration error (ro) */
58738         IRENABLE_FIR_ON         = 0x2000,  /* FIR on status (ro) */
58739         IRENABLE_MIR_ON         = 0x1000,  /* MIR on status (ro) */
58740 @@ -366,7 +419,7 @@
58741  /* VLSI_PIO_PHYCTL: IR Physical Layer Current Control Register (u16, ro) */
58742  
58743  /* read-back of the currently applied physical layer status.
58744 - * applied from VLSI_PIO_NPHYCTL at rising edge of IRENABLE_IREN
58745 + * applied from VLSI_PIO_NPHYCTL at rising edge of IRENABLE_PHYANDCLOCK
58746   * contents identical to VLSI_PIO_NPHYCTL (see below)
58747   */
58748  
58749 @@ -374,7 +427,7 @@
58750  
58751  /* VLSI_PIO_NPHYCTL: IR Physical Layer Next Control Register (u16, rw) */
58752  
58753 -/* latched during IRENABLE_IREN=0 and applied at 0-1 transition
58754 +/* latched during IRENABLE_PHYANDCLOCK=0 and applied at 0-1 transition
58755   *
58756   * consists of BAUD[15:10], PLSWID[9:5] and PREAMB[4:0] bits defined as follows:
58757   *
58758 @@ -616,21 +669,22 @@
58759          */
58760  
58761         if ((a & ~DMA_MASK_MSTRPAGE)>>24 != MSTRPAGE_VALUE) {
58762 -               BUG();
58763 +               ERROR("%s: pci busaddr inconsistency!\n", __FUNCTION__);
58764 +               dump_stack();
58765                 return;
58766         }
58767  
58768         a &= DMA_MASK_MSTRPAGE;  /* clear highbyte to make sure we won't write
58769                                   * to status - just in case MSTRPAGE_VALUE!=0
58770                                   */
58771 -       rd->hw->rd_addr = a;
58772 +       rd->hw->rd_addr = cpu_to_le32(a);
58773         wmb();
58774         rd_set_status(rd, s);    /* may pass ownership to the hardware */
58775  }
58776  
58777  static inline void rd_set_count(struct ring_descr *rd, u16 c)
58778  {
58779 -       rd->hw->rd_count = c;
58780 +       rd->hw->rd_count = cpu_to_le16(c);
58781  }
58782  
58783  static inline u8 rd_get_status(struct ring_descr *rd)
58784 @@ -642,13 +696,13 @@
58785  {
58786         dma_addr_t      a;
58787  
58788 -       a = (rd->hw->rd_addr & DMA_MASK_MSTRPAGE) | (MSTRPAGE_VALUE << 24);
58789 -       return a;
58790 +       a = le32_to_cpu(rd->hw->rd_addr);
58791 +       return (a & DMA_MASK_MSTRPAGE) | (MSTRPAGE_VALUE << 24);
58792  }
58793  
58794  static inline u16 rd_get_count(struct ring_descr *rd)
58795  {
58796 -       return rd->hw->rd_count;
58797 +       return le16_to_cpu(rd->hw->rd_count);
58798  }
58799  
58800  /******************************************************************/
58801 diff -Nru a/init/Kconfig b/init/Kconfig
58802 --- a/init/Kconfig      Wed Aug 20 22:30:10 2003
58803 +++ b/init/Kconfig      Tue Sep  2 11:30:07 2003
58804 @@ -32,16 +32,24 @@
58805           you say Y here, you will be offered the choice of using features or
58806           drivers that are currently considered to be in the alpha-test phase.
58807  
58808 -config BROKEN
58809 -       bool "Prompt for old and known-broken drivers"
58810 -       depends on EXPERIMENTAL
58811 -       default n
58812 +config CLEAN_COMPILE
58813 +       bool "Don't select drivers known to be broken" if EXPERIMENTAL
58814 +       default y
58815         help
58816 -         This option allows you to choose whether you want to try to
58817 -         compile (and fix) old drivers that haven't been updated to
58818 -         new infrastructure.
58819 +         Select this option if you don't even want to see the option
58820 +         to configure known-broken drivers.
58821 +
58822 +         If unsure, say Y
58823 +
58824 +config BROKEN
58825 +       bool
58826 +       depends on !CLEAN_COMPILE
58827 +       default y
58828  
58829 -         If unsure, say N.
58830 +config BROKEN_ON_SMP
58831 +       bool
58832 +       depends on BROKEN || !SMP
58833 +       default y
58834  
58835  endmenu
58836  
58837 diff -Nru a/init/main.c b/init/main.c
58838 --- a/init/main.c       Fri May  2 11:15:48 2003
58839 +++ b/init/main.c       Sun Aug 31 16:14:48 2003
58840 @@ -89,10 +89,6 @@
58841  extern void tc_init(void);
58842  #endif
58843  
58844 -#if defined(CONFIG_SYSVIPC)
58845 -extern void ipc_init(void);
58846 -#endif
58847 -
58848  /*
58849   * Are we up and running (ie do we have all the infrastructure
58850   * set up)
58851 @@ -106,6 +102,8 @@
58852  #define MAX_INIT_ENVS 8
58853  
58854  extern void time_init(void);
58855 +/* Default late time init is NULL. archs can override this later. */
58856 +void (*late_time_init)(void) = NULL;
58857  extern void softirq_init(void);
58858  
58859  int rows, cols;
58860 @@ -421,7 +419,6 @@
58861         console_init();
58862         profile_init();
58863         local_irq_enable();
58864 -       calibrate_delay();
58865  #ifdef CONFIG_BLK_DEV_INITRD
58866         if (initrd_start && !initrd_below_start_ok &&
58867                         initrd_start < min_low_pfn << PAGE_SHIFT) {
58868 @@ -433,6 +430,9 @@
58869         page_address_init();
58870         mem_init();
58871         kmem_cache_init();
58872 +       if (late_time_init)
58873 +               late_time_init();
58874 +       calibrate_delay();
58875         pidmap_init();
58876         pgtable_cache_init();
58877         pte_chain_init();
58878 @@ -448,9 +448,6 @@
58879         populate_rootfs();
58880  #ifdef CONFIG_PROC_FS
58881         proc_root_init();
58882 -#endif
58883 -#if defined(CONFIG_SYSVIPC)
58884 -       ipc_init();
58885  #endif
58886         check_bugs();
58887         printk("POSIX conformance testing by UNIFIX\n");
58888 diff -Nru a/ipc/msg.c b/ipc/msg.c
58889 --- a/ipc/msg.c Mon May 12 21:23:19 2003
58890 +++ b/ipc/msg.c Thu Aug 28 10:07:51 2003
58891 @@ -707,7 +707,7 @@
58892                 goto retry;
58893         }
58894  
58895 -       msq->q_lspid = current->pid;
58896 +       msq->q_lspid = current->tgid;
58897         msq->q_stime = get_seconds();
58898  
58899         if(!pipelined_send(msq,msg)) {
58900 @@ -801,7 +801,7 @@
58901                 list_del(&msg->m_list);
58902                 msq->q_qnum--;
58903                 msq->q_rtime = get_seconds();
58904 -               msq->q_lrpid = current->pid;
58905 +               msq->q_lrpid = current->tgid;
58906                 msq->q_cbytes -= msg->m_ts;
58907                 atomic_sub(msg->m_ts,&msg_bytes);
58908                 atomic_dec(&msg_hdrs);
58909 diff -Nru a/ipc/sem.c b/ipc/sem.c
58910 --- a/ipc/sem.c Sun Jul 13 08:55:51 2003
58911 +++ b/ipc/sem.c Thu Aug 28 10:08:09 2003
58912 @@ -664,7 +664,7 @@
58913                 for (un = sma->undo; un; un = un->id_next)
58914                         un->semadj[semnum] = 0;
58915                 curr->semval = val;
58916 -               curr->sempid = current->pid;
58917 +               curr->sempid = current->tgid;
58918                 sma->sem_ctime = get_seconds();
58919                 /* maybe some queued-up processes were waiting for this */
58920                 update_queue(sma);
58921 @@ -1052,7 +1052,7 @@
58922         if (error)
58923                 goto out_unlock_free;
58924  
58925 -       error = try_atomic_semop (sma, sops, nsops, un, current->pid);
58926 +       error = try_atomic_semop (sma, sops, nsops, un, current->tgid);
58927         if (error <= 0)
58928                 goto update;
58929  
58930 @@ -1064,7 +1064,7 @@
58931         queue.sops = sops;
58932         queue.nsops = nsops;
58933         queue.undo = un;
58934 -       queue.pid = current->pid;
58935 +       queue.pid = current->tgid;
58936         queue.id = semid;
58937         if (alter)
58938                 append_to_queue(sma ,&queue);
58939 @@ -1206,7 +1206,7 @@
58940                                 sem->semval += u->semadj[i];
58941                                 if (sem->semval < 0)
58942                                         sem->semval = 0; /* shouldn't happen */
58943 -                               sem->sempid = current->pid;
58944 +                               sem->sempid = current->tgid;
58945                         }
58946                 }
58947                 sma->sem_otime = get_seconds();
58948 diff -Nru a/ipc/shm.c b/ipc/shm.c
58949 --- a/ipc/shm.c Thu Jul 10 22:22:59 2003
58950 +++ b/ipc/shm.c Thu Aug 28 10:08:22 2003
58951 @@ -89,7 +89,7 @@
58952         if(!(shp = shm_lock(id)))
58953                 BUG();
58954         shp->shm_atim = get_seconds();
58955 -       shp->shm_lprid = current->pid;
58956 +       shp->shm_lprid = current->tgid;
58957         shp->shm_nattch++;
58958         shm_unlock(shp);
58959  }
58960 @@ -136,7 +136,7 @@
58961         /* remove from the list of attaches of the shm segment */
58962         if(!(shp = shm_lock(id)))
58963                 BUG();
58964 -       shp->shm_lprid = current->pid;
58965 +       shp->shm_lprid = current->tgid;
58966         shp->shm_dtim = get_seconds();
58967         shp->shm_nattch--;
58968         if(shp->shm_nattch == 0 &&
58969 @@ -209,7 +209,7 @@
58970         if(id == -1) 
58971                 goto no_id;
58972  
58973 -       shp->shm_cprid = current->pid;
58974 +       shp->shm_cprid = current->tgid;
58975         shp->shm_lprid = 0;
58976         shp->shm_atim = shp->shm_dtim = 0;
58977         shp->shm_ctim = get_seconds();
58978 diff -Nru a/ipc/util.c b/ipc/util.c
58979 --- a/ipc/util.c        Tue Jul  1 06:04:38 2003
58980 +++ b/ipc/util.c        Sun Aug 31 16:14:46 2003
58981 @@ -36,13 +36,14 @@
58982   *     memory are initialised
58983   */
58984   
58985 -void __init ipc_init (void)
58986 +static int __init ipc_init(void)
58987  {
58988         sem_init();
58989         msg_init();
58990         shm_init();
58991 -       return;
58992 +       return 0;
58993  }
58994 +__initcall(ipc_init);
58995  
58996  /**
58997   *     ipc_init_ids            -       initialise IPC identifiers
58998 diff -Nru a/kernel/Makefile b/kernel/Makefile
58999 --- a/kernel/Makefile   Wed Aug  6 13:59:24 2003
59000 +++ b/kernel/Makefile   Sun Aug 31 16:13:58 2003
59001 @@ -20,9 +20,6 @@
59002  obj-$(CONFIG_COMPAT) += compat.o
59003  obj-$(CONFIG_IKCONFIG) += configs.o
59004  
59005 -# files to be removed upon make clean
59006 -clean-files := ikconfig.h
59007 -
59008  ifneq ($(CONFIG_IA64),y)
59009  # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
59010  # needed for x86 only.  Why this used to be enabled for all architectures is beyond
59011 @@ -32,8 +29,12 @@
59012  CFLAGS_sched.o := $(PROFILING) -fno-omit-frame-pointer
59013  endif
59014  
59015 -$(obj)/ikconfig.h: scripts/mkconfigs .config Makefile
59016 -       $(CONFIG_SHELL) scripts/mkconfigs .config Makefile > $(obj)/ikconfig.h
59017 +quiet_cmd_ikconfig = IKCFG   $@
59018 +      cmd_ikconfig = $(CONFIG_SHELL) $< .config $(srctree)/Makefile > $@
59019 +
59020 +targets += ikconfig.h
59021 +
59022 +$(obj)/ikconfig.h: scripts/mkconfigs .config Makefile FORCE
59023 +       $(call if_changed,ikconfig)
59024  
59025 -$(obj)/configs.o: $(obj)/ikconfig.h $(obj)/configs.c \
59026 -               include/linux/version.h include/linux/compile.h
59027 +$(obj)/configs.o: $(obj)/ikconfig.h
59028 diff -Nru a/kernel/compat.c b/kernel/compat.c
59029 --- a/kernel/compat.c   Sat Aug  9 07:50:24 2003
59030 +++ b/kernel/compat.c   Wed Aug 27 23:55:00 2003
59031 @@ -464,6 +464,7 @@
59032         if (get_compat_itimerspec(&newts, new))
59033                 return -EFAULT; 
59034         oldfs = get_fs();
59035 +       set_fs(KERNEL_DS);
59036         err = sys_timer_settime(timer_id, flags, &newts, &oldts);
59037         set_fs(oldfs); 
59038         if (!err && old && put_compat_itimerspec(old, &oldts))
59039 @@ -477,6 +478,7 @@
59040         mm_segment_t oldfs;
59041         struct itimerspec ts; 
59042         oldfs = get_fs();
59043 +       set_fs(KERNEL_DS);
59044         err = sys_timer_gettime(timer_id, &ts); 
59045         set_fs(oldfs); 
59046         if (!err && put_compat_itimerspec(setting, &ts))
59047 @@ -494,7 +496,8 @@
59048         struct timespec ts; 
59049         if (get_compat_timespec(&ts, tp))
59050                 return -EFAULT; 
59051 -       oldfs = get_fs(); 
59052 +       oldfs = get_fs();
59053 +       set_fs(KERNEL_DS);      
59054         err = sys_clock_settime(which_clock, &ts); 
59055         set_fs(oldfs);
59056         return err;
59057 @@ -508,7 +511,8 @@
59058         long err;
59059         mm_segment_t oldfs;
59060         struct timespec ts; 
59061 -       oldfs = get_fs(); 
59062 +       oldfs = get_fs();
59063 +       set_fs(KERNEL_DS);
59064         err = sys_clock_gettime(which_clock, &ts); 
59065         set_fs(oldfs);
59066         if (!err && put_compat_timespec(&ts, tp))
59067 @@ -524,7 +528,8 @@
59068         long err;
59069         mm_segment_t oldfs;
59070         struct timespec ts; 
59071 -       oldfs = get_fs(); 
59072 +       oldfs = get_fs();
59073 +       set_fs(KERNEL_DS);
59074         err = sys_clock_getres(which_clock, &ts); 
59075         set_fs(oldfs);
59076         if (!err && put_compat_timespec(&ts, tp))
59077 @@ -546,7 +551,8 @@
59078         struct timespec in, out; 
59079         if (get_compat_timespec(&in, rqtp)) 
59080                 return -EFAULT;
59081 -       oldfs = get_fs(); 
59082 +       oldfs = get_fs();
59083 +       set_fs(KERNEL_DS);      
59084         err = sys_clock_nanosleep(which_clock, flags, &in, &out);  
59085         set_fs(oldfs);
59086         if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
59087 diff -Nru a/kernel/exit.c b/kernel/exit.c
59088 --- a/kernel/exit.c     Tue Aug  5 23:04:02 2003
59089 +++ b/kernel/exit.c     Sun Aug 31 16:14:26 2003
59090 @@ -80,6 +80,8 @@
59091         p->parent->cmin_flt += p->min_flt + p->cmin_flt;
59092         p->parent->cmaj_flt += p->maj_flt + p->cmaj_flt;
59093         p->parent->cnswap += p->nswap + p->cnswap;
59094 +       p->parent->cnvcsw += p->nvcsw + p->cnvcsw;
59095 +       p->parent->cnivcsw += p->nivcsw + p->cnivcsw;
59096         sched_exit(p);
59097         write_unlock_irq(&tasklist_lock);
59098         spin_unlock(&p->proc_lock);
59099 diff -Nru a/kernel/fork.c b/kernel/fork.c
59100 --- a/kernel/fork.c     Wed Aug 20 22:32:07 2003
59101 +++ b/kernel/fork.c     Sun Aug 31 16:14:26 2003
59102 @@ -461,6 +461,7 @@
59103         tsk->min_flt = tsk->maj_flt = 0;
59104         tsk->cmin_flt = tsk->cmaj_flt = 0;
59105         tsk->nswap = tsk->cnswap = 0;
59106 +       tsk->nvcsw = tsk->nivcsw = tsk->cnvcsw = tsk->cnivcsw = 0;
59107  
59108         tsk->mm = NULL;
59109         tsk->active_mm = NULL;
59110 diff -Nru a/kernel/futex.c b/kernel/futex.c
59111 --- a/kernel/futex.c    Sun May 25 20:39:28 2003
59112 +++ b/kernel/futex.c    Sun Aug 31 16:14:42 2003
59113 @@ -28,6 +28,7 @@
59114   */
59115  #include <linux/slab.h>
59116  #include <linux/poll.h>
59117 +#include <linux/fs.h>
59118  #include <linux/file.h>
59119  #include <linux/hash.h>
59120  #include <linux/init.h>
59121 @@ -60,8 +61,6 @@
59122  /* The key for the hash is the address + index + offset within page */
59123  static struct list_head futex_queues[1<<FUTEX_HASHBITS];
59124  static spinlock_t futex_lock = SPIN_LOCK_UNLOCKED;
59125 -
59126 -extern void send_sigio(struct fown_struct *fown, int fd, int band);
59127  
59128  /* Futex-fs vfsmount entry: */
59129  static struct vfsmount *futex_mnt;
59130 diff -Nru a/kernel/kallsyms.c b/kernel/kallsyms.c
59131 --- a/kernel/kallsyms.c Tue Aug 19 04:58:04 2003
59132 +++ b/kernel/kallsyms.c Sun Aug 31 16:14:13 2003
59133 @@ -189,9 +189,11 @@
59134         if (pos < iter->pos)
59135                 reset_iter(iter);
59136  
59137 -       /* We need to iterate through the previous symbols. */
59138 -       for (; iter->pos <= pos; iter->pos++)
59139 +       /* We need to iterate through the previous symbols: can be slow */
59140 +       for (; iter->pos != pos; iter->pos++) {
59141                 get_ksymbol_core(iter);
59142 +               cond_resched();
59143 +       }
59144         return 1;
59145  }
59146  
59147 @@ -280,8 +282,7 @@
59148  {
59149         struct proc_dir_entry *entry;
59150  
59151 -       /* root-only: could chew up lots of cpu by read, seek back, read... */
59152 -       entry = create_proc_entry("kallsyms", 0400, NULL);
59153 +       entry = create_proc_entry("kallsyms", 0444, NULL);
59154         if (entry)
59155                 entry->proc_fops = &kallsyms_operations;
59156         return 0;
59157 diff -Nru a/kernel/ksyms.c b/kernel/ksyms.c
59158 --- a/kernel/ksyms.c    Tue Aug 19 09:33:08 2003
59159 +++ b/kernel/ksyms.c    Thu Aug 28 00:36:28 2003
59160 @@ -120,7 +120,6 @@
59161  EXPORT_SYMBOL(max_mapnr);
59162  #endif
59163  EXPORT_SYMBOL(high_memory);
59164 -EXPORT_SYMBOL_GPL(invalidate_mmap_range);
59165  EXPORT_SYMBOL(vmtruncate);
59166  EXPORT_SYMBOL(find_vma);
59167  EXPORT_SYMBOL(get_unmapped_area);
59168 @@ -198,7 +197,6 @@
59169  EXPORT_SYMBOL(invalidate_inode_pages);
59170  EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
59171  EXPORT_SYMBOL(truncate_inode_pages);
59172 -EXPORT_SYMBOL(install_page);
59173  EXPORT_SYMBOL(fsync_bdev);
59174  EXPORT_SYMBOL(permission);
59175  EXPORT_SYMBOL(vfs_permission);
59176 diff -Nru a/kernel/posix-timers.c b/kernel/posix-timers.c
59177 --- a/kernel/posix-timers.c     Sat Jun 14 16:15:58 2003
59178 +++ b/kernel/posix-timers.c     Sat Aug 30 22:24:41 2003
59179 @@ -948,11 +948,15 @@
59180   */
59181  static int do_posix_gettime(struct k_clock *clock, struct timespec *tp)
59182  {
59183 +       struct timeval tv;
59184 +
59185         if (clock->clock_get)
59186                 return clock->clock_get(tp);
59187  
59188 -       do_gettimeofday((struct timeval *) tp);
59189 -       tp->tv_nsec *= NSEC_PER_USEC;
59190 +       do_gettimeofday(&tv);
59191 +       tp->tv_sec = tv.tv_sec;
59192 +       tp->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
59193 +
59194         return 0;
59195  }
59196  
59197 diff -Nru a/kernel/sched.c b/kernel/sched.c
59198 --- a/kernel/sched.c    Mon Aug 18 19:46:23 2003
59199 +++ b/kernel/sched.c    Sun Aug 31 16:14:26 2003
59200 @@ -1325,8 +1325,10 @@
59201                 }
59202         default:
59203                 deactivate_task(prev, rq);
59204 +               prev->nvcsw++;
59205 +               break;
59206         case TASK_RUNNING:
59207 -               ;
59208 +               prev->nivcsw++;
59209         }
59210  pick_next_task:
59211         if (unlikely(!rq->nr_running)) {
59212 diff -Nru a/kernel/sys.c b/kernel/sys.c
59213 --- a/kernel/sys.c      Tue Aug 19 21:53:11 2003
59214 +++ b/kernel/sys.c      Sun Aug 31 16:14:26 2003
59215 @@ -1309,6 +1309,8 @@
59216                 case RUSAGE_SELF:
59217                         jiffies_to_timeval(p->utime, &r.ru_utime);
59218                         jiffies_to_timeval(p->stime, &r.ru_stime);
59219 +                       r.ru_nvcsw = p->nvcsw;
59220 +                       r.ru_nivcsw = p->nivcsw;
59221                         r.ru_minflt = p->min_flt;
59222                         r.ru_majflt = p->maj_flt;
59223                         r.ru_nswap = p->nswap;
59224 @@ -1316,6 +1318,8 @@
59225                 case RUSAGE_CHILDREN:
59226                         jiffies_to_timeval(p->cutime, &r.ru_utime);
59227                         jiffies_to_timeval(p->cstime, &r.ru_stime);
59228 +                       r.ru_nvcsw = p->cnvcsw;
59229 +                       r.ru_nivcsw = p->cnivcsw;
59230                         r.ru_minflt = p->cmin_flt;
59231                         r.ru_majflt = p->cmaj_flt;
59232                         r.ru_nswap = p->cnswap;
59233 @@ -1323,6 +1327,8 @@
59234                 default:
59235                         jiffies_to_timeval(p->utime + p->cutime, &r.ru_utime);
59236                         jiffies_to_timeval(p->stime + p->cstime, &r.ru_stime);
59237 +                       r.ru_nvcsw = p->nvcsw + p->cnvcsw;
59238 +                       r.ru_nivcsw = p->nivcsw + p->cnivcsw;
59239                         r.ru_minflt = p->min_flt + p->cmin_flt;
59240                         r.ru_majflt = p->maj_flt + p->cmaj_flt;
59241                         r.ru_nswap = p->nswap + p->cnswap;
59242 diff -Nru a/kernel/timer.c b/kernel/timer.c
59243 --- a/kernel/timer.c    Thu Aug 14 17:00:00 2003
59244 +++ b/kernel/timer.c    Tue Sep  2 00:05:52 2003
59245 @@ -338,6 +338,7 @@
59246                         break;
59247                 }
59248         }
59249 +       smp_rmb();
59250         if (timer_pending(timer))
59251                 goto del_again;
59252  
59253 diff -Nru a/mm/fremap.c b/mm/fremap.c
59254 --- a/mm/fremap.c       Sun May 25 14:08:24 2003
59255 +++ b/mm/fremap.c       Thu Aug 28 00:38:39 2003
59256 @@ -3,7 +3,7 @@
59257   * 
59258   * Explicit pagetable population and nonlinear (random) mappings support.
59259   *
59260 - * started by Ingo Molnar, Copyright (C) 2002
59261 + * started by Ingo Molnar, Copyright (C) 2002, 2003
59262   */
59263  
59264  #include <linux/mm.h>
59265 @@ -13,6 +13,8 @@
59266  #include <linux/pagemap.h>
59267  #include <linux/swapops.h>
59268  #include <linux/rmap-locking.h>
59269 +#include <linux/module.h>
59270 +
59271  #include <asm/mmu_context.h>
59272  #include <asm/cacheflush.h>
59273  #include <asm/tlbflush.h>
59274 @@ -95,6 +97,8 @@
59275  err:
59276         return err;
59277  }
59278 +EXPORT_SYMBOL(install_page);
59279 +
59280  
59281  /***
59282   * sys_remap_file_pages - remap arbitrary pages of a shared backing store
59283 diff -Nru a/mm/memory.c b/mm/memory.c
59284 --- a/mm/memory.c       Thu Aug 14 18:17:40 2003
59285 +++ b/mm/memory.c       Sun Aug 31 16:14:24 2003
59286 @@ -45,6 +45,7 @@
59287  #include <linux/pagemap.h>
59288  #include <linux/vcache.h>
59289  #include <linux/rmap-locking.h>
59290 +#include <linux/module.h>
59291  
59292  #include <asm/pgalloc.h>
59293  #include <asm/rmap.h>
59294 @@ -810,17 +811,18 @@
59295  static inline int zeromap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address,
59296                                      unsigned long size, pgprot_t prot)
59297  {
59298 -       unsigned long end;
59299 +       unsigned long base, end;
59300  
59301 +       base = address & PGDIR_MASK;
59302         address &= ~PGDIR_MASK;
59303         end = address + size;
59304         if (end > PGDIR_SIZE)
59305                 end = PGDIR_SIZE;
59306         do {
59307 -               pte_t * pte = pte_alloc_map(mm, pmd, address);
59308 +               pte_t * pte = pte_alloc_map(mm, pmd, base + address);
59309                 if (!pte)
59310                         return -ENOMEM;
59311 -               zeromap_pte_range(pte, address, end - address, prot);
59312 +               zeromap_pte_range(pte, base + address, end - address, prot);
59313                 pte_unmap(pte);
59314                 address = (address + PMD_SIZE) & PMD_MASK;
59315                 pmd++;
59316 @@ -1138,6 +1140,7 @@
59317                 invalidate_mmap_range_list(&mapping->i_mmap_shared, hba, hlen);
59318         up(&mapping->i_shared_sem);
59319  }
59320 +EXPORT_SYMBOL_GPL(invalidate_mmap_range);
59321  
59322  /*
59323   * Handle all mappings that got truncated by a "truncate()"
59324 @@ -1384,10 +1387,10 @@
59325         unsigned long address, int write_access, pte_t *page_table, pmd_t *pmd)
59326  {
59327         struct page * new_page;
59328 -       struct address_space *mapping;
59329 +       struct address_space *mapping = NULL;
59330         pte_t entry;
59331         struct pte_chain *pte_chain;
59332 -       int sequence;
59333 +       int sequence = 0;
59334         int ret;
59335  
59336         if (!vma->vm_ops || !vma->vm_ops->nopage)
59337 @@ -1396,8 +1399,10 @@
59338         pte_unmap(page_table);
59339         spin_unlock(&mm->page_table_lock);
59340  
59341 -       mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
59342 -       sequence = atomic_read(&mapping->truncate_count);
59343 +       if (vma->vm_file) {
59344 +               mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
59345 +               sequence = atomic_read(&mapping->truncate_count);
59346 +       }
59347         smp_rmb();  /* Prevent CPU from reordering lock-free ->nopage() */
59348  retry:
59349         new_page = vma->vm_ops->nopage(vma, address & PAGE_MASK, 0);
59350 @@ -1433,7 +1438,8 @@
59351          * invalidated this page.  If invalidate_mmap_range got called,
59352          * retry getting the page.
59353          */
59354 -       if (unlikely(sequence != atomic_read(&mapping->truncate_count))) {
59355 +       if (mapping &&
59356 +             (unlikely(sequence != atomic_read(&mapping->truncate_count)))) {
59357                 sequence = atomic_read(&mapping->truncate_count);
59358                 spin_unlock(&mm->page_table_lock);
59359                 page_cache_release(new_page);
59360 @@ -1453,7 +1459,8 @@
59361          */
59362         /* Only go through if we didn't race with anybody else... */
59363         if (pte_none(*page_table)) {
59364 -               ++mm->rss;
59365 +               if (!PageReserved(new_page))
59366 +                       ++mm->rss;
59367                 flush_icache_page(vma, new_page);
59368                 entry = mk_pte(new_page, vma->vm_page_prot);
59369                 if (write_access)
59370 diff -Nru a/mm/swapfile.c b/mm/swapfile.c
59371 --- a/mm/swapfile.c     Thu Jul 31 16:52:11 2003
59372 +++ b/mm/swapfile.c     Sun Aug 31 16:15:45 2003
59373 @@ -1403,7 +1403,8 @@
59374         p->max = maxpages;
59375         p->pages = nr_good_pages;
59376  
59377 -       if (setup_swap_extents(p))
59378 +       error = setup_swap_extents(p);
59379 +       if (error)
59380                 goto bad_swap;
59381  
59382         swap_list_lock();
59383 diff -Nru a/mm/vmscan.c b/mm/vmscan.c
59384 --- a/mm/vmscan.c       Thu Aug 21 11:57:48 2003
59385 +++ b/mm/vmscan.c       Sun Aug 31 16:14:47 2003
59386 @@ -80,25 +80,6 @@
59387  #endif
59388  
59389  /*
59390 - * exponentially decaying average
59391 - */
59392 -static inline int expavg(int avg, int val)
59393 -{
59394 -       return ((val - avg) >> 1) + avg;
59395 -}
59396 -
59397 -static void zone_adj_pressure(struct zone *zone, int priority)
59398 -{
59399 -       zone->pressure = expavg(zone->pressure,
59400 -                       (DEF_PRIORITY - priority) << 10);
59401 -}
59402 -
59403 -static int pressure_to_priority(int pressure)
59404 -{
59405 -       return DEF_PRIORITY - (pressure >> 10);
59406 -}
59407 -
59408 -/*
59409   * The list of shrinker callbacks used by to apply pressure to
59410   * ageable caches.
59411   */
59412 @@ -646,7 +627,7 @@
59413          * `distress' is a measure of how much trouble we're having reclaiming
59414          * pages.  0 -> no problems.  100 -> great trouble.
59415          */
59416 -       distress = 100 >> pressure_to_priority(zone->pressure);
59417 +       distress = 100 >> zone->prev_priority;
59418  
59419         /*
59420          * The point of this algorithm is to decide when to start reclaiming
59421 @@ -830,6 +811,9 @@
59422                 int nr_mapped = 0;
59423                 int max_scan;
59424  
59425 +               if (zone->free_pages < zone->pages_high)
59426 +                       zone->temp_priority = priority;
59427 +
59428                 if (zone->all_unreclaimable && priority != DEF_PRIORITY)
59429                         continue;       /* Let kswapd poll it */
59430  
59431 @@ -843,10 +827,8 @@
59432                 ret += shrink_zone(zone, max_scan, gfp_mask,
59433                                 to_reclaim, &nr_mapped, ps, priority);
59434                 *total_scanned += max_scan + nr_mapped;
59435 -               if (ret >= nr_pages) {
59436 -                       zone_adj_pressure(zone, priority);
59437 +               if (ret >= nr_pages)
59438                         break;
59439 -               }
59440         }
59441         return ret;
59442  }
59443 @@ -880,6 +862,9 @@
59444  
59445         inc_page_state(allocstall);
59446  
59447 +       for (zone = cz; zone >= cz->zone_pgdat->node_zones; --zone)
59448 +               zone->temp_priority = DEF_PRIORITY;
59449 +
59450         for (priority = DEF_PRIORITY; priority >= 0; priority--) {
59451                 int total_scanned = 0;
59452                 struct page_state ps;
59453 @@ -912,9 +897,9 @@
59454         }
59455         if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY))
59456                 out_of_memory();
59457 -       for (zone = cz; zone >= cz->zone_pgdat->node_zones; -- zone)
59458 -               zone_adj_pressure(zone, -1);
59459  out:
59460 +       for (zone = cz; zone >= cz->zone_pgdat->node_zones; --zone)
59461 +               zone->prev_priority = zone->temp_priority;
59462         return ret;
59463  }
59464  
59465 @@ -945,6 +930,12 @@
59466  
59467         inc_page_state(pageoutrun);
59468  
59469 +       for (i = 0; i < pgdat->nr_zones; i++) {
59470 +               struct zone *zone = pgdat->node_zones + i;
59471 +
59472 +               zone->temp_priority = DEF_PRIORITY;
59473 +       }
59474 +
59475         for (priority = DEF_PRIORITY; priority; priority--) {
59476                 int all_zones_ok = 1;
59477  
59478 @@ -961,11 +952,10 @@
59479                                 to_reclaim = min(to_free, SWAP_CLUSTER_MAX*8);
59480                         } else {                        /* Zone balancing */
59481                                 to_reclaim = zone->pages_high-zone->free_pages;
59482 -                               if (to_reclaim <= 0) {
59483 -                                       zone_adj_pressure(zone, priority);
59484 +                               if (to_reclaim <= 0)
59485                                         continue;
59486 -                               }
59487                         }
59488 +                       zone->temp_priority = priority;
59489                         all_zones_ok = 0;
59490                         max_scan = zone->nr_inactive >> priority;
59491                         if (max_scan < to_reclaim * 2)
59492 @@ -989,13 +979,11 @@
59493                 if (to_free > 0)
59494                         blk_congestion_wait(WRITE, HZ/10);
59495         }
59496 -       if (priority < 0) {
59497 -               for (i = 0; i < pgdat->nr_zones; i++) {
59498 -                       struct zone *zone = pgdat->node_zones + i;
59499  
59500 -                       if (zone->free_pages < zone->pages_high)
59501 -                               zone_adj_pressure(zone, -1);
59502 -               }
59503 +       for (i = 0; i < pgdat->nr_zones; i++) {
59504 +               struct zone *zone = pgdat->node_zones + i;
59505 +
59506 +               zone->prev_priority = zone->temp_priority;
59507         }
59508         return nr_pages - to_free;
59509  }
59510 diff -Nru a/net/Kconfig b/net/Kconfig
59511 --- a/net/Kconfig       Tue Aug 19 21:12:36 2003
59512 +++ b/net/Kconfig       Mon Sep  1 01:44:26 2003
59513 @@ -191,9 +191,11 @@
59514           information.
59515  
59516           If you enable iptables support along with the bridge support then you
59517 -         turn your bridge into a bridging firewall.
59518 +         turn your bridge into a bridging IP firewall.
59519           iptables will then see the IP packets being bridged, so you need to
59520           take this into account when setting up your firewall rules.
59521 +         Enabling arptables support when bridging will let arptables see
59522 +         bridged ARP traffic in the arptables FORWARD chain.
59523  
59524           If you want to compile this code as a module ( = code which can be
59525           inserted in and removed from the running kernel whenever you want),
59526 @@ -243,6 +245,12 @@
59527           box can transparently forward the traffic to a local server,
59528           typically a caching proxy server.
59529  
59530 +         Yet another use of Netfilter is building a bridging firewall. Using
59531 +         a bridge with Network packet filtering enabled makes iptables "see"
59532 +         the bridged traffic. For filtering on the lower network and Ethernet
59533 +         protocols over the bridge, use ebtables (under bridge netfilter
59534 +         configuration).
59535 +
59536           Various modules exist for netfilter which replace the previous
59537           masquerading (ipmasqadm), packet filtering (ipchains), transparent
59538           proxying, and portforwarding mechanisms. Please see
59539 @@ -263,6 +271,19 @@
59540         help
59541           You can say Y here if you want to get additional messages useful in
59542           debugging the netfilter code.
59543 +
59544 +config BRIDGE_NETFILTER
59545 +       bool "Bridged IP/ARP packets filtering"
59546 +       depends on BRIDGE && NETFILTER && INET
59547 +       default y
59548 +       ---help---
59549 +         Enabling this option will let arptables resp. iptables see bridged
59550 +         ARP resp. IP traffic. If you want a bridging firewall, you probably
59551 +         want this option enabled.
59552 +         Enabling or disabling this option doesn't enable or disable
59553 +         ebtables.
59554 +
59555 +         If unsure, say N.
59556  
59557  source "net/ipv4/netfilter/Kconfig"
59558  source "net/ipv6/netfilter/Kconfig"
59559 diff -Nru a/net/appletalk/aarp.c b/net/appletalk/aarp.c
59560 --- a/net/appletalk/aarp.c      Wed Jun  4 17:57:07 2003
59561 +++ b/net/appletalk/aarp.c      Sat Aug 30 19:27:36 2003
59562 @@ -37,6 +37,7 @@
59563  #include <linux/atalk.h>
59564  #include <linux/init.h>
59565  #include <linux/proc_fs.h>
59566 +#include <linux/seq_file.h>
59567  
59568  int sysctl_aarp_expiry_time = AARP_EXPIRY_TIME;
59569  int sysctl_aarp_tick_time = AARP_TICK_TIME;
59570 @@ -145,6 +146,7 @@
59571         aarp_dl->request(aarp_dl, skb, aarp_eth_multicast);
59572         /* Update the sending count */
59573         a->xmit_count++;
59574 +       a->last_sent = jiffies;
59575  }
59576  
59577  /* This runs under aarp_lock and in softint context, so only atomic memory
59578 @@ -338,6 +340,32 @@
59579         return NOTIFY_DONE;
59580  }
59581  
59582 +/* Expire all entries in a hash chain */
59583 +static void __aarp_expire_all(struct aarp_entry **n)
59584 +{
59585 +       struct aarp_entry *t;
59586 +
59587 +       while (*n) {
59588 +               t = *n;
59589 +               *n = (*n)->next;
59590 +               __aarp_expire(t);
59591 +       }
59592 +}
59593 +
59594 +/* Cleanup all hash chains -- module unloading */
59595 +static void aarp_purge(void)
59596 +{
59597 +       int ct;
59598 +
59599 +       write_lock_bh(&aarp_lock);
59600 +       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
59601 +               __aarp_expire_all(&resolved[ct]);
59602 +               __aarp_expire_all(&unresolved[ct]);
59603 +               __aarp_expire_all(&proxies[ct]);
59604 +       }
59605 +       write_unlock_bh(&aarp_lock);
59606 +}
59607 +
59608  /*
59609   *     Create a new aarp entry.  This must use GFP_ATOMIC because it
59610   *     runs while holding spinlocks.
59611 @@ -861,112 +889,181 @@
59612         write_unlock_bh(&aarp_lock);
59613  }
59614  
59615 -/* Called from proc fs */
59616 -static int aarp_get_info(char *buffer, char **start, off_t offset, int length)
59617 +#ifdef CONFIG_PROC_FS
59618 +struct aarp_iter_state {
59619 +       int bucket;
59620 +       struct aarp_entry **table;
59621 +};
59622 +
59623 +/*
59624 + * Get the aarp entry that is in the chain described
59625 + * by the iterator. 
59626 + * If pos is set then skip till that index.
59627 + * pos = 1 is the first entry
59628 + */
59629 +static struct aarp_entry *iter_next(struct aarp_iter_state *iter, loff_t *pos)
59630  {
59631 -       /* we should dump all our AARP entries */
59632 +       int ct = iter->bucket;
59633 +       struct aarp_entry **table = iter->table;
59634 +       loff_t off = 0;
59635         struct aarp_entry *entry;
59636 -       int ct, len = sprintf(buffer,
59637 -                             "%-10.10s  %-10.10s%-18.18s%12.12s%12.12s "
59638 -                             "xmit_count  status\n",
59639 -                             "address", "device", "hw addr", "last_sent",
59640 -                             "expires");
59641 +       
59642 + rescan:
59643 +       while(ct < AARP_HASH_SIZE) {
59644 +               for (entry = table[ct]; entry; entry = entry->next) {
59645 +                       if (!pos || ++off == *pos) {
59646 +                               iter->table = table;
59647 +                               iter->bucket = ct;
59648 +                               return entry;
59649 +                       }
59650 +               }
59651 +               ++ct;
59652 +       }
59653 +
59654 +       if (table == resolved) {
59655 +               ct = 0;
59656 +               table = unresolved;
59657 +               goto rescan;
59658 +       }
59659 +       if (table == unresolved) {
59660 +               ct = 0;
59661 +               table = proxies;
59662 +               goto rescan;
59663 +       }
59664 +       return NULL;
59665 +}
59666 +
59667 +static void *aarp_seq_start(struct seq_file *seq, loff_t *pos)
59668 +{
59669 +       struct aarp_iter_state *iter = seq->private;
59670  
59671         read_lock_bh(&aarp_lock);
59672 +       iter->table     = resolved;
59673 +       iter->bucket    = 0;
59674  
59675 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
59676 -               for (entry = resolved[ct]; entry; entry = entry->next) {
59677 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
59678 -                               (unsigned int)ntohs(entry->target_addr.s_net),
59679 -                               (unsigned int)(entry->target_addr.s_node));
59680 -                       len += sprintf(buffer + len, "%-10.10s",
59681 -                                      entry->dev->name);
59682 -                       len += sprintf(buffer + len,
59683 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
59684 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
59685 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
59686 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
59687 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
59688 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
59689 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
59690 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
59691 -                                      (unsigned long)entry->last_sent,
59692 -                                      (unsigned long)entry->expires_at);
59693 -                       len += sprintf(buffer + len, "%10u",
59694 -                                      (unsigned int)entry->xmit_count);
59695 +       return *pos ? iter_next(iter, pos) : ((void *)1);
59696 +}
59697  
59698 -                       len += sprintf(buffer + len, "   resolved\n");
59699 -               }
59700 -       }
59701 +static void *aarp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
59702 +{
59703 +       struct aarp_entry *entry = v;
59704 +       struct aarp_iter_state *iter = seq->private;
59705  
59706 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
59707 -               for (entry = unresolved[ct]; entry; entry = entry->next) {
59708 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
59709 -                               (unsigned int)ntohs(entry->target_addr.s_net),
59710 -                               (unsigned int)(entry->target_addr.s_node));
59711 -                       len += sprintf(buffer + len, "%-10.10s",
59712 -                                      entry->dev->name);
59713 -                       len += sprintf(buffer + len,
59714 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
59715 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
59716 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
59717 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
59718 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
59719 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
59720 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
59721 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
59722 -                                      (unsigned long)entry->last_sent,
59723 -                                      (unsigned long)entry->expires_at);
59724 -                       len += sprintf(buffer + len, "%10u",
59725 -                                      (unsigned int)entry->xmit_count);
59726 -                       len += sprintf(buffer + len, " unresolved\n");
59727 -               }
59728 -       }
59729 +       ++*pos;
59730  
59731 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
59732 -               for (entry = proxies[ct]; entry; entry = entry->next) {
59733 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
59734 -                               (unsigned int)ntohs(entry->target_addr.s_net),
59735 -                               (unsigned int)(entry->target_addr.s_node));
59736 -                       len += sprintf(buffer + len, "%-10.10s",
59737 -                                      entry->dev->name);
59738 -                       len += sprintf(buffer + len,
59739 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
59740 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
59741 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
59742 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
59743 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
59744 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
59745 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
59746 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
59747 -                                      (unsigned long)entry->last_sent,
59748 -                                      (unsigned long)entry->expires_at);
59749 -                       len += sprintf(buffer + len, "%10u",
59750 -                                      (unsigned int)entry->xmit_count);
59751 -                       len += sprintf(buffer + len, "      proxy\n");
59752 -               }
59753 +       /* first line after header */
59754 +       if (v == ((void *)1)) 
59755 +               entry = iter_next(iter, NULL);
59756 +               
59757 +       /* next entry in current bucket */
59758 +       else if (entry->next)
59759 +               entry = entry->next;
59760 +
59761 +       /* next bucket or table */
59762 +       else {
59763 +               ++iter->bucket;
59764 +               entry = iter_next(iter, NULL);
59765         }
59766 +       return entry;
59767 +}
59768  
59769 +static void aarp_seq_stop(struct seq_file *seq, void *v)
59770 +{
59771         read_unlock_bh(&aarp_lock);
59772 -       return len;
59773  }
59774  
59775 -/* General module cleanup. Called from cleanup_module() in ddp.c. */
59776 -void aarp_cleanup_module(void)
59777 +static const char *dt2str(unsigned long ticks)
59778  {
59779 -       del_timer(&aarp_timer);
59780 -       unregister_netdevice_notifier(&aarp_notifier);
59781 -       unregister_snap_client(aarp_dl);
59782 +       static char buf[32];
59783 +
59784 +       sprintf(buf, "%ld.%02ld", ticks / HZ, ((ticks % HZ) * 100 ) / HZ);
59785 +
59786 +       return buf;
59787  }
59788  
59789 -#ifdef CONFIG_PROC_FS
59790 -void aarp_register_proc_fs(void)
59791 +static int aarp_seq_show(struct seq_file *seq, void *v)
59792  {
59793 -       proc_net_create("aarp", 0, aarp_get_info);
59794 +       struct aarp_iter_state *iter = seq->private;
59795 +       struct aarp_entry *entry = v;
59796 +       unsigned long now = jiffies;
59797 +
59798 +       if (v == ((void *)1))
59799 +               seq_puts(seq, 
59800 +                        "Address  Interface   Hardware Address"
59801 +                        "   Expires LastSend  Retry Status\n");
59802 +       else {
59803 +               seq_printf(seq, "%04X:%02X  %-12s",
59804 +                          ntohs(entry->target_addr.s_net),
59805 +                          (unsigned int) entry->target_addr.s_node,
59806 +                          entry->dev ? entry->dev->name : "????");
59807 +               seq_printf(seq, "%02X:%02X:%02X:%02X:%02X:%02X",
59808 +                          entry->hwaddr[0] & 0xFF,
59809 +                          entry->hwaddr[1] & 0xFF,
59810 +                          entry->hwaddr[2] & 0xFF,
59811 +                          entry->hwaddr[3] & 0xFF,
59812 +                          entry->hwaddr[4] & 0xFF,
59813 +                          entry->hwaddr[5] & 0xFF);
59814 +               seq_printf(seq, " %8s",
59815 +                          dt2str((long)entry->expires_at - (long)now));
59816 +               if (iter->table == unresolved)
59817 +                       seq_printf(seq, " %8s %6hu",
59818 +                                  dt2str(now - entry->last_sent),
59819 +                                  entry->xmit_count);
59820 +               else
59821 +                       seq_puts(seq, "                ");
59822 +               seq_printf(seq, " %s\n",
59823 +                          (iter->table == resolved) ? "resolved"
59824 +                          : (iter->table == unresolved) ? "unresolved"
59825 +                          : (iter->table == proxies) ? "proxies"
59826 +                          : "unknown");
59827 +       }                                
59828 +       return 0;
59829  }
59830  
59831 -void aarp_unregister_proc_fs(void)
59832 +static struct seq_operations aarp_seq_ops = {
59833 +       .start  = aarp_seq_start,
59834 +       .next   = aarp_seq_next,
59835 +       .stop   = aarp_seq_stop,
59836 +       .show   = aarp_seq_show,
59837 +};
59838 +
59839 +static int aarp_seq_open(struct inode *inode, struct file *file)
59840  {
59841 -       proc_net_remove("aarp");
59842 +       struct seq_file *seq;
59843 +       int rc = -ENOMEM;
59844 +       struct aarp_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
59845 +       
59846 +       if (!s)
59847 +               goto out;
59848 +
59849 +       rc = seq_open(file, &aarp_seq_ops);
59850 +       if (rc)
59851 +               goto out_kfree;
59852 +
59853 +       seq          = file->private_data;
59854 +       seq->private = s;
59855 +       memset(s, 0, sizeof(*s));
59856 +out:
59857 +       return rc;
59858 +out_kfree:
59859 +       kfree(s);
59860 +       goto out;
59861  }
59862 +
59863 +struct file_operations atalk_seq_arp_fops = {
59864 +       .owner          = THIS_MODULE,
59865 +       .open           = aarp_seq_open,
59866 +       .read           = seq_read,
59867 +       .llseek         = seq_lseek,
59868 +       .release        = seq_release_private,
59869 +};
59870  #endif
59871 +
59872 +/* General module cleanup. Called from cleanup_module() in ddp.c. */
59873 +void aarp_cleanup_module(void)
59874 +{
59875 +       del_timer_sync(&aarp_timer);
59876 +       unregister_netdevice_notifier(&aarp_notifier);
59877 +       unregister_snap_client(aarp_dl);
59878 +       aarp_purge();
59879 +}
59880 diff -Nru a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
59881 --- a/net/appletalk/atalk_proc.c        Mon Jun 16 08:11:36 2003
59882 +++ b/net/appletalk/atalk_proc.c        Sat Aug 30 19:27:36 2003
59883 @@ -16,6 +16,8 @@
59884  #include <linux/atalk.h>
59885  
59886  #ifdef CONFIG_PROC_FS
59887 +extern struct file_operations atalk_seq_arp_fops;
59888 +
59889  static __inline__ struct atalk_iface *atalk_get_interface_idx(loff_t pos)
59890  {
59891         struct atalk_iface *i;
59892 @@ -61,7 +63,7 @@
59893         struct atalk_iface *iface;
59894  
59895         if (v == (void *)1) {
59896 -               seq_puts(seq, "Interface          Address   Networks   "
59897 +               seq_puts(seq, "Interface        Address   Networks  "
59898                               "Status\n");
59899                 goto out;
59900         }
59901 @@ -275,6 +277,7 @@
59902         atalk_proc_dir = proc_mkdir("atalk", proc_net);
59903         if (!atalk_proc_dir)
59904                 goto out;
59905 +       atalk_proc_dir->owner = THIS_MODULE;
59906  
59907         p = create_proc_entry("interface", S_IRUGO, atalk_proc_dir);
59908         if (!p)
59909 @@ -291,9 +294,16 @@
59910                 goto out_socket;
59911         p->proc_fops = &atalk_seq_socket_fops;
59912  
59913 +       p = create_proc_entry("arp", S_IRUGO, atalk_proc_dir);
59914 +       if (!p) 
59915 +               goto out_arp;
59916 +       p->proc_fops = &atalk_seq_arp_fops;
59917 +
59918         rc = 0;
59919  out:
59920         return rc;
59921 +out_arp:
59922 +       remove_proc_entry("socket", atalk_proc_dir);
59923  out_socket:
59924         remove_proc_entry("route", atalk_proc_dir);
59925  out_route:
59926 @@ -308,6 +318,7 @@
59927         remove_proc_entry("interface", atalk_proc_dir);
59928         remove_proc_entry("route", atalk_proc_dir);
59929         remove_proc_entry("socket", atalk_proc_dir);
59930 +       remove_proc_entry("arp", atalk_proc_dir);
59931         remove_proc_entry("atalk", proc_net);
59932  }
59933  
59934 diff -Nru a/net/appletalk/ddp.c b/net/appletalk/ddp.c
59935 --- a/net/appletalk/ddp.c       Mon Jun 16 08:11:36 2003
59936 +++ b/net/appletalk/ddp.c       Tue Sep  2 04:38:10 2003
59937 @@ -61,11 +61,6 @@
59938  #include <net/route.h>
59939  #include <linux/atalk.h>
59940  
59941 -#ifdef CONFIG_PROC_FS
59942 -extern void aarp_register_proc_fs(void);
59943 -extern void aarp_unregister_proc_fs(void);
59944 -#endif
59945 -
59946  extern void aarp_cleanup_module(void);
59947  
59948  extern void aarp_probe_network(struct atalk_iface *atif);
59949 @@ -183,13 +178,12 @@
59950  {
59951         struct sock *sk = (struct sock *)data;
59952  
59953 -       if (!atomic_read(&sk->sk_wmem_alloc) &&
59954 -           !atomic_read(&sk->sk_rmem_alloc) && sock_flag(sk, SOCK_DEAD))
59955 -               sock_put(sk);
59956 -       else {
59957 +       if (atomic_read(&sk->sk_wmem_alloc) ||
59958 +           atomic_read(&sk->sk_rmem_alloc)) {
59959                 sk->sk_timer.expires = jiffies + SOCK_DESTROY_TIME;
59960                 add_timer(&sk->sk_timer);
59961 -       }
59962 +       } else
59963 +               sock_put(sk);
59964  }
59965  
59966  static inline void atalk_destroy_socket(struct sock *sk)
59967 @@ -197,16 +191,15 @@
59968         atalk_remove_socket(sk);
59969         skb_queue_purge(&sk->sk_receive_queue);
59970  
59971 -       if (!atomic_read(&sk->sk_wmem_alloc) &&
59972 -           !atomic_read(&sk->sk_rmem_alloc) && sock_flag(sk, SOCK_DEAD))
59973 -               sock_put(sk);
59974 -       else {
59975 +       if (atomic_read(&sk->sk_wmem_alloc) ||
59976 +           atomic_read(&sk->sk_rmem_alloc)) {
59977                 init_timer(&sk->sk_timer);
59978                 sk->sk_timer.expires    = jiffies + SOCK_DESTROY_TIME;
59979                 sk->sk_timer.function   = atalk_destroy_timer;
59980                 sk->sk_timer.data       = (unsigned long)sk;
59981                 add_timer(&sk->sk_timer);
59982 -       }
59983 +       } else
59984 +               sock_put(sk);
59985  }
59986  
59987  /**************************************************************************\
59988 @@ -239,6 +232,7 @@
59989         while ((tmp = *iface) != NULL) {
59990                 if (tmp->dev == dev) {
59991                         *iface = tmp->next;
59992 +                       dev_put(dev);
59993                         kfree(tmp);
59994                         dev->atalk_ptr = NULL;
59995                 } else
59996 @@ -255,6 +249,7 @@
59997         if (!iface)
59998                 goto out;
59999  
60000 +       dev_hold(dev);
60001         iface->dev = dev;
60002         dev->atalk_ptr = iface;
60003         iface->address = *sa;
60004 @@ -616,6 +611,7 @@
60005                     (!(tmp->flags&RTF_GATEWAY) ||
60006                      tmp->target.s_node == addr->s_node)) {
60007                         *r = tmp->next;
60008 +                       dev_put(tmp->dev);
60009                         kfree(tmp);
60010                         goto out;
60011                 }
60012 @@ -640,6 +636,7 @@
60013         while ((tmp = *r) != NULL) {
60014                 if (tmp->dev == dev) {
60015                         *r = tmp->next;
60016 +                       dev_put(dev);
60017                         kfree(tmp);
60018                 } else
60019                         r = &tmp->next;
60020 @@ -935,24 +932,95 @@
60021   * Checksum: This is 'optional'. It's quite likely also a good
60022   * candidate for assembler hackery 8)
60023   */
60024 -unsigned short atalk_checksum(struct ddpehdr *ddp, int len)
60025 +static unsigned long atalk_sum_partial(const unsigned char *data, 
60026 +                                      int len, unsigned long sum)
60027  {
60028 -       unsigned long sum = 0;  /* Assume unsigned long is >16 bits */
60029 -       unsigned char *data = (unsigned char *)ddp;
60030 -
60031 -       len  -= 4;              /* skip header 4 bytes */
60032 -       data += 4;
60033 -
60034         /* This ought to be unwrapped neatly. I'll trust gcc for now */
60035         while (len--) {
60036 -               sum += *data;
60037 +               sum += *data++;
60038                 sum <<= 1;
60039 -               if (sum & 0x10000) {
60040 -                       sum++;
60041 -                       sum &= 0xFFFF;
60042 +               sum = ((sum >> 16) + sum) & 0xFFFF;
60043 +       }
60044 +       return sum;
60045 +}
60046 +
60047 +/*  Checksum skb data --  similar to skb_checksum  */
60048 +static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
60049 +                                  int len, unsigned long sum)
60050 +{
60051 +       int start = skb_headlen(skb);
60052 +       int i, copy;
60053 +
60054 +       /* checksum stuff in header space */
60055 +       if ( (copy = start - offset) > 0) {
60056 +               if (copy > len)
60057 +                       copy = len;
60058 +               sum = atalk_sum_partial(skb->data + offset, copy, sum);
60059 +               if ( (len -= copy) == 0) 
60060 +                       return sum;
60061 +
60062 +               offset += copy;
60063 +       }
60064 +
60065 +       /* checksum stuff in frags */
60066 +       for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
60067 +               int end;
60068 +
60069 +               BUG_TRAP(start <= offset + len);
60070 +
60071 +               end = start + skb_shinfo(skb)->frags[i].size;
60072 +               if ((copy = end - offset) > 0) {
60073 +                       u8 *vaddr;
60074 +                       skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
60075 +
60076 +                       if (copy > len)
60077 +                               copy = len;
60078 +                       vaddr = kmap_skb_frag(frag);
60079 +                       sum = atalk_sum_partial(vaddr + frag->page_offset +
60080 +                                                 offset - start, copy, sum);
60081 +                       kunmap_skb_frag(vaddr);
60082 +
60083 +                       if (!(len -= copy))
60084 +                               return sum;
60085 +                       offset += copy;
60086 +               }
60087 +               start = end;
60088 +       }
60089 +
60090 +       if (skb_shinfo(skb)->frag_list) {
60091 +               struct sk_buff *list = skb_shinfo(skb)->frag_list;
60092 +
60093 +               for (; list; list = list->next) {
60094 +                       int end;
60095 +
60096 +                       BUG_TRAP(start <= offset + len);
60097 +
60098 +                       end = start + list->len;
60099 +                       if ((copy = end - offset) > 0) {
60100 +                               if (copy > len)
60101 +                                       copy = len;
60102 +                               sum = atalk_sum_skb(list, offset - start,
60103 +                                                   copy, sum);
60104 +                               if ((len -= copy) == 0)
60105 +                                       return sum;
60106 +                               offset += copy;
60107 +                       }
60108 +                       start = end;
60109                 }
60110 -               data++;
60111         }
60112 +
60113 +       BUG_ON(len > 0);
60114 +
60115 +       return sum;
60116 +}
60117 +
60118 +static unsigned short atalk_checksum(const struct sk_buff *skb, int len)
60119 +{
60120 +       unsigned long sum;
60121 +
60122 +       /* skip header 4 bytes */
60123 +       sum = atalk_sum_skb(skb, 4, len-4, 0);
60124 +
60125         /* Use 0xFFFF for 0. 0 itself means none */
60126         return sum ? htons((unsigned short)sum) : 0xFFFF;
60127  }
60128 @@ -983,6 +1051,8 @@
60129         rc = 0;
60130         sock->ops = &atalk_dgram_ops;
60131         sock_init_data(sock, sk);
60132 +       sk_set_owner(sk, THIS_MODULE);
60133 +
60134         /* Checksums on by default */
60135         sk->sk_zapped = 1;
60136  out:
60137 @@ -998,10 +1068,7 @@
60138         struct sock *sk = sock->sk;
60139  
60140         if (sk) {
60141 -               if (!sock_flag(sk, SOCK_DEAD)) {
60142 -                       sk->sk_state_change(sk);
60143 -                       sock_set_flag(sk, SOCK_DEAD);
60144 -               }
60145 +               sock_orphan(sk);
60146                 sock->sk = NULL;
60147                 atalk_destroy_socket(sk);
60148         }
60149 @@ -1335,25 +1402,27 @@
60150  static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
60151                      struct packet_type *pt)
60152  {
60153 -       struct ddpehdr *ddp = ddp_hdr(skb);
60154 +       struct ddpehdr *ddp;
60155         struct sock *sock;
60156         struct atalk_iface *atif;
60157         struct sockaddr_at tosat;
60158          int origlen;
60159          struct ddpebits ddphv;
60160  
60161 -       /* Size check */
60162 -       if (skb->len < sizeof(*ddp))
60163 +       /* Don't mangle buffer if shared */
60164 +       if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 
60165 +               goto out;
60166 +               
60167 +       /* Size check and make sure header is contiguous */
60168 +       if (!pskb_may_pull(skb, sizeof(*ddp)))
60169                 goto freeit;
60170  
60171 +       ddp = ddp_hdr(skb);
60172 +
60173         /*
60174          *      Fix up the length field [Ok this is horrible but otherwise
60175          *      I end up with unions of bit fields and messy bit field order
60176          *      compiler/endian dependencies..]
60177 -        *
60178 -        *      FIXME: This is a write to a shared object. Granted it
60179 -        *      happens to be safe BUT.. (Its safe as user space will not
60180 -        *      run until we put it back)
60181          */
60182         *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp));
60183  
60184 @@ -1374,7 +1443,7 @@
60185          * valid for net byte orders all over the networking code...
60186          */
60187         if (ddp->deh_sum &&
60188 -           atalk_checksum(ddp, ddphv.deh_len) != ddp->deh_sum)
60189 +           atalk_checksum(skb, ddphv.deh_len) != ddp->deh_sum)
60190                 /* Not a valid AppleTalk frame - dustbin time */
60191                 goto freeit;
60192  
60193 @@ -1433,14 +1502,16 @@
60194  
60195                 if (!ap || skb->len < sizeof(struct ddpshdr))
60196                         goto freeit;
60197 +
60198 +               /* Don't mangle buffer if shared */
60199 +               if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 
60200 +                       return 0;
60201 +
60202                 /*
60203                  * The push leaves us with a ddephdr not an shdr, and
60204                  * handily the port bytes in the right place preset.
60205                  */
60206 -
60207 -               skb_push(skb, sizeof(*ddp) - 4);
60208 -               /* FIXME: use skb->cb to be able to use shared skbs */
60209 -               ddp = (struct ddpehdr *)skb->data;
60210 +               ddp = (struct ddpehdr *) skb_push(skb, sizeof(*ddp) - 4);
60211  
60212                 /* Now fill in the long header */
60213  
60214 @@ -1592,7 +1663,7 @@
60215         if (sk->sk_no_check == 1)
60216                 ddp->deh_sum = 0;
60217         else
60218 -               ddp->deh_sum = atalk_checksum(ddp, len + sizeof(*ddp));
60219 +               ddp->deh_sum = atalk_checksum(skb, len + sizeof(*ddp));
60220  
60221         /*
60222          * Loopback broadcast packets to non gateway targets (ie routes
60223 @@ -1801,11 +1872,13 @@
60224  struct packet_type ltalk_packet_type = {
60225         .type           = __constant_htons(ETH_P_LOCALTALK),
60226         .func           = ltalk_rcv,
60227 +       .data           = (void *)1,
60228  };
60229  
60230  struct packet_type ppptalk_packet_type = {
60231         .type           = __constant_htons(ETH_P_PPPTALK),
60232         .func           = atalk_rcv,
60233 +       .data           = (void *)1,
60234  };
60235  
60236  static unsigned char ddp_snap_id[] = { 0x08, 0x00, 0x07, 0x80, 0x9B };
60237 @@ -1834,9 +1907,6 @@
60238         register_netdevice_notifier(&ddp_notifier);
60239         aarp_proto_init();
60240         atalk_proc_init();
60241 -#ifdef CONFIG_PROC_FS
60242 -       aarp_register_proc_fs();
60243 -#endif /* CONFIG_PROC_FS */
60244         atalk_register_sysctl();
60245         printk(atalk_banner);
60246         return 0;
60247 @@ -1844,13 +1914,10 @@
60248  module_init(atalk_init);
60249  
60250  /*
60251 - * Note on MOD_{INC,DEC}_USE_COUNT:
60252 - *
60253 - * Use counts are incremented/decremented when
60254 - * sockets are created/deleted.
60255 - *
60256 - * AppleTalk interfaces are not incremented until atalkd is run
60257 - * and are only decremented when they are downed.
60258 + * No explicit module reference count manipulation is needed in the
60259 + * protocol. Socket layer sets module reference count for us
60260 + * and interfaces reference counting is done
60261 + * by the network device layer.
60262   *
60263   * Ergo, before the AppleTalk module can be removed, all AppleTalk
60264   * sockets be closed from user space.
60265 @@ -1861,9 +1928,6 @@
60266         atalk_unregister_sysctl();
60267  #endif /* CONFIG_SYSCTL */
60268         atalk_proc_exit();
60269 -#ifdef CONFIG_PROC_FS
60270 -       aarp_unregister_proc_fs();
60271 -#endif /* CONFIG_PROC_FS */
60272         aarp_cleanup_module();  /* General aarp clean-up. */
60273         unregister_netdevice_notifier(&ddp_notifier);
60274         dev_remove_pack(&ltalk_packet_type);
60275 @@ -1876,3 +1940,4 @@
60276  MODULE_LICENSE("GPL");
60277  MODULE_AUTHOR("Alan Cox <Alan.Cox@linux.org>");
60278  MODULE_DESCRIPTION("AppleTalk 0.20 for Linux NET4.0\n");
60279 +MODULE_ALIAS_NETPROTO(PF_APPLETALK);
60280 diff -Nru a/net/atm/common.c b/net/atm/common.c
60281 --- a/net/atm/common.c  Tue Aug 19 21:10:45 2003
60282 +++ b/net/atm/common.c  Tue Sep  2 04:38:10 2003
60283 @@ -279,6 +279,7 @@
60284         if (!sk)
60285                 return -ENOMEM;
60286         sock_init_data(sock, sk);
60287 +       sk_set_owner(sk, THIS_MODULE);
60288         sk->sk_state_change = vcc_def_wakeup;
60289         sk->sk_write_space = vcc_write_space;
60290  
60291 @@ -1135,3 +1136,5 @@
60292  module_exit(atm_exit);
60293  
60294  MODULE_LICENSE("GPL");
60295 +MODULE_ALIAS_NETPROTO(PF_ATMPVC);
60296 +MODULE_ALIAS_NETPROTO(PF_ATMSVC);
60297 diff -Nru a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
60298 --- a/net/ax25/af_ax25.c        Thu Aug 21 11:59:08 2003
60299 +++ b/net/ax25/af_ax25.c        Tue Sep  2 04:38:10 2003
60300 @@ -1842,81 +1842,107 @@
60301         return res;
60302  }
60303  
60304 -static int ax25_get_info(char *buffer, char **start, off_t offset, int length)
60305 +#ifdef CONFIG_PROC_FS
60306 +
60307 +static void *ax25_info_start(struct seq_file *seq, loff_t *pos)
60308  {
60309 -       ax25_cb *ax25;
60310 -       int k;
60311 -       int len = 0;
60312 -       off_t pos = 0;
60313 -       off_t begin = 0;
60314 +       struct ax25_cb *ax25;
60315         struct hlist_node *node;
60316 +       int i = 0;
60317  
60318         spin_lock_bh(&ax25_list_lock);
60319 +       ax25_for_each(ax25, node, &ax25_list) {
60320 +               if (i == *pos)
60321 +                       return ax25;
60322 +               ++i;
60323 +       }
60324 +       return NULL;
60325 +}
60326 +
60327 +static void *ax25_info_next(struct seq_file *seq, void *v, loff_t *pos)
60328 +{
60329 +       ++*pos;
60330 +
60331 +       return hlist_entry( ((struct ax25_cb *)v)->ax25_node.next,
60332 +                           struct ax25_cb, ax25_node);
60333 +}
60334 +       
60335 +static void ax25_info_stop(struct seq_file *seq, void *v)
60336 +{
60337 +       spin_unlock_bh(&ax25_list_lock);
60338 +}
60339 +
60340 +static int ax25_info_show(struct seq_file *seq, void *v)
60341 +{
60342 +       ax25_cb *ax25 = v;
60343 +       int k;
60344 +
60345  
60346         /*
60347          * New format:
60348          * 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
60349          */
60350  
60351 -       ax25_for_each(ax25, node, &ax25_list) {
60352 -               len += sprintf(buffer+len, "%8.8lx %s %s%s ",
60353 -                               (long) ax25,
60354 -                               ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
60355 -                               ax2asc(&ax25->source_addr),
60356 -                               ax25->iamdigi? "*":"");
60357 -
60358 -               len += sprintf(buffer+len, "%s", ax2asc(&ax25->dest_addr));
60359 -
60360 -               for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) {
60361 -                       len += sprintf(buffer+len, ",%s%s",
60362 -                                       ax2asc(&ax25->digipeat->calls[k]),
60363 -                                       ax25->digipeat->repeated[k]? "*":"");
60364 -               }
60365 -
60366 -               len += sprintf(buffer+len, " %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %d %d",
60367 -                       ax25->state,
60368 -                       ax25->vs, ax25->vr, ax25->va,
60369 -                       ax25_display_timer(&ax25->t1timer) / HZ, ax25->t1 / HZ,
60370 -                       ax25_display_timer(&ax25->t2timer) / HZ, ax25->t2 / HZ,
60371 -                       ax25_display_timer(&ax25->t3timer) / HZ, ax25->t3 / HZ,
60372 -                       ax25_display_timer(&ax25->idletimer) / (60 * HZ),
60373 -                       ax25->idle / (60 * HZ),
60374 -                       ax25->n2count, ax25->n2,
60375 -                       ax25->rtt / HZ,
60376 -                       ax25->window,
60377 -                       ax25->paclen);
60378 -
60379 -               if (ax25->sk != NULL) {
60380 -                       bh_lock_sock(ax25->sk);
60381 -                       len += sprintf(buffer + len, " %d %d %ld\n",
60382 -                               atomic_read(&ax25->sk->sk_wmem_alloc),
60383 -                               atomic_read(&ax25->sk->sk_rmem_alloc),
60384 -                               ax25->sk->sk_socket != NULL ? SOCK_INODE(ax25->sk->sk_socket)->i_ino : 0L);
60385 -                       bh_unlock_sock(ax25->sk);
60386 -               } else {
60387 -                       len += sprintf(buffer + len, " * * *\n");
60388 -               }
60389 -
60390 -               pos = begin + len;
60391 -
60392 -               if (pos < offset) {
60393 -                       len   = 0;
60394 -                       begin = pos;
60395 -               }
60396 +       seq_printf(seq, "%8.8lx %s %s%s ",
60397 +                  (long) ax25,
60398 +                  ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
60399 +                  ax2asc(&ax25->source_addr),
60400 +                  ax25->iamdigi? "*":"");
60401 +       seq_printf(seq, "%s", ax2asc(&ax25->dest_addr));
60402 +
60403 +       for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) {
60404 +               seq_printf(seq, ",%s%s",
60405 +                          ax2asc(&ax25->digipeat->calls[k]),
60406 +                          ax25->digipeat->repeated[k]? "*":"");
60407 +       }
60408  
60409 -               if (pos > offset + length)
60410 -                       break;
60411 +       seq_printf(seq, " %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %d %d",
60412 +                  ax25->state,
60413 +                  ax25->vs, ax25->vr, ax25->va,
60414 +                  ax25_display_timer(&ax25->t1timer) / HZ, ax25->t1 / HZ,
60415 +                  ax25_display_timer(&ax25->t2timer) / HZ, ax25->t2 / HZ,
60416 +                  ax25_display_timer(&ax25->t3timer) / HZ, ax25->t3 / HZ,
60417 +                  ax25_display_timer(&ax25->idletimer) / (60 * HZ),
60418 +                  ax25->idle / (60 * HZ),
60419 +                  ax25->n2count, ax25->n2,
60420 +                  ax25->rtt / HZ,
60421 +                  ax25->window,
60422 +                  ax25->paclen);
60423 +
60424 +       if (ax25->sk != NULL) {
60425 +               bh_lock_sock(ax25->sk);
60426 +               seq_printf(seq," %d %d %ld\n",
60427 +                          atomic_read(&ax25->sk->sk_wmem_alloc),
60428 +                          atomic_read(&ax25->sk->sk_rmem_alloc),
60429 +                          ax25->sk->sk_socket != NULL ? SOCK_INODE(ax25->sk->sk_socket)->i_ino : 0L);
60430 +               bh_unlock_sock(ax25->sk);
60431 +       } else {
60432 +               seq_puts(seq, " * * *\n");
60433         }
60434 +       return 0;
60435 +}
60436  
60437 -       spin_unlock_bh(&ax25_list_lock);
60438 +static struct seq_operations ax25_info_seqops = {
60439 +       .start = ax25_info_start,
60440 +       .next = ax25_info_next,
60441 +       .stop = ax25_info_stop,
60442 +       .show = ax25_info_show,
60443 +};
60444  
60445 -       *start = buffer + (offset - begin);
60446 -       len   -= (offset - begin);
60447 +static int ax25_info_open(struct inode *inode, struct file *file)
60448 +{
60449 +       return seq_open(file, &ax25_info_seqops);
60450 +}
60451  
60452 -       if (len > length) len = length;
60453 +static struct file_operations ax25_info_fops = {
60454 +       .owner = THIS_MODULE,
60455 +       .open = ax25_info_open,
60456 +       .read = seq_read,
60457 +       .llseek = seq_lseek,
60458 +       .release = seq_release,
60459 +};
60460  
60461 -       return(len);
60462 -}
60463 +#endif
60464  
60465  static struct net_proto_family ax25_family_ops = {
60466         .family =       PF_AX25,
60467 @@ -1986,9 +2012,9 @@
60468         register_netdevice_notifier(&ax25_dev_notifier);
60469         ax25_register_sysctl();
60470  
60471 -       proc_net_create("ax25_route", 0, ax25_rt_get_info);
60472 -       proc_net_create("ax25", 0, ax25_get_info);
60473 -       proc_net_create("ax25_calls", 0, ax25_uid_get_info);
60474 +       proc_net_fops_create("ax25_route", S_IRUGO, &ax25_route_fops);
60475 +       proc_net_fops_create("ax25", S_IRUGO, &ax25_info_fops);
60476 +       proc_net_fops_create("ax25_calls", S_IRUGO, &ax25_uid_fops);
60477  
60478         printk(banner);
60479         return 0;
60480 @@ -1999,6 +2025,7 @@
60481  MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>");
60482  MODULE_DESCRIPTION("The amateur radio AX.25 link layer protocol");
60483  MODULE_LICENSE("GPL");
60484 +MODULE_ALIAS_NETPROTO(PF_AX25);
60485  
60486  static void __exit ax25_exit(void)
60487  {
60488 diff -Nru a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
60489 --- a/net/ax25/ax25_dev.c       Thu Jun  5 01:01:36 2003
60490 +++ b/net/ax25/ax25_dev.c       Sun Aug 24 04:32:46 2003
60491 @@ -67,6 +67,7 @@
60492  
60493         dev->ax25_ptr     = ax25_dev;
60494         ax25_dev->dev     = dev;
60495 +       dev_hold(dev);
60496         ax25_dev->forward = NULL;
60497  
60498         ax25_dev->values[AX25_VALUES_IPDEFMODE] = AX25_DEF_IPDEFMODE;
60499 @@ -121,6 +122,7 @@
60500         if ((s = ax25_dev_list) == ax25_dev) {
60501                 ax25_dev_list = s->next;
60502                 spin_unlock_bh(&ax25_dev_lock);
60503 +               dev_put(dev);
60504                 kfree(ax25_dev);
60505                 ax25_register_sysctl();
60506                 return;
60507 @@ -130,6 +132,7 @@
60508                 if (s->next == ax25_dev) {
60509                         s->next = ax25_dev->next;
60510                         spin_unlock_bh(&ax25_dev_lock);
60511 +                       dev_put(dev);
60512                         kfree(ax25_dev);
60513                         ax25_register_sysctl();
60514                         return;
60515 @@ -196,8 +199,8 @@
60516         ax25_dev = ax25_dev_list;
60517         while (ax25_dev != NULL) {
60518                 s        = ax25_dev;
60519 +               dev_put(ax25_dev->dev);
60520                 ax25_dev = ax25_dev->next;
60521 -
60522                 kfree(s);
60523         }
60524         ax25_dev_list = NULL;
60525 diff -Nru a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
60526 --- a/net/ax25/ax25_route.c     Thu Aug 21 11:59:08 2003
60527 +++ b/net/ax25/ax25_route.c     Sun Aug 24 04:34:01 2003
60528 @@ -34,6 +34,7 @@
60529  #include <linux/mm.h>
60530  #include <linux/interrupt.h>
60531  #include <linux/init.h>
60532 +#include <linux/seq_file.h>
60533  
60534  static ax25_route *ax25_route_list;
60535  static rwlock_t ax25_route_lock = RW_LOCK_UNLOCKED;
60536 @@ -278,66 +279,100 @@
60537         }
60538  }
60539  
60540 -int ax25_rt_get_info(char *buffer, char **start, off_t offset, int length)
60541 -{
60542 -       ax25_route *ax25_rt;
60543 -       int len     = 0;
60544 -       off_t pos   = 0;
60545 -       off_t begin = 0;
60546 -       char *callsign;
60547 -       int i;
60548 +#ifdef CONFIG_PROC_FS
60549  
60550 -       read_lock(&ax25_route_lock);
60551 +#define AX25_PROC_START        ((void *)1)
60552  
60553 -       len += sprintf(buffer, "callsign  dev  mode digipeaters\n");
60554 +static void *ax25_rt_seq_start(struct seq_file *seq, loff_t *pos)
60555 +{
60556 +       struct ax25_route *ax25_rt;
60557 +       int i = 1;
60558
60559 +       read_lock(&ax25_route_lock);
60560 +       if (*pos == 0)
60561 +               return AX25_PROC_START;
60562  
60563         for (ax25_rt = ax25_route_list; ax25_rt != NULL; ax25_rt = ax25_rt->next) {
60564 +               if (i == *pos)
60565 +                       return ax25_rt;
60566 +               ++i;
60567 +       }
60568 +
60569 +       return NULL;
60570 +}
60571 +
60572 +static void *ax25_rt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
60573 +{
60574 +       ++*pos;
60575 +       return (v == AX25_PROC_START) ? ax25_route_list : 
60576 +               ((struct ax25_route *) v)->next;
60577 +}
60578 +
60579 +static void ax25_rt_seq_stop(struct seq_file *seq, void *v)
60580 +{
60581 +       read_unlock(&ax25_route_lock);
60582 +}
60583 +
60584 +static int ax25_rt_seq_show(struct seq_file *seq, void *v)
60585 +{
60586 +       if (v == AX25_PROC_START)
60587 +               seq_puts(seq, "callsign  dev  mode digipeaters\n");
60588 +       else {
60589 +               struct ax25_route *ax25_rt = v;
60590 +               const char *callsign;
60591 +               int i;
60592 +
60593                 if (ax25cmp(&ax25_rt->callsign, &null_ax25_address) == 0)
60594                         callsign = "default";
60595                 else
60596                         callsign = ax2asc(&ax25_rt->callsign);
60597 -               len += sprintf(buffer + len, "%-9s %-4s",
60598 +
60599 +               seq_printf(seq, "%-9s %-4s",
60600                         callsign,
60601                         ax25_rt->dev ? ax25_rt->dev->name : "???");
60602  
60603                 switch (ax25_rt->ip_mode) {
60604                 case 'V':
60605 -                       len += sprintf(buffer + len, "   vc");
60606 +                       seq_puts(seq, "   vc");
60607                         break;
60608                 case 'D':
60609 -                       len += sprintf(buffer + len, "   dg");
60610 +                       seq_puts(seq, "   dg");
60611                         break;
60612                 default:
60613 -                       len += sprintf(buffer + len, "    *");
60614 +                       seq_puts(seq, "    *");
60615                         break;
60616                 }
60617  
60618                 if (ax25_rt->digipeat != NULL)
60619                         for (i = 0; i < ax25_rt->digipeat->ndigi; i++)
60620 -                               len += sprintf(buffer + len, " %s", ax2asc(&ax25_rt->digipeat->calls[i]));
60621 -
60622 -               len += sprintf(buffer + len, "\n");
60623 +                               seq_printf(seq, " %s", ax2asc(&ax25_rt->digipeat->calls[i]));
60624  
60625 -               pos = begin + len;
60626 -
60627 -               if (pos < offset) {
60628 -                       len   = 0;
60629 -                       begin = pos;
60630 -               }
60631 -
60632 -               if (pos > offset + length)
60633 -                       break;
60634 +               seq_puts(seq, "\n");
60635         }
60636 -       read_unlock(&ax25_route_lock);
60637 -
60638 -       *start = buffer + (offset - begin);
60639 -       len   -= (offset - begin);
60640 +       return 0;
60641 +}
60642  
60643 -       if (len > length)
60644 -               len = length;
60645 +static struct seq_operations ax25_rt_seqops = {
60646 +       .start = ax25_rt_seq_start,
60647 +       .next = ax25_rt_seq_next,
60648 +       .stop = ax25_rt_seq_stop,
60649 +       .show = ax25_rt_seq_show,
60650 +};
60651  
60652 -       return len;
60653 +static int ax25_rt_info_open(struct inode *inode, struct file *file)
60654 +{
60655 +       return seq_open(file, &ax25_rt_seqops);
60656  }
60657 +
60658 +struct file_operations ax25_route_fops = {
60659 +       .owner = THIS_MODULE,
60660 +       .open = ax25_rt_info_open,
60661 +       .read = seq_read,
60662 +       .llseek = seq_lseek,
60663 +       .release = seq_release,
60664 +};
60665 +
60666 +#endif
60667  
60668  /*
60669   *     Find AX.25 route
60670 diff -Nru a/net/ax25/ax25_uid.c b/net/ax25/ax25_uid.c
60671 --- a/net/ax25/ax25_uid.c       Mon Aug  5 06:20:38 2002
60672 +++ b/net/ax25/ax25_uid.c       Sun Aug 24 04:34:01 2003
60673 @@ -30,6 +30,7 @@
60674  #include <linux/interrupt.h>
60675  #include <linux/notifier.h>
60676  #include <linux/proc_fs.h>
60677 +#include <linux/seq_file.h>
60678  #include <linux/stat.h>
60679  #include <linux/netfilter.h>
60680  #include <linux/sysctl.h>
60681 @@ -141,39 +142,73 @@
60682         return -EINVAL; /*NOTREACHED */
60683  }
60684  
60685 -int ax25_uid_get_info(char *buffer, char **start, off_t offset, int length)
60686 +#ifdef CONFIG_PROC_FS
60687 +
60688 +#define AX25_PROC_START        ((void *)1)
60689 +
60690 +static void *ax25_uid_seq_start(struct seq_file *seq, loff_t *pos)
60691  {
60692 -       ax25_uid_assoc *pt;
60693 -       int len     = 0;
60694 -       off_t pos   = 0;
60695 -       off_t begin = 0;
60696 +       struct ax25_uid_assoc *pt;
60697 +       int i = 1;
60698  
60699         read_lock(&ax25_uid_lock);
60700 -       len += sprintf(buffer, "Policy: %d\n", ax25_uid_policy);
60701 +       if (*pos == 0)
60702 +               return AX25_PROC_START;
60703  
60704         for (pt = ax25_uid_list; pt != NULL; pt = pt->next) {
60705 -               len += sprintf(buffer + len, "%6d %s\n", pt->uid, ax2asc(&pt->call));
60706 -
60707 -               pos = begin + len;
60708 +               if (i == *pos)
60709 +                       return pt;
60710 +               ++i;
60711 +       }
60712 +       return NULL;
60713 +}
60714  
60715 -               if (pos < offset) {
60716 -                       len = 0;
60717 -                       begin = pos;
60718 -               }
60719 +static void *ax25_uid_seq_next(struct seq_file *seq, void *v, loff_t *pos)
60720 +{
60721 +       ++*pos;
60722 +       return (v == AX25_PROC_START) ? ax25_uid_list : 
60723 +               ((struct ax25_uid_assoc *) v)->next;
60724 +}
60725  
60726 -               if (pos > offset + length)
60727 -                       break;
60728 -       }
60729 +static void ax25_uid_seq_stop(struct seq_file *seq, void *v)
60730 +{
60731         read_unlock(&ax25_uid_lock);
60732 +}
60733 +
60734 +static int ax25_uid_seq_show(struct seq_file *seq, void *v)
60735 +{
60736 +       if (v == AX25_PROC_START)
60737 +               seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
60738 +       else {
60739 +               struct ax25_uid_assoc *pt = v;
60740 +               
60741  
60742 -       *start = buffer + (offset - begin);
60743 -       len   -= offset - begin;
60744 +               seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(&pt->call));
60745 +       }
60746 +       return 0;
60747 +}
60748  
60749 -       if (len > length)
60750 -               len = length;
60751 +static struct seq_operations ax25_uid_seqops = {
60752 +       .start = ax25_uid_seq_start,
60753 +       .next = ax25_uid_seq_next,
60754 +       .stop = ax25_uid_seq_stop,
60755 +       .show = ax25_uid_seq_show,
60756 +};
60757  
60758 -       return len;
60759 +static int ax25_uid_info_open(struct inode *inode, struct file *file)
60760 +{
60761 +       return seq_open(file, &ax25_uid_seqops);
60762  }
60763 +
60764 +struct file_operations ax25_uid_fops = {
60765 +       .owner = THIS_MODULE,
60766 +       .open = ax25_uid_info_open,
60767 +       .read = seq_read,
60768 +       .llseek = seq_lseek,
60769 +       .release = seq_release,
60770 +};
60771 +
60772 +#endif
60773  
60774  /*
60775   *     Free all memory associated with UID/Callsign structures.
60776 diff -Nru a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
60777 --- a/net/bluetooth/af_bluetooth.c      Wed Jun 18 13:59:01 2003
60778 +++ b/net/bluetooth/af_bluetooth.c      Sat Aug 30 19:30:42 2003
60779 @@ -130,6 +130,7 @@
60780         }
60781  
60782         sock_init_data(sock, sk);
60783 +       sk_set_owner(sk, THIS_MODULE);
60784         INIT_LIST_HEAD(&bt_sk(sk)->accept_q);
60785         
60786         sk->sk_zapped   = 0;
60787 diff -Nru a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
60788 --- a/net/bluetooth/bnep/core.c Wed Jun  4 17:57:08 2003
60789 +++ b/net/bluetooth/bnep/core.c Tue Sep  2 06:40:45 2003
60790 @@ -711,3 +711,4 @@
60791  MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION);
60792  MODULE_AUTHOR("David Libault <david.libault@inventel.fr>, Maxim Krasnyanskiy <maxk@qualcomm.com>");
60793  MODULE_LICENSE("GPL");
60794 +MODULE_ALIAS_NETPROTO(PF_BLUETOOTH);
60795 diff -Nru a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
60796 --- a/net/bluetooth/l2cap.c     Mon Jun 16 08:11:36 2003
60797 +++ b/net/bluetooth/l2cap.c     Sun Aug 31 16:14:24 2003
60798 @@ -200,7 +200,7 @@
60799   */
60800  static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src)
60801  {
60802 -       struct sock *sk, *sk1 = NULL;
60803 +       struct sock *sk = NULL, *sk1 = NULL;
60804         struct hlist_node *node;
60805  
60806         sk_for_each(sk, node, &l2cap_sk_list.head) {
60807 diff -Nru a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
60808 --- a/net/bluetooth/rfcomm/sock.c       Fri Jul  4 23:52:58 2003
60809 +++ b/net/bluetooth/rfcomm/sock.c       Sun Aug 31 16:14:24 2003
60810 @@ -114,7 +114,7 @@
60811  /* ---- Socket functions ---- */
60812  static struct sock *__rfcomm_get_sock_by_addr(u8 channel, bdaddr_t *src)
60813  {
60814 -       struct sock *sk;
60815 +       struct sock *sk = NULL;
60816         struct hlist_node *node;
60817  
60818         sk_for_each(sk, node, &rfcomm_sk_list.head) {
60819 @@ -131,7 +131,7 @@
60820   */
60821  static struct sock *__rfcomm_get_sock_by_channel(int state, u8 channel, bdaddr_t *src)
60822  {
60823 -       struct sock *sk, *sk1 = NULL;
60824 +       struct sock *sk = NULL, *sk1 = NULL;
60825         struct hlist_node *node;
60826  
60827         sk_for_each(sk, node, &rfcomm_sk_list.head) {
60828 diff -Nru a/net/bridge/Makefile b/net/bridge/Makefile
60829 --- a/net/bridge/Makefile       Sun Aug  3 15:08:32 2003
60830 +++ b/net/bridge/Makefile       Mon Sep  1 01:44:26 2003
60831 @@ -8,9 +8,6 @@
60832                         br_ioctl.o br_notify.o br_stp.o br_stp_bpdu.o \
60833                         br_stp_if.o br_stp_timer.o
60834  
60835 -# br_netfilter only deals with IPv4 and ARP filtering, both are INET protocols
60836 -ifeq ($(CONFIG_INET),y)
60837 -bridge-$(CONFIG_NETFILTER)     += br_netfilter.o
60838 -endif
60839 +bridge-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.o
60840  
60841  obj-$(CONFIG_BRIDGE_NF_EBTABLES) += netfilter/
60842 diff -Nru a/net/bridge/br_forward.c b/net/bridge/br_forward.c
60843 --- a/net/bridge/br_forward.c   Sun May 25 20:10:58 2003
60844 +++ b/net/bridge/br_forward.c   Mon Sep  1 01:44:26 2003
60845 @@ -33,7 +33,7 @@
60846  
60847  int br_dev_queue_push_xmit(struct sk_buff *skb)
60848  {
60849 -#ifdef CONFIG_NETFILTER
60850 +#ifdef CONFIG_BRIDGE_NETFILTER
60851         /* ip_refrag calls ip_fragment, which doesn't copy the MAC header. */
60852         if (skb->nf_bridge)
60853                 memcpy(skb->data - 16, skb->nf_bridge->hh, 16);
60854 diff -Nru a/net/bridge/netfilter/Kconfig b/net/bridge/netfilter/Kconfig
60855 --- a/net/bridge/netfilter/Kconfig      Thu Jul 17 23:40:19 2003
60856 +++ b/net/bridge/netfilter/Kconfig      Sat Aug 30 20:40:35 2003
60857 @@ -1,9 +1,30 @@
60858  #
60859  # Bridge netfilter configuration
60860  #
60861 +
60862 +menu "Bridge: Netfilter Configuration"
60863 +       depends on BRIDGE && NETFILTER
60864 +
60865  config BRIDGE_NF_EBTABLES
60866 -       tristate "Bridge: ebtables"
60867 -       depends on NETFILTER && BRIDGE
60868 +       tristate "Ethernet Bridge tables (ebtables) support"
60869 +       help
60870 +         ebtables is a general, extensible frame/packet identification
60871 +         framework. Say 'Y' or 'M' here if you want to do Ethernet
60872 +         filtering/NAT/brouting on the Ethernet bridge.
60873 +#
60874 +# tables
60875 +#
60876 +config BRIDGE_EBT_BROUTE
60877 +       tristate "ebt: broute table support"
60878 +       depends on BRIDGE_NF_EBTABLES
60879 +       help
60880 +         The ebtables broute table is used to define rules that decide between
60881 +         bridging and routing frames, giving Linux the functionality of a
60882 +         brouter. See the man page for ebtables(8) and examples on the ebtables
60883 +         website.
60884 +
60885 +         If you want to compile it as a module, say M here and read
60886 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
60887  
60888  config BRIDGE_EBT_T_FILTER
60889         tristate "ebt: filter table support"
60890 @@ -26,35 +47,14 @@
60891  
60892           If you want to compile it as a module, say M here and read
60893           <file:Documentation/modules.txt>.  If unsure, say `N'.
60894 -
60895 -config BRIDGE_EBT_BROUTE
60896 -       tristate "ebt: broute table support"
60897 +#
60898 +# matches
60899 +#
60900 +config BRIDGE_EBT_802_3
60901 +       tristate "ebt: 802.3 filter support"
60902         depends on BRIDGE_NF_EBTABLES
60903         help
60904 -         The ebtables broute table is used to define rules that decide between
60905 -         bridging and routing frames, giving Linux the functionality of a
60906 -         brouter. See the man page for ebtables(8) and examples on the ebtables
60907 -         website.
60908 -
60909 -         If you want to compile it as a module, say M here and read
60910 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
60911 -
60912 -config BRIDGE_EBT_LOG
60913 -       tristate "ebt: log support"
60914 -       depends on BRIDGE_NF_EBTABLES
60915 -       help
60916 -         This option adds the log target, that you can use in any rule in
60917 -         any ebtables table. It records the frame header to the syslog.
60918 -
60919 -         If you want to compile it as a module, say M here and read
60920 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
60921 -
60922 -config BRIDGE_EBT_IP
60923 -       tristate "ebt: IP filter support"
60924 -       depends on BRIDGE_NF_EBTABLES
60925 -       help
60926 -         This option adds the IP match, which allows basic IP header field
60927 -         filtering.
60928 +         This option adds matching support for 802.3 Ethernet frames.
60929  
60930           If you want to compile it as a module, say M here and read
60931           <file:Documentation/modules.txt>.  If unsure, say `N'.
60932 @@ -69,12 +69,12 @@
60933           If you want to compile it as a module, say M here and read
60934           <file:Documentation/modules.txt>.  If unsure, say `N'.
60935  
60936 -config BRIDGE_EBT_VLAN
60937 -       tristate "ebt: 802.1Q VLAN filter support"
60938 +config BRIDGE_EBT_IP
60939 +       tristate "ebt: IP filter support"
60940         depends on BRIDGE_NF_EBTABLES
60941         help
60942 -         This option adds the 802.1Q vlan match, which allows the filtering of
60943 -         802.1Q vlan fields.
60944 +         This option adds the IP match, which allows basic IP header field
60945 +         filtering.
60946  
60947           If you want to compile it as a module, say M here and read
60948           <file:Documentation/modules.txt>.  If unsure, say `N'.
60949 @@ -113,12 +113,24 @@
60950           If you want to compile it as a module, say M here and read
60951           <file:Documentation/modules.txt>.  If unsure, say `N'.
60952  
60953 -config BRIDGE_EBT_SNAT
60954 -       tristate "ebt: snat target support"
60955 +config BRIDGE_EBT_VLAN
60956 +       tristate "ebt: 802.1Q VLAN filter support"
60957         depends on BRIDGE_NF_EBTABLES
60958         help
60959 -         This option adds the MAC SNAT target, which allows altering the MAC
60960 -         source address of frames.
60961 +         This option adds the 802.1Q vlan match, which allows the filtering of
60962 +         802.1Q vlan fields.
60963 +
60964 +         If you want to compile it as a module, say M here and read
60965 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
60966 +#
60967 +# targets
60968 +#
60969 +config BRIDGE_EBT_ARPREPLY
60970 +       tristate "ebt: arp reply target support"
60971 +       depends on BRIDGE_NF_EBTABLES
60972 +       help
60973 +         This option adds the arp reply target, which allows
60974 +         automatically sending arp replies to arp requests.
60975  
60976           If you want to compile it as a module, say M here and read
60977           <file:Documentation/modules.txt>.  If unsure, say `N'.
60978 @@ -133,6 +145,18 @@
60979           If you want to compile it as a module, say M here and read
60980           <file:Documentation/modules.txt>.  If unsure, say `N'.
60981  
60982 +config BRIDGE_EBT_MARK_T
60983 +       tristate "ebt: mark target support"
60984 +       depends on BRIDGE_NF_EBTABLES
60985 +       help
60986 +         This option adds the mark target, which allows marking frames by
60987 +         setting the 'nfmark' value in the frame.
60988 +         This value is the same as the one used in the iptables mark match and
60989 +         target.
60990 +
60991 +         If you want to compile it as a module, say M here and read
60992 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
60993 +
60994  config BRIDGE_EBT_REDIRECT
60995         tristate "ebt: redirect target support"
60996         depends on BRIDGE_NF_EBTABLES
60997 @@ -143,15 +167,26 @@
60998           If you want to compile it as a module, say M here and read
60999           <file:Documentation/modules.txt>.  If unsure, say `N'.
61000  
61001 -config BRIDGE_EBT_MARK_T
61002 -       tristate "ebt: mark target support"
61003 +config BRIDGE_EBT_SNAT
61004 +       tristate "ebt: snat target support"
61005         depends on BRIDGE_NF_EBTABLES
61006         help
61007 -         This option adds the mark target, which allows marking frames by
61008 -         setting the 'nfmark' value in the frame.
61009 -         This value is the same as the one used in the iptables mark match and
61010 -         target.
61011 +         This option adds the MAC SNAT target, which allows altering the MAC
61012 +         source address of frames.
61013 +
61014 +         If you want to compile it as a module, say M here and read
61015 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
61016 +#
61017 +# watchers
61018 +#
61019 +config BRIDGE_EBT_LOG
61020 +       tristate "ebt: log support"
61021 +       depends on BRIDGE_NF_EBTABLES
61022 +       help
61023 +         This option adds the log target, that you can use in any rule in
61024 +         any ebtables table. It records the frame header to the syslog.
61025  
61026           If you want to compile it as a module, say M here and read
61027           <file:Documentation/modules.txt>.  If unsure, say `N'.
61028  
61029 +endmenu
61030 diff -Nru a/net/bridge/netfilter/Makefile b/net/bridge/netfilter/Makefile
61031 --- a/net/bridge/netfilter/Makefile     Thu Jul 17 23:40:19 2003
61032 +++ b/net/bridge/netfilter/Makefile     Sat Aug 30 20:40:35 2003
61033 @@ -3,17 +3,27 @@
61034  #
61035  
61036  obj-$(CONFIG_BRIDGE_NF_EBTABLES) += ebtables.o
61037 +
61038 +# tables
61039 +obj-$(CONFIG_BRIDGE_EBT_BROUTE) += ebtable_broute.o
61040  obj-$(CONFIG_BRIDGE_EBT_T_FILTER) += ebtable_filter.o
61041  obj-$(CONFIG_BRIDGE_EBT_T_NAT) += ebtable_nat.o
61042 -obj-$(CONFIG_BRIDGE_EBT_BROUTE) += ebtable_broute.o
61043 -obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o
61044 +
61045 +#matches
61046 +obj-$(CONFIG_BRIDGE_EBT_802_3) += ebt_802_3.o
61047  obj-$(CONFIG_BRIDGE_EBT_ARP) += ebt_arp.o
61048 -obj-$(CONFIG_BRIDGE_EBT_VLAN) += ebt_vlan.o
61049 +obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o
61050  obj-$(CONFIG_BRIDGE_EBT_MARK) += ebt_mark_m.o
61051  obj-$(CONFIG_BRIDGE_EBT_PKTTYPE) += ebt_pkttype.o
61052  obj-$(CONFIG_BRIDGE_EBT_STP) += ebt_stp.o
61053 -obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o
61054 -obj-$(CONFIG_BRIDGE_EBT_SNAT) += ebt_snat.o
61055 +obj-$(CONFIG_BRIDGE_EBT_VLAN) += ebt_vlan.o
61056 +
61057 +# targets
61058 +obj-$(CONFIG_BRIDGE_EBT_ARPREPLY) += ebt_arpreply.o
61059 +obj-$(CONFIG_BRIDGE_EBT_MARK_T) += ebt_mark.o
61060  obj-$(CONFIG_BRIDGE_EBT_DNAT) += ebt_dnat.o
61061  obj-$(CONFIG_BRIDGE_EBT_REDIRECT) += ebt_redirect.o
61062 -obj-$(CONFIG_BRIDGE_EBT_MARK_T) += ebt_mark.o
61063 +obj-$(CONFIG_BRIDGE_EBT_SNAT) += ebt_snat.o
61064 +
61065 +# watchers
61066 +obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o
61067 diff -Nru a/net/bridge/netfilter/ebt_802_3.c b/net/bridge/netfilter/ebt_802_3.c
61068 --- /dev/null   Wed Dec 31 16:00:00 1969
61069 +++ b/net/bridge/netfilter/ebt_802_3.c  Sat Aug 30 20:40:29 2003
61070 @@ -0,0 +1,73 @@
61071 +/*
61072 + * 802_3
61073 + *
61074 + * Author:
61075 + * Chris Vitale csv@bluetail.com
61076 + *
61077 + * May 2003
61078 + * 
61079 + */
61080 +
61081 +#include <linux/netfilter_bridge/ebtables.h>
61082 +#include <linux/netfilter_bridge/ebt_802_3.h>
61083 +#include <linux/module.h>
61084 +
61085 +static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *in,
61086 +   const struct net_device *out, const void *data, unsigned int datalen)
61087 +{
61088 +       struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
61089 +       struct ebt_802_3_hdr *hdr = (struct ebt_802_3_hdr *)skb->mac.ethernet;
61090 +       uint16_t type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
61091 +
61092 +       if (info->bitmask & EBT_802_3_SAP) {
61093 +               if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP)) 
61094 +                               return EBT_NOMATCH;
61095 +               if (FWINV(info->sap != hdr->llc.ui.dsap, EBT_802_3_SAP))
61096 +                               return EBT_NOMATCH;
61097 +       }
61098 +
61099 +       if (info->bitmask & EBT_802_3_TYPE) {
61100 +               if (!(hdr->llc.ui.dsap == CHECK_TYPE && hdr->llc.ui.ssap == CHECK_TYPE))
61101 +                       return EBT_NOMATCH;
61102 +               if (FWINV(info->type != type, EBT_802_3_TYPE)) 
61103 +                       return EBT_NOMATCH;
61104 +       }
61105 +
61106 +       return EBT_MATCH;
61107 +}
61108 +
61109 +static struct ebt_match filter_802_3;
61110 +static int ebt_802_3_check(const char *tablename, unsigned int hookmask,
61111 +   const struct ebt_entry *e, void *data, unsigned int datalen)
61112 +{
61113 +       struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
61114 +
61115 +       if (datalen < sizeof(struct ebt_802_3_info))
61116 +               return -EINVAL;
61117 +       if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
61118 +               return -EINVAL;
61119 +
61120 +       return 0;
61121 +}
61122 +
61123 +static struct ebt_match filter_802_3 =
61124 +{
61125 +       .name           = EBT_802_3_MATCH,
61126 +       .match          = ebt_filter_802_3,
61127 +       .check          = ebt_802_3_check,
61128 +       .me             = THIS_MODULE,
61129 +};
61130 +
61131 +static int __init init(void)
61132 +{
61133 +       return ebt_register_match(&filter_802_3);
61134 +}
61135 +
61136 +static void __exit fini(void)
61137 +{
61138 +       ebt_unregister_match(&filter_802_3);
61139 +}
61140 +
61141 +module_init(init);
61142 +module_exit(fini);
61143 +MODULE_LICENSE("GPL");
61144 diff -Nru a/net/bridge/netfilter/ebt_arpreply.c b/net/bridge/netfilter/ebt_arpreply.c
61145 --- /dev/null   Wed Dec 31 16:00:00 1969
61146 +++ b/net/bridge/netfilter/ebt_arpreply.c       Sun Aug 24 04:31:46 2003
61147 @@ -0,0 +1,89 @@
61148 +/*
61149 + *  ebt_arpreply
61150 + *
61151 + *     Authors:
61152 + *     Grzegorz Borowiak <grzes@gnu.univ.gda.pl>
61153 + *     Bart De Schuymer <bdschuym@pandora.be>
61154 + *
61155 + *  August, 2003
61156 + *
61157 + */
61158 +
61159 +#include <linux/netfilter_bridge/ebtables.h>
61160 +#include <linux/netfilter_bridge/ebt_arpreply.h>
61161 +#include <linux/if_arp.h>
61162 +#include <net/arp.h>
61163 +#include <linux/module.h>
61164 +
61165 +static int ebt_target_reply(struct sk_buff **pskb, unsigned int hooknr,
61166 +   const struct net_device *in, const struct net_device *out,
61167 +   const void *data, unsigned int datalen)
61168 +{
61169 +       struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
61170 +       u32 sip, dip;
61171 +       struct arphdr ah;
61172 +       unsigned char sha[ETH_ALEN];
61173 +       struct sk_buff *skb = *pskb;
61174 +
61175 +       if (skb_copy_bits(skb, 0, &ah, sizeof(ah)))
61176 +               return EBT_DROP;
61177 +
61178 +       if (ah.ar_op != __constant_htons(ARPOP_REQUEST) || ah.ar_hln != ETH_ALEN
61179 +           || ah.ar_pro != __constant_htons(ETH_P_IP) || ah.ar_pln != 4)
61180 +               return EBT_CONTINUE;
61181 +
61182 +       if (skb_copy_bits(skb, sizeof(ah), &sha, ETH_ALEN))
61183 +               return EBT_DROP;
61184 +
61185 +       if (skb_copy_bits(skb, sizeof(ah) + ETH_ALEN, &sip, sizeof(sip)))
61186 +               return EBT_DROP;
61187 +
61188 +       if (skb_copy_bits(skb, sizeof(ah) + 2 * ETH_ALEN + sizeof(sip),
61189 +           &dip, sizeof(dip)))
61190 +               return EBT_DROP;
61191 +
61192 +       arp_send(ARPOP_REPLY, ETH_P_ARP, sip, (struct net_device *)in,
61193 +                dip, sha, info->mac, sha);
61194 +
61195 +       return info->target;
61196 +}
61197 +
61198 +static int ebt_target_reply_check(const char *tablename, unsigned int hookmask,
61199 +   const struct ebt_entry *e, void *data, unsigned int datalen)
61200 +{
61201 +       struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
61202 +
61203 +       if (datalen != EBT_ALIGN(sizeof(struct ebt_arpreply_info)))
61204 +               return -EINVAL;
61205 +       if (BASE_CHAIN && info->target == EBT_RETURN)
61206 +               return -EINVAL;
61207 +       if (e->ethproto != __constant_htons(ETH_P_ARP) ||
61208 +           e->invflags & EBT_IPROTO)
61209 +               return -EINVAL;
61210 +       CLEAR_BASE_CHAIN_BIT;
61211 +       if (strcmp(tablename, "nat") || hookmask & ~(1 << NF_BR_PRE_ROUTING))
61212 +               return -EINVAL;
61213 +       return 0;
61214 +}
61215 +
61216 +static struct ebt_target reply_target =
61217 +{
61218 +       .name           = EBT_ARPREPLY_TARGET,
61219 +       .target         = ebt_target_reply,
61220 +       .check          = ebt_target_reply_check,
61221 +       .me             = THIS_MODULE,
61222 +};
61223 +
61224 +static int __init init(void)
61225 +{
61226 +       return ebt_register_target(&reply_target);
61227 +}
61228 +
61229 +static void __exit fini(void)
61230 +{
61231 +       ebt_unregister_target(&reply_target);
61232 +}
61233 +
61234 +module_init(init);
61235 +module_exit(fini);
61236 +MODULE_LICENSE("GPL");
61237 diff -Nru a/net/core/dev.c b/net/core/dev.c
61238 --- a/net/core/dev.c    Tue Aug 19 21:04:26 2003
61239 +++ b/net/core/dev.c    Mon Sep  1 12:14:20 2003
61240 @@ -845,11 +845,7 @@
61241          * engine, but this requires more changes in devices. */
61242  
61243         smp_mb__after_clear_bit(); /* Commit netif_running(). */
61244 -       while (test_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
61245 -               /* No hurry. */
61246 -               current->state = TASK_INTERRUPTIBLE;
61247 -               schedule_timeout(1);
61248 -       }
61249 +       netif_poll_disable(dev);
61250  
61251         /*
61252          *      Call the device specific close. This cannot fail.
61253 @@ -1210,7 +1206,7 @@
61254  int lo_cong = 100;
61255  int mod_cong = 290;
61256  
61257 -struct netif_rx_stats netdev_rx_stat[NR_CPUS];
61258 +DEFINE_PER_CPU(struct netif_rx_stats, netdev_rx_stat) = { 0, };
61259  
61260  
61261  #ifdef CONFIG_NET_HW_FLOWCONTROL
61262 @@ -1359,7 +1355,7 @@
61263         this_cpu = smp_processor_id();
61264         queue = &__get_cpu_var(softnet_data);
61265  
61266 -       netdev_rx_stat[this_cpu].total++;
61267 +       __get_cpu_var(netdev_rx_stat).total++;
61268         if (queue->input_pkt_queue.qlen <= netdev_max_backlog) {
61269                 if (queue->input_pkt_queue.qlen) {
61270                         if (queue->throttle)
61271 @@ -1389,14 +1385,14 @@
61272  
61273         if (!queue->throttle) {
61274                 queue->throttle = 1;
61275 -               netdev_rx_stat[this_cpu].throttled++;
61276 +               __get_cpu_var(netdev_rx_stat).throttled++;
61277  #ifdef CONFIG_NET_HW_FLOWCONTROL
61278                 atomic_inc(&netdev_dropping);
61279  #endif
61280         }
61281  
61282  drop:
61283 -       netdev_rx_stat[this_cpu].dropped++;
61284 +       __get_cpu_var(netdev_rx_stat).dropped++;
61285         local_irq_restore(flags);
61286  
61287         kfree_skb(skb);
61288 @@ -1537,11 +1533,11 @@
61289  
61290         skb_bond(skb);
61291  
61292 -       netdev_rx_stat[smp_processor_id()].total++;
61293 +       __get_cpu_var(netdev_rx_stat).total++;
61294  
61295  #ifdef CONFIG_NET_FASTROUTE
61296         if (skb->pkt_type == PACKET_FASTROUTE) {
61297 -               netdev_rx_stat[smp_processor_id()].fastroute_deferred_out++;
61298 +               __get_cpu_var(netdev_rx_stat).fastroute_deferred_out++;
61299                 return dev_queue_xmit(skb);
61300         }
61301  #endif
61302 @@ -1657,7 +1653,7 @@
61303  
61304         list_del(&backlog_dev->poll_list);
61305         smp_mb__before_clear_bit();
61306 -       clear_bit(__LINK_STATE_RX_SCHED, &backlog_dev->state);
61307 +       netif_poll_enable(backlog_dev);
61308  
61309         if (queue->throttle) {
61310                 queue->throttle = 0;
61311 @@ -1672,7 +1668,6 @@
61312  
61313  static void net_rx_action(struct softirq_action *h)
61314  {
61315 -       int this_cpu = smp_processor_id();
61316         struct softnet_data *queue = &__get_cpu_var(softnet_data);
61317         unsigned long start_time = jiffies;
61318         int budget = netdev_max_backlog;
61319 @@ -1711,7 +1706,7 @@
61320         return;
61321  
61322  softnet_break:
61323 -       netdev_rx_stat[this_cpu].time_squeeze++;
61324 +       __get_cpu_var(netdev_rx_stat).time_squeeze++;
61325         __raise_softirq_irqoff(NET_RX_SOFTIRQ);
61326         goto out;
61327  }
61328 @@ -1912,7 +1907,7 @@
61329  
61330         while (*pos < NR_CPUS)
61331                 if (cpu_online(*pos)) {
61332 -                       rc = &netdev_rx_stat[*pos];
61333 +                       rc = &per_cpu(netdev_rx_stat, *pos);
61334                         break;
61335                 } else
61336                         ++*pos;
61337 diff -Nru a/net/core/ethtool.c b/net/core/ethtool.c
61338 --- a/net/core/ethtool.c        Thu Aug  7 13:16:02 2003
61339 +++ b/net/core/ethtool.c        Mon Sep  1 17:25:54 2003
61340 @@ -13,6 +13,7 @@
61341  #include <linux/errno.h>
61342  #include <linux/ethtool.h>
61343  #include <linux/netdevice.h>
61344 +#include <asm/uaccess.h>
61345  
61346  /* 
61347   * Some useful ethtool_ops methods that're device independent.
61348 @@ -30,6 +31,16 @@
61349         return (dev->features & NETIF_F_IP_CSUM) != 0;
61350  }
61351  
61352 +int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
61353 +{
61354 +       if (data)
61355 +               dev->features |= NETIF_F_IP_CSUM;
61356 +       else
61357 +               dev->features &= ~NETIF_F_IP_CSUM;
61358 +
61359 +       return 0;
61360 +}
61361 +
61362  u32 ethtool_op_get_sg(struct net_device *dev)
61363  {
61364         return (dev->features & NETIF_F_SG) != 0;
61365 @@ -45,6 +56,21 @@
61366         return 0;
61367  }
61368  
61369 +u32 ethtool_op_get_tso(struct net_device *dev)
61370 +{
61371 +       return (dev->features & NETIF_F_TSO) != 0;
61372 +}
61373 +
61374 +int ethtool_op_set_tso(struct net_device *dev, u32 data)
61375 +{
61376 +       if (data)
61377 +               dev->features |= NETIF_F_TSO;
61378 +       else
61379 +               dev->features &= ~NETIF_F_TSO;
61380 +
61381 +       return 0;
61382 +}
61383 +
61384  /* Handlers for each ethtool command */
61385  
61386  static int ethtool_get_settings(struct net_device *dev, void *useraddr)
61387 @@ -454,6 +480,33 @@
61388         return dev->ethtool_ops->set_sg(dev, edata.data);
61389  }
61390  
61391 +static int ethtool_get_tso(struct net_device *dev, char *useraddr)
61392 +{
61393 +       struct ethtool_value edata = { ETHTOOL_GTSO };
61394 +
61395 +       if (!dev->ethtool_ops->get_tso)
61396 +               return -EOPNOTSUPP;
61397 +
61398 +       edata.data = dev->ethtool_ops->get_tso(dev);
61399 +
61400 +       if (copy_to_user(useraddr, &edata, sizeof(edata)))
61401 +               return -EFAULT;
61402 +       return 0;
61403 +}
61404 +
61405 +static int ethtool_set_tso(struct net_device *dev, char *useraddr)
61406 +{
61407 +       struct ethtool_value edata;
61408 +
61409 +       if (!dev->ethtool_ops->set_tso)
61410 +               return -EOPNOTSUPP;
61411 +
61412 +       if (copy_from_user(&edata, useraddr, sizeof(edata)))
61413 +               return -EFAULT;
61414 +
61415 +       return dev->ethtool_ops->set_tso(dev, edata.data);
61416 +}
61417 +
61418  static int ethtool_self_test(struct net_device *dev, char *useraddr)
61419  {
61420         struct ethtool_test test;
61421 @@ -502,15 +555,15 @@
61422  
61423         switch (gstrings.string_set) {
61424         case ETH_SS_TEST:
61425 -               if (ops->self_test_count)
61426 -                       gstrings.len = ops->self_test_count(dev);
61427 -               else
61428 +               if (!ops->self_test_count)
61429                         return -EOPNOTSUPP;
61430 +               gstrings.len = ops->self_test_count(dev);
61431 +               break;
61432         case ETH_SS_STATS:
61433 -               if (ops->get_stats_count)
61434 -                       gstrings.len = ops->get_stats_count(dev);
61435 -               else
61436 +               if (!ops->get_stats_count)
61437                         return -EOPNOTSUPP;
61438 +               gstrings.len = ops->get_stats_count(dev);
61439 +               break;
61440         default:
61441                 return -EINVAL;
61442         }
61443 @@ -653,6 +706,10 @@
61444                 return ethtool_get_sg(dev, useraddr);
61445         case ETHTOOL_SSG:
61446                 return ethtool_set_sg(dev, useraddr);
61447 +       case ETHTOOL_GTSO:
61448 +               return ethtool_get_tso(dev, useraddr);
61449 +       case ETHTOOL_STSO:
61450 +               return ethtool_set_tso(dev, useraddr);
61451         case ETHTOOL_TEST:
61452                 return ethtool_self_test(dev, useraddr);
61453         case ETHTOOL_GSTRINGS:
61454 diff -Nru a/net/core/netfilter.c b/net/core/netfilter.c
61455 --- a/net/core/netfilter.c      Wed Jul 30 16:57:26 2003
61456 +++ b/net/core/netfilter.c      Mon Sep  1 01:44:26 2003
61457 @@ -430,7 +430,7 @@
61458  {
61459         int status;
61460         struct nf_info *info;
61461 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
61462 +#ifdef CONFIG_BRIDGE_NETFILTER
61463         struct net_device *physindev = NULL;
61464         struct net_device *physoutdev = NULL;
61465  #endif
61466 @@ -467,7 +467,7 @@
61467         if (indev) dev_hold(indev);
61468         if (outdev) dev_hold(outdev);
61469  
61470 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
61471 +#ifdef CONFIG_BRIDGE_NETFILTER
61472         if (skb->nf_bridge) {
61473                 physindev = skb->nf_bridge->physindev;
61474                 if (physindev) dev_hold(physindev);
61475 @@ -483,7 +483,7 @@
61476                 /* James M doesn't say fuck enough. */
61477                 if (indev) dev_put(indev);
61478                 if (outdev) dev_put(outdev);
61479 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
61480 +#ifdef CONFIG_BRIDGE_NETFILTER
61481                 if (physindev) dev_put(physindev);
61482                 if (physoutdev) dev_put(physoutdev);
61483  #endif
61484 @@ -560,7 +560,7 @@
61485         /* Release those devices we held, or Alexey will kill me. */
61486         if (info->indev) dev_put(info->indev);
61487         if (info->outdev) dev_put(info->outdev);
61488 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
61489 +#ifdef CONFIG_BRIDGE_NETFILTER
61490         if (skb->nf_bridge) {
61491                 if (skb->nf_bridge->physindev)
61492                         dev_put(skb->nf_bridge->physindev);
61493 diff -Nru a/net/core/scm.c b/net/core/scm.c
61494 --- a/net/core/scm.c    Sun Mar 23 22:06:53 2003
61495 +++ b/net/core/scm.c    Sun Aug 24 05:14:27 2003
61496 @@ -41,7 +41,7 @@
61497  
61498  static __inline__ int scm_check_creds(struct ucred *creds)
61499  {
61500 -       if ((creds->pid == current->pid || capable(CAP_SYS_ADMIN)) &&
61501 +       if ((creds->pid == current->tgid || capable(CAP_SYS_ADMIN)) &&
61502             ((creds->uid == current->uid || creds->uid == current->euid ||
61503               creds->uid == current->suid) || capable(CAP_SETUID)) &&
61504             ((creds->gid == current->gid || creds->gid == current->egid ||
61505 diff -Nru a/net/core/skbuff.c b/net/core/skbuff.c
61506 --- a/net/core/skbuff.c Sat Aug  9 02:14:55 2003
61507 +++ b/net/core/skbuff.c Mon Sep  1 01:44:26 2003
61508 @@ -236,7 +236,7 @@
61509         }
61510  #ifdef CONFIG_NETFILTER
61511         nf_conntrack_put(skb->nfct);
61512 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
61513 +#ifdef CONFIG_BRIDGE_NETFILTER
61514         nf_bridge_put(skb->nf_bridge);
61515  #endif
61516  #endif
61517 @@ -301,7 +301,7 @@
61518  #ifdef CONFIG_NETFILTER_DEBUG
61519         C(nf_debug);
61520  #endif
61521 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
61522 +#ifdef CONFIG_BRIDGE_NETFILTER
61523         C(nf_bridge);
61524         nf_bridge_get(skb->nf_bridge);
61525  #endif
61526 @@ -359,7 +359,7 @@
61527  #ifdef CONFIG_NETFILTER_DEBUG
61528         new->nf_debug   = old->nf_debug;
61529  #endif
61530 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
61531 +#ifdef CONFIG_BRIDGE_NETFILTER
61532         new->nf_bridge  = old->nf_bridge;
61533         nf_bridge_get(old->nf_bridge);
61534  #endif
61535 diff -Nru a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
61536 --- a/net/decnet/af_decnet.c    Tue Jul 22 23:33:06 2003
61537 +++ b/net/decnet/af_decnet.c    Tue Sep  2 04:38:10 2003
61538 @@ -2349,6 +2349,7 @@
61539  MODULE_DESCRIPTION("The Linux DECnet Network Protocol");
61540  MODULE_AUTHOR("Linux DECnet Project Team");
61541  MODULE_LICENSE("GPL");
61542 +MODULE_ALIAS_NETPROTO(PF_DECnet);
61543  
61544  static char banner[] __initdata = KERN_INFO "NET4: DECnet for Linux: V.2.5.68s (C) 1995-2003 Linux DECnet Project Team\n";
61545  
61546 diff -Nru a/net/econet/af_econet.c b/net/econet/af_econet.c
61547 --- a/net/econet/af_econet.c    Wed Jun 18 13:59:01 2003
61548 +++ b/net/econet/af_econet.c    Tue Sep  2 04:38:10 2003
61549 @@ -562,6 +562,7 @@
61550         sk->sk_reuse = 1;
61551         sock->ops = &econet_ops;
61552         sock_init_data(sock,sk);
61553 +       sk_set_owner(sk, THIS_MODULE);
61554  
61555         eo = ec_sk(sk) = kmalloc(sizeof(*eo), GFP_KERNEL);
61556         if (!eo)
61557 @@ -1115,3 +1116,4 @@
61558  module_exit(econet_proto_exit);
61559  
61560  MODULE_LICENSE("GPL");
61561 +MODULE_ALIAS_NETPROTO(PF_ECONET);
61562 diff -Nru a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
61563 --- a/net/ipv4/af_inet.c        Sun Jul 27 16:03:33 2003
61564 +++ b/net/ipv4/af_inet.c        Tue Sep  2 04:38:10 2003
61565 @@ -1248,3 +1248,4 @@
61566         return 0;
61567  }
61568  #endif /* CONFIG_PROC_FS */
61569 +MODULE_ALIAS_NETPROTO(PF_INET);
61570 diff -Nru a/net/ipv4/icmp.c b/net/ipv4/icmp.c
61571 --- a/net/ipv4/icmp.c   Fri Jun 27 09:43:50 2003
61572 +++ b/net/ipv4/icmp.c   Tue Sep  2 14:34:13 2003
61573 @@ -230,12 +230,18 @@
61574  static DEFINE_PER_CPU(struct socket *, __icmp_socket) = NULL;
61575  #define icmp_socket    __get_cpu_var(__icmp_socket)
61576  
61577 -static __inline__ void icmp_xmit_lock(void)
61578 +static __inline__ int icmp_xmit_lock(void)
61579  {
61580         local_bh_disable();
61581  
61582 -       if (unlikely(!spin_trylock(&icmp_socket->sk->sk_lock.slock)))
61583 -               BUG();
61584 +       if (unlikely(!spin_trylock(&icmp_socket->sk->sk_lock.slock))) {
61585 +               /* This can happen if the output path signals a
61586 +                * dst_link_failure() for an outgoing ICMP packet.
61587 +                */
61588 +               local_bh_enable();
61589 +               return 1;
61590 +       }
61591 +       return 0;
61592  }
61593  
61594  static void icmp_xmit_unlock(void)
61595 @@ -376,7 +382,8 @@
61596         if (ip_options_echo(&icmp_param->replyopts, skb))
61597                 goto out;
61598  
61599 -       icmp_xmit_lock();
61600 +       if (icmp_xmit_lock())
61601 +               return;
61602  
61603         icmp_param->data.icmph.checksum = 0;
61604         icmp_out_count(icmp_param->data.icmph.type);
61605 @@ -488,7 +495,8 @@
61606                 }
61607         }
61608  
61609 -       icmp_xmit_lock();
61610 +       if (icmp_xmit_lock())
61611 +               return;
61612  
61613         /*
61614          *      Construct source address and options.
61615 diff -Nru a/net/ipv4/igmp.c b/net/ipv4/igmp.c
61616 --- a/net/ipv4/igmp.c   Wed Aug 20 10:42:42 2003
61617 +++ b/net/ipv4/igmp.c   Wed Aug 27 23:45:13 2003
61618 @@ -2122,6 +2122,7 @@
61619                         break;
61620                 }
61621                 read_unlock(&in_dev->lock);
61622 +               in_dev_put(in_dev);
61623         }
61624         return im;
61625  }
61626 @@ -2181,7 +2182,9 @@
61627         if (likely(state->in_dev != NULL)) {
61628                 read_unlock(&state->in_dev->lock);
61629                 in_dev_put(state->in_dev);
61630 +               state->in_dev = NULL;
61631         }
61632 +       state->dev = NULL;
61633         read_unlock(&dev_base_lock);
61634  }
61635  
61636 @@ -2284,6 +2287,7 @@
61637                         spin_unlock_bh(&im->lock);
61638                 }
61639                 read_unlock_bh(&idev->lock);
61640 +               in_dev_put(idev);
61641         }
61642         return psf;
61643  }
61644 @@ -2350,12 +2354,16 @@
61645  static void igmp_mcf_seq_stop(struct seq_file *seq, void *v)
61646  {
61647         struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
61648 -       if (likely(state->im != NULL))
61649 +       if (likely(state->im != NULL)) {
61650                 spin_unlock_bh(&state->im->lock);
61651 +               state->im = NULL;
61652 +       }
61653         if (likely(state->idev != NULL)) {
61654                 read_unlock_bh(&state->idev->lock);
61655                 in_dev_put(state->idev);
61656 +               state->idev = NULL;
61657         }
61658 +       state->dev = NULL;
61659         read_unlock(&dev_base_lock);
61660  }
61661  
61662 diff -Nru a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
61663 --- a/net/ipv4/ip_output.c      Fri Jul 25 13:42:43 2003
61664 +++ b/net/ipv4/ip_output.c      Mon Sep  1 01:44:26 2003
61665 @@ -414,7 +414,7 @@
61666         /* Connection association is same as pre-frag packet */
61667         to->nfct = from->nfct;
61668         nf_conntrack_get(to->nfct);
61669 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
61670 +#ifdef CONFIG_BRIDGE_NETFILTER
61671         to->nf_bridge = from->nf_bridge;
61672         nf_bridge_get(to->nf_bridge);
61673  #endif
61674 diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
61675 --- a/net/ipv4/ipvs/ip_vs_conn.c        Mon Jul 21 02:35:25 2003
61676 +++ b/net/ipv4/ipvs/ip_vs_conn.c        Thu Aug 28 01:21:50 2003
61677 @@ -837,7 +837,7 @@
61678                    "(size=%d, memory=%ldKbytes)\n",
61679                    IP_VS_CONN_TAB_SIZE,
61680                    (long)(IP_VS_CONN_TAB_SIZE*sizeof(struct list_head))/1024);
61681 -       IP_VS_DBG(0, "Each connection entry needs %d bytes at least\n",
61682 +       IP_VS_DBG(0, "Each connection entry needs %Zd bytes at least\n",
61683                   sizeof(struct ip_vs_conn));
61684  
61685         for (idx = 0; idx < IP_VS_CONN_TAB_SIZE; idx++) {
61686 diff -Nru a/net/ipv4/ipvs/ip_vs_dh.c b/net/ipv4/ipvs/ip_vs_dh.c
61687 --- a/net/ipv4/ipvs/ip_vs_dh.c  Sat Jul 12 22:20:28 2003
61688 +++ b/net/ipv4/ipvs/ip_vs_dh.c  Thu Aug 28 01:21:50 2003
61689 @@ -147,7 +147,7 @@
61690                 return -ENOMEM;
61691         }
61692         svc->sched_data = tbl;
61693 -       IP_VS_DBG(6, "DH hash table (memory=%dbytes) allocated for "
61694 +       IP_VS_DBG(6, "DH hash table (memory=%Zdbytes) allocated for "
61695                   "current service\n",
61696                   sizeof(struct ip_vs_dh_bucket)*IP_VS_DH_TAB_SIZE);
61697  
61698 @@ -167,7 +167,7 @@
61699  
61700         /* release the table itself */
61701         kfree(svc->sched_data);
61702 -       IP_VS_DBG(6, "DH hash table (memory=%dbytes) released\n",
61703 +       IP_VS_DBG(6, "DH hash table (memory=%Zdbytes) released\n",
61704                   sizeof(struct ip_vs_dh_bucket)*IP_VS_DH_TAB_SIZE);
61705  
61706         return 0;
61707 diff -Nru a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
61708 --- a/net/ipv4/ipvs/ip_vs_lblc.c        Sat Jul 12 22:20:28 2003
61709 +++ b/net/ipv4/ipvs/ip_vs_lblc.c        Thu Aug 28 01:21:50 2003
61710 @@ -396,7 +396,7 @@
61711                 return -ENOMEM;
61712         }
61713         svc->sched_data = tbl;
61714 -       IP_VS_DBG(6, "LBLC hash table (memory=%dbytes) allocated for "
61715 +       IP_VS_DBG(6, "LBLC hash table (memory=%Zdbytes) allocated for "
61716                   "current service\n",
61717                   sizeof(struct ip_vs_lblc_table));
61718  
61719 @@ -436,7 +436,7 @@
61720  
61721         /* release the table itself */
61722         kfree(svc->sched_data);
61723 -       IP_VS_DBG(6, "LBLC hash table (memory=%dbytes) released\n",
61724 +       IP_VS_DBG(6, "LBLC hash table (memory=%Zdbytes) released\n",
61725                   sizeof(struct ip_vs_lblc_table));
61726  
61727         return 0;
61728 diff -Nru a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
61729 --- a/net/ipv4/ipvs/ip_vs_lblcr.c       Sat Jul 12 22:20:28 2003
61730 +++ b/net/ipv4/ipvs/ip_vs_lblcr.c       Thu Aug 28 01:21:50 2003
61731 @@ -649,7 +649,7 @@
61732                 return -ENOMEM;
61733         }
61734         svc->sched_data = tbl;
61735 -       IP_VS_DBG(6, "LBLCR hash table (memory=%dbytes) allocated for "
61736 +       IP_VS_DBG(6, "LBLCR hash table (memory=%Zdbytes) allocated for "
61737                   "current service\n",
61738                   sizeof(struct ip_vs_lblcr_table));
61739  
61740 @@ -692,7 +692,7 @@
61741  
61742         /* release the table itself */
61743         kfree(svc->sched_data);
61744 -       IP_VS_DBG(6, "LBLCR hash table (memory=%dbytes) released\n",
61745 +       IP_VS_DBG(6, "LBLCR hash table (memory=%Zdbytes) released\n",
61746                   sizeof(struct ip_vs_lblcr_table));
61747  
61748         return 0;
61749 diff -Nru a/net/ipv4/ipvs/ip_vs_sh.c b/net/ipv4/ipvs/ip_vs_sh.c
61750 --- a/net/ipv4/ipvs/ip_vs_sh.c  Sat Jul 12 22:20:28 2003
61751 +++ b/net/ipv4/ipvs/ip_vs_sh.c  Thu Aug 28 01:21:50 2003
61752 @@ -144,7 +144,7 @@
61753                 return -ENOMEM;
61754         }
61755         svc->sched_data = tbl;
61756 -       IP_VS_DBG(6, "SH hash table (memory=%dbytes) allocated for "
61757 +       IP_VS_DBG(6, "SH hash table (memory=%Zdbytes) allocated for "
61758                   "current service\n",
61759                   sizeof(struct ip_vs_sh_bucket)*IP_VS_SH_TAB_SIZE);
61760  
61761 @@ -164,7 +164,7 @@
61762  
61763         /* release the table itself */
61764         kfree(svc->sched_data);
61765 -       IP_VS_DBG(6, "SH hash table (memory=%dbytes) released\n",
61766 +       IP_VS_DBG(6, "SH hash table (memory=%Zdbytes) released\n",
61767                   sizeof(struct ip_vs_sh_bucket)*IP_VS_SH_TAB_SIZE);
61768  
61769         return 0;
61770 diff -Nru a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
61771 --- a/net/ipv4/ipvs/ip_vs_sync.c        Sat Jul 12 22:20:28 2003
61772 +++ b/net/ipv4/ipvs/ip_vs_sync.c        Thu Aug 28 01:21:50 2003
61773 @@ -851,7 +851,7 @@
61774                 return -EEXIST;
61775  
61776         IP_VS_DBG(7, "%s: pid %d\n", __FUNCTION__, current->pid);
61777 -       IP_VS_DBG(7, "Each ip_vs_sync_conn entry need %d bytes\n",
61778 +       IP_VS_DBG(7, "Each ip_vs_sync_conn entry need %Zd bytes\n",
61779                   sizeof(struct ip_vs_sync_conn));
61780  
61781         ip_vs_sync_state |= state;
61782 diff -Nru a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
61783 --- a/net/ipv4/netfilter/Kconfig        Wed Jun 25 23:28:43 2003
61784 +++ b/net/ipv4/netfilter/Kconfig        Mon Sep  1 01:44:26 2003
61785 @@ -74,8 +74,7 @@
61786           <file:Documentation/modules.txt>.  If unsure, say `Y'.
61787  
61788  config IP_NF_QUEUE
61789 -       tristate "Userspace queueing via NETLINK (EXPERIMENTAL)"
61790 -       depends on EXPERIMENTAL
61791 +       tristate "Userspace queueing via NETLINK"
61792         help
61793           Netfilter has the ability to queue packets to user space: the
61794           netlink device can be used to access them using this driver.
61795 @@ -106,6 +105,16 @@
61796           If you want to compile it as a module, say M here and read
61797           <file:Documentation/modules.txt>.  If unsure, say `N'.
61798  
61799 +config IP_NF_MATCH_IPRANGE
61800 +       tristate "IP range match support"
61801 +       depends on IP_NF_IPTABLES
61802 +       help
61803 +         This option makes possible to match IP addresses against IP address
61804 +         ranges.
61805 +
61806 +         If you want to compile it as a module, say M here and read
61807 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
61808 +
61809  config IP_NF_MATCH_MAC
61810         tristate "MAC address match support"
61811         depends on IP_NF_IPTABLES
61812 @@ -239,7 +248,7 @@
61813  
61814  config IP_NF_MATCH_HELPER
61815         tristate "Helper match support"
61816 -       depends on IP_NF_CONNTRACK!=n && IP_NF_IPTABLES
61817 +       depends on IP_NF_CONNTRACK && IP_NF_IPTABLES
61818         help
61819           Helper matching allows you to match packets in dynamic connections
61820           tracked by a conntrack-helper, ie. ip_conntrack_ftp
61821 @@ -271,19 +280,9 @@
61822           If you want to compile it as a module, say M here and read
61823           Documentation/modules.txt.  If unsure, say `N'.
61824  
61825 -config IP_NF_MATCH_UNCLEAN
61826 -       tristate "Unclean match support (EXPERIMENTAL)"
61827 -       depends on EXPERIMENTAL && IP_NF_IPTABLES
61828 -       help
61829 -         Unclean packet matching matches any strange or invalid packets, by
61830 -         looking at a series of fields in the IP, TCP, UDP and ICMP headers.
61831 -
61832 -         If you want to compile it as a module, say M here and read
61833 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
61834 -
61835  config IP_NF_MATCH_OWNER
61836 -       tristate "Owner match support (EXPERIMENTAL)"
61837 -       depends on EXPERIMENTAL && IP_NF_IPTABLES
61838 +       tristate "Owner match support"
61839 +       depends on IP_NF_IPTABLES
61840         help
61841           Packet owner matching allows you to match locally-generated packets
61842           based on who created them: the user, group, process or session.
61843 @@ -293,7 +292,7 @@
61844  
61845  config IP_NF_MATCH_PHYSDEV
61846         tristate "Physdev match support"
61847 -       depends on IP_NF_IPTABLES!=n && BRIDGE!=n
61848 +       depends on IP_NF_IPTABLES!=n && BRIDGE_NETFILTER
61849         help
61850           Physdev packet matching matches against the physical bridge ports
61851           the IP packet arrived on or will leave by.
61852 @@ -324,16 +323,6 @@
61853           If you want to compile it as a module, say M here and read
61854           <file:Documentation/modules.txt>.  If unsure, say `N'.
61855  
61856 -config IP_NF_TARGET_MIRROR
61857 -       tristate "MIRROR target support (EXPERIMENTAL)"
61858 -       depends on EXPERIMENTAL && IP_NF_FILTER
61859 -       help
61860 -         The MIRROR target allows a filtering rule to specify that an
61861 -         incoming packet should be bounced back to the sender.
61862 -
61863 -         If you want to compile it as a module, say M here and read
61864 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
61865 -
61866  config IP_NF_NAT
61867         tristate "Full NAT"
61868         depends on IP_NF_IPTABLES && IP_NF_CONNTRACK
61869 @@ -375,6 +364,28 @@
61870           If you want to compile it as a module, say M here and read
61871           <file:Documentation/modules.txt>.  If unsure, say `N'.
61872  
61873 +config IP_NF_TARGET_NETMAP
61874 +       tristate "NETMAP target support"
61875 +       depends on IP_NF_NAT
61876 +       help
61877 +         NETMAP is an implementation of static 1:1 NAT mapping of network
61878 +         addresses. It maps the network address part, while keeping the host
61879 +         address part intact. It is similar to Fast NAT, except that
61880 +         Netfilter's connection tracking doesn't work well with Fast NAT.
61881 +
61882 +         If you want to compile it as a module, say M here and read
61883 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
61884 +
61885 +config IP_NF_TARGET_SAME
61886 +       tristate "SAME target support"
61887 +       depends on IP_NF_NAT
61888 +       help
61889 +         This option adds a `SAME' target, which works like the standard SNAT
61890 +         target, but attempts to give clients the same IP for all connections.
61891 +
61892 +         If you want to compile it as a module, say M here and read
61893 +         Documentation/modules.txt.  If unsure, say `N'.
61894 +
61895  config IP_NF_NAT_LOCAL
61896         bool "NAT of local connections (READ HELP)"
61897         depends on IP_NF_NAT
61898 @@ -490,6 +501,19 @@
61899           the routing method (see `Use netfilter MARK value as routing
61900           key') and can also be used by other subsystems to change their
61901           behavior.
61902 +
61903 +         If you want to compile it as a module, say M here and read
61904 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
61905 +
61906 +config IP_NF_TARGET_CLASSIFY
61907 +       tristate "CLASSIFY target support"
61908 +       depends on IP_NF_MANGLE
61909 +       help
61910 +         This option adds a `CLASSIFY' target, which enables the user to set
61911 +         the priority of a packet. Some qdiscs can use this value for
61912 +         classification, among these are:
61913 +
61914 +         atm, cbq, dsmark, pfifo_fast, htb, prio
61915  
61916           If you want to compile it as a module, say M here and read
61917           <file:Documentation/modules.txt>.  If unsure, say `N'.
61918 diff -Nru a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
61919 --- a/net/ipv4/netfilter/Makefile       Wed Jun 25 23:28:43 2003
61920 +++ b/net/ipv4/netfilter/Makefile       Sun Aug 24 17:25:23 2003
61921 @@ -44,6 +44,7 @@
61922  obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o
61923  obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o
61924  obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o
61925 +obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o
61926  
61927  obj-$(CONFIG_IP_NF_MATCH_PKTTYPE) += ipt_pkttype.o
61928  obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o
61929 @@ -61,20 +62,21 @@
61930  obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
61931  obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o
61932  obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o
61933 -obj-$(CONFIG_IP_NF_MATCH_UNCLEAN) += ipt_unclean.o
61934  obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o
61935  
61936  obj-$(CONFIG_IP_NF_MATCH_PHYSDEV) += ipt_physdev.o
61937  
61938  # targets
61939  obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
61940 -obj-$(CONFIG_IP_NF_TARGET_MIRROR) += ipt_MIRROR.o
61941  obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
61942  obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
61943  obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o
61944  obj-$(CONFIG_IP_NF_TARGET_MARK) += ipt_MARK.o
61945  obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
61946  obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
61947 +obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
61948 +obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o
61949 +obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o
61950  obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
61951  obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
61952  obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
61953 diff -Nru a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
61954 --- a/net/ipv4/netfilter/arp_tables.c   Sat Aug  2 18:29:28 2003
61955 +++ b/net/ipv4/netfilter/arp_tables.c   Sun Aug 24 05:00:28 2003
61956 @@ -25,6 +25,10 @@
61957  
61958  #include <linux/netfilter_arp/arp_tables.h>
61959  
61960 +MODULE_LICENSE("GPL");
61961 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
61962 +MODULE_DESCRIPTION("arptables core");
61963 +
61964  /*#define DEBUG_ARP_TABLES*/
61965  /*#define DEBUG_ARP_TABLES_USER*/
61966  
61967 @@ -1324,4 +1328,3 @@
61968  
61969  module_init(init);
61970  module_exit(fini);
61971 -MODULE_LICENSE("GPL");
61972 diff -Nru a/net/ipv4/netfilter/arpt_mangle.c b/net/ipv4/netfilter/arpt_mangle.c
61973 --- a/net/ipv4/netfilter/arpt_mangle.c  Wed Jun 25 23:28:48 2003
61974 +++ b/net/ipv4/netfilter/arpt_mangle.c  Sun Aug 24 05:00:28 2003
61975 @@ -3,6 +3,10 @@
61976  #include <linux/netfilter_arp/arpt_mangle.h>
61977  #include <net/sock.h>
61978  
61979 +MODULE_LICENSE("GPL");
61980 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
61981 +MODULE_DESCRIPTION("arptables mangle table");
61982 +
61983  static unsigned int
61984  target(struct sk_buff **pskb, unsigned int hooknum, const struct net_device *in,
61985     const struct net_device *out, const void *targinfo, void *userinfo)
61986 @@ -98,4 +102,3 @@
61987  
61988  module_init(init);
61989  module_exit(fini);
61990 -MODULE_LICENSE("GPL");
61991 diff -Nru a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
61992 --- a/net/ipv4/netfilter/arptable_filter.c      Thu Jun 19 12:42:06 2003
61993 +++ b/net/ipv4/netfilter/arptable_filter.c      Sun Aug 24 05:00:28 2003
61994 @@ -8,6 +8,10 @@
61995  #include <linux/module.h>
61996  #include <linux/netfilter_arp/arp_tables.h>
61997  
61998 +MODULE_LICENSE("GPL");
61999 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
62000 +MODULE_DESCRIPTION("arptables filter table");
62001 +
62002  #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \
62003                            (1 << NF_ARP_FORWARD))
62004  
62005 @@ -209,4 +213,3 @@
62006  
62007  module_init(init);
62008  module_exit(fini);
62009 -MODULE_LICENSE("GPL");
62010 diff -Nru a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
62011 --- a/net/ipv4/netfilter/ip_conntrack_core.c    Sat Aug  2 18:29:28 2003
62012 +++ b/net/ipv4/netfilter/ip_conntrack_core.c    Sat Aug 30 20:35:04 2003
62013 @@ -13,7 +13,6 @@
62014   *     - export ip_conntrack[_expect]_{find_get,put} functions
62015   * */
62016  
62017 -#include <linux/version.h>
62018  #include <linux/config.h>
62019  #include <linux/types.h>
62020  #include <linux/icmp.h>
62021 @@ -285,14 +284,15 @@
62022  static void
62023  clean_from_lists(struct ip_conntrack *ct)
62024  {
62025 +       unsigned int ho, hr;
62026 +       
62027         DEBUGP("clean_from_lists(%p)\n", ct);
62028         MUST_BE_WRITE_LOCKED(&ip_conntrack_lock);
62029 -       LIST_DELETE(&ip_conntrack_hash
62030 -                   [hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple)],
62031 -                   &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
62032 -       LIST_DELETE(&ip_conntrack_hash
62033 -                   [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)],
62034 -                   &ct->tuplehash[IP_CT_DIR_REPLY]);
62035 +
62036 +       ho = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
62037 +       hr = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
62038 +       LIST_DELETE(&ip_conntrack_hash[ho], &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
62039 +       LIST_DELETE(&ip_conntrack_hash[hr], &ct->tuplehash[IP_CT_DIR_REPLY]);
62040  
62041         /* Destroy all un-established, pending expectations */
62042         remove_expectations(ct, 1);
62043 @@ -364,9 +364,10 @@
62044                     const struct ip_conntrack *ignored_conntrack)
62045  {
62046         struct ip_conntrack_tuple_hash *h;
62047 +       unsigned int hash = hash_conntrack(tuple);
62048  
62049         MUST_BE_READ_LOCKED(&ip_conntrack_lock);
62050 -       h = LIST_FIND(&ip_conntrack_hash[hash_conntrack(tuple)],
62051 +       h = LIST_FIND(&ip_conntrack_hash[hash],
62052                       conntrack_tuple_cmp,
62053                       struct ip_conntrack_tuple_hash *,
62054                       tuple, ignored_conntrack);
62055 diff -Nru a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
62056 --- a/net/ipv4/netfilter/ip_conntrack_ftp.c     Sat Aug  2 18:29:28 2003
62057 +++ b/net/ipv4/netfilter/ip_conntrack_ftp.c     Sun Aug 24 05:00:28 2003
62058 @@ -11,6 +11,10 @@
62059  #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
62060  #include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
62061  
62062 +MODULE_LICENSE("GPL");
62063 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
62064 +MODULE_DESCRIPTION("ftp connection tracking helper");
62065 +
62066  /* This is slow, but it's simple. --RR */
62067  static char ftp_buffer[65536];
62068  
62069 @@ -439,6 +443,5 @@
62070  PROVIDES_CONNTRACK(ftp);
62071  EXPORT_SYMBOL(ip_ftp_lock);
62072  
62073 -MODULE_LICENSE("GPL");
62074  module_init(init);
62075  module_exit(fini);
62076 diff -Nru a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
62077 --- a/net/ipv4/netfilter/ip_conntrack_irc.c     Sat Aug  2 18:29:28 2003
62078 +++ b/net/ipv4/netfilter/ip_conntrack_irc.c     Sun Aug 24 05:00:28 2003
62079 @@ -41,8 +41,8 @@
62080  /* This is slow, but it's simple. --RR */
62081  static char irc_buffer[65536];
62082  
62083 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
62084 -MODULE_DESCRIPTION("IRC (DCC) connection tracking module");
62085 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
62086 +MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
62087  MODULE_LICENSE("GPL");
62088  #ifdef MODULE_PARM
62089  MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
62090 diff -Nru a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
62091 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c      Mon Apr 28 02:27:56 2003
62092 +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c      Sat Aug 30 20:35:04 2003
62093 @@ -14,7 +14,6 @@
62094  #include <linux/module.h>
62095  #include <linux/skbuff.h>
62096  #include <linux/proc_fs.h>
62097 -#include <linux/version.h>
62098  #include <net/checksum.h>
62099  
62100  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock)
62101 diff -Nru a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
62102 --- a/net/ipv4/netfilter/ip_conntrack_tftp.c    Sat Aug  2 18:29:28 2003
62103 +++ b/net/ipv4/netfilter/ip_conntrack_tftp.c    Sun Aug 24 05:00:28 2003
62104 @@ -17,7 +17,7 @@
62105  #include <linux/netfilter_ipv4/ip_conntrack_tftp.h>
62106  
62107  MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
62108 -MODULE_DESCRIPTION("Netfilter connection tracking module for tftp");
62109 +MODULE_DESCRIPTION("tftp connection tracking helper");
62110  MODULE_LICENSE("GPL");
62111  
62112  #define MAX_PORTS 8
62113 @@ -44,7 +44,7 @@
62114  
62115         if (skb_copy_bits(skb, skb->nh.iph->ihl * 4 + sizeof(struct udphdr),
62116                           &tftph, sizeof(tftph)) != 0)
62117 -               return -1;
62118 +               return NF_ACCEPT;
62119  
62120         switch (ntohs(tftph.opcode)) {
62121         /* RRQ and WRQ works the same way */
62122 diff -Nru a/net/ipv4/netfilter/ip_fw_compat_masq.c b/net/ipv4/netfilter/ip_fw_compat_masq.c
62123 --- a/net/ipv4/netfilter/ip_fw_compat_masq.c    Sun May 11 22:12:07 2003
62124 +++ b/net/ipv4/netfilter/ip_fw_compat_masq.c    Sat Aug 30 20:35:04 2003
62125 @@ -13,7 +13,6 @@
62126  #include <linux/netdevice.h>
62127  #include <linux/inetdevice.h>
62128  #include <linux/proc_fs.h>
62129 -#include <linux/version.h>
62130  #include <linux/module.h>
62131  #include <net/route.h>
62132  
62133 diff -Nru a/net/ipv4/netfilter/ip_nat_amanda.c b/net/ipv4/netfilter/ip_nat_amanda.c
62134 --- a/net/ipv4/netfilter/ip_nat_amanda.c        Tue Jun 24 15:34:39 2003
62135 +++ b/net/ipv4/netfilter/ip_nat_amanda.c        Sun Aug 24 05:00:28 2003
62136 @@ -35,7 +35,7 @@
62137  #endif
62138  
62139  MODULE_AUTHOR("Brian J. Murrell <netfilter@interlinx.bc.ca>");
62140 -MODULE_DESCRIPTION("Amanda network address translation module");
62141 +MODULE_DESCRIPTION("Amanda NAT helper");
62142  MODULE_LICENSE("GPL");
62143  
62144  /* protects amanda part of conntracks */
62145 diff -Nru a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
62146 --- a/net/ipv4/netfilter/ip_nat_core.c  Sat Aug  2 18:29:28 2003
62147 +++ b/net/ipv4/netfilter/ip_nat_core.c  Sat Aug 30 20:35:04 2003
62148 @@ -2,7 +2,6 @@
62149  
62150  /* (c) 1999 Paul `Rusty' Russell.  Licenced under the GNU General
62151     Public Licence. */
62152 -#include <linux/version.h>
62153  #include <linux/module.h>
62154  #include <linux/types.h>
62155  #include <linux/timer.h>
62156 @@ -68,6 +67,7 @@
62157  static void ip_nat_cleanup_conntrack(struct ip_conntrack *conn)
62158  {
62159         struct ip_nat_info *info = &conn->nat.info;
62160 +       unsigned int hs, hp;
62161  
62162         if (!info->initialized)
62163                 return;
62164 @@ -75,21 +75,18 @@
62165         IP_NF_ASSERT(info->bysource.conntrack);
62166         IP_NF_ASSERT(info->byipsproto.conntrack);
62167  
62168 +       hs = hash_by_src(&conn->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src,
62169 +                        conn->tuplehash[IP_CT_DIR_ORIGINAL]
62170 +                        .tuple.dst.protonum);
62171 +
62172 +       hp = hash_by_ipsproto(conn->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip,
62173 +                             conn->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip,
62174 +                             conn->tuplehash[IP_CT_DIR_REPLY]
62175 +                             .tuple.dst.protonum);
62176 +
62177         WRITE_LOCK(&ip_nat_lock);
62178 -       LIST_DELETE(&bysource[hash_by_src(&conn->tuplehash[IP_CT_DIR_ORIGINAL]
62179 -                                         .tuple.src,
62180 -                                         conn->tuplehash[IP_CT_DIR_ORIGINAL]
62181 -                                         .tuple.dst.protonum)],
62182 -                   &info->bysource);
62183 -
62184 -       LIST_DELETE(&byipsproto
62185 -                   [hash_by_ipsproto(conn->tuplehash[IP_CT_DIR_REPLY]
62186 -                                     .tuple.src.ip,
62187 -                                     conn->tuplehash[IP_CT_DIR_REPLY]
62188 -                                     .tuple.dst.ip,
62189 -                                     conn->tuplehash[IP_CT_DIR_REPLY]
62190 -                                     .tuple.dst.protonum)],
62191 -                   &info->byipsproto);
62192 +       LIST_DELETE(&bysource[hs], &info->bysource);
62193 +       LIST_DELETE(&byipsproto[hp], &info->byipsproto);
62194         WRITE_UNLOCK(&ip_nat_lock);
62195  }
62196  
62197 @@ -246,11 +243,12 @@
62198            const struct ip_conntrack *conntrack)
62199  {
62200         unsigned int score = 0;
62201 +       unsigned int h;
62202  
62203         MUST_BE_READ_LOCKED(&ip_nat_lock);
62204 -       LIST_FIND(&byipsproto[hash_by_ipsproto(src, dst, protonum)],
62205 -                 fake_cmp, struct ip_nat_hash *, src, dst, protonum, &score,
62206 -                 conntrack);
62207 +       h = hash_by_ipsproto(src, dst, protonum);
62208 +       LIST_FIND(&byipsproto[h], fake_cmp, struct ip_nat_hash *,
62209 +                 src, dst, protonum, &score, conntrack);
62210  
62211         return score;
62212  }
62213 diff -Nru a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c
62214 --- a/net/ipv4/netfilter/ip_nat_ftp.c   Sat Aug  2 18:29:28 2003
62215 +++ b/net/ipv4/netfilter/ip_nat_ftp.c   Sun Aug 24 05:00:28 2003
62216 @@ -10,6 +10,10 @@
62217  #include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
62218  #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
62219  
62220 +MODULE_LICENSE("GPL");
62221 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
62222 +MODULE_DESCRIPTION("ftp NAT helper");
62223 +
62224  #if 0
62225  #define DEBUGP printk
62226  #else
62227 @@ -342,4 +346,3 @@
62228  
62229  module_init(init);
62230  module_exit(fini);
62231 -MODULE_LICENSE("GPL");
62232 diff -Nru a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c
62233 --- a/net/ipv4/netfilter/ip_nat_helper.c        Thu Jul 17 14:50:26 2003
62234 +++ b/net/ipv4/netfilter/ip_nat_helper.c        Sat Aug 30 20:35:04 2003
62235 @@ -12,7 +12,6 @@
62236   *             - make ip_nat_resize_packet more generic (TCP and UDP)
62237   *             - add ip_nat_mangle_udp_packet
62238   */
62239 -#include <linux/version.h>
62240  #include <linux/config.h>
62241  #include <linux/module.h>
62242  #include <linux/kmod.h>
62243 diff -Nru a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc.c
62244 --- a/net/ipv4/netfilter/ip_nat_irc.c   Sat Aug  2 18:29:28 2003
62245 +++ b/net/ipv4/netfilter/ip_nat_irc.c   Sun Aug 24 05:00:28 2003
62246 @@ -39,7 +39,7 @@
62247  static int ports_c;
62248  
62249  MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
62250 -MODULE_DESCRIPTION("IRC (DCC) network address translation module");
62251 +MODULE_DESCRIPTION("IRC (DCC) NAT helper");
62252  MODULE_LICENSE("GPL");
62253  #ifdef MODULE_PARM
62254  MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
62255 diff -Nru a/net/ipv4/netfilter/ip_nat_rule.c b/net/ipv4/netfilter/ip_nat_rule.c
62256 --- a/net/ipv4/netfilter/ip_nat_rule.c  Wed May 21 16:29:38 2003
62257 +++ b/net/ipv4/netfilter/ip_nat_rule.c  Sat Aug 30 20:35:04 2003
62258 @@ -9,7 +9,6 @@
62259  #include <linux/proc_fs.h>
62260  #include <net/checksum.h>
62261  #include <linux/bitops.h>
62262 -#include <linux/version.h>
62263  
62264  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock)
62265  #define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock)
62266 diff -Nru a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
62267 --- a/net/ipv4/netfilter/ip_nat_snmp_basic.c    Sat Aug  2 18:29:28 2003
62268 +++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c    Sun Aug 24 05:00:28 2003
62269 @@ -56,7 +56,9 @@
62270  #include <asm/uaccess.h>
62271  #include <asm/checksum.h>
62272  
62273 -
62274 +MODULE_LICENSE("GPL");
62275 +MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
62276 +MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
62277  
62278  #define SNMP_PORT 161
62279  #define SNMP_TRAP_PORT 162
62280 @@ -1357,5 +1359,3 @@
62281  module_exit(fini);
62282  
62283  MODULE_PARM(debug, "i");
62284 -MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
62285 -MODULE_LICENSE("GPL");
62286 diff -Nru a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
62287 --- a/net/ipv4/netfilter/ip_nat_standalone.c    Sat May 17 22:10:44 2003
62288 +++ b/net/ipv4/netfilter/ip_nat_standalone.c    Sat Aug 30 20:35:04 2003
62289 @@ -23,7 +23,6 @@
62290  #include <linux/proc_fs.h>
62291  #include <net/checksum.h>
62292  #include <linux/spinlock.h>
62293 -#include <linux/version.h>
62294  
62295  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock)
62296  #define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock)
62297 diff -Nru a/net/ipv4/netfilter/ip_nat_tftp.c b/net/ipv4/netfilter/ip_nat_tftp.c
62298 --- a/net/ipv4/netfilter/ip_nat_tftp.c  Tue May  6 01:04:01 2003
62299 +++ b/net/ipv4/netfilter/ip_nat_tftp.c  Sun Aug 24 05:00:28 2003
62300 @@ -30,7 +30,7 @@
62301  #include <linux/netfilter_ipv4/ip_nat_rule.h>
62302  
62303  MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
62304 -MODULE_DESCRIPTION("Netfilter NAT helper for tftp");
62305 +MODULE_DESCRIPTION("tfpt NAT helper");
62306  MODULE_LICENSE("GPL");
62307  
62308  #define MAX_PORTS 8
62309 diff -Nru a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
62310 --- a/net/ipv4/netfilter/ip_tables.c    Sat Aug  2 18:29:28 2003
62311 +++ b/net/ipv4/netfilter/ip_tables.c    Sun Aug 24 05:00:28 2003
62312 @@ -25,6 +25,10 @@
62313  
62314  #include <linux/netfilter_ipv4/ip_tables.h>
62315  
62316 +MODULE_LICENSE("GPL");
62317 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
62318 +MODULE_DESCRIPTION("IPv4 packet filter");
62319 +
62320  /*#define DEBUG_IP_FIREWALL*/
62321  /*#define DEBUG_ALLOW_ALL*/ /* Useful for remote debugging */
62322  /*#define DEBUG_IP_FIREWALL_USER*/
62323 @@ -1845,4 +1849,3 @@
62324  
62325  module_init(init);
62326  module_exit(fini);
62327 -MODULE_LICENSE("GPL");
62328 diff -Nru a/net/ipv4/netfilter/ipchains_core.c b/net/ipv4/netfilter/ipchains_core.c
62329 --- a/net/ipv4/netfilter/ipchains_core.c        Wed Jun  4 17:57:08 2003
62330 +++ b/net/ipv4/netfilter/ipchains_core.c        Sun Aug 24 05:00:28 2003
62331 @@ -100,6 +100,9 @@
62332  #include <linux/proc_fs.h>
62333  #include <linux/stat.h>
62334  
62335 +MODULE_LICENSE("Dual BSD/GPL");
62336 +MODULE_DESCRIPTION("ipchains backwards compatibility layer");
62337 +
62338  /* Understanding locking in this code: (thanks to Alan Cox for using
62339   * little words to explain this to me). -- PR
62340   *
62341 @@ -1842,4 +1845,3 @@
62342  #endif
62343         return ret;
62344  }
62345 -MODULE_LICENSE("Dual BSD/GPL");
62346 diff -Nru a/net/ipv4/netfilter/ipfwadm_core.c b/net/ipv4/netfilter/ipfwadm_core.c
62347 --- a/net/ipv4/netfilter/ipfwadm_core.c Wed Jun  4 17:57:08 2003
62348 +++ b/net/ipv4/netfilter/ipfwadm_core.c Sat Aug 30 20:35:04 2003
62349 @@ -131,9 +131,9 @@
62350  #include <net/checksum.h>
62351  #include <linux/proc_fs.h>
62352  #include <linux/stat.h>
62353 -#include <linux/version.h>
62354  
62355  MODULE_LICENSE("Dual BSD/GPL");
62356 +MODULE_DESCRIPTION("ipfwadm backwards compatibility layer");
62357  
62358  /*
62359   *     Implement IP packet firewall
62360 diff -Nru a/net/ipv4/netfilter/ipt_CLASSIFY.c b/net/ipv4/netfilter/ipt_CLASSIFY.c
62361 --- /dev/null   Wed Dec 31 16:00:00 1969
62362 +++ b/net/ipv4/netfilter/ipt_CLASSIFY.c Sun Aug 24 19:51:27 2003
62363 @@ -0,0 +1,86 @@
62364 +/*
62365 + * This is a module which is used for setting the skb->priority field
62366 + * of an skb for qdisc classification.
62367 + */
62368 +
62369 +#include <linux/module.h>
62370 +#include <linux/skbuff.h>
62371 +#include <linux/ip.h>
62372 +#include <net/checksum.h>
62373 +
62374 +#include <linux/netfilter_ipv4/ip_tables.h>
62375 +#include <linux/netfilter_ipv4/ipt_CLASSIFY.h>
62376 +
62377 +MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
62378 +MODULE_LICENSE("GPL");
62379 +MODULE_DESCRIPTION("iptables qdisc classification target module");
62380 +
62381 +static unsigned int
62382 +target(struct sk_buff **pskb,
62383 +       const struct net_device *in,
62384 +       const struct net_device *out,
62385 +       unsigned int hooknum,
62386 +       const void *targinfo,
62387 +       void *userinfo)
62388 +{
62389 +       const struct ipt_classify_target_info *clinfo = targinfo;
62390 +
62391 +       if((*pskb)->priority != clinfo->priority) {
62392 +               (*pskb)->priority = clinfo->priority;
62393 +               (*pskb)->nfcache |= NFC_ALTERED;
62394 +       }
62395 +
62396 +       return IPT_CONTINUE;
62397 +}
62398 +
62399 +static int
62400 +checkentry(const char *tablename,
62401 +           const struct ipt_entry *e,
62402 +           void *targinfo,
62403 +           unsigned int targinfosize,
62404 +           unsigned int hook_mask)
62405 +{
62406 +       if (targinfosize != IPT_ALIGN(sizeof(struct ipt_classify_target_info))){
62407 +               printk(KERN_ERR "CLASSIFY: invalid size (%u != %Zu).\n",
62408 +                      targinfosize,
62409 +                      IPT_ALIGN(sizeof(struct ipt_classify_target_info)));
62410 +               return 0;
62411 +       }
62412 +       
62413 +       if (hook_mask & ~(1 << NF_IP_POST_ROUTING)) {
62414 +               printk(KERN_ERR "CLASSIFY: only valid in POST_ROUTING.\n");
62415 +               return 0;
62416 +       }
62417 +
62418 +       if (strcmp(tablename, "mangle") != 0) {
62419 +               printk(KERN_WARNING "CLASSIFY: can only be called from "
62420 +                                   "\"mangle\" table, not \"%s\".\n",
62421 +                                   tablename);
62422 +               return 0;
62423 +       }
62424 +
62425 +       return 1;
62426 +}
62427 +
62428 +static struct ipt_target ipt_classify_reg = { 
62429 +       .name           = "CLASSIFY", 
62430 +       .target         = target,
62431 +       .checkentry     = checkentry,
62432 +       .me             = THIS_MODULE,
62433 +};
62434 +
62435 +static int __init init(void)
62436 +{
62437 +       if (ipt_register_target(&ipt_classify_reg))
62438 +               return -EINVAL;
62439 +
62440 +       return 0;
62441 +}
62442 +
62443 +static void __exit fini(void)
62444 +{
62445 +       ipt_unregister_target(&ipt_classify_reg);
62446 +}
62447 +
62448 +module_init(init);
62449 +module_exit(fini);
62450 diff -Nru a/net/ipv4/netfilter/ipt_DSCP.c b/net/ipv4/netfilter/ipt_DSCP.c
62451 --- a/net/ipv4/netfilter/ipt_DSCP.c     Wed May 21 16:36:54 2003
62452 +++ b/net/ipv4/netfilter/ipt_DSCP.c     Sun Aug 24 05:00:28 2003
62453 @@ -17,8 +17,8 @@
62454  #include <linux/netfilter_ipv4/ip_tables.h>
62455  #include <linux/netfilter_ipv4/ipt_DSCP.h>
62456  
62457 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
62458 -MODULE_DESCRIPTION("IP tables DSCP modification module");
62459 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
62460 +MODULE_DESCRIPTION("iptables DSCP modification module");
62461  MODULE_LICENSE("GPL");
62462  
62463  static unsigned int
62464 diff -Nru a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c
62465 --- a/net/ipv4/netfilter/ipt_ECN.c      Wed May 21 16:36:54 2003
62466 +++ b/net/ipv4/netfilter/ipt_ECN.c      Sun Aug 24 05:00:28 2003
62467 @@ -17,6 +17,8 @@
62468  #include <linux/netfilter_ipv4/ipt_ECN.h>
62469  
62470  MODULE_LICENSE("GPL");
62471 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
62472 +MODULE_DESCRIPTION("iptables ECN modification module");
62473  
62474  /* set ECT codepoint from IP header.
62475   *     return 0 if there was an error. */
62476 diff -Nru a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
62477 --- a/net/ipv4/netfilter/ipt_LOG.c      Sat Aug  2 22:47:01 2003
62478 +++ b/net/ipv4/netfilter/ipt_LOG.c      Mon Sep  1 01:44:26 2003
62479 @@ -13,6 +13,10 @@
62480  #include <linux/netfilter_ipv4/ip_tables.h>
62481  #include <linux/netfilter_ipv4/ipt_LOG.h>
62482  
62483 +MODULE_LICENSE("GPL");
62484 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
62485 +MODULE_DESCRIPTION("iptables syslog logging module");
62486 +
62487  #if 0
62488  #define DEBUGP printk
62489  #else
62490 @@ -329,7 +333,7 @@
62491                loginfo->prefix,
62492                in ? in->name : "",
62493                out ? out->name : "");
62494 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
62495 +#ifdef CONFIG_BRIDGE_NETFILTER
62496         if ((*pskb)->nf_bridge) {
62497                 struct net_device *physindev = (*pskb)->nf_bridge->physindev;
62498                 struct net_device *physoutdev = (*pskb)->nf_bridge->physoutdev;
62499 @@ -413,4 +417,3 @@
62500  
62501  module_init(init);
62502  module_exit(fini);
62503 -MODULE_LICENSE("GPL");
62504 diff -Nru a/net/ipv4/netfilter/ipt_MARK.c b/net/ipv4/netfilter/ipt_MARK.c
62505 --- a/net/ipv4/netfilter/ipt_MARK.c     Wed May 21 16:36:54 2003
62506 +++ b/net/ipv4/netfilter/ipt_MARK.c     Sun Aug 24 05:00:28 2003
62507 @@ -7,6 +7,10 @@
62508  #include <linux/netfilter_ipv4/ip_tables.h>
62509  #include <linux/netfilter_ipv4/ipt_MARK.h>
62510  
62511 +MODULE_LICENSE("GPL");
62512 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
62513 +MODULE_DESCRIPTION("iptables MARK modification module");
62514 +
62515  static unsigned int
62516  target(struct sk_buff **pskb,
62517         const struct net_device *in,
62518 @@ -68,4 +72,3 @@
62519  
62520  module_init(init);
62521  module_exit(fini);
62522 -MODULE_LICENSE("GPL");
62523 diff -Nru a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
62524 --- a/net/ipv4/netfilter/ipt_MASQUERADE.c       Mon Aug 11 22:46:31 2003
62525 +++ b/net/ipv4/netfilter/ipt_MASQUERADE.c       Sun Aug 24 05:00:28 2003
62526 @@ -12,6 +12,10 @@
62527  #include <linux/netfilter_ipv4/ip_nat_rule.h>
62528  #include <linux/netfilter_ipv4/ip_tables.h>
62529  
62530 +MODULE_LICENSE("GPL");
62531 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
62532 +MODULE_DESCRIPTION("iptables MASQUERADE target module");
62533 +
62534  #if 0
62535  #define DEBUGP printk
62536  #else
62537 @@ -213,4 +217,3 @@
62538  
62539  module_init(init);
62540  module_exit(fini);
62541 -MODULE_LICENSE("GPL");
62542 diff -Nru a/net/ipv4/netfilter/ipt_MIRROR.c b/net/ipv4/netfilter/ipt_MIRROR.c
62543 --- a/net/ipv4/netfilter/ipt_MIRROR.c   Fri Jul 25 15:22:30 2003
62544 +++ /dev/null   Wed Dec 31 16:00:00 1969
62545 @@ -1,222 +0,0 @@
62546 -/*
62547 -  This is a module which is used for resending packets with inverted src and dst.
62548 -
62549 -  Based on code from: ip_nat_dumb.c,v 1.9 1999/08/20
62550 -  and various sources.
62551 -
62552 -  Copyright (C) 2000 Emmanuel Roger <winfield@freegates.be>
62553 -
62554 -  Changes:
62555 -       25 Aug 2001 Harald Welte <laforge@gnumonks.org>
62556 -               - decrement and check TTL if not called from FORWARD hook
62557 -       18 Jul 2003 Harald Welte <laforge@netfilter.org>
62558 -               - merge Patrick McHardy's mirror fixes from 2.4.22 to
62559 -                 2.6.0-test1
62560 -       19 Jul 2003 Harald Welte <laforge@netfilter.org>
62561 -               - merge Patrick McHardy's rp_filter fixes from 2.4.22 to
62562 -                 2.6.0-test1
62563 -
62564 -  This program is free software; you can redistribute it and/or modify it
62565 -  under the terms of the GNU General Public License as published by the
62566 -  Free Software Foundation; either version 2 of the License, or (at your
62567 -  option) any later version.
62568 -
62569 -  This program is distributed in the hope that it will be useful, but
62570 -  WITHOUT ANY WARRANTY; without even the implied warranty of
62571 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
62572 -  General Public License for more details.
62573 -
62574 -  You should have received a copy of the GNU General Public License
62575 -  along with this program; if not, write to the Free Software Foundation,
62576 -  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
62577 - */
62578 -#include <linux/module.h>
62579 -#include <linux/skbuff.h>
62580 -#include <linux/ip.h>
62581 -#include <net/ip.h>
62582 -#include <net/icmp.h>
62583 -#include <linux/netfilter_ipv4/ip_tables.h>
62584 -#include <linux/netdevice.h>
62585 -#include <linux/route.h>
62586 -#include <net/route.h>
62587 -
62588 -#if 0
62589 -#define DEBUGP printk
62590 -#else
62591 -#define DEBUGP(format, args...)
62592 -#endif
62593 -
62594 -static inline struct rtable *route_mirror(struct sk_buff *skb, int local)
62595 -{
62596 -        struct iphdr *iph = skb->nh.iph;
62597 -       struct dst_entry *odst;
62598 -       struct flowi fl = {};
62599 -       struct rtable *rt;
62600 -
62601 -       if (local) {
62602 -               fl.nl_u.ip4_u.daddr = iph->saddr;
62603 -               fl.nl_u.ip4_u.saddr = iph->daddr;
62604 -               fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
62605 -
62606 -               if (ip_route_output_key(&rt, &fl) != 0)
62607 -                       return NULL;
62608 -       } else {
62609 -               /* non-local src, find valid iif to satisfy
62610 -                * rp-filter when calling ip_route_input(). */
62611 -               fl.nl_u.ip4_u.daddr = iph->daddr;
62612 -               if (ip_route_output_key(&rt, &fl) != 0)
62613 -                       return NULL;
62614 -
62615 -               odst = skb->dst;
62616 -               if (ip_route_input(skb, iph->saddr, iph->daddr,
62617 -                                       RT_TOS(iph->tos), rt->u.dst.dev) != 0) {
62618 -                       dst_release(&rt->u.dst);
62619 -                       return NULL;
62620 -               }
62621 -               dst_release(&rt->u.dst);
62622 -               rt = (struct rtable *)skb->dst;
62623 -               skb->dst = odst;
62624 -       }
62625 -
62626 -       if (rt->u.dst.error) {
62627 -               dst_release(&rt->u.dst);
62628 -               rt = NULL;
62629 -       }
62630 -
62631 -       return rt;
62632 -}
62633 -
62634 -static inline void ip_rewrite(struct sk_buff *skb)
62635 -{
62636 -       u32 odaddr, osaddr;
62637 -
62638 -       odaddr = skb->nh.iph->saddr;
62639 -       osaddr = skb->nh.iph->daddr;
62640 -
62641 -       skb->nfcache |= NFC_ALTERED;
62642 -
62643 -       /* Rewrite IP header */
62644 -       skb->nh.iph->daddr = odaddr;
62645 -       skb->nh.iph->saddr = osaddr;
62646 -}
62647 -
62648 -/* Stolen from ip_finish_output2 */
62649 -static void ip_direct_send(struct sk_buff *skb)
62650 -{
62651 -       struct dst_entry *dst = skb->dst;
62652 -       struct hh_cache *hh = dst->hh;
62653 -
62654 -       if (hh) {
62655 -               int hh_alen;
62656 -
62657 -               read_lock_bh(&hh->hh_lock);
62658 -               hh_alen = HH_DATA_ALIGN(hh->hh_len);
62659 -               memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
62660 -               read_unlock_bh(&hh->hh_lock);
62661 -               skb_push(skb, hh->hh_len);
62662 -               hh->hh_output(skb);
62663 -       } else if (dst->neighbour)
62664 -               dst->neighbour->output(skb);
62665 -       else {
62666 -               printk(KERN_DEBUG "khm in MIRROR\n");
62667 -               kfree_skb(skb);
62668 -       }
62669 -}
62670 -
62671 -static unsigned int ipt_mirror_target(struct sk_buff **pskb,
62672 -                                     const struct net_device *in,
62673 -                                     const struct net_device *out,
62674 -                                     unsigned int hooknum,
62675 -                                     const void *targinfo,
62676 -                                     void *userinfo)
62677 -{
62678 -       struct rtable *rt;
62679 -       struct sk_buff *nskb;
62680 -       unsigned int hh_len;
62681 -
62682 -       /* Make skb writable */
62683 -       if (!skb_ip_make_writable(pskb, sizeof(struct iphdr)))
62684 -               return 0;
62685 -
62686 -       /* If we are not at FORWARD hook (INPUT/PREROUTING),
62687 -        * the TTL isn't decreased by the IP stack */
62688 -       if (hooknum != NF_IP_FORWARD) {
62689 -               if ((*pskb)->nh.iph->ttl <= 1) {
62690 -                       /* this will traverse normal stack, and 
62691 -                        * thus call conntrack on the icmp packet */
62692 -                       icmp_send(*pskb, ICMP_TIME_EXCEEDED, 
62693 -                                 ICMP_EXC_TTL, 0);
62694 -                       return NF_DROP;
62695 -               }
62696 -               ip_decrease_ttl((*pskb)->nh.iph);
62697 -       }
62698 -
62699 -       if ((rt = route_mirror(*pskb, hooknum == NF_IP_LOCAL_IN)) == NULL)
62700 -               return NF_DROP;
62701 -
62702 -       hh_len = (rt->u.dst.dev->hard_header_len + 15) & ~15;
62703 -
62704 -       /* Copy skb (even if skb is about to be dropped, we can't just
62705 -        * clone it because there may be other things, such as tcpdump,
62706 -        * interested in it). We also need to expand headroom in case
62707 -        * hh_len of incoming interface < hh_len of outgoing interface */
62708 -       nskb = skb_copy_expand(*pskb, hh_len, skb_tailroom(*pskb), GFP_ATOMIC);
62709 -       if (nskb == NULL) {
62710 -               dst_release(&rt->u.dst);
62711 -               return NF_DROP;
62712 -       }
62713 -
62714 -       dst_release(nskb->dst);
62715 -       nskb->dst = &rt->u.dst;
62716 -
62717 -       ip_rewrite(nskb);
62718 -       /* Don't let conntrack code see this packet:
62719 -        * it will think we are starting a new
62720 -        * connection! --RR */
62721 -       ip_direct_send(nskb);
62722 -
62723 -       return NF_DROP;
62724 -}
62725 -
62726 -static int ipt_mirror_checkentry(const char *tablename,
62727 -                                const struct ipt_entry *e,
62728 -                                void *targinfo,
62729 -                                unsigned int targinfosize,
62730 -                                unsigned int hook_mask)
62731 -{
62732 -       /* Only on INPUT, FORWARD or PRE_ROUTING, otherwise loop danger. */
62733 -       if (hook_mask & ~((1 << NF_IP_PRE_ROUTING)
62734 -                         | (1 << NF_IP_FORWARD)
62735 -                         | (1 << NF_IP_LOCAL_IN))) {
62736 -               DEBUGP("MIRROR: bad hook\n");
62737 -               return 0;
62738 -       }
62739 -
62740 -       if (targinfosize != IPT_ALIGN(0)) {
62741 -               DEBUGP("MIRROR: targinfosize %u != 0\n", targinfosize);
62742 -               return 0;
62743 -       }
62744 -
62745 -       return 1;
62746 -}
62747 -
62748 -static struct ipt_target ipt_mirror_reg = {
62749 -       .name           = "MIRROR",
62750 -       .target         = ipt_mirror_target,
62751 -       .checkentry     = ipt_mirror_checkentry,
62752 -       .me             = THIS_MODULE,
62753 -};
62754 -
62755 -static int __init init(void)
62756 -{
62757 -       return ipt_register_target(&ipt_mirror_reg);
62758 -}
62759 -
62760 -static void __exit fini(void)
62761 -{
62762 -       ipt_unregister_target(&ipt_mirror_reg);
62763 -}
62764 -
62765 -module_init(init);
62766 -module_exit(fini);
62767 -MODULE_LICENSE("GPL");
62768 diff -Nru a/net/ipv4/netfilter/ipt_NETMAP.c b/net/ipv4/netfilter/ipt_NETMAP.c
62769 --- /dev/null   Wed Dec 31 16:00:00 1969
62770 +++ b/net/ipv4/netfilter/ipt_NETMAP.c   Sun Aug 24 17:25:18 2003
62771 @@ -0,0 +1,112 @@
62772 +/* NETMAP - static NAT mapping of IP network addresses (1:1).
62773 +   The mapping can be applied to source (POSTROUTING),
62774 +   destination (PREROUTING), or both (with separate rules).
62775 +
62776 +   Author: Svenning Soerensen <svenning@post5.tele.dk>
62777 +*/
62778 +
62779 +#include <linux/config.h>
62780 +#include <linux/ip.h>
62781 +#include <linux/module.h>
62782 +#include <linux/netdevice.h>
62783 +#include <linux/netfilter.h>
62784 +#include <linux/netfilter_ipv4.h>
62785 +#include <linux/netfilter_ipv4/ip_nat_rule.h>
62786 +
62787 +#define MODULENAME "NETMAP"
62788 +MODULE_LICENSE("GPL");
62789 +MODULE_AUTHOR("Svenning Soerensen <svenning@post5.tele.dk>");
62790 +MODULE_DESCRIPTION("iptables 1:1 NAT mapping of IP networks target");
62791 +
62792 +#if 0
62793 +#define DEBUGP printk
62794 +#else
62795 +#define DEBUGP(format, args...)
62796 +#endif
62797 +
62798 +static int
62799 +check(const char *tablename,
62800 +      const struct ipt_entry *e,
62801 +      void *targinfo,
62802 +      unsigned int targinfosize,
62803 +      unsigned int hook_mask)
62804 +{
62805 +       const struct ip_nat_multi_range *mr = targinfo;
62806 +
62807 +       if (strcmp(tablename, "nat") != 0) {
62808 +               DEBUGP(MODULENAME":check: bad table `%s'.\n", tablename);
62809 +               return 0;
62810 +       }
62811 +       if (targinfosize != IPT_ALIGN(sizeof(*mr))) {
62812 +               DEBUGP(MODULENAME":check: size %u.\n", targinfosize);
62813 +               return 0;
62814 +       }
62815 +       if (hook_mask & ~((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_POST_ROUTING))) {
62816 +               DEBUGP(MODULENAME":check: bad hooks %x.\n", hook_mask);
62817 +               return 0;
62818 +       }
62819 +       if (!(mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)) {
62820 +               DEBUGP(MODULENAME":check: bad MAP_IPS.\n");
62821 +               return 0;
62822 +       }
62823 +       if (mr->rangesize != 1) {
62824 +               DEBUGP(MODULENAME":check: bad rangesize %u.\n", mr->rangesize);
62825 +               return 0;
62826 +       }
62827 +       return 1;
62828 +}
62829 +
62830 +static unsigned int
62831 +target(struct sk_buff **pskb,
62832 +       const struct net_device *in,
62833 +       const struct net_device *out,
62834 +       unsigned int hooknum,
62835 +       const void *targinfo,
62836 +       void *userinfo)
62837 +{
62838 +       struct ip_conntrack *ct;
62839 +       enum ip_conntrack_info ctinfo;
62840 +       u_int32_t new_ip, netmask;
62841 +       const struct ip_nat_multi_range *mr = targinfo;
62842 +       struct ip_nat_multi_range newrange;
62843 +
62844 +       IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING
62845 +                    || hooknum == NF_IP_POST_ROUTING);
62846 +       ct = ip_conntrack_get(*pskb, &ctinfo);
62847 +
62848 +       netmask = ~(mr->range[0].min_ip ^ mr->range[0].max_ip);
62849 +
62850 +       if (hooknum == NF_IP_PRE_ROUTING)
62851 +               new_ip = (*pskb)->nh.iph->daddr & ~netmask;
62852 +       else
62853 +               new_ip = (*pskb)->nh.iph->saddr & ~netmask;
62854 +       new_ip |= mr->range[0].min_ip & netmask;
62855 +
62856 +       newrange = ((struct ip_nat_multi_range)
62857 +       { 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
62858 +                new_ip, new_ip,
62859 +                mr->range[0].min, mr->range[0].max } } });
62860 +
62861 +       /* Hand modified range to generic setup. */
62862 +       return ip_nat_setup_info(ct, &newrange, hooknum);
62863 +}
62864 +
62865 +static struct ipt_target target_module = { 
62866 +       .name           = MODULENAME,
62867 +       .target         = target, 
62868 +       .checkentry     = check,
62869 +       .me             = THIS_MODULE 
62870 +};
62871 +
62872 +static int __init init(void)
62873 +{
62874 +       return ipt_register_target(&target_module);
62875 +}
62876 +
62877 +static void __exit fini(void)
62878 +{
62879 +       ipt_unregister_target(&target_module);
62880 +}
62881 +
62882 +module_init(init);
62883 +module_exit(fini);
62884 diff -Nru a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
62885 --- a/net/ipv4/netfilter/ipt_REDIRECT.c Wed May 21 16:36:54 2003
62886 +++ b/net/ipv4/netfilter/ipt_REDIRECT.c Sun Aug 24 05:00:28 2003
62887 @@ -12,6 +12,10 @@
62888  #include <linux/netfilter_ipv4.h>
62889  #include <linux/netfilter_ipv4/ip_nat_rule.h>
62890  
62891 +MODULE_LICENSE("GPL");
62892 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
62893 +MODULE_DESCRIPTION("iptables REDIRECT target module");
62894 +
62895  #if 0
62896  #define DEBUGP printk
62897  #else
62898 @@ -115,4 +119,3 @@
62899  
62900  module_init(init);
62901  module_exit(fini);
62902 -MODULE_LICENSE("GPL");
62903 diff -Nru a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
62904 --- a/net/ipv4/netfilter/ipt_REJECT.c   Sun Jul 27 16:03:33 2003
62905 +++ b/net/ipv4/netfilter/ipt_REJECT.c   Tue Sep  2 11:21:51 2003
62906 @@ -16,6 +16,10 @@
62907  #include <linux/netfilter_ipv4/ip_tables.h>
62908  #include <linux/netfilter_ipv4/ipt_REJECT.h>
62909  
62910 +MODULE_LICENSE("GPL");
62911 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
62912 +MODULE_DESCRIPTION("iptables REJECT target module");
62913 +
62914  #if 0
62915  #define DEBUGP printk
62916  #else
62917 @@ -137,6 +141,10 @@
62918         nskb->nf_debug = 0;
62919  #endif
62920         nskb->nfmark = 0;
62921 +#ifdef CONFIG_BRIDGE_NETFILTER
62922 +       nf_bridge_put(nskb->nf_bridge);
62923 +       nskb->nf_bridge = NULL;
62924 +#endif
62925  
62926         tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
62927  
62928 @@ -462,4 +470,3 @@
62929  
62930  module_init(init);
62931  module_exit(fini);
62932 -MODULE_LICENSE("GPL");
62933 diff -Nru a/net/ipv4/netfilter/ipt_SAME.c b/net/ipv4/netfilter/ipt_SAME.c
62934 --- /dev/null   Wed Dec 31 16:00:00 1969
62935 +++ b/net/ipv4/netfilter/ipt_SAME.c     Sun Aug 24 17:25:18 2003
62936 @@ -0,0 +1,206 @@
62937 +/* Same.  Just like SNAT, only try to make the connections
62938 + *       between client A and server B always have the same source ip.
62939 + *
62940 + * (C) 2000 Rusty Russell.  GPL.
62941 + *
62942 + * 010320 Martin Josefsson <gandalf@wlug.westbo.se>
62943 + *     * copied ipt_BALANCE.c to ipt_SAME.c and changed a few things.
62944 + * 010728 Martin Josefsson <gandalf@wlug.westbo.se>
62945 + *     * added --nodst to not include destination-ip in new source
62946 + *       calculations.
62947 + *     * added some more sanity-checks.
62948 + * 010729 Martin Josefsson <gandalf@wlug.westbo.se>
62949 + *     * fixed a buggy if-statement in same_check(), should have
62950 + *       used ntohl() but didn't.
62951 + *     * added support for multiple ranges. IPT_SAME_MAX_RANGE is
62952 + *       defined in linux/include/linux/netfilter_ipv4/ipt_SAME.h
62953 + *       and is currently set to 10.
62954 + *     * added support for 1-address range, nice to have now that
62955 + *       we have multiple ranges.
62956 + */
62957 +#include <linux/types.h>
62958 +#include <linux/ip.h>
62959 +#include <linux/timer.h>
62960 +#include <linux/module.h>
62961 +#include <linux/netfilter.h>
62962 +#include <linux/netdevice.h>
62963 +#include <linux/if.h>
62964 +#include <linux/inetdevice.h>
62965 +#include <net/protocol.h>
62966 +#include <net/checksum.h>
62967 +#include <linux/netfilter_ipv4.h>
62968 +#include <linux/netfilter_ipv4/ip_nat_rule.h>
62969 +#include <linux/netfilter_ipv4/ipt_SAME.h>
62970 +
62971 +MODULE_LICENSE("GPL");
62972 +MODULE_AUTHOR("Martin Josefsson <gandalf@wlug.westbo.se>");
62973 +MODULE_DESCRIPTION("iptables special SNAT module for consistent sourceip");
62974 +
62975 +#if 0
62976 +#define DEBUGP printk
62977 +#else
62978 +#define DEBUGP(format, args...)
62979 +#endif
62980 +
62981 +static int
62982 +same_check(const char *tablename,
62983 +             const struct ipt_entry *e,
62984 +             void *targinfo,
62985 +             unsigned int targinfosize,
62986 +             unsigned int hook_mask)
62987 +{
62988 +       unsigned int count, countess, rangeip, index = 0;
62989 +       struct ipt_same_info *mr = targinfo;
62990 +
62991 +       mr->ipnum = 0;
62992 +
62993 +       if (strcmp(tablename, "nat") != 0) {
62994 +               DEBUGP("same_check: bad table `%s'.\n", tablename);
62995 +               return 0;
62996 +       }
62997 +       if (targinfosize != IPT_ALIGN(sizeof(*mr))) {
62998 +               DEBUGP("same_check: size %u.\n", targinfosize);
62999 +               return 0;
63000 +       }
63001 +       if (hook_mask & ~(1 << NF_IP_PRE_ROUTING | 1 << NF_IP_POST_ROUTING)) {
63002 +               DEBUGP("same_check: bad hooks %x.\n", hook_mask);
63003 +               return 0;
63004 +       }
63005 +       if (mr->rangesize < 1) {
63006 +               DEBUGP("same_check: need at least one dest range.\n");
63007 +               return 0;
63008 +       }
63009 +       if (mr->rangesize > IPT_SAME_MAX_RANGE) {
63010 +               DEBUGP("same_check: too many ranges specified, maximum "
63011 +                               "is %u ranges\n",
63012 +                               IPT_SAME_MAX_RANGE);
63013 +               return 0;
63014 +       }
63015 +       for (count = 0; count < mr->rangesize; count++) {
63016 +               if (ntohl(mr->range[count].min_ip) >
63017 +                               ntohl(mr->range[count].max_ip)) {
63018 +                       DEBUGP("same_check: min_ip is larger than max_ip in "
63019 +                               "range `%u.%u.%u.%u-%u.%u.%u.%u'.\n",
63020 +                               NIPQUAD(mr->range[count].min_ip),
63021 +                               NIPQUAD(mr->range[count].max_ip));
63022 +                       return 0;
63023 +               }
63024 +               if (!(mr->range[count].flags & IP_NAT_RANGE_MAP_IPS)) {
63025 +                       DEBUGP("same_check: bad MAP_IPS.\n");
63026 +                       return 0;
63027 +               }
63028 +               rangeip = (ntohl(mr->range[count].max_ip) - 
63029 +                                       ntohl(mr->range[count].min_ip) + 1);
63030 +               mr->ipnum += rangeip;
63031 +               
63032 +               DEBUGP("same_check: range %u, ipnum = %u\n", count, rangeip);
63033 +       }
63034 +       DEBUGP("same_check: total ipaddresses = %u\n", mr->ipnum);
63035 +       
63036 +       mr->iparray = kmalloc((sizeof(u_int32_t) * mr->ipnum), GFP_KERNEL);
63037 +       if (!mr->iparray) {
63038 +               DEBUGP("same_check: Couldn't allocate %u bytes "
63039 +                       "for %u ipaddresses!\n", 
63040 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
63041 +               return 0;
63042 +       }
63043 +       DEBUGP("same_check: Allocated %u bytes for %u ipaddresses.\n",
63044 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
63045 +       
63046 +       for (count = 0; count < mr->rangesize; count++) {
63047 +               for (countess = ntohl(mr->range[count].min_ip);
63048 +                               countess <= ntohl(mr->range[count].max_ip);
63049 +                                       countess++) {
63050 +                       mr->iparray[index] = countess;
63051 +                       DEBUGP("same_check: Added ipaddress `%u.%u.%u.%u' "
63052 +                               "in index %u.\n",
63053 +                               HIPQUAD(countess), index);
63054 +                       index++;
63055 +               }
63056 +       }
63057 +       return 1;
63058 +}
63059 +
63060 +static void 
63061 +same_destroy(void *targinfo,
63062 +               unsigned int targinfosize)
63063 +{
63064 +       struct ipt_same_info *mr = targinfo;
63065 +
63066 +       kfree(mr->iparray);
63067 +       
63068 +       DEBUGP("same_destroy: Deallocated %u bytes for %u ipaddresses.\n",
63069 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
63070 +}
63071 +
63072 +static unsigned int
63073 +same_target(struct sk_buff **pskb,
63074 +               const struct net_device *in,
63075 +               const struct net_device *out,
63076 +               unsigned int hooknum,
63077 +               const void *targinfo,
63078 +               void *userinfo)
63079 +{
63080 +       struct ip_conntrack *ct;
63081 +       enum ip_conntrack_info ctinfo;
63082 +       u_int32_t tmpip, aindex, new_ip;
63083 +       const struct ipt_same_info *mr = targinfo;
63084 +       struct ip_nat_multi_range newrange;
63085 +       const struct ip_conntrack_tuple *t;
63086 +
63087 +       IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
63088 +                       hooknum == NF_IP_POST_ROUTING);
63089 +       ct = ip_conntrack_get(*pskb, &ctinfo);
63090 +
63091 +       t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
63092 +
63093 +       /* Base new source on real src ip and optionally dst ip,
63094 +          giving some hope for consistency across reboots.
63095 +          Here we calculate the index in mr->iparray which
63096 +          holds the ipaddress we should use */
63097 +       
63098 +       tmpip = ntohl(t->src.ip);
63099 +
63100 +       if (!(mr->info & IPT_SAME_NODST))
63101 +               tmpip += ntohl(t->dst.ip);
63102 +       
63103 +       aindex = tmpip % mr->ipnum;
63104 +               
63105 +       new_ip = htonl(mr->iparray[aindex]);
63106 +
63107 +       DEBUGP("ipt_SAME: src=%u.%u.%u.%u dst=%u.%u.%u.%u, "
63108 +                       "new src=%u.%u.%u.%u\n",
63109 +                       NIPQUAD(t->src.ip), NIPQUAD(t->dst.ip),
63110 +                       NIPQUAD(new_ip));
63111 +
63112 +       /* Transfer from original range. */
63113 +       newrange = ((struct ip_nat_multi_range)
63114 +               { 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
63115 +                        new_ip, new_ip,
63116 +                        mr->range[0].min, mr->range[0].max } } });
63117 +
63118 +       /* Hand modified range to generic setup. */
63119 +       return ip_nat_setup_info(ct, &newrange, hooknum);
63120 +}
63121 +
63122 +static struct ipt_target same_reg = { 
63123 +       .name           = "SAME",
63124 +       .target         = same_target,
63125 +       .checkentry     = same_check,
63126 +       .destroy        = same_destroy,
63127 +       .me             = THIS_MODULE,
63128 +};
63129 +
63130 +static int __init init(void)
63131 +{
63132 +       return ipt_register_target(&same_reg);
63133 +}
63134 +
63135 +static void __exit fini(void)
63136 +{
63137 +       ipt_unregister_target(&same_reg);
63138 +}
63139 +
63140 +module_init(init);
63141 +module_exit(fini);
63142 +
63143 diff -Nru a/net/ipv4/netfilter/ipt_TCPMSS.c b/net/ipv4/netfilter/ipt_TCPMSS.c
63144 --- a/net/ipv4/netfilter/ipt_TCPMSS.c   Wed May 21 16:36:54 2003
63145 +++ b/net/ipv4/netfilter/ipt_TCPMSS.c   Sun Aug 24 05:00:28 2003
63146 @@ -12,6 +12,10 @@
63147  #include <linux/netfilter_ipv4/ip_tables.h>
63148  #include <linux/netfilter_ipv4/ipt_TCPMSS.h>
63149  
63150 +MODULE_LICENSE("GPL");
63151 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
63152 +MODULE_DESCRIPTION("iptables TCP MSS modification module");
63153 +
63154  #if 0
63155  #define DEBUGP printk
63156  #else
63157 @@ -250,4 +254,3 @@
63158  
63159  module_init(init);
63160  module_exit(fini);
63161 -MODULE_LICENSE("GPL");
63162 diff -Nru a/net/ipv4/netfilter/ipt_TOS.c b/net/ipv4/netfilter/ipt_TOS.c
63163 --- a/net/ipv4/netfilter/ipt_TOS.c      Wed May 21 16:36:54 2003
63164 +++ b/net/ipv4/netfilter/ipt_TOS.c      Sun Aug 24 05:00:28 2003
63165 @@ -7,6 +7,10 @@
63166  #include <linux/netfilter_ipv4/ip_tables.h>
63167  #include <linux/netfilter_ipv4/ipt_TOS.h>
63168  
63169 +MODULE_LICENSE("GPL");
63170 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
63171 +MODULE_DESCRIPTION("iptables TOS mangling module");
63172 +
63173  static unsigned int
63174  target(struct sk_buff **pskb,
63175         const struct net_device *in,
63176 @@ -93,4 +97,3 @@
63177  
63178  module_init(init);
63179  module_exit(fini);
63180 -MODULE_LICENSE("GPL");
63181 diff -Nru a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
63182 --- a/net/ipv4/netfilter/ipt_ULOG.c     Tue Jun 24 15:36:11 2003
63183 +++ b/net/ipv4/netfilter/ipt_ULOG.c     Sat Aug 30 20:35:04 2003
63184 @@ -36,7 +36,6 @@
63185   */
63186  
63187  #include <linux/module.h>
63188 -#include <linux/version.h>
63189  #include <linux/config.h>
63190  #include <linux/spinlock.h>
63191  #include <linux/socket.h>
63192 @@ -55,7 +54,7 @@
63193  
63194  MODULE_LICENSE("GPL");
63195  MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
63196 -MODULE_DESCRIPTION("IP tables userspace logging module");
63197 +MODULE_DESCRIPTION("iptables userspace logging module");
63198  
63199  #define ULOG_NL_EVENT          111             /* Harald's favorite number */
63200  #define ULOG_MAXNLGROUPS       32              /* numer of nlgroups */
63201 diff -Nru a/net/ipv4/netfilter/ipt_ah.c b/net/ipv4/netfilter/ipt_ah.c
63202 --- a/net/ipv4/netfilter/ipt_ah.c       Sat Aug  2 22:49:54 2003
63203 +++ b/net/ipv4/netfilter/ipt_ah.c       Sun Aug 24 05:00:28 2003
63204 @@ -7,6 +7,8 @@
63205  #include <linux/netfilter_ipv4/ip_tables.h>
63206  
63207  MODULE_LICENSE("GPL");
63208 +MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>");
63209 +MODULE_DESCRIPTION("iptables AH SPI match module");
63210  
63211  #ifdef DEBUG_CONNTRACK
63212  #define duprintf(format, args...) printk(format , ## args)
63213 diff -Nru a/net/ipv4/netfilter/ipt_conntrack.c b/net/ipv4/netfilter/ipt_conntrack.c
63214 --- a/net/ipv4/netfilter/ipt_conntrack.c        Wed May 21 16:35:36 2003
63215 +++ b/net/ipv4/netfilter/ipt_conntrack.c        Sun Aug 24 05:00:28 2003
63216 @@ -8,6 +8,10 @@
63217  #include <linux/netfilter_ipv4/ip_tables.h>
63218  #include <linux/netfilter_ipv4/ipt_conntrack.h>
63219  
63220 +MODULE_LICENSE("GPL");
63221 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
63222 +MODULE_DESCRIPTION("iptables connection tracking match module");
63223 +
63224  static int
63225  match(const struct sk_buff *skb,
63226        const struct net_device *in,
63227 @@ -122,4 +126,3 @@
63228  
63229  module_init(init);
63230  module_exit(fini);
63231 -MODULE_LICENSE("GPL");
63232 diff -Nru a/net/ipv4/netfilter/ipt_dscp.c b/net/ipv4/netfilter/ipt_dscp.c
63233 --- a/net/ipv4/netfilter/ipt_dscp.c     Wed May 21 16:35:36 2003
63234 +++ b/net/ipv4/netfilter/ipt_dscp.c     Sun Aug 24 05:00:28 2003
63235 @@ -13,8 +13,8 @@
63236  #include <linux/netfilter_ipv4/ipt_dscp.h>
63237  #include <linux/netfilter_ipv4/ip_tables.h>
63238  
63239 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
63240 -MODULE_DESCRIPTION("IP tables DSCP matching module");
63241 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
63242 +MODULE_DESCRIPTION("iptables DSCP matching module");
63243  MODULE_LICENSE("GPL");
63244  
63245  static int match(const struct sk_buff *skb, const struct net_device *in,
63246 diff -Nru a/net/ipv4/netfilter/ipt_ecn.c b/net/ipv4/netfilter/ipt_ecn.c
63247 --- a/net/ipv4/netfilter/ipt_ecn.c      Wed May 21 16:35:36 2003
63248 +++ b/net/ipv4/netfilter/ipt_ecn.c      Sun Aug 24 05:00:28 2003
63249 @@ -14,8 +14,8 @@
63250  #include <linux/netfilter_ipv4/ip_tables.h>
63251  #include <linux/netfilter_ipv4/ipt_ecn.h>
63252  
63253 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
63254 -MODULE_DESCRIPTION("IP tables ECN matching module");
63255 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
63256 +MODULE_DESCRIPTION("iptables ECN matching module");
63257  MODULE_LICENSE("GPL");
63258  
63259  static inline int match_ip(const struct sk_buff *skb,
63260 diff -Nru a/net/ipv4/netfilter/ipt_esp.c b/net/ipv4/netfilter/ipt_esp.c
63261 --- a/net/ipv4/netfilter/ipt_esp.c      Sat Aug  2 22:51:04 2003
63262 +++ b/net/ipv4/netfilter/ipt_esp.c      Sun Aug 24 05:00:28 2003
63263 @@ -7,6 +7,8 @@
63264  #include <linux/netfilter_ipv4/ip_tables.h>
63265  
63266  MODULE_LICENSE("GPL");
63267 +MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>");
63268 +MODULE_DESCRIPTION("iptables ESP SPI match module");
63269  
63270  #ifdef DEBUG_CONNTRACK
63271  #define duprintf(format, args...) printk(format , ## args)
63272 diff -Nru a/net/ipv4/netfilter/ipt_helper.c b/net/ipv4/netfilter/ipt_helper.c
63273 --- a/net/ipv4/netfilter/ipt_helper.c   Fri Aug  1 03:02:18 2003
63274 +++ b/net/ipv4/netfilter/ipt_helper.c   Sun Aug 24 05:00:28 2003
63275 @@ -17,6 +17,8 @@
63276  #include <linux/netfilter_ipv4/ipt_helper.h>
63277  
63278  MODULE_LICENSE("GPL");
63279 +MODULE_AUTHOR("Martin Josefsson <gandalf@netfilter.org>");
63280 +MODULE_DESCRIPTION("iptables helper match module");
63281  
63282  #if 0
63283  #define DEBUGP printk
63284 diff -Nru a/net/ipv4/netfilter/ipt_iprange.c b/net/ipv4/netfilter/ipt_iprange.c
63285 --- /dev/null   Wed Dec 31 16:00:00 1969
63286 +++ b/net/ipv4/netfilter/ipt_iprange.c  Sun Aug 24 17:25:18 2003
63287 @@ -0,0 +1,97 @@
63288 +/*
63289 + * iptables module to match IP address ranges
63290 + *   (c) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
63291 + *
63292 + * Released under the terms of GNU GPLv2.
63293 + *
63294 + */
63295 +#include <linux/module.h>
63296 +#include <linux/skbuff.h>
63297 +#include <linux/ip.h>
63298 +#include <linux/netfilter_ipv4/ip_tables.h>
63299 +#include <linux/netfilter_ipv4/ipt_iprange.h>
63300 +
63301 +MODULE_LICENSE("GPL");
63302 +MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
63303 +MODULE_DESCRIPTION("iptables arbitrary IP range match module");
63304 +
63305 +#if 0
63306 +#define DEBUGP printk
63307 +#else
63308 +#define DEBUGP(format, args...)
63309 +#endif
63310 +
63311 +static int
63312 +match(const struct sk_buff *skb,
63313 +      const struct net_device *in,
63314 +      const struct net_device *out,
63315 +      const void *matchinfo,
63316 +      int offset, int *hotdrop)
63317 +{
63318 +       const struct ipt_iprange_info *info = matchinfo;
63319 +       const struct iphdr *iph = skb->nh.iph;
63320 +
63321 +       if (info->flags & IPRANGE_SRC) {
63322 +               if (((ntohl(iph->saddr) < ntohl(info->src.min_ip))
63323 +                         || (ntohl(iph->saddr) > ntohl(info->src.max_ip)))
63324 +                        ^ !!(info->flags & IPRANGE_SRC_INV)) {
63325 +                       DEBUGP("src IP %u.%u.%u.%u NOT in range %s"
63326 +                              "%u.%u.%u.%u-%u.%u.%u.%u\n",
63327 +                               NIPQUAD(iph->saddr),
63328 +                               info->flags & IPRANGE_SRC_INV ? "(INV) " : "",
63329 +                               NIPQUAD(info->src.min_ip),
63330 +                               NIPQUAD(info->src.max_ip));
63331 +                       return 0;
63332 +               }
63333 +       }
63334 +       if (info->flags & IPRANGE_DST) {
63335 +               if (((ntohl(iph->daddr) < ntohl(info->dst.min_ip))
63336 +                         || (ntohl(iph->daddr) > ntohl(info->dst.max_ip)))
63337 +                        ^ !!(info->flags & IPRANGE_DST_INV)) {
63338 +                       DEBUGP("dst IP %u.%u.%u.%u NOT in range %s"
63339 +                              "%u.%u.%u.%u-%u.%u.%u.%u\n",
63340 +                               NIPQUAD(iph->daddr),
63341 +                               info->flags & IPRANGE_DST_INV ? "(INV) " : "",
63342 +                               NIPQUAD(info->dst.min_ip),
63343 +                               NIPQUAD(info->dst.max_ip));
63344 +                       return 0;
63345 +               }
63346 +       }
63347 +       return 1;
63348 +}
63349 +
63350 +static int check(const char *tablename,
63351 +                const struct ipt_ip *ip,
63352 +                void *matchinfo,
63353 +                unsigned int matchsize,
63354 +                unsigned int hook_mask)
63355 +{
63356 +       /* verify size */
63357 +       if (matchsize != IPT_ALIGN(sizeof(struct ipt_iprange_info)))
63358 +               return 0;
63359 +
63360 +       return 1;
63361 +}
63362 +
63363 +static struct ipt_match iprange_match = 
63364 +{ 
63365 +       .list = { NULL, NULL }, 
63366 +       .name = "iprange", 
63367 +       .match = &match, 
63368 +       .checkentry = &check, 
63369 +       .destroy = NULL, 
63370 +       .me = THIS_MODULE
63371 +};
63372 +
63373 +static int __init init(void)
63374 +{
63375 +       return ipt_register_match(&iprange_match);
63376 +}
63377 +
63378 +static void __exit fini(void)
63379 +{
63380 +       ipt_unregister_match(&iprange_match);
63381 +}
63382 +
63383 +module_init(init);
63384 +module_exit(fini);
63385 diff -Nru a/net/ipv4/netfilter/ipt_limit.c b/net/ipv4/netfilter/ipt_limit.c
63386 --- a/net/ipv4/netfilter/ipt_limit.c    Wed May 21 16:35:36 2003
63387 +++ b/net/ipv4/netfilter/ipt_limit.c    Sun Aug 24 05:00:28 2003
63388 @@ -15,6 +15,10 @@
63389  #include <linux/netfilter_ipv4/ip_tables.h>
63390  #include <linux/netfilter_ipv4/ipt_limit.h>
63391  
63392 +MODULE_LICENSE("GPL");
63393 +MODULE_AUTHOR("Herve Eychenne <rv@wallfire.org>");
63394 +MODULE_DESCRIPTION("iptables rate limit match");
63395 +
63396  /* The algorithm used is the Simple Token Bucket Filter (TBF)
63397   * see net/sched/sch_tbf.c in the linux source tree
63398   */
63399 @@ -134,4 +138,3 @@
63400  
63401  module_init(init);
63402  module_exit(fini);
63403 -MODULE_LICENSE("GPL");
63404 diff -Nru a/net/ipv4/netfilter/ipt_mac.c b/net/ipv4/netfilter/ipt_mac.c
63405 --- a/net/ipv4/netfilter/ipt_mac.c      Wed May 21 16:35:36 2003
63406 +++ b/net/ipv4/netfilter/ipt_mac.c      Sun Aug 24 05:00:28 2003
63407 @@ -6,6 +6,10 @@
63408  #include <linux/netfilter_ipv4/ipt_mac.h>
63409  #include <linux/netfilter_ipv4/ip_tables.h>
63410  
63411 +MODULE_LICENSE("GPL");
63412 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
63413 +MODULE_DESCRIPTION("iptables mac matching module");
63414 +
63415  static int
63416  match(const struct sk_buff *skb,
63417        const struct net_device *in,
63418 @@ -64,4 +68,3 @@
63419  
63420  module_init(init);
63421  module_exit(fini);
63422 -MODULE_LICENSE("GPL");
63423 diff -Nru a/net/ipv4/netfilter/ipt_mark.c b/net/ipv4/netfilter/ipt_mark.c
63424 --- a/net/ipv4/netfilter/ipt_mark.c     Wed May 21 16:35:36 2003
63425 +++ b/net/ipv4/netfilter/ipt_mark.c     Sun Aug 24 05:00:28 2003
63426 @@ -5,6 +5,10 @@
63427  #include <linux/netfilter_ipv4/ipt_mark.h>
63428  #include <linux/netfilter_ipv4/ip_tables.h>
63429  
63430 +MODULE_LICENSE("GPL");
63431 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
63432 +MODULE_DESCRIPTION("iptables mark matching module");
63433 +
63434  static int
63435  match(const struct sk_buff *skb,
63436        const struct net_device *in,
63437 @@ -50,4 +54,3 @@
63438  
63439  module_init(init);
63440  module_exit(fini);
63441 -MODULE_LICENSE("GPL");
63442 diff -Nru a/net/ipv4/netfilter/ipt_multiport.c b/net/ipv4/netfilter/ipt_multiport.c
63443 --- a/net/ipv4/netfilter/ipt_multiport.c        Wed May 21 16:35:36 2003
63444 +++ b/net/ipv4/netfilter/ipt_multiport.c        Sun Aug 24 05:00:28 2003
63445 @@ -8,6 +8,10 @@
63446  #include <linux/netfilter_ipv4/ipt_multiport.h>
63447  #include <linux/netfilter_ipv4/ip_tables.h>
63448  
63449 +MODULE_LICENSE("GPL");
63450 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
63451 +MODULE_DESCRIPTION("iptables multiple port match module");
63452 +
63453  #if 0
63454  #define duprintf(format, args...) printk(format , ## args)
63455  #else
63456 @@ -106,4 +110,3 @@
63457  
63458  module_init(init);
63459  module_exit(fini);
63460 -MODULE_LICENSE("GPL");
63461 diff -Nru a/net/ipv4/netfilter/ipt_owner.c b/net/ipv4/netfilter/ipt_owner.c
63462 --- a/net/ipv4/netfilter/ipt_owner.c    Wed Jun  4 17:57:08 2003
63463 +++ b/net/ipv4/netfilter/ipt_owner.c    Sun Aug 24 05:00:28 2003
63464 @@ -11,6 +11,10 @@
63465  #include <linux/netfilter_ipv4/ipt_owner.h>
63466  #include <linux/netfilter_ipv4/ip_tables.h>
63467  
63468 +MODULE_LICENSE("GPL");
63469 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
63470 +MODULE_DESCRIPTION("iptables owner match");
63471 +
63472  static int
63473  match_comm(const struct sk_buff *skb, const char *comm)
63474  {
63475 @@ -198,4 +202,3 @@
63476  
63477  module_init(init);
63478  module_exit(fini);
63479 -MODULE_LICENSE("GPL");
63480 diff -Nru a/net/ipv4/netfilter/ipt_physdev.c b/net/ipv4/netfilter/ipt_physdev.c
63481 --- a/net/ipv4/netfilter/ipt_physdev.c  Sat Aug  2 18:29:28 2003
63482 +++ b/net/ipv4/netfilter/ipt_physdev.c  Sat Aug 30 20:47:18 2003
63483 @@ -8,6 +8,10 @@
63484  #define MATCH   1
63485  #define NOMATCH 0
63486  
63487 +MODULE_LICENSE("GPL");
63488 +MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
63489 +MODULE_DESCRIPTION("iptables bridge physical device match module");
63490 +
63491  static int
63492  match(const struct sk_buff *skb,
63493        const struct net_device *in,
63494 @@ -120,4 +124,3 @@
63495  
63496  module_init(init);
63497  module_exit(fini);
63498 -MODULE_LICENSE("GPL");
63499 diff -Nru a/net/ipv4/netfilter/ipt_state.c b/net/ipv4/netfilter/ipt_state.c
63500 --- a/net/ipv4/netfilter/ipt_state.c    Wed May 21 16:35:36 2003
63501 +++ b/net/ipv4/netfilter/ipt_state.c    Sun Aug 24 05:00:28 2003
63502 @@ -7,6 +7,10 @@
63503  #include <linux/netfilter_ipv4/ip_tables.h>
63504  #include <linux/netfilter_ipv4/ipt_state.h>
63505  
63506 +MODULE_LICENSE("GPL");
63507 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
63508 +MODULE_DESCRIPTION("iptables connection tracking state match module");
63509 +
63510  static int
63511  match(const struct sk_buff *skb,
63512        const struct net_device *in,
63513 @@ -59,4 +63,3 @@
63514  
63515  module_init(init);
63516  module_exit(fini);
63517 -MODULE_LICENSE("GPL");
63518 diff -Nru a/net/ipv4/netfilter/ipt_tcpmss.c b/net/ipv4/netfilter/ipt_tcpmss.c
63519 --- a/net/ipv4/netfilter/ipt_tcpmss.c   Wed May 21 16:35:36 2003
63520 +++ b/net/ipv4/netfilter/ipt_tcpmss.c   Sun Aug 24 05:00:28 2003
63521 @@ -8,6 +8,10 @@
63522  
63523  #define TH_SYN 0x02
63524  
63525 +MODULE_LICENSE("GPL");
63526 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
63527 +MODULE_DESCRIPTION("iptables TCP MSS match module");
63528 +
63529  /* Returns 1 if the mss option is set and matched by the range, 0 otherwise */
63530  static inline int
63531  mssoption_match(u_int16_t min, u_int16_t max,
63532 @@ -117,4 +121,3 @@
63533  
63534  module_init(init);
63535  module_exit(fini);
63536 -MODULE_LICENSE("GPL");
63537 diff -Nru a/net/ipv4/netfilter/ipt_tos.c b/net/ipv4/netfilter/ipt_tos.c
63538 --- a/net/ipv4/netfilter/ipt_tos.c      Wed May 21 16:35:36 2003
63539 +++ b/net/ipv4/netfilter/ipt_tos.c      Sun Aug 24 05:00:28 2003
63540 @@ -5,6 +5,9 @@
63541  #include <linux/netfilter_ipv4/ipt_tos.h>
63542  #include <linux/netfilter_ipv4/ip_tables.h>
63543  
63544 +MODULE_LICENSE("GPL");
63545 +MODULE_DESCRIPTION("iptables TOS match module");
63546 +
63547  static int
63548  match(const struct sk_buff *skb,
63549        const struct net_device *in,
63550 @@ -50,4 +53,3 @@
63551  
63552  module_init(init);
63553  module_exit(fini);
63554 -MODULE_LICENSE("GPL");
63555 diff -Nru a/net/ipv4/netfilter/ipt_unclean.c b/net/ipv4/netfilter/ipt_unclean.c
63556 --- a/net/ipv4/netfilter/ipt_unclean.c  Wed May 21 16:35:36 2003
63557 +++ /dev/null   Wed Dec 31 16:00:00 1969
63558 @@ -1,610 +0,0 @@
63559 -/* Kernel module to match suspect packets. */
63560 -#include <linux/module.h>
63561 -#include <linux/skbuff.h>
63562 -#include <linux/ip.h>
63563 -#include <linux/udp.h>
63564 -#include <linux/tcp.h>
63565 -#include <linux/icmp.h>
63566 -#include <net/checksum.h>
63567 -
63568 -#include <linux/netfilter_ipv4/ip_tables.h>
63569 -
63570 -#define limpk(format, args...)                                          \
63571 -do {                                                                    \
63572 -       if (net_ratelimit())                                             \
63573 -               printk("ipt_unclean: %s" format,                         \
63574 -                      embedded ? "(embedded packet) " : "" , ## args);  \
63575 -} while(0)
63576 -
63577 -enum icmp_error_status
63578 -{
63579 -       ICMP_MAY_BE_ERROR,
63580 -       ICMP_IS_ERROR,
63581 -       ICMP_NOT_ERROR
63582 -};
63583 -
63584 -struct icmp_info
63585 -{
63586 -       size_t min_len, max_len;
63587 -       enum icmp_error_status err;
63588 -       u_int8_t min_code, max_code;
63589 -};
63590 -
63591 -static int
63592 -check_ip(const struct sk_buff *skb, unsigned int offset);
63593 -
63594 -/* ICMP-specific checks. */
63595 -static int
63596 -check_icmp(const struct sk_buff *skb,
63597 -          unsigned int offset,
63598 -          unsigned int fragoff,
63599 -          int more_frags,
63600 -          int embedded)
63601 -{
63602 -       struct icmphdr icmph;
63603 -       static struct icmp_info info[]
63604 -               = { [ICMP_ECHOREPLY]
63605 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
63606 -                   [ICMP_DEST_UNREACH]
63607 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 15 },
63608 -                   [ICMP_SOURCE_QUENCH]
63609 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 0 },
63610 -                   [ICMP_REDIRECT]
63611 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 3 },
63612 -                   [ICMP_ECHO]
63613 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0  },
63614 -                   /* Router advertisement. */
63615 -                   [9]
63616 -                   = { 8, 8 + 255 * 8, ICMP_NOT_ERROR, 0, 0 },
63617 -                   /* Router solicitation. */
63618 -                   [10]
63619 -                   = { 8, 8, ICMP_NOT_ERROR, 0, 0 },
63620 -                   [ICMP_TIME_EXCEEDED]
63621 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 1  },
63622 -                   [ICMP_PARAMETERPROB]
63623 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 1 },
63624 -                   [ICMP_TIMESTAMP]
63625 -                   = { 20, 20, ICMP_NOT_ERROR, 0, 0 },
63626 -                   [ICMP_TIMESTAMPREPLY]
63627 -                   = { 20, 20, ICMP_NOT_ERROR, 0, 0 },
63628 -                   [ICMP_INFO_REQUEST]
63629 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
63630 -                   [ICMP_INFO_REPLY]
63631 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
63632 -                   [ICMP_ADDRESS]
63633 -                   = { 12, 12, ICMP_NOT_ERROR, 0, 0 },
63634 -                   [ICMP_ADDRESSREPLY]
63635 -                   = { 12, 12, ICMP_NOT_ERROR, 0, 0 } };
63636 -
63637 -       /* Can't do anything if it's a fragment. */
63638 -       if (fragoff)
63639 -               return 1;
63640 -
63641 -       /* CHECK: Must have whole header.. */
63642 -       if (skb_copy_bits(skb, offset, &icmph, sizeof(icmph)) < 0) {
63643 -               limpk("ICMP len=%u too short\n", skb->len - offset);
63644 -               return 0;
63645 -       }
63646 -
63647 -       /* If not embedded in an ICMP error already. */
63648 -       if (!embedded) {
63649 -               /* CHECK: Truncated ICMP (even if first fragment). */
63650 -               if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
63651 -                   && info[icmph.type].min_len != 0
63652 -                   && skb->len - offset < info[icmph.type].min_len) {
63653 -                       limpk("ICMP type %u len %u too short\n",
63654 -                             icmph.type, skb->len - offset);
63655 -                       return 0;
63656 -               }
63657 -
63658 -               /* CHECK: Check within known error ICMPs. */
63659 -               if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
63660 -                   && info[icmph.type].err == ICMP_IS_ERROR) {
63661 -                       /* Max IP header size = 60 */
63662 -                       char inner[60 + 8];
63663 -                       struct iphdr *inner_ip = (struct iphdr *)inner;
63664 -
63665 -                       /* CHECK: Embedded packet must be at least
63666 -                          length of iph + 8 bytes. */
63667 -                       if (skb_copy_bits(skb, offset + sizeof(icmph),
63668 -                                         inner, sizeof(struct iphdr)+8) < 0) {
63669 -                               limpk("ICMP error internal way too short\n");
63670 -                               return 0;
63671 -                       }
63672 -
63673 -                       /* iphhdr may actually be longer: still need 8
63674 -                           actual protocol bytes. */
63675 -                       if (offset + sizeof(icmph) + inner_ip->ihl*4 + 8
63676 -                           > skb->len) {
63677 -                               limpk("ICMP error internal too short\n");
63678 -                               return 0;
63679 -                       }
63680 -                       if (!check_ip(skb, offset + sizeof(icmph)))
63681 -                               return 0;
63682 -               }
63683 -       } else {
63684 -               /* CHECK: Can't embed ICMP unless known non-error. */
63685 -               if (icmph.type >= sizeof(info)/sizeof(struct icmp_info)
63686 -                   || info[icmph.type].err != ICMP_NOT_ERROR) {
63687 -                       limpk("ICMP type %u not embeddable\n",
63688 -                             icmph.type);
63689 -                       return 0;
63690 -               }
63691 -       }
63692 -
63693 -       /* CHECK: Invalid ICMP codes. */
63694 -       if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
63695 -           && (icmph.code < info[icmph.type].min_code
63696 -               || icmph.code > info[icmph.type].max_code)) {
63697 -               limpk("ICMP type=%u code=%u\n",
63698 -                     icmph.type, icmph.code);
63699 -               return 0;
63700 -       }
63701 -
63702 -       /* CHECK: Above maximum length. */
63703 -       if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
63704 -           && info[icmph.type].max_len != 0
63705 -           && skb->len - offset > info[icmph.type].max_len) {
63706 -               limpk("ICMP type=%u too long: %u bytes\n",
63707 -                     icmph.type, skb->len - offset);
63708 -               return 0;
63709 -       }
63710 -
63711 -       switch (icmph.type) {
63712 -       case ICMP_PARAMETERPROB: {
63713 -               /* CHECK: Problem param must be within error packet's
63714 -                * IP header. */
63715 -               u_int32_t arg = ntohl(icmph.un.gateway);
63716 -
63717 -               if (icmph.code == 0) {
63718 -                       /* We've already made sure it's long enough. */
63719 -                       struct iphdr iph;
63720 -                       skb_copy_bits(skb, offset + sizeof(icmph), &iph,
63721 -                                     sizeof(iph));
63722 -                       /* Code 0 means that upper 8 bits is pointer
63723 -                           to problem. */
63724 -                       if ((arg >> 24) >= iph.ihl*4) {
63725 -                               limpk("ICMP PARAMETERPROB ptr = %u\n",
63726 -                                     ntohl(icmph.un.gateway) >> 24);
63727 -                               return 0;
63728 -                       }
63729 -                       arg &= 0x00FFFFFF;
63730 -               }
63731 -
63732 -               /* CHECK: Rest must be zero. */
63733 -               if (arg) {
63734 -                       limpk("ICMP PARAMETERPROB nonzero arg = %u\n",
63735 -                             arg);
63736 -                       return 0;
63737 -               }
63738 -               break;
63739 -       }
63740 -
63741 -       case ICMP_TIME_EXCEEDED:
63742 -       case ICMP_SOURCE_QUENCH:
63743 -               /* CHECK: Unused must be zero. */
63744 -               if (icmph.un.gateway != 0) {
63745 -                       limpk("ICMP type=%u unused = %u\n",
63746 -                             icmph.type, ntohl(icmph.un.gateway));
63747 -                       return 0;
63748 -               }
63749 -               break;
63750 -       }
63751 -
63752 -       return 1;
63753 -}
63754 -
63755 -/* UDP-specific checks. */
63756 -static int
63757 -check_udp(const struct sk_buff *skb,
63758 -         unsigned int offset,
63759 -         unsigned int fragoff,
63760 -         int more_frags,
63761 -         int embedded)
63762 -{
63763 -       struct udphdr udph;
63764 -
63765 -       /* Can't do anything if it's a fragment. */
63766 -       if (fragoff)
63767 -               return 1;
63768 -
63769 -       /* CHECK: Must cover UDP header. */
63770 -       if (skb_copy_bits(skb, offset, &udph, sizeof(udph)) < 0) {
63771 -               limpk("UDP len=%u too short\n", skb->len - offset);
63772 -               return 0;
63773 -       }
63774 -
63775 -       /* CHECK: Destination port can't be zero. */
63776 -       if (!udph.dest) {
63777 -               limpk("UDP zero destination port\n");
63778 -               return 0;
63779 -       }
63780 -
63781 -       if (!more_frags) {
63782 -               if (!embedded) {
63783 -                       /* CHECK: UDP length must match. */
63784 -                       if (ntohs(udph.len) != skb->len - offset) {
63785 -                               limpk("UDP len too short %u vs %u\n",
63786 -                                     ntohs(udph.len), skb->len - offset);
63787 -                               return 0;
63788 -                       }
63789 -               } else {
63790 -                       /* CHECK: UDP length be >= this truncated pkt. */
63791 -                       if (ntohs(udph.len) < skb->len - offset) {
63792 -                               limpk("UDP len too long %u vs %u\n",
63793 -                                     ntohs(udph.len), skb->len - offset);
63794 -                               return 0;
63795 -                       }
63796 -               }
63797 -       } else {
63798 -               /* CHECK: UDP length must be > this frag's length. */
63799 -               if (ntohs(udph.len) <= skb->len - offset) {
63800 -                       limpk("UDP fragment len too short %u vs %u\n",
63801 -                             ntohs(udph.len), skb->len - offset);
63802 -                       return 0;
63803 -               }
63804 -       }
63805 -
63806 -       return 1;
63807 -}
63808 -
63809 -/* TCP-specific checks. */
63810 -static int
63811 -check_tcp(const struct sk_buff *skb,
63812 -         unsigned int offset,
63813 -         unsigned int fragoff,
63814 -         int more_frags,
63815 -         int embedded)
63816 -{
63817 -       struct tcphdr tcph; 
63818 -       unsigned char opt[15 * 4 - sizeof(struct tcphdr)];
63819 -       u32 tcpflags;
63820 -       int end_of_options = 0;
63821 -       unsigned int i, optlen;
63822 -
63823 -       /* CHECK: Can't have offset=1: used to override TCP syn-checks. */
63824 -       /* In fact, this is caught below (offset < 516). */
63825 -
63826 -       /* Can't do anything if it's a fragment. */
63827 -       if (fragoff)
63828 -               return 1;
63829 -
63830 -       /* CHECK: Smaller than minimal TCP hdr. */
63831 -       if (skb_copy_bits(skb, offset, &tcph, sizeof(tcph)) < 0) {
63832 -               u16 ports[2];
63833 -
63834 -               if (!embedded) {
63835 -                       limpk("Packet length %u < TCP header.\n",
63836 -                             skb->len - offset);
63837 -                       return 0;
63838 -               }
63839 -
63840 -               /* Must have ports available (datalen >= 8), from
63841 -                   check_icmp which set embedded = 1 */
63842 -               /* CHECK: TCP ports inside ICMP error */
63843 -               skb_copy_bits(skb, offset, ports, sizeof(ports));
63844 -               if (!ports[0] || !ports[1]) {
63845 -                       limpk("Zero TCP ports %u/%u.\n",
63846 -                             htons(ports[0]), htons(ports[1]));
63847 -                       return 0;
63848 -               }
63849 -               return 1;
63850 -       }
63851 -
63852 -       /* CHECK: TCP header claims tiny size. */
63853 -       if (tcph.doff * 4 < sizeof(tcph)) {
63854 -               limpk("TCP header claims tiny size %u\n", tcph.doff * 4);
63855 -               return 0;
63856 -       }
63857 -
63858 -       /* CHECK: Packet smaller than actual TCP hdr. */
63859 -       optlen = tcph.doff*4 - sizeof(tcph);
63860 -       if (skb_copy_bits(skb, offset + sizeof(tcph), opt, optlen) < 0) {
63861 -               if (!embedded) {
63862 -                       limpk("Packet length %u < actual TCP header.\n",
63863 -                             skb->len - offset);
63864 -                       return 0;
63865 -               } else
63866 -                       return 1;
63867 -       }
63868 -
63869 -       /* CHECK: TCP ports non-zero */
63870 -       if (!tcph.source || !tcph.dest) {
63871 -               limpk("Zero TCP ports %u/%u.\n",
63872 -                     htons(tcph.source), htons(tcph.dest));
63873 -               return 0;
63874 -       }
63875 -
63876 -       tcpflags = tcp_flag_word(&tcph);
63877 -
63878 -       /* CHECK: TCP reserved bits zero. */
63879 -       if (tcpflags & TCP_RESERVED_BITS) {
63880 -               limpk("TCP reserved bits not zero\n");
63881 -               return 0;
63882 -       }
63883 -
63884 -       tcpflags &= ~(TCP_DATA_OFFSET | TCP_FLAG_CWR | TCP_FLAG_ECE
63885 -                     | __constant_htonl(0x0000FFFF));
63886 -
63887 -       /* CHECK: TCP flags. */
63888 -       if (tcpflags != TCP_FLAG_SYN
63889 -           && tcpflags != (TCP_FLAG_SYN|TCP_FLAG_ACK)
63890 -           && tcpflags != TCP_FLAG_RST
63891 -           && tcpflags != (TCP_FLAG_RST|TCP_FLAG_ACK)
63892 -           && tcpflags != (TCP_FLAG_RST|TCP_FLAG_ACK|TCP_FLAG_PSH)
63893 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK)
63894 -           && tcpflags != TCP_FLAG_ACK
63895 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_PSH)
63896 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_URG)
63897 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_URG|TCP_FLAG_PSH)
63898 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_PSH)
63899 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_URG)
63900 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_URG
63901 -                           |TCP_FLAG_PSH)) {
63902 -               limpk("TCP flags bad: 0x%04X\n", ntohl(tcpflags) >> 16);
63903 -               return 0;
63904 -       }
63905 -
63906 -       for (i = 0; i < optlen; ) {
63907 -               switch (opt[i]) {
63908 -               case 0:
63909 -                       end_of_options = 1;
63910 -                       i++;
63911 -                       break;
63912 -               case 1:
63913 -                       i++;
63914 -                       break;
63915 -               default:
63916 -                       /* CHECK: options after EOO. */
63917 -                       if (end_of_options) {
63918 -                               limpk("TCP option %u after end\n",
63919 -                                     opt[i]);
63920 -                               return 0;
63921 -                       }
63922 -                       /* CHECK: options at tail. */
63923 -                       else if (i+1 >= optlen) {
63924 -                               limpk("TCP option %u at tail\n",
63925 -                                     opt[i]);
63926 -                               return 0;
63927 -                       }
63928 -                       /* CHECK: zero-length options. */
63929 -                       else if (opt[i+1] == 0) {
63930 -                               limpk("TCP option %u 0 len\n",
63931 -                                     opt[i]);
63932 -                               return 0;
63933 -                       }
63934 -                       /* CHECK: oversize options. */
63935 -                       else if (i + opt[i+1] > optlen) {
63936 -                               limpk("TCP option %u at %u too long\n",
63937 -                                     (unsigned int) opt[i], i);
63938 -                               return 0;
63939 -                       }
63940 -                       /* Move to next option */
63941 -                       i += opt[i+1];
63942 -               }
63943 -       }
63944 -
63945 -       return 1;
63946 -}
63947 -
63948 -/* Returns 1 if ok */
63949 -/* Standard IP checks. */
63950 -static int
63951 -check_ip(const struct sk_buff *skb, unsigned int offset)
63952 -{
63953 -       int end_of_options = 0;
63954 -       unsigned int datalen, optlen;
63955 -       unsigned int i;
63956 -       unsigned int fragoff;
63957 -       struct iphdr iph;
63958 -       unsigned char opt[15 * 4 - sizeof(struct iphdr)];
63959 -       int embedded = offset;
63960 -
63961 -       /* Should only happen for local outgoing raw-socket packets. */
63962 -       /* CHECK: length >= ip header. */
63963 -       if (skb_copy_bits(skb, offset, &iph, sizeof(iph)) < 0) {
63964 -               limpk("Packet length %u < IP header.\n", skb->len - offset);
63965 -               return 0;
63966 -       }
63967 -       if (iph.ihl * 4 < sizeof(iph)) {
63968 -               limpk("IP len %u < minimum IP header.\n", iph.ihl*4);
63969 -               return 0;
63970 -       }
63971 -
63972 -       optlen = iph.ihl * 4 - sizeof(iph);
63973 -       if (skb_copy_bits(skb, offset+sizeof(struct iphdr), opt, optlen)<0) {
63974 -               limpk("Packet length %u < IP header %u.\n",
63975 -                     skb->len - offset, iph.ihl * 4);
63976 -               return 0;
63977 -       }
63978 -
63979 -       fragoff = (ntohs(iph.frag_off) & IP_OFFSET);
63980 -       datalen = skb->len - (offset + sizeof(struct iphdr) + optlen);
63981 -
63982 -       /* CHECK: Embedded fragment. */
63983 -       if (offset && fragoff) {
63984 -               limpk("Embedded fragment.\n");
63985 -               return 0;
63986 -       }
63987 -
63988 -       for (i = 0; i < optlen; ) {
63989 -               switch (opt[i]) {
63990 -               case 0:
63991 -                       end_of_options = 1;
63992 -                       i++;
63993 -                       break;
63994 -               case 1:
63995 -                       i++;
63996 -                       break;
63997 -               default:
63998 -                       /* CHECK: options after EOO. */
63999 -                       if (end_of_options) {
64000 -                               limpk("IP option %u after end\n",
64001 -                                     opt[i]);
64002 -                               return 0;
64003 -                       }
64004 -                       /* CHECK: options at tail. */
64005 -                       else if (i+1 >= optlen) {
64006 -                               limpk("IP option %u at tail\n",
64007 -                                     opt[i]);
64008 -                               return 0;
64009 -                       }
64010 -                       /* CHECK: zero-length or one-length options. */
64011 -                       else if (opt[i+1] < 2) {
64012 -                               limpk("IP option %u %u len\n",
64013 -                                     opt[i], opt[i+1]);
64014 -                               return 0;
64015 -                       }
64016 -                       /* CHECK: oversize options. */
64017 -                       else if (i + opt[i+1] > optlen) {
64018 -                               limpk("IP option %u at %u too long\n",
64019 -                                     opt[i], i);
64020 -                               return 0;
64021 -                       }
64022 -                       /* Move to next option */
64023 -                       i += opt[i+1];
64024 -               }
64025 -       }
64026 -
64027 -       /* Fragment checks. */
64028 -
64029 -       /* CHECK: More fragments, but doesn't fill 8-byte boundary. */
64030 -       if ((ntohs(iph.frag_off) & IP_MF)
64031 -           && (ntohs(iph.tot_len) % 8) != 0) {
64032 -               limpk("Truncated fragment %u long.\n", ntohs(iph.tot_len));
64033 -               return 0;
64034 -       }
64035 -
64036 -       /* CHECK: Oversize fragment a-la Ping of Death. */
64037 -       if (fragoff * 8 + datalen > 65535) {
64038 -               limpk("Oversize fragment to %u.\n", fragoff * 8);
64039 -               return 0;
64040 -       }
64041 -
64042 -       /* CHECK: DF set and fragoff or MF set. */
64043 -       if ((ntohs(iph.frag_off) & IP_DF)
64044 -           && (fragoff || (ntohs(iph.frag_off) & IP_MF))) {
64045 -               limpk("DF set and offset=%u, MF=%u.\n",
64046 -                     fragoff, ntohs(iph.frag_off) & IP_MF);
64047 -               return 0;
64048 -       }
64049 -
64050 -       /* CHECK: Zero-sized fragments. */
64051 -       if ((fragoff || (ntohs(iph.frag_off) & IP_MF))
64052 -           && datalen == 0) {
64053 -               limpk("Zero size fragment offset=%u\n", fragoff);
64054 -               return 0;
64055 -       }
64056 -
64057 -       /* Note: we can have even middle fragments smaller than this:
64058 -          consider a large packet passing through a 600MTU then
64059 -          576MTU link: this gives a fragment of 24 data bytes.  But
64060 -          everyone packs fragments largest first, hence a fragment
64061 -          can't START before 576 - MAX_IP_HEADER_LEN. */
64062 -
64063 -       /* Used to be min-size 576: I recall Alan Cox saying ax25 goes
64064 -          down to 128 (576 taken from RFC 791: All hosts must be
64065 -          prepared to accept datagrams of up to 576 octets).  Use 128
64066 -          here. */
64067 -#define MIN_LIKELY_MTU 128
64068 -       /* CHECK: Min size of first frag = 128. */
64069 -       if ((ntohs(iph.frag_off) & IP_MF)
64070 -           && fragoff == 0
64071 -           && ntohs(iph.tot_len) < MIN_LIKELY_MTU) {
64072 -               limpk("First fragment size %u < %u\n", ntohs(iph.tot_len),
64073 -                     MIN_LIKELY_MTU);
64074 -               return 0;
64075 -       }
64076 -
64077 -       /* CHECK: Min offset of frag = 128 - IP hdr len. */
64078 -       if (fragoff && fragoff * 8 < MIN_LIKELY_MTU - iph.ihl * 4) {
64079 -               limpk("Fragment starts at %u < %u\n", fragoff * 8,
64080 -                     MIN_LIKELY_MTU - iph.ihl * 4);
64081 -               return 0;
64082 -       }
64083 -
64084 -       /* CHECK: Protocol specification non-zero. */
64085 -       if (iph.protocol == 0) {
64086 -               limpk("Zero protocol\n");
64087 -               return 0;
64088 -       }
64089 -
64090 -       /* FIXME: This is already checked for in "Oversize fragment"
64091 -           above --RR */
64092 -       /* CHECK: Do not use what is unused.
64093 -        * First bit of fragmentation flags should be unused.
64094 -        * May be used by OS fingerprinting tools.
64095 -        * 04 Jun 2002, Maciej Soltysiak, solt@dns.toxicfilms.tv
64096 -        */
64097 -       if (ntohs(iph.frag_off)>>15) {
64098 -               limpk("IP unused bit set\n");
64099 -               return 0;
64100 -       }
64101 -
64102 -       /* Per-protocol checks. */
64103 -       switch (iph.protocol) {
64104 -       case IPPROTO_ICMP:
64105 -               return check_icmp(skb, offset + iph.ihl*4, fragoff,
64106 -                                 (ntohs(iph.frag_off) & IP_MF),
64107 -                                 embedded);
64108 -
64109 -       case IPPROTO_UDP:
64110 -               return check_udp(skb, offset + iph.ihl*4, fragoff,
64111 -                                (ntohs(iph.frag_off) & IP_MF),
64112 -                                embedded);
64113 -
64114 -       case IPPROTO_TCP:
64115 -               return check_tcp(skb, offset + iph.ihl*4, fragoff,
64116 -                                (ntohs(iph.frag_off) & IP_MF),
64117 -                                embedded);
64118 -       default:
64119 -               /* Ignorance is bliss. */
64120 -               return 1;
64121 -       }
64122 -}
64123 -
64124 -static int
64125 -match(const struct sk_buff *skb,
64126 -      const struct net_device *in,
64127 -      const struct net_device *out,
64128 -      const void *matchinfo,
64129 -      int offset,
64130 -      int *hotdrop)
64131 -{
64132 -       return !check_ip(skb, 0);
64133 -}
64134 -
64135 -/* Called when user tries to insert an entry of this type. */
64136 -static int
64137 -checkentry(const char *tablename,
64138 -          const struct ipt_ip *ip,
64139 -          void *matchinfo,
64140 -          unsigned int matchsize,
64141 -          unsigned int hook_mask)
64142 -{
64143 -       if (matchsize != IPT_ALIGN(0))
64144 -               return 0;
64145 -
64146 -       return 1;
64147 -}
64148 -
64149 -static struct ipt_match unclean_match = {
64150 -       .name           = "unclean",
64151 -       .match          = &match,
64152 -       .checkentry     = &checkentry,
64153 -       .me             = THIS_MODULE,
64154 -};
64155 -
64156 -static int __init init(void)
64157 -{
64158 -       return ipt_register_match(&unclean_match);
64159 -}
64160 -
64161 -static void __exit fini(void)
64162 -{
64163 -       ipt_unregister_match(&unclean_match);
64164 -}
64165 -
64166 -module_init(init);
64167 -module_exit(fini);
64168 -MODULE_LICENSE("GPL");
64169 diff -Nru a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
64170 --- a/net/ipv4/netfilter/iptable_filter.c       Wed Jun 11 23:34:58 2003
64171 +++ b/net/ipv4/netfilter/iptable_filter.c       Sun Aug 24 05:00:28 2003
64172 @@ -6,6 +6,10 @@
64173  #include <linux/module.h>
64174  #include <linux/netfilter_ipv4/ip_tables.h>
64175  
64176 +MODULE_LICENSE("GPL");
64177 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
64178 +MODULE_DESCRIPTION("iptables filter table");
64179 +
64180  #define FILTER_VALID_HOOKS ((1 << NF_IP_LOCAL_IN) | (1 << NF_IP_FORWARD) | (1 << NF_IP_LOCAL_OUT))
64181  
64182  /* Standard entry. */
64183 @@ -200,4 +204,3 @@
64184  
64185  module_init(init);
64186  module_exit(fini);
64187 -MODULE_LICENSE("GPL");
64188 diff -Nru a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
64189 --- a/net/ipv4/netfilter/iptable_mangle.c       Wed Jun 11 23:34:58 2003
64190 +++ b/net/ipv4/netfilter/iptable_mangle.c       Sun Aug 24 05:00:28 2003
64191 @@ -14,6 +14,10 @@
64192  #include <net/route.h>
64193  #include <linux/ip.h>
64194  
64195 +MODULE_LICENSE("GPL");
64196 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
64197 +MODULE_DESCRIPTION("iptables mangle table");
64198 +
64199  #define MANGLE_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | \
64200                             (1 << NF_IP_LOCAL_IN) | \
64201                             (1 << NF_IP_FORWARD) | \
64202 @@ -267,4 +271,3 @@
64203  
64204  module_init(init);
64205  module_exit(fini);
64206 -MODULE_LICENSE("GPL");
64207 diff -Nru a/net/ipv4/route.c b/net/ipv4/route.c
64208 --- a/net/ipv4/route.c  Sat Aug 16 12:08:34 2003
64209 +++ b/net/ipv4/route.c  Thu Aug 28 00:02:15 2003
64210 @@ -312,49 +312,6 @@
64211         return 0;
64212  }
64213  
64214 -static int rt_cache_stat_get_info(char *buffer, char **start, off_t offset, int length)
64215 -{
64216 -       unsigned int dst_entries = atomic_read(&ipv4_dst_ops.entries);
64217 -       int i;
64218 -       int len = 0;
64219 -
64220 -       for (i = 0; i < NR_CPUS; i++) {
64221 -               if (!cpu_possible(i))
64222 -                       continue;
64223 -               len += sprintf(buffer+len, "%08x  %08x %08x %08x %08x %08x %08x %08x  %08x %08x %08x %08x %08x %08x %08x %08x %08x \n",
64224 -                              dst_entries,                    
64225 -                              per_cpu_ptr(rt_cache_stat, i)->in_hit,
64226 -                              per_cpu_ptr(rt_cache_stat, i)->in_slow_tot,
64227 -                              per_cpu_ptr(rt_cache_stat, i)->in_slow_mc,
64228 -                              per_cpu_ptr(rt_cache_stat, i)->in_no_route,
64229 -                              per_cpu_ptr(rt_cache_stat, i)->in_brd,
64230 -                              per_cpu_ptr(rt_cache_stat, i)->in_martian_dst,
64231 -                              per_cpu_ptr(rt_cache_stat, i)->in_martian_src,
64232 -
64233 -                              per_cpu_ptr(rt_cache_stat, i)->out_hit,
64234 -                              per_cpu_ptr(rt_cache_stat, i)->out_slow_tot,
64235 -                              per_cpu_ptr(rt_cache_stat, i)->out_slow_mc, 
64236 -
64237 -                              per_cpu_ptr(rt_cache_stat, i)->gc_total,
64238 -                              per_cpu_ptr(rt_cache_stat, i)->gc_ignored,
64239 -                              per_cpu_ptr(rt_cache_stat, i)->gc_goal_miss,
64240 -                              per_cpu_ptr(rt_cache_stat, i)->gc_dst_overflow,
64241 -                              per_cpu_ptr(rt_cache_stat, i)->in_hlist_search,
64242 -                              per_cpu_ptr(rt_cache_stat, i)->out_hlist_search
64243 -
64244 -                       );
64245 -       }
64246 -       len -= offset;
64247 -
64248 -       if (len > length)
64249 -               len = length;
64250 -       if (len < 0)
64251 -               len = 0;
64252 -
64253 -       *start = buffer + offset;
64254 -       return len;
64255 -}
64256 -
64257  static struct seq_operations rt_cache_seq_ops = {
64258         .start  = rt_cache_seq_start,
64259         .next   = rt_cache_seq_next,
64260 @@ -391,22 +348,89 @@
64261         .release = seq_release_private,
64262  };
64263  
64264 -int __init rt_cache_proc_init(void)
64265 +
64266 +static void *rt_cpu_seq_start(struct seq_file *seq, loff_t *pos)
64267  {
64268 -       int rc = 0;
64269 -       struct proc_dir_entry *p = create_proc_entry("rt_cache", S_IRUGO,
64270 -                                                    proc_net);
64271 -       if (p)
64272 -               p->proc_fops = &rt_cache_seq_fops;
64273 -       else
64274 -               rc = -ENOMEM;
64275 -       return rc;
64276 +       int cpu;
64277 +
64278 +       for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
64279 +               if (!cpu_possible(cpu))
64280 +                       continue;
64281 +               *pos = cpu;
64282 +               return per_cpu_ptr(rt_cache_stat, cpu);
64283 +       }
64284 +       return NULL;
64285 +}
64286 +
64287 +static void *rt_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
64288 +{
64289 +       int cpu;
64290 +
64291 +       for (cpu = *pos + 1; cpu < NR_CPUS; ++cpu) {
64292 +               if (!cpu_possible(cpu))
64293 +                       continue;
64294 +               *pos = cpu;
64295 +               return per_cpu_ptr(rt_cache_stat, cpu);
64296 +       }
64297 +       return NULL;
64298 +       
64299  }
64300  
64301 -void __init rt_cache_proc_exit(void)
64302 +static void rt_cpu_seq_stop(struct seq_file *seq, void *v)
64303  {
64304 -       remove_proc_entry("rt_cache", proc_net);
64305 +
64306  }
64307 +
64308 +static int rt_cpu_seq_show(struct seq_file *seq, void *v)
64309 +{
64310 +       struct rt_cache_stat *st = v;
64311 +       
64312 +       seq_printf(seq,"%08x  %08x %08x %08x %08x %08x %08x %08x "
64313 +                  " %08x %08x %08x %08x %08x %08x %08x %08x %08x \n",
64314 +                  atomic_read(&ipv4_dst_ops.entries),
64315 +                  st->in_hit,
64316 +                  st->in_slow_tot,
64317 +                  st->in_slow_mc,
64318 +                  st->in_no_route,
64319 +                  st->in_brd,
64320 +                  st->in_martian_dst,
64321 +                  st->in_martian_src,
64322 +
64323 +                  st->out_hit,
64324 +                  st->out_slow_tot,
64325 +                  st->out_slow_mc, 
64326 +
64327 +                  st->gc_total,
64328 +                  st->gc_ignored,
64329 +                  st->gc_goal_miss,
64330 +                  st->gc_dst_overflow,
64331 +                  st->in_hlist_search,
64332 +                  st->out_hlist_search
64333 +               );
64334 +       return 0;
64335 +}
64336 +
64337 +static struct seq_operations rt_cpu_seq_ops = {
64338 +       .start  = rt_cpu_seq_start,
64339 +       .next   = rt_cpu_seq_next,
64340 +       .stop   = rt_cpu_seq_stop,
64341 +       .show   = rt_cpu_seq_show,
64342 +};
64343 +
64344 +
64345 +static int rt_cpu_seq_open(struct inode *inode, struct file *file)
64346 +{
64347 +       return seq_open(file, &rt_cpu_seq_ops);
64348 +}
64349 +
64350 +static struct file_operations rt_cpu_seq_fops = {
64351 +       .owner   = THIS_MODULE,
64352 +       .open    = rt_cpu_seq_open,
64353 +       .read    = seq_read,
64354 +       .llseek  = seq_lseek,
64355 +       .release = seq_release_private,
64356 +};
64357 +
64358  #endif /* CONFIG_PROC_FS */
64359    
64360  static __inline__ void rt_free(struct rtable *rt)
64361 @@ -2779,11 +2803,12 @@
64362         add_timer(&rt_secret_timer);
64363  
64364  #ifdef CONFIG_PROC_FS
64365 -       if (rt_cache_proc_init())
64366 +       if (!proc_net_fops_create("rt_cache", S_IRUGO, &rt_cache_seq_fops) ||
64367 +           !proc_net_fops_create("rt_cache_stat", S_IRUGO, &rt_cpu_seq_fops))
64368                 goto out_enomem;
64369 -       proc_net_create ("rt_cache_stat", 0, rt_cache_stat_get_info);
64370 +
64371  #ifdef CONFIG_NET_CLS_ROUTE
64372 -       create_proc_read_entry("net/rt_acct", 0, 0, ip_rt_acct_read, NULL);
64373 +       create_proc_read_entry("rt_acct", 0, proc_net, ip_rt_acct_read, NULL);
64374  #endif
64375  #endif
64376  #ifdef CONFIG_XFRM
64377 diff -Nru a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
64378 --- a/net/ipv6/af_inet6.c       Sat Aug  2 18:29:28 2003
64379 +++ b/net/ipv6/af_inet6.c       Tue Sep  2 04:38:10 2003
64380 @@ -893,3 +893,5 @@
64381  }
64382  module_exit(inet6_exit);
64383  #endif /* MODULE */
64384 +
64385 +MODULE_ALIAS_NETPROTO(PF_INET6);
64386 diff -Nru a/net/ipv6/icmp.c b/net/ipv6/icmp.c
64387 --- a/net/ipv6/icmp.c   Mon Aug 18 03:38:34 2003
64388 +++ b/net/ipv6/icmp.c   Mon Sep  1 01:38:00 2003
64389 @@ -70,12 +70,14 @@
64390  DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
64391  
64392  /*
64393 - *     ICMP socket(s) for flow control.
64394 + *     The ICMP socket(s). This is the most convenient way to flow control
64395 + *     our ICMP output as well as maintain a clean interface throughout
64396 + *     all layers. All Socketless IP sends will soon be gone.
64397 + *
64398 + *     On SMP we have one ICMP socket per-cpu.
64399   */
64400 -
64401 -/* XXX We can't use per_cpu because this can be modular... */
64402 -static struct socket *__icmpv6_socket[NR_CPUS];
64403 -#define icmpv6_socket  __icmpv6_socket[smp_processor_id()]
64404 +static DEFINE_PER_CPU(struct socket *, __icmpv6_socket) = NULL;
64405 +#define icmpv6_socket  __get_cpu_var(__icmpv6_socket)
64406  
64407  static int icmpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp);
64408  
64409 @@ -93,11 +95,19 @@
64410         __u32                   csum;
64411  };
64412  
64413 -static __inline__ void icmpv6_xmit_lock(void)
64414 +static __inline__ int icmpv6_xmit_lock(void)
64415  {
64416         local_bh_disable();
64417 -       if (unlikely(!spin_trylock(&icmpv6_socket->sk->sk_lock.slock)))
64418 -               BUG();
64419 +
64420 +       if (unlikely(!spin_trylock(&icmpv6_socket->sk->sk_lock.slock))) {
64421 +               /* This can happen if the output path (f.e. SIT or
64422 +                * ip6ip6 tunnel) signals dst_link_failure() for an
64423 +                * outgoing ICMP6 packet.
64424 +                */
64425 +               local_bh_enable();
64426 +               return 1;
64427 +       }
64428 +       return 0;
64429  }
64430  
64431  static __inline__ void icmpv6_xmit_unlock(void)
64432 @@ -342,7 +352,8 @@
64433         fl.fl_icmp_type = type;
64434         fl.fl_icmp_code = code;
64435  
64436 -       icmpv6_xmit_lock();
64437 +       if (icmpv6_xmit_lock())
64438 +               return;
64439  
64440         if (!icmpv6_xrlim_allow(sk, type, &fl))
64441                 goto out;
64442 @@ -432,7 +443,8 @@
64443         fl.oif = skb->dev->ifindex;
64444         fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
64445  
64446 -       icmpv6_xmit_lock();
64447 +       if (icmpv6_xmit_lock())
64448 +               return;
64449  
64450         if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))
64451                 fl.oif = np->mcast_oif;
64452 @@ -657,33 +669,23 @@
64453  int __init icmpv6_init(struct net_proto_family *ops)
64454  {
64455         struct sock *sk;
64456 -       int i;
64457 +       int err, i, j;
64458  
64459         for (i = 0; i < NR_CPUS; i++) {
64460 -               int err;
64461 -
64462                 if (!cpu_possible(i))
64463                         continue;
64464  
64465                 err = sock_create(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6,
64466 -                                 &__icmpv6_socket[i]);
64467 +                                 &per_cpu(__icmpv6_socket, i));
64468                 if (err < 0) {
64469 -                       int j;
64470 -
64471                         printk(KERN_ERR
64472                                "Failed to initialize the ICMP6 control socket "
64473                                "(err %d).\n",
64474                                err);
64475 -                       for (j = 0; j < i; j++) {
64476 -                               if (!cpu_possible(j))
64477 -                                       continue;
64478 -                               sock_release(__icmpv6_socket[j]);
64479 -                               __icmpv6_socket[j] = NULL; /* for safety */
64480 -                       }
64481 -                       return err;
64482 +                       goto fail;
64483                 }
64484  
64485 -               sk = __icmpv6_socket[i]->sk;
64486 +               sk = per_cpu(__icmpv6_socket, i)->sk;
64487                 sk->sk_allocation = GFP_ATOMIC;
64488                 sk->sk_sndbuf = SK_WMEM_MAX * 2;
64489                 sk->sk_prot->unhash(sk);
64490 @@ -692,16 +694,20 @@
64491  
64492         if (inet6_add_protocol(&icmpv6_protocol, IPPROTO_ICMPV6) < 0) {
64493                 printk(KERN_ERR "Failed to register ICMP6 protocol\n");
64494 -               for (i = 0; i < NR_CPUS; i++) {
64495 -                       if (!cpu_possible(i))
64496 -                               continue;
64497 -                       sock_release(__icmpv6_socket[i]);
64498 -                       __icmpv6_socket[i] = NULL;
64499 -               }
64500 -               return -EAGAIN;
64501 +               err = -EAGAIN;
64502 +               goto fail;
64503         }
64504  
64505         return 0;
64506 +
64507 + fail:
64508 +       for (j = 0; j < i; j++) {
64509 +               if (!cpu_possible(j))
64510 +                       continue;
64511 +               sock_release(per_cpu(__icmpv6_socket, j));
64512 +       }
64513 +
64514 +       return err;
64515  }
64516  
64517  void icmpv6_cleanup(void)
64518 @@ -711,8 +717,7 @@
64519         for (i = 0; i < NR_CPUS; i++) {
64520                 if (!cpu_possible(i))
64521                         continue;
64522 -               sock_release(__icmpv6_socket[i]);
64523 -               __icmpv6_socket[i] = NULL; /* For safety. */
64524 +               sock_release(per_cpu(__icmpv6_socket, i));
64525         }
64526         inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
64527  }
64528 diff -Nru a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
64529 --- a/net/ipv6/ip6_flowlabel.c  Tue Jul  8 17:51:54 2003
64530 +++ b/net/ipv6/ip6_flowlabel.c  Mon Sep  1 07:38:18 2003
64531 @@ -49,7 +49,8 @@
64532  static atomic_t fl_size = ATOMIC_INIT(0);
64533  static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1];
64534  
64535 -static struct timer_list ip6_fl_gc_timer;
64536 +static void ip6_fl_gc(unsigned long dummy);
64537 +static struct timer_list ip6_fl_gc_timer = TIMER_INITIALIZER(ip6_fl_gc, 0, 0);
64538  
64539  /* FL hash table lock: it protects only of GC */
64540  
64541 @@ -93,10 +94,12 @@
64542  
64543  static void fl_release(struct ip6_flowlabel *fl)
64544  {
64545 +       write_lock_bh(&ip6_fl_lock);
64546 +
64547         fl->lastuse = jiffies;
64548         if (atomic_dec_and_test(&fl->users)) {
64549                 unsigned long ttd = fl->lastuse + fl->linger;
64550 -               if ((long)(ttd - fl->expires) > 0)
64551 +               if (time_after(ttd, fl->expires))
64552                         fl->expires = ttd;
64553                 ttd = fl->expires;
64554                 if (fl->opt && fl->share == IPV6_FL_S_EXCL) {
64555 @@ -104,11 +107,12 @@
64556                         fl->opt = NULL;
64557                         kfree(opt);
64558                 }
64559 -               if (!del_timer(&ip6_fl_gc_timer) ||
64560 -                   (long)(ip6_fl_gc_timer.expires - ttd) > 0)
64561 -                       ip6_fl_gc_timer.expires = ttd;
64562 -               add_timer(&ip6_fl_gc_timer);
64563 +               if (!timer_pending(&ip6_fl_gc_timer) ||
64564 +                   time_after(ip6_fl_gc_timer.expires, ttd))
64565 +                       mod_timer(&ip6_fl_gc_timer, ttd);
64566         }
64567 +
64568 +       write_unlock_bh(&ip6_fl_lock);
64569  }
64570  
64571  static void ip6_fl_gc(unsigned long dummy)
64572 @@ -125,16 +129,16 @@
64573                 while ((fl=*flp) != NULL) {
64574                         if (atomic_read(&fl->users) == 0) {
64575                                 unsigned long ttd = fl->lastuse + fl->linger;
64576 -                               if ((long)(ttd - fl->expires) > 0)
64577 +                               if (time_after(ttd, fl->expires))
64578                                         fl->expires = ttd;
64579                                 ttd = fl->expires;
64580 -                               if ((long)(now - ttd) >= 0) {
64581 +                               if (time_after_eq(now, ttd)) {
64582                                         *flp = fl->next;
64583                                         fl_free(fl);
64584                                         atomic_dec(&fl_size);
64585                                         continue;
64586                                 }
64587 -                               if (!sched || (long)(ttd - sched) < 0)
64588 +                               if (!sched || time_before(ttd, sched))
64589                                         sched = ttd;
64590                         }
64591                         flp = &fl->next;
64592 @@ -245,7 +249,7 @@
64593         return opt_space;
64594  }
64595  
64596 -static __u32 check_linger(__u16 ttl)
64597 +static unsigned long check_linger(unsigned long ttl)
64598  {
64599         if (ttl < FL_MIN_LINGER)
64600                 return FL_MIN_LINGER*HZ;
64601 @@ -254,7 +258,7 @@
64602         return ttl*HZ;
64603  }
64604  
64605 -static int fl6_renew(struct ip6_flowlabel *fl, unsigned linger, unsigned expires)
64606 +static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned long expires)
64607  {
64608         linger = check_linger(linger);
64609         if (!linger)
64610 @@ -263,11 +267,11 @@
64611         if (!expires)
64612                 return -EPERM;
64613         fl->lastuse = jiffies;
64614 -       if (fl->linger < linger)
64615 +       if (time_before(fl->linger, linger))
64616                 fl->linger = linger;
64617 -       if (expires < fl->linger)
64618 +       if (time_before(expires, fl->linger))
64619                 expires = fl->linger;
64620 -       if ((long)(fl->expires - (fl->lastuse+expires)) < 0)
64621 +       if (time_before(fl->expires, fl->lastuse + expires))
64622                 fl->expires = fl->lastuse + expires;
64623         return 0;
64624  }
64625 @@ -623,7 +627,7 @@
64626  {
64627         while(fl) {
64628                 seq_printf(seq,
64629 -                          "%05X %-1d %-6d %-6d %-6d %-8ld "
64630 +                          "%05X %-1d %-6d %-6d %-6ld %-8ld "
64631                            "%02x%02x%02x%02x%02x%02x%02x%02x "
64632                            "%-4d\n",
64633                            (unsigned)ntohl(fl->label),
64634 @@ -693,8 +697,6 @@
64635  #ifdef CONFIG_PROC_FS
64636         struct proc_dir_entry *p;
64637  #endif
64638 -       init_timer(&ip6_fl_gc_timer);
64639 -       ip6_fl_gc_timer.function = ip6_fl_gc;
64640  #ifdef CONFIG_PROC_FS
64641         p = create_proc_entry("ip6_flowlabel", S_IRUGO, proc_net);
64642         if (p)
64643 diff -Nru a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
64644 --- a/net/ipv6/ip6_output.c     Mon Aug 18 03:38:34 2003
64645 +++ b/net/ipv6/ip6_output.c     Mon Sep  1 01:44:26 2003
64646 @@ -876,7 +876,7 @@
64647         /* Connection association is same as pre-frag packet */
64648         to->nfct = from->nfct;
64649         nf_conntrack_get(to->nfct);
64650 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
64651 +#ifdef CONFIG_BRIDGE_NETFILTER
64652         to->nf_bridge = from->nf_bridge;
64653         nf_bridge_get(to->nf_bridge);
64654  #endif
64655 diff -Nru a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
64656 --- a/net/ipv6/ip6_tunnel.c     Mon Aug 18 04:52:14 2003
64657 +++ b/net/ipv6/ip6_tunnel.c     Mon Sep  1 01:55:01 2003
64658 @@ -23,7 +23,6 @@
64659  #include <linux/module.h>
64660  #include <linux/errno.h>
64661  #include <linux/types.h>
64662 -#include <linux/socket.h>
64663  #include <linux/sockios.h>
64664  #include <linux/if.h>
64665  #include <linux/in.h>
64666 @@ -37,12 +36,12 @@
64667  #include <linux/init.h>
64668  #include <linux/route.h>
64669  #include <linux/rtnetlink.h>
64670 +#include <linux/netfilter_ipv6.h>
64671  
64672  #include <asm/uaccess.h>
64673  #include <asm/atomic.h>
64674  
64675  #include <net/ip.h>
64676 -#include <net/sock.h>
64677  #include <net/ipv6.h>
64678  #include <net/protocol.h>
64679  #include <net/ip6_route.h>
64680 @@ -63,22 +62,6 @@
64681  
64682  #define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
64683  
64684 -/* socket(s) used by ip6ip6_tnl_xmit() for resending packets */
64685 -static struct socket *__ip6_socket[NR_CPUS];
64686 -#define ip6_socket __ip6_socket[smp_processor_id()]
64687 -
64688 -static void ip6_xmit_lock(void)
64689 -{
64690 -       local_bh_disable();
64691 -       if (unlikely(!spin_trylock(&ip6_socket->sk->sk_lock.slock)))
64692 -               BUG();
64693 -}
64694 -
64695 -static void ip6_xmit_unlock(void)
64696 -{
64697 -       spin_unlock_bh(&ip6_socket->sk->sk_lock.slock);
64698 -}
64699 -
64700  #define HASH_SIZE  32
64701  
64702  #define HASH(addr) (((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \
64703 @@ -101,6 +84,33 @@
64704  /* lock for the tunnel lists */
64705  static rwlock_t ip6ip6_lock = RW_LOCK_UNLOCKED;
64706  
64707 +static inline struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t)
64708 +{
64709 +       struct dst_entry *dst = t->dst_cache;
64710 +
64711 +       if (dst && dst->obsolete && 
64712 +           dst->ops->check(dst, t->dst_cookie) == NULL) {
64713 +               t->dst_cache = NULL;
64714 +               return NULL;
64715 +       }
64716 +
64717 +       return dst;
64718 +}
64719 +
64720 +static inline void ip6_tnl_dst_reset(struct ip6_tnl *t)
64721 +{
64722 +       dst_release(t->dst_cache);
64723 +       t->dst_cache = NULL;
64724 +}
64725 +
64726 +static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
64727 +{
64728 +       struct rt6_info *rt = (struct rt6_info *) dst;
64729 +       t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
64730 +       dst_release(t->dst_cache);
64731 +       t->dst_cache = dst;
64732 +}
64733 +
64734  /**
64735   * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses
64736   *   @remote: the address of the tunnel exit-point 
64737 @@ -294,13 +304,16 @@
64738  static void
64739  ip6ip6_tnl_dev_uninit(struct net_device *dev)
64740  {
64741 +       struct ip6_tnl *t = dev->priv;
64742 +
64743         if (dev == ip6ip6_fb_tnl_dev) {
64744                 write_lock_bh(&ip6ip6_lock);
64745                 tnls_wc[0] = NULL;
64746                 write_unlock_bh(&ip6ip6_lock);
64747         } else {
64748 -               ip6ip6_tnl_unlink((struct ip6_tnl *) dev->priv);
64749 +               ip6ip6_tnl_unlink(t);
64750         }
64751 +       ip6_tnl_dst_reset(t);
64752         dev_put(dev);
64753  }
64754  
64755 @@ -421,7 +434,7 @@
64756                 }
64757                 teli = parse_tlv_tnl_enc_lim(skb, skb->data);
64758  
64759 -               if (teli && teli == info - 2) {
64760 +               if (teli && teli == ntohl(info) - 2) {
64761                         tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
64762                         if (tel->encap_limit == 0) {
64763                                 if (net_ratelimit())
64764 @@ -434,10 +447,9 @@
64765                 }
64766                 break;
64767         case ICMPV6_PKT_TOOBIG:
64768 -               mtu = info - offset;
64769 -               if (mtu <= IPV6_MIN_MTU) {
64770 +               mtu = ntohl(info) - offset;
64771 +               if (mtu < IPV6_MIN_MTU)
64772                         mtu = IPV6_MIN_MTU;
64773 -               }
64774                 t->dev->mtu = mtu;
64775  
64776                 if ((len = sizeof (*ipv6h) + ipv6h->payload_len) > mtu) {
64777 @@ -523,112 +535,34 @@
64778         return 0;
64779  }
64780  
64781 -/**
64782 - * txopt_len - get necessary size for new &struct ipv6_txoptions
64783 - *   @orig_opt: old options
64784 - *
64785 - * Return:
64786 - *   Size of old one plus size of tunnel encapsulation limit option
64787 - **/
64788 -
64789 -static inline int
64790 -txopt_len(struct ipv6_txoptions *orig_opt)
64791 -{
64792 -       int len = sizeof (*orig_opt) + 8;
64793 -
64794 -       if (orig_opt && orig_opt->dst0opt)
64795 -               len += ipv6_optlen(orig_opt->dst0opt);
64796 -       return len;
64797 -}
64798 -
64799 -/**
64800 - * merge_options - add encapsulation limit to original options
64801 - *   @encap_limit: number of allowed encapsulation limits
64802 - *   @orig_opt: original options
64803 - * 
64804 - * Return:
64805 - *   Pointer to new &struct ipv6_txoptions containing the tunnel
64806 - *   encapsulation limit
64807 - **/
64808 -
64809 -static struct ipv6_txoptions *
64810 -merge_options(struct sock *sk, __u8 encap_limit,
64811 -             struct ipv6_txoptions *orig_opt)
64812 +static inline struct ipv6_txoptions *create_tel(__u8 encap_limit)
64813  {
64814         struct ipv6_tlv_tnl_enc_lim *tel;
64815         struct ipv6_txoptions *opt;
64816         __u8 *raw;
64817 -       __u8 pad_to = 8;
64818 -       int opt_len = txopt_len(orig_opt);
64819  
64820 -       if (!(opt = sock_kmalloc(sk, opt_len, GFP_ATOMIC))) {
64821 +       int opt_len = sizeof(*opt) + 8;
64822 +
64823 +       if (!(opt = kmalloc(opt_len, GFP_ATOMIC))) {
64824                 return NULL;
64825         }
64826 -
64827         memset(opt, 0, opt_len);
64828         opt->tot_len = opt_len;
64829         opt->dst0opt = (struct ipv6_opt_hdr *) (opt + 1);
64830         opt->opt_nflen = 8;
64831  
64832 -       raw = (__u8 *) opt->dst0opt;
64833 -
64834         tel = (struct ipv6_tlv_tnl_enc_lim *) (opt->dst0opt + 1);
64835         tel->type = IPV6_TLV_TNL_ENCAP_LIMIT;
64836         tel->length = 1;
64837         tel->encap_limit = encap_limit;
64838  
64839 -       if (orig_opt) {
64840 -               __u8 *orig_raw;
64841 -
64842 -               opt->hopopt = orig_opt->hopopt;
64843 -
64844 -               /* Keep the original destination options properly
64845 -                  aligned and merge possible old paddings to the
64846 -                  new padding option */
64847 -               if ((orig_raw = (__u8 *) orig_opt->dst0opt) != NULL) {
64848 -                       __u8 type;
64849 -                       int i = sizeof (struct ipv6_opt_hdr);
64850 -                       pad_to += sizeof (struct ipv6_opt_hdr);
64851 -                       while (i < ipv6_optlen(orig_opt->dst0opt)) {
64852 -                               type = orig_raw[i++];
64853 -                               if (type == IPV6_TLV_PAD0)
64854 -                                       pad_to++;
64855 -                               else if (type == IPV6_TLV_PADN) {
64856 -                                       int len = orig_raw[i++];
64857 -                                       i += len;
64858 -                                       pad_to += len + 2;
64859 -                               } else {
64860 -                                       break;
64861 -                               }
64862 -                       }
64863 -                       opt->dst0opt->hdrlen = orig_opt->dst0opt->hdrlen + 1;
64864 -                       memcpy(raw + pad_to, orig_raw + pad_to - 8,
64865 -                              opt_len - sizeof (*opt) - pad_to);
64866 -               }
64867 -               opt->srcrt = orig_opt->srcrt;
64868 -               opt->opt_nflen += orig_opt->opt_nflen;
64869 -
64870 -               opt->dst1opt = orig_opt->dst1opt;
64871 -               opt->auth = orig_opt->auth;
64872 -               opt->opt_flen = orig_opt->opt_flen;
64873 -       }
64874 +       raw = (__u8 *) opt->dst0opt;
64875         raw[5] = IPV6_TLV_PADN;
64876 -
64877 -       /* subtract lengths of destination suboption header,
64878 -          tunnel encapsulation limit and pad N header */
64879 -       raw[6] = pad_to - 7;
64880 +       raw[6] = 1;
64881  
64882         return opt;
64883  }
64884  
64885 -static int 
64886 -ip6ip6_getfrag(void *from, char *to, int offset, int len, int odd, 
64887 -               struct sk_buff *skb)
64888 -{
64889 -       memcpy(to, (char *) from + offset, len);
64890 -       return 0;
64891 -}
64892 -
64893  /**
64894   * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own
64895   *   @t: the outgoing tunnel device
64896 @@ -656,7 +590,7 @@
64897   *
64898   * Description:
64899   *   Build new header and do some sanity checks on the packet before sending
64900 - *   it to ip6_build_xmit().
64901 + *   it.
64902   *
64903   * Return: 
64904   *   0
64905 @@ -667,18 +601,17 @@
64906         struct ip6_tnl *t = (struct ip6_tnl *) dev->priv;
64907         struct net_device_stats *stats = &t->stat;
64908         struct ipv6hdr *ipv6h = skb->nh.ipv6h;
64909 -       struct ipv6_txoptions *orig_opt = NULL;
64910         struct ipv6_txoptions *opt = NULL;
64911         int encap_limit = -1;
64912         __u16 offset;
64913         struct flowi fl;
64914 -       struct ip6_flowlabel *fl_lbl = NULL;
64915 -       int err = 0;
64916         struct dst_entry *dst;
64917 -       int link_failure = 0;
64918 -       struct sock *sk = ip6_socket->sk;
64919 -       struct ipv6_pinfo *np = inet6_sk(sk);
64920 +       struct net_device *tdev;
64921         int mtu;
64922 +       int max_headroom = sizeof(struct ipv6hdr);
64923 +       u8 proto;
64924 +       int err;
64925 +       int pkt_len;
64926  
64927         if (t->recursion++) {
64928                 stats->collisions++;
64929 @@ -701,58 +634,39 @@
64930         } else if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) {
64931                 encap_limit = t->parms.encap_limit;
64932         }
64933 -       ip6_xmit_lock();
64934 -
64935         memcpy(&fl, &t->fl, sizeof (fl));
64936 +       proto = fl.proto;
64937  
64938         if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
64939                 fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_TCLASS_MASK);
64940         if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL))
64941                 fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_FLOWLABEL_MASK);
64942  
64943 -       if (fl.fl6_flowlabel) {
64944 -               fl_lbl = fl6_sock_lookup(sk, fl.fl6_flowlabel);
64945 -               if (fl_lbl)
64946 -                       orig_opt = fl_lbl->opt;
64947 -       }
64948 -       if (encap_limit >= 0) {
64949 -               if (!(opt = merge_options(sk, encap_limit, orig_opt))) {
64950 -                       goto tx_err_free_fl_lbl;
64951 -               }
64952 -       } else {
64953 -               opt = orig_opt;
64954 -       }
64955 -       dst = __sk_dst_check(sk, np->dst_cookie);
64956 +       if (encap_limit >= 0 && (opt = create_tel(encap_limit)) == NULL)
64957 +               goto tx_err;
64958  
64959 -       if (dst) {
64960 -               if (np->daddr_cache == NULL ||
64961 -                   ipv6_addr_cmp(&fl.fl6_dst, np->daddr_cache) ||
64962 -                   (fl.oif && fl.oif != dst->dev->ifindex)) {
64963 -                       dst = NULL;
64964 -               }
64965 -       }
64966 -       if (dst == NULL) {
64967 -               dst = ip6_route_output(sk, &fl);
64968 -               if (dst->error) {
64969 -                       stats->tx_carrier_errors++;
64970 -                       link_failure = 1;
64971 -                       goto tx_err_dst_release;
64972 -               }
64973 -               /* local routing loop */
64974 -               if (dst->dev == dev) {
64975 -                       stats->collisions++;
64976 -                       if (net_ratelimit())
64977 -                               printk(KERN_WARNING 
64978 -                                      "%s: Local routing loop detected!\n",
64979 -                                      t->parms.name);
64980 -                       goto tx_err_dst_release;
64981 -               }
64982 -               ipv6_addr_copy(&np->daddr, &fl.fl6_dst);
64983 -               ipv6_addr_copy(&np->saddr, &fl.fl6_src);
64984 +       if ((dst = ip6_tnl_dst_check(t)) != NULL)
64985 +               dst_hold(dst);
64986 +       else
64987 +               dst = ip6_route_output(NULL, &fl);
64988 +
64989 +       if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0)
64990 +               goto tx_err_link_failure;
64991 +
64992 +       tdev = dst->dev;
64993 +
64994 +       if (tdev == dev) {
64995 +               stats->collisions++;
64996 +               if (net_ratelimit())
64997 +                       printk(KERN_WARNING 
64998 +                              "%s: Local routing loop detected!\n",
64999 +                              t->parms.name);
65000 +               goto tx_err_dst_release;
65001         }
65002         mtu = dst_pmtu(dst) - sizeof (*ipv6h);
65003         if (opt) {
65004 -               mtu -= (opt->opt_nflen + opt->opt_flen);
65005 +               max_headroom += 8;
65006 +               mtu -= 8;
65007         }
65008         if (mtu < IPV6_MIN_MTU)
65009                 mtu = IPV6_MIN_MTU;
65010 @@ -765,41 +679,71 @@
65011                 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, dev);
65012                 goto tx_err_dst_release;
65013         }
65014 -       err = ip6_append_data(sk, ip6ip6_getfrag, skb->nh.raw, skb->len, 0,
65015 -                             t->parms.hop_limit, opt, &fl, 
65016 -                             (struct rt6_info *)dst, MSG_DONTWAIT);
65017 +       skb->h.raw = skb->nh.raw;
65018  
65019 -       if (err) {
65020 -               ip6_flush_pending_frames(sk);
65021 -       } else {
65022 -               err = ip6_push_pending_frames(sk);
65023 -               err = (err < 0 ? err : 0);
65024 +       /*
65025 +        * Okay, now see if we can stuff it in the buffer as-is.
65026 +        */
65027 +       max_headroom += LL_RESERVED_SPACE(tdev);
65028 +       
65029 +       if (skb_headroom(skb) < max_headroom || 
65030 +           skb_cloned(skb) || skb_shared(skb)) {
65031 +               struct sk_buff *new_skb;
65032 +               
65033 +               if (!(new_skb = skb_realloc_headroom(skb, max_headroom)))
65034 +                       goto tx_err_dst_release;
65035 +
65036 +               if (skb->sk)
65037 +                       skb_set_owner_w(new_skb, skb->sk);
65038 +               kfree_skb(skb);
65039 +               skb = new_skb;
65040         }
65041 -       if (!err) {
65042 -               stats->tx_bytes += skb->len;
65043 +       dst_release(skb->dst);
65044 +       skb->dst = dst_clone(dst);
65045 +
65046 +       if (opt)
65047 +               ipv6_push_nfrag_opts(skb, opt, &proto, NULL);
65048 +
65049 +       skb->nh.raw = skb_push(skb, sizeof(struct ipv6hdr));
65050 +       ipv6h = skb->nh.ipv6h;
65051 +       *(u32*)ipv6h = fl.fl6_flowlabel | htonl(0x60000000);
65052 +       ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
65053 +       ipv6h->hop_limit = t->parms.hop_limit;
65054 +       ipv6h->nexthdr = proto;
65055 +       ipv6_addr_copy(&ipv6h->saddr, &fl.fl6_src);
65056 +       ipv6_addr_copy(&ipv6h->daddr, &fl.fl6_dst);
65057 +#ifdef CONFIG_NETFILTER
65058 +       nf_conntrack_put(skb->nfct);
65059 +       skb->nfct = NULL;
65060 +#ifdef CONFIG_NETFILTER_DEBUG
65061 +       skb->nf_debug = 0;
65062 +#endif
65063 +#endif
65064 +       pkt_len = skb->len;
65065 +       err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, 
65066 +                     skb->dst->dev, dst_output);
65067 +
65068 +       if (err == NET_XMIT_SUCCESS || err == NET_XMIT_CN) {
65069 +               stats->tx_bytes += pkt_len;
65070                 stats->tx_packets++;
65071         } else {
65072                 stats->tx_errors++;
65073                 stats->tx_aborted_errors++;
65074         }
65075 -       if (opt && opt != orig_opt)
65076 -               sock_kfree_s(sk, opt, opt->tot_len);
65077 +       ip6_tnl_dst_store(t, dst);
65078 +
65079 +       if (opt)
65080 +               kfree(opt);
65081  
65082 -       fl6_sock_release(fl_lbl);
65083 -       ip6_dst_store(sk, dst, &np->daddr);
65084 -       ip6_xmit_unlock();
65085 -       kfree_skb(skb);
65086         t->recursion--;
65087         return 0;
65088 +tx_err_link_failure:
65089 +       stats->tx_carrier_errors++;
65090 +       dst_link_failure(skb);
65091  tx_err_dst_release:
65092         dst_release(dst);
65093 -       if (opt && opt != orig_opt)
65094 -               sock_kfree_s(sk, opt, opt->tot_len);
65095 -tx_err_free_fl_lbl:
65096 -       fl6_sock_release(fl_lbl);
65097 -       ip6_xmit_unlock();
65098 -       if (link_failure)
65099 -               dst_link_failure(skb);
65100 +       if (opt)
65101 +               kfree(opt);
65102  tx_err:
65103         stats->tx_errors++;
65104         stats->tx_dropped++;
65105 @@ -851,9 +795,12 @@
65106  {
65107         struct net_device *dev = t->dev;
65108         struct ip6_tnl_parm *p = &t->parms;
65109 -       struct flowi *fl;
65110 +       struct flowi *fl = &t->fl;
65111 +
65112 +       memcpy(&dev->dev_addr, &p->laddr, sizeof(struct in6_addr));
65113 +       memcpy(&dev->broadcast, &p->raddr, sizeof(struct in6_addr));
65114 +
65115         /* Set up flowi template */
65116 -       fl = &t->fl;
65117         ipv6_addr_copy(&fl->fl6_src, &p->laddr);
65118         ipv6_addr_copy(&fl->fl6_dst, &p->raddr);
65119         fl->oif = p->link;
65120 @@ -878,10 +825,7 @@
65121                 if (rt == NULL)
65122                         return;
65123  
65124 -               /* as long as tunnels use the same socket for transmission,
65125 -                  locally nested tunnels won't work */
65126 -               
65127 -               if (rt->rt6i_dev && rt->rt6i_dev->type != ARPHRD_TUNNEL6) {
65128 +               if (rt->rt6i_dev) {
65129                         dev->iflink = rt->rt6i_dev->ifindex;
65130  
65131                         dev->hard_header_len = rt->rt6i_dev->hard_header_len +
65132 @@ -1083,7 +1027,7 @@
65133  {
65134         SET_MODULE_OWNER(dev);
65135         dev->uninit = ip6ip6_tnl_dev_uninit;
65136 -       dev->destructor = (void (*)(struct net_device *))kfree;
65137 +       dev->destructor = free_netdev;
65138         dev->hard_start_xmit = ip6ip6_tnl_xmit;
65139         dev->get_stats = ip6ip6_tnl_get_stats;
65140         dev->do_ioctl = ip6ip6_tnl_ioctl;
65141 @@ -1094,10 +1038,7 @@
65142         dev->mtu = ETH_DATA_LEN - sizeof (struct ipv6hdr);
65143         dev->flags |= IFF_NOARP;
65144         dev->iflink = 0;
65145 -       /* Hmm... MAX_ADDR_LEN is 8, so the ipv6 addresses can't be
65146 -          copied to dev->dev_addr and dev->broadcast, like the ipv4
65147 -          addresses were in ipip.c, ip_gre.c and sit.c. */
65148 -       dev->addr_len = 0;
65149 +       dev->addr_len = sizeof(struct in6_addr);
65150  }
65151  
65152  
65153 @@ -1139,7 +1080,7 @@
65154  int ip6ip6_fb_tnl_dev_init(struct net_device *dev)
65155  {
65156         struct ip6_tnl *t = dev->priv;
65157 -       ip6ip6_tnl_dev_init_gen(dev); 
65158 +       ip6ip6_tnl_dev_init_gen(dev);
65159         dev_hold(dev);
65160         tnls_wc[0] = t;
65161         return 0;
65162 @@ -1159,61 +1100,28 @@
65163  
65164  int __init ip6_tunnel_init(void)
65165  {
65166 -       int i, j, err;
65167 -       struct sock *sk;
65168 -       struct ipv6_pinfo *np;
65169 -
65170 -       for (i = 0; i < NR_CPUS; i++) {
65171 -               if (!cpu_possible(i))
65172 -                       continue;
65173 -
65174 -               err = sock_create(PF_INET6, SOCK_RAW, IPPROTO_IPV6, 
65175 -                                 &__ip6_socket[i]);
65176 -               if (err < 0) {
65177 -                       printk(KERN_ERR 
65178 -                              "Failed to create the IPv6 tunnel socket "
65179 -                              "(err %d).\n", 
65180 -                              err);
65181 -                       goto fail;
65182 -               }
65183 -               sk = __ip6_socket[i]->sk;
65184 -               sk->sk_allocation = GFP_ATOMIC;
65185 -
65186 -               np = inet6_sk(sk);
65187 -               np->hop_limit = 255;
65188 -               np->mc_loop = 0;
65189 +       int  err;
65190  
65191 -               sk->sk_prot->unhash(sk);
65192 -       }
65193         if ((err = inet6_add_protocol(&ip6ip6_protocol, IPPROTO_IPV6)) < 0) {
65194                 printk(KERN_ERR "Failed to register IPv6 protocol\n");
65195 -               goto fail;
65196 +               return err;
65197         }
65198 -
65199 -       
65200         ip6ip6_fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
65201                                          ip6ip6_tnl_dev_setup);
65202  
65203         if (!ip6ip6_fb_tnl_dev) {
65204                 err = -ENOMEM;
65205 -               goto tnl_fail;
65206 +               goto fail;
65207         }
65208         ip6ip6_fb_tnl_dev->init = ip6ip6_fb_tnl_dev_init;
65209  
65210         if ((err = register_netdev(ip6ip6_fb_tnl_dev))) {
65211                 kfree(ip6ip6_fb_tnl_dev);
65212 -               goto tnl_fail;
65213 +               goto fail;
65214         }
65215         return 0;
65216 -tnl_fail:
65217 -       inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
65218  fail:
65219 -       for (j = 0; j < i; j++) {
65220 -               if (!cpu_possible(j))
65221 -                       continue;
65222 -               sock_release(__ip6_socket[j]);
65223 -               __ip6_socket[j] = NULL;
65224 -       }
65225 +       inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
65226         return err;
65227  }
65228  
65229 @@ -1223,18 +1131,8 @@
65230  
65231  void ip6_tunnel_cleanup(void)
65232  {
65233 -       int i;
65234 -
65235         unregister_netdev(ip6ip6_fb_tnl_dev);
65236 -
65237         inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
65238 -
65239 -       for (i = 0; i < NR_CPUS; i++) {
65240 -               if (!cpu_possible(i))
65241 -                       continue;
65242 -               sock_release(__ip6_socket[i]);
65243 -               __ip6_socket[i] = NULL;
65244 -       }
65245  }
65246  
65247  #ifdef MODULE
65248 diff -Nru a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c
65249 --- a/net/ipv6/ipv6_syms.c      Sat Aug  9 02:14:55 2003
65250 +++ b/net/ipv6/ipv6_syms.c      Mon Sep  1 01:55:02 2003
65251 @@ -45,3 +45,4 @@
65252  EXPORT_SYMBOL(ip6_append_data);
65253  EXPORT_SYMBOL(ip6_flush_pending_frames);
65254  EXPORT_SYMBOL(ip6_push_pending_frames);
65255 +EXPORT_SYMBOL(ipv6_push_nfrag_opts);
65256 diff -Nru a/net/ipv6/mcast.c b/net/ipv6/mcast.c
65257 --- a/net/ipv6/mcast.c  Thu Aug 21 14:48:55 2003
65258 +++ b/net/ipv6/mcast.c  Wed Aug 27 23:45:13 2003
65259 @@ -2078,6 +2078,7 @@
65260                         break;
65261                 }
65262                 read_unlock_bh(&idev->lock);
65263 +               in6_dev_put(idev);
65264         }
65265         return im;
65266  }
65267 @@ -2135,7 +2136,9 @@
65268         if (likely(state->idev != NULL)) {
65269                 read_unlock_bh(&state->idev->lock);
65270                 in6_dev_put(state->idev);
65271 +               state->idev = NULL;
65272         }
65273 +       state->dev = NULL;
65274         read_unlock(&dev_base_lock);
65275  }
65276  
65277 @@ -2225,6 +2228,7 @@
65278                         spin_unlock_bh(&im->mca_lock);
65279                 }
65280                 read_unlock_bh(&idev->lock);
65281 +               in6_dev_put(idev);
65282         }
65283         return psf;
65284  }
65285 @@ -2291,12 +2295,16 @@
65286  static void igmp6_mcf_seq_stop(struct seq_file *seq, void *v)
65287  {
65288         struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
65289 -       if (likely(state->im != NULL))
65290 +       if (likely(state->im != NULL)) {
65291                 spin_unlock_bh(&state->im->mca_lock);
65292 +               state->im = NULL;
65293 +       }
65294         if (likely(state->idev != NULL)) {
65295                 read_unlock_bh(&state->idev->lock);
65296                 in6_dev_put(state->idev);
65297 +               state->idev = NULL;
65298         }
65299 +       state->dev = NULL;
65300         read_unlock(&dev_base_lock);
65301  }
65302  
65303 diff -Nru a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
65304 --- a/net/ipv6/netfilter/Kconfig        Mon Mar  3 01:40:45 2003
65305 +++ b/net/ipv6/netfilter/Kconfig        Sun Aug 24 04:58:54 2003
65306 @@ -3,14 +3,14 @@
65307  #
65308  
65309  menu "IPv6: Netfilter Configuration"
65310 -       depends on INET && EXPERIMENTAL && IPV6!=n && NETFILTER
65311 +       depends on INET && IPV6!=n && NETFILTER
65312  
65313  #tristate 'Connection tracking (required for masq/NAT)' CONFIG_IP6_NF_CONNTRACK
65314  #if [ "$CONFIG_IP6_NF_CONNTRACK" != "n" ]; then
65315  #  dep_tristate '  FTP protocol support' CONFIG_IP6_NF_FTP $CONFIG_IP6_NF_CONNTRACK
65316  #fi
65317  config IP6_NF_QUEUE
65318 -       tristate "Userspace queueing via NETLINK (EXPERIMENTAL)"
65319 +       tristate "Userspace queueing via NETLINK"
65320         ---help---
65321  
65322           This option adds a queue handler to the kernel for IPv6
65323 @@ -62,7 +62,7 @@
65324  
65325  config IP6_NF_MATCH_RT
65326         tristate "Routing header match support"
65327 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
65328 +       depends on IP6_NF_IPTABLES
65329         help
65330           rt matching allows you to match packets based on the routing
65331           header of the packet.
65332 @@ -72,7 +72,7 @@
65333  
65334  config IP6_NF_MATCH_OPTS
65335         tristate "Hop-by-hop and Dst opts header match support"
65336 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
65337 +       depends on IP6_NF_IPTABLES
65338         help
65339           This allows one to match packets based on the hop-by-hop
65340           and destination options headers of a packet.
65341 @@ -82,7 +82,7 @@
65342  
65343  config IP6_NF_MATCH_FRAG
65344         tristate "Fragmentation header match support"
65345 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
65346 +       depends on IP6_NF_IPTABLES
65347         help
65348           frag matching allows you to match packets based on the fragmentation
65349           header of the packet.
65350 @@ -112,7 +112,7 @@
65351           <file:Documentation/modules.txt>.  If unsure, say `N'.
65352  
65353  config IP6_NF_MATCH_OWNER
65354 -       tristate "Owner match support (EXPERIMENTAL)"
65355 +       tristate "Owner match support"
65356         depends on IP6_NF_IPTABLES
65357         help
65358           Packet owner matching allows you to match locally-generated packets
65359 @@ -134,8 +134,8 @@
65360           <file:Documentation/modules.txt>.  If unsure, say `N'.
65361  
65362  config IP6_NF_MATCH_IPV6HEADER
65363 -       tristate "IPv6 Extension Headers Match (EXPERIMENTAL)"
65364 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
65365 +       tristate "IPv6 Extension Headers Match"
65366 +       depends on IP6_NF_IPTABLES
65367         help
65368           This module allows one to match packets based upon
65369           the ipv6 extension headers.
65370 @@ -144,8 +144,8 @@
65371           <file:Documentation/modules.txt>.  If unsure, say `N'.
65372  
65373  config IP6_NF_MATCH_AHESP
65374 -       tristate "AH/ESP match support (EXPERIMENTAL)"
65375 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
65376 +       tristate "AH/ESP match support"
65377 +       depends on IP6_NF_IPTABLES
65378         help
65379           This module allows one to match AH and ESP packets.
65380  
65381 @@ -163,7 +163,7 @@
65382           Documentation/modules.txt.  If unsure, say `N'.
65383  
65384  config IP6_NF_MATCH_EUI64
65385 -       tristate "EUI64 address check (EXPERIMENTAL)"
65386 +       tristate "EUI64 address check"
65387         depends on IP6_NF_IPTABLES
65388         help
65389           This module performs checking on the IPv6 source address
65390 diff -Nru a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
65391 --- a/net/ipv6/netfilter/ip6_tables.c   Sat Aug  2 18:29:29 2003
65392 +++ b/net/ipv6/netfilter/ip6_tables.c   Sun Aug 24 05:00:28 2003
65393 @@ -26,6 +26,10 @@
65394  
65395  #include <linux/netfilter_ipv6/ip6_tables.h>
65396  
65397 +MODULE_LICENSE("GPL");
65398 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
65399 +MODULE_DESCRIPTION("IPv6 packet filter");
65400 +
65401  #define IPV6_HDR_LEN   (sizeof(struct ipv6hdr))
65402  #define IPV6_OPTHDR_LEN        (sizeof(struct ipv6_opt_hdr))
65403  
65404 @@ -1923,4 +1927,3 @@
65405  
65406  module_init(init);
65407  module_exit(fini);
65408 -MODULE_LICENSE("GPL");
65409 diff -Nru a/net/ipv6/netfilter/ip6t_MARK.c b/net/ipv6/netfilter/ip6t_MARK.c
65410 --- a/net/ipv6/netfilter/ip6t_MARK.c    Tue Feb  5 07:24:40 2002
65411 +++ b/net/ipv6/netfilter/ip6t_MARK.c    Sun Aug 24 05:00:28 2003
65412 @@ -7,6 +7,9 @@
65413  #include <linux/netfilter_ipv6/ip6_tables.h>
65414  #include <linux/netfilter_ipv6/ip6t_MARK.h>
65415  
65416 +MODULE_LICENSE("GPL");
65417 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
65418 +
65419  static unsigned int
65420  target(struct sk_buff **pskb,
65421         unsigned int hooknum,
65422 @@ -65,4 +68,3 @@
65423  
65424  module_init(init);
65425  module_exit(fini);
65426 -MODULE_LICENSE("GPL");
65427 diff -Nru a/net/ipv6/netfilter/ip6t_eui64.c b/net/ipv6/netfilter/ip6t_eui64.c
65428 --- a/net/ipv6/netfilter/ip6t_eui64.c   Thu Mar 20 00:43:40 2003
65429 +++ b/net/ipv6/netfilter/ip6t_eui64.c   Sun Aug 24 05:00:28 2003
65430 @@ -6,6 +6,10 @@
65431  
65432  #include <linux/netfilter_ipv6/ip6_tables.h>
65433  
65434 +MODULE_DESCRIPTION("IPv6 EUI64 address checking match");
65435 +MODULE_LICENSE("GPL");
65436 +MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
65437 +
65438  static int
65439  match(const struct sk_buff *skb,
65440        const struct net_device *in,
65441 @@ -88,6 +92,3 @@
65442  
65443  module_init(init);
65444  module_exit(fini);
65445 -MODULE_DESCRIPTION("IPv6 EUI64 address checking match");
65446 -MODULE_LICENSE("GPL");
65447 -MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
65448 diff -Nru a/net/ipv6/netfilter/ip6t_length.c b/net/ipv6/netfilter/ip6t_length.c
65449 --- a/net/ipv6/netfilter/ip6t_length.c  Thu Mar 20 00:43:40 2003
65450 +++ b/net/ipv6/netfilter/ip6t_length.c  Sun Aug 24 05:00:28 2003
65451 @@ -5,6 +5,10 @@
65452  #include <linux/netfilter_ipv6/ip6t_length.h>
65453  #include <linux/netfilter_ipv6/ip6_tables.h>
65454  
65455 +MODULE_LICENSE("GPL");
65456 +MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
65457 +MODULE_DESCRIPTION("IPv6 packet length match");
65458 +
65459  static int
65460  match(const struct sk_buff *skb,
65461        const struct net_device *in,
65462 diff -Nru a/net/ipv6/netfilter/ip6t_limit.c b/net/ipv6/netfilter/ip6t_limit.c
65463 --- a/net/ipv6/netfilter/ip6t_limit.c   Thu Mar 20 00:43:40 2003
65464 +++ b/net/ipv6/netfilter/ip6t_limit.c   Sun Aug 24 05:00:28 2003
65465 @@ -15,6 +15,10 @@
65466  #include <linux/netfilter_ipv6/ip6_tables.h>
65467  #include <linux/netfilter_ipv6/ip6t_limit.h>
65468  
65469 +MODULE_LICENSE("GPL");
65470 +MODULE_AUTHOR("Herve Eychenne <rv@wallfire.org>");
65471 +MODULE_DESCRIPTION("rate limiting within ip6tables");
65472 +
65473  /* The algorithm used is the Simple Token Bucket Filter (TBF)
65474   * see net/sched/sch_tbf.c in the linux source tree
65475   */
65476 @@ -136,4 +140,3 @@
65477  
65478  module_init(init);
65479  module_exit(fini);
65480 -MODULE_LICENSE("GPL");
65481 diff -Nru a/net/ipv6/netfilter/ip6t_mac.c b/net/ipv6/netfilter/ip6t_mac.c
65482 --- a/net/ipv6/netfilter/ip6t_mac.c     Thu Mar 20 00:43:40 2003
65483 +++ b/net/ipv6/netfilter/ip6t_mac.c     Sun Aug 24 05:00:28 2003
65484 @@ -6,6 +6,10 @@
65485  #include <linux/netfilter_ipv6/ip6t_mac.h>
65486  #include <linux/netfilter_ipv6/ip6_tables.h>
65487  
65488 +MODULE_LICENSE("GPL");
65489 +MODULE_DESCRIPTION("MAC address matching module for IPv6");
65490 +MODULE_AUTHOR("Netfilter Core Teaam <coreteam@netfilter.org>");
65491 +
65492  static int
65493  match(const struct sk_buff *skb,
65494        const struct net_device *in,
65495 @@ -66,5 +70,3 @@
65496  
65497  module_init(init);
65498  module_exit(fini);
65499 -MODULE_LICENSE("GPL");
65500 -MODULE_DESCRIPTION("MAC address matching module for IPv6");
65501 diff -Nru a/net/ipv6/netfilter/ip6t_mark.c b/net/ipv6/netfilter/ip6t_mark.c
65502 --- a/net/ipv6/netfilter/ip6t_mark.c    Thu Mar 20 00:43:40 2003
65503 +++ b/net/ipv6/netfilter/ip6t_mark.c    Sun Aug 24 05:00:28 2003
65504 @@ -5,6 +5,10 @@
65505  #include <linux/netfilter_ipv6/ip6t_mark.h>
65506  #include <linux/netfilter_ipv6/ip6_tables.h>
65507  
65508 +MODULE_LICENSE("GPL");
65509 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
65510 +MODULE_DESCRIPTION("ip6tables mark match");
65511 +
65512  static int
65513  match(const struct sk_buff *skb,
65514        const struct net_device *in,
65515 @@ -52,4 +56,3 @@
65516  
65517  module_init(init);
65518  module_exit(fini);
65519 -MODULE_LICENSE("GPL");
65520 diff -Nru a/net/ipv6/netfilter/ip6t_multiport.c b/net/ipv6/netfilter/ip6t_multiport.c
65521 --- a/net/ipv6/netfilter/ip6t_multiport.c       Thu Mar 20 00:43:40 2003
65522 +++ b/net/ipv6/netfilter/ip6t_multiport.c       Sun Aug 24 05:00:28 2003
65523 @@ -9,6 +9,10 @@
65524  #include <linux/netfilter_ipv6/ip6t_multiport.h>
65525  #include <linux/netfilter_ipv6/ip6_tables.h>
65526  
65527 +MODULE_LICENSE("GPL");
65528 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
65529 +MODULE_DESCRIPTION("ip6tables match for multiple ports");
65530 +
65531  #if 0
65532  #define duprintf(format, args...) printk(format , ## args)
65533  #else
65534 diff -Nru a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
65535 --- a/net/ipv6/netfilter/ip6table_filter.c      Mon Apr 28 02:27:56 2003
65536 +++ b/net/ipv6/netfilter/ip6table_filter.c      Sun Aug 24 05:00:28 2003
65537 @@ -6,6 +6,10 @@
65538  #include <linux/module.h>
65539  #include <linux/netfilter_ipv6/ip6_tables.h>
65540  
65541 +MODULE_LICENSE("GPL");
65542 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
65543 +MODULE_DESCRIPTION("ip6tables filter table");
65544 +
65545  #define FILTER_VALID_HOOKS ((1 << NF_IP6_LOCAL_IN) | (1 << NF_IP6_FORWARD) | (1 << NF_IP6_LOCAL_OUT))
65546  
65547  /* Standard entry. */
65548 @@ -202,4 +206,3 @@
65549  
65550  module_init(init);
65551  module_exit(fini);
65552 -MODULE_LICENSE("GPL");
65553 diff -Nru a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
65554 --- a/net/ipv6/netfilter/ip6table_mangle.c      Mon Apr 28 02:27:56 2003
65555 +++ b/net/ipv6/netfilter/ip6table_mangle.c      Sun Aug 24 05:00:28 2003
65556 @@ -6,6 +6,10 @@
65557  #include <linux/module.h>
65558  #include <linux/netfilter_ipv6/ip6_tables.h>
65559  
65560 +MODULE_LICENSE("GPL");
65561 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
65562 +MODULE_DESCRIPTION("ip6tables mangle table");
65563 +
65564  #define MANGLE_VALID_HOOKS ((1 << NF_IP6_PRE_ROUTING) | \
65565                             (1 << NF_IP6_LOCAL_IN) | \
65566                             (1 << NF_IP6_FORWARD) | \
65567 @@ -279,4 +283,3 @@
65568  
65569  module_init(init);
65570  module_exit(fini);
65571 -MODULE_LICENSE("GPL");
65572 diff -Nru a/net/ipv6/route.c b/net/ipv6/route.c
65573 --- a/net/ipv6/route.c  Mon Aug 18 03:49:00 2003
65574 +++ b/net/ipv6/route.c  Sat Aug 30 21:26:12 2003
65575 @@ -577,7 +577,7 @@
65576         rt->rt6i_dev      = dev;
65577         rt->rt6i_nexthop  = neigh;
65578         rt->rt6i_expires  = 0;
65579 -       rt->rt6i_flags    = RTF_LOCAL;
65580 +       rt->rt6i_flags    = RTF_LOCAL | RTF_NDISC;
65581         rt->rt6i_metric   = 0;
65582         atomic_set(&rt->u.dst.__refcnt, 1);
65583         rt->u.dst.metrics[RTAX_HOPLIMIT-1] = 255;
65584 @@ -831,7 +831,7 @@
65585                 }
65586         }
65587  
65588 -       rt->rt6i_flags = rtmsg->rtmsg_flags;
65589 +       rt->rt6i_flags = rtmsg->rtmsg_flags & ~RTF_NDISC;
65590  
65591  install_route:
65592         if (rta && rta[RTA_METRICS-1]) {
65593 @@ -1123,6 +1123,8 @@
65594  static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
65595  {
65596         struct rt6_info *rt = ip6_dst_alloc();
65597 +
65598 +       BUG_ON(ort->rt6i_flags & RTF_NDISC);
65599  
65600         if (rt) {
65601                 rt->u.dst.input = ort->u.dst.input;
65602 diff -Nru a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
65603 --- a/net/ipv6/xfrm6_policy.c   Sun Jul 27 19:22:27 2003
65604 +++ b/net/ipv6/xfrm6_policy.c   Sat Aug 30 21:26:12 2003
65605 @@ -55,12 +55,22 @@
65606  __xfrm6_find_bundle(struct flowi *fl, struct rtable *rt, struct xfrm_policy *policy)
65607  {
65608         struct dst_entry *dst;
65609 +       u32 ndisc_bit = 0;
65610 +
65611 +       if (fl->proto == IPPROTO_ICMPV6 &&
65612 +           (fl->fl_icmp_type == NDISC_NEIGHBOUR_ADVERTISEMENT ||
65613 +            fl->fl_icmp_type == NDISC_NEIGHBOUR_SOLICITATION  ||
65614 +            fl->fl_icmp_type == NDISC_ROUTER_SOLICITATION))
65615 +               ndisc_bit = RTF_NDISC;
65616  
65617         /* Still not clear if we should set fl->fl6_{src,dst}... */
65618         read_lock_bh(&policy->lock);
65619         for (dst = policy->bundles; dst; dst = dst->next) {
65620                 struct xfrm_dst *xdst = (struct xfrm_dst*)dst;
65621                 struct in6_addr fl_dst_prefix, fl_src_prefix;
65622 +
65623 +               if ((xdst->u.rt6.rt6i_flags & RTF_NDISC) != ndisc_bit)
65624 +                       continue;
65625  
65626                 ipv6_addr_prefix(&fl_dst_prefix,
65627                                  &fl->fl6_dst,
65628 diff -Nru a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
65629 --- a/net/ipx/af_ipx.c  Wed Jun 18 13:59:01 2003
65630 +++ b/net/ipx/af_ipx.c  Tue Sep  2 04:38:10 2003
65631 @@ -1365,6 +1365,7 @@
65632                         atomic_read(&ipx_sock_nr));
65633  #endif
65634         sock_init_data(sock, sk);
65635 +       sk_set_owner(sk, THIS_MODULE);
65636         sk->sk_no_check = 1;            /* Checksum off by default */
65637         rc = 0;
65638  out:
65639 @@ -2020,3 +2021,4 @@
65640  module_init(ipx_init);
65641  module_exit(ipx_proto_finito);
65642  MODULE_LICENSE("GPL");
65643 +MODULE_ALIAS_NETPROTO(PF_IPX);
65644 diff -Nru a/net/irda/af_irda.c b/net/irda/af_irda.c
65645 --- a/net/irda/af_irda.c        Wed Jun  4 17:57:09 2003
65646 +++ b/net/irda/af_irda.c        Sat Aug 30 19:15:30 2003
65647 @@ -1098,6 +1098,7 @@
65648  
65649         /* Initialise networking socket struct */
65650         sock_init_data(sock, sk);       /* Note : set sk->sk_refcnt to 1 */
65651 +       sk_set_owner(sk, THIS_MODULE);
65652         sk->sk_family = PF_IRDA;
65653         sk->sk_protocol = protocol;
65654         /* Link networking socket and IrDA socket structs together */
65655 diff -Nru a/net/irda/irsyms.c b/net/irda/irsyms.c
65656 --- a/net/irda/irsyms.c Sun May 25 19:36:24 2003
65657 +++ b/net/irda/irsyms.c Tue Sep  2 04:38:10 2003
65658 @@ -351,3 +351,4 @@
65659  #ifdef CONFIG_IRDA_DEBUG
65660  MODULE_PARM(irda_debug, "1l");
65661  #endif
65662 +MODULE_ALIAS_NETPROTO(PF_IRDA);
65663 diff -Nru a/net/key/af_key.c b/net/key/af_key.c
65664 --- a/net/key/af_key.c  Sun Jul 27 16:31:49 2003
65665 +++ b/net/key/af_key.c  Tue Sep  2 04:38:10 2003
65666 @@ -2844,3 +2844,4 @@
65667  module_init(ipsec_pfkey_init);
65668  module_exit(ipsec_pfkey_exit);
65669  MODULE_LICENSE("GPL");
65670 +MODULE_ALIAS_NETPROTO(PF_KEY);
65671 diff -Nru a/net/llc/llc_mac.c b/net/llc/llc_mac.c
65672 --- a/net/llc/llc_mac.c Wed Jun  4 17:57:09 2003
65673 +++ b/net/llc/llc_mac.c Sat Aug 30 19:09:25 2003
65674 @@ -35,7 +35,7 @@
65675  
65676  u8 llc_mac_null_var[IFHWADDRLEN];
65677  
65678 -static void fix_up_incoming_skb(struct sk_buff *skb);
65679 +static int fix_up_incoming_skb(struct sk_buff *skb);
65680  static void llc_station_rcv(struct sk_buff *skb);
65681  static void llc_sap_rcv(struct llc_sap *sap, struct sk_buff *skb);
65682  
65683 @@ -69,7 +69,8 @@
65684         skb = skb_share_check(skb, GFP_ATOMIC);
65685         if (!skb)
65686                 goto out;
65687 -       fix_up_incoming_skb(skb);
65688 +       if (!fix_up_incoming_skb(skb))
65689 +               goto drop;
65690         pdu = llc_pdu_sn_hdr(skb);
65691         if (!pdu->dsap) { /* NULL DSAP, refer to station */
65692                 dprintk("%s: calling llc_station_rcv!\n", __FUNCTION__);
65693 @@ -172,11 +173,15 @@
65694   *     by looking at the two lowest-order bits of the first control field
65695   *     byte; field is either 3 or 4 bytes long.
65696   */
65697 -static void fix_up_incoming_skb(struct sk_buff *skb)
65698 +static int fix_up_incoming_skb(struct sk_buff *skb)
65699  {
65700         u8 llc_len = 2;
65701 -       struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->data;
65702 +       struct llc_pdu_sn *pdu;
65703 +
65704 +       if (!pskb_may_pull(skb, sizeof(*pdu)))
65705 +               return 0;
65706  
65707 +       pdu = (struct llc_pdu_sn *)skb->data;
65708         if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) == LLC_PDU_TYPE_U)
65709                 llc_len = 1;
65710         llc_len += 2;
65711 @@ -188,6 +193,7 @@
65712  
65713                 skb_trim(skb, data_size);
65714         }
65715 +       return 1;
65716  }
65717  
65718  /*
65719 diff -Nru a/net/llc/llc_main.c b/net/llc/llc_main.c
65720 --- a/net/llc/llc_main.c        Mon Jun 16 08:11:36 2003
65721 +++ b/net/llc/llc_main.c        Tue Sep  2 04:38:10 2003
65722 @@ -229,6 +229,7 @@
65723         if (llc_sk_init(sk))
65724                 goto outsk;
65725         sock_init_data(NULL, sk);
65726 +       sk_set_owner(sk, THIS_MODULE);
65727  #ifdef LLC_REFCNT_DEBUG
65728         atomic_inc(&llc_sock_nr);
65729         printk(KERN_DEBUG "LLC socket %p created in %s, now we have %d alive\n", sk,
65730 @@ -603,3 +604,4 @@
65731  MODULE_LICENSE("GPL");
65732  MODULE_AUTHOR("Procom, 1997, Arnaldo C. Melo, Jay Schullist, 2001-2003");
65733  MODULE_DESCRIPTION("LLC 2.0, NET4.0 IEEE 802.2 extended support");
65734 +MODULE_ALIAS_NETPROTO(PF_LLC);
65735 diff -Nru a/net/llc/llc_proc.c b/net/llc/llc_proc.c
65736 --- a/net/llc/llc_proc.c        Mon Jun 16 08:11:36 2003
65737 +++ b/net/llc/llc_proc.c        Sat Aug 30 19:11:23 2003
65738 @@ -245,6 +245,7 @@
65739         llc_proc_dir = proc_mkdir("llc", proc_net);
65740         if (!llc_proc_dir)
65741                 goto out;
65742 +       llc_proc_dir->owner = THIS_MODULE;
65743  
65744         p = create_proc_entry("socket", S_IRUGO, llc_proc_dir);
65745         if (!p)
65746 diff -Nru a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
65747 --- a/net/netlink/af_netlink.c  Sat Jul 12 22:45:18 2003
65748 +++ b/net/netlink/af_netlink.c  Tue Sep  2 12:03:57 2003
65749 @@ -40,6 +40,7 @@
65750  #include <linux/netdevice.h>
65751  #include <linux/rtnetlink.h>
65752  #include <linux/proc_fs.h>
65753 +#include <linux/seq_file.h>
65754  #include <linux/smp_lock.h>
65755  #include <linux/notifier.h>
65756  #include <linux/security.h>
65757 @@ -964,62 +965,108 @@
65758  
65759  #endif
65760  
65761 -
65762  #ifdef CONFIG_PROC_FS
65763 -static int netlink_read_proc(char *buffer, char **start, off_t offset,
65764 -                            int length, int *eof, void *data)
65765 +static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos)
65766  {
65767 -       off_t pos=0;
65768 -       off_t begin=0;
65769 -       int len=0;
65770         int i;
65771         struct sock *s;
65772         struct hlist_node *node;
65773 -       
65774 -       len+= sprintf(buffer,"sk       Eth Pid    Groups   "
65775 -                     "Rmem     Wmem     Dump     Locks\n");
65776 -       
65777 +       loff_t off = 0;
65778 +
65779         for (i=0; i<MAX_LINKS; i++) {
65780 -               read_lock(&nl_table_lock);
65781                 sk_for_each(s, node, &nl_table[i]) {
65782 -                       struct netlink_opt *nlk = nlk_sk(s);
65783 +                       if (off == pos) {
65784 +                               seq->private = (void *) i;
65785 +                               return s;
65786 +                       }
65787 +                       ++off;
65788 +               }
65789 +       }
65790 +       return NULL;
65791 +}
65792  
65793 -                       len+=sprintf(buffer+len,"%p %-3d %-6d %08x %-8d %-8d %p %d",
65794 -                                    s,
65795 -                                    s->sk_protocol,
65796 -                                    nlk->pid,
65797 -                                    nlk->groups,
65798 -                                    atomic_read(&s->sk_rmem_alloc),
65799 -                                    atomic_read(&s->sk_wmem_alloc),
65800 -                                    nlk->cb,
65801 -                                    atomic_read(&s->sk_refcnt)
65802 -                                    );
65803 +static void *netlink_seq_start(struct seq_file *seq, loff_t *pos)
65804 +{
65805 +       read_lock(&nl_table_lock);
65806 +       return *pos ? netlink_seq_socket_idx(seq, *pos - 1) : (void *) 1;
65807 +}
65808 +
65809 +static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
65810 +{
65811 +       struct sock *s;
65812 +
65813 +       ++*pos;
65814  
65815 -                       buffer[len++]='\n';
65816 +       if (v == (void *) 1) 
65817 +               return netlink_seq_socket_idx(seq, 0);
65818                 
65819 -                       pos=begin+len;
65820 -                       if(pos<offset) {
65821 -                               len=0;
65822 -                               begin=pos;
65823 -                       }
65824 -                       if(pos>offset+length) {
65825 -                               read_unlock(&nl_table_lock);
65826 -                               goto done;
65827 +       s = sk_next(v);
65828 +       if (!s) {
65829 +               int i = (int) seq->private; 
65830 +
65831 +               while (++i < MAX_LINKS) {
65832 +                       s = sk_head(&nl_table[i]);
65833 +                       if (s) {
65834 +                               seq->private = (void *) i;
65835 +                               break;
65836                         }
65837                 }
65838 -               read_unlock(&nl_table_lock);
65839         }
65840 -       *eof = 1;
65841 +       return s;
65842 +}
65843  
65844 -done:
65845 -       *start=buffer+(offset-begin);
65846 -       len-=(offset-begin);
65847 -       if(len>length)
65848 -               len=length;
65849 -       if(len<0)
65850 -               len=0;
65851 -       return len;
65852 +static void netlink_seq_stop(struct seq_file *seq, void *v)
65853 +{
65854 +       read_unlock(&nl_table_lock);
65855 +}
65856 +
65857 +
65858 +static int netlink_seq_show(struct seq_file *seq, void *v)
65859 +{
65860 +       if (v == (void *)1) 
65861 +               seq_puts(seq,
65862 +                        "sk       Eth Pid    Groups   "
65863 +                        "Rmem     Wmem     Dump     Locks\n");
65864 +       else {
65865 +               struct sock *s = v;
65866 +               struct netlink_opt *nlk = nlk_sk(s);
65867 +
65868 +               seq_printf(seq, "%p %-3d %-6d %08x %-8d %-8d %p %d\n",
65869 +                          s,
65870 +                          s->sk_protocol,
65871 +                          nlk->pid,
65872 +                          nlk->groups,
65873 +                          atomic_read(&s->sk_rmem_alloc),
65874 +                          atomic_read(&s->sk_wmem_alloc),
65875 +                          nlk->cb,
65876 +                          atomic_read(&s->sk_refcnt)
65877 +                       );
65878 +
65879 +       }
65880 +       return 0;
65881  }
65882 +
65883 +struct seq_operations netlink_seq_ops = {
65884 +       .start  = netlink_seq_start,
65885 +       .next   = netlink_seq_next,
65886 +       .stop   = netlink_seq_stop,
65887 +       .show   = netlink_seq_show,
65888 +};
65889 +
65890 +
65891 +static int netlink_seq_open(struct inode *inode, struct file *file)
65892 +{
65893 +       return seq_open(file, &netlink_seq_ops);
65894 +}
65895 +
65896 +static struct file_operations netlink_seq_fops = {
65897 +       .owner          = THIS_MODULE,
65898 +       .open           = netlink_seq_open,
65899 +       .read           = seq_read,
65900 +       .llseek         = seq_lseek,
65901 +       .release        = seq_release,
65902 +};
65903 +
65904  #endif
65905  
65906  int netlink_register_notifier(struct notifier_block *nb)
65907 @@ -1069,7 +1116,7 @@
65908         }
65909         sock_register(&netlink_family_ops);
65910  #ifdef CONFIG_PROC_FS
65911 -       create_proc_read_entry("net/netlink", 0, 0, netlink_read_proc, NULL);
65912 +       proc_net_fops_create("netlink", 0, &netlink_seq_fops);
65913  #endif
65914         /* The netlink device handler may be needed early. */ 
65915         rtnetlink_init();
65916 @@ -1079,10 +1126,11 @@
65917  static void __exit netlink_proto_exit(void)
65918  {
65919         sock_unregister(PF_NETLINK);
65920 -       remove_proc_entry("net/netlink", NULL);
65921 +       proc_net_remove("netlink");
65922  }
65923  
65924  core_initcall(netlink_proto_init);
65925  module_exit(netlink_proto_exit);
65926  
65927  MODULE_LICENSE("GPL");
65928 +MODULE_ALIAS_NETPROTO(PF_NETLINK);
65929 diff -Nru a/net/netlink/netlink_dev.c b/net/netlink/netlink_dev.c
65930 --- a/net/netlink/netlink_dev.c Sun May 25 19:34:11 2003
65931 +++ b/net/netlink/netlink_dev.c Tue Aug 26 09:25:41 2003
65932 @@ -41,7 +41,7 @@
65933   
65934  static unsigned int netlink_poll(struct file *file, poll_table * wait)
65935  {
65936 -       struct socket *sock = netlink_user[minor(file->f_dentry->d_inode->i_rdev)];
65937 +       struct socket *sock = netlink_user[iminor(file->f_dentry->d_inode)];
65938  
65939         if (sock->ops->poll==NULL)
65940                 return 0;
65941 @@ -56,7 +56,7 @@
65942                              size_t count, loff_t *pos)
65943  {
65944         struct inode *inode = file->f_dentry->d_inode;
65945 -       struct socket *sock = netlink_user[minor(inode->i_rdev)];
65946 +       struct socket *sock = netlink_user[iminor(inode)];
65947         struct msghdr msg;
65948         struct iovec iov;
65949  
65950 @@ -80,7 +80,7 @@
65951                             size_t count, loff_t *pos)
65952  {
65953         struct inode *inode = file->f_dentry->d_inode;
65954 -       struct socket *sock = netlink_user[minor(inode->i_rdev)];
65955 +       struct socket *sock = netlink_user[iminor(inode)];
65956         struct msghdr msg;
65957         struct iovec iov;
65958  
65959 @@ -100,7 +100,7 @@
65960  
65961  static int netlink_open(struct inode * inode, struct file * file)
65962  {
65963 -       unsigned int minor = minor(inode->i_rdev);
65964 +       unsigned int minor = iminor(inode);
65965         struct socket *sock;
65966         struct sockaddr_nl nladdr;
65967         int err;
65968 @@ -132,7 +132,7 @@
65969  
65970  static int netlink_release(struct inode * inode, struct file * file)
65971  {
65972 -       unsigned int minor = minor(inode->i_rdev);
65973 +       unsigned int minor = iminor(inode);
65974         struct socket *sock;
65975  
65976         sock = netlink_user[minor];
65977 @@ -146,7 +146,7 @@
65978  static int netlink_ioctl(struct inode *inode, struct file *file,
65979                     unsigned int cmd, unsigned long arg)
65980  {
65981 -       unsigned int minor = minor(inode->i_rdev);
65982 +       unsigned int minor = iminor(inode);
65983         int retval = 0;
65984  
65985         if (minor >= MAX_LINKS)
65986 diff -Nru a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
65987 --- a/net/netrom/af_netrom.c    Thu Aug 14 21:16:39 2003
65988 +++ b/net/netrom/af_netrom.c    Tue Sep  2 04:38:10 2003
65989 @@ -433,6 +433,7 @@
65990         nr = nr_sk(sk);
65991  
65992         sock_init_data(sock, sk);
65993 +       sk_set_owner(sk, THIS_MODULE);
65994  
65995         sock->ops    = &nr_proto_ops;
65996         sk->sk_protocol = protocol;
65997 @@ -473,6 +474,7 @@
65998         nr = nr_sk(sk);
65999  
66000         sock_init_data(NULL, sk);
66001 +       sk_set_owner(sk, THIS_MODULE);
66002  
66003         sk->sk_type     = osk->sk_type;
66004         sk->sk_socket   = osk->sk_socket;
66005 @@ -1458,6 +1460,7 @@
66006  MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>");
66007  MODULE_DESCRIPTION("The amateur radio NET/ROM network and transport layer protocol");
66008  MODULE_LICENSE("GPL");
66009 +MODULE_ALIAS_NETPROTO(PF_NETROM);
66010  
66011  static void __exit nr_exit(void)
66012  {
66013 diff -Nru a/net/netsyms.c b/net/netsyms.c
66014 --- a/net/netsyms.c     Tue Aug 19 22:13:11 2003
66015 +++ b/net/netsyms.c     Mon Sep  1 17:25:54 2003
66016 @@ -631,7 +631,10 @@
66017  /* ethtool.c */
66018  EXPORT_SYMBOL(ethtool_op_get_link);
66019  EXPORT_SYMBOL(ethtool_op_get_tx_csum);
66020 +EXPORT_SYMBOL(ethtool_op_set_tx_csum);
66021  EXPORT_SYMBOL(ethtool_op_get_sg);
66022  EXPORT_SYMBOL(ethtool_op_set_sg);
66023 +EXPORT_SYMBOL(ethtool_op_get_tso);
66024 +EXPORT_SYMBOL(ethtool_op_set_tso);
66025  
66026  #endif  /* CONFIG_NET */
66027 diff -Nru a/net/packet/af_packet.c b/net/packet/af_packet.c
66028 --- a/net/packet/af_packet.c    Wed Jul  2 08:40:36 2003
66029 +++ b/net/packet/af_packet.c    Tue Sep  2 04:38:10 2003
66030 @@ -1832,3 +1832,4 @@
66031  module_init(packet_init);
66032  module_exit(packet_exit);
66033  MODULE_LICENSE("GPL");
66034 +MODULE_ALIAS_NETPROTO(PF_PACKET);
66035 diff -Nru a/net/rose/af_rose.c b/net/rose/af_rose.c
66036 --- a/net/rose/af_rose.c        Tue Aug 19 20:57:58 2003
66037 +++ b/net/rose/af_rose.c        Tue Sep  2 04:38:10 2003
66038 @@ -518,6 +518,7 @@
66039         rose = rose_sk(sk);
66040  
66041         sock_init_data(sock, sk);
66042 +       sk_set_owner(sk, THIS_MODULE);
66043  
66044         skb_queue_head_init(&rose->ack_queue);
66045  #ifdef M_BIT
66046 @@ -556,6 +557,7 @@
66047         rose = rose_sk(sk);
66048  
66049         sock_init_data(NULL, sk);
66050 +       sk_set_owner(sk, THIS_MODULE);
66051  
66052         skb_queue_head_init(&rose->ack_queue);
66053  #ifdef M_BIT
66054 @@ -1549,6 +1551,7 @@
66055  MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>");
66056  MODULE_DESCRIPTION("The amateur radio ROSE network layer protocol");
66057  MODULE_LICENSE("GPL");
66058 +MODULE_ALIAS_NETPROTO(PF_ROSE);
66059  
66060  static void __exit rose_exit(void)
66061  {
66062 diff -Nru a/net/rxrpc/krxiod.c b/net/rxrpc/krxiod.c
66063 --- a/net/rxrpc/krxiod.c        Tue Feb 11 14:57:54 2003
66064 +++ b/net/rxrpc/krxiod.c        Sat Aug 30 20:36:03 2003
66065 @@ -9,7 +9,6 @@
66066   * 2 of the License, or (at your option) any later version.
66067   */
66068  
66069 -#include <linux/version.h>
66070  #include <linux/sched.h>
66071  #include <linux/completion.h>
66072  #include <linux/spinlock.h>
66073 diff -Nru a/net/rxrpc/krxsecd.c b/net/rxrpc/krxsecd.c
66074 --- a/net/rxrpc/krxsecd.c       Tue Feb 11 14:57:54 2003
66075 +++ b/net/rxrpc/krxsecd.c       Sat Aug 30 20:36:03 2003
66076 @@ -14,7 +14,6 @@
66077   * - responding to security challenges on outbound connections
66078   */
66079  
66080 -#include <linux/version.h>
66081  #include <linux/module.h>
66082  #include <linux/sched.h>
66083  #include <linux/completion.h>
66084 diff -Nru a/net/rxrpc/krxtimod.c b/net/rxrpc/krxtimod.c
66085 --- a/net/rxrpc/krxtimod.c      Sun Apr 20 07:45:44 2003
66086 +++ b/net/rxrpc/krxtimod.c      Sat Aug 30 20:36:03 2003
66087 @@ -9,7 +9,6 @@
66088   * 2 of the License, or (at your option) any later version.
66089   */
66090  
66091 -#include <linux/version.h>
66092  #include <linux/module.h>
66093  #include <linux/init.h>
66094  #include <linux/sched.h>
66095 diff -Nru a/net/sched/sch_generic.c b/net/sched/sch_generic.c
66096 --- a/net/sched/sch_generic.c   Sun Apr 20 00:57:16 2003
66097 +++ b/net/sched/sch_generic.c   Mon Sep  1 01:18:30 2003
66098 @@ -121,7 +121,7 @@
66099                                         printk(KERN_DEBUG "Dead loop on netdevice %s, fix it urgently!\n", dev->name);
66100                                 return -1;
66101                         }
66102 -                       netdev_rx_stat[smp_processor_id()].cpu_collision++;
66103 +                       __get_cpu_var(netdev_rx_stat).cpu_collision++;
66104                 }
66105  
66106                 /* Device kicked us out :(
66107 diff -Nru a/net/sctp/socket.c b/net/sctp/socket.c
66108 --- a/net/sctp/socket.c Mon Aug  4 10:35:40 2003
66109 +++ b/net/sctp/socket.c Thu Aug 28 01:21:04 2003
66110 @@ -852,7 +852,7 @@
66111                 associd = sinfo->sinfo_assoc_id;
66112         }
66113  
66114 -       SCTP_DEBUG_PRINTK("msg_len: %Zd, sinfo_flags: 0x%x\n",
66115 +       SCTP_DEBUG_PRINTK("msg_len: %d, sinfo_flags: 0x%x\n",
66116                           msg_len, sinfo_flags);
66117  
66118         /* MSG_EOF or MSG_ABORT cannot be set on a TCP-style socket. */
66119 diff -Nru a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
66120 --- a/net/sunrpc/rpc_pipe.c     Sat Jun 14 16:58:21 2003
66121 +++ b/net/sunrpc/rpc_pipe.c     Sat Aug 30 20:35:33 2003
66122 @@ -10,7 +10,6 @@
66123   */
66124  #include <linux/config.h>
66125  #include <linux/module.h>
66126 -#include <linux/version.h>
66127  #include <linux/slab.h>
66128  #include <linux/string.h>
66129  #include <linux/pagemap.h>
66130 diff -Nru a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
66131 --- a/net/sunrpc/svcsock.c      Mon Aug 18 15:49:47 2003
66132 +++ b/net/sunrpc/svcsock.c      Sat Aug 30 20:35:33 2003
66133 @@ -27,7 +27,6 @@
66134  #include <linux/inet.h>
66135  #include <linux/udp.h>
66136  #include <linux/tcp.h>
66137 -#include <linux/version.h>
66138  #include <linux/unistd.h>
66139  #include <linux/slab.h>
66140  #include <linux/netdevice.h>
66141 diff -Nru a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
66142 --- a/net/sunrpc/sysctl.c       Mon Aug 11 22:33:48 2003
66143 +++ b/net/sunrpc/sysctl.c       Sat Aug 30 20:35:33 2003
66144 @@ -8,7 +8,6 @@
66145   */
66146  
66147  #include <linux/config.h>
66148 -#include <linux/version.h>
66149  #include <linux/types.h>
66150  #include <linux/linkage.h>
66151  #include <linux/ctype.h>
66152 diff -Nru a/net/sunrpc/timer.c b/net/sunrpc/timer.c
66153 --- a/net/sunrpc/timer.c        Thu Aug 21 18:32:56 2003
66154 +++ b/net/sunrpc/timer.c        Sat Aug 30 20:35:33 2003
66155 @@ -15,7 +15,6 @@
66156  
66157  #include <asm/param.h>
66158  
66159 -#include <linux/version.h>
66160  #include <linux/types.h>
66161  #include <linux/unistd.h>
66162  
66163 diff -Nru a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
66164 --- a/net/sunrpc/xprt.c Thu Aug 21 18:41:58 2003
66165 +++ b/net/sunrpc/xprt.c Sat Aug 30 20:35:33 2003
66166 @@ -45,7 +45,6 @@
66167  
66168  #define __KERNEL_SYSCALLS__
66169  
66170 -#include <linux/version.h>
66171  #include <linux/types.h>
66172  #include <linux/slab.h>
66173  #include <linux/capability.h>
66174 diff -Nru a/net/unix/af_unix.c b/net/unix/af_unix.c
66175 --- a/net/unix/af_unix.c        Sun Jun 29 23:49:26 2003
66176 +++ b/net/unix/af_unix.c        Tue Sep  2 04:38:10 2003
66177 @@ -1965,3 +1965,4 @@
66178  module_exit(af_unix_exit);
66179  
66180  MODULE_LICENSE("GPL");
66181 +MODULE_ALIAS_NETPROTO(PF_UNIX);
66182 diff -Nru a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c
66183 --- a/net/wanrouter/af_wanpipe.c        Wed Jun 18 13:59:01 2003
66184 +++ b/net/wanrouter/af_wanpipe.c        Tue Sep  2 04:38:10 2003
66185 @@ -2600,3 +2600,4 @@
66186  }
66187  #endif
66188  MODULE_LICENSE("GPL");
66189 +MODULE_ALIAS_NETPROTO(PF_WANPIPE);
66190 diff -Nru a/net/x25/af_x25.c b/net/x25/af_x25.c
66191 --- a/net/x25/af_x25.c  Tue Aug  5 17:31:06 2003
66192 +++ b/net/x25/af_x25.c  Tue Sep  2 04:38:10 2003
66193 @@ -449,6 +449,7 @@
66194         x25->sk = sk;
66195  
66196         sock_init_data(NULL, sk);
66197 +       sk_set_owner(sk, THIS_MODULE);
66198  
66199         skb_queue_head_init(&x25->ack_queue);
66200         skb_queue_head_init(&x25->fragment_queue);
66201 @@ -478,6 +479,7 @@
66202         x25 = x25_sk(sk);
66203  
66204         sock_init_data(sock, sk);
66205 +       sk_set_owner(sk, THIS_MODULE);
66206  
66207         init_timer(&x25->timer);
66208  
66209 @@ -1421,3 +1423,4 @@
66210  MODULE_AUTHOR("Jonathan Naylor <g4klx@g4klx.demon.co.uk>");
66211  MODULE_DESCRIPTION("The X.25 Packet Layer network layer protocol");
66212  MODULE_LICENSE("GPL");
66213 +MODULE_ALIAS_NETPROTO(PF_X25);
66214 diff -Nru a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
66215 --- a/net/xfrm/xfrm_user.c      Thu Aug  7 21:04:46 2003
66216 +++ b/net/xfrm/xfrm_user.c      Mon Sep  1 01:12:32 2003
66217 @@ -1195,3 +1195,4 @@
66218  
66219  module_init(xfrm_user_init);
66220  module_exit(xfrm_user_exit);
66221 +MODULE_LICENSE("GPL");
66222 diff -Nru a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
66223 --- a/scripts/kconfig/Makefile  Tue Aug 19 09:27:03 2003
66224 +++ b/scripts/kconfig/Makefile  Sun Aug 31 16:13:49 2003
66225 @@ -2,40 +2,43 @@
66226  # Kernel configuration targets
66227  # These targets are used from top-level makefile
66228  
66229 -.PHONY: oldconfig xconfig gconfig menuconfig config
66230 +.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig
66231  
66232 -xconfig: scripts/kconfig/qconf
66233 -       ./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
66234 +xconfig: $(obj)/qconf
66235 +       $< arch/$(ARCH)/Kconfig
66236  
66237 -gconfig: scripts/kconfig/gconf
66238 -       ./scripts/kconfig/gconf arch/$(ARCH)/Kconfig
66239 +gconfig: $(obj)/gconf
66240 +       ./$<  arch/$(ARCH)/Kconfig
66241  
66242 -menuconfig: scripts/kconfig/mconf
66243 +menuconfig: $(obj)/mconf
66244         $(Q)$(MAKE) $(build)=scripts/lxdialog
66245 -       ./scripts/kconfig/mconf arch/$(ARCH)/Kconfig
66246 +       $< arch/$(ARCH)/Kconfig
66247  
66248 -config: scripts/kconfig/conf
66249 -       ./scripts/kconfig/conf arch/$(ARCH)/Kconfig
66250 +config: $(obj)/conf
66251 +       $< arch/$(ARCH)/Kconfig
66252  
66253 -oldconfig: scripts/kconfig/conf
66254 -       ./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
66255 +oldconfig: $(obj)/conf
66256 +       $< -o arch/$(ARCH)/Kconfig
66257 +
66258 +silentoldconfig: $(obj)/conf
66259 +       $< -s arch/$(ARCH)/Kconfig
66260  
66261  .PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
66262  
66263 -randconfig: scripts/kconfig/conf
66264 -       ./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
66265 +randconfig: $(obj)/conf
66266 +       $< -r arch/$(ARCH)/Kconfig
66267  
66268 -allyesconfig: scripts/kconfig/conf
66269 -       ./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
66270 +allyesconfig: $(obj)/conf
66271 +       $< -y arch/$(ARCH)/Kconfig
66272  
66273 -allnoconfig: scripts/kconfig/conf
66274 -       ./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
66275 +allnoconfig: $(obj)/conf
66276 +       $< -n arch/$(ARCH)/Kconfig
66277  
66278 -allmodconfig: scripts/kconfig/conf
66279 -       ./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
66280 +allmodconfig: $(obj)/conf
66281 +       $< -m arch/$(ARCH)/Kconfig
66282  
66283 -defconfig: scripts/kconfig/conf
66284 -       ./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
66285 +defconfig: $(obj)/conf
66286 +       $< -d arch/$(ARCH)/Kconfig
66287  
66288  # Help text used by make help
66289  help:
66290 diff -Nru a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
66291 --- a/scripts/kconfig/symbol.c  Fri Jun  6 01:28:22 2003
66292 +++ b/scripts/kconfig/symbol.c  Sun Aug 31 16:14:08 2003
66293 @@ -12,21 +12,21 @@
66294  #include "lkc.h"
66295  
66296  struct symbol symbol_yes = {
66297 -       name: "y",
66298 -       curr: { "y", yes },
66299 -       flags: SYMBOL_YES|SYMBOL_VALID,
66300 +       .name = "y",
66301 +       .curr = { "y", yes },
66302 +       .flags = SYMBOL_YES|SYMBOL_VALID,
66303  }, symbol_mod = {
66304 -       name: "m",
66305 -       curr: { "m", mod },
66306 -       flags: SYMBOL_MOD|SYMBOL_VALID,
66307 +       .name = "m",
66308 +       .curr = { "m", mod },
66309 +       .flags = SYMBOL_MOD|SYMBOL_VALID,
66310  }, symbol_no = {
66311 -       name: "n",
66312 -       curr: { "n", no },
66313 -       flags: SYMBOL_NO|SYMBOL_VALID,
66314 +       .name = "n",
66315 +       .curr = { "n", no },
66316 +       .flags = SYMBOL_NO|SYMBOL_VALID,
66317  }, symbol_empty = {
66318 -       name: "",
66319 -       curr: { "", no },
66320 -       flags: SYMBOL_VALID,
66321 +       .name = "",
66322 +       .curr = { "", no },
66323 +       .flags = SYMBOL_VALID,
66324  };
66325  
66326  int sym_change_count;
66327 diff -Nru a/security/capability.c b/security/capability.c
66328 --- a/security/capability.c     Wed Jul  2 21:22:38 2003
66329 +++ b/security/capability.c     Sun Aug 31 16:14:14 2003
66330 @@ -295,12 +295,7 @@
66331  
66332         vm_acct_memory(pages);
66333  
66334 -        /*
66335 -        * Sometimes we want to use more memory than we have
66336 -        */
66337 -       if (sysctl_overcommit_memory == 1)
66338 -               return 0;
66339 -
66340 +       /* We estimate memory ourselves (common case) */
66341         if (sysctl_overcommit_memory == 0) {
66342                 free = get_page_cache_size();
66343                 free += nr_free_pages();
66344 @@ -322,10 +317,16 @@
66345  
66346                 if (free > pages)
66347                         return 0;
66348 +
66349                 vm_unacct_memory(pages);
66350                 return -ENOMEM;
66351         }
66352  
66353 +       /* Kernel assumes allocation */
66354 +       if (sysctl_overcommit_memory == 1)
66355 +               return 0;
66356 +
66357 +       /* sysctl_overcommit_memory must be 2 which means strict_overcommit*/
66358         allowed = totalram_pages * sysctl_overcommit_ratio / 100;
66359         allowed += total_swap_pages;
66360  
66361 diff -Nru a/security/selinux/hooks.c b/security/selinux/hooks.c
66362 --- a/security/selinux/hooks.c  Mon Aug 18 22:27:19 2003
66363 +++ b/security/selinux/hooks.c  Sun Aug 31 16:14:20 2003
66364 @@ -1332,31 +1332,19 @@
66365  
66366  static int selinux_bprm_alloc_security(struct linux_binprm *bprm)
66367  {
66368 -       int rc;
66369 +       struct bprm_security_struct *bsec;
66370  
66371 -       /* Make sure that the secondary module doesn't use the
66372 -          bprm->security field, since we do not yet support chaining
66373 -          of multiple security structures on the field.  Neither
66374 -          the dummy nor the capability module use the field.  The owlsm
66375 -          module uses the field if CONFIG_OWLSM_FD is enabled. */
66376 -       rc = secondary_ops->bprm_alloc_security(bprm);
66377 -       if (rc)
66378 -               return rc;
66379 -       if (bprm->security) {
66380 -               printk(KERN_WARNING "%s: no support yet for chaining on the "
66381 -                      "security field by secondary modules.\n", __FUNCTION__);
66382 -               /* Release the secondary module's security object. */
66383 -               secondary_ops->bprm_free_security(bprm);
66384 -               /* Unregister the secondary module to prevent problems
66385 -                  with subsequent binprm hooks. This will revert to the
66386 -                  original (dummy) module for the secondary operations. */
66387 -               rc = security_ops->unregister_security("unknown", secondary_ops);
66388 -               if (rc)
66389 -                       return rc;
66390 -               printk(KERN_WARNING "%s: Unregistered the secondary security "
66391 -                      "module.\n", __FUNCTION__);
66392 -       }
66393 -       bprm->security = NULL;
66394 +       bsec = kmalloc(sizeof(struct bprm_security_struct), GFP_KERNEL);
66395 +       if (!bsec)
66396 +               return -ENOMEM;
66397 +
66398 +       memset(bsec, 0, sizeof *bsec);
66399 +       bsec->magic = SELINUX_MAGIC;
66400 +       bsec->bprm = bprm;
66401 +       bsec->sid = SECINITSID_UNLABELED;
66402 +       bsec->set = 0;
66403 +
66404 +       bprm->security = bsec;
66405         return 0;
66406  }
66407  
66408 @@ -1365,6 +1353,7 @@
66409         struct task_security_struct *tsec;
66410         struct inode *inode = bprm->file->f_dentry->d_inode;
66411         struct inode_security_struct *isec;
66412 +       struct bprm_security_struct *bsec;
66413         u32 newsid;
66414         struct avc_audit_data ad;
66415         int rc;
66416 @@ -1373,15 +1362,16 @@
66417         if (rc)
66418                 return rc;
66419  
66420 -       if (bprm->sh_bang || bprm->security)
66421 -               /* The security field should already be set properly. */
66422 +       bsec = bprm->security;
66423 +
66424 +       if (bsec->set)
66425                 return 0;
66426  
66427         tsec = current->security;
66428         isec = inode->i_security;
66429  
66430         /* Default to the current task SID. */
66431 -       bprm->security = (void *)tsec->sid;
66432 +       bsec->sid = tsec->sid;
66433  
66434         /* Reset create SID on execve. */
66435         tsec->create_sid = 0;
66436 @@ -1427,9 +1417,10 @@
66437                         return rc;
66438  
66439                 /* Set the security field to the new SID. */
66440 -               bprm->security = (void*) newsid;
66441 +               bsec->sid = newsid;
66442         }
66443  
66444 +       bsec->set = 1;
66445         return 0;
66446  }
66447  
66448 @@ -1463,8 +1454,9 @@
66449  
66450  static void selinux_bprm_free_security(struct linux_binprm *bprm)
66451  {
66452 -       /* Nothing to do - not dynamically allocated. */
66453 -       return;
66454 +       struct bprm_security_struct *bsec = bprm->security;
66455 +       bprm->security = NULL;
66456 +       kfree(bsec);
66457  }
66458  
66459  /* Derived from fs/exec.c:flush_old_files. */
66460 @@ -1509,6 +1501,7 @@
66461  static void selinux_bprm_compute_creds(struct linux_binprm *bprm)
66462  {
66463         struct task_security_struct *tsec, *psec;
66464 +       struct bprm_security_struct *bsec;
66465         u32 sid;
66466         struct av_decision avd;
66467         int rc;
66468 @@ -1517,9 +1510,8 @@
66469  
66470         tsec = current->security;
66471  
66472 -       sid = (u32)bprm->security;
66473 -       if (!sid)
66474 -               sid = tsec->sid;
66475 +       bsec = bprm->security;
66476 +       sid = bsec->sid;
66477  
66478         tsec->osid = tsec->sid;
66479         if (tsec->sid != sid) {
66480 @@ -2057,9 +2049,11 @@
66481                 case F_GETLK:
66482                 case F_SETLK:
66483                 case F_SETLKW:
66484 +#if BITS_PER_LONG == 32
66485                 case F_GETLK64:
66486                 case F_SETLK64:
66487                 case F_SETLKW64:
66488 +#endif
66489                         if (!file->f_dentry || !file->f_dentry->d_inode) {
66490                                 err = -EINVAL;
66491                                 break;
66492 @@ -3112,9 +3106,8 @@
66493                                char *name, void *value, size_t size)
66494  {
66495         struct task_security_struct *tsec;
66496 -       u32 sid;
66497 +       u32 sid, len;
66498         char *context;
66499 -       size_t len;
66500         int error;
66501  
66502         if (current != p) {
66503 diff -Nru a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
66504 --- a/security/selinux/include/objsec.h Thu Aug 14 18:17:44 2003
66505 +++ b/security/selinux/include/objsec.h Sun Aug 31 16:14:20 2003
66506 @@ -21,6 +21,7 @@
66507  #include <linux/list.h>
66508  #include <linux/sched.h>
66509  #include <linux/fs.h>
66510 +#include <linux/binfmts.h>
66511  #include <linux/in.h>
66512  #include "flask.h"
66513  #include "avc.h"
66514 @@ -83,6 +84,13 @@
66515         u16 sclass;     /* security class of this object */
66516         u32 sid;              /* SID of IPC resource */
66517          struct avc_entry_ref avcr;     /* reference to permissions */
66518 +};
66519 +
66520 +struct bprm_security_struct {
66521 +       unsigned long magic;           /* magic number for this module */
66522 +       struct linux_binprm *bprm;     /* back pointer to bprm object */
66523 +       u32 sid;                       /* SID for transformed process */
66524 +       unsigned char set;
66525  };
66526  
66527  extern int inode_security_set_sid(struct inode *inode, u32 sid);
66528 diff -Nru a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c
66529 --- a/security/selinux/ss/avtab.c       Thu Jul 17 02:38:01 2003
66530 +++ b/security/selinux/ss/avtab.c       Sun Aug 31 16:14:19 2003
66531 @@ -106,7 +106,7 @@
66532                 }
66533                 h->htable[i] = NULL;
66534         }
66535 -       kfree(h->htable);
66536 +       vfree(h->htable);
66537  }
66538  
66539  
66540 @@ -138,7 +138,7 @@
66541  {
66542         int i;
66543  
66544 -       h->htable = kmalloc(sizeof(*(h->htable)) * AVTAB_SIZE, GFP_KERNEL);
66545 +       h->htable = vmalloc(sizeof(*(h->htable)) * AVTAB_SIZE);
66546         if (!h->htable)
66547                 return -ENOMEM;
66548         for (i = 0; i < AVTAB_SIZE; i++)
66549 diff -Nru a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
66550 --- a/security/selinux/ss/ebitmap.c     Thu Jul 17 02:38:01 2003
66551 +++ b/security/selinux/ss/ebitmap.c     Sun Aug 31 16:14:19 2003
66552 @@ -250,8 +250,8 @@
66553         count = le32_to_cpu(buf[2]);
66554  
66555         if (mapsize != MAPSIZE) {
66556 -               printk(KERN_ERR "security: ebitmap: map size %d does not "
66557 -                      "match my size %d (high bit was %d)\n", mapsize,
66558 +               printk(KERN_ERR "security: ebitmap: map size %u does not "
66559 +                      "match my size %Zd (high bit was %d)\n", mapsize,
66560                        MAPSIZE, e->highbit);
66561                 goto out;
66562         }
66563 @@ -261,7 +261,7 @@
66564         }
66565         if (e->highbit & (MAPSIZE - 1)) {
66566                 printk(KERN_ERR "security: ebitmap: high bit (%d) is not a "
66567 -                      "multiple of the map size (%d)\n", e->highbit, MAPSIZE);
66568 +                      "multiple of the map size (%Zd)\n", e->highbit, MAPSIZE);
66569                 goto bad;
66570         }
66571         l = NULL;
66572 @@ -283,13 +283,13 @@
66573  
66574                 if (n->startbit & (MAPSIZE - 1)) {
66575                         printk(KERN_ERR "security: ebitmap start bit (%d) is "
66576 -                              "not a multiple of the map size (%d)\n",
66577 +                              "not a multiple of the map size (%Zd)\n",
66578                                n->startbit, MAPSIZE);
66579                         goto bad_free;
66580                 }
66581                 if (n->startbit > (e->highbit - MAPSIZE)) {
66582                         printk(KERN_ERR "security: ebitmap start bit (%d) is "
66583 -                              "beyond the end of the bitmap (%d)\n",
66584 +                              "beyond the end of the bitmap (%Zd)\n",
66585                                n->startbit, (e->highbit - MAPSIZE));
66586                         goto bad_free;
66587                 }
66588 diff -Nru a/security/selinux/ss/global.h b/security/selinux/ss/global.h
66589 --- a/security/selinux/ss/global.h      Sun Aug 10 04:22:59 2003
66590 +++ b/security/selinux/ss/global.h      Sun Aug 31 16:14:19 2003
66591 @@ -8,6 +8,7 @@
66592  #include <linux/in.h>
66593  #include <linux/spinlock.h>
66594  #include <linux/sched.h>
66595 +#include <linux/vmalloc.h>
66596  
66597  #include "flask.h"
66598  #include "avc.h"
66599 diff -Nru a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
66600 --- a/security/selinux/ss/policydb.c    Mon Aug 18 22:27:19 2003
66601 +++ b/security/selinux/ss/policydb.c    Sun Aug 31 16:14:19 2003
66602 @@ -1074,7 +1074,7 @@
66603         len = buf[1];
66604         if (len != strlen(POLICYDB_STRING)) {
66605                 printk(KERN_ERR "security:  policydb string length %d does not "
66606 -                      "match expected length %d\n",
66607 +                      "match expected length %Zd\n",
66608                        len, strlen(POLICYDB_STRING));
66609                 goto bad;
66610         }
66611 diff -Nru a/sound/core/control.c b/sound/core/control.c
66612 --- a/sound/core/control.c      Mon Jul 21 02:29:40 2003
66613 +++ b/sound/core/control.c      Tue Aug 26 09:25:41 2003
66614 @@ -42,7 +42,7 @@
66615  
66616  static int snd_ctl_open(struct inode *inode, struct file *file)
66617  {
66618 -       int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
66619 +       int cardnum = SNDRV_MINOR_CARD(iminor(inode));
66620         unsigned long flags;
66621         snd_card_t *card;
66622         snd_ctl_file_t *ctl;
66623 diff -Nru a/sound/core/hwdep.c b/sound/core/hwdep.c
66624 --- a/sound/core/hwdep.c        Sun Jun  1 11:47:53 2003
66625 +++ b/sound/core/hwdep.c        Tue Aug 26 09:25:41 2003
66626 @@ -73,7 +73,7 @@
66627  
66628  static int snd_hwdep_open(struct inode *inode, struct file * file)
66629  {
66630 -       int major = major(inode->i_rdev);
66631 +       int major = imajor(inode);
66632         int cardnum;
66633         int device;
66634         snd_hwdep_t *hw;
66635 @@ -82,12 +82,12 @@
66636  
66637         switch (major) {
66638         case CONFIG_SND_MAJOR:
66639 -               cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
66640 -               device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev)) - SNDRV_MINOR_HWDEP;
66641 +               cardnum = SNDRV_MINOR_CARD(iminor(inode));
66642 +               device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_HWDEP;
66643                 break;
66644  #ifdef CONFIG_SND_OSSEMUL
66645         case SOUND_MAJOR:
66646 -               cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
66647 +               cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
66648                 device = 0;
66649                 break;
66650  #endif
66651 diff -Nru a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
66652 --- a/sound/core/oss/mixer_oss.c        Sun Jun  1 11:47:53 2003
66653 +++ b/sound/core/oss/mixer_oss.c        Tue Aug 26 09:25:41 2003
66654 @@ -36,7 +36,7 @@
66655  
66656  static int snd_mixer_oss_open(struct inode *inode, struct file *file)
66657  {
66658 -       int cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
66659 +       int cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
66660         snd_card_t *card;
66661         snd_mixer_oss_file_t *fmixer;
66662         int err;
66663 diff -Nru a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
66664 --- a/sound/core/oss/pcm_oss.c  Fri Aug 15 19:54:09 2003
66665 +++ b/sound/core/oss/pcm_oss.c  Tue Aug 26 09:25:41 2003
66666 @@ -1681,7 +1681,7 @@
66667  
66668  static int snd_pcm_oss_open(struct inode *inode, struct file *file)
66669  {
66670 -       int minor = minor(inode->i_rdev);
66671 +       int minor = iminor(inode);
66672         int cardnum = SNDRV_MINOR_OSS_CARD(minor);
66673         int device;
66674         int err;
66675 diff -Nru a/sound/core/pcm_native.c b/sound/core/pcm_native.c
66676 --- a/sound/core/pcm_native.c   Mon Jul 28 04:35:00 2003
66677 +++ b/sound/core/pcm_native.c   Tue Aug 26 09:25:41 2003
66678 @@ -1431,11 +1431,11 @@
66679                 return 0;
66680         inode = file->f_dentry->d_inode;
66681         if (!S_ISCHR(inode->i_mode) ||
66682 -           major(inode->i_rdev) != snd_major) {
66683 +           imajor(inode) != snd_major) {
66684                 fput(file);
66685                 return 0;
66686         }
66687 -       minor = minor(inode->i_rdev);
66688 +       minor = iminor(inode);
66689         if (minor >= 256 || 
66690             minor % SNDRV_MINOR_DEVICES < SNDRV_MINOR_PCM_PLAYBACK) {
66691                 fput(file);
66692 @@ -1940,8 +1940,8 @@
66693  
66694  int snd_pcm_open(struct inode *inode, struct file *file)
66695  {
66696 -       int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
66697 -       int device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev));
66698 +       int cardnum = SNDRV_MINOR_CARD(iminor(inode));
66699 +       int device = SNDRV_MINOR_DEVICE(iminor(inode));
66700         int err;
66701         snd_pcm_t *pcm;
66702         snd_pcm_file_t *pcm_file;
66703 diff -Nru a/sound/core/rawmidi.c b/sound/core/rawmidi.c
66704 --- a/sound/core/rawmidi.c      Mon Jul 28 04:35:00 2003
66705 +++ b/sound/core/rawmidi.c      Tue Aug 26 09:25:41 2003
66706 @@ -345,7 +345,7 @@
66707  
66708  static int snd_rawmidi_open(struct inode *inode, struct file *file)
66709  {
66710 -       int maj = major(inode->i_rdev);
66711 +       int maj = imajor(inode);
66712         int cardnum;
66713         snd_card_t *card;
66714         int device, subdevice;
66715 @@ -359,16 +359,16 @@
66716  
66717         switch (maj) {
66718         case CONFIG_SND_MAJOR:
66719 -               cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
66720 +               cardnum = SNDRV_MINOR_CARD(iminor(inode));
66721                 cardnum %= SNDRV_CARDS;
66722 -               device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev)) - SNDRV_MINOR_RAWMIDI;
66723 +               device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_RAWMIDI;
66724                 device %= SNDRV_MINOR_RAWMIDIS;
66725                 break;
66726  #ifdef CONFIG_SND_OSSEMUL
66727         case SOUND_MAJOR:
66728 -               cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
66729 +               cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
66730                 cardnum %= SNDRV_CARDS;
66731 -               device = SNDRV_MINOR_OSS_DEVICE(minor(inode->i_rdev)) == SNDRV_MINOR_OSS_MIDI ?
66732 +               device = SNDRV_MINOR_OSS_DEVICE(iminor(inode)) == SNDRV_MINOR_OSS_MIDI ?
66733                         midi_map[cardnum] : amidi_map[cardnum];
66734                 break;
66735  #endif
66736 diff -Nru a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
66737 --- a/sound/core/seq/oss/seq_oss.c      Sun Jun  1 11:47:54 2003
66738 +++ b/sound/core/seq/oss/seq_oss.c      Tue Aug 26 09:25:41 2003
66739 @@ -121,7 +121,7 @@
66740  {
66741         int level, rc;
66742  
66743 -       if (minor(inode->i_rdev) == SNDRV_MINOR_OSS_MUSIC)
66744 +       if (iminor(inode) == SNDRV_MINOR_OSS_MUSIC)
66745                 level = SNDRV_SEQ_OSS_MODE_MUSIC;
66746         else
66747                 level = SNDRV_SEQ_OSS_MODE_SYNTH;
66748 diff -Nru a/sound/core/sound.c b/sound/core/sound.c
66749 --- a/sound/core/sound.c        Mon Jul 28 04:35:00 2003
66750 +++ b/sound/core/sound.c        Tue Aug 26 09:25:41 2003
66751 @@ -117,7 +117,7 @@
66752  
66753  static int snd_open(struct inode *inode, struct file *file)
66754  {
66755 -       int minor = minor(inode->i_rdev);
66756 +       int minor = iminor(inode);
66757         int card = SNDRV_MINOR_CARD(minor);
66758         int dev = SNDRV_MINOR_DEVICE(minor);
66759         snd_minor_t *mptr = NULL;
66760 diff -Nru a/sound/oss/ad1889.c b/sound/oss/ad1889.c
66761 --- a/sound/oss/ad1889.c        Sat Aug  2 23:59:09 2003
66762 +++ b/sound/oss/ad1889.c        Tue Aug 26 09:25:41 2003
66763 @@ -755,7 +755,7 @@
66764  static int ad1889_open(struct inode *inode, struct file *file)
66765  {
66766         /* check minor; only support /dev/dsp atm */
66767 -       if (minor(inode->i_rdev) != 3)
66768 +       if (iminor(inode) != 3)
66769                 return -ENXIO;
66770         
66771         file->private_data = ad1889_dev;
66772 @@ -788,7 +788,7 @@
66773  /************************* /dev/mixer interfaces ************************ */
66774  static int ad1889_mixer_open(struct inode *inode, struct file *file)
66775  {
66776 -       if (ad1889_dev->ac97_codec->dev_mixer != minor(inode->i_rdev))
66777 +       if (ad1889_dev->ac97_codec->dev_mixer != iminor(inode))
66778                 return -ENODEV;
66779  
66780         file->private_data = ad1889_dev->ac97_codec;
66781 diff -Nru a/sound/oss/ali5455.c b/sound/oss/ali5455.c
66782 --- a/sound/oss/ali5455.c       Sat Aug  2 23:59:09 2003
66783 +++ b/sound/oss/ali5455.c       Tue Aug 26 09:25:41 2003
66784 @@ -3026,7 +3026,7 @@
66785  static int ali_open_mixdev(struct inode *inode, struct file *file)
66786  {
66787         int i;
66788 -       int minor = minor(inode->i_rdev);
66789 +       int minor = iminor(inode);
66790         struct ali_card *card = devs;
66791         for (card = devs; card != NULL; card = card->next) {
66792                 /*
66793 diff -Nru a/sound/oss/au1000.c b/sound/oss/au1000.c
66794 --- a/sound/oss/au1000.c        Sat Aug  2 23:59:09 2003
66795 +++ b/sound/oss/au1000.c        Tue Aug 26 09:25:41 2003
66796 @@ -1842,7 +1842,7 @@
66797  
66798  static int  au1000_open(struct inode *inode, struct file *file)
66799  {
66800 -       int             minor = MINOR(inode->i_rdev);
66801 +       int             minor = iminor(inode);
66802         DECLARE_WAITQUEUE(wait, current);
66803         struct au1000_state *s = &au1000_state;
66804         int             ret;
66805 diff -Nru a/sound/oss/btaudio.c b/sound/oss/btaudio.c
66806 --- a/sound/oss/btaudio.c       Tue Aug 12 13:28:49 2003
66807 +++ b/sound/oss/btaudio.c       Tue Aug 26 09:25:41 2003
66808 @@ -299,7 +299,7 @@
66809  
66810  static int btaudio_mixer_open(struct inode *inode, struct file *file)
66811  {
66812 -       int minor = minor(inode->i_rdev);
66813 +       int minor = iminor(inode);
66814         struct btaudio *bta;
66815  
66816         for (bta = btaudios; bta != NULL; bta = bta->next)
66817 @@ -458,7 +458,7 @@
66818  
66819  static int btaudio_dsp_open_digital(struct inode *inode, struct file *file)
66820  {
66821 -       int minor = minor(inode->i_rdev);
66822 +       int minor = iminor(inode);
66823         struct btaudio *bta;
66824  
66825         for (bta = btaudios; bta != NULL; bta = bta->next)
66826 @@ -474,7 +474,7 @@
66827  
66828  static int btaudio_dsp_open_analog(struct inode *inode, struct file *file)
66829  {
66830 -       int minor = minor(inode->i_rdev);
66831 +       int minor = iminor(inode);
66832         struct btaudio *bta;
66833  
66834         for (bta = btaudios; bta != NULL; bta = bta->next)
66835 diff -Nru a/sound/oss/cmpci.c b/sound/oss/cmpci.c
66836 --- a/sound/oss/cmpci.c Wed Jul 23 08:32:08 2003
66837 +++ b/sound/oss/cmpci.c Tue Aug 26 09:25:41 2003
66838 @@ -1448,7 +1448,7 @@
66839  
66840  static int cm_open_mixdev(struct inode *inode, struct file *file)
66841  {
66842 -       int minor = minor(inode->i_rdev);
66843 +       int minor = iminor(inode);
66844         struct cm_state *s = devs;
66845  
66846         while (s && s->dev_mixer != minor)
66847 @@ -2207,7 +2207,7 @@
66848  
66849  static int cm_open(struct inode *inode, struct file *file)
66850  {
66851 -       int minor = minor(inode->i_rdev);
66852 +       int minor = iminor(inode);
66853         struct cm_state *s = devs;
66854         unsigned char fmtm = ~0, fmts = 0;
66855  
66856 @@ -2462,7 +2462,7 @@
66857  
66858  static int cm_midi_open(struct inode *inode, struct file *file)
66859  {
66860 -       int minor = minor(inode->i_rdev);
66861 +       int minor = iminor(inode);
66862         struct cm_state *s = devs;
66863         unsigned long flags;
66864  
66865 @@ -2679,7 +2679,7 @@
66866  
66867  static int cm_dmfm_open(struct inode *inode, struct file *file)
66868  {
66869 -       int minor = minor(inode->i_rdev);
66870 +       int minor = iminor(inode);
66871         struct cm_state *s = devs;
66872  
66873         while (s && s->dev_dmfm != minor)
66874 diff -Nru a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
66875 --- a/sound/oss/cs4281/cs4281m.c        Thu Jul 31 08:58:39 2003
66876 +++ b/sound/oss/cs4281/cs4281m.c        Tue Aug 26 09:25:41 2003
66877 @@ -2567,7 +2567,7 @@
66878  
66879  static int cs4281_open_mixdev(struct inode *inode, struct file *file)
66880  {
66881 -       unsigned int minor = minor(inode->i_rdev);
66882 +       unsigned int minor = iminor(inode);
66883         struct cs4281_state *s=NULL;
66884         struct list_head *entry;
66885  
66886 @@ -3624,7 +3624,7 @@
66887  
66888  static int cs4281_open(struct inode *inode, struct file *file)
66889  {
66890 -       unsigned int minor = minor(inode->i_rdev);
66891 +       unsigned int minor = iminor(inode);
66892         struct cs4281_state *s=NULL;
66893         struct list_head *entry;
66894  
66895 @@ -3966,7 +3966,7 @@
66896  static int cs4281_midi_open(struct inode *inode, struct file *file)
66897  {
66898         unsigned long flags, temp1;
66899 -       unsigned int minor = minor(inode->i_rdev);
66900 +       unsigned int minor = iminor(inode);
66901         struct cs4281_state *s=NULL;
66902         struct list_head *entry;
66903         list_for_each(entry, &cs4281_devs)
66904 diff -Nru a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
66905 --- a/sound/oss/cs46xx.c        Tue Aug 12 13:28:49 2003
66906 +++ b/sound/oss/cs46xx.c        Tue Aug 26 09:25:41 2003
66907 @@ -1838,7 +1838,7 @@
66908  
66909  static int cs_midi_open(struct inode *inode, struct file *file)
66910  {
66911 -        unsigned int minor = minor(inode->i_rdev);
66912 +        unsigned int minor = iminor(inode);
66913          struct cs_card *card=NULL;
66914          unsigned long flags;
66915         struct list_head *entry;
66916 @@ -3200,7 +3200,7 @@
66917         struct cs_state *state = NULL;
66918         struct dmabuf *dmabuf = NULL;
66919         struct list_head *entry;
66920 -        unsigned int minor = minor(inode->i_rdev);
66921 +        unsigned int minor = iminor(inode);
66922         int ret=0;
66923         unsigned int tmp;
66924  
66925 @@ -4066,7 +4066,7 @@
66926  static int cs_open_mixdev(struct inode *inode, struct file *file)
66927  {
66928         int i=0;
66929 -       unsigned int minor = minor(inode->i_rdev);
66930 +       unsigned int minor = iminor(inode);
66931         struct cs_card *card=NULL;
66932         struct list_head *entry;
66933         unsigned int tmp;
66934 @@ -4113,7 +4113,7 @@
66935  
66936  static int cs_release_mixdev(struct inode *inode, struct file *file)
66937  {
66938 -       unsigned int minor = minor(inode->i_rdev);
66939 +       unsigned int minor = iminor(inode);
66940         struct cs_card *card=NULL;
66941         struct list_head *entry;
66942         int i;
66943 diff -Nru a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
66944 --- a/sound/oss/dmasound/dmasound_core.c        Tue Aug 12 13:28:49 2003
66945 +++ b/sound/oss/dmasound/dmasound_core.c        Tue Aug 26 09:25:41 2003
66946 @@ -904,7 +904,7 @@
66947           O_RDONLY and dsp1 could be opened O_WRONLY
66948         */
66949  
66950 -       dmasound.minDev = minor(inode->i_rdev) & 0x0f;
66951 +       dmasound.minDev = iminor(inode) & 0x0f;
66952  
66953         /* OK. - we should make some attempt at consistency. At least the H'ware
66954            options should be set with a valid mode.  We will make it that the LL
66955 diff -Nru a/sound/oss/emu10k1/audio.c b/sound/oss/emu10k1/audio.c
66956 --- a/sound/oss/emu10k1/audio.c Tue Jul 15 10:35:45 2003
66957 +++ b/sound/oss/emu10k1/audio.c Tue Aug 26 09:25:41 2003
66958 @@ -1112,7 +1112,7 @@
66959  
66960  static int emu10k1_audio_open(struct inode *inode, struct file *file)
66961  {
66962 -       int minor = minor(inode->i_rdev);
66963 +       int minor = iminor(inode);
66964         struct emu10k1_card *card = NULL;
66965         struct list_head *entry;
66966         struct emu10k1_wavedevice *wave_dev;
66967 diff -Nru a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
66968 --- a/sound/oss/emu10k1/midi.c  Thu Apr  3 14:52:57 2003
66969 +++ b/sound/oss/emu10k1/midi.c  Tue Aug 26 09:25:41 2003
66970 @@ -86,7 +86,7 @@
66971  
66972  static int emu10k1_midi_open(struct inode *inode, struct file *file)
66973  {
66974 -       int minor = minor(inode->i_rdev);
66975 +       int minor = iminor(inode);
66976         struct emu10k1_card *card = NULL;
66977         struct emu10k1_mididevice *midi_dev;
66978         struct list_head *entry;
66979 diff -Nru a/sound/oss/emu10k1/mixer.c b/sound/oss/emu10k1/mixer.c
66980 --- a/sound/oss/emu10k1/mixer.c Tue Jul 15 10:35:45 2003
66981 +++ b/sound/oss/emu10k1/mixer.c Tue Aug 26 09:25:41 2003
66982 @@ -654,7 +654,7 @@
66983  
66984  static int emu10k1_mixer_open(struct inode *inode, struct file *file)
66985  {
66986 -       int minor = minor(inode->i_rdev);
66987 +       int minor = iminor(inode);
66988         struct emu10k1_card *card = NULL;
66989         struct list_head *entry;
66990  
66991 diff -Nru a/sound/oss/es1370.c b/sound/oss/es1370.c
66992 --- a/sound/oss/es1370.c        Tue Aug 12 16:21:59 2003
66993 +++ b/sound/oss/es1370.c        Tue Aug 26 09:25:41 2003
66994 @@ -1023,7 +1023,7 @@
66995  
66996  static int es1370_open_mixdev(struct inode *inode, struct file *file)
66997  {
66998 -       unsigned int minor = minor(inode->i_rdev);
66999 +       unsigned int minor = iminor(inode);
67000         struct list_head *list;
67001         struct es1370_state *s;
67002  
67003 @@ -1727,7 +1727,7 @@
67004  
67005  static int es1370_open(struct inode *inode, struct file *file)
67006  {
67007 -       unsigned int minor = minor(inode->i_rdev);
67008 +       unsigned int minor = iminor(inode);
67009         DECLARE_WAITQUEUE(wait, current);
67010         unsigned long flags;
67011         struct list_head *list;
67012 @@ -2165,7 +2165,7 @@
67013  
67014  static int es1370_open_dac(struct inode *inode, struct file *file)
67015  {
67016 -       unsigned int minor = minor(inode->i_rdev);
67017 +       unsigned int minor = iminor(inode);
67018         DECLARE_WAITQUEUE(wait, current);
67019         unsigned long flags;
67020         struct list_head *list;
67021 @@ -2408,7 +2408,7 @@
67022  
67023  static int es1370_midi_open(struct inode *inode, struct file *file)
67024  {
67025 -       unsigned int minor = minor(inode->i_rdev);
67026 +       unsigned int minor = iminor(inode);
67027         DECLARE_WAITQUEUE(wait, current);
67028         unsigned long flags;
67029         struct list_head *list;
67030 diff -Nru a/sound/oss/es1371.c b/sound/oss/es1371.c
67031 --- a/sound/oss/es1371.c        Tue Aug 12 13:28:49 2003
67032 +++ b/sound/oss/es1371.c        Tue Aug 26 09:25:41 2003
67033 @@ -1210,7 +1210,7 @@
67034  
67035  static int es1371_open_mixdev(struct inode *inode, struct file *file)
67036  {
67037 -       int minor = minor(inode->i_rdev);
67038 +       int minor = iminor(inode);
67039         struct list_head *list;
67040         struct es1371_state *s;
67041  
67042 @@ -1914,7 +1914,7 @@
67043  
67044  static int es1371_open(struct inode *inode, struct file *file)
67045  {
67046 -       int minor = minor(inode->i_rdev);
67047 +       int minor = iminor(inode);
67048         DECLARE_WAITQUEUE(wait, current);
67049         unsigned long flags;
67050         struct list_head *list;
67051 @@ -2345,7 +2345,7 @@
67052  
67053  static int es1371_open_dac(struct inode *inode, struct file *file)
67054  {
67055 -       int minor = minor(inode->i_rdev);
67056 +       int minor = iminor(inode);
67057         DECLARE_WAITQUEUE(wait, current);
67058         unsigned long flags;
67059         struct list_head *list;
67060 @@ -2587,7 +2587,7 @@
67061  
67062  static int es1371_midi_open(struct inode *inode, struct file *file)
67063  {
67064 -       int minor = minor(inode->i_rdev);
67065 +       int minor = iminor(inode);
67066         DECLARE_WAITQUEUE(wait, current);
67067         unsigned long flags;
67068         struct list_head *list;
67069 diff -Nru a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
67070 --- a/sound/oss/esssolo1.c      Thu Jul 31 08:58:39 2003
67071 +++ b/sound/oss/esssolo1.c      Tue Aug 26 09:25:41 2003
67072 @@ -913,7 +913,7 @@
67073  
67074  static int solo1_open_mixdev(struct inode *inode, struct file *file)
67075  {
67076 -       unsigned int minor = minor(inode->i_rdev);
67077 +       unsigned int minor = iminor(inode);
67078         struct solo1_state *s = NULL;
67079         struct pci_dev *pci_dev = NULL;
67080  
67081 @@ -1594,7 +1594,7 @@
67082  
67083  static int solo1_open(struct inode *inode, struct file *file)
67084  {
67085 -       unsigned int minor = minor(inode->i_rdev);
67086 +       unsigned int minor = iminor(inode);
67087         DECLARE_WAITQUEUE(wait, current);
67088         struct solo1_state *s = NULL;
67089         struct pci_dev *pci_dev = NULL;
67090 @@ -1884,7 +1884,7 @@
67091  
67092  static int solo1_midi_open(struct inode *inode, struct file *file)
67093  {
67094 -       unsigned int minor = minor(inode->i_rdev);
67095 +       unsigned int minor = iminor(inode);
67096         DECLARE_WAITQUEUE(wait, current);
67097         unsigned long flags;
67098         struct solo1_state *s = NULL;
67099 @@ -2106,7 +2106,7 @@
67100  
67101  static int solo1_dmfm_open(struct inode *inode, struct file *file)
67102  {
67103 -       unsigned int minor = minor(inode->i_rdev);
67104 +       unsigned int minor = iminor(inode);
67105         DECLARE_WAITQUEUE(wait, current);
67106         struct solo1_state *s = NULL;
67107         struct pci_dev *pci_dev = NULL;
67108 diff -Nru a/sound/oss/hal2.c b/sound/oss/hal2.c
67109 --- a/sound/oss/hal2.c  Sat Aug  2 23:59:09 2003
67110 +++ b/sound/oss/hal2.c  Tue Aug 26 09:25:41 2003
67111 @@ -867,7 +867,7 @@
67112  
67113  static int hal2_open_mixdev(struct inode *inode, struct file *file)
67114  {
67115 -       hal2_card_t *hal2 = hal2_mixer_find_card(MINOR(inode->i_rdev));
67116 +       hal2_card_t *hal2 = hal2_mixer_find_card(iminor(inode));
67117  
67118         if (hal2) {
67119                 file->private_data = hal2;
67120 @@ -1242,7 +1242,7 @@
67121  static int hal2_open(struct inode *inode, struct file *file)
67122  {
67123         int err;
67124 -       hal2_card_t *hal2 = hal2_dsp_find_card(MINOR(inode->i_rdev));
67125 +       hal2_card_t *hal2 = hal2_dsp_find_card(iminor(inode));
67126  
67127         DEBUG("opening audio device.\n");
67128  
67129 diff -Nru a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
67130 --- a/sound/oss/i810_audio.c    Tue Aug 12 16:21:48 2003
67131 +++ b/sound/oss/i810_audio.c    Tue Aug 26 09:25:41 2003
67132 @@ -2648,7 +2648,7 @@
67133  static int i810_open_mixdev(struct inode *inode, struct file *file)
67134  {
67135         int i;
67136 -       int minor = minor(inode->i_rdev);
67137 +       int minor = iminor(inode);
67138         struct i810_card *card = devs;
67139  
67140         for (card = devs; card != NULL; card = card->next) {
67141 diff -Nru a/sound/oss/ite8172.c b/sound/oss/ite8172.c
67142 --- a/sound/oss/ite8172.c       Sun Aug  3 00:02:01 2003
67143 +++ b/sound/oss/ite8172.c       Sun Aug 31 16:14:08 2003
67144 @@ -867,7 +867,7 @@
67145  
67146  static int it8172_open_mixdev(struct inode *inode, struct file *file)
67147  {
67148 -       int minor = MINOR(inode->i_rdev);
67149 +       int minor = iminor(inode);
67150         struct list_head *list;
67151         struct it8172_state *s;
67152  
67153 @@ -1771,7 +1771,7 @@
67154  
67155  static int it8172_open(struct inode *inode, struct file *file)
67156  {
67157 -       int minor = MINOR(inode->i_rdev);
67158 +       int minor = iminor(inode);
67159         DECLARE_WAITQUEUE(wait, current);
67160         unsigned long flags;
67161         struct list_head *list;
67162 @@ -2198,10 +2198,10 @@
67163  MODULE_DEVICE_TABLE(pci, id_table);
67164  
67165  static struct pci_driver it8172_driver = {
67166 -       name: IT8172_MODULE_NAME,
67167 -       id_table: id_table,
67168 -       probe: it8172_probe,
67169 -       remove: it8172_remove
67170 +       .name = IT8172_MODULE_NAME,
67171 +       .id_table = id_table,
67172 +       .probe = it8172_probe,
67173 +       .remove = it8172_remove
67174  };
67175  
67176  static int __init init_it8172(void)
67177 diff -Nru a/sound/oss/maestro.c b/sound/oss/maestro.c
67178 --- a/sound/oss/maestro.c       Tue Aug 12 13:28:49 2003
67179 +++ b/sound/oss/maestro.c       Tue Aug 26 09:25:41 2003
67180 @@ -2138,7 +2138,7 @@
67181  /* --------------------------------------------------------------------- */
67182  static int ess_open_mixdev(struct inode *inode, struct file *file)
67183  {
67184 -       unsigned int minor = minor(inode->i_rdev);
67185 +       unsigned int minor = iminor(inode);
67186         struct ess_card *card = NULL;
67187         struct pci_dev *pdev = NULL;
67188         struct pci_driver *drvr;
67189 @@ -2983,7 +2983,7 @@
67190  static int 
67191  ess_open(struct inode *inode, struct file *file)
67192  {
67193 -       unsigned int minor = minor(inode->i_rdev);
67194 +       unsigned int minor = iminor(inode);
67195         struct ess_state *s = NULL;
67196         unsigned char fmtm = ~0, fmts = 0;
67197         struct pci_dev *pdev = NULL;
67198 diff -Nru a/sound/oss/maestro3.c b/sound/oss/maestro3.c
67199 --- a/sound/oss/maestro3.c      Thu Jul 31 08:58:39 2003
67200 +++ b/sound/oss/maestro3.c      Tue Aug 26 09:25:41 2003
67201 @@ -1980,7 +1980,7 @@
67202  
67203  static int m3_open(struct inode *inode, struct file *file)
67204  {
67205 -    unsigned int minor = minor(inode->i_rdev);
67206 +    unsigned int minor = iminor(inode);
67207      struct m3_card *c;
67208      struct m3_state *s = NULL;
67209      int i;
67210 @@ -2149,7 +2149,7 @@
67211  /* OSS /dev/mixer file operation methods */
67212  static int m3_open_mixdev(struct inode *inode, struct file *file)
67213  {
67214 -    unsigned int minor = minor(inode->i_rdev);
67215 +    unsigned int minor = iminor(inode);
67216      struct m3_card *card = devs;
67217  
67218      for (card = devs; card != NULL; card = card->next) {
67219 diff -Nru a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
67220 --- a/sound/oss/msnd_pinnacle.c Wed Jul 23 08:32:08 2003
67221 +++ b/sound/oss/msnd_pinnacle.c Tue Aug 26 09:25:41 2003
67222 @@ -646,7 +646,7 @@
67223  
67224  static int dev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
67225  {
67226 -       int minor = minor(inode->i_rdev);
67227 +       int minor = iminor(inode);
67228  
67229         if (cmd == OSS_GETVERSION) {
67230                 int sound_version = SOUND_VERSION;
67231 @@ -758,7 +758,7 @@
67232  
67233  static int dev_open(struct inode *inode, struct file *file)
67234  {
67235 -       int minor = minor(inode->i_rdev);
67236 +       int minor = iminor(inode);
67237         int err = 0;
67238  
67239         if (minor == dev.dsp_minor) {
67240 @@ -793,7 +793,7 @@
67241  
67242  static int dev_release(struct inode *inode, struct file *file)
67243  {
67244 -       int minor = minor(inode->i_rdev);
67245 +       int minor = iminor(inode);
67246         int err = 0;
67247  
67248         lock_kernel();
67249 @@ -983,7 +983,7 @@
67250  
67251  static ssize_t dev_read(struct file *file, char *buf, size_t count, loff_t *off)
67252  {
67253 -       int minor = minor(file->f_dentry->d_inode->i_rdev);
67254 +       int minor = iminor(file->f_dentry->d_inode);
67255         if (minor == dev.dsp_minor)
67256                 return dsp_read(buf, count);
67257         else
67258 @@ -992,7 +992,7 @@
67259  
67260  static ssize_t dev_write(struct file *file, const char *buf, size_t count, loff_t *off)
67261  {
67262 -       int minor = minor(file->f_dentry->d_inode->i_rdev);
67263 +       int minor = iminor(file->f_dentry->d_inode);
67264         if (minor == dev.dsp_minor)
67265                 return dsp_write(buf, count);
67266         else
67267 diff -Nru a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
67268 --- a/sound/oss/nec_vrc5477.c   Tue Aug 12 13:28:49 2003
67269 +++ b/sound/oss/nec_vrc5477.c   Tue Aug 26 09:25:41 2003
67270 @@ -857,7 +857,7 @@
67271  
67272  static int vrc5477_ac97_open_mixdev(struct inode *inode, struct file *file)
67273  {
67274 -       int minor = minor(inode->i_rdev);
67275 +       int minor = iminor(inode);
67276         struct list_head *list;
67277         struct vrc5477_ac97_state *s;
67278  
67279 @@ -1569,7 +1569,7 @@
67280  
67281  static int vrc5477_ac97_open(struct inode *inode, struct file *file)
67282  {
67283 -       int minor = minor(inode->i_rdev);
67284 +       int minor = iminor(inode);
67285         DECLARE_WAITQUEUE(wait, current);
67286         unsigned long flags;
67287         struct list_head *list;
67288 diff -Nru a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
67289 --- a/sound/oss/rme96xx.c       Thu Jul 31 08:58:39 2003
67290 +++ b/sound/oss/rme96xx.c       Tue Aug 26 09:25:41 2003
67291 @@ -1445,7 +1445,7 @@
67292  
67293  static int rme96xx_open(struct inode *in, struct file *f)
67294  {
67295 -       int minor = minor(in->i_rdev);
67296 +       int minor = iminor(in);
67297         struct list_head *list;
67298         int devnum;
67299         rme96xx_info *s;
67300 @@ -1769,7 +1769,7 @@
67301  
67302  static int rme96xx_mixer_open(struct inode *inode, struct file *file)
67303  {
67304 -       int minor = minor(inode->i_rdev);
67305 +       int minor = iminor(inode);
67306         struct list_head *list;
67307         rme96xx_info *s;
67308  
67309 diff -Nru a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
67310 --- a/sound/oss/sonicvibes.c    Tue Aug 12 13:28:49 2003
67311 +++ b/sound/oss/sonicvibes.c    Tue Aug 26 09:25:41 2003
67312 @@ -1238,7 +1238,7 @@
67313  
67314  static int sv_open_mixdev(struct inode *inode, struct file *file)
67315  {
67316 -       int minor = minor(inode->i_rdev);
67317 +       int minor = iminor(inode);
67318         struct list_head *list;
67319         struct sv_state *s;
67320  
67321 @@ -1900,7 +1900,7 @@
67322  
67323  static int sv_open(struct inode *inode, struct file *file)
67324  {
67325 -       int minor = minor(inode->i_rdev);
67326 +       int minor = iminor(inode);
67327         DECLARE_WAITQUEUE(wait, current);
67328         unsigned char fmtm = ~0, fmts = 0;
67329         struct list_head *list;
67330 @@ -2149,7 +2149,7 @@
67331  
67332  static int sv_midi_open(struct inode *inode, struct file *file)
67333  {
67334 -       int minor = minor(inode->i_rdev);
67335 +       int minor = iminor(inode);
67336         DECLARE_WAITQUEUE(wait, current);
67337         unsigned long flags;
67338         struct list_head *list;
67339 @@ -2371,7 +2371,7 @@
67340  
67341  static int sv_dmfm_open(struct inode *inode, struct file *file)
67342  {
67343 -       int minor = minor(inode->i_rdev);
67344 +       int minor = iminor(inode);
67345         DECLARE_WAITQUEUE(wait, current);
67346         struct list_head *list;
67347         struct sv_state *s;
67348 diff -Nru a/sound/oss/soundcard.c b/sound/oss/soundcard.c
67349 --- a/sound/oss/soundcard.c     Tue Aug 12 13:28:49 2003
67350 +++ b/sound/oss/soundcard.c     Tue Aug 26 09:25:41 2003
67351 @@ -144,7 +144,7 @@
67352  
67353  static ssize_t sound_read(struct file *file, char *buf, size_t count, loff_t *ppos)
67354  {
67355 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
67356 +       int dev = iminor(file->f_dentry->d_inode);
67357         int ret = -EINVAL;
67358  
67359         /*
67360 @@ -177,7 +177,7 @@
67361  
67362  static ssize_t sound_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
67363  {
67364 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
67365 +       int dev = iminor(file->f_dentry->d_inode);
67366         int ret = -EINVAL;
67367         
67368         lock_kernel();
67369 @@ -204,7 +204,7 @@
67370  
67371  static int sound_open(struct inode *inode, struct file *file)
67372  {
67373 -       int dev = minor(inode->i_rdev);
67374 +       int dev = iminor(inode);
67375         int retval;
67376  
67377         DEB(printk("sound_open(dev=%d)\n", dev));
67378 @@ -253,7 +253,7 @@
67379  
67380  static int sound_release(struct inode *inode, struct file *file)
67381  {
67382 -       int dev = minor(inode->i_rdev);
67383 +       int dev = iminor(inode);
67384  
67385         lock_kernel();
67386         DEB(printk("sound_release(dev=%d)\n", dev));
67387 @@ -333,7 +333,7 @@
67388                        unsigned int cmd, unsigned long arg)
67389  {
67390         int err, len = 0, dtype;
67391 -       int dev = minor(inode->i_rdev);
67392 +       int dev = iminor(inode);
67393  
67394         if (_SIOC_DIR(cmd) != _SIOC_NONE && _SIOC_DIR(cmd) != 0) {
67395                 /*
67396 @@ -396,7 +396,7 @@
67397  static unsigned int sound_poll(struct file *file, poll_table * wait)
67398  {
67399         struct inode *inode = file->f_dentry->d_inode;
67400 -       int dev = minor(inode->i_rdev);
67401 +       int dev = iminor(inode);
67402  
67403         DEB(printk("sound_poll(dev=%d)\n", dev));
67404         switch (dev & 0x0f) {
67405 @@ -420,7 +420,7 @@
67406         int dev_class;
67407         unsigned long size;
67408         struct dma_buffparms *dmap = NULL;
67409 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
67410 +       int dev = iminor(file->f_dentry->d_inode);
67411  
67412         dev_class = dev & 0x0f;
67413         dev >>= 4;
67414 diff -Nru a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
67415 --- a/sound/oss/swarm_cs4297a.c Sun Aug  3 00:04:24 2003
67416 +++ b/sound/oss/swarm_cs4297a.c Tue Aug 26 09:25:41 2003
67417 @@ -1537,7 +1537,7 @@
67418  
67419  static int cs4297a_open_mixdev(struct inode *inode, struct file *file)
67420  {
67421 -       int minor = MINOR(inode->i_rdev);
67422 +       int minor = iminor(inode);
67423         struct cs4297a_state *s=NULL;
67424         struct list_head *entry;
67425  
67426 @@ -2386,7 +2386,7 @@
67427  
67428  static int cs4297a_open(struct inode *inode, struct file *file)
67429  {
67430 -       int minor = MINOR(inode->i_rdev);
67431 +       int minor = iminor(inode);
67432         struct cs4297a_state *s=NULL;
67433         struct list_head *entry;
67434  
67435 diff -Nru a/sound/oss/trident.c b/sound/oss/trident.c
67436 --- a/sound/oss/trident.c       Sat Aug  9 11:53:08 2003
67437 +++ b/sound/oss/trident.c       Tue Aug 26 09:25:41 2003
67438 @@ -2600,7 +2600,7 @@
67439  static int trident_open(struct inode *inode, struct file *file)
67440  {
67441         int i = 0;
67442 -       int minor = minor(inode->i_rdev);
67443 +       int minor = iminor(inode);
67444         struct trident_card *card = devs;
67445         struct trident_state *state = NULL;
67446         struct dmabuf *dmabuf = NULL;
67447 @@ -3883,7 +3883,7 @@
67448  static int trident_open_mixdev(struct inode *inode, struct file *file)
67449  {
67450         int i = 0;
67451 -       int minor = minor(inode->i_rdev);
67452 +       int minor = iminor(inode);
67453         struct trident_card *card = devs;
67454  
67455         for (card = devs; card != NULL; card = card->next)
67456 diff -Nru a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
67457 --- a/sound/oss/via82cxxx_audio.c       Sun Aug  3 00:05:26 2003
67458 +++ b/sound/oss/via82cxxx_audio.c       Tue Aug 26 09:25:41 2003
67459 @@ -1556,7 +1556,7 @@
67460  
67461  static int via_mixer_open (struct inode *inode, struct file *file)
67462  {
67463 -       int minor = minor(inode->i_rdev);
67464 +       int minor = iminor(inode);
67465         struct via_info *card;
67466         struct pci_dev *pdev = NULL;
67467         struct pci_driver *drvr;
67468 @@ -3252,7 +3252,7 @@
67469  
67470  static int via_dsp_open (struct inode *inode, struct file *file)
67471  {
67472 -       int minor = minor(inode->i_rdev);
67473 +       int minor = iminor(inode);
67474         struct via_info *card;
67475         struct pci_dev *pdev = NULL;
67476         struct via_channel *chan;
67477 diff -Nru a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
67478 --- a/sound/oss/vwsnd.c Mon Apr 21 00:32:53 2003
67479 +++ b/sound/oss/vwsnd.c Tue Aug 26 09:25:41 2003
67480 @@ -2916,7 +2916,7 @@
67481  static int vwsnd_audio_open(struct inode *inode, struct file *file)
67482  {
67483         vwsnd_dev_t *devc;
67484 -       dev_t minor = minor(inode->i_rdev);
67485 +       int minor = iminor(inode);
67486         int sw_samplefmt;
67487  
67488         DBGE("(inode=0x%p, file=0x%p)\n", inode, file);
67489 @@ -3063,7 +3063,7 @@
67490  
67491         INC_USE_COUNT;
67492         for (devc = vwsnd_dev_list; devc; devc = devc->next_dev)
67493 -               if (devc->mixer_minor == minor(inode->i_rdev))
67494 +               if (devc->mixer_minor == iminor(inode))
67495                         break;
67496  
67497         if (devc == NULL) {
67498 diff -Nru a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
67499 --- a/sound/oss/ymfpci.c        Mon Aug 18 22:27:20 2003
67500 +++ b/sound/oss/ymfpci.c        Tue Aug 26 09:25:41 2003
67501 @@ -1905,7 +1905,7 @@
67502         struct ymf_state *state;
67503         int err;
67504  
67505 -       minor = minor(inode->i_rdev);
67506 +       minor = iminor(inode);
67507         if ((minor & 0x0F) == 3) {      /* /dev/dspN */
67508                 ;
67509         } else {
67510 @@ -2019,7 +2019,7 @@
67511   */
67512  static int ymf_open_mixdev(struct inode *inode, struct file *file)
67513  {
67514 -       int minor = minor(inode->i_rdev);
67515 +       int minor = iminor(inode);
67516         struct list_head *list;
67517         ymfpci_t *unit;
67518         int i;
67519 diff -Nru a/sound/pcmcia/vx/vx_entry.c b/sound/pcmcia/vx/vx_entry.c
67520 --- a/sound/pcmcia/vx/vx_entry.c        Tue Jun 10 07:32:30 2003
67521 +++ b/sound/pcmcia/vx/vx_entry.c        Fri Aug 22 05:02:18 2003
67522 @@ -34,10 +34,8 @@
67523  static int vxpocket_event(event_t event, int priority, event_callback_args_t *args);
67524  
67525  
67526 -static void vxpocket_release(u_long arg)
67527 +static void vxpocket_release(dev_link_t* link)
67528  {
67529 -       dev_link_t *link = (dev_link_t *)arg;
67530 -       
67531         if (link->state & DEV_CONFIG) {
67532                 /* release cs resources */
67533                 CardServices(ReleaseConfiguration, link->handle);
67534 @@ -56,7 +54,7 @@
67535         struct snd_vxp_entry *hw;
67536         dev_link_t *link = &vxp->link;
67537  
67538 -       vxpocket_release((u_long)link);
67539 +       vxpocket_release(link);
67540  
67541         /* Break the link with Card Services */
67542         if (link->handle)
67543 @@ -148,9 +146,6 @@
67544         link->irq.Handler = &snd_vx_irq_handler;
67545         link->irq.Instance = chip;
67546  
67547 -       link->release.function = &vxpocket_release;
67548 -       link->release.data = (u_long)link;
67549 -
67550         link->conf.Attributes = CONF_ENABLE_IRQ;
67551         link->conf.Vcc = 50;
67552         link->conf.IntType = INT_MEMORY_AND_IO;
67553 @@ -229,8 +224,6 @@
67554  {
67555         vx_core_t *chip = snd_magic_cast(vx_core_t, link->priv, return);
67556  
67557 -       del_timer(&link->release);
67558 -
67559         snd_printdd(KERN_DEBUG "vxpocket_detach called\n");
67560         /* Remove the interface data from the linked list */
67561         if (hw) {
67562 @@ -326,7 +319,6 @@
67563                 snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n");
67564                 link->state &= ~DEV_PRESENT;
67565                 if (link->state & DEV_CONFIG) {
67566 -                       mod_timer(&link->release, jiffies + HZ/20);
67567                         chip->chip_status |= VX_STAT_IS_STALE;
67568                 }
67569                 break;
67570 diff -Nru a/sound/ppc/keywest.c b/sound/ppc/keywest.c
67571 --- a/sound/ppc/keywest.c       Tue May 20 14:13:01 2003
67572 +++ b/sound/ppc/keywest.c       Sun Aug 24 06:11:13 2003
67573 @@ -50,7 +50,7 @@
67574  
67575  
67576  #ifndef i2c_device_name
67577 -#define i2c_device_name(x)     ((x)->dev.name)
67578 +#define i2c_device_name(x)     ((x)->name)
67579  #endif
67580  
67581  static int keywest_attach_adapter(struct i2c_adapter *adapter)
67582 diff -Nru a/sound/sound_core.c b/sound/sound_core.c
67583 --- a/sound/sound_core.c        Sat May 17 12:39:14 2003
67584 +++ b/sound/sound_core.c        Tue Aug 26 09:25:41 2003
67585 @@ -483,7 +483,7 @@
67586  int soundcore_open(struct inode *inode, struct file *file)
67587  {
67588         int chain;
67589 -       int unit = minor(inode->i_rdev);
67590 +       int unit = iminor(inode);
67591         struct sound_unit *s;
67592         struct file_operations *new_fops = NULL;
67593  
This page took 6.121072 seconds and 3 git commands to generate.