| [15] | 1 | /* |
|---|
| [96] | 2 | compat.h - Part of lm_sensors, Linux kernel modules for hardware |
|---|
| 3 | monitoring |
|---|
| [207] | 4 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
|---|
| [15] | 5 | |
|---|
| 6 | This program is free software; you can redistribute it and/or modify |
|---|
| 7 | it under the terms of the GNU General Public License as published by |
|---|
| 8 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | This program is distributed in the hope that it will be useful, |
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | GNU General Public License for more details. |
|---|
| 15 | |
|---|
| 16 | You should have received a copy of the GNU General Public License |
|---|
| 17 | along with this program; if not, write to the Free Software |
|---|
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #ifndef SENSORS_COMPAT_H |
|---|
| 22 | #define SENSORS_COMPAT_H |
|---|
| 23 | |
|---|
| 24 | /* This useful macro is not defined in the 2.0 kernels */ |
|---|
| 25 | |
|---|
| 26 | #include <linux/version.h> |
|---|
| 27 | #ifndef KERNEL_VERSION |
|---|
| 28 | #define KERNEL_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c)) |
|---|
| 29 | #endif |
|---|
| 30 | |
|---|
| 31 | #ifdef MODULE |
|---|
| 32 | #include <linux/module.h> |
|---|
| 33 | #ifndef MODULE_AUTHOR |
|---|
| 34 | #define MODULE_AUTHOR(whatever) |
|---|
| 35 | #endif |
|---|
| 36 | #ifndef MODULE_DESCRIPTION |
|---|
| 37 | #define MODULE_DESCRIPTION(whatever) |
|---|
| 38 | #endif |
|---|
| 39 | #endif /* def MODULE */ |
|---|
| 40 | |
|---|
| [22] | 41 | /* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels |
|---|
| 42 | get_user was redefined in 2.1 kernels to use two arguments, and returns |
|---|
| 43 | an error code */ |
|---|
| [19] | 44 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4)) |
|---|
| 45 | #define copy_from_user memcpy_fromfs |
|---|
| 46 | #define copy_to_user memcpy_tofs |
|---|
| 47 | #define get_user_data(to,from) ((to) = get_user(from),0) |
|---|
| 48 | #else |
|---|
| [22] | 49 | #include <asm/uaccess.h> |
|---|
| [19] | 50 | #define get_user_data(to,from) get_user(to,from) |
|---|
| 51 | #endif |
|---|
| 52 | |
|---|
| [37] | 53 | /* Add a scheduling fix for the new code in kernel 2.1.127 */ |
|---|
| 54 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,127)) |
|---|
| 55 | #define schedule_timeout(x) ( current->timeout = jiffies + (x), schedule() ) |
|---|
| 56 | #endif |
|---|
| 57 | |
|---|
| [34] | 58 | /* If the new PCI interface is not present, fall back on the old PCI BIOS |
|---|
| 59 | interface. We also define some things to unite both interfaces. Not |
|---|
| 60 | very nice, but it works like a charm. |
|---|
| 61 | device is the 2.1 struct pci_dev, bus is the 2.0 bus number, dev is the |
|---|
| 62 | 2.0 device/function code, com is the PCI command, and res is the result. */ |
|---|
| 63 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,54)) |
|---|
| 64 | #define pci_present pcibios_present |
|---|
| 65 | #define pci_read_config_byte_united(device,bus,dev,com,res) \ |
|---|
| [379] | 66 | pcibios_read_config_byte(bus,dev,com,res) |
|---|
| [34] | 67 | #define pci_read_config_word_united(device,bus,dev,com,res) \ |
|---|
| [379] | 68 | pcibios_read_config_word(bus,dev,com,res) |
|---|
| [34] | 69 | #define pci_write_config_byte_united(device,bus,dev,com,res) \ |
|---|
| [379] | 70 | pcibios_write_config_byte(bus,dev,com,res) |
|---|
| [34] | 71 | #define pci_write_config_word_united(device,bus,dev,com,res) \ |
|---|
| [379] | 72 | pcibios_write_config_word(bus,dev,com,res) |
|---|
| [34] | 73 | #else |
|---|
| 74 | #define pci_read_config_byte_united(device,bus,dev,com,res) \ |
|---|
| [379] | 75 | pci_read_config_byte(device,com,res) |
|---|
| [34] | 76 | #define pci_read_config_word_united(device,bus,dev,com,res) \ |
|---|
| [379] | 77 | pci_read_config_word(device,com,res) |
|---|
| [34] | 78 | #define pci_write_config_byte_united(device,bus,dev,com,res) \ |
|---|
| [379] | 79 | pci_write_config_byte(device,com,res) |
|---|
| [34] | 80 | #define pci_write_config_word_united(device,bus,dev,com,res) \ |
|---|
| [379] | 81 | pci_write_config_byte(device,com,res) |
|---|
| [34] | 82 | #endif |
|---|
| [19] | 83 | |
|---|
| [442] | 84 | /* I hope this is always correct, even for the PPC, but I really think so. |
|---|
| 85 | And yes, the kernel version is exactly correct */ |
|---|
| 86 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)) |
|---|
| 87 | #include <linux/mm.h> |
|---|
| 88 | #define ioremap vremap |
|---|
| 89 | #define iounmap vfree |
|---|
| 90 | #endif |
|---|
| [34] | 91 | |
|---|
| [15] | 92 | #endif /* SENSORS_COMPAT_H */ |
|---|