PATCH: Linux 2.6.0-test support for rtl8139 and pci-scan

"G. Del Merritt" <[email protected]> Tue, 21 Oct 2003 14:28:06 -0400 (EDT)
Newsgroups gmane.linux.drivers.realtek.devel
Message-ID <[email protected]>
Below is a patch to let netdrivers-3.5 work under Linux 2.6.0. As I note in
the ChangeLog, since I only have the Realtek card, I didn't feel I should
change the other modules that I have no intention of compiling or testing.

Side notes, not covered in the ChangeLog below: I am still learning 2.6, and -
as noted - this change works under 2.6.0-test8, which is the latest checkpoint
in the 2.6 world as of this time.  I have yet to come across the kernel
documentation that points to "/lib/modules/`uname -r`/extra".  I got the hint
for this set of changes from http://lwn.net/Articles/21823/, but note that I
don't see a graceful way to just say "make" and have it all work for the
"current kernel".  Note too that the Makefile as I've patched it AssUMes your
"make" can handle conditionals.  YMMV.  The "make clean" target tries to clean
up the new temporary files from the new kernel module build process; the
"make" that includes "SUBDIRS=" and "clean" doesn't work as I want, though
arguably it does work as expected.  Finally, I've had this kernel up only
since last night and the tweaked rtl8139 and pci-scan modules since just
before noon, EDT.  Sic caveat emptor.

I would be happy to submit this patch in a different format if it makes life
simpler.  I intentionally didn't gzip and uuencode it because the patch is
pretty short.  The diff command options and directory order is supposedly the
"standard" way to do a kernel patch.

-Del

---------------------- 8< patch starts here 8< ----------------------
diff --unified --recursive --new-file netdrivers-3.5-gdm/ChangeLog netdrivers-3.5/ChangeLog
--- netdrivers-3.5-gdm/ChangeLog	2003-10-21 13:53:54.818182821 -0400
+++ netdrivers-3.5/ChangeLog	1969-12-31 19:00:00.000000000 -0500
@@ -1,20 +0,0 @@
-2003-10-21  G. Del Merritt  <[email protected]>
-
-	* Modified Makefile, along with pci-scan and Realtek modules, to
-	compile and link under Linux kernel 2.6.0-test8.  From the
-	documentation I surmise this should work for most 2.5 kernels too,
-	but that's all development stuff.  At the risk of being redundant:
-
-	See Documentation/kbuild/makefiles.txt in your kernel source tree.
-	A quick summary of that is:  
-	
-	    Try to play nice in the 2.5/2.6 kernel world.  In that world,
-	    you should type: 
-	       # make -C YOURKERNELSRCDIR SUBDIRS=THISDIR modules
-	       # make -C YOURKERNELSRCDIR SUBDIRS=THISDIR modules_install
-	
-	where YOURKERNELSRCDIR is something like "/usr/src/linux-2.6.0-test8" and
-	THISDIR is something like "/usr/local/src/netdrivers-3.5/".  There are other
-	ways to do it, but that worked for me.  As of -test8, the
-	modules_install step didn't echo the new driver modules, but did
-	silently put them into "/lib/modules/2.6.0-test8/extra/".
diff --unified --recursive --new-file netdrivers-3.5-gdm/Makefile netdrivers-3.5/Makefile
--- netdrivers-3.5-gdm/Makefile	2003-10-21 13:51:42.347151883 -0400
+++ netdrivers-3.5/Makefile	2002-11-17 10:46:23.000000000 -0500
@@ -13,30 +13,8 @@
 #  PCMCIA        The include file for the PCMCIA subsystem.
 #
 # Setting KERNVER may allow this Makefile to guess the above.
-#
-# Try to play nice in the 2.5/2.6 kernel world.  In that world, you should type:
-#   # make -C YOURKERNELSRCDIR SUBDIRS=THISDIR modules
-#   # make -C YOURKERNELSRCDIR SUBDIRS=THISDIR modules_install
-# where YOURKERNELSRCDIR is something like "/usr/src/linux-2.6.0-test8" and
-# THISDIR is something like "/usr/local/src/netdrivers-3.5/".  There are other
-# ways to do it, but that worked for me.
-# 
 # $id$
 
-ifneq ($(KERNELRELEASE),)
-
-# Hey, I only have a Realtek-based board, so that's what I know works.
-obj-m := pci-scan.o
-obj-m += rtl8139.o
-
-# add other "netdrivers" modules as you clean up and test them.  See
-# Documentation/kbuild/makefiles.txt in your 2.6 (and 2.5?) source tree. 
-
-# Um, you might think this was the right place; maybe, some day.
-clean:
-	-rm -f *.o *.ko *.mod.c *.o.cmd netdrivers.tgz ChangeLog
-else
-
 # PREFIX may be set by the RPM build to set the effective root.
 PREFIX=
 # Set KERNVER on the command line to build modules for a kernel other than
