patch from abbotti@mev.co.uk (Ian Abbott):
authorFrank Mori Hess <fmhess@speakeasy.net>
Mon, 25 Jul 2005 02:10:39 +0000 (02:10 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Mon, 25 Jul 2005 02:10:39 +0000 (02:10 +0000)
The class_simple interface has been removed - mostly a renaming exercise.
Comedi needs to use the new interface with some compatibility stuff for older
kernels.

The patch has been tested on 2.4.28, 2.6.12 and
2.6.13-rc1 and seems to work.

INSTALL
comedi/comedi_fops.c
include/linux/device.h

diff --git a/INSTALL b/INSTALL
index 411d1fb011464dc864afe2e9165bc10760878b54..56b077d6a0b8773b014bd4381cc09abb17fff351 100644 (file)
--- a/INSTALL
+++ b/INSTALL
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
+Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+These are generic installation instructions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  (Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.)
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a
+time in the source code directory.  After you have installed the
+package for one architecture, use `make distclean' before reconfiguring
+for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PREFIX', the package will
+use PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the `--target=TYPE' option to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
 
-* Linux source:
-
-In order to compile the Comedi modules, you will need to have
-a correctly configured Linux kernel source tree.  The best
-way to get one is to download a tarball from kernel.org and
-compile your own kernel.  Comedi should work with most 2.2, 
-2.4, and 2.6 Linux kernels.  2.6.x kernels older than 2.6.6 are
-not supported.  Support for 2.0.3x is not actively maintained,
-but it should work and bugs will be fixed as they are reported.
-
-You can also prepare a kernel source tree that matches
-the kernel you are currently running if you have its config file (in
-the Debian distibution the config files for the kernel-image packages
-are installed into the /boot directory).  The following steps will
-(almost) set up your kernel sources correctly.  You will also need
-write permission to the kernel source directory the first time you
-run comedi's configure script, so you might want to unpack the kernel
-source into a directory you own.
-
-1) Get a copy of the kernel source that matches the kernel you are
-       running.  Unpack it and copy your kernel config file to '.config'
-       in the top directory of your kernel source.
-2) You might need to edit the file 'Makefile' in the kernel source.
-       At the top of the Makefile, the variable EXTRAVERSION is defined.
-       If necessary, change it to match your kernel (for example, if the command
-       'uname -r' produces "2.4.16-386" then your EXTRAVERSION should be
-       set as 'EXTRAVERSION=-386'.
-3) Run 'make oldconfig' in your kernel source directory.
-4) Run 'make dep' (for 2.6 kernels, do a 'make modules_prepare' instead 
-       or even better a full 'make') in the kernel source directory and 
-       you are done.
-
-Red Hat users note: Kernel sources that are distributed with Red
-Hat Linux are not supported, because they are too heavily
-modified.  However, there is some information in
-Documentation/comedi/redhat-notes on how to use Red Hat kernels.
-
-* RTAI support:
-
-If you want to use the real-time capabilities of Comedi with
-RTAI, you need to compile and install RTAI first.  If you
-don't install the rtai kernel modules, you may get unresolved
-symbols when installing the comedi kernel modules.
-
-* RTLinux support:
-
-If you want to use the real-time capabilities of Comedi with
-RTLinux, you need to compile RTLinux (both the kernel and the
-modules) first.  Known working versions are 2.x and 3.0.
-
-* Configuration:
-
-Configure with './configure'.  './configure --help' will give the
-configuration options.  If the configure script does not exist
-(if you checked comedi out from cvs for example), it can
-be generated by running './autogen.sh'.  The autoconf, automake,
-autoheader, etc. tools are required to generate the configure
-script (automake version >= 1.7 recommended).  The --with-linuxdir
-option is particularly useful, as it allows you to specify
-the location of your Linux kernel source directory.  If
-you are using an RT-patched kernel, the --with-rtaidir or
---with-rtlinuxdir options allow you to specify
-the location of your RTAI or RTLinux source directory.
-
-* Compiling:
-
-Compile using 'make'.  If this fails for some reason, send the
-_entire_ build log to the mailing list.  Without the build
-log, it is impossible to find problems.
-
-* Installation:
-
-Install using 'make install' as root.  This installs the files:
-
-  /lib/modules/<<kernel version>>/comedi/comedi.o
-  /lib/modules/<<kernel version>>/comedi/kcomedilib.o
-  /lib/modules/<<kernel version>>/comedi/<<driver files>>.o
-
-You need to create device files to access the hardware from a
-user process.  These can be created using 'make dev'.  The following
-special files will be created:
-
-  /dev/comedi0
-  /dev/comedi1
-  /dev/comedi2
-  ...
-  /dev/comedi15
-
-* Comedilib:
-
-Now would be a good time to compile and install Comedilib.  Comedi
-and Comedilib are completely independent, so it doesn't matter
-which is installed first.
-
-* Running Comedi:
-
-To use comedi, the driver module and the core Comedi modules must
-be loaded into the kernel.  This is done by a command similar to
-
-  /sbin/modprobe <<driver>>
-
-If your module dependencies are set up correctly, this will load
-both comedi.o and your driver.  If you get unresolved symbols, check
-the FAQ or the mailing list archives.  Also look at the man pages
-for modprobe and insmod.
-
-In order to configure a driver module to use a particular device
-file (/dev/comediN) and a particular device, you need to use the
-command 'comedi_config', which is part of the comedilib
-distribution.  Comedi_config is invoked using
-
-  comedi_config /dev/comedi0 <device name> <option list>
-
-The device name may or may not be the same as the module name.  In
-general, if the device type can be autoprobed (as with ISA PnP or
-PCI devices), the device name will be the same as the module name.
-Otherwise, you will need to check Documentation/comedi/drivers.txt
-for information about what device name is appropriate for your
-hardware.  The option list is to supply additional information,
-such as I/O address, IRQ, DMA channels, and other jumper settings.
-Information about option lists appropriate for a driver is in
-drivers.txt.  The following commands are examples:
-
-  comedi_config /dev/comedi0 dt2821 0x240,3
-  comedi_config /dev/comedi1 ni_atmio 0x260,4
-  comedi_config /dev/comedi2 dt2817 0x228
-  comedi_config /dev/comedi3 ni_pcimio
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).  Here is a another example:
+
+     /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
+configuration-related scripts to be executed by `/bin/bash'.
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
 
-Try a 'man comedi_config' for information on how to use
-this utility.  Scripts have been written for a few of the drivers
-with very complicated option lists -- these are found in the etc
-directory.
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
 
-* Module Autoloading:
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
 
-If you like to autoload your modules, put the following lines
-into /etc/modules.conf (this does not apply for PCMCIA cards):
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
 
-  alias char-major-98 comedi
-  alias char-major-98-0 your_driver
-  post-install your_driver PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH;comedi_config /dev/comedi0 board_name <<options>>
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
 
-Alternatively, for complicated option lists, the scripts in etc
-are designed to be copied into /etc, so that you could put the
-following lines into /etc/conf.modules:
-
-  alias char-major-98-0 dt282x
-  post-install dt282x /etc/dt282x.conf
-
-If your board has self-calibration capabilities,
-will want to run comedi_calibrate, an autocalibration tool that is part
-of comedilib, in a bootup script.
-
-* PCMCIA:
-
-Linux-2.4 kernels are recommended for PCMCIA drivers, since 2.2
-kernel require the separate PCMCIA package.  It is possible to
-use 2.2 kernels with PCMCIA, although it is necessary to modify
-the top level Makefile.
-
-Comedi works with several PCMCIA cards, and the driver modules can
-be loaded and unloaded upon insertion and removal of the card.
-The necessary configuration files are in the Comedilib source
-package.  Copy the files in etc/pcmcia/ to /etc/pcmcia and restart
-card services.  The pcmcia script provided is very simple -- it only
-uses /dev/comedi0 for devices, which is a limitation if you have
-other Comedi devices in your system.
-
-* Upgrading:
-
-From versions prior to 0.6.0, you will need to edit and recompile
-all programs that use comedi or comedilib, since the names of
-functions and ioctls have changed.
-
-From versions prior to 0.5.0, you will need to recompile all programs
-that use comedi or comedilib, since the interface to both of these has
-changed.  No changes should need to be made to the source of the
-programs.  The format for parameters of comedi_config has changed.
-
-From versions prior to 0.4.0, you will need to run 'make dev' again
-to recreate /dev/comedi*, since the major number has changed.
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
 
index d012c02917ee56c077065d2b0bd88a7b2ae1ad59..b53ed544c6bf361d90e91742130f2d1cc245171b 100644 (file)
@@ -1784,7 +1784,7 @@ static struct file_operations comedi_fops={
 };
 #endif
 
-static struct class_simple *comedi_class;
+static struct class *comedi_class;
 
 static int __init comedi_init(void)
 {
@@ -1795,7 +1795,7 @@ static int __init comedi_init(void)
                printk("comedi: unable to get major %d\n",COMEDI_MAJOR);
                return -EIO;
        }
-       comedi_class = class_simple_create(THIS_MODULE, "comedi");
+       comedi_class = class_create(THIS_MODULE, "comedi");
        if(IS_ERR(comedi_class))
        {
                printk("comedi: failed to create class");
@@ -1805,7 +1805,7 @@ static int __init comedi_init(void)
        comedi_devices=(comedi_device *)kmalloc(sizeof(comedi_device)*COMEDI_NDEVICES,GFP_KERNEL);
        if(!comedi_devices)
        {
-               class_simple_destroy(comedi_class);
+               class_destroy(comedi_class);
                devfs_unregister_chrdev(COMEDI_MAJOR,"comedi");
                return -ENOMEM;
        }
@@ -1823,7 +1823,7 @@ static int __init comedi_init(void)
                sprintf(name, "comedi%d", i);
                devfs_register(NULL, name, DEVFS_FL_DEFAULT,
                        COMEDI_MAJOR, i, 0666 | S_IFCHR, &comedi_fops, NULL);
-               class_simple_device_add(comedi_class, MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i", i);
+               class_device_create(comedi_class, MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i", i);
        }
 
        comedi_rt_init();
@@ -1840,12 +1840,12 @@ static void __exit comedi_cleanup(void)
 
        for(i=0;i<COMEDI_NDEVICES;i++){
                char name[20];
-               class_simple_device_remove(MKDEV(COMEDI_MAJOR, i));
+               class_device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, i));
                sprintf(name, "comedi%d", i);
                devfs_unregister(devfs_find_handle(NULL, name,
                        COMEDI_MAJOR, i, DEVFS_SPECIAL_CHR, 0));
        }
-       class_simple_destroy(comedi_class);
+       class_destroy(comedi_class);
        devfs_unregister_chrdev(COMEDI_MAJOR,"comedi");
 
        comedi_proc_cleanup();
index 7f3bf34eb8f76820100ba1199a334b8ec3342bc1..47da6ddd46de10e324f94b6ab1513aef7239e97e 100644 (file)
@@ -15,32 +15,42 @@ struct device_driver
        char *name;
 };
 
-typedef void class_simple;
+struct class;
+struct class_device;
+struct device;
 
-struct device
-{
-       void *dummy;
-};
-
-static inline struct class_simple *class_simple_create(struct module *owner, char *name)
+static inline struct class *class_create(struct module *owner, char *name)
 {
        return NULL;
 };
 
-static inline void class_simple_destroy(struct class_simple *cs)
+static inline void class_destroy(struct class *cs)
 {};
 
-static inline struct class_device *class_simple_device_add(struct class_simple *cs, 
+static inline struct class_device *class_device_create(struct class *cs, 
        dev_t dev, struct device *device, const char *fmt, ...)
 {
        return NULL;
 };
 
-static inline void class_simple_device_remove(dev_t dev)
+static inline void class_device_destroy(struct class *cs, dev_t dev)
 {};
 
 #else
 #include_next <linux/device.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
+#define class_create(owner, name) \
+       (struct class *)class_simple_create(owner, name)
+#define class_destroy(cs) \
+       class_simple_destroy((struct class_simple *)(cs))
+#define class_device_create(cs, dev, device, fmt...) \
+       class_simple_device_add((struct class_simple *)(cs), \
+               dev, device, fmt)
+#define class_device_destroy(cs, dev) \
+       class_simple_device_remove(dev)
+#endif
+
 #endif
 
 #endif // __COMPAT_LINUX_DEVICE_H_