@@ -194,5 +172,4 @@
 .PHONEY: all clean install cardbus tar
 
 clean:
-	-rm -f *.o *.ko *.mod.c .*.o.cmd .*.ko.cmd netdrivers.tgz ChangeLog
-endif
+	-rm -f *.o netdrivers.tgz ChangeLog
diff --unified --recursive --new-file netdrivers-3.5-gdm/pci-scan.c netdrivers-3.5/pci-scan.c
--- netdrivers-3.5-gdm/pci-scan.c	2003-10-21 13:30:43.736201734 -0400
+++ netdrivers-3.5/pci-scan.c	2003-07-31 16:08:25.000000000 -0400
@@ -18,7 +18,6 @@
 	Annapolis MD 21403
 
 	Other contributers:
-    First-cut 2.6 kernel support by Del <[email protected]>.
 */
 static const char version[] =
 "pci-scan.c:v1.12 7/30/2003  Donald Becker <[email protected]>"
@@ -43,11 +42,6 @@
 #endif
 
 #include <linux/config.h>
-
-#if !defined(KERNEL_VERSION)
-#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#endif
-
 #if defined(CONFIG_SMP) && ! defined(__SMP__)
 #define __SMP__
 #endif
@@ -56,7 +50,7 @@
 #endif
 
 #include <linux/version.h>
-#if defined(MODVERSIONS) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+#if defined(MODVERSIONS)
 #include <linux/modversions.h>
 #endif
 #if LINUX_VERSION_CODE < 0x20500  &&  defined(MODVERSIONS)
@@ -656,15 +650,6 @@
 
 
 /*
- * Special note: Building for Linux 2.[56]?  See Documentation/kbuild/makefiles.txt 
- * in your kernel source tree.  A quick summary of that is:
- *   Try to play nice in the 2.5/2.6 kernel world.  In that world, you should type:
- *     # make -C YOURKERNELSRCDIR SUBDIRS=THISDIR modules
- *     # make -C YOURKERNELSRCDIR SUBDIRS=THISDIR modules_install
- *   where YOURKERNELSRCDIR is something like "/usr/src/linux-2.6.0-test8" and
- *   THISDIR is something like "/usr/local/src/netdrivers-3.5/".  There are other
- *   ways to do it, but that worked for me.
- *
  * Local variables:
  *  compile-command: "gcc -DMODULE -D__KERNEL__ -DEXPORT_SYMTAB -Wall -Wstrict-prototypes -O6 -c pci-scan.c"
  *  c-indent-level: 4
diff --unified --recursive --new-file netdrivers-3.5-gdm/rtl8139.c netdrivers-3.5/rtl8139.c
--- netdrivers-3.5-gdm/rtl8139.c	2003-10-21 13:30:05.711539835 -0400
+++ netdrivers-3.5/rtl8139.c	2003-08-24 11:03:23.000000000 -0400
@@ -20,7 +20,6 @@
 	http://www.scyld.com/network/rtl8139.html
 
 	Twister-tuning table provided by Kinston <[email protected]>.
-    First-cut 2.6 kernel support by Del <[email protected]>.
 */
 
 /* These identify the driver base version and may not be removed. */
@@ -99,12 +98,7 @@
 #endif
 
 #include <linux/version.h>
-
-#if !defined(KERNEL_VERSION)
-#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#endif
-
-#if defined(MODVERSIONS) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+#if defined(MODVERSIONS)
 #include <linux/modversions.h>
 #endif
 #include <linux/module.h>
@@ -1731,15 +1725,6 @@
 #endif  /* MODULE */
 
 /*
- * Special note: Building for Linux 2.[56]?  See Documentation/kbuild/makefiles.txt 
- * in your kernel source tree.  A quick summary of that is:
- *   Try to play nice in the 2.5/2.6 kernel world.  In that world, you should type:
- *     # make -C YOURKERNELSRCDIR SUBDIRS=THISDIR modules
- *     # make -C YOURKERNELSRCDIR SUBDIRS=THISDIR modules_install
- *   where YOURKERNELSRCDIR is something like "/usr/src/linux-2.6.0-test8" and
- *   THISDIR is something like "/usr/local/src/netdrivers-3.5/".  There are other
- *   ways to do it, but that worked for me.
- *
  * Local variables:
  *  compile-command: "make KERNVER=`uname -r` rtl8139.o"
  *  compile-cmd: "gcc -DMODULE -Wall -Wstrict-prototypes -O6 -c rtl8139.c"